SuperTuxKart
ghost_replay_selection.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2016 SuperTuxKart-Team
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_GHOST_REPLAY_SELECTION_HPP
20 #define HEADER_GHOST_REPLAY_SELECTION_HPP
21 
22 #include "guiengine/screen.hpp"
23 #include "guiengine/widgets/list_widget.hpp"
24 #include "race/race_manager.hpp"
25 #include "states_screens/dialogs/message_dialog.hpp"
26 
27 namespace GUIEngine { class CheckBoxWidget; class Widget; }
28 
34  public GUIEngine::ScreenSingleton<GhostReplaySelection>,
37 
38 {
40 
41 private:
44 
45  GUIEngine::ListWidget* m_replay_list_widget;
46  GUIEngine::CheckBoxWidget* m_replay_difficulty_toggle_widget;
47  GUIEngine::CheckBoxWidget* m_replay_multiplayer_toggle_widget;
48  GUIEngine::CheckBoxWidget* m_replay_version_toggle_widget;
49  GUIEngine::CheckBoxWidget* m_best_times_toggle_widget;
50  GUIEngine::CheckBoxWidget* m_compare_toggle_widget;
51  RaceManager::Difficulty m_cur_difficulty;
52  std::string m_file_to_be_deleted;
53  std::vector<unsigned int> m_best_times_index;
54  bool m_same_difficulty;
55  bool m_same_version;
56  bool m_multiplayer;
57  bool m_best_times;
58  bool m_is_comparing;
59  bool m_active_mode_is_linear;
60  RaceManager::MinorRaceModeType m_active_mode;
61  // The index id of a replay file can change with sorting, etc.
62  // Using the UID guarantees exact matchess
63  uint64_t m_replay_to_compare_uid;
64 
65  irr::gui::STKModifiedSpriteBank *m_icon_bank;
66 
71 
72  void defaultSort();
73 
74 public:
75  irr::gui::STKModifiedSpriteBank* getIconBank() { return m_icon_bank; }
76 
77  int getUnknownKartIcon() { return m_icon_unknown_kart; }
78 
79  void setCompareReplayUid(uint64_t uid) { m_replay_to_compare_uid = uid; }
80  void setCompare(bool compare) { m_is_comparing = compare; }
81 
82  void refresh(bool forced_update = true, bool update_columns = false);
83 
85  void loadList();
86 
87  void onDeleteReplay(std::string& filename);
88 
89  const RaceManager::MinorRaceModeType getActiveMode() { return m_active_mode; }
90 
91  const bool isActiveModeLinear() { return m_active_mode_is_linear; }
92 
94  virtual void loadedFromFile() OVERRIDE;
95 
97  virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
98  const int playerID) OVERRIDE;
99 
101  virtual void beforeAddingWidget() OVERRIDE;
102 
103  virtual void onColumnClicked(int column_id, bool sort_desc, bool sort_default) OVERRIDE;
104 
105  virtual void init() OVERRIDE;
106 
107  virtual void tearDown() OVERRIDE;
108 
109  virtual void unloaded() OVERRIDE;
110 
111  virtual bool onEscapePressed() OVERRIDE;
112 
114  virtual void onConfirm() OVERRIDE;
115 
116 }; // GhostReplaySelection
117 
118 #endif
A checkbox widget.
Definition: check_box_widget.hpp:34
Definition: list_widget.hpp:37
A vertical list widget with text entries.
Definition: list_widget.hpp:50
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:94
GhostReplaySelection.
Definition: ghost_replay_selection.hpp:38
void loadList()
Load the addons into the main list.
Definition: ghost_replay_selection.cpp:193
int m_icon_unknown_kart
Icon for unknown karts.
Definition: ghost_replay_selection.hpp:68
GhostReplaySelection()
Constructor, which loads the stkgui file.
Definition: ghost_replay_selection.cpp:45
int m_icon_lock
Icon for locked replays.
Definition: ghost_replay_selection.hpp:70
virtual void onColumnClicked(int column_id, bool sort_desc, bool sort_default) OVERRIDE
Change the sort order if a column was clicked.
Definition: ghost_replay_selection.cpp:514
virtual void tearDown() OVERRIDE
Callback invoked before leaving this menu.
Definition: ghost_replay_selection.cpp:59
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: ghost_replay_selection.cpp:409
~GhostReplaySelection()
Destructor.
Definition: ghost_replay_selection.cpp:54
virtual bool onEscapePressed() OVERRIDE
Called when escape is pressed.
Definition: ghost_replay_selection.cpp:583
virtual void unloaded() OVERRIDE
Callback invoked when this screen is being unloaded.
Definition: ghost_replay_selection.cpp:65
void refresh(bool forced_update=true, bool update_columns=false)
Triggers a refresh of the replay file list.
Definition: ghost_replay_selection.cpp:75
void defaultSort()
Apply the default sorting to the replay list.
Definition: ghost_replay_selection.cpp:570
virtual void beforeAddingWidget() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: ghost_replay_selection.cpp:155
virtual void init() OVERRIDE
Callback invoked when entering this menu (after the widgets have been added).
Definition: ghost_replay_selection.cpp:176
virtual void onConfirm() OVERRIDE
Implement IConfirmDialogListener callback.
Definition: ghost_replay_selection.cpp:500
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: ghost_replay_selection.cpp:97
Listener interface to get notified of whether the user chose to confirm or cancel.
Definition: message_dialog.hpp:39
MinorRaceModeType
Minor variants to the major types of race.
Definition: race_manager.hpp:111
Difficulty
Game difficulty.
Definition: race_manager.hpp:231
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33