2019-07-26 20:57:28 +02:00
|
|
|
/* Copyright (C) 2019 Wildfire Games.
|
2009-04-18 19:00:33 +02:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2004-06-03 20:38:14 +02:00
|
|
|
#include "precompiled.h"
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2004-05-29 06:06:50 +02:00
|
|
|
#include "CText.h"
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2019-07-26 20:57:28 +02:00
|
|
|
#include "gui/CGUIScrollBarVertical.h"
|
|
|
|
#include "gui/GUI.h"
|
2006-06-02 04:10:27 +02:00
|
|
|
#include "lib/ogl.h"
|
2003-12-27 07:26:03 +01:00
|
|
|
|
2019-08-21 12:12:33 +02:00
|
|
|
CText::CText(CGUI& pGUI)
|
2019-08-02 01:55:10 +02:00
|
|
|
: IGUIObject(pGUI), IGUIScrollBarOwner(pGUI), IGUITextOwner(pGUI)
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<float>("buffer_zone");
|
|
|
|
AddSetting<CGUIString>("caption");
|
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.
2019-08-28 13:21:11 +02:00
|
|
|
AddSetting<i32>("cell_id");
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<bool>("clip");
|
|
|
|
AddSetting<CStrW>("font");
|
|
|
|
AddSetting<bool>("scrollbar");
|
|
|
|
AddSetting<CStr>("scrollbar_style");
|
|
|
|
AddSetting<bool>("scroll_bottom");
|
|
|
|
AddSetting<bool>("scroll_top");
|
|
|
|
AddSetting<CGUISpriteInstance>("sprite");
|
|
|
|
AddSetting<EAlign>("text_align");
|
|
|
|
AddSetting<EVAlign>("text_valign");
|
|
|
|
AddSetting<CGUIColor>("textcolor");
|
|
|
|
AddSetting<CGUIColor>("textcolor_disabled");
|
|
|
|
AddSetting<CStrW>("tooltip");
|
|
|
|
AddSetting<CStr>("tooltip_style");
|
2003-12-27 07:26:03 +01:00
|
|
|
|
2011-02-18 23:36:39 +01:00
|
|
|
// Private settings
|
2019-08-04 04:20:08 +02:00
|
|
|
AddSetting<CStrW>("_icon_tooltip");
|
|
|
|
AddSetting<CStr>("_icon_tooltip_style");
|
2010-10-30 06:02:42 +02:00
|
|
|
|
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.
2019-08-28 13:21:11 +02:00
|
|
|
//SetSetting<bool>("ghost", true, true);
|
|
|
|
SetSetting<bool>("scrollbar", false, true);
|
|
|
|
SetSetting<bool>("clip", true, true);
|
2003-12-27 07:26:03 +01:00
|
|
|
|
|
|
|
// Add scroll-bar
|
2019-08-01 22:20:24 +02:00
|
|
|
CGUIScrollBarVertical* bar = new CGUIScrollBarVertical(pGUI);
|
2003-12-27 07:26:03 +01:00
|
|
|
bar->SetRightAligned(true);
|
|
|
|
AddScrollBar(bar);
|
2004-05-29 06:06:50 +02:00
|
|
|
|
|
|
|
// Add text
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
AddText();
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CText::~CText()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-05-29 06:06:50 +02:00
|
|
|
void CText::SetupText()
|
|
|
|
{
|
2019-08-01 22:20:24 +02:00
|
|
|
if (m_GeneratedTexts.empty())
|
2004-05-29 06:06:50 +02:00
|
|
|
return;
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool scrollbar = GetSetting<bool>("scrollbar");
|
2004-05-29 06:06:50 +02:00
|
|
|
|
2004-09-03 07:48:47 +02:00
|
|
|
float width = m_CachedActualSize.GetWidth();
|
2004-05-29 06:06:50 +02:00
|
|
|
// remove scrollbar if applicable
|
|
|
|
if (scrollbar && GetScrollBar(0).GetStyle())
|
|
|
|
width -= GetScrollBar(0).GetStyle()->m_Width;
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const CGUIString& caption = GetSetting<CGUIString>("caption");
|
|
|
|
const CStrW& font = GetSetting<CStrW>("font");
|
|
|
|
const float buffer_zone = GetSetting<float>("buffer_zone");
|
2004-08-31 05:25:36 +02:00
|
|
|
|
2019-08-19 12:32:29 +02:00
|
|
|
m_GeneratedTexts[0] = CGUIText(m_pGUI, caption, font, width, buffer_zone, this);
|
2004-05-29 06:06:50 +02:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
if (!scrollbar)
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
CalculateTextPosition(m_CachedActualSize, m_TextPos, m_GeneratedTexts[0]);
|
2004-12-28 13:17:04 +01:00
|
|
|
|
2004-05-29 06:06:50 +02:00
|
|
|
// Setup scrollbar
|
|
|
|
if (scrollbar)
|
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool scroll_bottom = GetSetting<bool>("scroll_bottom");
|
|
|
|
const bool scroll_top = GetSetting<bool>("scroll_top");
|
2010-07-02 23:28:48 +02:00
|
|
|
|
|
|
|
// If we are currently scrolled to the bottom of the text,
|
|
|
|
// then add more lines of text, update the scrollbar so we
|
|
|
|
// stick to the bottom.
|
|
|
|
// (Use 1.5px delta so this triggers the first time caption is set)
|
|
|
|
bool bottom = false;
|
2016-12-11 22:15:50 +01:00
|
|
|
if (scroll_bottom && GetScrollBar(0).GetPos() > GetScrollBar(0).GetMaxPos() - 1.5f)
|
2010-07-02 23:28:48 +02:00
|
|
|
bottom = true;
|
|
|
|
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
GetScrollBar(0).SetScrollRange(m_GeneratedTexts[0].GetSize().cy);
|
2010-07-02 23:28:48 +02:00
|
|
|
GetScrollBar(0).SetScrollSpace(m_CachedActualSize.GetHeight());
|
|
|
|
|
2010-07-03 15:12:44 +02:00
|
|
|
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
|
|
|
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
|
|
|
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
|
|
|
|
2010-07-02 23:28:48 +02:00
|
|
|
if (bottom)
|
|
|
|
GetScrollBar(0).SetPos(GetScrollBar(0).GetMaxPos());
|
2016-12-11 22:15:50 +01:00
|
|
|
if (scroll_top)
|
|
|
|
GetScrollBar(0).SetPos(0.0f);
|
2004-05-29 06:06:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void CText::HandleMessage(SGUIMessage& Message)
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
|
|
|
IGUIScrollBarOwner::HandleMessage(Message);
|
2005-02-05 08:25:16 +01:00
|
|
|
//IGUITextOwner::HandleMessage(Message); <== placed it after the switch instead!
|
2003-12-27 07:26:03 +01:00
|
|
|
|
|
|
|
switch (Message.type)
|
|
|
|
{
|
|
|
|
case GUIM_SETTINGS_UPDATED:
|
2010-07-03 15:12:44 +02:00
|
|
|
if (Message.value == "scrollbar")
|
2005-02-05 08:25:16 +01:00
|
|
|
SetupText();
|
|
|
|
|
2004-05-29 06:06:50 +02:00
|
|
|
// Update scrollbar
|
2010-07-03 15:12:44 +02:00
|
|
|
if (Message.value == "scrollbar_style")
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
2019-08-26 14:25:07 +02:00
|
|
|
GetScrollBar(0).SetScrollBarStyle(GetSetting<CStr>(Message.value));
|
2005-04-07 11:13:10 +02:00
|
|
|
SetupText();
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
2004-05-29 06:06:50 +02:00
|
|
|
|
2003-12-27 07:26:03 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GUIM_MOUSE_WHEEL_DOWN:
|
2015-08-21 19:08:41 +02:00
|
|
|
{
|
2005-10-20 17:27:39 +02:00
|
|
|
GetScrollBar(0).ScrollPlus();
|
2004-05-29 06:06:50 +02:00
|
|
|
// Since the scroll was changed, let's simulate a mouse movement
|
|
|
|
// to check if scrollbar now is hovered
|
2011-04-28 22:42:11 +02:00
|
|
|
SGUIMessage msg(GUIM_MOUSE_MOTION);
|
|
|
|
HandleMessage(msg);
|
2003-12-27 07:26:03 +01:00
|
|
|
break;
|
2015-08-21 19:08:41 +02:00
|
|
|
}
|
2003-12-27 07:26:03 +01:00
|
|
|
case GUIM_MOUSE_WHEEL_UP:
|
2015-08-21 19:08:41 +02:00
|
|
|
{
|
2005-10-20 17:27:39 +02:00
|
|
|
GetScrollBar(0).ScrollMinus();
|
2004-05-29 06:06:50 +02:00
|
|
|
// Since the scroll was changed, let's simulate a mouse movement
|
|
|
|
// to check if scrollbar now is hovered
|
2011-04-28 22:42:11 +02:00
|
|
|
SGUIMessage msg(GUIM_MOUSE_MOTION);
|
|
|
|
HandleMessage(msg);
|
2003-12-27 07:26:03 +01:00
|
|
|
break;
|
2015-08-21 19:08:41 +02:00
|
|
|
}
|
2005-02-05 08:25:16 +01:00
|
|
|
case GUIM_LOAD:
|
2015-08-21 19:08:41 +02:00
|
|
|
{
|
|
|
|
GetScrollBar(0).SetX(m_CachedActualSize.right);
|
|
|
|
GetScrollBar(0).SetY(m_CachedActualSize.top);
|
|
|
|
GetScrollBar(0).SetZ(GetBufferedZ());
|
|
|
|
GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);
|
2019-08-26 14:25:07 +02:00
|
|
|
GetScrollBar(0).SetScrollBarStyle(GetSetting<CStr>("scrollbar_style"));
|
2005-02-05 08:25:16 +01:00
|
|
|
break;
|
2015-08-21 19:08:41 +02:00
|
|
|
}
|
2005-02-05 08:25:16 +01:00
|
|
|
|
2003-12-27 07:26:03 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-02-05 08:25:16 +01:00
|
|
|
|
|
|
|
IGUITextOwner::HandleMessage(Message);
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
void CText::Draw()
|
2003-12-27 07:26:03 +01:00
|
|
|
{
|
2004-05-29 06:06:50 +02:00
|
|
|
float bz = GetBufferedZ();
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool scrollbar = GetSetting<bool>("scrollbar");
|
2003-12-27 07:26:03 +01:00
|
|
|
|
2004-05-29 06:06:50 +02:00
|
|
|
if (scrollbar)
|
|
|
|
IGUIScrollBarOwner::Draw();
|
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
CGUISpriteInstance& sprite = GetSetting<CGUISpriteInstance>("sprite");
|
|
|
|
const int cell_id = GetSetting<i32>("cell_id");
|
|
|
|
const bool clip = GetSetting<bool>("clip");
|
2005-07-24 10:29:02 +02:00
|
|
|
|
2019-08-21 12:12:33 +02:00
|
|
|
m_pGUI.DrawSprite(sprite, cell_id, bz, m_CachedActualSize);
|
2010-05-30 15:42:56 +02:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
float scroll = 0.f;
|
|
|
|
if (scrollbar)
|
|
|
|
scroll = GetScrollBar(0).GetPos();
|
2004-05-29 06:06:50 +02:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
// Clipping area (we'll have to subtract the scrollbar)
|
|
|
|
CRect cliparea;
|
|
|
|
if (clip)
|
|
|
|
{
|
|
|
|
cliparea = m_CachedActualSize;
|
2004-05-29 06:06:50 +02:00
|
|
|
|
2004-12-28 13:17:04 +01:00
|
|
|
if (scrollbar)
|
2015-08-21 19:08:41 +02:00
|
|
|
{
|
|
|
|
// subtract scrollbar from cliparea
|
|
|
|
if (cliparea.right > GetScrollBar(0).GetOuterRect().left &&
|
|
|
|
cliparea.right <= GetScrollBar(0).GetOuterRect().right)
|
|
|
|
cliparea.right = GetScrollBar(0).GetOuterRect().left;
|
|
|
|
|
|
|
|
if (cliparea.left >= GetScrollBar(0).GetOuterRect().left &&
|
|
|
|
cliparea.left < GetScrollBar(0).GetOuterRect().right)
|
|
|
|
cliparea.left = GetScrollBar(0).GetOuterRect().right;
|
|
|
|
}
|
2004-05-29 06:06:50 +02:00
|
|
|
}
|
2015-08-21 19:08:41 +02:00
|
|
|
|
2019-08-26 14:25:07 +02:00
|
|
|
const bool enabled = GetSetting<bool>("enabled");
|
|
|
|
const CGUIColor& color = GetSetting<CGUIColor>(enabled ? "textcolor" : "textcolor_disabled");
|
2015-08-21 19:08:41 +02:00
|
|
|
|
|
|
|
if (scrollbar)
|
Stop copying color every draw call for every GUI object using colors.
Avoid color copies for rendering Draw calls in
GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes,
CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,
8f4f8e240f, 3028551b91, a905fbbc98.
Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage,
CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren.
Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors,
CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for
consistency with the other "databases", refs 3028551b91.
Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an
unexplicit copy, refs 3028551b91.
Explicit ugly copy in CGUI::Xeromyces_ReadColor and
CGUIColor::ParseString.
Deregister copying <CGUIColor>GetSetting functions, refs 8f4f8e240f.
Uses the const ref GetSetting from 3dfa23cd25.
This was SVN commit r22694.
2019-08-19 14:53:58 +02:00
|
|
|
DrawText(0, color, m_CachedActualSize.TopLeft() - CPos(0.f, scroll), bz + 0.1f, cliparea);
|
2015-08-21 19:08:41 +02:00
|
|
|
else
|
Stop copying color every draw call for every GUI object using colors.
Avoid color copies for rendering Draw calls in
GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes,
CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,
8f4f8e240f, 3028551b91, a905fbbc98.
Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage,
CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren.
Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors,
CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for
consistency with the other "databases", refs 3028551b91.
Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an
unexplicit copy, refs 3028551b91.
Explicit ugly copy in CGUI::Xeromyces_ReadColor and
CGUIColor::ParseString.
Deregister copying <CGUIColor>GetSetting functions, refs 8f4f8e240f.
Uses the const ref GetSetting from 3dfa23cd25.
This was SVN commit r22694.
2019-08-19 14:53:58 +02:00
|
|
|
DrawText(0, color, m_TextPos, bz + 0.1f, cliparea);
|
2003-12-27 07:26:03 +01:00
|
|
|
}
|
2010-10-30 06:02:42 +02:00
|
|
|
|
|
|
|
bool CText::MouseOverIcon()
|
|
|
|
{
|
Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.
Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline
This was SVN commit r22679.
2019-08-17 03:32:11 +02:00
|
|
|
for (const CGUIText& guitext : m_GeneratedTexts)
|
|
|
|
for (const CGUIText::SSpriteCall& spritecall : guitext.GetSpriteCalls())
|
2010-10-30 06:02:42 +02:00
|
|
|
{
|
2015-08-21 19:08:41 +02:00
|
|
|
// Check mouse over sprite
|
2019-08-21 12:12:33 +02:00
|
|
|
if (!spritecall.m_Area.PointInside(m_pGUI.GetMousePos() - m_CachedActualSize.TopLeft()))
|
2015-08-21 19:08:41 +02:00
|
|
|
continue;
|
2010-10-30 06:02:42 +02:00
|
|
|
|
2015-08-21 19:08:41 +02:00
|
|
|
// If tooltip exists, set the property
|
|
|
|
if (!spritecall.m_Tooltip.empty())
|
2010-10-30 06:02:42 +02:00
|
|
|
{
|
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.
2019-08-28 13:21:11 +02:00
|
|
|
SetSettingFromString("_icon_tooltip_style", spritecall.m_TooltipStyle, true);
|
|
|
|
SetSettingFromString("_icon_tooltip", spritecall.m_Tooltip, true);
|
2010-10-30 06:02:42 +02:00
|
|
|
}
|
2015-08-21 19:08:41 +02:00
|
|
|
|
|
|
|
return true;
|
2010-10-30 06:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|