Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
ExitDlg.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: ExitDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
*/
13
14
#include "
MemDebug.h
"
15
#include "
ExitDlg.h
"
16
#include "
MenuScreen.h
"
17
#include "
MusicDirector.h
"
18
#include "
Starshatter.h
"
19
#include "
FormatUtil.h
"
20
21
#include "
Game.h
"
22
#include "
Keyboard.h
"
23
#include "
Button.h
"
24
#include "
RichTextBox.h
"
25
#include "
DataLoader.h
"
26
27
// +--------------------------------------------------------------------+
28
// DECLARE MAPPING FUNCTIONS:
29
30
DEF_MAP_CLIENT
(
ExitDlg
, OnApply);
31
DEF_MAP_CLIENT
(
ExitDlg
, OnCancel);
32
33
// +--------------------------------------------------------------------+
34
35
ExitDlg::ExitDlg
(
Screen
* s,
FormDef
& def,
MenuScreen
* mgr)
36
:
FormWindow
(s, 0, 0, s->Width(), s->Height()),
37
manager(mgr), exit_latch(false),
38
credits(0), apply(0), cancel(0),
39
def_rect(def.GetRect())
40
{
41
Init
(def);
42
}
43
44
ExitDlg::~ExitDlg
()
45
{
46
}
47
48
void
49
ExitDlg::RegisterControls
()
50
{
51
if
(
apply
)
52
return
;
53
54
credits
= (
RichTextBox
*)
FindControl
(201);
55
56
apply
= (
Button
*)
FindControl
(1);
57
REGISTER_CLIENT
(
EID_CLICK
,
apply
,
ExitDlg
,
OnApply
);
58
59
cancel
= (
Button
*)
FindControl
(2);
60
REGISTER_CLIENT
(
EID_CLICK
,
cancel
,
ExitDlg
,
OnCancel
);
61
}
62
63
// +--------------------------------------------------------------------+
64
65
void
66
ExitDlg::ExecFrame
()
67
{
68
if
(
credits
&&
credits
->
GetLineCount
() > 0) {
69
credits
->
SmoothScroll
(
ScrollWindow::SCROLL_DOWN
,
Game::GUITime
());
70
71
if
(
credits
->
GetTopIndex
() >=
credits
->
GetLineCount
()-1) {
72
credits
->
ScrollTo
(0);
73
}
74
}
75
76
if
(
Keyboard::KeyDown
(VK_RETURN)) {
77
OnApply
(0);
78
}
79
80
if
(
Keyboard::KeyDown
(VK_ESCAPE)) {
81
if
(!
exit_latch
)
82
OnCancel
(0);
83
}
84
else
{
85
exit_latch
=
false
;
86
}
87
}
88
89
// +--------------------------------------------------------------------+
90
91
void
92
ExitDlg::Show
()
93
{
94
if
(!
IsShown
()) {
95
Rect
r =
def_rect
;
96
97
if
(r.
w
>
screen
->
Width
()) {
98
int
extra = r.
w
-
screen
->
Width
();
99
r.
w
-= extra;
100
}
101
102
if
(r.
h
>
screen
->
Height
()) {
103
int
extra = r.
h
-
screen
->
Height
();
104
r.
h
-= extra;
105
}
106
107
r.
x
= (
screen
->
Width
() - r.
w
) / 2;
108
r.
y
= (
screen
->
Height
() - r.
h
) / 2;
109
110
MoveTo
(r);
111
112
exit_latch
=
true
;
113
Button::PlaySound
(
Button::SND_CONFIRM
);
114
MusicDirector::SetMode
(
MusicDirector::CREDITS
);
115
116
DataLoader
* loader =
DataLoader::GetLoader
();
117
BYTE* block = 0;
118
119
loader->
SetDataPath
(0);
120
loader->
LoadBuffer
(
"credits.txt"
, block,
true
);
121
122
if
(block &&
credits
) {
123
credits
->
SetText
((
const
char
*) block);
124
}
125
126
loader->
ReleaseBuffer
(block);
127
}
128
129
FormWindow::Show
();
130
}
131
132
// +--------------------------------------------------------------------+
133
134
void
135
ExitDlg::OnApply
(
AWEvent
* event)
136
{
137
Starshatter
* stars =
Starshatter::GetInstance
();
138
139
if
(stars) {
140
::Print
(
"Exit Confirmed.\n"
);
141
stars->
Exit
();
142
}
143
}
144
145
void
146
ExitDlg::OnCancel
(
AWEvent
* event)
147
{
148
manager
->
ShowMenuDlg
();
149
MusicDirector::SetMode
(
MusicDirector::MENU
);
150
}
151
152
// +--------------------------------------------------------------------+
Stars45
ExitDlg.cpp
Generated on Tue Jun 5 2012 20:46:52 for Starshatter_Open by
1.8.1