summaryrefslogtreecommitdiffhomepage
path: root/StarsEx/CmpSceneDlg.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-01 21:23:39 +0200
committerAki <please@ignore.pl>2022-04-01 21:23:39 +0200
commit3c487c5cd69c53d6fea948643c0a76df03516605 (patch)
tree72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /StarsEx/CmpSceneDlg.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'StarsEx/CmpSceneDlg.cpp')
-rw-r--r--StarsEx/CmpSceneDlg.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/StarsEx/CmpSceneDlg.cpp b/StarsEx/CmpSceneDlg.cpp
new file mode 100644
index 0000000..4cedc21
--- /dev/null
+++ b/StarsEx/CmpSceneDlg.cpp
@@ -0,0 +1,186 @@
+/* Starshatter: The Open Source Project
+ Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
+ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
+ Copyright (c) 1997-2006, Destroyer Studios LLC.
+
+ AUTHOR: John DiCamillo
+
+
+ OVERVIEW
+ ========
+*/
+
+#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 "Clock.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 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 = Clock::GetInstance()->RealTime() / 1000.0 + subtitles_delay;
+ }
+ else {
+ subtitles_delay = -1;
+ }
+ }
+
+ if (subtitles_delay > 0) {
+ double seconds = Clock::GetInstance()->RealTime() / 1000.0;
+
+ if (subtitles_time <= seconds) {
+ subtitles_time = seconds + subtitles_delay;
+ subtitles_box->Scroll(ScrollWindow::SCROLL_DOWN);
+ }
+ }
+ }
+ }
+ else {
+ manager->ShowCmdDlg();
+ }
+}
+