diff --git a/source/gui/CGUIText.cpp b/source/gui/CGUIText.cpp index 2aaff39bc6..73e9c29fb4 100644 --- a/source/gui/CGUIText.cpp +++ b/source/gui/CGUIText.cpp @@ -79,7 +79,7 @@ CGUIText::CGUIText(const CGUI& pGUI, const CGUIString& string, const CStrW& Font // get the alignment type for the control we are computing the text for since // we are computing the horizontal alignment in this method in order to not have // to run through the TextCalls a second time in the CalculateTextPosition method again - EAlign align = EAlign_Left; + EAlign align = EAlign::LEFT; if (pObject->SettingExists("text_align")) align = pObject->GetSetting("text_align"); @@ -319,14 +319,14 @@ float CGUIText::GetLineOffset( { switch (align) { - case EAlign_Left: + case EAlign::LEFT: // don't add an offset return 0.f; - case EAlign_Center: + case EAlign::CENTER: return ((width_range_to - width_range_from) - line_size.cx) / 2; - case EAlign_Right: + case EAlign::RIGHT: return width_range_to - line_size.cx; default: diff --git a/source/gui/GUIStringConversions.cpp b/source/gui/GUIStringConversions.cpp index 976703f48d..a11403f1ec 100644 --- a/source/gui/GUIStringConversions.cpp +++ b/source/gui/GUIStringConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -179,11 +179,11 @@ template <> bool CGUI::ParseString(const CGUI* UNUSED(pGUI), const CStrW& Value, EAlign& Output) { if (Value == L"left") - Output = EAlign_Left; + Output = EAlign::LEFT; else if (Value == L"center") - Output = EAlign_Center; + Output = EAlign::CENTER; else if (Value == L"right") - Output = EAlign_Right; + Output = EAlign::RIGHT; else return false; @@ -194,11 +194,11 @@ template <> bool CGUI::ParseString(const CGUI* UNUSED(pGUI), const CStrW& Value, EVAlign& Output) { if (Value == L"top") - Output = EVAlign_Top; + Output = EVAlign::TOP; else if (Value == L"center") - Output = EVAlign_Center; + Output = EVAlign::CENTER; else if (Value == L"bottom") - Output = EVAlign_Bottom; + Output = EVAlign::BOTTOM; else return false; diff --git a/source/gui/ObjectBases/IGUITextOwner.cpp b/source/gui/ObjectBases/IGUITextOwner.cpp index e2a313d618..8268975296 100644 --- a/source/gui/ObjectBases/IGUITextOwner.cpp +++ b/source/gui/ObjectBases/IGUITextOwner.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -106,14 +106,14 @@ void IGUITextOwner::CalculateTextPosition(CRect& ObjSize, CPos& TextPos, CGUITex switch (m_pObject.GetSetting("text_valign")) { - case EVAlign_Top: + case EVAlign::TOP: TextPos.y = ObjSize.top; break; - case EVAlign_Center: + case EVAlign::CENTER: // Round to integer pixel values, else the fonts look awful TextPos.y = floorf(ObjSize.CenterPoint().y - Text.GetSize().cy / 2.f); break; - case EVAlign_Bottom: + case EVAlign::BOTTOM: TextPos.y = ObjSize.bottom - Text.GetSize().cy; break; default: diff --git a/source/gui/ObjectTypes/CTooltip.cpp b/source/gui/ObjectTypes/CTooltip.cpp index c232dff669..965eca50cb 100644 --- a/source/gui/ObjectTypes/CTooltip.cpp +++ b/source/gui/ObjectTypes/CTooltip.cpp @@ -65,8 +65,8 @@ CTooltip::CTooltip(CGUI& pGUI) // Defaults SetSetting("delay", 500, true); - SetSetting("anchor", EVAlign_Bottom, true); - SetSetting("text_align", EAlign_Left, true); + SetSetting("anchor", EVAlign::BOTTOM, true); + SetSetting("text_align", EAlign::LEFT, true); // Set up a blank piece of text, to be replaced with a more // interesting message later @@ -96,15 +96,15 @@ void CTooltip::SetupText() switch (m_Anchor) { - case EVAlign_Top: + case EVAlign::TOP: size.pixel.top = mousepos.y + m_Offset.y; size.pixel.bottom = size.pixel.top + textheight; break; - case EVAlign_Bottom: + case EVAlign::BOTTOM: size.pixel.bottom = mousepos.y + m_Offset.y; size.pixel.top = size.pixel.bottom - textheight; break; - case EVAlign_Center: + case EVAlign::CENTER: size.pixel.top = mousepos.y + m_Offset.y - textheight/2.f; size.pixel.bottom = size.pixel.top + textwidth; break; diff --git a/source/gui/Scripting/GuiScriptConversions.cpp b/source/gui/Scripting/GuiScriptConversions.cpp index 2859e3e788..f07e7f37f6 100644 --- a/source/gui/Scripting/GuiScriptConversions.cpp +++ b/source/gui/Scripting/GuiScriptConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -259,15 +259,15 @@ template<> void ScriptInterface::ToJSVal(const ScriptRequest& rq, JS::M std::string word; switch (val) { - case EVAlign_Top: + case EVAlign::TOP: word = "top"; break; - case EVAlign_Bottom: + case EVAlign::BOTTOM: word = "bottom"; break; - case EVAlign_Center: + case EVAlign::CENTER: word = "center"; break; @@ -285,14 +285,14 @@ template<> bool ScriptInterface::FromJSVal(const ScriptRequest& rq, JS: FromJSVal(rq, v, word); if (word == "top") - out = EVAlign_Top; + out = EVAlign::TOP; else if (word == "bottom") - out = EVAlign_Bottom; + out = EVAlign::BOTTOM; else if (word == "center") - out = EVAlign_Center; + out = EVAlign::CENTER; else { - out = EVAlign_Top; + out = EVAlign::TOP; LOGERROR("Invalid alignment (should be 'left', 'right' or 'center')"); return false; } @@ -304,13 +304,13 @@ template<> void ScriptInterface::ToJSVal(const ScriptRequest& rq, JS::Mu std::string word; switch (val) { - case EAlign_Left: + case EAlign::LEFT: word = "left"; break; - case EAlign_Right: + case EAlign::RIGHT: word = "right"; break; - case EAlign_Center: + case EAlign::CENTER: word = "center"; break; default: @@ -327,14 +327,14 @@ template<> bool ScriptInterface::FromJSVal(const ScriptRequest& rq, JS:: FromJSVal(rq, v, word); if (word == "left") - out = EAlign_Left; + out = EAlign::LEFT; else if (word == "right") - out = EAlign_Right; + out = EAlign::RIGHT; else if (word == "center") - out = EAlign_Center; + out = EAlign::CENTER; else { - out = EAlign_Left; + out = EAlign::LEFT; LOGERROR("Invalid alignment (should be 'left', 'right' or 'center')"); return false; } diff --git a/source/gui/SettingTypes/EAlign.h b/source/gui/SettingTypes/EAlign.h index 892732f9ce..77e523ccb7 100644 --- a/source/gui/SettingTypes/EAlign.h +++ b/source/gui/SettingTypes/EAlign.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -18,7 +18,18 @@ #ifndef INCLUDED_EALIGN #define INCLUDED_EALIGN -enum EAlign { EAlign_Left, EAlign_Right, EAlign_Center }; -enum EVAlign { EVAlign_Top, EVAlign_Bottom, EVAlign_Center }; +enum EAlign +{ + LEFT, + RIGHT, + CENTER +}; + +enum class EVAlign +{ + TOP, + BOTTOM, + CENTER +}; #endif // INCLUDED_EALIGN