aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-05-29 00:14:29 +0200
committerThierry Crozat2019-07-28 15:09:14 +0100
commit4b12c8d17b3df2780c255b957f7035ccb1274071 (patch)
tree27781d23def6bd0f3d02692c73718a97e4ed621b
parent9b786ded4fbf3bcd2981c65dc30a1a278dd97de2 (diff)
downloadscummvm-rg350-4b12c8d17b3df2780c255b957f7035ccb1274071.tar.gz
scummvm-rg350-4b12c8d17b3df2780c255b957f7035ccb1274071.tar.bz2
scummvm-rg350-4b12c8d17b3df2780c255b957f7035ccb1274071.zip
SUPERNOVA2: Begin intro animation
Copy and modify all the code needed for animation from supernova engine and display Mission Supernova logo.
-rw-r--r--engines/supernova2/graphics.cpp1
-rw-r--r--engines/supernova2/ms2_def.h133
-rw-r--r--engines/supernova2/resman.cpp8
-rw-r--r--engines/supernova2/resman.h2
-rw-r--r--engines/supernova2/rooms.cpp49
-rw-r--r--engines/supernova2/rooms.h20
-rw-r--r--engines/supernova2/screen.cpp18
-rw-r--r--engines/supernova2/state.cpp139
-rw-r--r--engines/supernova2/state.h13
-rw-r--r--engines/supernova2/supernova2.cpp241
-rw-r--r--engines/supernova2/supernova2.h31
11 files changed, 618 insertions, 37 deletions
diff --git a/engines/supernova2/graphics.cpp b/engines/supernova2/graphics.cpp
index 3ea310a936..6f6ee00a33 100644
--- a/engines/supernova2/graphics.cpp
+++ b/engines/supernova2/graphics.cpp
@@ -74,6 +74,7 @@ bool MS2Image::init(int filenumber) {
}
_filenumber = filenumber;
+
loadStream(file);
return true;
diff --git a/engines/supernova2/ms2_def.h b/engines/supernova2/ms2_def.h
index ac0e3880e2..bbb2b7c55d 100644
--- a/engines/supernova2/ms2_def.h
+++ b/engines/supernova2/ms2_def.h
@@ -32,7 +32,7 @@ const int kMsecPerTick = 55;
const int kMaxSection = 40;
const int kMaxDialog = 2;
-const int kMaxObject = 25;
+const int kMaxObject = 30;
const int kMaxCarry = 30;
const int kSleepAutosaveSlot = 999;
@@ -86,7 +86,7 @@ enum RoomId {
PYRAMID,PYRGANG,UPSTAIRS1,DOWNSTAIRS1,
BOTTOM_RIGHT_DOOR,BOTTOM_LEFT_DOOR,UPSTAIRS2,DOWNSTAIRS2,
UPPER_DOOR,PUZZLE_FRONT,PUZZLE_BEHIND,
- FORMULA1_F,FORMULA1_N,FORMULA2_F,FORMULA2_N,TOMATO,TOMATO,
+ FORMULA1_F,FORMULA1_N,FORMULA2_F,FORMULA2_N,TOMATO_F,TOMATO_N,
MONSTER_F,MONSTER1_N,MONSTER2_N,UPSTAIRS3,DOWNSTAIRS3,
LGANG1,LGANG2,HOLE_ROOM,IN_HOLE,BODENTUER,BODENTUER_U,
BST_DOOR,HALL,COFFIN_ROOM,MASK,
@@ -94,11 +94,12 @@ enum RoomId {
MUSEUM,MUS_EING,MUS1,MUS2,MUS3,MUS4,MUS5,MUS6,MUS7,MUS8,
MUS9,MUS10,MUS11,MUS_RUND,
MUS12,MUS13,MUS14,MUS15,MUS16,MUS17,MUS18,MUS19,MUS20,MUS21,MUS22,
- NULLROOM
+ NUMROOMS,NULLROOM
};
enum ObjectId {
INVALIDOBJECT = -1,
+ NULLOBJECT = 0,
TAXI=1,WALLET,TRANSMITTER,KNIFE,POLE,BES_CABIN,MONEY,
SLOT1,CHAIR,GANG,G_RIGHT,G_LEFT,PYRA_ENTRANCE,DOOR,BUTTON,
PART0,PART1,PART2,PART3,PART4,PART5,PART6,PART7,
@@ -121,11 +122,133 @@ enum ObjectId {
ENCRYPTED_DOOR,ALARM_ANLAGE,MUS_STREET,BIG_DOOR,INVESTMENT,
HANDLE,COUNTER,DOOR_SWITCH,SUIT,MANAGEMENT,RMANAGEMENT,
MUSCARD,SKOPF
- NULLOBJECT = 0
};
enum StringId {
- kNoString = -1, kStringDefaultDescription
+ kNoString = -1,
+kString0, kString1, kString2, kString3, kString4,
+kString5, kString6, kString7, kString8, kString9,
+kString10, kString11, kString12, kString13, kString14,
+kString15, kString16, kString17, kString18, kString19,
+kString20, kString21, kString22, kString23, kString24,
+kString25, kString26, kString27, kStringTextSpeed, kString29,
+kString30, kString31, kString32, kString33, kString34,
+kString35, kString36, kString37, kString38, kString39,
+kString40, kString41, kString42, kString43, kString44,
+kString45, kString46, kString47, kString48, kString49,
+kString50, kString51, kString52, kString53, kString54,
+kString55, kString56, kString57, kString58, kString59,
+kString60, kString61, kString62, kString63, kString64,
+kString65, kString66, kString67, kString68, kString69,
+kString70, kString71, kString72, kString73, kString74,
+kString75, kString76, kString77, kString78, kString79,
+kString80, kString81, kString82, kString83, kString84,
+kString85, kString86, kString87, kString88, kString89,
+kString90, kString91, kString92, kString93, kString94,
+kString95, kString96, kString97, kString98, kString99,
+kString100, kString101, kString102, kString103, kString104,
+kString105, kString106, kString107, kString108, kString109,
+kString110, kString111, kString112, kString113, kString114,
+kString115, kString116, kString117, kString118, kString119,
+kString120, kString121, kString122, kString123, kString124,
+kString125, kString126, kString127, kString128, kString129,
+kString130, kString131, kString132, kString133, kString134,
+kString135, kString136, kString137, kString138, kString139,
+kString140, kString141, kString142, kString143, kString144,
+kString145, kString146, kString147, kString148, kString149,
+kString150, kString151, kString152, kString153, kString154,
+kString155, kString156, kString157, kString158, kString159,
+kString160, kString161, kString162, kString163, kString164,
+kString165, kString166, kString167, kString168, kString169,
+kString170, kString171, kString172, kString173, kString174,
+kString175, kString176, kString177, kStringDefaultDescription, kString179,
+kString180, kString181, kString182, kString183, kString184,
+kString185, kString186, kString187, kString188, kString189,
+kString190, kString191, kString192, kString193, kString194,
+kString195, kString196, kString197, kString198, kString199,
+kString200, kString201, kString202, kString203, kString204,
+kString205, kString206, kString207, kString208, kString209,
+kString210, kString211, kString212, kString213, kString214,
+kString215, kString216, kString217, kString218, kString219,
+kString220, kString221, kString222, kString223, kString224,
+kString225, kString226, kString227, kString228, kString229,
+kString230, kString231, kString232, kString233, kString234,
+kString235, kString236, kString237, kString238, kString239,
+kString240, kString241, kString242, kString243, kString244,
+kString245, kString246, kString247, kString248, kString249,
+kString250, kString251, kString252, kString253, kString254,
+kString255, kString256, kString257, kString258, kString259,
+kString260, kString261, kString262, kString263, kString264,
+kString265, kString266, kString267, kString268, kString269,
+kString270, kString271, kString272, kString273, kString274,
+kString275, kString276, kString277, kString278, kString279,
+kString280, kString281, kString282, kString283, kString284,
+kString285, kString286, kString287, kString288, kString289,
+kString290, kString291, kString292, kString293, kString294,
+kString295, kString296, kString297, kString298, kString299,
+kString300, kString301, kString302, kString303, kString304,
+kString305, kString306, kString307, kString308, kString309,
+kString310, kString311, kString312, kString313, kString314,
+kString315, kString316, kString317, kString318, kString319,
+kString320, kString321, kString322, kString323, kString324,
+kString325, kString326, kString327, kString328, kString329,
+kString330, kString331, kString332, kString333, kString334,
+kString335, kString336, kString337, kString338, kString339,
+kString340, kString341, kString342, kString343, kString344,
+kString345, kString346, kString347, kString348, kString349,
+kString350, kString351, kString352, kString353, kString354,
+kString355, kString356, kString357, kString358, kString359,
+kString360, kString361, kString362, kString363, kString364,
+kString365, kString366, kString367, kString368, kString369,
+kString370, kString371, kString372, kString373, kString374,
+kString375, kString376, kString377, kString378, kString379,
+kString380, kString381, kString382, kString383, kString384,
+kString385, kString386, kString387, kString388, kString389,
+kString390, kString391, kString392, kString393, kString394,
+kString395, kString396, kString397, kString398, kString399,
+kString400, kString401, kString402, kString403, kString404,
+kString405, kString406, kString407, kString408, kString409,
+kString410, kString411, kString412, kString413, kString414,
+kString415, kString416, kString417, kString418, kString419,
+kString420, kString421, kString422, kString423, kString424,
+kString425, kString426, kString427, kString428, kString429,
+kString430, kString431, kString432, kString433, kString434,
+kString435, kString436, kString437, kString438, kString439,
+kString440, kString441, kString442, kString443, kString444,
+kString445, kString446, kString447, kString448, kString449,
+kString450, kString451, kString452, kString453, kString454,
+kString455, kString456, kString457, kString458, kString459,
+kString460, kString461, kString462, kString463, kString464,
+kString465, kString466, kString467, kString468, kString469,
+kString470, kString471, kString472, kString473, kString474,
+kString475, kString476, kString477, kString478, kString479,
+kString480, kString481, kString482, kString483, kString484,
+kString485, kString486, kString487, kString488, kString489,
+kString490, kString491, kString492, kString493, kString494,
+kString495, kString496, kString497, kString498, kString499,
+kString500, kString501, kString502, kString503, kString504,
+kString505, kString506, kString507, kString508, kString509,
+kString510, kString511, kString512, kString513, kString514,
+kString515, kString516, kString517, kString518, kString519,
+kString520, kString521, kString522, kString523, kString524,
+kString525, kString526, kString527, kString528, kString529,
+kString530, kString531, kString532, kString533, kString534,
+kString535, kString536, kString537, kString538, kString539,
+kString540, kString541, kString542, kString543, kString544,
+kString545, kString546, kString547, kString548, kString549,
+kString550, kString551, kString552, kString553, kString554,
+kString555, kString556, kString557, kString558, kString559,
+kString560, kString561, kString562, kString563, kString564,
+kString565, kString566, kString567, kString568, kString569,
+kString570, kString571, kString572, kString573, kString574,
+kString575, kString576, kString577, kString578, kString579,
+kString580, kString581, kString582, kString583, kString584,
+kString585, kString586, kString587, kString588, kString589,
+kString590, kString591, kString592, kString593, kString594,
+kString595, kString596, kString597, kString598, kString599,
+kString600, kString601, kString602, kString603, kString604,
+kString605, kString606, kString607, kString608, kString609,
+kString610, kString611, kString612, kString613
};
ObjectType operator|(ObjectType a, ObjectType b);
diff --git a/engines/supernova2/resman.cpp b/engines/supernova2/resman.cpp
index 259d279eec..a47a155b2f 100644
--- a/engines/supernova2/resman.cpp
+++ b/engines/supernova2/resman.cpp
@@ -164,12 +164,10 @@ void ResourceManager::initCursorGraphics() {
}
void ResourceManager::initImages() {
- for (int i = 0; i < 44; ++i) {
+ for (int i = 0; i < kNumImageFiles; ++i) {
if (!_images[i].init(i))
error("Failed reading image file ms2_data.%03d", i);
}
- if (!_images[44].init(55))
- error("Failed reading image file ms2_data.055");
}
//TODO
@@ -194,10 +192,8 @@ Audio::AudioStream *ResourceManager::getSoundStream(MusicId index) {
}*/
const MS2Image *ResourceManager::getImage(int filenumber) const {
- if (filenumber < 44)
+ if (filenumber < 47)
return &_images[filenumber];
- else if (filenumber == 55)
- return &_images[44];
else
return nullptr;
}
diff --git a/engines/supernova2/resman.h b/engines/supernova2/resman.h
index 84289d2b7f..72b7d78bfd 100644
--- a/engines/supernova2/resman.h
+++ b/engines/supernova2/resman.h
@@ -44,7 +44,7 @@ public:
};
public:
- static const int kNumImageFiles = 45;
+ static const int kNumImageFiles = 47;
public:
ResourceManager();
diff --git a/engines/supernova2/rooms.cpp b/engines/supernova2/rooms.cpp
index f7f76c0da2..77b4429d57 100644
--- a/engines/supernova2/rooms.cpp
+++ b/engines/supernova2/rooms.cpp
@@ -180,4 +180,53 @@ bool Room::interact(Action verb, Object &obj1, Object &obj2) {
return false;
}
+Intro::Intro(Supernova2Engine *vm, GameManager *gm) {
+ _vm = vm;
+ _gm = gm;
+
+ _fileNumber = -1;
+ _id = INTRO;
+}
+
+void Intro::onEntrance() {
+ _gm->_guiEnabled = false;
+ _vm->_allowSaveGame = false;
+ _vm->_allowLoadGame = false;
+ titleScreen();
+}
+
+void Intro::titleScreen() {
+ _vm->_system->fillScreen(kColorBlack);
+ _vm->_screen->setViewportBrightness(0);
+ _vm->_screen->setGuiBrightness(0);
+ _vm->paletteBrightness();
+ _vm->setCurrentImage(1);
+ _vm->renderImage(0);
+ _vm->paletteFadeIn();
+ _gm->getInput();
+}
+
+void Intro::titleFadeIn() {
+}
+
+bool Intro::animate(int section1, int section2, int duration) {
+ return true;
+}
+
+bool Intro::animate(int section1, int section2, int duration,
+ MessagePosition position, StringId textId) {
+ return true;
+}
+
+bool Intro::animate(int section1, int section2, int section3, int section4,
+ int duration, MessagePosition position, StringId textId) {
+ return true;
+}
+
+void Intro::cutscene() {
+}
+
+void Intro::leaveCutscene() {
+}
+
}
diff --git a/engines/supernova2/rooms.h b/engines/supernova2/rooms.h
index 26113d0425..2fcf636eea 100644
--- a/engines/supernova2/rooms.h
+++ b/engines/supernova2/rooms.h
@@ -74,6 +74,26 @@ private:
bool _seen;
};
+class Intro : public Room {
+public:
+ Intro(Supernova2Engine *vm, GameManager *gm);
+ virtual void onEntrance();
+
+private:
+ bool animate(int section1, int section2, int duration);
+ bool animate(int section1, int section2, int duration, MessagePosition position,
+ StringId text);
+ bool animate(int section1, int section2, int section3, int section4, int duration,
+ MessagePosition position, StringId text);
+
+ void titleScreen();
+ void titleFadeIn();
+ void cutscene();
+ void leaveCutscene();
+
+ bool _shouldExit;
+ Common::String _introText;
+};
}
#endif // SUPERNOVA2_ROOMS_H
diff --git a/engines/supernova2/screen.cpp b/engines/supernova2/screen.cpp
index 47c9535b0b..24efe91094 100644
--- a/engines/supernova2/screen.cpp
+++ b/engines/supernova2/screen.cpp
@@ -340,20 +340,10 @@ void Screen::renderImageSection(const MS2Image *image, int section, bool invert)
image->_section[section].y1,
image->_section[section].x2 + 1,
image->_section[section].y2 + 1);
- if (image->_filenumber == 1 || image->_filenumber == 2) {
- sectionRect.setWidth(640);
- sectionRect.setHeight(480);
- if (_screenWidth != 640) {
- _screenWidth = 640;
- _screenHeight = 480;
- initGraphics(_screenWidth, _screenHeight);
- }
- } else {
- if (_screenWidth != 320) {
- _screenWidth = 320;
- _screenHeight = 200;
- initGraphics(_screenWidth, _screenHeight);
- }
+ if (_screenWidth != 320) {
+ _screenWidth = 320;
+ _screenHeight = 200;
+ initGraphics(_screenWidth, _screenHeight);
}
uint offset = 0;
diff --git a/engines/supernova2/state.cpp b/engines/supernova2/state.cpp
index 4dd24a5e82..44553f2cd5 100644
--- a/engines/supernova2/state.cpp
+++ b/engines/supernova2/state.cpp
@@ -45,13 +45,16 @@ namespace Supernova2 {
GameManager::GameManager(Supernova2Engine *vm)
: _vm(vm)
, _mouseClickType(Common::EVENT_INVALID) {
- initState();
+ initRooms();
+ changeRoom(INTRO);
+ initState();
}
GameManager::~GameManager() {
}
void GameManager::initState() {
+ _processInput = false;
_guiEnabled = true;
_animationEnabled = true;
_mouseClicked = false;
@@ -74,5 +77,139 @@ void GameManager::initState() {
_prevImgId = 0;
}
+
+void GameManager::initRooms() {
+ _rooms[INTRO] = new Intro(_vm, this);
+}
+
+void GameManager::updateEvents() {
+ if (_animationEnabled && !_vm->_screen->isMessageShown() && _animationTimer == 0)
+ _currentRoom->animation();
+
+ _mouseClicked = false;
+ _keyPressed = false;
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ _keyPressed = true;
+ processInput(event.kbd);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ // fallthrough
+ case Common::EVENT_RBUTTONUP:
+ if (_currentRoom->getId() != INTRO)
+ return;
+ _mouseClicked = true;
+ // fallthrough
+ case Common::EVENT_MOUSEMOVE:
+ _mouseClickType = event.type;
+ _mouseX = event.mouse.x;
+ _mouseY = event.mouse.y;
+ if (_guiEnabled)
+ //processInput();
+ break;
+ default:
+ break;
+ }
+ }
+}
+void GameManager::processInput(Common::KeyState &state) {
+ _key = state;
+
+ switch (state.keycode) {
+ case Common::KEYCODE_F1:
+ // help
+ break;
+ case Common::KEYCODE_F2:
+ // show game doc
+ break;
+ case Common::KEYCODE_F3:
+ // show game info
+ break;
+ case Common::KEYCODE_F4:
+ //_vm->setTextSpeed();
+ break;
+ case Common::KEYCODE_F5:
+ // load/save
+ break;
+ case Common::KEYCODE_x:
+ if (state.flags & Common::KBD_ALT) {
+ //if (_vm->quitGameDialog())
+ _vm->quitGame();
+ }
+ break;
+ case Common::KEYCODE_d:
+ if (state.flags & Common::KBD_CTRL)
+ _vm->_console->attach();
+ break;
+ default:
+ break;
+ }
+}
+
+void GameManager::getInput() {
+ while (!_vm->shouldQuit()) {
+ updateEvents();
+ if (_mouseClicked || _keyPressed)
+ break;
+ g_system->updateScreen();
+ g_system->delayMillis(_vm->_delay);
+ }
+}
+
+void GameManager::changeRoom(RoomId id) {
+ _currentRoom = _rooms[id];
+ _newRoom = true;
+}
+
+void GameManager::resetInputState() {
+// setObjectNull(_inputObject[0]);
+// setObjectNull(_inputObject[1]);
+// _inputVerb = ACTION_WALK;
+ _processInput = false;
+ _mouseClicked = false;
+ _keyPressed = false;
+ _key.reset();
+ _mouseClickType = Common::EVENT_MOUSEMOVE;
+
+ //processInput();
+}
+
+void GameManager::executeRoom() {
+ if (_processInput && !_vm->_screen->isMessageShown() && _guiEnabled) {
+// handleInput();
+ if (_mouseClicked) {
+ Common::Event event;
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.mouse = Common::Point(0, 0);
+ _vm->getEventManager()->pushEvent(event);
+ event.type = Common::EVENT_MOUSEMOVE;
+ event.mouse = Common::Point(_mouseX, _mouseY);
+ _vm->getEventManager()->pushEvent(event);
+ }
+
+ resetInputState();
+ }
+
+ if (_guiEnabled) {
+ if (!_vm->_screen->isMessageShown()) {
+ g_system->fillScreen(kColorBlack);
+ _vm->renderRoom(*_currentRoom);
+ }
+// drawMapExits();
+// drawInventory();
+// drawStatus();
+// drawCommandBox();
+ }
+
+ //if (_vm->_screen->getViewportBrightness() == 0)
+ // _vm->paletteFadeIn();
+
+ if (!_currentRoom->hasSeen() && _newRoom) {
+ _newRoom = false;
+ _currentRoom->onEntrance();
+ }
+}
}
diff --git a/engines/supernova2/state.h b/engines/supernova2/state.h
index 7665d22807..c6d357fc43 100644
--- a/engines/supernova2/state.h
+++ b/engines/supernova2/state.h
@@ -41,6 +41,11 @@ public:
GameManager(Supernova2Engine *vm);
~GameManager();
+ void updateEvents();
+ void processInput(Common::KeyState &state);
+ //void processInput();
+ void executeRoom();
+
Supernova2Engine *_vm;
Common::KeyState _key;
Common::EventType _mouseClickType;
@@ -48,7 +53,11 @@ public:
bool _keyPressed;
int _mouseX;
int _mouseY;
+ Room *_currentRoom;
+ bool _newRoom;
+ Room *_rooms[NUMROOMS];
GameState _state;
+ bool _processInput;
bool _guiEnabled;
bool _animationEnabled;
uint _timePaused;
@@ -64,6 +73,10 @@ public:
byte _rowsStart[6];
void initState();
+ void initRooms();
+ void getInput();
+ void changeRoom(RoomId id);
+ void resetInputState();
private:
int _prevImgId;
diff --git a/engines/supernova2/supernova2.cpp b/engines/supernova2/supernova2.cpp
index 5a2acfbaf9..fd19ab6a4a 100644
--- a/engines/supernova2/supernova2.cpp
+++ b/engines/supernova2/supernova2.cpp
@@ -41,6 +41,8 @@
#include "graphics/thumbnail.h"
#include "gui/saveload.h"
+#include "supernova2/resman.h"
+#include "supernova2/screen.h"
#include "supernova2/supernova2.h"
#include "supernova2/state.h"
@@ -51,6 +53,8 @@ Supernova2Engine::Supernova2Engine(OSystem *syst)
: Engine(syst)
, _console(nullptr)
, _gm(nullptr)
+ , _resMan(nullptr)
+ , _screen(nullptr)
, _allowLoadGame(true)
, _allowSaveGame(true)
, _sleepAutoSave(nullptr)
@@ -68,6 +72,8 @@ Supernova2Engine::~Supernova2Engine() {
delete _console;
delete _gm;
+ delete _resMan;
+ delete _screen;
delete _sleepAutoSave;
}
@@ -76,6 +82,8 @@ Common::Error Supernova2Engine::run() {
while (!shouldQuit()) {
uint32 start = _system->getMillis();
+ _gm->updateEvents();
+ _gm->executeRoom();
_console->onFrame();
_system->updateScreen();
int end = _delay - (_system->getMillis() - start);
@@ -97,11 +105,26 @@ void Supernova2Engine::init() {
if (status.getCode() != Common::kNoError)
error("Failed reading game strings");
+ _resMan = new ResourceManager();
_gm = new GameManager(this);
+ _screen = new Screen(this, _resMan);
_console = new Console(this, _gm);
setTotalPlayTime(0);
}
+bool Supernova2Engine::hasFeature(EngineFeature f) const {
+ switch (f) {
+ case kSupportsRTL:
+ return true;
+ case kSupportsLoadingDuringRuntime:
+ return true;
+ case kSupportsSavingDuringRuntime:
+ return true;
+ default:
+ return false;
+ }
+}
+
Common::Error Supernova2Engine::loadGameStrings() {
Common::String cur_lang = ConfMan.get("language");
Common::String string_id("TEXT");
@@ -171,17 +194,215 @@ void Supernova2Engine::setGameString(int idx, const Common::String &string) {
_gameStrings[idx] = string;
}
-bool Supernova2Engine::hasFeature(EngineFeature f) const {
- switch (f) {
- case kSupportsRTL:
- return true;
- case kSupportsLoadingDuringRuntime:
- return true;
- case kSupportsSavingDuringRuntime:
- return true;
- default:
- return false;
+void Supernova2Engine::renderImage(int section) {
+ if (section > 128)
+ _gm->_currentRoom->setSectionVisible(section - 128, false);
+ else
+ _gm->_currentRoom->setSectionVisible(section, true);
+
+ _screen->renderImage(section);
+}
+
+void Supernova2Engine::renderImage(ImageId id, bool removeImage) {
+ _gm->_currentRoom->setSectionVisible(_screen->getImageInfo(id)->section, !removeImage);
+ _screen->renderImage(id, removeImage);
+}
+
+bool Supernova2Engine::setCurrentImage(int filenumber) {
+ return _screen->setCurrentImage(filenumber);
+}
+
+void Supernova2Engine::restoreScreen() {
+ _screen->restoreScreen();
+}
+
+void Supernova2Engine::renderRoom(Room &room) {
+ _screen->renderRoom(room);
+}
+
+void Supernova2Engine::renderMessage(const char *text, MessagePosition position) {
+ _gm->_messageDuration = (Common::strnlen(text, 512) + 20) * _textSpeed / 10;
+ _screen->renderMessage(text, position);
+}
+
+void Supernova2Engine::renderMessage(const Common::String &text, MessagePosition position) {
+ _gm->_messageDuration = (text.size() + 20) * _textSpeed / 10;
+ _screen->renderMessage(text, position);
+}
+
+void Supernova2Engine::renderMessage(StringId stringId, MessagePosition position, Common::String var1, Common::String var2) {
+ _gm->_messageDuration = (getGameString(stringId).size() + 20) * _textSpeed / 10;
+ _screen->renderMessage(stringId, position, var1, var2);
+}
+
+void Supernova2Engine::removeMessage() {
+ _screen->removeMessage();
+}
+
+void Supernova2Engine::renderText(const uint16 character) {
+ _screen->renderText(character);
+}
+
+void Supernova2Engine::renderText(const char *text) {
+ _screen->renderText(text);
+}
+
+void Supernova2Engine::renderText(const Common::String &text) {
+ _screen->renderText(text);
+}
+
+void Supernova2Engine::renderText(StringId stringId) {
+ _screen->renderText(stringId);
+}
+
+void Supernova2Engine::paletteBrightness() {
+ _screen->paletteBrightness();
+}
+
+void Supernova2Engine::paletteFadeOut() {
+ _screen->paletteFadeOut();
+}
+
+void Supernova2Engine::paletteFadeIn() {
+ _screen->paletteFadeIn(255);
+}
+
+void Supernova2Engine::setColor63(byte value) {
+ _screen->setColor63(value);
+}
+
+/*void Supernova2Engine::setTextSpeed() {
+ const Common::String &textSpeedString = getGameString(kStringTextSpeed);
+ int stringWidth = Screen::textWidth(textSpeedString);
+ int textX = (kScreenWidth - stringWidth) / 2;
+ int textY = 100;
+ stringWidth += 4;
+ int boxX = stringWidth > 110 ? (kScreenWidth - stringWidth) / 2 : 105;
+ int boxY = 97;
+ int boxWidth = stringWidth > 110 ? stringWidth : 110;
+ int boxHeight = 27;
+
+ _gm->animationOff();
+ _gm->saveTime();
+ saveScreen(boxX, boxY, boxWidth, boxHeight);
+
+ renderBox(boxX, boxY, boxWidth, boxHeight, kColorBlue);
+ renderText(textSpeedString, textX, textY, kColorWhite99); // Text speed
+
+ // Find the closest index in kTextSpeed for the current _textSpeed.
+ // Important note: values in kTextSpeed decrease with the index.
+ int speedIndex = 0;
+ while (speedIndex < 4 && _textSpeed < (kTextSpeed[speedIndex] + kTextSpeed[speedIndex+1]) / 2)
+ ++speedIndex;
+
+ char nbString[2];
+ nbString[1] = 0;
+ for (int i = 0; i < 5; ++i) {
+ byte color = i == speedIndex ? kColorWhite63 : kColorWhite35;
+ renderBox(110 + 21 * i, 111, 16, 10, color);
+
+ nbString[0] = '1' + i;
+ renderText(nbString, 115 + 21 * i, 112, kColorWhite99);
}
+ do {
+ _gm->getInput();
+ int key = _gm->_keyPressed ? _gm->_key.keycode : Common::KEYCODE_INVALID;
+ if (!_gm->_keyPressed && _gm->_mouseClicked && _gm->_mouseY >= 111 && _gm->_mouseY < 121 && (_gm->_mouseX + 16) % 21 < 16)
+ key = Common::KEYCODE_0 - 5 + (_gm->_mouseX + 16) / 21;
+ if (key == Common::KEYCODE_ESCAPE)
+ break;
+ else if (key >= Common::KEYCODE_1 && key <= Common::KEYCODE_5) {
+ speedIndex = key - Common::KEYCODE_1;
+ _textSpeed = kTextSpeed[speedIndex];
+ ConfMan.setInt("textspeed", _textSpeed);
+ break;
+ }
+ } while (!shouldQuit());
+ _gm->resetInputState();
+
+ restoreScreen();
+ _gm->loadTime();
+ _gm->animationOn();
+}*/
+
+/*bool Supernova2Engine::quitGameDialog() {
+ bool quit = false;
+
+ GuiElement guiQuitBox;
+ guiQuitBox.setColor(kColorRed, kColorWhite99, kColorRed, kColorWhite99);
+ guiQuitBox.setSize(112, 97, 112 + 96, 97 + 27);
+ guiQuitBox.setText(getGameString(kStringLeaveGame).c_str());
+ guiQuitBox.setTextPosition(guiQuitBox.left + 3, guiQuitBox.top + 3);
+ GuiElement guiQuitYes;
+ guiQuitYes.setColor(kColorWhite35, kColorWhite99, kColorWhite35, kColorWhite99);
+ guiQuitYes.setSize(115, 111, 158, 121);
+ guiQuitYes.setText(getGameString(kStringYes).c_str());
+ guiQuitYes.setTextPosition(132, 112);
+ GuiElement guiQuitNo;
+ guiQuitNo.setColor(kColorWhite35, kColorWhite99, kColorWhite35, kColorWhite99);
+ guiQuitNo.setSize(162, 111, 205, 121);
+ guiQuitNo.setText(getGameString(kStringNo).c_str());
+ guiQuitNo.setTextPosition(173, 112);
+
+ _gm->animationOff();
+ _gm->saveTime();
+ saveScreen(guiQuitBox);
+
+ renderBox(guiQuitBox);
+ renderText(guiQuitBox);
+ renderBox(guiQuitYes);
+ renderText(guiQuitYes);
+ renderBox(guiQuitNo);
+ renderText(guiQuitNo);
+
+ do {
+ _gm->getInput();
+ if (_gm->_keyPressed) {
+ if (_gm->_key.keycode == Common::KEYCODE_j) {
+ quit = true;
+ break;
+ } else if (_gm->_key.keycode == Common::KEYCODE_n) {
+ quit = false;
+ break;
+ }
+ }
+ if (_gm->_mouseClicked) {
+ if (guiQuitYes.contains(_gm->_mouseX, _gm->_mouseY)) {
+ quit = true;
+ break;
+ } else if (guiQuitNo.contains(_gm->_mouseX, _gm->_mouseY)) {
+ quit = false;
+ break;
+ }
+ }
+ } while (true);
+
+ _gm->resetInputState();
+ restoreScreen();
+ _gm->loadTime();
+ _gm->animationOn();
+
+ return quit;
+}*/
+
+void Supernova2Engine::renderText(const uint16 character, int x, int y, byte color) {
+ _screen->renderText(character, x, y, color);
+}
+
+void Supernova2Engine::renderText(const char *text, int x, int y, byte color) {
+ _screen->renderText(text, x, y, color);
+}
+
+void Supernova2Engine::renderText(const Common::String &text, int x, int y, byte color) {
+ _screen->renderText(text, x, y, color);
+}
+
+void Supernova2Engine::renderText(StringId stringId, int x, int y, byte color) {
+ _screen->renderText(stringId, x, y, color);
+}
+
+void Supernova2Engine::renderBox(int x, int y, int width, int height, byte color) {
+ _screen->renderBox(x, y, width, height, color);
}
}
diff --git a/engines/supernova2/supernova2.h b/engines/supernova2/supernova2.h
index 043c5cd4a5..e5798d921f 100644
--- a/engines/supernova2/supernova2.h
+++ b/engines/supernova2/supernova2.h
@@ -31,6 +31,10 @@
#include "common/file.h"
#include "supernova2/console.h"
+#include "supernova2/graphics.h"
+#include "supernova2/ms2_def.h"
+#include "supernova2/rooms.h"
+#include "supernova2/imageid.h"
namespace Common {
class MemoryReadWriteStream;
@@ -45,8 +49,10 @@ namespace Supernova2 {
#define SUPERNOVA2_DAT_VERSION 1
class GuiElement;
+class ResourceManager;
class console;
class GameManager;
+class Screen;
class Supernova2Engine : public Engine {
public:
@@ -58,6 +64,8 @@ public:
GameManager *_gm;
Console *_console;
+ ResourceManager *_resMan;
+ Screen *_screen;
bool _allowLoadGame;
bool _allowSaveGame;
Common::StringArray _gameStrings;
@@ -81,6 +89,29 @@ public:
void setGameString(int idx, const Common::String &string);
// forwarding calls
+ void paletteFadeIn();
+ void paletteFadeOut();
+ void paletteBrightness();
+ void renderImage(int section);
+ void renderImage(ImageId id, bool removeImage = false);
+ bool setCurrentImage(int filenumber);
+ void restoreScreen();
+ void renderRoom(Room &room);
+ void renderMessage(const char *text, MessagePosition position = kMessageNormal);
+ void renderMessage(const Common::String &text, MessagePosition position = kMessageNormal);
+ void renderMessage(StringId stringId, MessagePosition position = kMessageNormal,
+ Common::String var1 = "", Common::String var2 = "");
+ void removeMessage();
+ void renderText(const uint16 character);
+ void renderText(const char *text);
+ void renderText(const Common::String &text);
+ void renderText(StringId stringId);
+ void renderText(const uint16 character, int x, int y, byte color);
+ void renderText(const char *text, int x, int y, byte color);
+ void renderText(const Common::String &text, int x, int y, byte color);
+ void renderText(StringId stringId, int x, int y, byte color);
+ void renderBox(int x, int y, int width, int height, byte color);
+ void setColor63(byte value);
};
}