XEEN: Refactored doScroll to have it available to cutscenes

This commit is contained in:
Paul Gilbert 2016-09-21 07:26:24 -04:00
parent 41fea11ce6
commit 2e4fc11320
26 changed files with 159 additions and 195 deletions

View File

@ -20,7 +20,7 @@
*
*/
#include "xeen/worldofxeen/cutscenes.h"
#include "xeen/cutscenes.h"
#include "xeen/xeen.h"
namespace Xeen {
@ -103,4 +103,98 @@ uint Cutscenes::getSpeakingFrame(uint minFrame, uint maxFrame) {
return minFrame + interval % (maxFrame + 1 - minFrame);
}
void Cutscenes::doScroll(bool drawFlag, bool doFade) {
Screen &screen = *_vm->_screen;
EventsManager &events = *_vm->_events;
if (_vm->getGameID() != GType_Clouds) {
if (doFade) {
screen.fadeIn(2);
}
return;
}
const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 };
const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 };
screen.saveBackground();
// Load hand vga files
SpriteResource *hand[16];
for (int i = 0; i < 16; ++i) {
Common::String name = Common::String::format("hand%02d.vga", i);
hand[i] = new SpriteResource(name);
}
// Load marb vga files
SpriteResource *marb[5];
for (int i = 1; i < 5; ++i) {
Common::String name = Common::String::format("marb%02d.vga", i);
marb[i] = new SpriteResource(name);
}
if (drawFlag) {
for (int i = 22; i > 0; --i) {
events.updateGameCounter();
screen.restoreBackground();
if (i > 0 && i <= 14) {
hand[i - 1]->draw(screen, 0);
} else {
hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0), SPRFLAG_800);
marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0), SPRFLAG_800);
}
if (i <= 20) {
marb[i / 5]->draw(screen, i % 5);
}
while (!_vm->shouldQuit() && events.timeElapsed() == 0)
events.pollEventsAndWait();
screen._windows[0].update();
if (i == 0 && doFade)
screen.fadeIn(2);
}
} else {
for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) {
events.updateGameCounter();
screen.restoreBackground();
if (i < 14) {
hand[i]->draw(screen, 0);
} else {
hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0), SPRFLAG_800);
marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0), SPRFLAG_800);
}
if (i < 20) {
marb[i / 5]->draw(screen, i % 5);
}
while (!_vm->shouldQuit() && events.timeElapsed() == 0)
events.pollEventsAndWait();
screen._windows[0].update();
if (i == 0 && doFade)
screen.fadeIn(2);
}
}
if (drawFlag) {
hand[0]->draw(screen, 0);
marb[0]->draw(screen, 0);
} else {
screen.restoreBackground();
}
screen._windows[0].update();
// Free resources
for (int i = 1; i < 5; ++i)
delete marb[i];
for (int i = 0; i < 16; ++i)
delete hand[i];
}
} // End of namespace Xeen

View File

@ -20,8 +20,8 @@
*
*/
#ifndef XEEN_WORLDOFXEEN_CUTSCENES_H
#define XEEN_WORLDOFXEEN_CUTSCENES_H
#ifndef XEEN_CUTSCENES_H
#define XEEN_CUTSCENES_H
#include "xeen/files.h"
#include "xeen/sprites.h"
@ -81,8 +81,13 @@ protected:
* Get a speaking frame from a range
*/
uint getSpeakingFrame(uint minFrame, uint maxFrame);
/**
* Draws the scroll in the background
*/
virtual void doScroll(bool drawFlag, bool doFade);
};
} // End of namespace Xeen
#endif /* XEEN_WORLDOFXEEN_CUTSCENES_H */
#endif /* XEEN_CUTSCENES_H */

View File

