Skip to content

Commit

Permalink
XEEN: Implementing spells
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 1, 2015
1 parent 07f504f commit b243768
Show file tree
Hide file tree
Showing 5 changed files with 662 additions and 45 deletions.
107 changes: 107 additions & 0 deletions engines/xeen/dialogs_spells.cpp
Expand Up @@ -755,5 +755,112 @@ void NotWhileEngaged::execute(int spellId) {
_vm->_mode = oldMode;
}

/*------------------------------------------------------------------------*/

bool LloydsBeacon::show(XeenEngine *vm) {
LloydsBeacon *dlg = new LloydsBeacon(vm);
bool result = dlg->execute();
delete dlg;

return result;
}

bool LloydsBeacon::execute() {
Combat &combat = *_vm->_combat;
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
SoundManager &sound = *_vm->_sound;
Spells &spells = *_vm->_spells;
Window &w = screen._windows[10];
bool isDarkCc = _vm->_files->_isDarkCc;
Character &c = *combat._oldCharacter;

loadButtons();

if (!c._lloydMap) {
// No destination previously set, so have a default ready
if (isDarkCc) {
c._lloydSide = 1;
c._lloydPosition = Common::Point(25, 21);
c._lloydMap = 29;
} else {
c._lloydSide = 0;
c._lloydPosition = Common::Point(18, 4);
c._lloydMap = 28;
}
}

// Open up the text file for the destination map and read in it's name
File textFile(Common::String::format("%s%c%03d.txt",
c._lloydSide == 0 ? "xeen" : "dark",
c._lloydMap >= 100 ? 'x' : '0',
c._lloydMap));
Common::String mapName = textFile.readString();
textFile.close();

// Display the dialog
w.open();
w.writeString(Common::String::format(LLOYDS_BEACON,
mapName.c_str(), c._lloydPosition.x, c._lloydPosition.y));
drawButtons(&screen);
w.update();

bool result = true;
do {
do {
events.updateGameCounter();
intf.draw3d(true);

do {
events.pollEventsAndWait();
if (_vm->shouldQuit())
return true;

checkEvents(_vm);
} while (!_buttonValue && events.timeElapsed() < 1);
} while (!_buttonValue);

switch (_buttonValue) {
case Common::KEYCODE_r:
if (!isDarkCc && c._lloydMap >= 75 && c._lloydMap <= 78 && !party._cloudsEnd) {
result = false;
} else {
sound.playFX(51);
map._loadDarkSide = isDarkCc;
if (c._lloydMap != party._mazeId || c._lloydSide != (isDarkCc ? 1 : 0)) {
map.load(c._lloydMap);
}

party._mazePosition = c._lloydPosition;
}

_buttonValue = Common::KEYCODE_ESCAPE;
break;

case Common::KEYCODE_s:
case Common::KEYCODE_t:
sound.playFX(20);
c._lloydMap = party._mazeId;
c._lloydPosition = party._mazePosition;
c._lloydSide = isDarkCc ? 1 : 0;

_buttonValue = Common::KEYCODE_ESCAPE;
break;
}
} while (_buttonValue != Common::KEYCODE_ESCAPE);

w.close();
return result;
}

void LloydsBeacon::loadButtons() {
_iconSprites.load("lloyds.icn");

addButton(Common::Rect(281, 108, 305, 128), Common::KEYCODE_r, &_iconSprites);
addButton(Common::Rect(242, 108, 266, 128), Common::KEYCODE_t, &_iconSprites);
}

} // End of namespace Xeen
13 changes: 13 additions & 0 deletions engines/xeen/dialogs_spells.h
Expand Up @@ -109,6 +109,19 @@ class NotWhileEngaged : public ButtonContainer {
static void show(XeenEngine *vm, int spellId);
};

class LloydsBeacon : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;

LloydsBeacon(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}

bool execute();

void loadButtons();
public:
static bool show(XeenEngine *vm);
};

} // End of namespace Xeen

Expand Down
10 changes: 10 additions & 0 deletions engines/xeen/resources.cpp
Expand Up @@ -1544,4 +1544,14 @@ const char *const WHICH_ELEMENT2 =
"\r\x3""cWhich Element?', 2, 0Bh, '034\t014\f15F\fdire\t044"
"\f15E\fdlec\t074\f15C\fdold\t104\f15A\fdcid\x1";

const char *const DETECT_MONSTERS = "\x3""cDetect Monsters";

const char *const LLOYDS_BEACON =
"\r\x3""c\v000\t000\x1Lloyd's Beacon\n"
"\n"
"Last Location\n"
"\n"
"%s\x3l\n"
"x = %d\x3r\t000y = %d\x3""c\x2\v122\t021\f15S\fdet\t060\f15R\fdeturn\x1";

} // End of namespace Xeen
4 changes: 4 additions & 0 deletions engines/xeen/resources.h
Expand Up @@ -546,6 +546,10 @@ extern const char *const ON_WHO;
extern const char *const WHICH_ELEMENT1;
extern const char *const WHICH_ELEMENT2;

extern const char *const DETECT_MONSTERS;

extern const char *const LLOYDS_BEACON;

} // End of namespace Xeen

#endif /* XEEN_RESOURCES_H */

0 comments on commit b243768

Please sign in to comment.