mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Use CGUI& instead of CGUI* so that the 50+ users stop wondering whether or not that is null and can't even be mistaken to add redundant null checks preemptively.
Remove the remaining of such checks afterd3e56f0f57removed 21 of them already.2c47fbd66ainitialized the pointer at construction time rather than at random conditional events later. Differential Revision: https://code.wildfiregames.com/D2205 Comments By: Vladislav, wraitii Tested on: gcc 9.1.0, clang 8.0.1 This was SVN commit r22741.
This commit is contained in:
@@ -113,14 +113,14 @@ bool GUITooltip::GetTooltip(IGUIObject* obj, CStr& style)
|
||||
return false;
|
||||
}
|
||||
|
||||
void GUITooltip::ShowTooltip(IGUIObject* obj, const CPos& pos, const CStr& style, CGUI* gui)
|
||||
void GUITooltip::ShowTooltip(IGUIObject* obj, const CPos& pos, const CStr& style, CGUI& pGUI)
|
||||
{
|
||||
ENSURE(obj);
|
||||
|
||||
if (style.empty())
|
||||
return;
|
||||
|
||||
IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style);
|
||||
IGUIObject* tooltipobj = pGUI.FindObjectByName("__tooltip_" + style);
|
||||
if (!tooltipobj)
|
||||
{
|
||||
LOGERROR("Cannot find tooltip named '%s'", style.c_str());
|
||||
@@ -133,7 +133,7 @@ void GUITooltip::ShowTooltip(IGUIObject* obj, const CPos& pos, const CStr& style
|
||||
if (GUI<CStr>::GetSetting(tooltipobj, "use_object", usedObjectName) == PSRETURN_OK &&
|
||||
!usedObjectName.empty())
|
||||
{
|
||||
usedobj = gui->FindObjectByName(usedObjectName);
|
||||
usedobj = pGUI.FindObjectByName(usedObjectName);
|
||||
if (!usedobj)
|
||||
{
|
||||
LOGERROR("Cannot find object named '%s' used by tooltip '%s'", usedObjectName.c_str(), style.c_str());
|
||||
@@ -161,12 +161,12 @@ void GUITooltip::ShowTooltip(IGUIObject* obj, const CPos& pos, const CStr& style
|
||||
usedobj->HandleMessage(msg);
|
||||
}
|
||||
|
||||
void GUITooltip::HideTooltip(const CStr& style, CGUI* gui)
|
||||
void GUITooltip::HideTooltip(const CStr& style, CGUI& pGUI)
|
||||
{
|
||||
if (style.empty())
|
||||
return;
|
||||
|
||||
IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style);
|
||||
IGUIObject* tooltipobj = pGUI.FindObjectByName("__tooltip_" + style);
|
||||
if (!tooltipobj)
|
||||
{
|
||||
LOGERROR("Cannot find tooltip named '%s'", style.c_str());
|
||||
@@ -177,7 +177,7 @@ void GUITooltip::HideTooltip(const CStr& style, CGUI* gui)
|
||||
if (GUI<CStr>::GetSetting(tooltipobj, "use_object", usedObjectName) == PSRETURN_OK &&
|
||||
!usedObjectName.empty())
|
||||
{
|
||||
IGUIObject* usedobj = gui->FindObjectByName(usedObjectName);
|
||||
IGUIObject* usedobj = pGUI.FindObjectByName(usedObjectName);
|
||||
if (!usedobj)
|
||||
{
|
||||
LOGERROR("Cannot find object named '%s' used by tooltip '%s'", usedObjectName.c_str(), style.c_str());
|
||||
@@ -198,11 +198,11 @@ void GUITooltip::HideTooltip(const CStr& style, CGUI* gui)
|
||||
GUI<bool>::SetSetting(tooltipobj, "hidden", true);
|
||||
}
|
||||
|
||||
static int GetTooltipDelay(const CStr& style, CGUI* gui)
|
||||
static int GetTooltipDelay(const CStr& style, CGUI& pGUI)
|
||||
{
|
||||
int delay = 500; // default value (in msec)
|
||||
|
||||
IGUIObject* tooltipobj = gui->FindObjectByName("__tooltip_"+style);
|
||||
IGUIObject* tooltipobj = pGUI.FindObjectByName("__tooltip_" + style);
|
||||
if (!tooltipobj)
|
||||
{
|
||||
LOGERROR("Cannot find tooltip object named '%s'", style.c_str());
|
||||
@@ -212,7 +212,7 @@ static int GetTooltipDelay(const CStr& style, CGUI* gui)
|
||||
return delay;
|
||||
}
|
||||
|
||||
void GUITooltip::Update(IGUIObject* Nearest, const CPos& MousePos, CGUI* GUI)
|
||||
void GUITooltip::Update(IGUIObject* Nearest, const CPos& MousePos, CGUI& GUI)
|
||||
{
|
||||
// Called once per frame, so efficiency isn't vital
|
||||
double now = timer_Time();
|
||||
|
||||
Reference in New Issue
Block a user