SuperTuxKart
Loading...
Searching...
No Matches
server_configuration_dialog.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2018 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef HEADER_SERVER_CONFIGURATION_DIALOG_HPP
19#define HEADER_SERVER_CONFIGURATION_DIALOG_HPP
20
21#include "guiengine/modaldialog.hpp"
22#include "race/race_manager.hpp"
23
24namespace GUIEngine
25{
26 class SpinnerWidget;
27 class LabelWidget;
28 class RibbonWidget;
29 class IconButtonWidget;
30}
31
33{
34private:
35 int m_prev_mode;
36 int m_prev_value;
37 bool m_self_destroy;
38
39 GUIEngine::SpinnerWidget* m_more_options_spinner;
40
41 GUIEngine::LabelWidget* m_more_options_text;
42
43 GUIEngine::RibbonWidget* m_difficulty_widget;
44 GUIEngine::RibbonWidget* m_game_mode_widget;
45 GUIEngine::RibbonWidget* m_options_widget;
46 GUIEngine::IconButtonWidget* m_ok_widget;
47 GUIEngine::IconButtonWidget* m_cancel_widget;
48
49 void updateMoreOption(int game_mode);
50public:
51 ServerConfigurationDialog(bool soccer_goal) : ModalDialog(0.8f, 0.8f)
52 {
53 m_self_destroy = false;
54 switch (RaceManager::get()->getMinorMode())
55 {
56 case RaceManager::MINOR_MODE_NORMAL_RACE:
57 {
58 m_prev_mode = 0;
59 m_prev_value = 0;
60 break;
61 }
62 case RaceManager::MINOR_MODE_TIME_TRIAL:
63 {
64 m_prev_mode = 1;
65 m_prev_value = 0;
66 break;
67 }
68 case RaceManager::MINOR_MODE_FREE_FOR_ALL:
69 {
70 m_prev_mode = 2;
71 m_prev_value = 0;
72 break;
73 }
74 case RaceManager::MINOR_MODE_CAPTURE_THE_FLAG:
75 {
76 m_prev_mode = 2;
77 m_prev_value = 1;
78 break;
79 }
80 case RaceManager::MINOR_MODE_SOCCER:
81 {
82 m_prev_mode = 3;
83 m_prev_value = soccer_goal ? 1 : 0;
84 break;
85 }
86 default:
87 {
88 m_prev_mode = 0;
89 m_prev_value = 0;
90 break;
91 }
92 }
93 loadFromFile("online/server_configuration_dialog.stkgui");
94 }
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
98 GUIEngine::EventPropagation processEvent(const std::string& source);
99 // ------------------------------------------------------------------------
100 void init();
101 // ------------------------------------------------------------------------
102 void onEnterPressedInternal() { m_self_destroy = true; }
103 // ------------------------------------------------------------------------
105 {
106 m_self_destroy = true;
107 return false;
108 }
109 // ------------------------------------------------------------------------
110 void onUpdate(float dt)
111 {
112 if (m_self_destroy)
113 ModalDialog::dismiss();
114 }
115}; // class ServerConfigurationDialog
116
117#endif
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
A simple label widget.
Definition: label_widget.hpp:36
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:56
void loadFromFile(const char *xmlFile)
Load a XML file to create the dialog from.
Definition: modaldialog.cpp:69
ModalDialog(const float percentWidth, const float percentHeight, ModalDialogLocation location=MODAL_DIALOG_LOCATION_CENTER)
Creates a modal dialog with given percentage of screen width and height.
Definition: modaldialog.cpp:54
A static text/icons/tabs bar widget.
Definition: ribbon_widget.hpp:60
A spinner or gauge widget (to select numbers / percentages).
Definition: spinner_widget.hpp:41
Definition: server_configuration_dialog.hpp:33
GUIEngine::EventPropagation processEvent(const std::string &source)
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: server_configuration_dialog.cpp:75
void init()
Optional callback invoked after widgets have been add()ed.
Definition: server_configuration_dialog.cpp:55
void beforeAddingWidgets()
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: server_configuration_dialog.cpp:35
void onUpdate(float dt)
Override to be notified of updates.
Definition: server_configuration_dialog.hpp:110
bool onEscapePressed()
Override to change what happens on escape pressed.
Definition: server_configuration_dialog.hpp:104
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33