mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Use a new GetSetting returning a reference instead of GetSettingPointer when the setting is known to exist.
Differential Revision: https://code.wildfiregames.com/D2192 This was SVN commit r22693.
This commit is contained in:
parent
5cfef19a06
commit
3dfa23cd25
16 changed files with 259 additions and 318 deletions
|
|
@ -64,13 +64,12 @@ void CButton::SetupText()
|
|||
// TODO Gee: (2004-08-14) Default should not be hard-coded, but be in styles!
|
||||
font = L"default";
|
||||
|
||||
CGUIString* caption = nullptr;
|
||||
GUI<CGUIString>::GetSettingPointer(this, "caption", caption);
|
||||
const CGUIString& caption = GUI<CGUIString>::GetSetting(this, "caption");
|
||||
|
||||
float buffer_zone = 0.f;
|
||||
GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
|
||||
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, *caption, font, m_CachedActualSize.GetWidth(), buffer_zone, this);
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, caption, font, m_CachedActualSize.GetWidth(), buffer_zone, this);
|
||||
|
||||
CalculateTextPosition(m_CachedActualSize, m_TextPos, m_GeneratedTexts[0]);
|
||||
}
|
||||
|
|
@ -86,10 +85,6 @@ void CButton::Draw()
|
|||
{
|
||||
float bz = GetBufferedZ();
|
||||
|
||||
CGUISpriteInstance* sprite;
|
||||
CGUISpriteInstance* sprite_over;
|
||||
CGUISpriteInstance* sprite_pressed;
|
||||
CGUISpriteInstance* sprite_disabled;
|
||||
int cell_id;
|
||||
|
||||
// Statically initialise some strings, so we don't have to do
|
||||
|
|
@ -100,19 +95,14 @@ void CButton::Draw()
|
|||
static const CStr strSpriteDisabled("sprite_disabled");
|
||||
static const CStr strCellId("cell_id");
|
||||
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSprite, sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteOver, sprite_over);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpritePressed, sprite_pressed);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, strSpriteDisabled, sprite_disabled);
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, strSprite);
|
||||
CGUISpriteInstance& sprite_over = GUI<CGUISpriteInstance>::GetSetting(this, strSpriteOver);
|
||||
CGUISpriteInstance& sprite_pressed = GUI<CGUISpriteInstance>::GetSetting(this, strSpritePressed);
|
||||
CGUISpriteInstance& sprite_disabled = GUI<CGUISpriteInstance>::GetSetting(this, strSpriteDisabled);
|
||||
|
||||
GUI<int>::GetSetting(this, strCellId, cell_id);
|
||||
|
||||
DrawButton(m_CachedActualSize,
|
||||
bz,
|
||||
*sprite,
|
||||
*sprite_over,
|
||||
*sprite_pressed,
|
||||
*sprite_disabled,
|
||||
cell_id);
|
||||
DrawButton(m_CachedActualSize, bz, sprite, sprite_over, sprite_pressed, sprite_disabled, cell_id);
|
||||
|
||||
CGUIColor color = ChooseColor();
|
||||
DrawText(0, color, m_TextPos, bz+0.1f);
|
||||
|
|
|
|||
|
|
@ -184,22 +184,19 @@ CRect CChart::GetChartRect() const
|
|||
|
||||
void CChart::UpdateSeries()
|
||||
{
|
||||
CGUISeries* pSeries;
|
||||
GUI<CGUISeries>::GetSettingPointer(this, "series", pSeries);
|
||||
|
||||
CGUIList* pSeriesColor;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "series_color", pSeriesColor);
|
||||
const CGUISeries& pSeries = GUI<CGUISeries>::GetSetting(this, "series");
|
||||
const CGUIList& pSeriesColor = GUI<CGUIList>::GetSetting(this, "series_color");
|
||||
|
||||
m_Series.clear();
|
||||
m_Series.resize(pSeries->m_Series.size());
|
||||
for (size_t i = 0; i < pSeries->m_Series.size(); ++i)
|
||||
m_Series.resize(pSeries.m_Series.size());
|
||||
for (size_t i = 0; i < pSeries.m_Series.size(); ++i)
|
||||
{
|
||||
CChartData& data = m_Series[i];
|
||||
|
||||
if (i < pSeriesColor->m_Items.size() && !data.m_Color.ParseString(m_pGUI, pSeriesColor->m_Items[i].GetOriginalString().ToUTF8(), 0))
|
||||
LOGWARNING("GUI: Error parsing 'series_color' (\"%s\")", utf8_from_wstring(pSeriesColor->m_Items[i].GetOriginalString()));
|
||||
if (i < pSeriesColor.m_Items.size() && !data.m_Color.ParseString(m_pGUI, pSeriesColor.m_Items[i].GetOriginalString().ToUTF8(), 0))
|
||||
LOGWARNING("GUI: Error parsing 'series_color' (\"%s\")", utf8_from_wstring(pSeriesColor.m_Items[i].GetOriginalString()));
|
||||
|
||||
data.m_Points = pSeries->m_Series[i];
|
||||
data.m_Points = pSeries.m_Series[i];
|
||||
}
|
||||
UpdateBounds();
|
||||
|
||||
|
|
|
|||
|
|
@ -77,12 +77,11 @@ void CCheckBox::SetupText()
|
|||
float square_side;
|
||||
GUI<float>::GetSetting(this, "square_side", square_side);
|
||||
|
||||
CGUIString* caption = nullptr;
|
||||
GUI<CGUIString>::GetSettingPointer(this, "caption", caption);
|
||||
const CGUIString& caption = GUI<CGUIString>::GetSetting(this, "caption");
|
||||
|
||||
float buffer_zone = 0.f;
|
||||
GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, *caption, font, m_CachedActualSize.GetWidth() - square_side, 0.f, this);
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, caption, font, m_CachedActualSize.GetWidth() - square_side, 0.f, this);
|
||||
}
|
||||
|
||||
void CCheckBox::HandleMessage(SGUIMessage& Message)
|
||||
|
|
@ -111,37 +110,22 @@ void CCheckBox::HandleMessage(SGUIMessage& Message)
|
|||
|
||||
void CCheckBox::Draw()
|
||||
{
|
||||
float bz = GetBufferedZ();
|
||||
bool checked;
|
||||
int cell_id;
|
||||
CGUISpriteInstance* sprite;
|
||||
CGUISpriteInstance* sprite_over;
|
||||
CGUISpriteInstance* sprite_pressed;
|
||||
CGUISpriteInstance* sprite_disabled;
|
||||
|
||||
GUI<bool>::GetSetting(this, "checked", checked);
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
|
||||
if (checked)
|
||||
{
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2", sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite_over);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite_pressed);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite_disabled);
|
||||
}
|
||||
if (GUI<bool>::GetSetting(this, "checked"))
|
||||
DrawButton(
|
||||
m_CachedActualSize,
|
||||
GetBufferedZ(),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite2"),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite2_over"),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite2_pressed"),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite2_disabled"),
|
||||
GUI<int>::GetSetting(this, "cell_id"));
|
||||
else
|
||||
{
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_over", sprite_over);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_pressed", sprite_pressed);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_disabled", sprite_disabled);
|
||||
}
|
||||
|
||||
DrawButton(m_CachedActualSize,
|
||||
bz,
|
||||
*sprite,
|
||||
*sprite_over,
|
||||
*sprite_pressed,
|
||||
*sprite_disabled,
|
||||
cell_id);
|
||||
DrawButton(
|
||||
m_CachedActualSize,
|
||||
GetBufferedZ(),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite"),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite_over"),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite_pressed"),
|
||||
GUI<CGUISpriteInstance>::GetSetting(this, "sprite_disabled"),
|
||||
GUI<int>::GetSetting(this, "cell_id"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,9 +109,8 @@ void CDropDown::HandleMessage(SGUIMessage& Message)
|
|||
break;
|
||||
|
||||
bool scrollbar;
|
||||
CGUIList* pList;
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
float scroll = 0.f;
|
||||
if (scrollbar)
|
||||
scroll = GetScrollBar(0).GetPos();
|
||||
|
|
@ -119,7 +118,7 @@ void CDropDown::HandleMessage(SGUIMessage& Message)
|
|||
CRect rect = GetListRect();
|
||||
mouse.y += scroll;
|
||||
int set = -1;
|
||||
for (int i = 0; i < (int)pList->m_Items.size(); ++i)
|
||||
for (int i = 0; i < static_cast<int>(pList.m_Items.size()); ++i)
|
||||
{
|
||||
if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
|
||||
mouse.y < rect.top + m_ItemsYPositions[i+1] &&
|
||||
|
|
@ -185,9 +184,8 @@ void CDropDown::HandleMessage(SGUIMessage& Message)
|
|||
|
||||
if (!m_Open)
|
||||
{
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
if (pList->m_Items.empty())
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
if (pList.m_Items.empty())
|
||||
return;
|
||||
|
||||
m_Open = true;
|
||||
|
|
@ -343,20 +341,19 @@ InReaction CDropDown::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
|
||||
m_TimeOfLastInput = timer_Time();
|
||||
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
// let's look for the closest element
|
||||
// basically it's alphabetic order and "as many letters as we can get".
|
||||
int closest = -1;
|
||||
int bestIndex = -1;
|
||||
int difference = 1250;
|
||||
for (int i = 0; i < (int)pList->m_Items.size(); ++i)
|
||||
for (int i = 0; i < static_cast<int>(pList.m_Items.size()); ++i)
|
||||
{
|
||||
int indexOfDifference = 0;
|
||||
int diff = 0;
|
||||
for (size_t j = 0; j < m_InputBuffer.length(); ++j)
|
||||
{
|
||||
diff = std::abs((int)(pList->m_Items[i].GetRawString().LowerCase()[j]) - (int)m_InputBuffer[j]);
|
||||
diff = std::abs(static_cast<int>(pList.m_Items[i].GetRawString().LowerCase()[j]) - static_cast<int>(m_InputBuffer[j]));
|
||||
if (diff == 0)
|
||||
indexOfDifference = j+1;
|
||||
else
|
||||
|
|
@ -478,22 +475,20 @@ void CDropDown::Draw()
|
|||
GUI<float>::GetSetting(this, "dropdown_size", dropdown_size);
|
||||
GUI<float>::GetSetting(this, "button_width", button_width);
|
||||
|
||||
CGUISpriteInstance* sprite;
|
||||
CGUISpriteInstance* sprite2;
|
||||
CGUISpriteInstance* sprite2_second;
|
||||
int cell_id, selected = 0;
|
||||
CGUIColor color;
|
||||
|
||||
bool enabled;
|
||||
GUI<bool>::GetSetting(this, "enabled", enabled);
|
||||
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2", sprite2);
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, enabled ? "sprite" : "sprite_disabled");
|
||||
CGUISpriteInstance& sprite2 = GUI<CGUISpriteInstance>::GetSetting(this, "sprite2");
|
||||
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
GUI<int>::GetSetting(this, "selected", selected);
|
||||
GUI<CGUIColor>::GetSetting(this, enabled ? "textcolor_selected" : "textcolor_disabled", color);
|
||||
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, enabled ? "sprite" : "sprite_disabled", sprite);
|
||||
m_pGUI->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, m_CachedActualSize);
|
||||
|
||||
if (button_width > 0.f)
|
||||
{
|
||||
|
|
@ -502,21 +497,21 @@ void CDropDown::Draw()
|
|||
|
||||
if (!enabled)
|
||||
{
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite2_second);
|
||||
m_pGUI->DrawSprite(*sprite2_second || *sprite2, cell_id, bz + 0.05f, rect);
|
||||
CGUISpriteInstance& sprite2_second = GUI<CGUISpriteInstance>::GetSetting(this, "sprite2_disabled");
|
||||
m_pGUI->DrawSprite(sprite2_second || sprite2, cell_id, bz + 0.05f, rect);
|
||||
}
|
||||
else if (m_Open)
|
||||
{
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite2_second);
|
||||
m_pGUI->DrawSprite(*sprite2_second || *sprite2, cell_id, bz + 0.05f, rect);
|
||||
CGUISpriteInstance& sprite2_second = GUI<CGUISpriteInstance>::GetSetting(this, "sprite2_pressed");
|
||||
m_pGUI->DrawSprite(sprite2_second || sprite2, cell_id, bz + 0.05f, rect);
|
||||
}
|
||||
else if (m_MouseHovering)
|
||||
{
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite2_second);
|
||||
m_pGUI->DrawSprite(*sprite2_second || *sprite2, cell_id, bz + 0.05f, rect);
|
||||
CGUISpriteInstance& sprite2_second = GUI<CGUISpriteInstance>::GetSetting(this, "sprite2_over");
|
||||
m_pGUI->DrawSprite(sprite2_second || sprite2, cell_id, bz + 0.05f, rect);
|
||||
}
|
||||
else
|
||||
m_pGUI->DrawSprite(*sprite2, cell_id, bz + 0.05f, rect);
|
||||
m_pGUI->DrawSprite(sprite2, cell_id, bz + 0.05f, rect);
|
||||
}
|
||||
|
||||
if (selected != -1) // TODO: Maybe check validity completely?
|
||||
|
|
@ -528,21 +523,19 @@ void CDropDown::Draw()
|
|||
DrawText(selected, color, pos, bz+0.1f, cliparea);
|
||||
}
|
||||
|
||||
bool* scrollbar = NULL;
|
||||
bool old;
|
||||
GUI<bool>::GetSettingPointer(this, "scrollbar", scrollbar);
|
||||
|
||||
old = *scrollbar;
|
||||
// Disable scrollbar during drawing without sending a setting-changed message
|
||||
bool& scrollbar = GUI<bool>::GetSetting(this, "scrollbar");
|
||||
bool old = scrollbar;
|
||||
|
||||
if (m_Open)
|
||||
{
|
||||
if (m_HideScrollBar)
|
||||
*scrollbar = false;
|
||||
scrollbar = false;
|
||||
|
||||
DrawList(m_ElementHighlight, "sprite_list", "sprite_selectarea", "textcolor");
|
||||
|
||||
if (m_HideScrollBar)
|
||||
*scrollbar = old;
|
||||
scrollbar = old;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,10 +40,9 @@ void CImage::Draw()
|
|||
{
|
||||
float bz = GetBufferedZ();
|
||||
|
||||
CGUISpriteInstance* sprite;
|
||||
int cell_id;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, "sprite");
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, m_CachedActualSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,10 +82,8 @@ void CInput::UpdateBufferPositionSetting()
|
|||
|
||||
void CInput::ClearComposedText()
|
||||
{
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
|
||||
pCaption->erase(m_iInsertPos, m_iComposedLength);
|
||||
CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
pCaption.erase(m_iInsertPos, m_iComposedLength);
|
||||
m_iBufferPos = m_iInsertPos;
|
||||
UpdateBufferPositionSetting();
|
||||
m_iComposedLength = 0;
|
||||
|
|
@ -113,8 +111,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
return IN_PASS;
|
||||
|
||||
// Text has been committed, either single key presses or through an IME
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
std::wstring text = wstring_from_utf8(ev->ev.text.text);
|
||||
|
||||
m_WantedX = 0.0f;
|
||||
|
|
@ -128,10 +125,10 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
m_ComposingText = false;
|
||||
}
|
||||
|
||||
if (m_iBufferPos == (int)pCaption->length())
|
||||
pCaption->append(text);
|
||||
if (m_iBufferPos == static_cast<int>(pCaption.length()))
|
||||
pCaption.append(text);
|
||||
else
|
||||
pCaption->insert(m_iBufferPos, text);
|
||||
pCaption.insert(m_iBufferPos, text);
|
||||
|
||||
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
|
||||
|
||||
|
|
@ -151,8 +148,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
|
||||
// Text is being composed with an IME
|
||||
// TODO: indicate this by e.g. underlining the uncommitted text
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
const char* rawText = ev->ev.edit.text;
|
||||
int rawLength = strlen(rawText);
|
||||
std::wstring wtext = wstring_from_utf8(rawText);
|
||||
|
|
@ -175,7 +171,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
m_ComposingText = ev->ev.edit.start != 0 || rawLength != 0;
|
||||
if (m_ComposingText)
|
||||
{
|
||||
pCaption->insert(m_iInsertPos, wtext);
|
||||
pCaption.insert(m_iInsertPos, wtext);
|
||||
|
||||
// The text buffer is limited to SDL_TEXTEDITINGEVENT_TEXT_SIZE bytes, yet start
|
||||
// increases without limit, so don't let it advance beyond the composed text length
|
||||
|
|
@ -203,8 +199,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
// Since the GUI framework doesn't handle to set settings
|
||||
// in Unicode (CStrW), we'll simply retrieve the actual
|
||||
// pointer and edit that.
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
SDL_Keycode keyCode = ev->ev.key.keysym.sym;
|
||||
|
||||
ManuallyImmutableHandleKeyDownEvent(keyCode, pCaption);
|
||||
|
|
@ -220,7 +215,7 @@ InReaction CInput::ManuallyHandleEvent(const SDL_Event_* ev)
|
|||
}
|
||||
}
|
||||
|
||||
void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW* pCaption)
|
||||
void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW& pCaption)
|
||||
{
|
||||
if (m_Readonly)
|
||||
return;
|
||||
|
|
@ -246,14 +241,15 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW*
|
|||
{
|
||||
m_iBufferPos_Tail = -1;
|
||||
|
||||
if (pCaption->empty() || m_iBufferPos == 0)
|
||||
if (pCaption.empty() || m_iBufferPos == 0)
|
||||
break;
|
||||
|
||||
if (m_iBufferPos == (int)pCaption->length())
|
||||
*pCaption = pCaption->Left((long)pCaption->length() - 1);
|
||||
if (m_iBufferPos == static_cast<int>(pCaption.length()))
|
||||
pCaption = pCaption.Left(static_cast<long>(pCaption.length()) - 1);
|
||||
else
|
||||
*pCaption = pCaption->Left(m_iBufferPos - 1) +
|
||||
pCaption->Right((long)pCaption->length() - m_iBufferPos);
|
||||
pCaption =
|
||||
pCaption.Left(m_iBufferPos - 1) +
|
||||
pCaption.Right(static_cast<long>(pCaption.length()) - m_iBufferPos);
|
||||
|
||||
--m_iBufferPos;
|
||||
|
||||
|
|
@ -272,11 +268,12 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW*
|
|||
DeleteCurSelection();
|
||||
else
|
||||
{
|
||||
if (pCaption->empty() || m_iBufferPos == (int)pCaption->length())
|
||||
if (pCaption.empty() || m_iBufferPos == static_cast<int>(pCaption.length()))
|
||||
break;
|
||||
|
||||
*pCaption = pCaption->Left(m_iBufferPos) +
|
||||
pCaption->Right((long)pCaption->length() - (m_iBufferPos + 1));
|
||||
pCaption =
|
||||
pCaption.Left(m_iBufferPos) +
|
||||
pCaption.Right(static_cast<long>(pCaption.length()) - (m_iBufferPos + 1));
|
||||
|
||||
UpdateText(m_iBufferPos, m_iBufferPos + 1, m_iBufferPos);
|
||||
}
|
||||
|
|
@ -311,7 +308,7 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW*
|
|||
// check max length
|
||||
int max_length;
|
||||
GUI<int>::GetSetting(this, "max_length", max_length);
|
||||
if (max_length != 0 && (int)pCaption->length() >= max_length)
|
||||
if (max_length != 0 && static_cast<int>(pCaption.length()) >= max_length)
|
||||
break;
|
||||
|
||||
m_WantedX = 0.0f;
|
||||
|
|
@ -320,11 +317,12 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW*
|
|||
DeleteCurSelection();
|
||||
m_iBufferPos_Tail = -1;
|
||||
|
||||
if (m_iBufferPos == (int)pCaption->length())
|
||||
*pCaption += cooked;
|
||||
if (m_iBufferPos == static_cast<int>(pCaption.length()))
|
||||
pCaption += cooked;
|
||||
else
|
||||
*pCaption = pCaption->Left(m_iBufferPos) + cooked +
|
||||
pCaption->Right((long)pCaption->length() - m_iBufferPos);
|
||||
pCaption =
|
||||
pCaption.Left(m_iBufferPos) + cooked +
|
||||
pCaption.Right(static_cast<long>(pCaption.length()) - m_iBufferPos);
|
||||
|
||||
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos + 1);
|
||||
|
||||
|
|
@ -337,7 +335,7 @@ void CInput::ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW*
|
|||
}
|
||||
}
|
||||
|
||||
void CInput::ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW* pCaption)
|
||||
void CInput::ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW& pCaption)
|
||||
{
|
||||
bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
|
||||
|
||||
|
|
@ -377,7 +375,7 @@ void CInput::ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStr
|
|||
m_iBufferPos_Tail = m_iBufferPos;
|
||||
}
|
||||
|
||||
m_iBufferPos = (long)pCaption->length();
|
||||
m_iBufferPos = static_cast<long>(pCaption.length());
|
||||
m_WantedX = 0.0f;
|
||||
|
||||
UpdateAutoScroll();
|
||||
|
|
@ -440,7 +438,7 @@ void CInput::ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStr
|
|||
else if (!SelectingText())
|
||||
m_iBufferPos_Tail = m_iBufferPos;
|
||||
|
||||
if (m_iBufferPos < (int)pCaption->length())
|
||||
if (m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
++m_iBufferPos;
|
||||
}
|
||||
else
|
||||
|
|
@ -573,8 +571,7 @@ void CInput::ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStr
|
|||
|
||||
InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
||||
{
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
|
||||
bool shiftKeyPressed = g_keys[SDLK_RSHIFT] || g_keys[SDLK_LSHIFT];
|
||||
|
||||
|
|
@ -593,11 +590,12 @@ InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|||
if (SelectingText())
|
||||
DeleteCurSelection();
|
||||
|
||||
if (m_iBufferPos == (int)pCaption->length())
|
||||
*pCaption += text;
|
||||
if (m_iBufferPos == static_cast<int>(pCaption.length()))
|
||||
pCaption += text;
|
||||
else
|
||||
*pCaption = pCaption->Left(m_iBufferPos) + text +
|
||||
pCaption->Right((long) pCaption->length()-m_iBufferPos);
|
||||
pCaption =
|
||||
pCaption.Left(m_iBufferPos) + text +
|
||||
pCaption.Right(static_cast<long>(pCaption.length()) - m_iBufferPos);
|
||||
|
||||
UpdateText(m_iBufferPos, m_iBufferPos, m_iBufferPos+1);
|
||||
|
||||
|
|
@ -635,7 +633,7 @@ InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|||
virtualTo = m_iBufferPos;
|
||||
}
|
||||
|
||||
CStrW text = (pCaption->Left(virtualTo)).Right(virtualTo - virtualFrom);
|
||||
CStrW text = (pCaption.Left(virtualTo)).Right(virtualTo - virtualFrom);
|
||||
|
||||
sys_clipboard_set(&text[0]);
|
||||
|
||||
|
|
@ -659,10 +657,10 @@ InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|||
if (SelectingText())
|
||||
DeleteCurSelection();
|
||||
|
||||
if (!pCaption->empty() && m_iBufferPos != 0)
|
||||
if (!pCaption.empty() && m_iBufferPos != 0)
|
||||
{
|
||||
m_iBufferPos_Tail = m_iBufferPos;
|
||||
CStrW searchString = pCaption->Left(m_iBufferPos);
|
||||
CStrW searchString = pCaption.Left(m_iBufferPos);
|
||||
|
||||
// If we are starting in whitespace, adjust position until we get a non whitespace
|
||||
while (m_iBufferPos > 0)
|
||||
|
|
@ -705,22 +703,22 @@ InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|||
if (SelectingText())
|
||||
DeleteCurSelection();
|
||||
|
||||
if (!pCaption->empty() && m_iBufferPos < (int)pCaption->length())
|
||||
if (!pCaption.empty() && m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
// Delete the word to the right of the cursor
|
||||
m_iBufferPos_Tail = m_iBufferPos;
|
||||
|
||||
// Delete chars to the right unit we hit whitespace
|
||||
while (++m_iBufferPos < (int)pCaption->length())
|
||||
while (++m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (iswspace((*pCaption)[m_iBufferPos]) || iswpunct((*pCaption)[m_iBufferPos]))
|
||||
if (iswspace(pCaption[m_iBufferPos]) || iswpunct(pCaption[m_iBufferPos]))
|
||||
break;
|
||||
}
|
||||
|
||||
// Eliminate any whitespace behind the word we just deleted
|
||||
while (m_iBufferPos < (int)pCaption->length())
|
||||
while (m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (!iswspace((*pCaption)[m_iBufferPos]))
|
||||
if (!iswspace(pCaption[m_iBufferPos]))
|
||||
break;
|
||||
|
||||
++m_iBufferPos;
|
||||
|
|
@ -743,9 +741,9 @@ InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|||
else if (!SelectingText())
|
||||
m_iBufferPos_Tail = m_iBufferPos;
|
||||
|
||||
if (!pCaption->empty() && m_iBufferPos != 0)
|
||||
if (!pCaption.empty() && m_iBufferPos != 0)
|
||||
{
|
||||
CStrW searchString = pCaption->Left(m_iBufferPos);
|
||||
CStrW searchString = pCaption.Left(m_iBufferPos);
|
||||
|
||||
// If we are starting in whitespace, adjust position until we get a non whitespace
|
||||
while (m_iBufferPos > 0)
|
||||
|
|
@ -796,19 +794,19 @@ InReaction CInput::ManuallyHandleHotkeyEvent(const SDL_Event_* ev)
|
|||
else if (!SelectingText())
|
||||
m_iBufferPos_Tail = m_iBufferPos;
|
||||
|
||||
if (!pCaption->empty() && m_iBufferPos < (int)pCaption->length())
|
||||
if (!pCaption.empty() && m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
// Select chars to the right until we hit whitespace
|
||||
while (++m_iBufferPos < (int)pCaption->length())
|
||||
while (++m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (iswspace((*pCaption)[m_iBufferPos]) || iswpunct((*pCaption)[m_iBufferPos]))
|
||||
if (iswspace(pCaption[m_iBufferPos]) || iswpunct(pCaption[m_iBufferPos]))
|
||||
break;
|
||||
}
|
||||
|
||||
// Also select any whitespace following the word we just selected
|
||||
while (m_iBufferPos < (int)pCaption->length())
|
||||
while (m_iBufferPos < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (!iswspace((*pCaption)[m_iBufferPos]))
|
||||
if (!iswspace(pCaption[m_iBufferPos]))
|
||||
break;
|
||||
|
||||
++m_iBufferPos;
|
||||
|
|
@ -942,23 +940,22 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
|||
if (m_ComposingText)
|
||||
break;
|
||||
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
const CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
|
||||
if (pCaption->empty())
|
||||
if (pCaption.empty())
|
||||
break;
|
||||
|
||||
m_iBufferPos = m_iBufferPos_Tail = GetMouseHoveringTextPosition();
|
||||
|
||||
if (m_iBufferPos >= (int)pCaption->length())
|
||||
m_iBufferPos = m_iBufferPos_Tail = pCaption->length() - 1;
|
||||
if (m_iBufferPos >= (int)pCaption.length())
|
||||
m_iBufferPos = m_iBufferPos_Tail = pCaption.length() - 1;
|
||||
|
||||
// See if we are clicking over whitespace
|
||||
if (iswspace((*pCaption)[m_iBufferPos]))
|
||||
if (iswspace(pCaption[m_iBufferPos]))
|
||||
{
|
||||
// see if we are in a section of whitespace greater than one character
|
||||
if ((m_iBufferPos + 1 < (int) pCaption->length() && iswspace((*pCaption)[m_iBufferPos + 1])) ||
|
||||
(m_iBufferPos - 1 > 0 && iswspace((*pCaption)[m_iBufferPos - 1])))
|
||||
if ((m_iBufferPos + 1 < (int) pCaption.length() && iswspace(pCaption[m_iBufferPos + 1])) ||
|
||||
(m_iBufferPos - 1 > 0 && iswspace(pCaption[m_iBufferPos - 1])))
|
||||
{
|
||||
//
|
||||
// We are clicking in an area with more than one whitespace character
|
||||
|
|
@ -968,7 +965,7 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
|||
// skip the whitespace
|
||||
while (m_iBufferPos > 0)
|
||||
{
|
||||
if (!iswspace((*pCaption)[m_iBufferPos - 1]))
|
||||
if (!iswspace(pCaption[m_iBufferPos - 1]))
|
||||
break;
|
||||
|
||||
m_iBufferPos--;
|
||||
|
|
@ -976,52 +973,52 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
|||
// now go until we hit white space or punctuation
|
||||
while (m_iBufferPos > 0)
|
||||
{
|
||||
if (iswspace((*pCaption)[m_iBufferPos - 1]))
|
||||
if (iswspace(pCaption[m_iBufferPos - 1]))
|
||||
break;
|
||||
|
||||
m_iBufferPos--;
|
||||
|
||||
if (iswpunct((*pCaption)[m_iBufferPos]))
|
||||
if (iswpunct(pCaption[m_iBufferPos]))
|
||||
break;
|
||||
}
|
||||
|
||||
// [2] Then the right
|
||||
// go right until we are not in whitespace
|
||||
while (++m_iBufferPos_Tail < (int)pCaption->length())
|
||||
while (++m_iBufferPos_Tail < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (!iswspace((*pCaption)[m_iBufferPos_Tail]))
|
||||
if (!iswspace(pCaption[m_iBufferPos_Tail]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_iBufferPos_Tail == (int)pCaption->length())
|
||||
if (m_iBufferPos_Tail == static_cast<int>(pCaption.length()))
|
||||
break;
|
||||
|
||||
// now go to the right until we hit whitespace or punctuation
|
||||
while (++m_iBufferPos_Tail < (int)pCaption->length())
|
||||
while (++m_iBufferPos_Tail < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (iswspace((*pCaption)[m_iBufferPos_Tail]) || iswpunct((*pCaption)[m_iBufferPos_Tail]))
|
||||
if (iswspace(pCaption[m_iBufferPos_Tail]) || iswpunct(pCaption[m_iBufferPos_Tail]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// single whitespace so select word to the right
|
||||
while (++m_iBufferPos_Tail < (int)pCaption->length())
|
||||
while (++m_iBufferPos_Tail < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (!iswspace((*pCaption)[m_iBufferPos_Tail]))
|
||||
if (!iswspace(pCaption[m_iBufferPos_Tail]))
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_iBufferPos_Tail == (int)pCaption->length())
|
||||
if (m_iBufferPos_Tail == static_cast<int>(pCaption.length()))
|
||||
break;
|
||||
|
||||
// Don't include the leading whitespace
|
||||
m_iBufferPos = m_iBufferPos_Tail;
|
||||
|
||||
// now go to the right until we hit whitespace or punctuation
|
||||
while (++m_iBufferPos_Tail < (int)pCaption->length())
|
||||
while (++m_iBufferPos_Tail < static_cast<int>(pCaption.length()))
|
||||
{
|
||||
if (iswspace((*pCaption)[m_iBufferPos_Tail]) || iswpunct((*pCaption)[m_iBufferPos_Tail]))
|
||||
if (iswspace(pCaption[m_iBufferPos_Tail]) || iswpunct(pCaption[m_iBufferPos_Tail]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1032,17 +1029,17 @@ void CInput::HandleMessage(SGUIMessage& Message)
|
|||
// go until we hit white space or punctuation
|
||||
while (m_iBufferPos > 0)
|
||||
{
|
||||
if (iswspace((*pCaption)[m_iBufferPos - 1]))
|
||||
if (iswspace(pCaption[m_iBufferPos - 1]))
|
||||
break;
|
||||
|
||||
m_iBufferPos--;
|
||||
|
||||
if (iswpunct((*pCaption)[m_iBufferPos]))
|
||||
if (iswpunct(pCaption[m_iBufferPos]))
|
||||
break;
|
||||
}
|
||||
// go to the right until we hit whitespace or punctuation
|
||||
while (++m_iBufferPos_Tail < (int)pCaption->length())
|
||||
if (iswspace((*pCaption)[m_iBufferPos_Tail]) || iswpunct((*pCaption)[m_iBufferPos_Tail]))
|
||||
while (++m_iBufferPos_Tail < static_cast<int>(pCaption.length()))
|
||||
if (iswspace(pCaption[m_iBufferPos_Tail]) || iswpunct(pCaption[m_iBufferPos_Tail]))
|
||||
break;
|
||||
}
|
||||
UpdateAutoScroll();
|
||||
|
|
@ -1185,9 +1182,7 @@ void CInput::Draw()
|
|||
GUI<CGUIColor>::GetSetting(this, "textcolor_selected", color_selected);
|
||||
CStrIntern font_name(font_name_w.ToUTF8());
|
||||
|
||||
// Get pointer of caption, it might be very large, and we don't
|
||||
// want to copy it continuously.
|
||||
CStrW* pCaption = NULL;
|
||||
const CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
wchar_t mask_char = L'*';
|
||||
if (mask)
|
||||
{
|
||||
|
|
@ -1196,19 +1191,14 @@ void CInput::Draw()
|
|||
if (maskStr.length() > 0)
|
||||
mask_char = maskStr[0];
|
||||
}
|
||||
else
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
|
||||
CGUISpriteInstance* sprite = NULL;
|
||||
CGUISpriteInstance* sprite_selectarea = NULL;
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, "sprite");
|
||||
CGUISpriteInstance& sprite_selectarea = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_selectarea");
|
||||
|
||||
int cell_id;
|
||||
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_selectarea", sprite_selectarea);
|
||||
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, m_CachedActualSize);
|
||||
|
||||
float scroll = 0.f;
|
||||
if (scrollbar && multiline)
|
||||
|
|
@ -1397,14 +1387,13 @@ void CInput::Draw()
|
|||
rect.right = m_CachedActualSize.right;
|
||||
}
|
||||
|
||||
if (sprite_selectarea)
|
||||
GetGUI()->DrawSprite(*sprite_selectarea, cell_id, bz+0.05f, rect);
|
||||
m_pGUI->DrawSprite(sprite_selectarea, cell_id, bz+0.05f, rect);
|
||||
}
|
||||
|
||||
if (i < (int)it->m_ListOfX.size())
|
||||
{
|
||||
if (!mask)
|
||||
x_pointer += (float)font.GetCharacterWidth((*pCaption)[it->m_ListStart + i]);
|
||||
x_pointer += (float)font.GetCharacterWidth(pCaption[it->m_ListStart + i]);
|
||||
else
|
||||
x_pointer += (float)font.GetCharacterWidth(mask_char);
|
||||
}
|
||||
|
|
@ -1490,7 +1479,7 @@ void CInput::Draw()
|
|||
if (i != (int)it->m_ListOfX.size())
|
||||
{
|
||||
if (!mask)
|
||||
textRenderer.PrintfAdvance(L"%lc", (*pCaption)[it->m_ListStart + i]);
|
||||
textRenderer.PrintfAdvance(L"%lc", pCaption[it->m_ListStart + i]);
|
||||
else
|
||||
textRenderer.PrintfAdvance(L"%lc", mask_char);
|
||||
}
|
||||
|
|
@ -1997,8 +1986,7 @@ int CInput::GetXTextPosition(const std::list<SRow>::const_iterator& current, con
|
|||
|
||||
void CInput::DeleteCurSelection()
|
||||
{
|
||||
CStrW* pCaption = nullptr;
|
||||
GUI<CStrW>::GetSettingPointer(this, "caption", pCaption);
|
||||
CStrW& pCaption = GUI<CStrW>::GetSetting(this, "caption");
|
||||
|
||||
int virtualFrom;
|
||||
int virtualTo;
|
||||
|
|
@ -2014,8 +2002,9 @@ void CInput::DeleteCurSelection()
|
|||
virtualTo = m_iBufferPos;
|
||||
}
|
||||
|
||||
*pCaption = pCaption->Left(virtualFrom) +
|
||||
pCaption->Right((long)pCaption->length() - virtualTo);
|
||||
pCaption =
|
||||
pCaption.Left(virtualFrom) +
|
||||
pCaption.Right(static_cast<long>(pCaption.length()) - virtualTo);
|
||||
|
||||
UpdateText(virtualFrom, virtualTo, virtualFrom);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ protected:
|
|||
/**
|
||||
* Handle events manually to catch keys which change the text.
|
||||
*/
|
||||
virtual void ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW* pCaption);
|
||||
virtual void ManuallyMutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW& pCaption);
|
||||
|
||||
/**
|
||||
* Handle events manually to catch keys which don't change the text.
|
||||
*/
|
||||
virtual void ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW* pCaption);
|
||||
virtual void ManuallyImmutableHandleKeyDownEvent(const SDL_Keycode keyCode, CStrW& pCaption);
|
||||
|
||||
/**
|
||||
* Handle hotkey events (called by ManuallyHandleEvent)
|
||||
|
|
|
|||
|
|
@ -72,12 +72,11 @@ CList::~CList()
|
|||
void CList::SetupText()
|
||||
{
|
||||
m_Modified = true;
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
|
||||
//ENSURE(m_GeneratedTexts.size()>=1);
|
||||
|
||||
m_ItemsYPositions.resize(pList->m_Items.size()+1);
|
||||
m_ItemsYPositions.resize(pList.m_Items.size() + 1);
|
||||
|
||||
// Delete all generated texts. Some could probably be saved,
|
||||
// but this is easier, and this function will never be called
|
||||
|
|
@ -104,12 +103,12 @@ void CList::SetupText()
|
|||
// Generate texts
|
||||
float buffered_y = 0.f;
|
||||
|
||||
for (size_t i = 0; i < pList->m_Items.size(); ++i)
|
||||
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
||||
{
|
||||
CGUIText* text;
|
||||
|
||||
if (!pList->m_Items[i].GetOriginalString().empty())
|
||||
text = &AddText(pList->m_Items[i], font, width, buffer_zone, this);
|
||||
if (!pList.m_Items[i].GetOriginalString().empty())
|
||||
text = &AddText(pList.m_Items[i], font, width, buffer_zone, this);
|
||||
else
|
||||
{
|
||||
// Minimum height of a space character of the current font size
|
||||
|
|
@ -122,7 +121,7 @@ void CList::SetupText()
|
|||
buffered_y += text->GetSize().cy;
|
||||
}
|
||||
|
||||
m_ItemsYPositions[pList->m_Items.size()] = buffered_y;
|
||||
m_ItemsYPositions[pList.m_Items.size()] = buffered_y;
|
||||
|
||||
// Setup scrollbar
|
||||
if (scrollbar)
|
||||
|
|
@ -330,17 +329,11 @@ void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spri
|
|||
{
|
||||
CRect rect = GetListRect();
|
||||
|
||||
CGUISpriteInstance* sprite = NULL;
|
||||
CGUISpriteInstance* sprite_selectarea = NULL;
|
||||
int cell_id;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite, sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite_selected, sprite_selectarea);
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, _sprite);
|
||||
CGUISpriteInstance& sprite_selectarea = GUI<CGUISpriteInstance>::GetSetting(this, _sprite_selected);
|
||||
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, rect);
|
||||
const int cell_id = GUI<int>::GetSetting(this, "cell_id");
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, rect);
|
||||
|
||||
float scroll = 0.f;
|
||||
if (scrollbar)
|
||||
|
|
@ -372,14 +365,16 @@ void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spri
|
|||
rect_sel.left = GetScrollBar(0).GetOuterRect().right;
|
||||
}
|
||||
|
||||
GetGUI()->DrawSprite(*sprite_selectarea, cell_id, bz+0.05f, rect_sel);
|
||||
m_pGUI->DrawSprite(sprite_selectarea, cell_id, bz+0.05f, rect_sel);
|
||||
}
|
||||
}
|
||||
|
||||
CGUIColor color;
|
||||
GUI<CGUIColor>::GetSetting(this, _textcolor, color);
|
||||
|
||||
for (size_t i = 0; i < pList->m_Items.size(); ++i)
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
|
||||
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
||||
{
|
||||
if (m_ItemsYPositions[i+1] - scroll < 0 ||
|
||||
m_ItemsYPositions[i] - scroll > rect.GetHeight())
|
||||
|
|
@ -406,18 +401,17 @@ void CList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spri
|
|||
|
||||
void CList::AddItem(const CStrW& str, const CStrW& data)
|
||||
{
|
||||
CGUIList* pList;
|
||||
CGUIList* pListData;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list_data", pListData);
|
||||
|
||||
CGUIString gui_string;
|
||||
gui_string.SetValue(str);
|
||||
pList->m_Items.push_back(gui_string);
|
||||
|
||||
// Do not send a settings-changed message
|
||||
CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
pList.m_Items.push_back(gui_string);
|
||||
|
||||
CGUIString data_string;
|
||||
data_string.SetValue(data);
|
||||
pListData->m_Items.push_back(data_string);
|
||||
CGUIList& pListData = GUI<CGUIList>::GetSetting(this, "list_data");
|
||||
pListData.m_Items.push_back(data_string);
|
||||
|
||||
// TODO Temp
|
||||
SetupText();
|
||||
|
|
@ -438,13 +432,11 @@ bool CList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile)
|
|||
|
||||
void CList::SelectNextElement()
|
||||
{
|
||||
int selected;
|
||||
GUI<int>::GetSetting(this, "selected", selected);
|
||||
int selected = GUI<int>::GetSetting(this, "selected");
|
||||
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
|
||||
if (selected != (int)pList->m_Items.size()-1)
|
||||
if (selected != static_cast<int>(pList.m_Items.size()) - 1)
|
||||
{
|
||||
++selected;
|
||||
GUI<int>::SetSetting(this, "selected", selected);
|
||||
|
|
@ -457,8 +449,7 @@ void CList::SelectNextElement()
|
|||
|
||||
void CList::SelectPrevElement()
|
||||
{
|
||||
int selected;
|
||||
GUI<int>::GetSetting(this, "selected", selected);
|
||||
int selected = GUI<int>::GetSetting(this, "selected");
|
||||
|
||||
if (selected > 0)
|
||||
{
|
||||
|
|
@ -473,38 +464,29 @@ void CList::SelectPrevElement()
|
|||
|
||||
void CList::SelectFirstElement()
|
||||
{
|
||||
int selected;
|
||||
GUI<int>::GetSetting(this, "selected", selected);
|
||||
|
||||
if (selected >= 0)
|
||||
if (GUI<int>::GetSetting(this, "selected") >= 0)
|
||||
GUI<int>::SetSetting(this, "selected", 0);
|
||||
}
|
||||
|
||||
void CList::SelectLastElement()
|
||||
{
|
||||
int selected;
|
||||
GUI<int>::GetSetting(this, "selected", selected);
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
const int index = static_cast<int>(pList.m_Items.size()) - 1;
|
||||
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
|
||||
if (selected != (int)pList->m_Items.size()-1)
|
||||
GUI<int>::SetSetting(this, "selected", (int)pList->m_Items.size()-1);
|
||||
if (GUI<int>::GetSetting(this, "selected") != index)
|
||||
GUI<int>::SetSetting(this, "selected", index);
|
||||
}
|
||||
|
||||
void CList::UpdateAutoScroll()
|
||||
{
|
||||
int selected;
|
||||
bool scrollbar;
|
||||
float scroll;
|
||||
GUI<int>::GetSetting(this, "selected", selected);
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
const int selected = GUI<int>::GetSetting(this, "selected");
|
||||
const bool scrollbar = GUI<bool>::GetSetting(this, "scrollbar");
|
||||
|
||||
// No scrollbar, no scrolling (at least it's not made to work properly).
|
||||
if (!scrollbar || selected < 0 || (std::size_t) selected >= m_ItemsYPositions.size())
|
||||
if (!scrollbar || selected < 0 || static_cast<std::size_t>(selected) >= m_ItemsYPositions.size())
|
||||
return;
|
||||
|
||||
scroll = GetScrollBar(0).GetPos();
|
||||
float scroll = GetScrollBar(0).GetPos();
|
||||
|
||||
// Check upper boundary
|
||||
if (m_ItemsYPositions[selected] < scroll)
|
||||
|
|
@ -522,13 +504,8 @@ void CList::UpdateAutoScroll()
|
|||
|
||||
int CList::GetHoveredItem()
|
||||
{
|
||||
bool scrollbar;
|
||||
CGUIList* pList;
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
float scroll = 0.f;
|
||||
if (scrollbar)
|
||||
scroll = GetScrollBar(0).GetPos();
|
||||
const bool scrollbar = GUI<bool>::GetSetting(this, "scrollbar");
|
||||
const float scroll = scrollbar ? GetScrollBar(0).GetPos() : 0.f;
|
||||
|
||||
const CRect& rect = GetListRect();
|
||||
CPos mouse = m_pGUI->GetMousePos();
|
||||
|
|
@ -540,7 +517,8 @@ int CList::GetHoveredItem()
|
|||
mouse.x <= GetScrollBar(0).GetOuterRect().right)
|
||||
return -1;
|
||||
|
||||
for (size_t i = 0; i < pList->m_Items.size(); ++i)
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
||||
if (mouse.y >= rect.top + m_ItemsYPositions[i] &&
|
||||
mouse.y < rect.top + m_ItemsYPositions[i + 1])
|
||||
return i;
|
||||
|
|
|
|||
|
|
@ -41,10 +41,8 @@ COList::COList(CGUI* pGUI)
|
|||
|
||||
void COList::SetupText()
|
||||
{
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
|
||||
m_ItemsYPositions.resize(pList->m_Items.size() + 1);
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
m_ItemsYPositions.resize(pList.m_Items.size() + 1);
|
||||
|
||||
// Delete all generated texts. Some could probably be saved,
|
||||
// but this is easier, and this function will never be called
|
||||
|
|
@ -86,7 +84,7 @@ void COList::SetupText()
|
|||
// Generate texts
|
||||
float buffered_y = 0.f;
|
||||
|
||||
for (size_t i = 0; i < pList->m_Items.size(); ++i)
|
||||
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
||||
{
|
||||
m_ItemsYPositions[i] = buffered_y;
|
||||
float shift = 0.0f;
|
||||
|
|
@ -96,11 +94,10 @@ void COList::SetupText()
|
|||
if (column.m_Width > 0 && column.m_Width < 1)
|
||||
width *= m_TotalAvailableColumnWidth;
|
||||
|
||||
CGUIList* pList_c;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list_" + column.m_Id, pList_c);
|
||||
CGUIList& pList_c = GUI<CGUIList>::GetSetting(this, "list_" + column.m_Id);
|
||||
CGUIText* text;
|
||||
if (!pList_c->m_Items[i].GetOriginalString().empty())
|
||||
text = &AddText(pList_c->m_Items[i], font, width, buffer_zone, this);
|
||||
if (!pList_c.m_Items[i].GetOriginalString().empty())
|
||||
text = &AddText(pList_c.m_Items[i], font, width, buffer_zone, this);
|
||||
else
|
||||
{
|
||||
// Minimum height of a space character of the current font size
|
||||
|
|
@ -113,7 +110,7 @@ void COList::SetupText()
|
|||
buffered_y += shift;
|
||||
}
|
||||
|
||||
m_ItemsYPositions[pList->m_Items.size()] = buffered_y;
|
||||
m_ItemsYPositions[pList.m_Items.size()] = buffered_y;
|
||||
|
||||
if (scrollbar)
|
||||
{
|
||||
|
|
@ -316,17 +313,13 @@ void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spr
|
|||
|
||||
CRect rect = GetListRect();
|
||||
|
||||
CGUISpriteInstance* sprite = NULL;
|
||||
CGUISpriteInstance* sprite_selectarea = NULL;
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, _sprite);
|
||||
CGUISpriteInstance& sprite_selectarea = GUI<CGUISpriteInstance>::GetSetting(this, _sprite_selected);
|
||||
|
||||
int cell_id;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite, sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, _sprite_selected, sprite_selectarea);
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
|
||||
CGUIList* pList;
|
||||
GUI<CGUIList>::GetSettingPointer(this, "list", pList);
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, rect);
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, rect);
|
||||
|
||||
float scroll = 0.f;
|
||||
if (scrollbar)
|
||||
|
|
@ -362,16 +355,15 @@ void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spr
|
|||
}
|
||||
|
||||
// Draw item selection
|
||||
GetGUI()->DrawSprite(*sprite_selectarea, cell_id, bz+0.05f, rect_sel);
|
||||
m_pGUI->DrawSprite(sprite_selectarea, cell_id, bz+0.05f, rect_sel);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw line above column header
|
||||
CGUISpriteInstance* sprite_heading = NULL;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_heading", sprite_heading);
|
||||
CGUISpriteInstance& sprite_heading = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_heading");
|
||||
CRect rect_head(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right,
|
||||
m_CachedActualSize.top + m_HeadingHeight);
|
||||
GetGUI()->DrawSprite(*sprite_heading, cell_id, bz, rect_head);
|
||||
m_pGUI->DrawSprite(sprite_heading, cell_id, bz, rect_head);
|
||||
|
||||
// Draw column headers
|
||||
bool sortable;
|
||||
|
|
@ -404,21 +396,22 @@ void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spr
|
|||
// Draw sort arrows in colum header
|
||||
if (sortable)
|
||||
{
|
||||
CGUISpriteInstance* sprite;
|
||||
CStr spriteName;
|
||||
if (selectedColumn == m_Columns[col].m_Id)
|
||||
{
|
||||
if (selectedColumnOrder == 0)
|
||||
LOGERROR("selected_column_order must not be 0");
|
||||
|
||||
if (selectedColumnOrder != -1)
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_asc", sprite);
|
||||
spriteName = "sprite_asc";
|
||||
else
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_desc", sprite);
|
||||
spriteName = "sprite_desc";
|
||||
}
|
||||
else
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_not_sorted", sprite);
|
||||
spriteName = "sprite_not_sorted";
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz + 0.1f, CRect(leftTopCorner + CPos(width - SORT_SPRITE_DIM, 0), leftTopCorner + CPos(width, SORT_SPRITE_DIM)));
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, spriteName);
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz + 0.1f, CRect(leftTopCorner + CPos(width - SORT_SPRITE_DIM, 0), leftTopCorner + CPos(width, SORT_SPRITE_DIM)));
|
||||
}
|
||||
|
||||
// Draw column header text
|
||||
|
|
@ -427,8 +420,9 @@ void COList::DrawList(const int& selected, const CStr& _sprite, const CStr& _spr
|
|||
}
|
||||
|
||||
// Draw list items for each column
|
||||
const CGUIList& pList = GUI<CGUIList>::GetSetting(this, "list");
|
||||
const size_t objectsCount = m_Columns.size();
|
||||
for (size_t i = 0; i < pList->m_Items.size(); ++i)
|
||||
for (size_t i = 0; i < pList.m_Items.size(); ++i)
|
||||
{
|
||||
if (m_ItemsYPositions[i+1] - scroll < 0 ||
|
||||
m_ItemsYPositions[i] - scroll > rect.GetHeight())
|
||||
|
|
|
|||
|
|
@ -64,20 +64,19 @@ void CProgressBar::HandleMessage(SGUIMessage& Message)
|
|||
|
||||
void CProgressBar::Draw()
|
||||
{
|
||||
CGUISpriteInstance& sprite_bar = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_bar");
|
||||
CGUISpriteInstance& sprite_background = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_background");
|
||||
|
||||
float bz = GetBufferedZ();
|
||||
|
||||
CGUISpriteInstance* sprite_background;
|
||||
CGUISpriteInstance* sprite_bar;
|
||||
int cell_id = 0;
|
||||
float value = 0;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_background", sprite_background);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_bar", sprite_bar);
|
||||
GUI<float>::GetSetting(this, "caption", value);
|
||||
|
||||
GetGUI()->DrawSprite(*sprite_background, cell_id, bz, m_CachedActualSize);
|
||||
m_pGUI->DrawSprite(sprite_background, cell_id, bz, m_CachedActualSize);
|
||||
|
||||
// Get size of bar (notice it is drawn slightly closer, to appear above the background)
|
||||
CRect bar_size(m_CachedActualSize.left, m_CachedActualSize.top,
|
||||
m_CachedActualSize.left+m_CachedActualSize.GetWidth()*(value/100.f), m_CachedActualSize.bottom);
|
||||
GetGUI()->DrawSprite(*sprite_bar, cell_id, bz+0.01f, bar_size);
|
||||
m_pGUI->DrawSprite(sprite_bar, cell_id, bz+0.01f, bar_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,19 +113,18 @@ void CSlider::HandleMessage(SGUIMessage& Message)
|
|||
|
||||
void CSlider::Draw()
|
||||
{
|
||||
CGUISpriteInstance* sprite;
|
||||
CGUISpriteInstance* sprite_button;
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, "sprite_bar");
|
||||
CGUISpriteInstance& sprite_button = GUI<CGUISpriteInstance>::GetSetting(this, "sprite");
|
||||
|
||||
int cell_id;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_bar", sprite);
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite_button);
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
|
||||
CRect slider_line(m_CachedActualSize);
|
||||
slider_line.left += m_ButtonSide / 2.0f;
|
||||
slider_line.right -= m_ButtonSide / 2.0f;
|
||||
float bz = GetBufferedZ();
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, slider_line);
|
||||
GetGUI()->DrawSprite(*sprite_button, cell_id, bz, GetButtonRect());
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, slider_line);
|
||||
m_pGUI->DrawSprite(sprite_button, cell_id, bz, GetButtonRect());
|
||||
}
|
||||
|
||||
void CSlider::UpdateValue()
|
||||
|
|
|
|||
|
|
@ -75,9 +75,6 @@ void CText::SetupText()
|
|||
// TODO Gee: (2004-08-14) Don't define standard like this. Do it with the default style.
|
||||
font = L"default";
|
||||
|
||||
CGUIString* caption = nullptr;
|
||||
GUI<CGUIString>::GetSettingPointer(this, "caption", caption);
|
||||
|
||||
bool scrollbar;
|
||||
GUI<bool>::GetSetting(this, "scrollbar", scrollbar);
|
||||
|
||||
|
|
@ -86,10 +83,10 @@ void CText::SetupText()
|
|||
if (scrollbar && GetScrollBar(0).GetStyle())
|
||||
width -= GetScrollBar(0).GetStyle()->m_Width;
|
||||
|
||||
const CGUIString& caption = GUI<CGUIString>::GetSetting(this, "caption");
|
||||
const float buffer_zone = GUI<float>::GetSetting(this, "buffer_zone");
|
||||
|
||||
float buffer_zone = 0.f;
|
||||
GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, *caption, font, width, buffer_zone, this);
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, caption, font, width, buffer_zone, this);
|
||||
|
||||
if (!scrollbar)
|
||||
CalculateTextPosition(m_CachedActualSize, m_TextPos, m_GeneratedTexts[0]);
|
||||
|
|
@ -198,14 +195,14 @@ void CText::Draw()
|
|||
// Draw scrollbar
|
||||
IGUIScrollBarOwner::Draw();
|
||||
|
||||
CGUISpriteInstance* sprite;
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, "sprite");
|
||||
|
||||
int cell_id;
|
||||
bool clip;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
|
||||
GUI<int>::GetSetting(this, "cell_id", cell_id);
|
||||
GUI<bool>::GetSetting(this, "clip", clip);
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, cell_id, bz, m_CachedActualSize);
|
||||
m_pGUI->DrawSprite(sprite, cell_id, bz, m_CachedActualSize);
|
||||
|
||||
float scroll = 0.f;
|
||||
if (scrollbar)
|
||||
|
|
|
|||
|
|
@ -72,13 +72,12 @@ void CTooltip::SetupText()
|
|||
float buffer_zone = 0.f;
|
||||
GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
|
||||
|
||||
CGUIString* caption = nullptr;
|
||||
GUI<CGUIString>::GetSettingPointer(this, "caption", caption);
|
||||
const CGUIString& caption = GUI<CGUIString>::GetSetting(this, "caption");
|
||||
|
||||
float max_width = 0.f;
|
||||
GUI<float>::GetSetting(this, "maxwidth", max_width);
|
||||
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, *caption, font, max_width, buffer_zone, this);
|
||||
m_GeneratedTexts[0] = CGUIText(m_pGUI, caption, font, max_width, buffer_zone, this);
|
||||
|
||||
// Position the tooltip relative to the mouse:
|
||||
|
||||
|
|
@ -149,8 +148,7 @@ void CTooltip::Draw()
|
|||
{
|
||||
float z = 900.f; // TODO: Find a nicer way of putting the tooltip on top of everything else
|
||||
|
||||
CGUISpriteInstance* sprite;
|
||||
GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
|
||||
CGUISpriteInstance& sprite = GUI<CGUISpriteInstance>::GetSetting(this, "sprite");
|
||||
|
||||
// Normally IGUITextOwner will handle this updating but since SetupText can modify the position
|
||||
// we need to call it now *before* we do the rest of the drawing
|
||||
|
|
@ -160,7 +158,7 @@ void CTooltip::Draw()
|
|||
m_GeneratedTextsValid = true;
|
||||
}
|
||||
|
||||
GetGUI()->DrawSprite(*sprite, 0, z, m_CachedActualSize);
|
||||
m_pGUI->DrawSprite(sprite, 0, z, m_CachedActualSize);
|
||||
|
||||
CGUIColor color;
|
||||
GUI<CGUIColor>::GetSetting(this, "textcolor", color);
|
||||
|
|
|
|||
|
|
@ -325,6 +325,18 @@ PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Settin
|
|||
return PSRETURN_OK;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool GUI<T>::HasSetting(const IGUIObject* pObject, const CStr& Setting)
|
||||
{
|
||||
return pObject->m_Settings.count(Setting) != 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting)
|
||||
{
|
||||
return static_cast<CGUISetting<T>* >(pObject->m_Settings.at(Setting))->m_pSetting;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
PSRETURN GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value)
|
||||
{
|
||||
|
|
@ -406,6 +418,8 @@ PSRETURN GUI<T>::SetSettingWrap(IGUIObject* pObject, const CStr& Setting, const
|
|||
// Instantiate templated functions:
|
||||
// These functions avoid copies by working with a pointer and move semantics.
|
||||
#define TYPE(T) \
|
||||
template bool GUI<T>::HasSetting(const IGUIObject* pObject, const CStr& Setting); \
|
||||
template T& GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting); \
|
||||
template PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value); \
|
||||
template PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, T& Value, const bool& SkipMessage); \
|
||||
template class CGUISetting<T>; \
|
||||
|
|
|
|||
|
|
@ -132,12 +132,27 @@ class GUI
|
|||
public:
|
||||
NONCOPYABLE(GUI);
|
||||
|
||||
/**
|
||||
* Determines whether a setting with the given name is registered.
|
||||
* This function may be used as a safeguard for GetSetting.
|
||||
*/
|
||||
static bool HasSetting(const IGUIObject* pObject, const CStr& Setting);
|
||||
|
||||
/**
|
||||
* Get a mutable reference to the setting.
|
||||
* If no such setting exists, an exception of type std::out_of_range is thrown.
|
||||
*
|
||||
* If the value is modified, there is no GUIM_SETTINGS_UPDATED message sent.
|
||||
* SetSetting should be used to modify the value if there is a use for the message.
|
||||
*/
|
||||
static T& GetSetting(const IGUIObject* pObject, const CStr& Setting);
|
||||
|
||||
// Like GetSetting (below), but doesn't make a copy of the value
|
||||
// (so it can be modified later)
|
||||
static PSRETURN GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value);
|
||||
|
||||
/**
|
||||
* Retrieves a setting by name from object pointer
|
||||
* Copy-assigns the current setting value to the given reference.
|
||||
*
|
||||
* @param pObject Object pointer
|
||||
* @param Setting Setting by name
|
||||
|
|
@ -147,10 +162,6 @@ public:
|
|||
|
||||
/**
|
||||
* Sets a value by name using a real datatype as input.
|
||||
*
|
||||
* This is the official way of setting a setting, no other
|
||||
* way should only cautiously be used!
|
||||
*
|
||||
* This variant will use the move-assignment.
|
||||
*
|
||||
* @param pObject Object pointer
|
||||
|
|
|
|||
|
|
@ -222,16 +222,15 @@ void IGUIObject::UpdateCachedSize()
|
|||
float aspectratio = 0.f;
|
||||
GUI<float>::GetSetting(this, "aspectratio", aspectratio);
|
||||
|
||||
CClientArea* ca;
|
||||
GUI<CClientArea>::GetSettingPointer(this, "size", ca);
|
||||
const CClientArea& ca = GUI<CClientArea>::GetSetting(this, "size");
|
||||
|
||||
// If absolute="false" and the object has got a parent,
|
||||
// use its cached size instead of the screen. Notice
|
||||
// it must have just been cached for it to work.
|
||||
if (absolute == false && m_pParent && !IsRootObject())
|
||||
m_CachedActualSize = ca->GetClientArea(m_pParent->m_CachedActualSize);
|
||||
m_CachedActualSize = ca.GetClientArea(m_pParent->m_CachedActualSize);
|
||||
else
|
||||
m_CachedActualSize = ca->GetClientArea(CRect(0.f, 0.f, g_xres / g_GuiScale, g_yres / g_GuiScale));
|
||||
m_CachedActualSize = ca.GetClientArea(CRect(0.f, 0.f, g_xres / g_GuiScale, g_yres / g_GuiScale));
|
||||
|
||||
// In a few cases, GUI objects have to resize to fill the screen
|
||||
// but maintain a constant aspect ratio.
|
||||
|
|
|
|||
Loading…
Reference in a new issue