Delete CInternalCGUIAccessorBase class from c2a71e41bf.

Delete GetSetting/SetSetting variants that operate on a GUI page other
than the one that the setting is defined in; introduced in c2a71e41bf,
obsolete since f0d9806b3f.

Delete CInternalCGUIAccessorBase::GetObjectPointer as these variants
were the only caller for that.
Delete CInternalCGUIAccessorBase::HandleMessage from a08cbd2f74 as it's
an unnecessary proxy.
Delete CInternalCGUIAccessorBase::QueryResetting from 953f72a91c by
making ResetStates public, equal to UpdateCachedSize from 90bbd48a14
(public required for VS2015 but not gcc 9).
Move ResetStates to implementation file.

Tested on: gcc 9, VS2015

This was SVN commit r22563.
This commit is contained in:
elexis 2019-07-28 02:39:52 +00:00
parent 3e4d339b51
commit ad4de3d3be
7 changed files with 30 additions and 140 deletions

View File

@ -68,7 +68,6 @@ class CGUI
NONCOPYABLE(CGUI);
friend class IGUIObject;
friend class CInternalCGUIAccessorBase;
private:
// Private typedefs

View File

@ -211,7 +211,6 @@ public:
ERROR_GROUP(GUI);
ERROR_TYPE(GUI, NullObjectProvided);
ERROR_TYPE(GUI, InvalidSetting);
ERROR_TYPE(GUI, OperationNeedsGUIObject);
ERROR_TYPE(GUI, NameAmbiguity);

View File

@ -255,8 +255,6 @@ bool __ParseString<CGUISeries>(const CStrW& UNUSED(Value), CGUISeries& UNUSED(Ou
return false;
}
//--------------------------------------------------------
CMatrix3D GetDefaultGuiMatrix()
{
float xres = g_xres / g_GuiScale;
@ -274,31 +272,6 @@ CMatrix3D GetDefaultGuiMatrix()
return m;
}
//--------------------------------------------------------
// Utilities implementation
//--------------------------------------------------------
IGUIObject* CInternalCGUIAccessorBase::GetObjectPointer(CGUI& GUIinstance, const CStr& Object)
{
return GUIinstance.FindObjectByName(Object);
}
const IGUIObject* CInternalCGUIAccessorBase::GetObjectPointer(const CGUI& GUIinstance, const CStr& Object)
{
return GUIinstance.FindObjectByName(Object);
}
void CInternalCGUIAccessorBase::QueryResetting(IGUIObject* pObject)
{
GUI<>::RecurseObject(0, pObject, &IGUIObject::ResetStates);
}
void CInternalCGUIAccessorBase::HandleMessage(IGUIObject* pObject, SGUIMessage& message)
{
pObject->HandleMessage(message);
}
#ifndef NDEBUG
#define TYPE(T) \
template<> void CheckType<T>(const IGUIObject* obj, const CStr& setting) { \
@ -315,8 +288,6 @@ void CInternalCGUIAccessorBase::HandleMessage(IGUIObject* pObject, SGUIMessage&
#endif
//--------------------------------------------------------------------
template <typename T>
PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value)
{
@ -399,13 +370,13 @@ PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, const T& V
{
// Hiding an object requires us to reset it and all children
if (IsBoolTrue(Value))
QueryResetting(pObject);
RecurseObject(0, pObject, &IGUIObject::ResetStates);
}
if (!SkipMessage)
{
SGUIMessage msg(GUIM_SETTINGS_UPDATED, Setting);
HandleMessage(pObject, msg);
pObject->HandleMessage(msg);
}
return PSRETURN_OK;

View File

@ -49,29 +49,6 @@ CMatrix3D GetDefaultGuiMatrix();
struct SGUIMessage;
/**
* Base class to only the class GUI. This superclass is
* kind of a templateless extention of the class GUI.
* Used for other functions to friend with, because it
* can't friend with GUI since it's templated (at least
* not on all compilers we're using).
*/
class CInternalCGUIAccessorBase
{
protected:
/// Get object pointer
static IGUIObject* GetObjectPointer(CGUI& GUIinstance, const CStr& Object);
/// const version
static const IGUIObject* GetObjectPointer(const CGUI& GUIinstance, const CStr& Object);
/// Wrapper for ResetStates
static void QueryResetting(IGUIObject* pObject);
static void HandleMessage(IGUIObject* pObject, SGUIMessage& message);
};
#ifndef NDEBUG
// Used to ensure type-safety, sort of
template<typename T> void CheckType(const IGUIObject* obj, const CStr& setting);
@ -86,12 +63,11 @@ template<typename T> void CheckType(const IGUIObject* obj, const CStr& setting);
* and are only within this class because it's convenient
*/
template <typename T=int>
class GUI : public CInternalCGUIAccessorBase
class GUI
{
// Private functions further ahead
friend class CGUI;
friend class IGUIObject;
friend class CInternalCGUIAccessorBase;
public:
@ -121,53 +97,6 @@ public:
*/
static PSRETURN SetSetting(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage = false);
/**
* Retrieves a setting by settings name and object name
*
* @param GUIinstance GUI Object const ref
* @param Object Object name
* @param Setting Setting by name
* @param Value Stores value here, note type T!
*/
static PSRETURN GetSetting(const CGUI& GUIinstance, const CStr& Object, const CStr& Setting, T& Value)
{
if (!GUIinstance.ObjectExists(Object))
return PSRETURN_GUI_NullObjectProvided;
// Retrieve pointer and call sibling function
const IGUIObject* pObject = GetObjectPointer(GUIinstance, Object);
return GetSetting(pObject, Setting, Value);
}
/**
* Sets a value by setting and object name using a real
* datatype as input
*
* This is just a wrapper so that we can type the object name
* and not input the actual pointer.
*
* @param GUIinstance GUI Object, reference since we'll be changing values
* @param Object Object name
* @param Setting Setting by name
* @param Value Sets value to this, note type T!
* @param SkipMessage Does not send a GUIM_SETTINGS_UPDATED if true
*/
static PSRETURN SetSetting(CGUI& GUIinstance, const CStr& Object, const CStr& Setting, const T& Value, const bool& SkipMessage = false)
{
if (!GUIinstance.ObjectExists(Object))
return PSRETURN_GUI_NullObjectProvided;
// Retrieve pointer and call sibling function
// Important, we don't want to use this T, we want
// to use the standard T, since that will be the
// one with the friend relationship
IGUIObject* pObject = GetObjectPointer(GUIinstance, Object);
return SetSetting(pObject, Setting, Value, SkipMessage);
}
/**
* This will return the value of the first sprite if it's not null,
* if it is null, it will return the value of the second sprite, if

View File

@ -296,6 +296,12 @@ IGUIObject* IGUIObject::GetParent() const
return m_pParent;
}
void IGUIObject::ResetStates()
{
// Notify the gui that we aren't hovered anymore
UpdateMouseOver(nullptr);
}
void IGUIObject::UpdateCachedSize()
{
bool absolute;

View File

@ -79,7 +79,6 @@ struct SGUISetting
class IGUIObject
{
friend class CGUI;
friend class CInternalCGUIAccessorBase;
friend class IGUIScrollBar;
friend class GUITooltip;
@ -190,6 +189,11 @@ public:
*/
virtual void UpdateCachedSize();
/**
* Reset internal state of this object.
*/
virtual void ResetStates();
/**
* Set a setting by string, regardless of what type it is.
*
@ -317,16 +321,8 @@ protected:
*/
void SetParent(IGUIObject* pParent) { m_pParent = pParent; }
/**
* Reset internal state of this object
*/
virtual void ResetStates()
{
// Notify the gui that we aren't hovered anymore
UpdateMouseOver(NULL);
}
public:
CGUI* GetGUI() { return m_pGUI; }
const CGUI* GetGUI() const { return m_pGUI; }

View File

@ -38,7 +38,6 @@ class PSERROR_File_WriteFailed : public PSERROR_File { public: PSERROR_File_Writ
class PSERROR_GUI_InvalidSetting : public PSERROR_GUI { public: PSERROR_GUI_InvalidSetting(); PSERROR_GUI_InvalidSetting(const char* msg); PSRETURN getCode() const; };
class PSERROR_GUI_JSOpenFailed : public PSERROR_GUI { public: PSERROR_GUI_JSOpenFailed(); PSERROR_GUI_JSOpenFailed(const char* msg); PSRETURN getCode() const; };
class PSERROR_GUI_NameAmbiguity : public PSERROR_GUI { public: PSERROR_GUI_NameAmbiguity(); PSERROR_GUI_NameAmbiguity(const char* msg); PSRETURN getCode() const; };
class PSERROR_GUI_NullObjectProvided : public PSERROR_GUI { public: PSERROR_GUI_NullObjectProvided(); PSERROR_GUI_NullObjectProvided(const char* msg); PSRETURN getCode() const; };
class PSERROR_GUI_ObjectNeedsName : public PSERROR_GUI { public: PSERROR_GUI_ObjectNeedsName(); PSERROR_GUI_ObjectNeedsName(const char* msg); PSRETURN getCode() const; };
class PSERROR_GUI_OperationNeedsGUIObject : public PSERROR_GUI { public: PSERROR_GUI_OperationNeedsGUIObject(); PSERROR_GUI_OperationNeedsGUIObject(const char* msg); PSRETURN getCode() const; };
class PSERROR_GUI_UnableToParse : public PSERROR_GUI { public: PSERROR_GUI_UnableToParse(); PSERROR_GUI_UnableToParse(const char* msg); PSRETURN getCode() const; };
@ -82,10 +81,9 @@ extern const PSRETURN PSRETURN_File_WriteFailed = 0x05000006;
extern const PSRETURN PSRETURN_GUI_InvalidSetting = 0x06000001;
extern const PSRETURN PSRETURN_GUI_JSOpenFailed = 0x06000002;
extern const PSRETURN PSRETURN_GUI_NameAmbiguity = 0x06000003;
extern const PSRETURN PSRETURN_GUI_NullObjectProvided = 0x06000004;
extern const PSRETURN PSRETURN_GUI_ObjectNeedsName = 0x06000005;
extern const PSRETURN PSRETURN_GUI_OperationNeedsGUIObject = 0x06000006;
extern const PSRETURN PSRETURN_GUI_UnableToParse = 0x06000007;
extern const PSRETURN PSRETURN_GUI_ObjectNeedsName = 0x06000004;
extern const PSRETURN PSRETURN_GUI_OperationNeedsGUIObject = 0x06000005;
extern const PSRETURN PSRETURN_GUI_UnableToParse = 0x06000006;
extern const PSRETURN PSRETURN_Game_World_MapLoadFailed = 0x07030001;
extern const PSRETURN PSRETURN_Scripting_DefineType_AlreadyExists = 0x08010001;
extern const PSRETURN PSRETURN_Scripting_DefineType_CreationFailed = 0x08010002;
@ -173,14 +171,12 @@ extern const PSRETURN MASK__PSRETURN_GUI_JSOpenFailed = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_GUI_JSOpenFailed = 0x06000002;
extern const PSRETURN MASK__PSRETURN_GUI_NameAmbiguity = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_GUI_NameAmbiguity = 0x06000003;
extern const PSRETURN MASK__PSRETURN_GUI_NullObjectProvided = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_GUI_NullObjectProvided = 0x06000004;
extern const PSRETURN MASK__PSRETURN_GUI_ObjectNeedsName = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_GUI_ObjectNeedsName = 0x06000005;
extern const PSRETURN CODE__PSRETURN_GUI_ObjectNeedsName = 0x06000004;
extern const PSRETURN MASK__PSRETURN_GUI_OperationNeedsGUIObject = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_GUI_OperationNeedsGUIObject = 0x06000006;
extern const PSRETURN CODE__PSRETURN_GUI_OperationNeedsGUIObject = 0x06000005;
extern const PSRETURN MASK__PSRETURN_GUI_UnableToParse = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_GUI_UnableToParse = 0x06000007;
extern const PSRETURN CODE__PSRETURN_GUI_UnableToParse = 0x06000006;
extern const PSRETURN MASK__PSRETURN_Game_World_MapLoadFailed = 0xffffffff;
extern const PSRETURN CODE__PSRETURN_Game_World_MapLoadFailed = 0x07030001;
extern const PSRETURN MASK__PSRETURN_Scripting_DefineType_AlreadyExists = 0xffffffff;
@ -311,21 +307,17 @@ PSERROR_GUI_NameAmbiguity::PSERROR_GUI_NameAmbiguity() : PSERROR_GUI(NULL) { }
PSERROR_GUI_NameAmbiguity::PSERROR_GUI_NameAmbiguity(const char* msg) : PSERROR_GUI(msg) { }
PSRETURN PSERROR_GUI_NameAmbiguity::getCode() const { return 0x06000003; }
PSERROR_GUI_NullObjectProvided::PSERROR_GUI_NullObjectProvided() : PSERROR_GUI(NULL) { }
PSERROR_GUI_NullObjectProvided::PSERROR_GUI_NullObjectProvided(const char* msg) : PSERROR_GUI(msg) { }
PSRETURN PSERROR_GUI_NullObjectProvided::getCode() const { return 0x06000004; }
PSERROR_GUI_ObjectNeedsName::PSERROR_GUI_ObjectNeedsName() : PSERROR_GUI(NULL) { }
PSERROR_GUI_ObjectNeedsName::PSERROR_GUI_ObjectNeedsName(const char* msg) : PSERROR_GUI(msg) { }
PSRETURN PSERROR_GUI_ObjectNeedsName::getCode() const { return 0x06000005; }
PSRETURN PSERROR_GUI_ObjectNeedsName::getCode() const { return 0x06000004; }
PSERROR_GUI_OperationNeedsGUIObject::PSERROR_GUI_OperationNeedsGUIObject() : PSERROR_GUI(NULL) { }
PSERROR_GUI_OperationNeedsGUIObject::PSERROR_GUI_OperationNeedsGUIObject(const char* msg) : PSERROR_GUI(msg) { }
PSRETURN PSERROR_GUI_OperationNeedsGUIObject::getCode() const { return 0x06000006; }
PSRETURN PSERROR_GUI_OperationNeedsGUIObject::getCode() const { return 0x06000005; }
PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse() : PSERROR_GUI(NULL) { }
PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse(const char* msg) : PSERROR_GUI(msg) { }
PSRETURN PSERROR_GUI_UnableToParse::getCode() const { return 0x06000007; }
PSRETURN PSERROR_GUI_UnableToParse::getCode() const { return 0x06000006; }
PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed() : PSERROR_Game_World(NULL) { }
PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed(const char* msg) : PSERROR_Game_World(msg) { }
@ -441,10 +433,9 @@ const char* GetErrorString(PSRETURN code)
case 0x06000001: return "GUI_InvalidSetting";
case 0x06000002: return "GUI_JSOpenFailed";
case 0x06000003: return "GUI_NameAmbiguity";
case 0x06000004: return "GUI_NullObjectProvided";
case 0x06000005: return "GUI_ObjectNeedsName";
case 0x06000006: return "GUI_OperationNeedsGUIObject";
case 0x06000007: return "GUI_UnableToParse";
case 0x06000004: return "GUI_ObjectNeedsName";
case 0x06000005: return "GUI_OperationNeedsGUIObject";
case 0x06000006: return "GUI_UnableToParse";
case 0x07030001: return "Game_World_MapLoadFailed";
case 0x08010001: return "Scripting_DefineType_AlreadyExists";
case 0x08010002: return "Scripting_DefineType_CreationFailed";
@ -493,10 +484,9 @@ void ThrowError(PSRETURN code)
case 0x06000001: throw PSERROR_GUI_InvalidSetting(); break;
case 0x06000002: throw PSERROR_GUI_JSOpenFailed(); break;
case 0x06000003: throw PSERROR_GUI_NameAmbiguity(); break;
case 0x06000004: throw PSERROR_GUI_NullObjectProvided(); break;
case 0x06000005: throw PSERROR_GUI_ObjectNeedsName(); break;
case 0x06000006: throw PSERROR_GUI_OperationNeedsGUIObject(); break;
case 0x06000007: throw PSERROR_GUI_UnableToParse(); break;
case 0x06000004: throw PSERROR_GUI_ObjectNeedsName(); break;
case 0x06000005: throw PSERROR_GUI_OperationNeedsGUIObject(); break;
case 0x06000006: throw PSERROR_GUI_UnableToParse(); break;
case 0x07030001: throw PSERROR_Game_World_MapLoadFailed(); break;
case 0x08010001: throw PSERROR_Scripting_DefineType_AlreadyExists(); break;
case 0x08010002: throw PSERROR_Scripting_DefineType_CreationFailed(); break;