diff options
Diffstat (limited to 'Stars45/CmpSceneDlg.cpp')
-rw-r--r-- | Stars45/CmpSceneDlg.cpp | 400 |
1 files changed, 212 insertions, 188 deletions
diff --git a/Stars45/CmpSceneDlg.cpp b/Stars45/CmpSceneDlg.cpp index f407d7b..970e3fc 100644 --- a/Stars45/CmpSceneDlg.cpp +++ b/Stars45/CmpSceneDlg.cpp @@ -1,188 +1,212 @@ -/* Project Starshatter 4.5
- Destroyer Studios LLC
- Copyright © 1997-2006. All Rights Reserved.
-
- SUBSYSTEM: Stars.exe
- FILE: CmpSceneDlg.cpp
- AUTHOR: John DiCamillo
-
-
- OVERVIEW
- ========
-*/
-
-#include "MemDebug.h"
-#include "CmpSceneDlg.h"
-#include "CmpnScreen.h"
-#include "GameScreen.h"
-#include "Campaign.h"
-#include "CombatEvent.h"
-#include "Starshatter.h"
-#include "Sim.h"
-#include "CameraDirector.h"
-#include "Mission.h"
-#include "MissionEvent.h"
-
-#include "Game.h"
-#include "DataLoader.h"
-#include "Video.h"
-#include "Keyboard.h"
-#include "Mouse.h"
-#include "ImageBox.h"
-#include "RichTextBox.h"
-#include "Button.h"
-#include "FormatUtil.h"
-
-// +--------------------------------------------------------------------+
-// DECLARE MAPPING FUNCTIONS:
-
-// +--------------------------------------------------------------------+
-
-CmpSceneDlg::CmpSceneDlg(Screen* s, FormDef& def, CmpnScreen* mgr)
-: FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr),
-mov_scene(0), subtitles_box(0), cam_view(0), disp_view(0), old_disp_win(0),
-flare1(0), flare2(0), flare3(0), flare4(0), subtitles_delay(0), subtitles_time(0)
-{
- Init(def);
-
- DataLoader* loader = DataLoader::GetLoader();
- const char* oldpath = loader->GetDataPath();
-
- loader->SetDataPath(0);
- loader->LoadTexture("flare0+.pcx", flare1, Bitmap::BMP_TRANSLUCENT);
- loader->LoadTexture("flare2.pcx", flare2, Bitmap::BMP_TRANSLUCENT);
- loader->LoadTexture("flare3.pcx", flare3, Bitmap::BMP_TRANSLUCENT);
- loader->LoadTexture("flare4.pcx", flare4, Bitmap::BMP_TRANSLUCENT);
- loader->SetDataPath(oldpath);
-}
-
-CmpSceneDlg::~CmpSceneDlg()
-{
-}
-
-void
-CmpSceneDlg::RegisterControls()
-{
- mov_scene = FindControl(101);
- subtitles_box = (RichTextBox*) FindControl(102);
-
- if (mov_scene) {
- CameraDirector* cam_dir = CameraDirector::GetInstance();
- cam_view = new(__FILE__,__LINE__) CameraView(mov_scene, cam_dir->GetCamera(), 0);
- if (cam_view)
- mov_scene->AddView(cam_view);
-
- disp_view = DisplayView::GetInstance();
- }
-}
-
-void
-CmpSceneDlg::Show()
-{
- FormWindow::Show();
-
- Starshatter* stars = Starshatter::GetInstance();
-
- if (stars->InCutscene()) {
- Sim* sim = Sim::GetSim();
-
- if (sim) {
- cam_view->UseCamera(CameraDirector::GetInstance()->GetCamera());
- cam_view->UseScene(sim->GetScene());
- }
-
- // initialize lens flare bitmaps:
- if (stars->LensFlare()) {
- cam_view->LensFlareElements(flare1, flare4, flare2, flare3);
- cam_view->LensFlare(true);
- }
-
- // if lens flare disabled, just create the corona:
- else if (stars->Corona()) {
- cam_view->LensFlareElements(flare1, 0, 0, 0);
- cam_view->LensFlare(true);
- }
-
- if (disp_view) {
- old_disp_win = disp_view->GetWindow();
-
- disp_view->SetWindow(mov_scene);
- mov_scene->AddView(disp_view);
- }
-
- if (subtitles_box) {
- subtitles_box->SetText(stars->GetSubtitles());
- subtitles_delay = 0;
- subtitles_time = 0;
- }
- }
-}
-
-void
-CmpSceneDlg::Hide()
-{
- FormWindow::Hide();
-
- if (disp_view && mov_scene && old_disp_win) {
- mov_scene->DelView(disp_view);
- disp_view->SetWindow(old_disp_win);
- }
-}
-
-// +--------------------------------------------------------------------+
-
-CameraView*
-CmpSceneDlg::GetCameraView()
-{
- return cam_view;
-}
-
-DisplayView*
-CmpSceneDlg::GetDisplayView()
-{
- return disp_view;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-CmpSceneDlg::ExecFrame()
-{
- Starshatter* stars = Starshatter::GetInstance();
- Mission* cutscene_mission = stars->GetCutsceneMission();
-
- if (cutscene_mission && disp_view) {
- disp_view->ExecFrame();
-
- if (subtitles_box && subtitles_box->GetLineCount() > 0) {
- if (subtitles_delay == 0) {
- int nlines = subtitles_box->GetLineCount();
-
- MissionEvent* begin_scene = cutscene_mission->FindEvent(MissionEvent::BEGIN_SCENE);
- MissionEvent* end_scene = cutscene_mission->FindEvent(MissionEvent::END_SCENE);
-
- if (begin_scene && end_scene) {
- double total_time = end_scene->Time() - begin_scene->Time();
- subtitles_delay = total_time / nlines;
- subtitles_time = Game::RealTime() / 1000.0 + subtitles_delay;
- }
- else {
- subtitles_delay = -1;
- }
- }
-
- if (subtitles_delay > 0) {
- double seconds = Game::RealTime() / 1000.0;
-
- if (subtitles_time <= seconds) {
- subtitles_time = seconds + subtitles_delay;
- subtitles_box->Scroll(ScrollWindow::SCROLL_DOWN);
- }
- }
- }
- }
- else {
- manager->ShowCmdDlg();
- }
-}
-
+/* Starshatter OpenSource Distribution + Copyright (c) 1997-2004, Destroyer Studios LLC. + All Rights Reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name "Destroyer Studios" nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + SUBSYSTEM: Stars.exe + FILE: CmpSceneDlg.cpp + AUTHOR: John DiCamillo + + + OVERVIEW + ======== +*/ + +#include "MemDebug.h" +#include "CmpSceneDlg.h" +#include "CmpnScreen.h" +#include "GameScreen.h" +#include "Campaign.h" +#include "CombatEvent.h" +#include "Starshatter.h" +#include "Sim.h" +#include "CameraDirector.h" +#include "Mission.h" +#include "MissionEvent.h" + +#include "Game.h" +#include "DataLoader.h" +#include "Video.h" +#include "Keyboard.h" +#include "Mouse.h" +#include "ImageBox.h" +#include "RichTextBox.h" +#include "Button.h" +#include "FormatUtil.h" + +// +--------------------------------------------------------------------+ +// DECLARE MAPPING FUNCTIONS: + +// +--------------------------------------------------------------------+ + +CmpSceneDlg::CmpSceneDlg(Screen* s, FormDef& def, CmpnScreen* mgr) +: FormWindow(s, 0, 0, s->Width(), s->Height()), manager(mgr), +mov_scene(0), subtitles_box(0), cam_view(0), disp_view(0), old_disp_win(0), +flare1(0), flare2(0), flare3(0), flare4(0), subtitles_delay(0), subtitles_time(0) +{ + Init(def); + + DataLoader* loader = DataLoader::GetLoader(); + const char* oldpath = loader->GetDataPath(); + + loader->SetDataPath(0); + loader->LoadTexture("flare0+.pcx", flare1, Bitmap::BMP_TRANSLUCENT); + loader->LoadTexture("flare2.pcx", flare2, Bitmap::BMP_TRANSLUCENT); + loader->LoadTexture("flare3.pcx", flare3, Bitmap::BMP_TRANSLUCENT); + loader->LoadTexture("flare4.pcx", flare4, Bitmap::BMP_TRANSLUCENT); + loader->SetDataPath(oldpath); +} + +CmpSceneDlg::~CmpSceneDlg() +{ +} + +void +CmpSceneDlg::RegisterControls() +{ + mov_scene = FindControl(101); + subtitles_box = (RichTextBox*) FindControl(102); + + if (mov_scene) { + CameraDirector* cam_dir = CameraDirector::GetInstance(); + cam_view = new(__FILE__,__LINE__) CameraView(mov_scene, cam_dir->GetCamera(), 0); + if (cam_view) + mov_scene->AddView(cam_view); + + disp_view = DisplayView::GetInstance(); + } +} + +void +CmpSceneDlg::Show() +{ + FormWindow::Show(); + + Starshatter* stars = Starshatter::GetInstance(); + + if (stars->InCutscene()) { + Sim* sim = Sim::GetSim(); + + if (sim) { + cam_view->UseCamera(CameraDirector::GetInstance()->GetCamera()); + cam_view->UseScene(sim->GetScene()); + } + + // initialize lens flare bitmaps: + if (stars->LensFlare()) { + cam_view->LensFlareElements(flare1, flare4, flare2, flare3); + cam_view->LensFlare(true); + } + + // if lens flare disabled, just create the corona: + else if (stars->Corona()) { + cam_view->LensFlareElements(flare1, 0, 0, 0); + cam_view->LensFlare(true); + } + + if (disp_view) { + old_disp_win = disp_view->GetWindow(); + + disp_view->SetWindow(mov_scene); + mov_scene->AddView(disp_view); + } + + if (subtitles_box) { + subtitles_box->SetText(stars->GetSubtitles()); + subtitles_delay = 0; + subtitles_time = 0; + } + } +} + +void +CmpSceneDlg::Hide() +{ + FormWindow::Hide(); + + if (disp_view && mov_scene && old_disp_win) { + mov_scene->DelView(disp_view); + disp_view->SetWindow(old_disp_win); + } +} + +// +--------------------------------------------------------------------+ + +CameraView* +CmpSceneDlg::GetCameraView() +{ + return cam_view; +} + +DisplayView* +CmpSceneDlg::GetDisplayView() +{ + return disp_view; +} + +// +--------------------------------------------------------------------+ + +void +CmpSceneDlg::ExecFrame() +{ + Starshatter* stars = Starshatter::GetInstance(); + Mission* cutscene_mission = stars->GetCutsceneMission(); + + if (cutscene_mission && disp_view) { + disp_view->ExecFrame(); + + if (subtitles_box && subtitles_box->GetLineCount() > 0) { + if (subtitles_delay == 0) { + int nlines = subtitles_box->GetLineCount(); + + MissionEvent* begin_scene = cutscene_mission->FindEvent(MissionEvent::BEGIN_SCENE); + MissionEvent* end_scene = cutscene_mission->FindEvent(MissionEvent::END_SCENE); + + if (begin_scene && end_scene) { + double total_time = end_scene->Time() - begin_scene->Time(); + subtitles_delay = total_time / nlines; + subtitles_time = Game::RealTime() / 1000.0 + subtitles_delay; + } + else { + subtitles_delay = -1; + } + } + + if (subtitles_delay > 0) { + double seconds = Game::RealTime() / 1000.0; + + if (subtitles_time <= seconds) { + subtitles_time = seconds + subtitles_delay; + subtitles_box->Scroll(ScrollWindow::SCROLL_DOWN); + } + } + } + } + else { + manager->ShowCmdDlg(); + } +} + |