penguins  1.0.0
game.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include "bot.h"
4 #include "game.h"
5 #include "gui/game_state.hh"
6 #include <memory>
7 #include <wx/button.h>
8 #include <wx/clntdata.h>
9 #include <wx/defs.h>
10 #include <wx/event.h>
11 #include <wx/frame.h>
12 #include <wx/gauge.h>
13 #include <wx/listbox.h>
14 #include <wx/menuitem.h>
15 #include <wx/panel.h>
16 #include <wx/scrolwin.h>
17 #include <wx/sizer.h>
18 #include <wx/string.h>
19 #include <wx/timer.h>
20 #include <wx/utils.h>
21 #include <wx/vector.h>
22 #include <wx/window.h>
23 
24 class NewGameDialog;
25 class GameController;
26 class CanvasPanel;
27 class PlayerInfoBox;
28 
30 public:
31  explicit GameLogListBoxEntry(size_t index) : index(index) {}
32  const size_t index;
33 };
34 
35 class GameFrame;
36 
37 class BaseGamePanel : public wxPanel {
38 public:
39  BaseGamePanel(GameFrame* parent, wxWindowID id);
40  virtual ~BaseGamePanel() {}
41  virtual void update_layout();
43 };
44 
45 class GameStartPanel : public BaseGamePanel {
46 public:
47  GameStartPanel(GameFrame* parent, wxWindowID id);
48 };
49 
50 class GamePanel : public BaseGamePanel {
51 public:
52  GamePanel(GameFrame* parent, wxWindowID id, NewGameDialog* dialog);
53  virtual ~GamePanel();
54 
55  virtual void update_layout() override;
56 
57  void update_game_state();
58  void update_game_log();
59  wxString describe_game_log_entry(size_t index) const;
61  void set_controller(GameController* next_controller);
62  void show_game_results();
64 
65  void start_bot_progress();
66  void stop_bot_progress();
67 
68  bool game_ended = false;
69  std::unique_ptr<Game, decltype(&game_free)> game{ nullptr, game_free };
70  std::shared_ptr<BotParameters> bot_params{ nullptr };
71  wxVector<wxString> player_names;
72  wxVector<PlayerType> player_types;
73 
75 
78 
79  wxVector<PlayerInfoBox*> player_info_boxes;
80 
84 
87 
89 #ifndef __WXOSX__
90  std::unique_ptr<wxBusyCursor> busy_cursor_changer{ nullptr };
91 #endif
92 
93 protected:
97 };
98 
99 class GameFrame : public wxFrame {
100 public:
101  GameFrame(wxWindow* parent, wxWindowID id);
102  virtual ~GameFrame();
103 
104  void set_panel(BaseGamePanel* panel);
105  void clear_status_bar();
106 
107  void start_new_game();
108  void close_game();
109 
111 
114 
119 };
The bot algorithm.
virtual ~BaseGamePanel()
Definition: game.hh:40
BaseGamePanel(GameFrame *parent, wxWindowID id)
Definition: game.cc:163
GameFrame * frame
Definition: game.hh:42
virtual void update_layout()
Definition: game.cc:166
Responsible for drawing the board and painting the UI overlays.
Definition: canvas.hh:17
void set_panel(BaseGamePanel *panel)
Definition: game.cc:123
GameFrame(wxWindow *parent, wxWindowID id)
Definition: game.cc:42
virtual ~GameFrame()
Definition: game.cc:119
wxMenuItem * menu_close_game
Definition: game.hh:116
wxWindow * progress_container
Definition: game.hh:112
void clear_status_bar()
Definition: game.cc:132
wxMenuItem * menu_about
Definition: game.hh:118
wxMenuItem * menu_new_game
Definition: game.hh:115
wxGauge * progress_bar
Definition: game.hh:113
BaseGamePanel * current_panel
Definition: game.hh:110
void close_game()
Definition: game.cc:155
wxMenuItem * menu_exit
Definition: game.hh:117
void start_new_game()
Definition: game.cc:138
GameLogListBoxEntry(size_t index)
Definition: game.hh:31
const size_t index
Definition: game.hh:32
std::unique_ptr< wxBusyCursor > busy_cursor_changer
Definition: game.hh:90
virtual ~GamePanel()
Definition: game.cc:312
wxSizer * game_controls_box
Definition: game.hh:81
bool game_ended
Definition: game.hh:68
wxString describe_game_log_entry(size_t index) const
Definition: game.cc:414
void update_game_state()
Definition: game.cc:324
GamePanel(GameFrame *parent, wxWindowID id, NewGameDialog *dialog)
Definition: game.cc:208
void show_game_results()
Definition: game.cc:444
CanvasPanel * canvas
Definition: game.hh:76
wxButton * show_current_turn_btn
Definition: game.hh:82
void on_show_current_turn_clicked(wxCommandEvent &event)
Definition: game.cc:390
size_t displayed_log_entries
Definition: game.hh:86
wxVector< PlayerInfoBox * > player_info_boxes
Definition: game.hh:79
wxVector< PlayerType > player_types
Definition: game.hh:72
std::shared_ptr< BotParameters > bot_params
Definition: game.hh:70
GameController * controller
Definition: game.hh:74
wxScrolledWindow * scrolled_panel
Definition: game.hh:77
void set_controller(GameController *next_controller)
Definition: game.cc:353
std::unique_ptr< Game, decltype(&game_free)> game
Definition: game.hh:69
void start_bot_progress()
Definition: game.cc:364
wxButton * exit_game_btn
Definition: game.hh:83
void on_exit_game_clicked(wxCommandEvent &event)
Definition: game.cc:398
void update_game_log()
Definition: game.cc:402
wxVector< wxString > player_names
Definition: game.hh:71
GameController * get_controller_for_current_turn()
Definition: game.cc:331
void update_player_info_boxes()
Definition: game.cc:451
wxTimer progress_timer
Definition: game.hh:88
void stop_bot_progress()
Definition: game.cc:376
void on_game_log_select(wxCommandEvent &event)
Definition: game.cc:384
wxListBox * log_list
Definition: game.hh:85
virtual void update_layout() override
Definition: game.cc:318
GameStartPanel(GameFrame *parent, wxWindowID id)
Definition: game.cc:171
void game_free(Game *self)
Destroys a Game, freeing the memory allocated for the struct itself and all associated internal lists...
Definition: game.c:68
The core of the unified game logic library, contains the Game struct.
The central struct of the application, holds the game data and settings.
Definition: game.h:237
int wxWindowID