forked from mirrors/0ad
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 from92b6cdfeab). That also simplifies std::function SetSettingWrap construct from0a7d0ecddeto 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, refsd87057b1c0,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:
+28
-14
@@ -33,7 +33,6 @@
|
||||
#include "lib/input.h" // just for IN_PASS
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -159,6 +158,29 @@ public:
|
||||
template <typename T>
|
||||
const T& GetSetting(const CStr& Setting) const;
|
||||
|
||||
/**
|
||||
* Set a setting by string, regardless of what type it is.
|
||||
* Used to parse setting values from XML files.
|
||||
* For example a CRect(10,10,20,20) is created from "10 10 20 20".
|
||||
* Returns false if the conversion fails, otherwise true.
|
||||
*/
|
||||
bool SetSettingFromString(const CStr& Setting, const CStrW& Value, const bool SendMessage);
|
||||
|
||||
/**
|
||||
* Assigns the given value to the setting identified by the given name.
|
||||
* Uses move semantics, so do not read from Value after this call.
|
||||
*
|
||||
* @param SendMessage If true, a GUIM_SETTINGS_UPDATED message will be broadcasted to all GUI objects.
|
||||
*/
|
||||
template <typename T>
|
||||
void SetSetting(const CStr& Setting, T& Value, const bool SendMessage);
|
||||
|
||||
/**
|
||||
* This variant will copy the value.
|
||||
*/
|
||||
template <typename T>
|
||||
void SetSetting(const CStr& Setting, const T& Value, const bool SendMessage);
|
||||
|
||||
/**
|
||||
* Returns whether this is object is set to be hidden.
|
||||
*/
|
||||
@@ -181,19 +203,6 @@ public:
|
||||
*/
|
||||
virtual void ResetStates();
|
||||
|
||||
/**
|
||||
* Set a setting by string, regardless of what type it is.
|
||||
*
|
||||
* example a CRect(10,10,20,20) would be "10 10 20 20"
|
||||
*
|
||||
* @param Setting Setting by name
|
||||
* @param Value Value to set to
|
||||
* @param SkipMessage Does not send a GUIM_SETTINGS_UPDATED if true
|
||||
*
|
||||
* @return PSRETURN (PSRETURN_OK if successful)
|
||||
*/
|
||||
PSRETURN SetSetting(const CStr& Setting, const CStrW& Value, const bool& SkipMessage = false);
|
||||
|
||||
/**
|
||||
* Set the script handler for a particular object-specific action
|
||||
*
|
||||
@@ -416,6 +425,11 @@ private:
|
||||
//--------------------------------------------------------
|
||||
//@{
|
||||
|
||||
/**
|
||||
* Updates some internal data depending on the setting changed.
|
||||
*/
|
||||
void SettingChanged(const CStr& Setting, const bool SendMessage);
|
||||
|
||||
/**
|
||||
* Inputs a reference pointer, checks if the new inputted object
|
||||
* if hovered, if so, then check if this's Z value is greater
|
||||
|
||||
Reference in New Issue
Block a user