Changeset View
Changeset View
Standalone View
Standalone View
source/gui/IGUIObject.cpp
/* Copyright (C) 2016 Wildfire Games. | /* Copyright (C) 2018 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 14 Lines | |||||
#include "ps/GameSetup/Config.h" | #include "ps/GameSetup/Config.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
IGUIObject::IGUIObject() | IGUIObject::IGUIObject() | ||||
: m_pGUI(NULL), m_pParent(NULL), m_MouseHovering(false), m_LastClickTime() | : m_pGUI(nullptr), m_pParent(nullptr), m_MouseHovering(false), m_LastClickTime() | ||||
{ | { | ||||
AddSetting(GUIST_bool, "enabled"); | AddSetting(GUIST_bool, "enabled"); | ||||
AddSetting(GUIST_bool, "hidden"); | AddSetting(GUIST_bool, "hidden"); | ||||
AddSetting(GUIST_CClientArea, "size"); | AddSetting(GUIST_CClientArea, "size"); | ||||
AddSetting(GUIST_CStr, "style"); | AddSetting(GUIST_CStr, "style"); | ||||
AddSetting(GUIST_CStr, "hotkey"); | AddSetting(GUIST_CStr, "hotkey"); | ||||
AddSetting(GUIST_float, "z"); | AddSetting(GUIST_float, "z"); | ||||
AddSetting(GUIST_bool, "absolute"); | AddSetting(GUIST_bool, "absolute"); | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | if (pChild->GetGUI()) | ||||
} | } | ||||
} | } | ||||
// else do nothing | // else do nothing | ||||
} | } | ||||
void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap) | void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap) | ||||
{ | { | ||||
// Just don't do anything about the top node | // Just don't do anything about the top node | ||||
if (m_pParent == NULL) | if (m_pParent == nullptr) | ||||
return; | return; | ||||
// Now actually add this one | // Now actually add this one | ||||
// notice we won't add it if it's doesn't have any parent | // notice we won't add it if it's doesn't have any parent | ||||
// (i.e. being the base object) | // (i.e. being the base object) | ||||
if (m_Name.empty()) | if (m_Name.empty()) | ||||
{ | { | ||||
throw PSERROR_GUI_ObjectNeedsName(); | throw PSERROR_GUI_ObjectNeedsName(); | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | |||||
void IGUIObject::ChooseMouseOverAndClosest(IGUIObject*& pObject) | void IGUIObject::ChooseMouseOverAndClosest(IGUIObject*& pObject) | ||||
{ | { | ||||
if (!MouseOver()) | if (!MouseOver()) | ||||
return; | return; | ||||
// Check if we've got competition at all | // Check if we've got competition at all | ||||
if (pObject == NULL) | if (pObject == nullptr) | ||||
{ | { | ||||
pObject = this; | pObject = this; | ||||
return; | return; | ||||
} | } | ||||
// Or if it's closer | // Or if it's closer | ||||
if (GetBufferedZ() >= pObject->GetBufferedZ()) | if (GetBufferedZ() >= pObject->GetBufferedZ()) | ||||
{ | { | ||||
pObject = this; | pObject = this; | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
IGUIObject* IGUIObject::GetParent() const | IGUIObject* IGUIObject::GetParent() const | ||||
{ | { | ||||
// Important, we're not using GetParent() for these | // Important, we're not using GetParent() for these | ||||
// checks, that could screw it up | // checks, that could screw it up | ||||
if (m_pParent) | if (m_pParent) | ||||
{ | { | ||||
if (m_pParent->m_pParent == NULL) | if (m_pParent->m_pParent == nullptr) | ||||
return NULL; | return nullptr; | ||||
} | } | ||||
return m_pParent; | return m_pParent; | ||||
} | } | ||||
void IGUIObject::UpdateCachedSize() | void IGUIObject::UpdateCachedSize() | ||||
{ | { | ||||
bool absolute; | bool absolute; | ||||
▲ Show 20 Lines • Show All 252 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator