![]() |
Survival Royale 1.0.0
A very simple yet funny card game.
|
Terminal User Interface (TUI) implementation for card game display. More...
Go to the source code of this file.
Data Structures | |
struct | PageData |
Struct to represent the layout and data of a page containing player information. More... |
Macros | |
#define | _GUI_H_ |
Include guard. | |
#define | CARD_WIDTH 15 |
Integer const to represent the width of a card. | |
#define | CARD_HEIGHT 9 |
Integer const to represent the height of a card. | |
#define | LOG_SECTION_HEIGHT 4 |
Integer const to represent the height of the logs section. | |
#define | MIN_ROWS ((2 * (CARD_HEIGHT + 4)) + (LOG_SECTION_HEIGHT + 2)) |
Integer const to represent the minimum rows of the terminal in order to start the game. | |
#define | MIN_COLUMNS 141 |
Integer const to represent the minimum columns of the terminal in order to start the game. |
Typedefs | |
typedef struct PageData | PageData |
Struct to represent the layout and data of a page containing player information. |
Functions | |
void | drawCardsForPage (PageData *page, int startX, int bestStartColumn) |
Draws all cards for the current page. | |
void | drawPageFrame (int maxRows, int maxColumns) |
Draws the frame for a page, including borders and separators. | |
void | displayPage (PageData *page, int maxRows, int maxColumns, int bestStartColumn) |
Displays a page of cards and player information. | |
void | navigatePages (PageData *pagesData, int totalPages, int maxRows, int maxColumns, int bestStartColumn, int playerIndex, Game *game) |
Navigates between pages and handles player actions during their turn. | |
int | getCardColor (int cardRank) |
Retrieves the color associated with a card rank. | |
void | drawLine (int startingX, int startingY, int length, char direction, char borders) |
Draws a line in the terminal. | |
void | drawCard (int startingX, int startingY, int suit, int rank) |
Draws a card at a specified position. | |
PageData * | getPageData (int maxRows, int maxColumns, Player **players, int totalPlayers, int *totalPages, int *bestStartColumn) |
Computes the page layout for players and allocates memory for the page data. | |
void | freePageData (PageData *pages, int totalPages) |
Frees the memory allocated for page data. | |
bool | isTerminalSizeValid (int maxRows, int maxColumns) |
Checks if the terminal size meets the minimum requirements. | |
int | getPageContainingPlayer (PageData *pagesData, int totalPages, int id) |
Determines which page contains a player by their ID. |
Terminal User Interface (TUI) implementation for card game display.
This file contains functions to handle terminal-based user interface components, including drawing cards, player information, and navigation between pages.
Definition in file tui.h.
#define CARD_HEIGHT 9 |
#define CARD_WIDTH 15 |
#define LOG_SECTION_HEIGHT 4 |
#define MIN_COLUMNS 141 |
#define MIN_ROWS ((2 * (CARD_HEIGHT + 4)) + (LOG_SECTION_HEIGHT + 2)) |
typedef struct PageData PageData |
Struct to represent the layout and data of a page containing player information.
void displayPage | ( | PageData * | page, |
int | maxRows, | ||
int | maxColumns, | ||
int | bestStartColumn ) |
void drawCard | ( | int | startingX, |
int | startingY, | ||
int | suit, | ||
int | rank ) |
void drawCardsForPage | ( | PageData * | page, |
int | startX, | ||
int | bestStartColumn ) |
void drawLine | ( | int | startingX, |
int | startingY, | ||
int | length, | ||
char | direction, | ||
char | borders ) |
Draws a line in the terminal.
startingX | The starting row position. |
startingY | The starting column position. |
length | The length of the line. |
direction | The direction of the line ('h' for horizontal, 'v' for vertical). |
borders | The type of border ('u' for upper, 'd' for lower, 'n' for none). |
void drawPageFrame | ( | int | maxRows, |
int | maxColumns ) |
void freePageData | ( | PageData * | pages, |
int | totalPages ) |
int getCardColor | ( | int | cardRank | ) |
int getPageContainingPlayer | ( | PageData * | pagesData, |
int | totalPages, | ||
int | id ) |
PageData * getPageData | ( | int | maxRows, |
int | maxColumns, | ||
Player ** | players, | ||
int | totalPlayers, | ||
int * | totalPages, | ||
int * | bestStartColumn ) |
Computes the page layout for players and allocates memory for the page data.
maxRows | The maximum number of rows in the terminal. |
maxColumns | The maximum number of columns in the terminal. |
players | An array of pointers to all players. |
totalPlayers | The total number of players in the game. |
totalPages | Pointer to store the total number of pages. |
bestStartColumn | Pointer to store the starting column for centering the cards. |
bool isTerminalSizeValid | ( | int | maxRows, |
int | maxColumns ) |
void navigatePages | ( | PageData * | pagesData, |
int | totalPages, | ||
int | maxRows, | ||
int | maxColumns, | ||
int | bestStartColumn, | ||
int | playerIndex, | ||
Game * | game ) |
Navigates between pages and handles player actions during their turn.
pagesData | The data of all pages. |
totalPages | The total number of pages. |
maxRows | The maximum number of rows in the terminal. |
maxColumns | The maximum number of columns in the terminal. |
bestStartColumn | The starting column to align content. |
playerIndex | The index of the current player. |
game | Pointer to the game state. |