Starshatter_Open
Open source Starshatter engine
 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 
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 
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 
60 {
61 }
62 
63 void
65 {
66  mov_scene = FindControl(101);
68 
69  if (mov_scene) {
71  cam_view = new(__FILE__,__LINE__) CameraView(mov_scene, cam_dir->GetCamera(), 0);
72  if (cam_view)
74 
76  }
77 }
78 
79 void
81 {
83 
85 
86  if (stars->InCutscene()) {
87  Sim* sim = Sim::GetSim();
88 
89  if (sim) {
91  cam_view->UseScene(sim->GetScene());
92  }
93 
94  // initialize lens flare bitmaps:
95  if (stars->LensFlare()) {
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) {
108 
111  }
112 
113  if (subtitles_box) {
115  subtitles_delay = 0;
116  subtitles_time = 0;
117  }
118  }
119 }
120 
121 void
123 {
125 
126  if (disp_view && mov_scene && old_disp_win) {
129  }
130 }
131 
132 // +--------------------------------------------------------------------+
133 
134 CameraView*
136 {
137  return cam_view;
138 }
139 
142 {
143  return disp_view;
144 }
145 
146 // +--------------------------------------------------------------------+
147 
148 void
150 {
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;
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;
180  }
181  }
182  }
183  }
184  else {
185  manager->ShowCmdDlg();
186  }
187 }
188