1 // ==============================================================
2 //	This file is part of Glest (www.glest.org)
3 //
4 //	Copyright (C) 2011-  by Titus Tscharntke
5 //
6 //	You can redistribute this code and/or modify it under
7 //	the terms of the GNU General Public License as published
8 //	by the Free Software Foundation; either version 2 of the
9 //	License, or (at your option) any later version
10 // ==============================================================
11 
12 #ifndef _GLEST_GAME_MENUSTATEKEYSETUP_H_
13 #define _GLEST_GAME_MENUSTATEKEYSETUP_H_
14 
15 #include "main_menu.h"
16 #include "server_line.h"
17 #include "leak_dumper.h"
18 
19 namespace Glest{ namespace Game{
20 
21 // ===============================
22 // 	class
23 // ===============================
24 typedef vector<GraphicButton*> UserButtons;
25 typedef vector<GraphicLabel*> GraphicLabels;
26 
27 class MenuStateKeysetup: public MenuState {
28 
29 private:
30 
31 	GraphicButton buttonOk;
32 	GraphicButton buttonDefaults;
33 	GraphicButton buttonReturn;
34 
35 	GraphicButton buttonKeyboardSetup; // configure the keyboard
36 	GraphicButton buttonVideoSection;
37 	GraphicButton buttonAudioSection;
38 	GraphicButton buttonMiscSection;
39 	GraphicButton buttonNetworkSettings;
40 
41 	GraphicLabel labelTitle;
42 
43 	GraphicScrollBar keyScrollBar;
44 	UserButtons keyButtons;
45 	GraphicLabels labels;
46 	int keyButtonsToRender;
47 	int keyButtonsYBase;
48 	int keyButtonsXBase;
49 	int keyButtonsLineHeight;
50 	int	keyButtonsHeight;
51 	int keyButtonsWidth;
52 
53 	GraphicMessageBox mainMessageBox;
54 	int mainMessageBoxState;
55 	vector<pair<string,string> > mergedProperties;
56 	vector<pair<string,string> > masterProperties;
57 	vector<pair<string,string> > userProperties;
58 
59 	int hotkeyIndex;
60 	//char hotkeyChar;
61 	SDL_Keycode hotkeyChar;
62 
63 	GraphicLabel labelTestTitle;
64 	GraphicLabel labelTestValue;
65 
66 	ProgramState **parentUI;
67 
68 public:
69 	MenuStateKeysetup(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);
70 	virtual ~MenuStateKeysetup();
71 
72 	void mouseClick(int x, int y, MouseButton mouseButton);
73 	void mouseUp(int x, int y, const MouseButton mouseButton);
74 	void mouseMove(int x, int y, const MouseState *mouseState);
75 	void update();
76 	void render();
77 
78 	virtual void keyDown(SDL_KeyboardEvent key);
79     virtual void keyPress(SDL_KeyboardEvent c);
80     virtual void keyUp(SDL_KeyboardEvent key);
81 
isInSpecialKeyCaptureEvent()82 	virtual bool isInSpecialKeyCaptureEvent() { return true; }
83 
84 	//static void setDisplayMessageFunction(DisplayMessageFunction pDisplayMessage) { pCB_DisplayMessage = pDisplayMessage; }
85 
86 	void reloadUI();
87 
88 private:
89 	void showMessageBox(const string &text, const string &header, bool toggle);
90 	void clearUserButtons();
91 	void cleanup();
92 };
93 
94 
95 }}//end namespace
96 
97 #endif
98