@ -97,107 +97,6 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) {
return false;
}
void ButtonContainer::doScroll(XeenEngine *vm, bool drawFlag, bool doFade) {
Screen &screen = *vm->_screen;
EventsManager &events = *vm->_events;
if (vm->getGameID() != GType_Clouds) {
if (doFade) {
screen.fadeIn(2);
}
return;
}
const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 };
const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 };
saveButtons();
clearButtons();
screen.saveBackground();
// Load hand vga files
SpriteResource *hand[16];
for (int i = 0; i < 16; ++i) {
Common::String name = Common::String::format("hand%02d.vga", i);
hand[i] = new SpriteResource(name);
}
// Load marb vga files
SpriteResource *marb[5];
for (int i = 1; i < 5; ++i) {
Common::String name = Common::String::format("marb%02d.vga", i);
marb[i] = new SpriteResource(name);
}
if (drawFlag) {
for (int i = 22; i > 0; --i) {
events.updateGameCounter();
screen.restoreBackground();
if (i > 0 && i <= 14) {
hand[i - 1]->draw(screen, 0);
}
else {
// TODO: Check '800h'.. horizontal reverse maybe?
hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0));
marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0));
}
if (i <= 20) {
marb[i / 5]->draw(screen, i % 5);
}
while (!vm->shouldQuit() && events.timeElapsed() == 0)
events.pollEventsAndWait();
screen._windows[0].update();
if (i == 0 && doFade)
screen.fadeIn(2);
}
} else {
for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) {
events.updateGameCounter();
screen.restoreBackground();
if (i < 14) {
hand[i]->draw(screen, 0);
} else {
// TODO: Check '800h'.. horizontal reverse maybe?
hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0));
marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0));
}
if (i < 20) {
marb[i / 5]->draw(screen, i % 5);
}
while (!vm->shouldQuit() && events.timeElapsed() == 0)
events.pollEventsAndWait();
screen._windows[0].update();
if (i == 0 && doFade)
screen.fadeIn(2);
}
}
if (drawFlag) {
hand[0]->draw(screen, 0);
marb[0]->draw(screen, 0);
}
else {
screen.restoreBackground();
}
screen._windows[0].update();
restoreButtons();
// Free resources
for (int i = 1; i < 5; ++i)
delete marb[i];
for (int i = 0; i < 16; ++i)
delete hand[i];
}
void ButtonContainer::drawButtons(XSurface *surface) {
for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) {
UIButton &btn = _buttons[btnIndex];
@ -208,6 +107,17 @@ void ButtonContainer::drawButtons(XSurface *surface) {
}
}
void ButtonContainer::doScroll(bool drawFlag, bool doFade) {
if (_vm->getGameID() == GType_Clouds) {
saveButtons();
clearButtons();
Cutscenes::doScroll(drawFlag, doFade);
restoreButtons();
} else {
Cutscenes::doScroll(drawFlag, doFade);
}
}
/*------------------------------------------------------------------------*/
void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) {
@ -228,12 +138,12 @@ void CreditsScreen::execute() {
EventsManager &events = *_vm->_events;
// Handle drawing the credits screen
doScroll(_vm, true, false);
doScroll(true, false);
screen._windows[GAME_WINDOW].close();
screen.loadBackground("marb.raw");
screen._windows[0].writeString(CREDITS);
doScroll(_vm, false, false);
doScroll(false, false);
events.setCursor(0);
screen._windows[0].update();
@ -243,7 +153,7 @@ void CreditsScreen::execute() {
while (!events.isKeyMousePressed())
events.pollEventsAndWait();
doScroll(_vm, true, false);
doScroll(true, false);
}
/*------------------------------------------------------------------------*/

View File

@ -26,6 +26,7 @@
#include "common/array.h"
#include "common/stack.h"
#include "common/rect.h"
#include "xeen/cutscenes.h"
#include "xeen/sprites.h"
#include "xeen/xsurface.h"
@ -46,21 +47,21 @@ public:
UIButton() : _value(0), _sprites(nullptr), _draw(false) {}
};
class ButtonContainer {
class ButtonContainer : public Cutscenes {
private:
Common::Stack< Common::Array<UIButton> > _savedButtons;
protected:
Common::Array<UIButton> _buttons;
int _buttonValue;
bool checkEvents(XeenEngine *vm);
/**
* Draws the scroll in the background
*/
void doScroll(XeenEngine *vm, bool drawFlag, bool doFade);
bool checkEvents(XeenEngine *vm);
virtual void doScroll(bool drawFlag, bool doFade);
public:
ButtonContainer() : _buttonValue(0) {}
ButtonContainer(XeenEngine *vm) : Cutscenes(vm), _buttonValue(0) {}
/**
* Saves the current list of buttons
@ -85,20 +86,16 @@ public:
class SettingsBaseDialog : public ButtonContainer {
protected:
XeenEngine *_vm;
virtual void showContents(SpriteResource &title1, bool mode);
public:
SettingsBaseDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
SettingsBaseDialog(XeenEngine *vm) : ButtonContainer(vm) {}
virtual ~SettingsBaseDialog() {}
};
class CreditsScreen: public ButtonContainer {
private:
XeenEngine *_vm;
CreditsScreen(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
CreditsScreen(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();
public:

View File

@ -31,9 +31,7 @@ class XeenEngine;
class AutoMapDialog: public ButtonContainer {
private:
XeenEngine *_vm;
AutoMapDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
AutoMapDialog(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();
public:

View File

@ -31,12 +31,11 @@ namespace Xeen {
class CharacterInfo : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
DrawStruct _drawList[24];
int _cursorCell;
CharacterInfo(XeenEngine *vm) : ButtonContainer(), _vm(vm), _cursorCell(0) {}
CharacterInfo(XeenEngine *vm) : ButtonContainer(vm), _cursorCell(0) {}
void execute(int charIndex);

View File

@ -29,9 +29,7 @@ namespace Xeen {
class ControlPanel : public ButtonContainer {
private:
XeenEngine *_vm;
ControlPanel(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
ControlPanel(XeenEngine *vm) : ButtonContainer(vm) {}
int execute();
public:

View File

@ -30,10 +30,9 @@ namespace Xeen {
class Dismiss : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
Dismiss(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
Dismiss(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();

View File

@ -33,9 +33,7 @@ enum ErrorWaitType { WT_FREEZE_WAIT = 0, WT_NONFREEZED_WAIT = 1,
class ErrorDialog : public ButtonContainer {
private:
XeenEngine *_vm;
ErrorDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
ErrorDialog(XeenEngine *vm) : ButtonContainer(vm) {}
void execute(const Common::String &msg, ErrorWaitType waitType);
public:
@ -51,9 +49,7 @@ public:
class CantCast: public ButtonContainer {
private:
XeenEngine *_vm;
CantCast(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
CantCast(XeenEngine *vm) : ButtonContainer(vm) {}
void execute(int spellId, int componentNum);
public:

View File

@ -30,10 +30,9 @@ namespace Xeen {
class ExchangeDialog : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
ExchangeDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
ExchangeDialog(XeenEngine *vm) : ButtonContainer(vm) {}
void execute(Character *&c, int &charIndex);

View File

@ -29,9 +29,7 @@ namespace Xeen {
class FightOptions : public ButtonContainer {
private:
XeenEngine *_vm;
FightOptions(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
FightOptions(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();
public:

View File

@ -30,10 +30,9 @@ namespace Xeen {
class InfoDialog : public ButtonContainer {
private:
XeenEngine *_vm;
Common::StringArray _lines;
InfoDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
InfoDialog(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();

View File

@ -36,7 +36,6 @@ private:
*/
Common::KeyCode doCursor(const Common::String &msg);
protected:
XeenEngine *_vm;
Window *_window;
/**
@ -44,7 +43,7 @@ protected:
*/
int getString(Common::String &line, uint maxLen, int maxWidth, bool isNumeric);
Input(XeenEngine *vm, Window *window) : _vm(vm), _window(window) {}
Input(XeenEngine *vm, Window *window) : ButtonContainer(vm), _window(window) {}
public:
static int show(XeenEngine *vm, Window *window, Common::String &line,
uint maxLen, int maxWidth, bool isNumeric = false);
@ -72,10 +71,9 @@ public:
class Choose123 : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
Choose123(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
Choose123(XeenEngine *vm) : ButtonContainer(vm) {}
int execute(int numOptions);

View File

@ -37,15 +37,13 @@ enum ItemsMode {
class ItemsDialog : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
SpriteResource _equipSprites;
Character _itemsCharacter;
Character *_oldCharacter;
DrawStruct _itemsDrawList[INV_ITEMS_TOTAL];
ItemsDialog(XeenEngine *vm) : ButtonContainer(),
_vm(vm), _oldCharacter(nullptr) {}
ItemsDialog(XeenEngine *vm) : ButtonContainer(vm), _oldCharacter(nullptr) {}
Character *execute(Character *c, ItemsMode mode);

View File

@ -32,7 +32,7 @@
namespace Xeen {
PartyDialog::PartyDialog(XeenEngine *vm) : ButtonContainer(),
PartyDialog::PartyDialog(XeenEngine *vm) : ButtonContainer(vm),
PartyDrawer(vm), _vm(vm) {
initDrawStructs();
}
@ -93,7 +93,7 @@ void PartyDialog::execute() {
screen._windows[0].update();
}
doScroll(_vm, false, false);
doScroll(false, false);
events.setCursor(0);
if (_vm->getGameID() == GType_DarkSide) {

View File

@ -29,9 +29,7 @@ namespace Xeen {
class Confirm : public ButtonContainer {
private:
XeenEngine *_vm;
Confirm(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
Confirm(XeenEngine *vm) : ButtonContainer(vm) {}
bool execute(const Common::String &msg, int mode);
public:
@ -40,9 +38,7 @@ public:
class YesNo : public ButtonContainer {
private:
XeenEngine *_vm;
YesNo(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
YesNo(XeenEngine *vm) : ButtonContainer(vm) {}
bool execute(bool type, bool townFlag);
public:

View File

@ -30,11 +30,10 @@ namespace Xeen {
class Quests : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
Common::StringArray _questNotes;
Quests(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
Quests(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();

View File

@ -29,9 +29,7 @@ namespace Xeen {
class QuickReferenceDialog : public ButtonContainer {
private:
XeenEngine *_vm;
QuickReferenceDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
QuickReferenceDialog(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();
public:

View File

@ -41,12 +41,11 @@ struct SpellEntry {
class SpellsDialog : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
SpriteResource _scrollSprites;
Common::Array<SpellEntry> _spells;
SpellsDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
SpellsDialog(XeenEngine *vm) : ButtonContainer(vm) {}
Character *execute(ButtonContainer *priorDialog, Character *c, int isCasting);
@ -60,10 +59,9 @@ public:
class CastSpell : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
CastSpell(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
CastSpell(XeenEngine *vm) : ButtonContainer(vm) {}
int execute(Character *&c);
@ -75,9 +73,7 @@ public:
class SpellOnWho : public ButtonContainer {
private:
XeenEngine *_vm;
SpellOnWho(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
SpellOnWho(XeenEngine *vm) : ButtonContainer(vm) {}
int execute(int spellId);
public:
@ -86,10 +82,9 @@ public:
class SelectElement : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
SelectElement(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
SelectElement(XeenEngine *vm) : ButtonContainer(vm) {}
int execute(int spellId);
@ -100,9 +95,7 @@ public:
class NotWhileEngaged : public ButtonContainer {
private:
XeenEngine *_vm;
NotWhileEngaged(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
NotWhileEngaged(XeenEngine *vm) : ButtonContainer(vm) {}
void execute(int spellId);
public:
@ -111,10 +104,9 @@ public:
class LloydsBeacon : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
LloydsBeacon(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
LloydsBeacon(XeenEngine *vm) : ButtonContainer(vm) {}
bool execute();
@ -125,10 +117,9 @@ public:
class Teleport : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
Teleport(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
Teleport(XeenEngine *vm) : ButtonContainer(vm) {}
int execute();
public:
@ -137,9 +128,7 @@ public:
class TownPortal : public ButtonContainer {
private:
XeenEngine *_vm;
TownPortal(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
TownPortal(XeenEngine *vm) : ButtonContainer(vm) {}
int execute();
public:
@ -148,9 +137,7 @@ public:
class IdentifyMonster : public ButtonContainer {
private:
XeenEngine *_vm;
IdentifyMonster(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
IdentifyMonster(XeenEngine *vm) : ButtonContainer(vm) {}
void execute();
public:

View File

@ -29,9 +29,7 @@ namespace Xeen {
class WhoWill : public ButtonContainer {
private:
XeenEngine *_vm;
WhoWill(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
WhoWill(XeenEngine *vm) : ButtonContainer(vm) {}
int execute(int message, int action, bool type);
public:

View File

@ -130,7 +130,7 @@ void PartyDrawer::resetHighlight() {
}
/*------------------------------------------------------------------------*/
Interface::Interface(XeenEngine *vm) : ButtonContainer(), InterfaceMap(vm),
Interface::Interface(XeenEngine *vm) : ButtonContainer(vm), InterfaceMap(vm),
PartyDrawer(vm), _vm(vm) {
_buttonsLoaded = false;
_intrIndex1 = 0;

View File

@ -1,12 +1,12 @@
MODULE := engines/xeen
MODULE_OBJS := \
worldofxeen/cutscenes.o \
worldofxeen/clouds_cutscenes.o \
worldofxeen/darkside_cutscenes.o \
worldofxeen/worldofxeen.o \
character.o \
combat.o \
cutscenes.o \
debugger.o \
detection.o \
dialogs.o \

View File

@ -30,7 +30,7 @@
namespace Xeen {
Town::Town(XeenEngine *vm) : _vm(vm) {
Town::Town(XeenEngine *vm) : ButtonContainer(vm) {
Common::fill(&_arr1[0], &_arr1[6], 0);
_townMaxId = 0;
_townActionId = 0;

View File

@ -37,7 +37,6 @@ class TownMessage;
class Town: public ButtonContainer {
friend class TownMessage;
private:
XeenEngine *_vm;
SpriteResource _icons1, _icons2;
Common::StringArray _textStrings;
Common::Array<SpriteResource> _townSprites;
@ -114,10 +113,9 @@ public:
class TownMessage : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;
TownMessage(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
TownMessage(XeenEngine *vm) : ButtonContainer(vm) {}
bool execute(int portrait, const Common::String &name,
const Common::String &text, int confirm);

View File

@ -23,7 +23,7 @@
#ifndef XEEN_WORLDOFXEEN_CLOUDS_CUTSCENES_H
#define XEEN_WORLDOFXEEN_CLOUDS_CUTSCENES_H
#include "xeen/worldofxeen/cutscenes.h"
#include "xeen/cutscenes.h"
#include "xeen/xeen.h"
namespace Xeen {

View File

@ -23,7 +23,7 @@
#ifndef XEEN_WORLDOFXEEN_DARKSIDE_CUTSCENES_H
#define XEEN_WORLDOFXEEN_DARKSIDE_CUTSCENES_H
#include "xeen/worldofxeen/cutscenes.h"
#include "xeen/cutscenes.h"
namespace Xeen {