aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/menu
diff options
context:
space:
mode:
authorLittleboy2011-06-23 00:05:01 -0400
committerLittleboy2011-06-23 08:52:45 -0400
commit7a96e0bfb67e9b5b8c0aa9bdae8415fb98214c3f (patch)
tree88cac3039de1071a998cd209d524c4b39555a827 /engines/lastexpress/menu
parentf0cf72f4313c146dcec25fa004312a4319b89b91 (diff)
downloadscummvm-rg350-7a96e0bfb67e9b5b8c0aa9bdae8415fb98214c3f.tar.gz
scummvm-rg350-7a96e0bfb67e9b5b8c0aa9bdae8415fb98214c3f.tar.bz2
scummvm-rg350-7a96e0bfb67e9b5b8c0aa9bdae8415fb98214c3f.zip
LASTEXPRESS: Extract Clock and TrainLine classes to separate files
Diffstat (limited to 'engines/lastexpress/menu')
-rw-r--r--engines/lastexpress/menu/clock.cpp106
-rw-r--r--engines/lastexpress/menu/clock.h53
-rw-r--r--engines/lastexpress/menu/menu.cpp221
-rw-r--r--engines/lastexpress/menu/trainline.cpp142
-rw-r--r--engines/lastexpress/menu/trainline.h51
5 files changed, 355 insertions, 218 deletions
diff --git a/engines/lastexpress/menu/clock.cpp b/engines/lastexpress/menu/clock.cpp
new file mode 100644
index 0000000000..b0e6a260d4
--- /dev/null
+++ b/engines/lastexpress/menu/clock.cpp
@@ -0,0 +1,106 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "lastexpress/menu/clock.h"
+
+#include "lastexpress/data/sequence.h"
+
+#include "lastexpress/game/scenes.h"
+#include "lastexpress/game/state.h"
+
+#include "lastexpress/helpers.h"
+#include "lastexpress/lastexpress.h"
+#include "lastexpress/resource.h"
+
+namespace LastExpress {
+
+Clock::Clock(LastExpressEngine *engine) : _engine(engine), _frameMinutes(NULL), _frameHour(NULL), _frameSun(NULL), _frameDate(NULL) {
+ _frameMinutes = new SequenceFrame(loadSequence("eggmin.seq"), 0, true);
+ _frameHour = new SequenceFrame(loadSequence("egghour.seq"), 0, true);
+ _frameSun = new SequenceFrame(loadSequence("sun.seq"), 0, true);
+ _frameDate = new SequenceFrame(loadSequence("datenew.seq"), 0, true);
+}
+
+Clock::~Clock() {
+ SAFE_DELETE(_frameMinutes);
+ SAFE_DELETE(_frameHour);
+ SAFE_DELETE(_frameSun);
+ SAFE_DELETE(_frameDate);
+
+ // Zero passed pointers
+ _engine = NULL;
+}
+
+void Clock::clear() {
+ getScenes()->removeFromQueue(_frameMinutes);
+ getScenes()->removeFromQueue(_frameHour);
+ getScenes()->removeFromQueue(_frameSun);
+ getScenes()->removeFromQueue(_frameDate);
+}
+
+void Clock::draw(uint32 time) {
+ assert(time >= kTimeCityParis && time <= kTimeCityConstantinople);
+
+ // Check that sequences have been loaded
+ if (!_frameMinutes || !_frameHour || !_frameSun || !_frameDate)
+ error("Clock::process: clock sequences have not been loaded correctly!");
+
+ // Clear existing frames
+ clear();
+
+ // Game starts at: 1037700 = 7:13 p.m. on July 24, 1914
+ // Game ends at: 4941000 = 7:30 p.m. on July 26, 1914
+ // Game lasts for: 3903300 = 2 days + 17 mins = 2897 mins
+
+ // 15 = 1 second
+ // 15 * 60 = 900 = 1 minute
+ // 900 * 60 = 54000 = 1 hour
+ // 54000 * 24 = 1296000 = 1 day
+
+ // Calculate each sequence index from the current time
+
+ uint8 hour = 0;
+ uint8 minute = 0;
+ State::getHourMinutes(time, &hour, &minute);
+ uint32 index_date = 18 * time / 1296000;
+ if (hour == 23)
+ index_date += 18 * minute / 60;
+
+ // Set sequences frames
+ _frameMinutes->setFrame(minute);
+ _frameHour->setFrame((5 * hour + minute / 12) % 60);
+ _frameSun->setFrame((5 * hour + minute / 12) % 120);
+ _frameDate->setFrame((uint16)index_date);
+
+ // Adjust z-order and queue
+ _frameMinutes->getInfo()->location = 1;
+ _frameHour->getInfo()->location = 1;
+ _frameSun->getInfo()->location = 1;
+ _frameDate->getInfo()->location = 1;
+
+ getScenes()->addToQueue(_frameMinutes);
+ getScenes()->addToQueue(_frameHour);
+ getScenes()->addToQueue(_frameSun);
+ getScenes()->addToQueue(_frameDate);
+}
+
+} // End of namespace LastExpress
diff --git a/engines/lastexpress/menu/clock.h b/engines/lastexpress/menu/clock.h
new file mode 100644
index 0000000000..339a18604f
--- /dev/null
+++ b/engines/lastexpress/menu/clock.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef LASTEXPRESS_CLOCK_H
+#define LASTEXPRESS_CLOCK_H
+
+#include "common/scummsys.h"
+
+namespace LastExpress {
+
+class LastExpressEngine;
+class SequenceFrame;
+
+class Clock {
+public:
+ explicit Clock(LastExpressEngine *engine);
+ ~Clock();
+
+ void draw(uint32 time);
+ void clear();
+
+private:
+ LastExpressEngine *_engine;
+
+ // Frames
+ SequenceFrame *_frameMinutes;
+ SequenceFrame *_frameHour;
+ SequenceFrame *_frameSun;
+ SequenceFrame *_frameDate;
+};
+
+} // End of namespace LastExpress
+
+#endif // LASTEXPRESS_CLOCK_H
diff --git a/engines/lastexpress/menu/menu.cpp b/engines/lastexpress/menu/menu.cpp
index b7e6a1430a..e55a6d5960 100644
--- a/engines/lastexpress/menu/menu.cpp
+++ b/engines/lastexpress/menu/menu.cpp
@@ -38,6 +38,9 @@
#include "lastexpress/game/sound.h"
#include "lastexpress/game/state.h"
+#include "lastexpress/menu/clock.h"
+#include "lastexpress/menu/trainline.h"
+
#include "lastexpress/graphics.h"
#include "lastexpress/helpers.h"
#include "lastexpress/lastexpress.h"
@@ -119,45 +122,6 @@ enum StartMenuTooltips {
//////////////////////////////////////////////////////////////////////////
// DATA
//////////////////////////////////////////////////////////////////////////
-
-// Information about the cities on the train line
-static const struct {
- uint8 frame;
- TimeValue time;
-} _trainCities[31] = {
- {0, kTimeCityParis},
- {9, kTimeCityEpernay},
- {11, kTimeCityChalons},
- {16, kTimeCityBarLeDuc},
- {21, kTimeCityNancy},
- {25, kTimeCityLuneville},
- {35, kTimeCityAvricourt},
- {37, kTimeCityDeutschAvricourt},
- {40, kTimeCityStrasbourg},
- {53, kTimeCityBadenOos},
- {56, kTimeCityKarlsruhe},
- {60, kTimeCityStuttgart},
- {63, kTimeCityGeislingen},
- {66, kTimeCityUlm},
- {68, kTimeCityAugsburg},
- {73, kTimeCityMunich},
- {84, kTimeCitySalzbourg},
- {89, kTimeCityAttnangPuchheim},
- {97, kTimeCityWels},
- {100, kTimeCityLinz},
- {104, kTimeCityAmstetten},
- {111, kTimeCityVienna},
- {120, kTimeCityPoszony},
- {124, kTimeCityGalanta},
- {132, kTimeCityBudapest},
- {148, kTimeCityBelgrade},
- /* Line 1 ends at 150 - line 2 begins at 0 */
- {157, kTimeCityNish},
- {165, kTimeCityTzaribrod},
- {174, kTimeCitySofia},
- {198, kTimeCityAdrianople},
- {210, kTimeCityConstantinople}};
-
static const struct {
TimeValue time;
uint index;
@@ -174,185 +138,6 @@ static const struct {
};
//////////////////////////////////////////////////////////////////////////
-// Clock
-//////////////////////////////////////////////////////////////////////////
-class Clock {
-public:
- explicit Clock(LastExpressEngine *engine);
- ~Clock();
-
- void draw(uint32 time);
- void clear();
-
-private:
- LastExpressEngine *_engine;
-
- // Frames
- SequenceFrame *_frameMinutes;
- SequenceFrame *_frameHour;
- SequenceFrame *_frameSun;
- SequenceFrame *_frameDate;
-};
-
-Clock::Clock(LastExpressEngine *engine) : _engine(engine), _frameMinutes(NULL), _frameHour(NULL), _frameSun(NULL), _frameDate(NULL) {
- _frameMinutes = new SequenceFrame(loadSequence("eggmin.seq"), 0, true);
- _frameHour = new SequenceFrame(loadSequence("egghour.seq"), 0, true);
- _frameSun = new SequenceFrame(loadSequence("sun.seq"), 0, true);
- _frameDate = new SequenceFrame(loadSequence("datenew.seq"), 0, true);
-}
-
-Clock::~Clock() {
- SAFE_DELETE(_frameMinutes);
- SAFE_DELETE(_frameHour);
- SAFE_DELETE(_frameSun);
- SAFE_DELETE(_frameDate);
-
- // Zero passed pointers
- _engine = NULL;
-}
-
-void Clock::clear() {
- getScenes()->removeFromQueue(_frameMinutes);
- getScenes()->removeFromQueue(_frameHour);
- getScenes()->removeFromQueue(_frameSun);
- getScenes()->removeFromQueue(_frameDate);
-}
-
-void Clock::draw(uint32 time) {
- assert(time >= kTimeCityParis && time <= kTimeCityConstantinople);
-
- // Check that sequences have been loaded
- if (!_frameMinutes || !_frameHour || !_frameSun || !_frameDate)
- error("Clock::process: clock sequences have not been loaded correctly!");
-
- // Clear existing frames
- clear();
-
- // Game starts at: 1037700 = 7:13 p.m. on July 24, 1914
- // Game ends at: 4941000 = 7:30 p.m. on July 26, 1914
- // Game lasts for: 3903300 = 2 days + 17 mins = 2897 mins
-
- // 15 = 1 second
- // 15 * 60 = 900 = 1 minute
- // 900 * 60 = 54000 = 1 hour
- // 54000 * 24 = 1296000 = 1 day
-
- // Calculate each sequence index from the current time
-
- uint8 hour = 0;
- uint8 minute = 0;
- State::getHourMinutes(time, &hour, &minute);
- uint32 index_date = 18 * time / 1296000;
- if (hour == 23)
- index_date += 18 * minute / 60;
-
- // Set sequences frames
- _frameMinutes->setFrame(minute);
- _frameHour->setFrame((5 * hour + minute / 12) % 60);
- _frameSun->setFrame((5 * hour + minute / 12) % 120);
- _frameDate->setFrame((uint16)index_date);
-
- // Adjust z-order and queue
- _frameMinutes->getInfo()->location = 1;
- _frameHour->getInfo()->location = 1;
- _frameSun->getInfo()->location = 1;
- _frameDate->getInfo()->location = 1;
-
- getScenes()->addToQueue(_frameMinutes);
- getScenes()->addToQueue(_frameHour);
- getScenes()->addToQueue(_frameSun);
- getScenes()->addToQueue(_frameDate);
-}
-
-//////////////////////////////////////////////////////////////////////////
-// TrainLine
-//////////////////////////////////////////////////////////////////////////
-class TrainLine {
-public:
- explicit TrainLine(LastExpressEngine *engine);
- ~TrainLine();
-
- void draw(uint32 time);
- void clear();
-
-private:
- LastExpressEngine *_engine;
-
- // Frames
- SequenceFrame *_frameLine1;
- SequenceFrame *_frameLine2;
-};
-
-TrainLine::TrainLine(LastExpressEngine *engine) : _engine(engine), _frameLine1(NULL), _frameLine2(NULL) {
- _frameLine1 = new SequenceFrame(loadSequence("line1.seq"), 0, true);
- _frameLine2 = new SequenceFrame(loadSequence("line2.seq"), 0, true);
-}
-
-TrainLine::~TrainLine() {
- SAFE_DELETE(_frameLine1);
- SAFE_DELETE(_frameLine2);
-
- // Zero passed pointers
- _engine = NULL;
-}
-
-void TrainLine::clear() {
- getScenes()->removeFromQueue(_frameLine1);
- getScenes()->removeFromQueue(_frameLine2);
-}
-
-// Draw the train line at the time
-// line1: 150 frames (=> Belgrade)
-// line2: 61 frames (=> Constantinople)
-void TrainLine::draw(uint32 time) {
- assert(time >= kTimeCityParis && time <= kTimeCityConstantinople);
-
- // Check that sequences have been loaded
- if (!_frameLine1 || !_frameLine2)
- error("TrainLine::process: Line sequences have not been loaded correctly!");
-
- // Clear existing frames
- clear();
-
- // Get the index of the last city the train has visited
- uint index = 0;
- for (uint i = 0; i < ARRAYSIZE(_trainCities); i++)
- if ((uint32)_trainCities[i].time <= time)
- index = i;
-
- uint16 frame;
- if (time > (uint32)_trainCities[index].time) {
- // Interpolate linearly to use a frame between the cities
- uint8 diffFrames = _trainCities[index + 1].frame - _trainCities[index].frame;
- uint diffTimeCities = (uint)(_trainCities[index + 1].time - _trainCities[index].time);
- uint traveledTime = (time - (uint)_trainCities[index].time);
- frame = (uint16)(_trainCities[index].frame + (traveledTime * diffFrames) / diffTimeCities);
- } else {
- // Exactly on the city
- frame = _trainCities[index].frame;
- }
-
- // Set frame, z-order and queue
- if (frame < 150) {
- _frameLine1->setFrame(frame);
-
- _frameLine1->getInfo()->location = 1;
- getScenes()->addToQueue(_frameLine1);
- } else {
- // We passed Belgrade
- _frameLine1->setFrame(149);
- _frameLine2->setFrame(frame - 150);
-
- _frameLine1->getInfo()->location = 1;
- _frameLine2->getInfo()->location = 1;
-
- getScenes()->addToQueue(_frameLine1);
- getScenes()->addToQueue(_frameLine2);
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
// Menu
//////////////////////////////////////////////////////////////////////////
Menu::Menu(LastExpressEngine *engine) : _engine(engine),
diff --git a/engines/lastexpress/menu/trainline.cpp b/engines/lastexpress/menu/trainline.cpp
new file mode 100644
index 0000000000..df08abf37b
--- /dev/null
+++ b/engines/lastexpress/menu/trainline.cpp
@@ -0,0 +1,142 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "lastexpress/menu/trainline.h"
+
+#include "lastexpress/data/sequence.h"
+
+#include "lastexpress/game/scenes.h"
+
+#include "lastexpress/helpers.h"
+#include "lastexpress/lastexpress.h"
+#include "lastexpress/resource.h"
+
+namespace LastExpress {
+
+// Information about the cities on the train line
+static const struct {
+ uint8 frame;
+ TimeValue time;
+} _trainCities[31] = {
+ {0, kTimeCityParis},
+ {9, kTimeCityEpernay},
+ {11, kTimeCityChalons},
+ {16, kTimeCityBarLeDuc},
+ {21, kTimeCityNancy},
+ {25, kTimeCityLuneville},
+ {35, kTimeCityAvricourt},
+ {37, kTimeCityDeutschAvricourt},
+ {40, kTimeCityStrasbourg},
+ {53, kTimeCityBadenOos},
+ {56, kTimeCityKarlsruhe},
+ {60, kTimeCityStuttgart},
+ {63, kTimeCityGeislingen},
+ {66, kTimeCityUlm},
+ {68, kTimeCityAugsburg},
+ {73, kTimeCityMunich},
+ {84, kTimeCitySalzbourg},
+ {89, kTimeCityAttnangPuchheim},
+ {97, kTimeCityWels},
+ {100, kTimeCityLinz},
+ {104, kTimeCityAmstetten},
+ {111, kTimeCityVienna},
+ {120, kTimeCityPoszony},
+ {124, kTimeCityGalanta},
+ {132, kTimeCityBudapest},
+ {148, kTimeCityBelgrade},
+ /* Line 1 ends at 150 - line 2 begins at 0 */
+ {157, kTimeCityNish},
+ {165, kTimeCityTzaribrod},
+ {174, kTimeCitySofia},
+ {198, kTimeCityAdrianople},
+ {210, kTimeCityConstantinople}
+};
+
+TrainLine::TrainLine(LastExpressEngine *engine) : _engine(engine), _frameLine1(NULL), _frameLine2(NULL) {
+ _frameLine1 = new SequenceFrame(loadSequence("line1.seq"), 0, true);
+ _frameLine2 = new SequenceFrame(loadSequence("line2.seq"), 0, true);
+}
+
+TrainLine::~TrainLine() {
+ SAFE_DELETE(_frameLine1);
+ SAFE_DELETE(_frameLine2);
+
+ // Zero passed pointers
+ _engine = NULL;
+}
+
+void TrainLine::clear() {
+ getScenes()->removeFromQueue(_frameLine1);
+ getScenes()->removeFromQueue(_frameLine2);
+}
+
+// Draw the train line at the time
+// line1: 150 frames (=> Belgrade)
+// line2: 61 frames (=> Constantinople)
+void TrainLine::draw(uint32 time) {
+ assert(time >= kTimeCityParis && time <= kTimeCityConstantinople);
+
+ // Check that sequences have been loaded
+ if (!_frameLine1 || !_frameLine2)
+ error("TrainLine::process: Line sequences have not been loaded correctly!");
+
+ // Clear existing frames
+ clear();
+
+ // Get the index of the last city the train has visited
+ uint index = 0;
+ for (uint i = 0; i < ARRAYSIZE(_trainCities); i++)
+ if ((uint32)_trainCities[i].time <= time)
+ index = i;
+
+ uint16 frame;
+ if (time > (uint32)_trainCities[index].time) {
+ // Interpolate linearly to use a frame between the cities
+ uint8 diffFrames = _trainCities[index + 1].frame - _trainCities[index].frame;
+ uint diffTimeCities = (uint)(_trainCities[index + 1].time - _trainCities[index].time);
+ uint traveledTime = (time - (uint)_trainCities[index].time);
+ frame = (uint16)(_trainCities[index].frame + (traveledTime * diffFrames) / diffTimeCities);
+ } else {
+ // Exactly on the city
+ frame = _trainCities[index].frame;
+ }
+
+ // Set frame, z-order and queue
+ if (frame < 150) {
+ _frameLine1->setFrame(frame);
+
+ _frameLine1->getInfo()->location = 1;
+ getScenes()->addToQueue(_frameLine1);
+ } else {
+ // We passed Belgrade
+ _frameLine1->setFrame(149);
+ _frameLine2->setFrame(frame - 150);
+
+ _frameLine1->getInfo()->location = 1;
+ _frameLine2->getInfo()->location = 1;
+
+ getScenes()->addToQueue(_frameLine1);
+ getScenes()->addToQueue(_frameLine2);
+ }
+}
+
+} // End of namespace LastExpress
diff --git a/engines/lastexpress/menu/trainline.h b/engines/lastexpress/menu/trainline.h
new file mode 100644
index 0000000000..af6a121e9c
--- /dev/null
+++ b/engines/lastexpress/menu/trainline.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef LASTEXPRESS_TRAINLINE_H
+#define LASTEXPRESS_TRAINLINE_H
+
+#include "common/scummsys.h"
+
+namespace LastExpress {
+
+class LastExpressEngine;
+class SequenceFrame;
+
+class TrainLine {
+public:
+ explicit TrainLine(LastExpressEngine *engine);
+ ~TrainLine();
+
+ void draw(uint32 time);
+ void clear();
+
+private:
+ LastExpressEngine *_engine;
+
+ // Frames
+ SequenceFrame *_frameLine1;
+ SequenceFrame *_frameLine2;
+};
+
+} // End of namespace LastExpress
+
+#endif // LASTEXPRESS_TRAINLINE_H