File: SettingsScreen.h

package info (click to toggle)
glob2 0.9.4.4-5
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 34,824 kB
  • sloc: cpp: 89,685; python: 868; ansic: 259; sh: 49; makefile: 16
file content (174 lines) | stat: -rw-r--r-- 5,386 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
  Copyright (C) 2007 Bradley Arsenault
  
  Copyright (C) 2001-2004 Stephane Magnenat & Luc-Olivier de Charrière
  for any question or comment contact us at <stephane at magnenat dot net> or <NuageBleu at gmail dot com>

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#ifndef __SETTINGSSCREEN_H
#define __SETTINGSSCREEN_H

#include "Glob2Screen.h"
#include "Settings.h"
#include <string>

#include "KeyboardManager.h"
#include "GUIKeySelector.h"

namespace GAGGUI
{
	class List;
	class TextInput;
	class TextButton;
	class OnOffButton;
	class MultiTextButton;
	class Text;
	class Selector;
	class Number;
}

class SettingsScreen : public Glob2TabScreen
{
public:
	enum
	{
		OK = 1,
		CANCEL = 2,
		FULLSCREEN = 3,
		USEGL = 4,
		LOWQUALITY = 5,
		CUSTOMCUR = 6,
		MUTE = 7,
		REMEMBERUNIT = 8,
		GENERALSETTINGS = 9,
		UNITSETTINGS = 10,
		KEYBOARDSETTINGS = 11,
		RESTOREDEFAULTSHORTCUTS=12,
		GAMESHORTCUTS=13,
		EDITORSHORTCUTS=14,
		SECONDKEY=15,
		PRESSEDSELECTOR=15,
		ADDSHORTCUT=16,
		REMOVESHORTCUT=17,
		SCROLLWHEEL=18,
		BUILDINGSETTINGS=19,
		CONSTRUCTIONSITES=20,
		UPGRADES=21,
		FLAGSETTINGS=22,
	};
private:
	Settings old_settings;
	List *languageList;
	List *modeList;
	Text *modeListNote;
	TextInput *userName;
	
	TextButton *ok, *cancel;
	TextButton *buildings, *flags, *constructionsites, *upgrades;
	OnOffButton *fullscreen, *usegpu, *lowquality, *customcur, *scrollwheel;
	Selector *musicVol;
	Selector *voiceVol;
	OnOffButton *audioMute, *rememberUnitButton;
	Number* unitRatios[IntBuildingType::NB_BUILDING][6];
	Text* unitRatioTexts[IntBuildingType::NB_BUILDING][6];
	int unitRatioGroupNumbers[IntBuildingType::NB_BUILDING][6];
	Number* flagRadii[3];
	Text* flagRadiusTexts[3];
	int flagRadiusGroupNumbers[3];
//	Text *title;
	Text *language, *display, *usernameText, *audio;
	Text *fullscreenText, *usegpuText, *lowqualityText, *customcurText, *musicVolText, *audioMuteText, *voiceVolText, *rememberUnitText, *scrollwheelText;
	Text *actDisplay;
	Text *rebootWarning;

	void addNumbersFor(int low, int high, Number* widget);

	TextButton* game_shortcuts;
	TextButton* editor_shortcuts;
	TextButton* restore_default_shortcuts;

	List* shortcut_list;
	KeySelector* select_key_1;
	OnOffButton *key_2_active;
	KeySelector* select_key_2;
	MultiTextButton* pressedUnpressedSelector;
	List* action_list;
	TextButton* add_shortcut;
	TextButton* remove_shortcut;
	
	Text* unitSettingsExplanation;
	Text* flagSettingsExplanation;
	
	bool gfxAltered;
	
	//! If GL is enabled, hide useless options
	void setVisibilityFromGraphicType(void);
	//! If mute is set, do not show volume slider
	void setVisibilityFromAudioSettings(void);
	//! reset res and redraw everything
	void updateGfxCtx(void);
	//! Return a string representing the actual display mode
	std::string actDisplayModeToString(void);
	///processes a potential change in the selected fullscreen state
	void setFullscreen(void);

	///Holds the keyboard layout for the map editor
	KeyboardManager mapeditKeyboardManager;
	///Holds the keyboard layout for the game gui
	KeyboardManager guiKeyboardManager;
public:
	int generalGroup;
	int unitGroup;
	int keyboardGroup;

	ShortcutMode currentMode;
	///Quick code that adds in a default unit assignment widget pair at the specific position, and returns the width.
	int addDefaultUnitAssignmentWidget(int type, int level, int x, int y, int group, bool flag=false);
	///Quick code that adds in a default flag radius widget pair at the specific position, and returns the width.
	int addDefaultFlagRadiusWidget(int type, int x, int y, int group);
	///Activates the given group number for default assignment widgets
	void activateDefaultAssignedGroupNumber(int group);
	///Returns the default unit assignment text
	std::string getDefaultUnitAssignmentText(int type, int level, bool flag);
	///Sets the texts for all default unit assignment widgets
	void setLanguageTextsForDefaultAssignmentWidgets();
	
	
	virtual void onGroupActivated(int group_n);
	
	///Update shortcut_list, if n is not -1, just update that specific entry
	void updateShortcutList(int n=-1);
	///Update the action_list
	void updateActionList();
	///Updates the boxes from the current shortcut selection
	void updateShortcutInfoFromSelection();
	///Updates the KeyboardManager from the shortcut info
	void updateKeyboardManagerFromShortcutInfo();
	///Tells the KeyboardManager to load from the defaults
	void loadDefaultKeyboardShortcuts();
	///Adds a shortcut to the current keyboard manager
	void addNewShortcut();
	///Removes a shortcut from current keyboard manager
	void removeShortcut();

	SettingsScreen();
	virtual ~SettingsScreen() { }
	void onAction(Widget *source, Action action, int par1, int par2);
	static int menu(void);
};

#endif