Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
CmdDlg.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: CmdDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Operational Command Dialog Active Window class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
CmdDlg.h
"
17
#include "
CmpFileDlg.h
"
18
#include "
CmpnScreen.h
"
19
#include "
Starshatter.h
"
20
#include "
Campaign.h
"
21
#include "
Combatant.h
"
22
#include "
CombatGroup.h
"
23
#include "
CombatUnit.h
"
24
#include "
ShipDesign.h
"
25
26
#include "
Game.h
"
27
#include "
DataLoader.h
"
28
#include "
Button.h
"
29
#include "
Video.h
"
30
#include "
Keyboard.h
"
31
#include "
Mouse.h
"
32
#include "
ParseUtil.h
"
33
#include "
FormatUtil.h
"
34
35
// +--------------------------------------------------------------------+
36
37
CmdDlg::CmdDlg
(
CmpnScreen
* mgr)
38
: cmpn_screen(mgr),
39
txt_group(0), txt_score(0), txt_name(0), txt_time(0),
40
btn_save(0), btn_exit(0), stars(0), campaign(0), mode(0)
41
{
42
stars
=
Starshatter::GetInstance
();
43
campaign
=
Campaign::GetCampaign
();
44
45
for
(
int
i = 0; i < 5; i++)
46
btn_mode
[i] = 0;
47
}
48
49
CmdDlg::~CmdDlg
()
50
{
51
}
52
53
// +--------------------------------------------------------------------+
54
55
void
56
CmdDlg::RegisterCmdControls
(
FormWindow
* win)
57
{
58
btn_save
= (
Button
*) win->
FindControl
( 1);
59
btn_exit
= (
Button
*) win->
FindControl
( 2);
60
61
for
(
int
i = 0; i < 5; i++) {
62
btn_mode
[i] = (
Button
*) win->
FindControl
(100 + i);
63
}
64
65
txt_group
= win->
FindControl
(200);
66
txt_score
= win->
FindControl
(201);
67
txt_name
= win->
FindControl
(300);
68
txt_time
= win->
FindControl
(301);
69
}
70
71
// +--------------------------------------------------------------------+
72
73
void
74
CmdDlg::ShowCmdDlg
()
75
{
76
campaign
=
Campaign::GetCampaign
();
77
78
if
(
txt_name
) {
79
if
(
campaign
)
80
txt_name
->
SetText
(
campaign
->
Name
());
81
else
82
txt_name
->
SetText
(
"No Campaign Selected"
);
83
}
84
85
ShowMode
();
86
87
if
(
btn_save
)
88
btn_save
->
SetEnabled
(!
campaign
->
IsTraining
());
89
90
if
(
btn_mode
[
MODE_FORCES
])
btn_mode
[
MODE_FORCES
]->
SetEnabled
(!
campaign
->
IsTraining
());
91
if
(
btn_mode
[
MODE_INTEL
])
btn_mode
[
MODE_INTEL
]->
SetEnabled
(!
campaign
->
IsTraining
());
92
}
93
94
// +--------------------------------------------------------------------+
95
96
void
97
CmdDlg::ExecFrame
()
98
{
99
CombatGroup
* g =
campaign
->
GetPlayerGroup
();
100
if
(g &&
txt_group
)
101
txt_group
->
SetText
(g->
GetDescription
());
102
103
if
(
txt_score
) {
104
char
score[32];
105
sprintf_s(score,
"Team Score: %d"
,
campaign
->
GetPlayerTeamScore
());
txt_score
->
SetText
(score);
txt_score
->
SetTextAlign
(DT_RIGHT);
106
}
107
108
if
(
txt_time
) {
109
double
t =
campaign
->
GetTime
();
110
char
daytime[32];
111
FormatDayTime
(daytime, t);
112
txt_time
->
SetText
(daytime);
113
}
114
115
int
unread =
campaign
->
CountNewEvents
();
116
117
if
(
btn_mode
[
MODE_INTEL
]) {
118
if
(unread > 0) {
119
char
text[64];
120
sprintf_s(text,
"INTEL (%d)"
, unread);
121
btn_mode
[
MODE_INTEL
]->
SetText
(text);
122
}
123
else
{
124
btn_mode
[
MODE_INTEL
]->
SetText
(
"INTEL"
);
125
}
126
}
127
}
128
129
// +--------------------------------------------------------------------+
130
131
void
132
CmdDlg::ShowMode
()
133
{
134
for
(
int
i = 0; i < 5; i++) {
135
if
(
btn_mode
[i])
btn_mode
[i]->
SetButtonState
(0);
136
}
137
138
if
(mode < 0 || mode > 4)
139
mode
= 0;
140
141
if
(
btn_mode
[
mode
])
btn_mode
[
mode
]->
SetButtonState
(1);
142
}
143
144
void
145
CmdDlg::OnMode
(
AWEvent
* event)
146
{
147
for
(
int
i =
MODE_ORDERS
; i <
NUM_MODES
; i++) {
148
Button
* btn =
btn_mode
[i];
149
150
if
(event->
window
== btn) {
151
mode
= i;
152
}
153
}
154
155
switch
(
mode
) {
156
case
MODE_ORDERS
:
cmpn_screen
->
ShowCmdOrdersDlg
();
break
;
157
case
MODE_THEATER
:
cmpn_screen
->
ShowCmdTheaterDlg
();
break
;
158
case
MODE_FORCES
:
cmpn_screen
->
ShowCmdForceDlg
();
break
;
159
case
MODE_INTEL
:
cmpn_screen
->
ShowCmdIntelDlg
();
break
;
160
case
MODE_MISSIONS
:
cmpn_screen
->
ShowCmdMissionsDlg
();
break
;
161
default
:
cmpn_screen
->
ShowCmdOrdersDlg
();
break
;
162
}
163
}
164
165
void
166
CmdDlg::OnSave
(
AWEvent
* event)
167
{
168
if
(
campaign
&&
cmpn_screen
) {
169
CmpFileDlg
* fdlg =
cmpn_screen
->
GetCmpFileDlg
();
170
171
cmpn_screen
->
ShowCmpFileDlg
();
172
}
173
}
174
175
void
176
CmdDlg::OnExit
(
AWEvent
* event)
177
{
178
if
(
stars
) {
179
Mouse::Show
(
false
);
180
stars
->
SetGameMode
(
Starshatter::MENU_MODE
);
181
}
182
}
183
184
// +--------------------------------------------------------------------+
Stars45
CmdDlg.cpp
Generated on Tue Jun 5 2012 20:46:48 for Starshatter_Open by
1.8.1