23 #include <unordered_map>
59 std::vector<std::string> m_art;
78 AsciiArt(
const std::string &name,
const std::vector<std::string> &artLines,
int x = 0,
int y = 0);
85 const std::string &
getName()
const;
92 const std::vector<std::string> &
getArt()
const;
141 std::vector<std::vector<int>> codes;
160 ANSIArt(std::vector<std::vector<int>> codes,
const std::string &name,
int x = 0,
int y = 0);
217 std::vector<std::vector<int>>
getCodes();
260 void drawBox(
int x,
int y,
size_t width,
size_t height);
298 void drawText(
const std::string &text,
int x,
int y);
316 std::string
getLine(
int x,
int y,
size_t maxLength = 0);
369 void drawTextBox(
int x,
int y,
size_t width,
size_t height);
385 void drawAsciiArt(
const std::string &name,
int x = -1,
int y = -1);
409 void drawANSIArt(
const std::string &name,
int x,
int y);
437 void drawWrappedText(
const std::string &text,
int x,
int y,
size_t width);
446 std::vector<std::string> m_textBox;
448 int m_textBoxCapacity;
450 std::vector<AsciiArt> m_asciiArts;
452 std::vector<ANSIArt> m_ANSIArt;
460 void displayResizeWarning(
UIManager &uiManager);
476 Button(
const std::string &label, std::function<
void()> action);
485 void draw(
int x,
int y,
bool selected);
505 const std::string &
getLabel()
const;
511 std::function<void()> m_action;
526 Menu(
bool horizontal =
false);
534 void addButton(
const std::string &label, std::function<
void()> action);
542 void draw(
int x,
int y);
581 return m_selectedIndex;
617 std::vector<Button> m_buttons;
619 size_t m_selectedIndex;
621 bool horizontal_layout;
654 virtual void render(std::shared_ptr<ConsoleWindow> window) = 0;
688 std::shared_ptr<ConsoleWindow>
getWindow();
728 Menu &
createMenu(
const std::string &name,
bool horizontal =
false);
760 AsciiArt createAsciiArt(
const std::string &name,
const std::vector<std::string> &artLines,
int x = -1,
int y = -1);
773 std::unordered_map<std::string, Menu>
m_menus;
787 std::vector<std::shared_ptr<Scene>> m_scenes;
A object that holds art containing 256bit colour ANSI codes.
Definition: menu.h:136
ANSIArt(std::vector< std::vector< int >> codes, const std::string &name, int x=0, int y=0)
Construct a new ANSIArt object.
Definition: menu.cpp:442
int getX()
Get the left most position.
Definition: menu.cpp:459
std::string toString()
Convert the 256bit colour codes into a string of ANSI codes.
Definition: menu.cpp:480
size_t getWidth()
Get the width of the art.
Definition: menu.cpp:449
std::vector< std::vector< int > > getCodes()
Get the 256bit colour codes.
Definition: menu.cpp:494
size_t getHeight()
Get the Height of the art.
Definition: menu.cpp:454
std::string getName()
Get the Name of the artwork.
Definition: menu.cpp:469
int getY()
Get the top most position.
Definition: menu.cpp:464
void setPosition(int x, int y)
Set the position of the top left corner of the artwork.
Definition: menu.cpp:474
An object that stores ascii art in the form of a string.
Definition: menu.h:54
int getY() const
Get the top most position.
Definition: menu.cpp:427
void setPosition(int x, int y)
Set the position of the top left corner.
Definition: menu.cpp:384
AsciiArt(const std::string &name, const std::vector< std::string > &artLines, int x=0, int y=0)
Construct a new Ascii Art object.
Definition: menu.cpp:403
size_t getWidth() const
Get the Width of the art.
Definition: menu.cpp:432
size_t getHeight() const
Get the Height of the art.
Definition: menu.cpp:437
const std::vector< std::string > & getArt() const
Get the lines comprising the art.
Definition: menu.cpp:417
int getX() const
Get the left most position.
Definition: menu.cpp:422
const std::string & getName() const
Get the Name of the art.
Definition: menu.cpp:412
Object repesenting the Console window.
Definition: menu.h:226
void drawANSIArt(const std::string &name, int x, int y)
Draws the ansi art object at a location.
Definition: menu.cpp:291
void drawCharacter(int x, int y, char ch)
Puts a character on the screen at a position.
Definition: menu.cpp:78
COORD getSize() const
Get the Size of the console window.
Definition: menu.cpp:184
void drawHorizontalLine(int x, int y, size_t length, char ch='-')
Draws a horizontal line using specified character.
Definition: menu.cpp:63
void drawTextBox(int x, int y, size_t width, size_t height)
Draws a text box of specified dimensions.
Definition: menu.cpp:198
void drawBox(int x, int y, size_t width, size_t height)
Draws a box.
Definition: menu.cpp:55
void updateSize()
Update the size of the console window.
Definition: menu.cpp:43
void setConsoleWindowSize(short width, short height)
Set the size of the console window.
Definition: menu.cpp:358
void drawAsciiArt(const std::string &name, int x=-1, int y=-1)
Definition: menu.cpp:242
ANSIArt * getANSIArtByName(const std::string &name)
Get an ANSI artwork by name.
Definition: menu.cpp:279
void addAsciiArt(const AsciiArt &art)
Definition: menu.cpp:237
void drawVerticalLine(int x, int y, size_t length, char ch='|')
Draws a vertical line using specified character.
Definition: menu.cpp:69
void drawCenteredText(const std::string &text, int y)
Put a string of text centered horizontally on the screen.
Definition: menu.cpp:110
ConsoleWindow()
Construct a new Console Window object.
Definition: menu.cpp:34
void setDefaultSize(short width, short height)
Set the default size of the console window.
Definition: menu.cpp:377
AsciiArt * getAsciiArtByName(const std::string &name)
Get and ASCII art object by name.
Definition: menu.cpp:390
void drawText(const std::string &text, int x, int y)
Puts a string of text on the srceen starting at a position.
Definition: menu.cpp:84
void addANSIArt(const ANSIArt &art)
Add an ansi art object to the consolewindow object.
Definition: menu.cpp:274
void clear()
Clear everything on the screen.
Definition: menu.cpp:179
virtual ~ConsoleWindow()=default
Destroy the Console Window object.
void checkWindowResize(UIManager &uiManager)
Check to see if the console window has been resized.
Definition: menu.cpp:314
void drawWrappedText(const std::string &text, int x, int y, size_t width)
Draws text on the screen wrapping the string to the next line if it reaches the width.
Definition: menu.cpp:208
std::string getLine(int x, int y, size_t maxLength=0)
Create a blank text input field to recieve and display user input.
Definition: menu.cpp:117
void drawBorder()
Draws a border around the console.
Definition: menu.cpp:50
void addTextToBox(const std::string &text)
The text to be added to a text box.
Definition: menu.cpp:189
void drawANSICode(int code, int x, int y)
Draws a 256bit colour on the screen at a position.
Definition: menu.cpp:91
Defines a UI scene.
Definition: menu.h:629
virtual void init()=0
Initialise the scene.
virtual ~Scene()=default
Destroy the Scene object.
virtual void setStaticDrawn(bool staticDrawn)=0
Sets the static drawn state of the scene.
virtual void update()=0
What to perfrom on scene update.
virtual void handleInput()=0
Handle user input from the scene.
virtual void render(std::shared_ptr< ConsoleWindow > window)=0
What to render in the console window.
Defines the UI manager.
Definition: menu.h:675
std::shared_ptr< ConsoleWindow > getWindow()
Get the Window object.
Definition: menu.cpp:664
void update()
Called each time there is a event.
Definition: menu.cpp:687
UIManager()
Construct a new UIManager object.
Definition: menu.cpp:660
Menu & createMenu(const std::string &name, bool horizontal=false)
Create the UI menu.
Definition: menu.cpp:719
AsciiArt createAsciiArt(const std::string &name, const std::vector< std::string > &artLines, int x=-1, int y=-1)
Create a Ascii Art object.
Definition: menu.cpp:749
void handleInput()
Handles user input.
Definition: menu.cpp:703
std::shared_ptr< Scene > m_currentScene
Definition: menu.h:771
void clearAllMenus()
Removes all menus from the UI.
Definition: menu.cpp:737
void render()
Renders objects on the console window.
Definition: menu.cpp:695
std::unordered_map< std::string, Menu > m_menus
Definition: menu.h:773
void setCurrentScene(std::shared_ptr< Scene > scene)
Set the Current Scene object.
Definition: menu.cpp:669
Menu & getMenu(const std::string &name)
Get the Menu object by it's name.
Definition: menu.cpp:724
void checkWindowResize()
Deteremine if the window has been resized.
Definition: menu.cpp:711
void init()
Initialise the UI.
Definition: menu.cpp:683
void clearMenu(const std::string &name)
Removes the named menu from the UI.
Definition: menu.cpp:729
std::vector< std::shared_ptr< Scene > > & getScenes()
Get the Scenes of the UI.
Definition: menu.h:780
std::shared_ptr< ConsoleWindow > m_window
Definition: menu.h:769
Contains useful helper functions.