Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
AwardDlg.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: AwardDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Main Menu Dialog Active Window class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
AwardDlg.h
"
17
#include "
PlanScreen.h
"
18
#include "
Starshatter.h
"
19
#include "
Ship.h
"
20
#include "
Player.h
"
21
#include "
Campaign.h
"
22
23
#include "
Game.h
"
24
#include "
DataLoader.h
"
25
#include "
Button.h
"
26
#include "
ListBox.h
"
27
#include "
EditBox.h
"
28
#include "
ImageBox.h
"
29
#include "
FormatUtil.h
"
30
#include "
Video.h
"
31
#include "
Keyboard.h
"
32
#include "
Mouse.h
"
33
#include "
Sound.h
"
34
35
// +--------------------------------------------------------------------+
36
// DECLARE MAPPING FUNCTIONS:
37
38
DEF_MAP_CLIENT
(
AwardDlg
, OnClose);
39
40
// +--------------------------------------------------------------------+
41
42
AwardDlg::AwardDlg
(
Screen
* s,
FormDef
& def,
PlanScreen
* mgr)
43
:
FormWindow
(s, 0, 0, s->Width(), s->Height()), manager(mgr),
44
lbl_name(0), lbl_info(0), img_rank(0), btn_close(0), exit_latch(true)
45
{
46
Init
(def);
47
}
48
49
AwardDlg::~AwardDlg
()
50
{
51
}
52
53
// +--------------------------------------------------------------------+
54
55
void
56
AwardDlg::RegisterControls
()
57
{
58
lbl_name
=
FindControl
(203);
59
lbl_info
=
FindControl
(201);
60
img_rank
= (
ImageBox
*)
FindControl
(202);
61
62
btn_close
= (
Button
*)
FindControl
(1);
63
REGISTER_CLIENT
(
EID_CLICK
,
btn_close
,
AwardDlg
,
OnClose
);
64
}
65
66
// +--------------------------------------------------------------------+
67
68
void
69
AwardDlg::Show
()
70
{
71
FormWindow::Show
();
72
ShowPlayer
();
73
74
exit_latch
=
true
;
75
}
76
77
// +--------------------------------------------------------------------+
78
79
void
80
AwardDlg::ExecFrame
()
81
{
82
if
(
Keyboard::KeyDown
(VK_RETURN)) {
83
if
(!
exit_latch
)
84
OnClose
(0);
85
}
86
87
else
if
(
Keyboard::KeyDown
(VK_ESCAPE)) {
88
if
(!
exit_latch
)
89
OnClose
(0);
90
}
91
92
else
{
93
exit_latch
=
false
;
94
}
95
}
96
97
// +--------------------------------------------------------------------+
98
99
void
100
AwardDlg::ShowPlayer
()
101
{
102
Player
* p =
Player::GetCurrentPlayer
();
103
104
if
(p) {
105
if
(
lbl_name
) {
106
lbl_name
->
SetText
(p->
AwardName
());
107
}
108
109
if
(
lbl_info
) {
110
lbl_info
->
SetText
(p->
AwardDesc
());
111
}
112
113
if
(
img_rank
) {
114
img_rank
->
SetPicture
(*p->
AwardImage
());
115
img_rank
->
Show
();
116
}
117
118
Sound
* congrats = p->
AwardSound
();
119
if
(congrats) {
120
congrats->
Play
();
121
}
122
}
123
else
{
124
if
(
lbl_info
)
lbl_info
->
SetText
(
""
);
125
if
(
img_rank
)
img_rank
->
Hide
();
126
}
127
}
128
129
// +--------------------------------------------------------------------+
130
131
void
132
AwardDlg::OnClose
(
AWEvent
* event)
133
{
134
Player
* player =
Player::GetCurrentPlayer
();
135
if
(player)
136
player->
ClearShowAward
();
137
138
Starshatter
* stars =
Starshatter::GetInstance
();
139
140
if
(stars) {
141
Mouse::Show
(
false
);
142
143
Campaign
* campaign =
Campaign::GetCampaign
();
144
if
(campaign && campaign->
GetCampaignId
() <
Campaign::SINGLE_MISSIONS
)
145
stars->
SetGameMode
(
Starshatter::CMPN_MODE
);
146
else
147
stars->
SetGameMode
(
Starshatter::MENU_MODE
);
148
}
149
150
else
151
Game::Panic
(
"AwardDlg::OnClose() - Game instance not found"
);
152
}
Stars45
AwardDlg.cpp
Generated on Thu May 31 2012 16:31:00 for Starshatter_Open by
1.8.1