GigaPasjans
Loading...
Searching...
No Matches
AsciiArtComponent.h
1// Plik utworzony przez Piotra Chudzińskiego w dniu 11.04.2025
2#pragma once
3#include "andromenda/Component.h"
4
5namespace Game
6{
7 using namespace Andromenda;
8
13 class AsciiArtComponent : public Component
14 {
15 private:
20 const std::array<WideString, 6> m_Lines = {
21 L"░██████╗░██╗░██████╗░░█████╗░██████╗░░█████╗░░██████╗░░░░░██╗░█████╗░███╗░░██╗░██████╗",
22 L"██╔════╝░██║██╔════╝░██╔══██╗██╔══██╗██╔══██╗██╔════╝░░░░░██║██╔══██╗████╗░██║██╔════╝",
23 L"██║░░██╗░██║██║░░██╗░███████║██████╔╝███████║╚█████╗░░░░░░██║███████║██╔██╗██║╚█████╗░",
24 L"██║░░╚██╗██║██║░░╚██╗██╔══██║██╔═══╝░██╔══██║░╚═══██╗██╗░░██║██╔══██║██║╚████║░╚═══██╗",
25 L"╚██████╔╝██║╚██████╔╝██║░░██║██║░░░░░██║░░██║██████╔╝╚█████╔╝██║░░██║██║░╚███║██████╔╝",
26 L"░╚═════╝░╚═╝░╚═════╝░╚═╝░░╚═╝╚═╝░░░░░╚═╝░░╚═╝╚═════╝░░╚════╝░╚═╝░░╚═╝╚═╝░░╚══╝╚═════╝░",
27 };
28
30 Int2 getSize() override
31 {
32 return Int2{m_Lines[0].GetLength(), static_cast<int32>(m_Lines.size())};
33 }
34
35 public:
36 AsciiArtComponent()
37 {
38 }
39
41 void ProvideActions(ActionRegistry &registry) override
42 {
43 }
44
46 bool IsSelectable() const override
47 {
48 return false;
49 }
50
52 void Draw(DrawContext &context) override
53 {
54 context.StyleStack.Push(TerminalStyle{Color::Yellow, Color::Black});
55
56 for (int32 i = 0; i < m_Lines.size(); i++)
57 {
58 context.Put(m_Lines[i], GetBounds().GetPosition() + Int2{0, i});
59 }
60
61 context.StyleStack.Pop();
62 }
63 };
64}
Represent registry of Action objects.
Definition ActionRegistry.h:74
Represents a renderable identified object.
Definition Component.h:23
Box GetBounds()
Returns Component bounds. Position is already aligned.
Definition Components.cpp:27
void Pop()
Pops style at the top.
Definition TerminalBase.cpp:45
void Push(const TerminalStyle &style)
Pushes given style to the top.
Definition TerminalBase.cpp:43
bool IsSelectable() const override
Returns value indicating, whether component is selectable.
Definition AsciiArtComponent.h:46
void Draw(DrawContext &context) override
Draws self.
Definition AsciiArtComponent.h:52
void ProvideActions(ActionRegistry &registry) override
Provides own actions to the ActionRegistry.
Definition AsciiArtComponent.h:41
A utility which contains all essential class instances and functions for rendering objects.
Definition DrawContext.h:14
void Put(const String &text, Int2 position)
Puts a UTF-8 text at given position and with given text.
Definition DrawContext.cpp:7
StyleStack StyleStack
Style stack.
Definition DrawContext.h:31
Represents terminal text style, described by background and foreground color.
Definition Terminal.h:20
Represents a two component vector. Components are 32-bit and they are signed.
Definition Int2.h:11