Eile Mit Weile
Loading...
Searching...
No Matches
MainGamePanel Class Reference

Panel for displaying the main game. More...

#include <MainGamePanel.hpp>

Inheritance diagram for MainGamePanel:

Public Member Functions

 MainGamePanel (wxWindow *parent)
 
void BuildGameState (GameState *game_state, Player *me)
 

Private Member Functions

void BuildBoard (wxPanel *parent, GameState *game_state, Player *me)
 
void BuildFigures (GameState *game_state, Player *me)
 
void BuildTurnIndicator (GameState *game_state, Player *me)
 
void BuildDice (wxPanel *parent, GameState *game_state, Player *me)
 
void ShowNoMoves (GameState *game_state, Player *me)
 

Private Attributes

wxPanel * _board_panel
 
wxPanel * _side_panel
 
std::map< int, std::pair< std::basic_string< char >, wxColour > > _color_map
 
std::map< unsigned, std::pair< wxPoint, wxSize > > _spaces_map
 
unsigned const _space_width = 72
 
unsigned const _space_height = 29
 
wxSize _space_horizontal = wxSize(_space_width, _space_height)
 
wxSize _space_vertical = wxSize(_space_height, _space_width)
 
unsigned const _board_length = 680
 
unsigned const _border_size = 10
 
wxSize const _board_panel_size = wxSize(_board_length, _board_length)
 
wxPoint const _board_panel_position = wxPoint(0, 0)
 
wxSize const _side_panel_size = wxSize(960 - _board_length - _border_size, _board_length)
 
wxPoint const _side_panel_position = wxPoint(_board_length + _border_size, 0)
 
wxSize const _dice_size = wxSize(50, 50)
 
wxPoint const _dice_position = wxPoint(50, _side_panel_size.GetHeight() - 100)
 
wxSize const _figure_size = wxSize(20, 20)
 
wxSize const _home_field_size = wxSize(40, 40)
 
unsigned const _home_field_offset = 3 * _space_width / 2
 
Corner points of normal spaces for easier initialisation of spaces map
wxPoint const _north = wxPoint(_board_length / 2 - 1.5 * _space_width, 0)
 
wxPoint const _east = wxPoint(680 - 8 * _space_height, _board_length / 2 - 1.5 * _space_width)
 
wxPoint const _south = wxPoint(_board_length / 2 - 1.5 * _space_width, 680 - 8 * _space_height)
 
wxPoint const _west = wxPoint(0, _board_length / 2 - 1.5 * _space_width)
 

Detailed Description

Panel for displaying the main game.

This class is derived from wxPanel, which is wxWidgets' panel class. It is responsible for displaying the main game. The board is manually constructed, where notably each space is a wxPanel and each figure is an ImagePanel. The panel also has a dice button and a turn indicator.

The layout is not scalable!

Constructor & Destructor Documentation

◆ MainGamePanel()

MainGamePanel::MainGamePanel ( wxWindow parent)

Initializes the MainGamePanel with the given parent window (GameWindow).

Member Function Documentation

◆ BuildBoard()

void MainGamePanel::BuildBoard ( wxPanel *  parent,
GameState game_state,
Player me 
)
private

Builds/Updates the Board. Notably highlights the spaces to which a playable figure of Player me can be moved.

◆ BuildDice()

void MainGamePanel::BuildDice ( wxPanel *  parent,
GameState game_state,
Player me 
)
private

Builds/Updates the dice.

◆ BuildFigures()

void MainGamePanel::BuildFigures ( GameState game_state,
Player me 
)
private

Builds/Updates the figures of the player.

◆ BuildTurnIndicator()

void MainGamePanel::BuildTurnIndicator ( GameState game_state,
Player me 
)
private

Builds/Updates the turn indicator.

◆ ShowNoMoves()

void MainGamePanel::ShowNoMoves ( GameState game_state,
Player me 
)
private

If me has no playable figures, a message box tells that to the Player and a GameController::SkipTurn is called.

Member Data Documentation

◆ _board_length

unsigned const MainGamePanel::_board_length = 680
private

The length (and width) of the board.

◆ _board_panel

wxPanel* MainGamePanel::_board_panel
private

The GUI is separated into _board_panel and _side_panel. Board consists of the board and all figures

◆ _board_panel_position

wxPoint const MainGamePanel::_board_panel_position = wxPoint(0, 0)
private

The position of the board panel.

◆ _board_panel_size

wxSize const MainGamePanel::_board_panel_size = wxSize(_board_length, _board_length)
private

The size of the board panel.

◆ _border_size

unsigned const MainGamePanel::_border_size = 10
private

The size of the border between the board and the side panel.

◆ _color_map

std::map<int, std::pair<std::basic_string<char>, wxColour> > MainGamePanel::_color_map
private

Maps the index of the color to the name of the color as a string.

◆ _dice_position

wxPoint const MainGamePanel::_dice_position = wxPoint(50, _side_panel_size.GetHeight() - 100)
private

The position of the Dice button.

◆ _dice_size

wxSize const MainGamePanel::_dice_size = wxSize(50, 50)
private

The size of the Dice button.

◆ _figure_size

wxSize const MainGamePanel::_figure_size = wxSize(20, 20)
private

The size of a figure.

◆ _home_field_offset

unsigned const MainGamePanel::_home_field_offset = 3 * _space_width / 2
private

The offset of the home fields.

◆ _home_field_size

wxSize const MainGamePanel::_home_field_size = wxSize(40, 40)
private

The size of a home field.

◆ _side_panel

wxPanel* MainGamePanel::_side_panel
private

The GUI is separated into _board_panel and _side_panel. Side displays the players names, the turn indicator and the dice

◆ _side_panel_position

wxPoint const MainGamePanel::_side_panel_position = wxPoint(_board_length + _border_size, 0)
private

The position of the side panel.

◆ _side_panel_size

wxSize const MainGamePanel::_side_panel_size = wxSize(960 - _board_length - _border_size, _board_length)
private

The size of the side panel.

◆ _space_height

unsigned const MainGamePanel::_space_height = 29
private

The height of a space.

◆ _space_horizontal

wxSize MainGamePanel::_space_horizontal = wxSize(_space_width, _space_height)
private

The size of a space in horizontal orientation.

◆ _space_vertical

wxSize MainGamePanel::_space_vertical = wxSize(_space_height, _space_width)
private

The size of a space in vertical orientation.

◆ _space_width

unsigned const MainGamePanel::_space_width = 72
private

The width of a space.

◆ _spaces_map

std::map<unsigned, std::pair<wxPoint, wxSize> > MainGamePanel::_spaces_map
private

Maps the index of the space to the position and size of space 0 - 95 : normal, bench and ladder spaces (according to numbering convention in Board) 96 : finish area space 97 - 100 : home fields


The documentation for this class was generated from the following files: