-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the UI text to a separate file
- Loading branch information
Showing
39 changed files
with
184 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "MI_Text.h" | ||
|
||
#include "ResourceManager.h" | ||
|
||
extern CResourceManager* rm; | ||
|
||
|
||
MI_Text::MI_Text(std::string text, short x, short y, short w, bool use_large_font, TextAlignment align) | ||
: UI_Control(x, y) | ||
, szText(std::move(text)) | ||
, iw(w) | ||
, m_align(align) | ||
, font(use_large_font ? &rm->menu_font_large : &rm->menu_font_small) | ||
{} | ||
|
||
void MI_Text::SetText(std::string text) | ||
{ | ||
szText = std::move(text); | ||
} | ||
|
||
void MI_Text::Draw() | ||
{ | ||
if (!fShow) | ||
return; | ||
|
||
if (m_align == TextAlignment::LEFT && iw == 0) | ||
font->draw(ix, iy, szText.c_str()); | ||
else if (m_align == TextAlignment::LEFT) | ||
font->drawChopRight(ix, iy, iw, szText.c_str()); | ||
else if (m_align == TextAlignment::CENTER) | ||
font->drawCentered(ix, iy, szText.c_str()); | ||
else if (m_align == TextAlignment::RIGHT) | ||
font->drawRightJustified(ix, iy, szText.c_str()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "uicontrol.h" | ||
|
||
|
||
class MI_Text : public UI_Control { | ||
public: | ||
MI_Text(std::string text, short x, short y, short w, bool use_large_font, TextAlignment align = TextAlignment::LEFT); | ||
|
||
void SetText(std::string text); | ||
void Draw() override; | ||
|
||
private: | ||
std::string szText; | ||
short iw = 0; | ||
TextAlignment m_align = TextAlignment::LEFT; | ||
gfxFont* font = nullptr; | ||
}; | ||
|
||
|
||
class MI_HeaderText: public MI_Text { | ||
public: | ||
MI_HeaderText(std::string text, short x, short y) | ||
: MI_Text(std::move(text), x, y, 0, true, TextAlignment::CENTER) | ||
{} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.