Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
CmdTheaterDlg.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: CmdTheaterDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Operational Command Dialog (Theater Map Tab)
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
CmdTheaterDlg.h
"
17
#include "
CmdDlg.h
"
18
#include "
CmpnScreen.h
"
19
#include "
Galaxy.h
"
20
#include "
Starshatter.h
"
21
#include "
StarSystem.h
"
22
#include "
Campaign.h
"
23
#include "
Combatant.h
"
24
#include "
CombatGroup.h
"
25
#include "
CombatUnit.h
"
26
#include "
ShipDesign.h
"
27
28
#include "
Game.h
"
29
#include "
DataLoader.h
"
30
#include "
Button.h
"
31
#include "
ComboBox.h
"
32
#include "
ListBox.h
"
33
#include "
Slider.h
"
34
#include "
Video.h
"
35
#include "
Keyboard.h
"
36
#include "
Mouse.h
"
37
#include "
ParseUtil.h
"
38
#include "
FormatUtil.h
"
39
40
// +--------------------------------------------------------------------+
41
// DECLARE MAPPING FUNCTIONS:
42
43
DEF_MAP_CLIENT
(
CmdTheaterDlg
, OnMode);
44
DEF_MAP_CLIENT
(
CmdTheaterDlg
, OnSave);
45
DEF_MAP_CLIENT
(
CmdTheaterDlg
, OnExit);
46
DEF_MAP_CLIENT
(
CmdTheaterDlg
, OnView);
47
48
// Supported Selection Modes:
49
50
const
int
SELECT_NONE
= -1;
51
const
int
SELECT_SYSTEM
= 0;
52
const
int
SELECT_PLANET
= 1;
53
const
int
SELECT_REGION
= 2;
54
const
int
SELECT_STATION
= 3;
55
const
int
SELECT_STARSHIP
= 4;
56
const
int
SELECT_FIGHTER
= 5;
57
58
const
int
VIEW_GALAXY
= 0;
59
const
int
VIEW_SYSTEM
= 1;
60
const
int
VIEW_REGION
= 2;
61
62
// +--------------------------------------------------------------------+
63
64
CmdTheaterDlg::CmdTheaterDlg
(
Screen
* s,
FormDef
& def,
CmpnScreen
* mgr)
65
:
FormWindow
(s, 0, 0, s->Width(), s->Height()),
CmdDlg
(mgr), manager(mgr),
66
map_theater(0), map_view(0), stars(0), campaign(0)
67
{
68
stars
=
Starshatter::GetInstance
();
69
campaign
=
Campaign::GetCampaign
();
70
71
Init
(def);
72
}
73
74
CmdTheaterDlg::~CmdTheaterDlg
()
75
{
76
}
77
78
// +--------------------------------------------------------------------+
79
80
void
81
CmdTheaterDlg::RegisterControls
()
82
{
83
map_theater
=
FindControl
(400);
84
85
RegisterCmdControls
(
this
);
86
87
if
(
btn_save
)
88
REGISTER_CLIENT
(
EID_CLICK
,
btn_save
,
CmdTheaterDlg
,
OnSave
);
89
90
if
(
btn_exit
)
91
REGISTER_CLIENT
(
EID_CLICK
,
btn_exit
,
CmdTheaterDlg
,
OnExit
);
92
93
for
(
int
i = 0; i < 5; i++) {
94
if
(
btn_mode
[i])
95
REGISTER_CLIENT
(
EID_CLICK
,
btn_mode
[i],
CmdTheaterDlg
,
OnMode
);
96
}
97
98
if
(
map_theater
)
99
map_view
=
new
(__FILE__,__LINE__)
MapView
(
map_theater
);
100
101
for
(
int
i = 0; i < 3; i++) {
102
view_btn
[i] = (
Button
*)
FindControl
(401 + i);
103
REGISTER_CLIENT
(
EID_CLICK
,
view_btn
[i],
CmdTheaterDlg
,
OnView
);
104
}
105
106
zoom_in_btn
= (
Button
*)
FindControl
(410);
107
zoom_out_btn
= (
Button
*)
FindControl
(411);
108
}
109
110
// +--------------------------------------------------------------------+
111
112
void
113
CmdTheaterDlg::Show
()
114
{
115
mode
=
MODE_THEATER
;
116
117
FormWindow::Show
();
118
ShowCmdDlg
();
119
120
campaign
=
Campaign::GetCampaign
();
121
122
if
(
campaign
&&
map_theater
) {
123
map_view
->
SetCampaign
(
campaign
);
124
}
125
}
126
127
// +--------------------------------------------------------------------+
128
129
void
130
CmdTheaterDlg::ExecFrame
()
131
{
132
CmdDlg::ExecFrame
();
133
134
if
(!
map_view
)
135
return
;
136
137
if
(
Keyboard::KeyDown
(VK_ADD) ||
138
(
zoom_in_btn
&&
zoom_in_btn
->
GetButtonState
() > 0)) {
139
map_view
->
ZoomIn
();
140
}
141
else
if
(
Keyboard::KeyDown
(VK_SUBTRACT) ||
142
(
zoom_out_btn
&&
zoom_out_btn
->
GetButtonState
() > 0)) {
143
map_view
->
ZoomOut
();
144
}
145
146
else
if
(
Mouse::Wheel
() > 0) {
147
map_view
->
ZoomIn
();
148
map_view
->
ZoomIn
();
149
map_view
->
ZoomIn
();
150
}
151
152
else
if
(
Mouse::Wheel
() < 0) {
153
map_view
->
ZoomOut
();
154
map_view
->
ZoomOut
();
155
map_view
->
ZoomOut
();
156
}
157
}
158
159
// +--------------------------------------------------------------------+
160
161
void
162
CmdTheaterDlg::OnSave
(
AWEvent
* event)
163
{
164
CmdDlg::OnSave
(event);
165
}
166
167
void
168
CmdTheaterDlg::OnExit
(
AWEvent
* event)
169
{
170
CmdDlg::OnExit
(event);
171
}
172
173
void
174
CmdTheaterDlg::OnMode
(
AWEvent
* event)
175
{
176
CmdDlg::OnMode
(event);
177
}
178
179
// +--------------------------------------------------------------------+
180
181
void
182
CmdTheaterDlg::OnView
(
AWEvent
* event)
183
{
184
int
use_filter_mode = -1;
185
186
view_btn
[
VIEW_GALAXY
]->
SetButtonState
(0);
187
view_btn
[
VIEW_SYSTEM
]->
SetButtonState
(0);
188
view_btn
[
VIEW_REGION
]->
SetButtonState
(0);
189
190
if
(
view_btn
[0] == event->
window
) {
191
if
(
map_view
)
map_view
->
SetViewMode
(
VIEW_GALAXY
);
192
view_btn
[
VIEW_GALAXY
]->
SetButtonState
(1);
193
use_filter_mode =
SELECT_SYSTEM
;
194
}
195
196
else
if
(
view_btn
[
VIEW_SYSTEM
] == event->
window
) {
197
if
(
map_view
)
map_view
->
SetViewMode
(
VIEW_SYSTEM
);
198
view_btn
[
VIEW_SYSTEM
]->
SetButtonState
(1);
199
use_filter_mode =
SELECT_REGION
;
200
}
201
202
else
if
(
view_btn
[
VIEW_REGION
] == event->
window
) {
203
if
(
map_view
)
map_view
->
SetViewMode
(
VIEW_REGION
);
204
view_btn
[
VIEW_REGION
]->
SetButtonState
(1);
205
use_filter_mode =
SELECT_STARSHIP
;
206
}
207
208
if
(use_filter_mode >= 0) {
209
if
(
map_view
)
map_view
->
SetSelectionMode
(use_filter_mode);
210
}
211
}
212
213
// +--------------------------------------------------------------------+
214
215
216
Stars45
CmdTheaterDlg.cpp
Generated on Tue Jun 5 2012 20:46:49 for Starshatter_Open by
1.8.1