aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/xeen/dialogs.cpp60
-rw-r--r--engines/xeen/dialogs.h45
-rw-r--r--engines/xeen/dialogs_options.cpp19
-rw-r--r--engines/xeen/party.h1
-rw-r--r--engines/xeen/xeen.cpp47
-rw-r--r--engines/xeen/xeen.h10
6 files changed, 119 insertions, 63 deletions
diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp
index 4d1a87647d..810c136431 100644
--- a/engines/xeen/dialogs.cpp
+++ b/engines/xeen/dialogs.cpp
@@ -22,34 +22,36 @@
#include "common/scummsys.h"
#include "xeen/dialogs.h"
+#include "xeen/events.h"
#include "xeen/resources.h"
+#include "xeen/xeen.h"
namespace Xeen {
/**
* Saves the current list of buttons
*/
-void Dialog::saveButtons() {
+void ButtonContainer::saveButtons() {
_savedButtons.push(_buttons);
}
/*
* Clears the current list of defined buttons
*/
-void Dialog::clearButtons() {
+void ButtonContainer::clearButtons() {
_buttons.clear();
}
-void Dialog::restoreButtons() {
+void ButtonContainer::restoreButtons() {
_buttons = _savedButtons.pop();
}
-void Dialog::addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw = true) {
- _buttons.push_back(DialogButton(bounds, c, sprites, draw));
+void ButtonContainer::addButton(const Common::Rect &bounds, int val, SpriteResource *sprites, bool draw = true) {
+ _buttons.push_back(UIButton(bounds, val, sprites, draw));
}
-void Dialog::checkEvents() {
- EventsManager &events = *_vm->_events;
+void ButtonContainer::checkEvents(XeenEngine *vm) {
+ EventsManager &events = *vm->_events;
events.pollEventsAndWait();
if (events._leftButton) {
@@ -59,7 +61,7 @@ void Dialog::checkEvents() {
for (uint i = 0; i < _buttons.size(); ++i) {
if (_buttons[i]._bounds.contains(pt)) {
- _key = _buttons[i]._c;
+ _buttonValue = _buttons[i]._value;
return;
}
}
@@ -67,7 +69,7 @@ void Dialog::checkEvents() {
Common::KeyState keyState;
events.getKey(keyState);
if (keyState.ascii >= 32 && keyState.ascii <= 127) {
- _key = keyState.ascii;
+ _buttonValue = keyState.ascii;
return;
}
}
@@ -77,13 +79,13 @@ void Dialog::checkEvents() {
/**
* Draws the scroll in the background
*/
-void Dialog::doScroll(bool drawFlag, bool doFade) {
- Screen &screen = *_vm->_screen;
- EventsManager &events = *_vm->_events;
+void ButtonContainer::doScroll(XeenEngine *vm, bool drawFlag, bool doFade) {
+ Screen &screen = *vm->_screen;
+ EventsManager &events = *vm->_events;
- if (_vm->getGameID() != GType_Clouds) {
+ if (vm->getGameID() != GType_Clouds) {
if (doFade) {
- _vm->_screen->fadeIn(2);
+ screen.fadeIn(2);
}
return;
}
@@ -127,8 +129,8 @@ void Dialog::doScroll(bool drawFlag, bool doFade) {
marb[i / 5]->draw(screen, i % 5);
}
- while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0)
- _vm->_events->pollEventsAndWait();
+ while (!vm->shouldQuit() && events.timeElapsed() == 0)
+ events.pollEventsAndWait();
screen._windows[0].update();
if (i == 0 && doFade)
@@ -151,8 +153,8 @@ void Dialog::doScroll(bool drawFlag, bool doFade) {
marb[i / 5]->draw(screen, i % 5);
}
- while (!_vm->shouldQuit() && _vm->_events->timeElapsed() == 0)
- _vm->_events->pollEventsAndWait();
+ while (!vm->shouldQuit() && events.timeElapsed() == 0)
+ events.pollEventsAndWait();
screen._windows[0].update();
if (i == 0 && doFade)
@@ -178,10 +180,24 @@ void Dialog::doScroll(bool drawFlag, bool doFade) {
delete hand[i];
}
+/**
+ * Draws the buttons onto the passed surface
+ */
+void ButtonContainer::drawButtons(XSurface *surface) {
+ for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) {
+ UIButton &btn = _buttons[btnIndex];
+ if (btn._draw) {
+ btn._sprites->draw(*surface, btnIndex * 2,
+ Common::Point(btn._bounds.left, btn._bounds.top));
+ }
+ }
+}
+
+
/*------------------------------------------------------------------------*/
void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) {
- checkEvents();
+ checkEvents(_vm);
}
/*------------------------------------------------------------------------*/
@@ -197,12 +213,12 @@ void CreditsScreen::execute() {
EventsManager &events = *_vm->_events;
// Handle drawing the credits screen
- doScroll(true, false);
+ doScroll(_vm, true, false);
screen._windows[28].close();
screen.loadBackground("marb.raw");
screen._windows[0].writeString(CREDITS);
- doScroll(false, false);
+ doScroll(_vm, false, false);
events.setCursor(0);
screen._windows[0].update();
@@ -212,7 +228,7 @@ void CreditsScreen::execute() {
while (!events.isKeyMousePressed())
events.pollEventsAndWait();
- doScroll(true, false);
+ doScroll(_vm, true, false);
}
} // End of namespace Xeen
diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h
index 1f8f2fb624..61ae73473d 100644
--- a/engines/xeen/dialogs.h
+++ b/engines/xeen/dialogs.h
@@ -26,36 +26,39 @@
#include "common/array.h"
#include "common/stack.h"
#include "common/rect.h"
-#include "xeen/xeen.h"
+#include "xeen/sprites.h"
namespace Xeen {
-class DialogButton {
+class XeenEngine;
+
+class UIButton {
public:
Common::Rect _bounds;
SpriteResource *_sprites;
- char _c;
+ int _value;
bool _draw;
- DialogButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw) :
- _bounds(bounds), _c(c), _sprites(sprites), _draw(draw) {}
+ UIButton(const Common::Rect &bounds, int value, SpriteResource *sprites, bool draw) :
+ _bounds(bounds), _value(value), _sprites(sprites), _draw(draw) {}
- DialogButton() : _c('\0'), _sprites(nullptr), _draw(false) {}
+ UIButton() : _value(0), _sprites(nullptr), _draw(false) {}
};
-class Dialog {
+class ButtonContainer {
private:
- Common::Stack< Common::Array<DialogButton> > _savedButtons;
+ Common::Stack< Common::Array<UIButton> > _savedButtons;
protected:
- XeenEngine *_vm;
- Common::Array<DialogButton> _buttons;
- char _key;
+ Common::Array<UIButton> _buttons;
+ int _buttonValue;
- void doScroll(bool drawFlag, bool doFade);
+ void doScroll(XeenEngine *vm, bool drawFlag, bool doFade);
- void checkEvents();
+ void checkEvents(XeenEngine *vm);
+
+ void drawButtons(XSurface *surface);
public:
- Dialog(XeenEngine *vm): _vm(vm), _key('\0') {}
+ ButtonContainer() : _buttonValue(0) {}
void saveButtons();
@@ -63,19 +66,23 @@ public:
void restoreButtons();
- void addButton(const Common::Rect &bounds, char c, SpriteResource *sprites, bool draw);
+ void addButton(const Common::Rect &bounds, int val, SpriteResource *sprites, bool draw);
};
-class SettingsBaseDialog : public Dialog {
+class SettingsBaseDialog : public ButtonContainer {
protected:
+ XeenEngine *_vm;
+
virtual void showContents(SpriteResource &title1, bool mode);
public:
- SettingsBaseDialog(XeenEngine *vm) : Dialog(vm) {}
+ SettingsBaseDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
};
-class CreditsScreen: public Dialog {
+class CreditsScreen: public ButtonContainer {
private:
- CreditsScreen(XeenEngine *vm) : Dialog(vm) {}
+ XeenEngine *_vm;
+
+ CreditsScreen(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
void execute();
public:
diff --git a/engines/xeen/dialogs_options.cpp b/engines/xeen/dialogs_options.cpp
index e85a4af51d..eace67eecd 100644
--- a/engines/xeen/dialogs_options.cpp
+++ b/engines/xeen/dialogs_options.cpp
@@ -81,14 +81,14 @@ void OptionsMenu::execute() {
while (!_vm->shouldQuit()) {
// Show the dialog with a continually animating background
- while (!_vm->shouldQuit() && _key == '\0')
+ while (!_vm->shouldQuit() && !_buttonValue)
showContents(title1Sprites, true);
if (_vm->shouldQuit())
return;
// Handle keypress
- char key = toupper(_key);
- _key = '\0';
+ int key = toupper(_buttonValue);
+ _buttonValue = 0;
if (key == 'C' || key == 'V') {
// Show credits
@@ -218,20 +218,13 @@ void WorldOptionsMenu::showContents(SpriteResource &title1, bool waitFlag) {
screen._windows[28].frame();
screen._windows[28].writeString(OPTIONS_TITLE);
- for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) {
- DialogButton &btn = _buttons[btnIndex];
- if (btn._draw) {
- btn._sprites->draw(screen._windows[0], btnIndex * 2,
- Common::Point(btn._bounds.left, btn._bounds.top));
- }
- }
+ drawButtons(&screen._windows[0]);
if (waitFlag) {
screen._windows[0].update();
- while (!_vm->shouldQuit() && _key == Common::KEYCODE_INVALID &&
- events.timeElapsed() < 3) {
- checkEvents();
+ while (!_vm->shouldQuit() && !_buttonValue && events.timeElapsed() < 3) {
+ checkEvents(_vm);
}
}
}
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 6a6ec5f8a1..9031b8831e 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -57,6 +57,7 @@ enum ConditionType { CURSED = 0, HEART_BROKEN = 1, WEAK = 2, POISONED = 3,
#define ITEMS_COUNT 36
#define TOTAL_CHARACTERS 30
+#define XEEN_TOTAL_CHARACTERS 24
#define MAX_ACTIVE_PARTY 6
class XeenEngine;
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index f2bbbe0517..d7f6138342 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -34,7 +34,7 @@
namespace Xeen {
XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
- : _gameDescription(gameDesc), Engine(syst), _randomSource("Xeen") {
+ : Engine(syst), ButtonContainer(), _gameDescription(gameDesc), _randomSource("Xeen") {
_debugger = nullptr;
_events = nullptr;
_saves = nullptr;
@@ -43,9 +43,9 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
_eventData = nullptr;
Common::fill(&_activeRoster[0], &_activeRoster[MAX_ACTIVE_PARTY], nullptr);
Common::fill(&_partyFaces[0], &_partyFaces[MAX_ACTIVE_PARTY], nullptr);
-
_isEarlyGame = false;
-
+ _loadDarkSide = 1;
+ _buttonsLoaded = false;
}
XeenEngine::~XeenEngine() {
@@ -246,15 +246,16 @@ void XeenEngine::showMainMenu() {
void XeenEngine::playGame() {
_saves->reset();
- drawUI(true);
+ setupUI(true);
}
/*
* Lots of stuff in this method.
* TODO: Consider renaming method when better understood
*/
-void XeenEngine::drawUI(bool soundPlayed) {
- SpriteResource sprites1("global.icn"), borderSprites("border.icn");
+void XeenEngine::setupUI(bool soundPlayed) {
+ SpriteResource sprites1("global.icn"), borderSprites("border.icn"),
+ uiSprites("inn.icn");
// Get mappings to the active characters in the party
Common::fill(&_activeRoster[0], &_activeRoster[MAX_ACTIVE_PARTY], nullptr);
@@ -271,11 +272,39 @@ void XeenEngine::drawUI(bool soundPlayed) {
if (!_partyFaces[0]) {
// Xeen only uses 24 of possible 30 character slots
- loadCharIcons(24);
+ loadCharIcons(XEEN_TOTAL_CHARACTERS);
for (int i = 0; i < _party._partyCount; ++i)
_partyFaces[i] = &_charFaces[_party._partyMembers[i]];
}
+
+ _mode = MODE_1;
+ Common::Array<int> xeenSideChars;
+
+ // Build up a list of characters on the same Xeen side being loaded
+ for (int i = 0; i < XEEN_TOTAL_CHARACTERS; ++i) {
+ PlayerStruct &player = _roster[i];
+ if (player._name.empty() || player._xeenSide != _loadDarkSide)
+ continue;
+
+ xeenSideChars.push_back(i);
+ }
+
+ // Add in buttons for the UI
+ _buttonsLoaded = true;
+ addButton(Common::Rect(16, 100, 40, 120), 242, &uiSprites, true);
+ addButton(Common::Rect(52, 100, 76, 120), 243, &uiSprites, true);
+ addButton(Common::Rect(87, 100, 111, 120), 68, &uiSprites, true);
+ addButton(Common::Rect(122, 100, 146, 120), 82, &uiSprites, true);
+ addButton(Common::Rect(157, 100, 181, 120), 67, &uiSprites, true);
+ addButton(Common::Rect(192, 100, 216, 120), 88, &uiSprites, true);
+ addButton(Common::Rect(), 27, &uiSprites, false);
+ addButton(Common::Rect(16, 16, 48, 48), 49, &uiSprites, false);
+ addButton(Common::Rect(117, 16, 139, 48), 50, &uiSprites, false);
+ addButton(Common::Rect(16, 59, 48, 81), 51, &uiSprites, false);
+ addButton(Common::Rect(117, 59, 149, 81), 52, &uiSprites, false);
+
+ setupGameBackground();
}
}
@@ -289,4 +318,8 @@ void XeenEngine::loadCharIcons(int numChars) {
_dseFace.load("dse.fac");
}
+void XeenEngine::setupGameBackground() {
+
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index 7155e39483..7261efc879 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -32,6 +32,7 @@
#include "common/util.h"
#include "engines/engine.h"
#include "xeen/debugger.h"
+#include "xeen/dialogs.h"
#include "xeen/events.h"
#include "xeen/party.h"
#include "xeen/saves.h"
@@ -67,6 +68,7 @@ enum XeenDebugChannels {
enum Mode {
MODE_0 = 0,
+ MODE_1 = 1,
MODE_9 = 9
};
@@ -75,23 +77,27 @@ struct XeenGameDescription;
#define XEEN_SAVEGAME_VERSION 1
#define GAME_FRAME_TIME 50
-class XeenEngine : public Engine {
+class XeenEngine : public Engine, public ButtonContainer {
private:
const XeenGameDescription *_gameDescription;
Common::RandomSource _randomSource;
int _loadSaveSlot;
bool _isEarlyGame;
+ int _loadDarkSide;
SpriteResource _charFaces[TOTAL_CHARACTERS];
SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
SpriteResource _dseFace;
+ bool _buttonsLoaded;
void showIntro();
void showMainMenu();
- void drawUI(bool soundPlayed);
+ void setupUI(bool soundPlayed);
void loadCharIcons(int numChars);
+
+ void setupGameBackground();
protected:
/**
* Play the game