mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-27 11:20:40 +00:00
XEEN: Objectifying town locations code
This commit is contained in:
parent
65ecb6e56f
commit
f0a87ed8ad
@ -242,7 +242,7 @@ int Choose123::execute(int numOptions) {
|
||||
events.updateGameCounter();
|
||||
int delay;
|
||||
if (town.isActive()) {
|
||||
town.drawTownAnim(true);
|
||||
town.drawAnim(true);
|
||||
delay = 3;
|
||||
} else {
|
||||
intf.draw3d(true);
|
||||
|
@ -128,7 +128,7 @@ bool YesNo::execute(bool type, bool townFlag) {
|
||||
events.updateGameCounter();
|
||||
|
||||
if (town.isActive()) {
|
||||
town.drawTownAnim(townFlag);
|
||||
town.drawAnim(townFlag);
|
||||
//numFrames = 3;
|
||||
} else {
|
||||
intf.draw3d(true);
|
||||
|
@ -66,7 +66,7 @@ int WhoWill::execute(int message, int action, bool type) {
|
||||
events.updateGameCounter();
|
||||
|
||||
if (windows[11]._enabled) {
|
||||
town.drawTownAnim(0);
|
||||
town.drawAnim(false);
|
||||
windows[36].frame();
|
||||
numFrames = 3;
|
||||
} else {
|
||||
|
@ -137,7 +137,6 @@ int Scripts::checkEvents() {
|
||||
Map &map = *_vm->_map;
|
||||
Party &party = *_vm->_party;
|
||||
Sound &sound = *_vm->_sound;
|
||||
Town &town = *_vm->_town;
|
||||
Windows &windows = *_vm->_windows;
|
||||
bool isDarkCc = _vm->_files->_isDarkCc;
|
||||
|
||||
@ -266,9 +265,6 @@ int Scripts::checkEvents() {
|
||||
party._treasure = party._savedTreasure;
|
||||
}
|
||||
|
||||
// Clear any town loaded sprites
|
||||
town.clearSprites();
|
||||
|
||||
_v2 = 1;
|
||||
Common::fill(&intf._charFX[0], &intf._charFX[6], 0);
|
||||
|
||||
@ -446,7 +442,7 @@ bool Scripts::cmdNPC(ParamsIterator ¶ms) {
|
||||
int confirm = params.readByte();
|
||||
int lineNum = params.readByte();
|
||||
|
||||
if (TownMessage::show(_vm, portrait, _message, map._events._text[textNum],
|
||||
if (TownMessage::show(portrait, _message, map._events._text[textNum],
|
||||
confirm)) {
|
||||
_lineNum = lineNum;
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,20 +34,22 @@ namespace Xeen {
|
||||
enum TownAction {
|
||||
BANK = 0, BLACKSMITH = 1, GUILD = 2, TAVERN = 3, TEMPLE = 4,
|
||||
TRAINING = 5, ARENA = 6, NO_ACTION = 7, REAPER = 8, GOLEM = 9,
|
||||
DWARF1 = 10, SPHINX = 11, ACTION12 = 12, DWARF2 = 13
|
||||
DWARF1 = 10, SPHINX = 11, PYRAMID = 12, DWARF2 = 13
|
||||
};
|
||||
|
||||
class XeenEngine;
|
||||
class TownMessage;
|
||||
|
||||
class Town: public ButtonContainer {
|
||||
friend class TownMessage;
|
||||
private:
|
||||
class TownLocation : public ButtonContainer {
|
||||
protected:
|
||||
TownAction _townActionId;
|
||||
Common::Array<SpriteResource> _townSprites;
|
||||
SpriteResource _icons1, _icons2;
|
||||
Common::StringArray _textStrings;
|
||||
Common::Array<SpriteResource> _townSprites;
|
||||
int _townMaxId;
|
||||
TownAction _townActionId;
|
||||
const bool &_isDarkCc;
|
||||
int _animFrame;
|
||||
Common::String _vocName, _songName;
|
||||
int _v1, _v2;
|
||||
int _donation;
|
||||
int _healCost;
|
||||
@ -68,27 +70,214 @@ private:
|
||||
uint _experienceToNextLevel;
|
||||
int _drawFrameIndex;
|
||||
int _drawCtr1, _drawCtr2;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Load a set of text strings from the given resource
|
||||
*/
|
||||
void loadStrings(const Common::String &name);
|
||||
|
||||
void pyramidEvent();
|
||||
/**
|
||||
* Draw the window
|
||||
*/
|
||||
void drawWindow();
|
||||
|
||||
void arenaEvent();
|
||||
/**
|
||||
* Waits for a brief pause, checking for any key or mouse events
|
||||
*/
|
||||
int wait();
|
||||
|
||||
void reaperEvent();
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch) { return ""; }
|
||||
|
||||
void golemEvent();
|
||||
/**
|
||||
* Draw the visual background
|
||||
*/
|
||||
virtual void drawBackground();
|
||||
|
||||
void sphinxEvent();
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c) { return c; }
|
||||
|
||||
void dwarfEvent();
|
||||
/**
|
||||
* Handle any farewell
|
||||
*/
|
||||
virtual void farewell() {}
|
||||
public:
|
||||
TownLocation(TownAction action);
|
||||
virtual ~TownLocation();
|
||||
|
||||
Common::String createTownText(Character &ch);
|
||||
/**
|
||||
* Show the town location
|
||||
*/
|
||||
virtual int show();
|
||||
|
||||
/**
|
||||
* Draws the animated parts
|
||||
*/
|
||||
void drawAnim(bool flag);
|
||||
};
|
||||
|
||||
class BankLocation : public TownLocation {
|
||||
private:
|
||||
/**
|
||||
* Handles deposits or withdrawls fro the bank
|
||||
*/
|
||||
void depositWithdrawl(PartyBank whereId);
|
||||
protected:
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch);
|
||||
|
||||
/**
|
||||
* Draw the visual background
|
||||
*/
|
||||
virtual void drawBackground();
|
||||
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c);
|
||||
public:
|
||||
BankLocation();
|
||||
virtual ~BankLocation() {}
|
||||
};
|
||||
|
||||
class BlacksmithLocation : public TownLocation {
|
||||
protected:
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch);
|
||||
|
||||
/**
|
||||
* Handle any farewell
|
||||
*/
|
||||
virtual void farewell();
|
||||
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c);
|
||||
public:
|
||||
BlacksmithLocation();
|
||||
virtual ~BlacksmithLocation() {}
|
||||
};
|
||||
|
||||
class GuildLocation : public TownLocation {
|
||||
protected:
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch);
|
||||
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c);
|
||||
public:
|
||||
GuildLocation();
|
||||
virtual ~GuildLocation() {}
|
||||
};
|
||||
|
||||
class TavernLocation : public TownLocation {
|
||||
protected:
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch);
|
||||
|
||||
/**
|
||||
* Handle any farewell
|
||||
*/
|
||||
virtual void farewell();
|
||||
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c);
|
||||
public:
|
||||
TavernLocation();
|
||||
virtual ~TavernLocation() {}
|
||||
};
|
||||
|
||||
class TempleLocation : public TownLocation {
|
||||
protected:
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch);
|
||||
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c);
|
||||
public:
|
||||
TempleLocation();
|
||||
virtual ~TempleLocation() {}
|
||||
};
|
||||
|
||||
class TrainingLocation : public TownLocation {
|
||||
protected:
|
||||
/**
|
||||
* Generates the display text for the location, for a given character
|
||||
*/
|
||||
virtual Common::String createLocationText(Character &ch);
|
||||
|
||||
/**
|
||||
* Handles options for the particular location
|
||||
*/
|
||||
virtual Character *doOptions(Character *c);
|
||||
public:
|
||||
TrainingLocation();
|
||||
virtual ~TrainingLocation() {}
|
||||
};
|
||||
|
||||
class ArenaLocation : public TownLocation {
|
||||
public:
|
||||
ArenaLocation();
|
||||
virtual ~ArenaLocation() {}
|
||||
};
|
||||
|
||||
class ReaperLocation : public TownLocation {
|
||||
public:
|
||||
ReaperLocation();
|
||||
virtual ~ReaperLocation() {}
|
||||
};
|
||||
|
||||
class GolemLocation : public TownLocation {
|
||||
public:
|
||||
GolemLocation();
|
||||
virtual ~GolemLocation() {}
|
||||
};
|
||||
|
||||
class DwarfLocation : public TownLocation {
|
||||
public:
|
||||
DwarfLocation(bool isDwarf1);
|
||||
virtual ~DwarfLocation() {}
|
||||
};
|
||||
|
||||
class SphinxLocation : public TownLocation {
|
||||
public:
|
||||
SphinxLocation();
|
||||
virtual ~SphinxLocation() {}
|
||||
};
|
||||
|
||||
class PyramidLocation : public TownLocation {
|
||||
public:
|
||||
PyramidLocation();
|
||||
virtual ~PyramidLocation() {}
|
||||
};
|
||||
|
||||
class Town {
|
||||
private:
|
||||
TownLocation *_location;
|
||||
private:
|
||||
int townWait();
|
||||
|
||||
Character *doTownOptions(Character *c);
|
||||
|
||||
Character *doBankOptions(Character *c);
|
||||
|
||||
Character *doBlacksmithOptions(Character *c);
|
||||
@ -100,35 +289,37 @@ private:
|
||||
Character *doTempleOptions(Character *c);
|
||||
|
||||
Character *doTrainingOptions(Character *c);
|
||||
|
||||
void depositWithdrawl(PartyBank whereId);
|
||||
public:
|
||||
Town(XeenEngine *vm);
|
||||
Town();
|
||||
|
||||
/**
|
||||
* Show a given location, and return any result
|
||||
*/
|
||||
int townAction(TownAction actionId);
|
||||
|
||||
void drawTownAnim(bool flag);
|
||||
|
||||
/**
|
||||
* Returns true if a town location (bank, blacksmith, etc.) is currently active
|
||||
*/
|
||||
bool isActive() const;
|
||||
|
||||
void clearSprites();
|
||||
/**
|
||||
* Draws a currently active town location's animation
|
||||
*/
|
||||
void drawAnim(bool flag);
|
||||
};
|
||||
|
||||
class TownMessage : public ButtonContainer {
|
||||
class TownMessage : public TownLocation {
|
||||
private:
|
||||
SpriteResource _iconSprites;
|
||||
|
||||
TownMessage(XeenEngine *vm) : ButtonContainer(vm) {}
|
||||
TownMessage() : TownLocation(NO_ACTION) {}
|
||||
|
||||
bool execute(int portrait, const Common::String &name,
|
||||
const Common::String &text, int confirm);
|
||||
|
||||
void loadButtons();
|
||||
public:
|
||||
static bool show(XeenEngine *vm, int portrait, const Common::String &name,
|
||||
static bool show(int portrait, const Common::String &name,
|
||||
const Common::String &text, int confirm);
|
||||
};
|
||||
|
||||
|
@ -103,7 +103,7 @@ void XeenEngine::initialize() {
|
||||
_scripts = new Scripts(this);
|
||||
_sound = new Sound(this, _mixer);
|
||||
_spells = new Spells(this);
|
||||
_town = new Town(this);
|
||||
_town = new Town();
|
||||
_windows = new Windows();
|
||||
|
||||
File f("029.obj");
|
||||
|
Loading…
Reference in New Issue
Block a user