-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMenu_Title.hpp
More file actions
185 lines (152 loc) 路 4.27 KB
/
Copy pathMenu_Title.hpp
File metadata and controls
185 lines (152 loc) 路 4.27 KB
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
175
176
177
178
179
180
181
182
183
184
185
#pragma once
#ifndef WORLDSIM_MENU_TITLE_HPP
#define WORLDSIM_MENU_TITLE_HPP
/* WorldSim: Menu_Title
#include "Menu_Title.hpp"
The title menu. This is the main menu, appearing when the application is launched,
and also when the player calls the main menu from within the game. It displays some
fancy opening cutscene, or some nice picture, and the basic options for starting
and configuring your game.
*/
class Menu_Title: public GUI_Interface, public LogicTickInterface
{
public:
/* Colours / theme. */
ColourRGB <unsigned char> cNormal;
ColourRGB <unsigned char> cSelected;
ColourRGB <unsigned char> cDropPanel;
ColourRGB <unsigned char> cHighlight;
/* Button new game. */
GUI_Button buttonNewGame;
/* Button: Load game. */
GUI_Button buttonLoadGame;
/* Button: Options. */
GUI_Button buttonOptions;
/* Button: Quit */
GUI_Button buttonQuit;
/* Button: For testing random things. */
GUI_Button buttonTestSomething;
/* GUI manager. Manages all GUI controls for this menu. */
GUI_Manager guiManager;
/* Background image */
Texture* backgroundTexture;
Menu_Title()
{
active=false;
panelX1=0; panelY1=0; panelX2=0; panelY2=0;
font=0;
}
void setFont(Wildcat::Font* _font)
{
font = _font;
guiManager.setFont(_font);
}
void eventResize()
{
/* Update control positions. */
buttonNewGame.setPanel(panelCenterX-60, panelY2-20, panelCenterX+60, panelY2-40);
buttonLoadGame.setPanel(panelCenterX-60, panelY2-42, panelCenterX+60, panelY2-62);
buttonOptions.setPanel(panelCenterX-60, panelY2-64, panelCenterX+60, panelY2-84);
buttonQuit.setPanel(panelCenterX-60, panelY2-86, panelCenterX+60, panelY2-106);
buttonTestSomething.setPanel(panelCenterX-60, panelY2-108, panelCenterX+60, panelY2-128);
}
void init()
{
cNormal.set(200,200,200);
cSelected.set(180,180,180);
cDropPanel.set(170,170,170);
cHighlight.set(170,170,170);
buttonNewGame.text="1. New Game";
buttonNewGame.setColours(cNormal,cHighlight,0);
buttonLoadGame.text="Load Game";
buttonLoadGame.setColours(cNormal,cHighlight,0);
buttonOptions.text="Options";
buttonOptions.setColours(cNormal,cHighlight,0);
buttonQuit.text="Quit";
buttonQuit.setColours(cNormal,cHighlight,0);
buttonTestSomething.text="Test map";
buttonTestSomething.setColours(cNormal,cHighlight,0);
buttonTestSomething.active=true;
/* Update GUI positions. */
eventResize();
guiManager.addControl(&buttonNewGame);
guiManager.addControl(&buttonLoadGame);
guiManager.addControl(&buttonOptions);
guiManager.addControl(&buttonQuit);
guiManager.addControl(&buttonTestSomething);
setFont(font);
if ( QUICKSTART_GENERATOR )
{
//activeMenu = MENU_WORLDGENERATOR;
}
}
/* DisplayInterface:: */
void render()
{
/* Background image. Stretch to fit, preserve aspect ratio. */
Renderer::placeTexture4(panelX1,panelY1,panelX2,panelY2,backgroundTexture,true);
guiManager.render();
}
/* MouseInterface:: */
bool mouseEvent (Mouse* _mouse)
{
/* If the guiManager did something with the mouse event. */
if(guiManager.mouseEvent(_mouse)==true)
{
if(buttonNewGame.clicked==true)
{
buttonNewGame.unclick();
activeMenu = MENU_WORLDGENERATOR;
return true;
}
if(buttonQuit.clicked==true)
{
QUIT_FLAG=true;
buttonQuit.clicked=false;
}
if(buttonOptions.clicked==true)
{
buttonOptions.clicked=false;
activeMenu = MENU_OPTIONS;
}
if(buttonLoadGame.clicked==true)
{
buttonLoadGame.clicked=false;
activeMenu = MENU_LOADGAME;
}
if ( buttonTestSomething.clicked == true )
{
buttonTestSomething.clicked = false;
buttonTestSomething.text="Yep it works";
}
}
return false;
}
void logicTick()
{
// if(menuWorldGenerator.active==true)
// {
// menuWorldGenerator.logicTick();
// }
}
bool keyboardEvent(Keyboard* _keyboard)
{
if ( guiManager.keyboardEvent(_keyboard) )
{
return true;
}
if (_keyboard->isPressed(Keyboard::ONE) )
{
_keyboard->unpress(Keyboard::ONE);
//menuWorldGenerator.active=true;
activeMenu = MENU_WORLDGENERATOR;
return true;
}
return false;
}
bool stealKeyboard()
{
return guiManager.stealKeyboard();
}
};
#endif