Skip to content

Commit

Permalink
Adding current turn indicator (for better UI)
Browse files Browse the repository at this point in the history
  • Loading branch information
kolyaka32 committed May 5, 2024
1 parent 3dabe83 commit 92ad851
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 5 deletions.
20 changes: 19 additions & 1 deletion src/data/texts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,25 @@

// Global static texts
Texts::Texts(){

// Setting window title
switch (language)
{
case LNG_ENGLISH:
SDL_SetWindowTitle(window, "Chess on SDL");
break;

case LNG_RUSSIAN:
SDL_SetWindowTitle(window, "Шахматы на SDL");
break;

case LNG_GERMAN:
SDL_SetWindowTitle(window, "Schach на SDL");
break;

case LNG_BELARUSIAN:
SDL_SetWindowTitle(window, "Шахматы на SDL");
break;
}
};

// Update translations of all texts
Expand Down
21 changes: 20 additions & 1 deletion src/data/texts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ enum TXT_types{
TXT_PAUSE_MUSIC,
TXT_PAUSE_SOUND,

// Game turnes
// Turnes at one computer
TXT_GAME_TURN_FIRST,
TXT_GAME_TURN_SECOND,

// Turnes at internet connection
TXT_GAME_TURN_THIS,
TXT_GAME_TURN_ANOTHER,

// End game texts
TXT_END_WIN,
TXT_END_WIN_1,
Expand All @@ -52,7 +61,7 @@ enum TXT_types{
};

// Summary texts counter
#define TXT_count 21
#define TXT_count 25


// Framed buttons
Expand Down Expand Up @@ -101,6 +110,16 @@ class Texts : public virtual App, public virtual InitFile
{"Sounds\nЗвуки\nGeräusche\nГук\n",
30, 0.5, 0.83},

// Game turnes
{"First player turn\nХод первого игрока\n-\n",
24, 0.5, 0.1, WHITE},
{"Second player turn\nХод второго игрока\n-\n",
24, 0.5, 0.1, WHITE},
{"Your turn\nВаш ход\n-\n",
24, 0.5, 0.1, WHITE},
{"Wait\nОжидайте\n-\n",
24, 0.5, 0.1, WHITE},

// Game end texts
{"Win!\nПобеда!\n-\n",
30, 0.5, 0.4, WHITE},
Expand Down
2 changes: 1 addition & 1 deletion src/define.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// Debuging modifiers
#define DEBUG true
#define DEBUG false
#define CHECK_CORRECTION DEBUG
#define ARCHIEVE_LOADING !DEBUG
#define SCROLLER_SOUND SND_count
Expand Down
3 changes: 3 additions & 0 deletions src/game/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ void GameCycle::draw() const{
// Draw surround letters
letters.blit();

// Drawing player state
data.texts[TXT_GAME_TURN_FIRST + board.currentTurn()].blit();

// Bliting game state, if need
if(endState > END_TURN){
// Bliting end background
Expand Down
3 changes: 3 additions & 0 deletions src/game/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ void ClientGameCycle::draw() const{
// Draw surround letters
letters.blit();

// Drawing player state
data.texts[TXT_GAME_TURN_THIS + waitTurn].blit();

// Bliting game state, if need
if(endState > END_TURN){
// Bliting end background
Expand Down
7 changes: 6 additions & 1 deletion src/game/entity/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ Uint8 Board::move(const coord _x1, const coord _y1, const coord _x2, const coord
}

//
position Board::getPreviousTurn(){
position Board::getPreviousTurn() const{
return activeCell.pos;
}

//
Uint8 Board::currentTurn() const{
return turn;
};
3 changes: 2 additions & 1 deletion src/game/entity/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ class Board
void blit() const; // Bliting field at screen
Uint8 click(const coord X, const coord Y); // Clicking with mouse on need cell on field
Uint8 move(const coord X1, const coord Y1, const coord X2, const coord Y2); // Simplier mover on field (for internet opponent turn)
position getPreviousTurn(); // Return, where was made previous turn
position getPreviousTurn() const; // Return, where was made previous turn
Uint8 currentTurn() const; // Return, which person is now active
};
3 changes: 3 additions & 0 deletions src/game/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ void ServerGameCycle::draw() const{
// Draw surround letters
letters.blit();

// Drawing player state
data.texts[TXT_GAME_TURN_THIS + waitTurn].blit();

// Bliting game state, if need
if(endState > END_TURN){
// Bliting end background
Expand Down

0 comments on commit 92ad851

Please sign in to comment.