Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.

Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.

Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.

Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts

This was SVN commit r22796.
This commit is contained in:
elexis
2019-08-28 11:21:11 +00:00
parent 36e2c1caf8
commit 1a49ccb294
19 changed files with 203 additions and 231 deletions
+5 -5
View File
@@ -30,7 +30,7 @@ CTooltip::CTooltip(CGUI& pGUI)
AddSetting<CGUIString>("caption");
AddSetting<CStrW>("font");
AddSetting<CGUISpriteInstance>("sprite");
AddSetting<int>("delay");
AddSetting<i32>("delay"); // in milliseconds
AddSetting<CGUIColor>("textcolor");
AddSetting<float>("maxwidth");
AddSetting<CPos>("offset");
@@ -48,9 +48,9 @@ CTooltip::CTooltip(CGUI& pGUI)
AddSetting<CPos>("_mousepos");
// Defaults
GUI<int>::SetSetting(this, "delay", 500);
GUI<EVAlign>::SetSetting(this, "anchor", EVAlign_Bottom);
GUI<EAlign>::SetSetting(this, "text_align", EAlign_Left);
SetSetting<i32>("delay", 500, true);
SetSetting<EVAlign>("anchor", EVAlign_Bottom, true);
SetSetting<EAlign>("text_align", EAlign_Left, true);
// Set up a blank piece of text, to be replaced with a more
// interesting message later
@@ -123,7 +123,7 @@ void CTooltip::SetupText()
else if (size.pixel.right > screenw)
size.pixel.left -= (size.pixel.right-screenw), size.pixel.right = screenw;
GUI<CClientArea>::SetSetting(this, "size", size);
SetSetting<CClientArea>("size", size, true);
}
void CTooltip::HandleMessage(SGUIMessage& Message)