22 players_by_score[i] = i;
25 players_by_score.begin(),
26 players_by_score.end(),
27 [&](
const int& a,
const int& b) ->
bool {
28 return game_get_player(game, a)->points > game_get_player(game, b)->points;
32 int winners_count = 0;
37 max_score = player->
points;
39 if (player->
points >= max_score) {
47 if (winners_count > 1) {
49 winners_str <<
"It is a tie between ";
51 winners_str <<
"The winners are ";
53 for (
int i = 0; i < winners_count; i++) {
54 winners_str << player_names.
at(players_by_score.at(i));
55 if (i < winners_count - 2) {
57 }
else if (i < winners_count - 1) {
58 winners_str <<
" and ";
62 }
else if (winners_count == 1) {
63 winners_str <<
"The winner is " << player_names.
at(players_by_score.at(0)) <<
"!";
65 winners_str <<
"There are no winners???";
94 int i = players_by_score.at(j);
104 outer_vbox->Add(content_vbox,
wxSizerFlags().Expand().DoubleBorder());
128 :
wxGrid(parent, id, pos, size, style, name) {
145 return wxGrid::TryBefore(event);
150 int cols_total_size = 0;
151 for (
int i = 0; i < ncols; i++) {
154 int cols_available_size = this->GetClientSize().x;
155 int cols_free_size = cols_available_size - cols_total_size;
156 int cols_ideal_size = cols_available_size / ncols;
157 int growable_cols = 0;
158 int growable_cols_total_size = 0;
159 for (
int i = 0; i < ncols; i++) {
162 growable_cols_total_size += this->
GetColSize(i);
165 if (growable_cols == 0) {
171 growable_cols_total_size += cols_free_size;
172 for (
int i = ncols - 1, grown = growable_cols; i >= 0; i--) {
174 int size = growable_cols_total_size / grown;
176 growable_cols_total_size -= size;
void equally_size_columns()
GameEndDialogGrid(wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxGridNameStr)
virtual bool TryBefore(wxEvent &event) override
void on_resize(wxSizeEvent &event)
void on_ok(wxCommandEvent &event)
wxStdDialogButtonSizer * buttons_sizer
wxStaticText * header_label
wxStaticText * winner_label
GameEndDialog(wxWindow *parent, wxWindowID id, const Game *game, const wxVector< wxString > &player_names)
void Centre(int direction=wxBOTH)
virtual void EndModal(int retCode)
wxStdDialogButtonSizer * CreateStdDialogButtonSizer(long flags)
void Bind(const EventTag &eventType, Functor functor, int id=wxID_ANY, int lastId=wxID_ANY, wxObject *userData=NULL)
bool CreateGrid(int numRows, int numCols, wxGridSelectionModes selmode=wxGridSelectCells)
void EnableEditing(bool edit)
void DisableDragColSize()
void SetColLabelValue(int col, const wxString &value)
void SetCellHighlightROPenWidth(int width)
void DisableDragRowSize()
void SetCellHighlightPenWidth(int width)
void DisableDragGridSize()
void SetCellValue(int row, int col, const wxString &s)
int GetColSize(int col) const
void SetColSize(int col, int width)
int GetNumberCols() const
void SetDefaultCellAlignment(int horiz, int vert)
wxSizerFlags & DoubleBorder(int direction=wxALL)
wxUniChar at(size_t n) const
static wxString Format(const wxString &format,...)
void SetSizerAndFit(wxSizer *sizer, bool deleteOld=true)
virtual bool SetFont(const wxFont &font)
Player * game_get_player(const Game *self, int idx)
Returns a pointer to the player at the given index. Fails if the index isn't within the bounds of the...
The core of the unified game logic library, contains the Game struct.
const wxSize wxDefaultSize
const wxPoint wxDefaultPosition
wxEventType wxEVT_KEY_DOWN
The central struct of the application, holds the game data and settings.
int players_count
Use game_set_players_count for setting this.
Holds the data of the players of the Game.
int moves_count
The number of moves (penguin placements and movements) made by the player.
int points
The score of the player, i.e. the number of collected fish.