Browse Source

DiabloUI: make UiArtText follow mutating char*

pull/2376/head
Vladimir Olteanu 5 years ago committed by Anders Jenbo
parent
commit
ed9b105299
  1. 2
      Source/DiabloUI/diabloui.cpp
  2. 2
      Source/DiabloUI/selgame.cpp
  3. 2
      Source/DiabloUI/selhero.cpp
  4. 21
      Source/DiabloUI/ui_item.h

2
Source/DiabloUI/diabloui.cpp

@ -725,7 +725,7 @@ void Render(UiText *uiText)
void Render(const UiArtText *uiArtText)
{
DrawArtStr(uiArtText->m_text, uiArtText->m_rect, uiArtText->m_iFlags);
DrawArtStr(uiArtText->text(), uiArtText->m_rect, uiArtText->m_iFlags);
}
void Render(const UiImage *uiImage)

2
Source/DiabloUI/selgame.cpp

@ -139,7 +139,7 @@ void selgame_GameSelection_Select(int value)
UiAddLogo(&vecSelGameDialog);
SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 };
vecSelGameDialog.push_back(std::make_unique<UiArtText>(title, rect1, UIS_CENTER | UIS_BIG));
vecSelGameDialog.push_back(std::make_unique<UiArtText>(&title, rect1, UIS_CENTER | UIS_BIG));
SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 34), (Sint16)(UI_OFFSET_Y + 211), 205, 33 };
vecSelGameDialog.push_back(std::make_unique<UiArtText>(selgame_Label, rect2, UIS_CENTER | UIS_BIG));

2
Source/DiabloUI/selhero.cpp

@ -466,7 +466,7 @@ void selhero_Init()
vecSelDlgItems.clear();
SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 24), (Sint16)(UI_OFFSET_Y + 161), 590, 35 };
vecSelHeroDialog.push_back(std::make_unique<UiArtText>(title, rect1, UIS_CENTER | UIS_BIG));
vecSelHeroDialog.push_back(std::make_unique<UiArtText>(&title, rect1, UIS_CENTER | UIS_BIG));
SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 30), (Sint16)(UI_OFFSET_Y + 211), 180, 76 };
auto heroImg = std::make_unique<UiImage>(&ArtHero, static_cast<int>(enum_size<HeroClass>::value), rect2);

21
Source/DiabloUI/ui_item.h

@ -135,15 +135,30 @@ class UiArtText : public UiItemBase {
public:
UiArtText(const char *text, SDL_Rect rect, int flags = 0)
: UiItemBase(rect, flags)
, m_text(text)
{
m_type = UI_ART_TEXT;
};
UiArtText(const char **ptext, SDL_Rect rect, int flags = 0)
: UiItemBase(rect, flags)
, m_ptext(ptext)
{
m_type = UI_ART_TEXT;
m_text = text;
};
const char *text() const
{
if (m_text != nullptr)
return m_text;
return *m_ptext;
}
~UiArtText() {};
//private:
const char *m_text;
private:
const char *m_text = nullptr;
const char **m_ptext = nullptr;
};
//=============================================================================

Loading…
Cancel
Save