Skip to content

Commit 2a85dcb

Browse files
committed
Reworked font height
Added global height systems for uniformity
1 parent 2463db3 commit 2a85dcb

17 files changed

+80
-69
lines changed

src/GUI/baseGUI.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ namespace GUI {
4646
class StaticText : public TextureTemplate {
4747
public:
4848
StaticText(const Window& window, float X, float Y, const LanguagedText texts,
49-
float size, Color color = WHITE, Aligment aligment = Aligment::Midle);
49+
float height = Height::Main, Color color = WHITE, Aligment aligment = Aligment::Midle);
5050
~StaticText();
5151
};
5252

5353

5454
// Static text on screen
5555
class HighlightedStaticText : public TextureTemplate {
5656
public:
57-
HighlightedStaticText(const Window& window, float X, float Y, const LanguagedText texts,
58-
int frameThickness, float size, Color color = WHITE, Aligment aligment = Aligment::Midle);
57+
HighlightedStaticText(const Window& window, float X, float Y, const LanguagedText texts, int frameThickness,
58+
float height = Height::Main, Color color = WHITE, Aligment aligment = Aligment::Midle);
5959
~HighlightedStaticText();
6060
};
6161

@@ -71,7 +71,7 @@ namespace GUI {
7171

7272
public:
7373
DynamicText(const Window& window, float X, float Y, const LanguagedText texts,
74-
float size = 20, Color color = WHITE, Aligment aligment = Aligment::Midle);
74+
float height = Height::Main, Color color = WHITE, Aligment aligment = Aligment::Midle);
7575
~DynamicText();
7676
template <typename ...Args>
7777
void setValues(Args&& ...args) {
@@ -181,8 +181,8 @@ namespace GUI {
181181
void copyToClipboard(); // Writing selected text to clipboard
182182

183183
public:
184-
TypeField(const Window& window, float posX, float posY, float height,
185-
const char *startText = "", Aligment aligment = Aligment::Midle, Color textColor = BLACK);
184+
TypeField(const Window& window, float posX, float posY, const char *startText = "",
185+
float height = Height::TypeBox, Aligment aligment = Aligment::Midle, Color textColor = BLACK);
186186
~TypeField(); // Clearing font and texture
187187
void writeString(const char* str); // Function of writing any string to buffer at caret position
188188
void type(SDL_Keycode code); // Function of processing special keycodes
@@ -202,7 +202,7 @@ namespace GUI {
202202
RectBackplate backplate;
203203

204204
public:
205-
TypeBox(const Window& window, float posX, float posY, float height, const char *startText = "",
205+
TypeBox(const Window& window, float posX, float posY, const char *startText = "", float height = Height::TypeBox,
206206
Aligment aligment = Aligment::Midle, unsigned frameWidth = 2, Color textColor = BLACK);
207207
void blit() const override; // Function for draw inputting text with backplate
208208
bool in(const Mouse mouse) const override;
@@ -215,7 +215,7 @@ namespace GUI {
215215
const RoundedBackplate backplate;
216216

217217
public:
218-
TextButton(const Window& window, float X, float Y, const LanguagedText texts, float size,
218+
TextButton(const Window& window, float X, float Y, const LanguagedText texts, float size = Height::Main,
219219
Color color = WHITE, Aligment aligment = Aligment::Midle);
220220
void blit() const override;
221221
};
@@ -229,7 +229,7 @@ namespace GUI {
229229

230230
public:
231231
InfoBox(const Window& window, float X, float Y, const LanguagedText texts,
232-
float size, Color color = WHITE, Aligment aligment = Aligment::Midle);
232+
float height = Height::Main, Color color = WHITE, Aligment aligment = Aligment::Midle);
233233
void update();
234234
void reset();
235235
};

src/GUI/typeBox.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88

99
template <unsigned bufferSize>
10-
GUI::TypeBox<bufferSize>::TypeBox(const Window& _window, float _posX, float _posY, float _height,
11-
const char *_startText, Aligment _aligment, unsigned _frameWidth, Color _textColor)
12-
: TypeField<bufferSize>(_window, _posX, _posY, _height, _startText, _aligment, _textColor),
13-
backplate(_window, {_posX*_window.getWidth() - (6.5f*bufferSize+2), _posY*_window.getHeight()-_height * 0.9f,
14-
13.0f * bufferSize+4, _height * 1.9f}, 2) {}
10+
GUI::TypeBox<bufferSize>::TypeBox(const Window& _window, float _posX, float _posY, const char *_startText,
11+
float _height, Aligment _aligment, unsigned _frameWidth, Color _textColor)
12+
: TypeField<bufferSize>(_window, _posX, _posY, _startText, _height, _aligment, _textColor),
13+
backplate(_window, {_posX*_window.getWidth() - (6.5f*bufferSize+2), _posY*_window.getHeight()-_height*0.85f,
14+
13.0f * bufferSize+4, _height * 1.8f}, 2) {}
1515

1616
template <unsigned bufferSize>
1717
void GUI::TypeBox<bufferSize>::blit() const {

src/GUI/typeField.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Type field class
1212
template <unsigned bufferSize>
13-
GUI::TypeField<bufferSize>::TypeField(const Window& _window, float _X, float _Y, float _height, const char* _text, Aligment _aligment, Color _color)
13+
GUI::TypeField<bufferSize>::TypeField(const Window& _window, float _X, float _Y, const char* _text, float _height, Aligment _aligment, Color _color)
1414
: TextureTemplate(_window),
1515
posX(window.getWidth()*_X),
1616
aligment(_aligment),

src/cycles/clientGame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
ClientGameCycle::ClientGameCycle(Window& _window, const Connection& _client)
1111
: InternetCycle(_window),
1212
connection(_client),
13-
waitText(window, 0.5, 0.05, {"Wait start", "Ожидайте начала", "Warte auf Start", "Чаканне старту"}, 24) {
13+
waitText(window, 0.5, 0.05, {"Wait start", "Ожидайте начала", "Warte auf Start", "Чаканне старту"}) {
1414
logAdditional("Start client game cycle");
1515
}
1616

src/cycles/clientLobby.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ char basePort[6] = "8000";
1414

1515
ClientLobbyCycle::ClientLobbyCycle(Window& _window)
1616
: BaseCycle(_window),
17-
enterIPText(window, 0.5, 0.2, {"Enter IP:", "Введите IP:", "Geben Sie die IP ein:", "Увядзіце IP:"}, 30, WHITE),
18-
enterIPField(window, 0.5, 0.32, 20, baseIP),
19-
enterPortText(window, 0.5, 0.5, {"Enter port:", "Введите порт:", "Port eingeben:", "Увядзіце порт:"}, 30, WHITE),
20-
enterPortField(window, 0.5, 0.62, 20, basePort),
21-
pasteButton(window, 0.5, 0.75, {"Paste the address", "Вставить адрес", "Kopierte Adresse", "Уставіць адрас"}, 24, WHITE),
22-
connectButton(window, 0.5, 0.9, {"Connect", "Присоединится", "Beitritt", "Далучыцца"}, 24, WHITE) {
17+
enterIPText(window, 0.5, 0.2, {"Enter IP:", "Введите IP:", "Geben Sie die IP ein:", "Увядзіце IP:"}, Height::SubTitle),
18+
enterIPField(window, 0.5, 0.32, baseIP),
19+
enterPortText(window, 0.5, 0.45, {"Enter port:", "Введите порт:", "Port eingeben:", "Увядзіце порт:"}, Height::SubTitle),
20+
enterPortField(window, 0.5, 0.57, basePort),
21+
pasteButton(window, 0.5, 0.75, {"Paste the address", "Вставить адрес", "Kopierte Adresse", "Уставіць адрас"}),
22+
connectButton(window, 0.5, 0.9, {"Connect", "Присоединится", "Beitritt", "Далучыцца"}) {
2323
if (isAdditionalRestarted()) {
2424
// Stopping cycle from launching after end of client game
2525
stop();

src/cycles/gameCycle.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ GameCycle::GameCycle(Window& _window)
1111
: BaseCycle(_window),
1212
field(_window),
1313
screamer(window),
14-
menuRestartButton(window, 0.5, 0.5, {"Restart", "Перезапустить", "Starten", "Перазапуск"}, 24),
15-
menuExitButton(window, 0.5, 0.65, {"Exit to menu", "Выйти в меню", "Menü verlassen", "Выйсці ў меню"}, 24),
14+
menuRestartButton(window, 0.5, 0.5, {"Restart", "Перезапустить", "Starten", "Перазапуск"}),
15+
menuExitButton(window, 0.5, 0.65, {"Exit to menu", "Выйти в меню", "Menü verlassen", "Выйсці ў меню"}),
1616
gameRestartButton(window, 0.12, 0.05, 0.08, Textures::RestartButton),
1717
playersTurnsTexts {
18-
{window, 0.5, 0.05, {"First player turn", "Ход первого игрока", "Der Zug des ersten Spielers", "Ход першага гульца"}, 24},
19-
{window, 0.5, 0.05, {"Second player turn", "Ход второго игрока", "Zug des zweiten Spielers", "Ход другога гульца"}, 24}
18+
{window, 0.5, 0.05, {"First player turn", "Ход первого игрока", "Der Zug des ersten Spielers", "Ход першага гульца"}},
19+
{window, 0.5, 0.05, {"Second player turn", "Ход второго игрока", "Zug des zweiten Spielers", "Ход другога гульца"}}
2020
},
2121
menuBackplate(window, 0.5, 0.5, 1, 0.46, 40, 5),
22-
firstWinText(window, 0.5, 0.35, {"Fist player win", "Первый игрок выйграл", "Der erste Spieler hat gewonnen", "Першы гулец выйграў"}, 1, 30),
23-
secondWinText(window, 0.5, 0.35, {"Second player win", "Второй игрок выйграл", "Der zweite Spieler hat gewonnen", "Другі гулец выйграў"}, 1, 30),
24-
nobodyWinText(window, 0.5, 0.35, {"Nobody win", "Ничья", "Unentschieden", "Чые"}, 1, 30) {
22+
firstWinText(window, 0.5, 0.35, {"Fist player win", "Первый игрок выйграл", "Der erste Spieler hat gewonnen", "Першы гулец выйграў"}, 1, Height::Info),
23+
secondWinText(window, 0.5, 0.35, {"Second player win", "Второй игрок выйграл", "Der zweite Spieler hat gewonnen", "Другі гулец выйграў"}, 1, Height::Info),
24+
nobodyWinText(window, 0.5, 0.35, {"Nobody win", "Ничья", "Unentschieden", "Чые"}, 1, Height::Info) {
2525
if (!isRestarted()) {
2626
// Resetting field
2727
field.reset();

src/cycles/internetCycle.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
InternetCycle::InternetCycle(Window& _window)
1010
: GameCycle(_window),
1111
playersTurnsTexts {
12-
{window, 0.5, 0.05, {"Your turn", "Ваш ход", "Sie spielen aus", "Ваш ход"}, 24, WHITE},
13-
{window, 0.5, 0.05, {"Wait", "Ожидайте", "Erwartet", "Чакаць"}, 24, WHITE},
12+
{window, 0.5, 0.05, {"Your turn", "Ваш ход", "Sie spielen aus", "Ваш ход"}},
13+
{window, 0.5, 0.05, {"Wait", "Ожидайте", "Erwartet", "Чакаць"}},
1414
},
1515
disconnectedBox(window),
1616
termianatedBox(window),
17-
looseText(window, 0.5, 0.35, {"You loose", "Вы проиграли", "Sie haben verloren", "Вы прайгралі"}, 1, 32, WHITE),
18-
winText(window, 0.5, 0.35, {"Win", "Победа", "Sieg", "Перамога"}, 1, 32, WHITE) {
17+
looseText(window, 0.5, 0.35, {"You loose", "Вы проиграли", "Sie haben verloren", "Вы прайгралі"}, 1, Height::Info),
18+
winText(window, 0.5, 0.35, {"Win", "Победа", "Sieg", "Перамога"}, 1, Height::Info) {
1919
// Resetting flag
2020
if (!isRestarted()) {
2121
disconnectedBox.reset();

src/cycles/parametersCycle.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99

1010
ParametersCycle::ParametersCycle(Window& _window)
1111
: BaseCycle(_window),
12-
titleText(window, 0.5, 0.1, {"Select field", "Выберете поле", "Feld auswählen", "Выберыце поле"}, 3, 40),
13-
widthText(window, 0.05, 0.25, {"Field width:", "Ширина поля:", "Feldbreite:", "Шырыня поля:"}, 2, 24,
14-
WHITE, GUI::Aligment::Left),
15-
widthTypeField(window, 0.8, 0.25, 20, std::to_string(GameField::getWidth()).c_str()),
16-
winWidthText(window, 0.05, 0.38, {"Win width:", "Победная длинна:", "Gewinnbreite:", "Выйгрышная шырыня:"}, 2, 24,
17-
WHITE, GUI::Aligment::Left),
18-
winWidthTypeField(window, 0.8, 0.38, 20, std::to_string(GameField::getWinWidth()).c_str()),
19-
smallFieldButton(window, 0.5, 0.51, {"Small field", "Маленькое поле", "Kleines Feld", "Невялікае поле"}, 24),
20-
mediumFieldButton(window, 0.5, 0.64, {"Medium field", "Среднее поле", "Mittleres Feld", "Сярэдняе поле"}, 24),
21-
bigFieldButton(window, 0.5, 0.77, {"Big field", "Большое поле", "Großes Feld", "Вялікае поле"}, 24),
22-
hugeFieldButton(window, 0.5, 0.9, {"Huge field", "Огромное поле", "Riesiges Feld", "Вялікае поле"}, 24) {
12+
titleText(window, 0.5, 0.1, {"Select field", "Выберете поле", "Feld auswählen", "Выберыце поле"}, 3, Height::Info),
13+
widthText(window, 0.05, 0.25, {"Field width:", "Ширина поля:", "Feldbreite:", "Шырыня поля:"},
14+
2, Height::Main, WHITE, GUI::Aligment::Left),
15+
widthTypeField(window, 0.8, 0.25, std::to_string(GameField::getWidth()).c_str()),
16+
winWidthText(window, 0.05, 0.38, {"Win width:", "Победная длинна:", "Gewinnbreite:", "Выйгрышная шырыня:"},
17+
2, Height::Main, WHITE, GUI::Aligment::Left),
18+
winWidthTypeField(window, 0.8, 0.38, std::to_string(GameField::getWinWidth()).c_str()),
19+
smallFieldButton(window, 0.5, 0.51, {"Small field", "Маленькое поле", "Kleines Feld", "Невялікае поле"}),
20+
mediumFieldButton(window, 0.5, 0.64, {"Medium field", "Среднее поле", "Mittleres Feld", "Сярэдняе поле"}),
21+
bigFieldButton(window, 0.5, 0.77, {"Big field", "Большое поле", "Großes Feld", "Вялікае поле"}),
22+
hugeFieldButton(window, 0.5, 0.9, {"Huge field", "Огромное поле", "Riesiges Feld", "Вялікае поле"}) {
2323
logAdditional("Start parameters selection cycle");
2424
}
2525

src/cycles/selectCycle.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
// Starting basic template with main theme
1515
SelectCycle::SelectCycle(Window& _window)
1616
: BaseCycle(_window),
17-
titleText(window, 0.5, 0.15, {"Tic-tac-toe", "Крестики нолики", "Tic-tac-toe", "Крыжыкі нулікі"}, 3, 40, WHITE),
18-
singleplayerButton(window, 0.5, 0.3, {"Singleplayer", "Одиночная игра", "Einzelspiel", "Адзіночная гульня"}, 24, WHITE),
19-
bigFieldInfobox(window, 0.5, 0.375, {"Too big field", "Слишком большое поле", "Zu großes Feld", "Занадта вялікае поле"}, 24),
20-
twoPlayerButton(window, 0.5, 0.45, {"Two players", "Два игрока", "Zwei Spieler", "Два гульца"}, 24, WHITE),
21-
serverButton(window, 0.5, 0.6, {"Create server", "Создать сервер", "Server erstellen", "Стварыць сервер"}, 24, WHITE),
22-
connectButton(window, 0.5, 0.75, {"Connect", "Присоединиться", "Beitreten", "Далучыцца"}, 24, WHITE),
23-
fieldParametersButton(window, 0.5, 0.9, {"Field parameters", "Параметры поля", "Feld-Parameter", "Параметры поля"}, 24, WHITE) {
17+
titleText(window, 0.5, 0.15, {"Tic-tac-toe", "Крестики нолики", "Tic-tac-toe", "Крыжыкі нулікі"}, 3, Height::Title),
18+
singleplayerButton(window, 0.5, 0.3, {"Singleplayer", "Одиночная игра", "Einzelspiel", "Адзіночная гульня"}),
19+
bigFieldInfobox(window, 0.5, 0.375, {"Too big field", "Слишком большое поле", "Zu großes Feld", "Занадта вялікае поле"}),
20+
twoPlayerButton(window, 0.5, 0.45, {"Two players", "Два игрока", "Zwei Spieler", "Два гульца"}),
21+
serverButton(window, 0.5, 0.6, {"Create server", "Создать сервер", "Server erstellen", "Стварыць сервер"}),
22+
connectButton(window, 0.5, 0.75, {"Connect", "Присоединиться", "Beitreten", "Далучыцца"}),
23+
fieldParametersButton(window, 0.5, 0.9, {"Field parameters", "Параметры поля", "Feld-Parameter", "Параметры поля"}) {
2424
// Starting menu song (if wasn't started)
2525
music.start(Music::Menu);
2626
logAdditional("Start select cycle");

src/cycles/serverGame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
ServerGameCycle::ServerGameCycle(Window& _window, const Connection& _server)
1010
: InternetCycle(_window),
1111
connection(_server),
12-
startFirst(window, 0.5, 0.45, {"Start as cross", "Начать за крестик", "Am Kreuz anfangen", "Пачаць за крыжык"}, 24),
13-
startSecond(window, 0.5, 0.55, {"Start as circle", "Начать за кружок", "Für einen Kreis beginnen", "Пачаць за гурток"}, 24) {
12+
startFirst(window, 0.5, 0.45, {"Start as cross", "Начать за крестик", "Am Kreuz anfangen", "Пачаць за крыжык"}),
13+
startSecond(window, 0.5, 0.55, {"Start as circle", "Начать за кружок", "Für einen Kreis beginnen", "Пачаць за гурток"}) {
1414
if (!isRestarted()) {
1515
// Sending applying initialsiation message
1616
connection.sendConfirmed<Uint8, Uint8>(ConnectionCode::Init, field.getWidth(), field.getWinWidth());

0 commit comments

Comments
 (0)