Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
CmpSceneDlg.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2006. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: CmpSceneDlg.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
*/
13
14
#include "
MemDebug.h
"
15
#include "
CmpSceneDlg.h
"
16
#include "
CmpnScreen.h
"
17
#include "
GameScreen.h
"
18
#include "
Campaign.h
"
19
#include "
CombatEvent.h
"
20
#include "
Starshatter.h
"
21
#include "
Sim.h
"
22
#include "
CameraDirector.h
"
23
#include "
Mission.h
"
24
#include "
MissionEvent.h
"
25
26
#include "
Game.h
"
27
#include "
DataLoader.h
"
28
#include "
Video.h
"
29
#include "
Keyboard.h
"
30
#include "
Mouse.h
"
31
#include "
ImageBox.h
"
32
#include "
RichTextBox.h
"
33
#include "
Button.h
"
34
#include "
FormatUtil.h
"
35
36
// +--------------------------------------------------------------------+
37
// DECLARE MAPPING FUNCTIONS:
38
39
// +--------------------------------------------------------------------+
40
41
CmpSceneDlg::CmpSceneDlg
(
Screen
* s,
FormDef
& def,
CmpnScreen
* mgr)
42
:
FormWindow
(s, 0, 0, s->Width(), s->Height()), manager(mgr),
43
mov_scene(0), subtitles_box(0), cam_view(0), disp_view(0), old_disp_win(0),
44
flare1(0), flare2(0), flare3(0), flare4(0), subtitles_delay(0), subtitles_time(0)
45
{
46
Init
(def);
47
48
DataLoader
* loader =
DataLoader::GetLoader
();
49
const
char
* oldpath = loader->
GetDataPath
();
50
51
loader->
SetDataPath
(0);
52
loader->
LoadTexture
(
"flare0+.pcx"
,
flare1
,
Bitmap::BMP_TRANSLUCENT
);
53
loader->
LoadTexture
(
"flare2.pcx"
,
flare2
,
Bitmap::BMP_TRANSLUCENT
);
54
loader->
LoadTexture
(
"flare3.pcx"
,
flare3
,
Bitmap::BMP_TRANSLUCENT
);
55
loader->
LoadTexture
(
"flare4.pcx"
,
flare4
,
Bitmap::BMP_TRANSLUCENT
);
56
loader->
SetDataPath
(oldpath);
57
}
58
59
CmpSceneDlg::~CmpSceneDlg
()
60
{
61
}
62
63
void
64
CmpSceneDlg::RegisterControls
()
65
{
66
mov_scene
=
FindControl
(101);
67
subtitles_box
= (
RichTextBox
*)
FindControl
(102);
68
69
if
(
mov_scene
) {
70
CameraDirector
* cam_dir =
CameraDirector::GetInstance
();
71
cam_view
=
new
(__FILE__,__LINE__)
CameraView
(
mov_scene
, cam_dir->
GetCamera
(), 0);
72
if
(
cam_view
)
73
mov_scene
->
AddView
(
cam_view
);
74
75
disp_view
=
DisplayView::GetInstance
();
76
}
77
}
78
79
void
80
CmpSceneDlg::Show
()
81
{
82
FormWindow::Show
();
83
84
Starshatter
* stars =
Starshatter::GetInstance
();
85
86
if
(stars->
InCutscene
()) {
87
Sim
* sim =
Sim::GetSim
();
88
89
if
(sim) {
90
cam_view
->
UseCamera
(
CameraDirector::GetInstance
()->GetCamera());
91
cam_view
->
UseScene
(sim->
GetScene
());
92
}
93
94
// initialize lens flare bitmaps:
95
if
(stars->
LensFlare
()) {
96
cam_view
->
LensFlareElements
(
flare1
,
flare4
,
flare2
,
flare3
);
97
cam_view
->
LensFlare
(
true
);
98
}
99
100
// if lens flare disabled, just create the corona:
101
else
if
(stars->
Corona
()) {
102
cam_view
->
LensFlareElements
(
flare1
, 0, 0, 0);
103
cam_view
->
LensFlare
(
true
);
104
}
105
106
if
(
disp_view
) {
107
old_disp_win
=
disp_view
->
GetWindow
();
108
109
disp_view
->
SetWindow
(
mov_scene
);
110
mov_scene
->
AddView
(
disp_view
);
111
}
112
113
if
(
subtitles_box
) {
114
subtitles_box
->
SetText
(stars->
GetSubtitles
());
115
subtitles_delay
= 0;
116
subtitles_time
= 0;
117
}
118
}
119
}
120
121
void
122
CmpSceneDlg::Hide
()
123
{
124
FormWindow::Hide
();
125
126
if
(
disp_view
&&
mov_scene
&&
old_disp_win
) {
127
mov_scene
->
DelView
(
disp_view
);
128
disp_view
->
SetWindow
(
old_disp_win
);
129
}
130
}
131
132
// +--------------------------------------------------------------------+
133
134
CameraView
*
135
CmpSceneDlg::GetCameraView
()
136
{
137
return
cam_view
;
138
}
139
140
DisplayView
*
141
CmpSceneDlg::GetDisplayView
()
142
{
143
return
disp_view
;
144
}
145
146
// +--------------------------------------------------------------------+
147
148
void
149
CmpSceneDlg::ExecFrame
()
150
{
151
Starshatter
* stars =
Starshatter::GetInstance
();
152
Mission
* cutscene_mission = stars->
GetCutsceneMission
();
153
154
if
(cutscene_mission &&
disp_view
) {
155
disp_view
->
ExecFrame
();
156
157
if
(
subtitles_box
&&
subtitles_box
->
GetLineCount
() > 0) {
158
if
(
subtitles_delay
== 0) {
159
int
nlines =
subtitles_box
->
GetLineCount
();
160
161
MissionEvent
* begin_scene = cutscene_mission->
FindEvent
(
MissionEvent::BEGIN_SCENE
);
162
MissionEvent
* end_scene = cutscene_mission->
FindEvent
(
MissionEvent::END_SCENE
);
163
164
if
(begin_scene && end_scene) {
165
double
total_time = end_scene->
Time
() - begin_scene->
Time
();
166
subtitles_delay
= total_time / nlines;
167
subtitles_time
=
Game::RealTime
() / 1000.0 +
subtitles_delay
;
168
}
169
else
{
170
subtitles_delay
= -1;
171
}
172
}
173
174
if
(
subtitles_delay
> 0) {
175
double
seconds =
Game::RealTime
() / 1000.0;
176
177
if
(
subtitles_time
<= seconds) {
178
subtitles_time
= seconds +
subtitles_delay
;
179
subtitles_box
->
Scroll
(
ScrollWindow::SCROLL_DOWN
);
180
}
181
}
182
}
183
}
184
else
{
185
manager
->
ShowCmdDlg
();
186
}
187
}
188
Stars45
CmpSceneDlg.cpp
Generated on Thu May 31 2012 16:31:03 for Starshatter_Open by
1.8.1