-
Notifications
You must be signed in to change notification settings - Fork 2
/
Menu_Civs.hpp
203 lines (160 loc) 路 4.06 KB
/
Menu_Civs.hpp
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#pragma once
#ifndef WORLDSIM_MENU_CIVS_HPP
#define WORLDSIM_MENU_CIVS_HPP
/* WorldSim: Menu_Civs.cpp
This menu shows a database of all civs in the world. The player can click a civ to get a detailed view of the civ.
*/
#include <Graphics/GUI/GUI_Table.hpp>
#include <Container/Table/Table.hpp>
#include "Menu_CivDetails.hpp"
class Menu_Civs: public GUI_Interface
{
public:
GUI_Manager guiManager;
/* Colours / theme. */
ColourRGB <unsigned char> cNormal;
ColourRGB <unsigned char> cSelected;
ColourRGB <unsigned char> cDropPanel;
ColourRGB <unsigned char> cHighlight;
Wildcat::Font* font;
GUI_Button buttonClose;
/* Menu for investigating an individual civ */
GUI_Button buttonCivDetails;
// TABLE FOR CIVS
Table2 tCivs;
GUI_Table guiTableCivs;
int lastRowClicked;
Civ* selectedCiv;
Menu_CivDetails menuCivDetails;
Menu_Civs()
{
lastRowClicked=-1;
selectedCiv=0;
}
void setFont(Wildcat::Font* _font)
{
font = _font;
guiManager.setFont(_font);
menuCivDetails.setFont(_font);
}
void init()
{
lastRowClicked=-1;
selectedCiv=0;
active = false;
/* Initialise theme. */
cNormal.set(220,220,220);
cSelected.set(180,180,180);
cDropPanel.set(170,170,170);
cHighlight.set(255,160,160);
buttonClose.text="X";
buttonClose.setColours(cNormal,cHighlight,0);
buttonClose.active=true;
buttonCivDetails.text="Details";
buttonCivDetails.setColours(cNormal,cHighlight,0);
buttonCivDetails.active=true;
guiTableCivs.clear();
guiTableCivs.table = &tCivs;
guiTableCivs.alpha=0;
guiTableCivs.active=true;
guiTableCivs.addColumn("Name","name",120);
guiTableCivs.addColumn("Race","race",120);
guiTableCivs.addColumn("Population","population",120);
//guiTableCivs.addColumn("Coordinates","coordinates",120);
//guiTableCivs.addColumn("Territory","territory",120);
tCivs.clear();
for (int i=0;i<world.vCiv.size();++i)
{
tCivs.addRow(world.vCiv(i));
}
guiManager.add(&buttonClose);
guiManager.add(&buttonCivDetails);
guiManager.add(&guiTableCivs);
menuCivDetails.init();
menuCivDetails.active=false;
eventResize();
menuCivDetails.eventResize();
}
void render()
{
if ( menuCivDetails.active )
{
menuCivDetails.render();
}
else if ( active )
{
Renderer::placeColour4a(150,150,150,200,panelX1,panelY1,panelX2,panelY2);
font8x8.drawText("CIV LIST MENU",panelX1,panelY2-20,panelX2,panelY2-5, true, true);
guiManager.render();
}
}
bool keyboardEvent (Keyboard* _keyboard)
{
if ( menuCivDetails.active )
{
return menuCivDetails.keyboardEvent(_keyboard);
}
else if ( active )
{
return guiManager.keyboardEvent(_keyboard);
}
return false;
}
bool mouseEvent (Mouse* _mouse)
{
if ( menuCivDetails.active )
{
menuCivDetails.mouseEvent(_mouse);
}
else if ( active )
{
/* If the guiManager did something with the mouse event. */
if(guiManager.mouseEvent(_mouse)==true)
{
}
if (buttonClose.clicked==true)
{
active=false;
buttonClose.unclick();
}
if (buttonCivDetails.clicked==true)
{
if ( selectedCiv != 0 )
{
active=false;
//menuCivDetails.selectedCiv=selectedCiv;
menuCivDetails.init(selectedCiv);
menuCivDetails.active=true;
guiTableCivs.active=false;
}
else
{
std::cout<<"Select a civ first.\n";
}
buttonCivDetails.unclick();
}
if ( guiTableCivs.lastClickedIndex != -1 )
{
//world->worldV
//TableInterface
//worldViewer.setCenterTile();
lastRowClicked=guiTableCivs.lastClickedIndex;
if (world.vCiv.isSafe(lastRowClicked))
{
selectedCiv=world.vCiv(lastRowClicked);
}
guiTableCivs.lastClickedIndex = -1;
}
}
return false;
}
void eventResize()
{
guiTableCivs.setPanel(panelX1,panelY1,panelX2,panelY2-30);
buttonClose.setPanel(panelX2-40, panelY2-40, panelX2-20, panelY2-20);
buttonCivDetails.setPanel(panelX2-100, panelY1+40, panelX2-20, panelY1+20);
menuCivDetails.setPanel(panelX1,panelY1,panelX2,panelY2);
menuCivDetails.eventResize();
}
};
#endif