XEEN: Beginnings of Town class, implemented handleAction

This commit is contained in:
Paul Gilbert 2015-01-25 23:59:16 -05:00
parent 2abce62b8f
commit f11e11006b
16 changed files with 471 additions and 35 deletions

View File

@ -780,6 +780,14 @@ void Interface::doFalling() {
// TODO
}
void Interface::highlightChar(int charId) {
error("TODO: highlightChar");
}
void Interface::unhighlightChar() {
error("TODO: unhighlight");
}
bool Interface::checkMoveDirection(int key) {
Map &map = *_vm->_map;
Party &party = *_vm->_party;

View File

@ -99,6 +99,10 @@ public:
void doFalling();
void highlightChar(int charId);
void unhighlightChar();
void perform();
};

View File

@ -4964,7 +4964,7 @@ void InterfaceMap::drawMiniMap() {
party._wizardEyeActive = eyeActive;
}
void InterfaceMap::drawTownAnim(int v) {
void InterfaceMap::drawTownAnim(bool v) {
warning("TODO");
}

View File

@ -114,18 +114,12 @@ protected:
bool _charsShooting;
bool _thinWall;
bool _isAnimReset;
int _batUIFrame;
int _spotDoorsUIFrame;
int _dangerSenseUIFrame;
int _face1UIFrame;
int _face2UIFrame;
int _blessedUIFrame;
int _powerShieldUIFrame;
int _holyBonusUIFrame;
int _heroismUIFrame;
int _flipUIFrame;
bool _flag1;
int _overallFrame;
void setMazeBits();
@ -135,8 +129,6 @@ protected:
void drawMiniMap();
void assembleBorder();
virtual void setup();
public:
OutdoorDrawList _outdoorList;
@ -144,10 +136,14 @@ public:
SpriteResource _globalSprites;
bool _upDoorText;
Common::String _screenText;
int _face1State;
int _face2State;
int _face1State, _face2State;
int _face1UIFrame, _face2UIFrame;
int _spotDoorsUIFrame;
int _dangerSenseUIFrame;
byte _tillMove;
int _objNumber;
int _overallFrame;
int _batUIFrame;
public:
InterfaceMap(XeenEngine *vm);
@ -169,7 +165,9 @@ public:
void drawOutdoors();
void drawTownAnim(int v);
void drawTownAnim(bool v);
void assembleBorder();
};
} // End of namespace Xeen

View File

@ -28,6 +28,7 @@ MODULE_OBJS := \
sound.o \
spells.o \
sprites.o \
town.o \
xeen.o \
xsurface.o

View File

@ -68,7 +68,7 @@ const char *const OPTIONS_TITLE =
const char *const THE_PARTY_NEEDS_REST = "\x0B""012The Party needs rest!";
const char *const WHO_WILL = "\X03""c\X0B""000\x09""000%s\x0A\x0A"
const char *const WHO_WILL = "\x03""c\x0B""000\x09""000%s\x0A\x0A"
"Who will\x0A%s?\x0A\x0B""055F1 - F%d";
const char *const WHATS_THE_PASSWORD = "What's the Password?";
@ -566,4 +566,23 @@ const int OUTDOOR_DRAWSTRCT_INDEXES[44] = {
93, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120
};
const int TOWN_MAXES[2][11] = {
{ 23, 13, 32, 16, 26, 16, 16, 16, 16, 16, 16 },
{ 26, 19, 48, 27, 26, 37, 16, 16, 16, 16, 16 }
};
const char *const TOWN_ACTION_MUSIC[14] = {
"bank.m", "smith.m", "guild.m", "tavern.m", "temple.m",
"grounds.m", "endgame.m", "bank.m", "sf09.m", "guild.m",
"tavern.m", "temple.m", "smith.m", "endgame.m"
};
const char *const TOWN_ACTION_SHAPES[4] = {
"bankr", "blck", "gild", "tvrn"
};
const int TOWN_ACTION_FILES[2][7] = {
{ 3, 2, 4, 2, 4, 2, 1 }, { 5, 3, 7, 5, 4, 6, 1 }
};
} // End of namespace Xeen

View File

@ -150,6 +150,14 @@ extern const int ARMOR_STRENGTHS[14];
extern const int OUTDOOR_DRAWSTRCT_INDEXES[44];
extern const int TOWN_MAXES[2][11];
extern const char *const TOWN_ACTION_MUSIC[14];
extern const char *const TOWN_ACTION_SHAPES[4];
extern const int TOWN_ACTION_FILES[2][7];
} // End of namespace Xeen
#endif /* XEEN_RESOURCES_H */

View File

@ -96,7 +96,7 @@ Scripts::Scripts(XeenEngine *vm) : _vm(vm) {
_treasureGems = 0;
_lineNum = 0;
_charIndex = 0;
_v2 = false;
_v2 = 0;
_nEdamageType = 0;
_animCounter = 0;
_eventSkipped = false;
@ -123,7 +123,7 @@ bool Scripts::checkEvents() {
_whoWill = 0;
Mode oldMode = _vm->_mode;
Common::fill(&_charFX[0], &_charFX[MAX_ACTIVE_PARTY], 0);
int items = _treasureItems;
//int items = _treasureItems;
if (_treasureGold & _treasureItems) {
// TODO
@ -138,7 +138,7 @@ bool Scripts::checkEvents() {
// int var4E = 0;
_currentPos = party._mazePosition;
_charIndex = 1;
_v2 = true;
_v2 = 1;
_nEdamageType = 0;
// int var40 = -1;
@ -202,7 +202,7 @@ bool Scripts::checkEvents() {
w.close();
}
_v2 = true;
_v2 = 1;
Common::fill(&_charFX[0], &_charFX[6], 0);
return _scriptResult;
@ -490,7 +490,7 @@ void Scripts::cmdSetChar(Common::Array<byte> &params) {
_charIndex = _vm->getRandomNumber(1, _vm->_party->_partyCount);
}
_v2 = true;
_v2 = 1;
cmdNoAction(params);
}
@ -515,7 +515,7 @@ void Scripts::cmdSpawn(Common::Array<byte> &params) {
}
void Scripts::cmdDoTownEvent(Common::Array<byte> &params) {
_scriptResult = doTownEvent(params[0]);
_scriptResult = _vm->_town->townAction(params[0]);
_vm->_party->_stepped = true;
cmdExit(params);
@ -1271,15 +1271,6 @@ bool Scripts::ifProc(int action, uint32 mask, int mode, int charIndex) {
}
}
bool Scripts::doTownEvent(int actionId) {
if (actionId == 12)
return false;
return false;
}
bool Scripts::copyProtectionCheck() {
// Currentl not implemented
return true;

View File

@ -149,7 +149,7 @@ private:
int _mirrorId;
int _refreshIcons;
int _scriptResult;
bool _v2;
int _v2;
bool _scriptExecuted;
bool _var50;
MazeEvent *_event;
@ -223,8 +223,6 @@ private:
bool ifProc(int action, uint32 mask, int mode, int charIndex);
bool doTownEvent(int actionId);
bool copyProtectionCheck();
public:
int _animCounter;

View File

@ -37,6 +37,8 @@ public:
void proc2(Common::SeekableReadStream &f);
void loadMusic(const Common::String &name, int v2) {}
void startMusic(int v1);
void playSong(Common::SeekableReadStream &f) {}

View File

@ -31,10 +31,15 @@ Spells::Spells(XeenEngine *vm) : _vm(vm) {
}
void Spells::load() {
File f("spells.xen");
while (f.pos() < f.size())
_spellNames.push_back(f.readString());
f.close();
File f1("spells.xen");
while (f1.pos() < f1.size())
_spellNames.push_back(f1.readString());
f1.close();
File f2("mae.xen");
while (f2.pos() < f2.size())
_maeNames.push_back(f2.readString());
f2.close();
}
} // End of namespace Xeen

View File

@ -37,6 +37,7 @@ private:
void load();
public:
Common::StringArray _spellNames;
Common::StringArray _maeNames;
public:
Spells(XeenEngine *vm);
};

321
engines/xeen/town.cpp Normal file
View File

@ -0,0 +1,321 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "xeen/town.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"
namespace Xeen {
Town::Town(XeenEngine *vm) : _vm(vm) {
_townMaxId = 0;
_townActionId = 0;
_townCurrent = 0;
_v1 = 0;
_v2 = 0;
Common::fill(&_arr1[0], &_arr1[6], 0);
}
void Town::loadStrings(const Common::String &name) {
File f(name);
_textStrings.clear();
while (f.pos() < f.size())
_textStrings.push_back(f.readString());
f.close();
}
int Town::townAction(int actionId) {
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
SoundManager &sound = *_vm->_sound;
bool isDarkCc = _vm->_files->_isDarkCc;
if (actionId == 12) {
pyramidEvent();
return 0;
}
_townMaxId = TOWN_MAXES[_vm->_files->_isDarkCc][actionId];
_townActionId = actionId;
_townCurrent = 0;
_v1 = 0;
_townPos = Common::Point(8, 8);
intf._overallFrame = 0;
// This area sets up the GUI buttos and startup sample to play for the
// given town action
Common::String vocName = "hello1.voc";
clearButtons();
_icons1.clear();
_icons2.clear();
switch (actionId) {
case 0:
// Bank
_icons1.load("bank.icn");
_icons2.load("bank2.icn");
addButton(Common::Rect(234, 108, 259, 128), Common::KEYCODE_d, &_icons1);
addButton(Common::Rect(261, 108, 285, 128), Common::KEYCODE_w, &_icons1);
addButton(Common::Rect(288, 108, 312, 128), Common::KEYCODE_ESCAPE, &_icons1);
intf._overallFrame = 1;
sound.playSample(nullptr, 0);
vocName = isDarkCc ? "bank1.voc" : "banker.voc";
break;
case 1:
// Blacksmith
_icons1.load("esc.icn");
addButton(Common::Rect(261, 100, 285, 120), Common::KEYCODE_ESCAPE, &_icons1, true);
addButton(Common::Rect(234, 54, 308, 62), 0, &_icons1, false);
addButton(Common::Rect(234, 64, 308, 72), Common::KEYCODE_b, &_icons1, false);
addButton(Common::Rect(234, 74, 308, 82), 0, &_icons1, false);
addButton(Common::Rect(234, 84, 308, 92), 0, &_icons1, false);
sound.playSample(nullptr, 0);
vocName = isDarkCc ? "see2.voc" : "whaddayo.voc";
break;
case 2:
// Guild
loadStrings("spldesc.bin");
_icons1.load("esc.icn");
addButton(Common::Rect(261, 100, 285, 120), Common::KEYCODE_ESCAPE, &_icons1, true);
addButton(Common::Rect(234, 54, 308, 62), 0, &_icons1, false);
addButton(Common::Rect(234, 64, 308, 72), Common::KEYCODE_b, &_icons1, false);
addButton(Common::Rect(234, 74, 308, 82), Common::KEYCODE_s, &_icons1, false);
addButton(Common::Rect(234, 84, 308, 92), 0, &_icons1, false);
_vm->_mode = MODE_17;
sound.playSample(nullptr, 0);
vocName = isDarkCc ? "parrot1.voc" : "guild10.voc";
break;
case 3:
// Tavern
loadStrings("tavern.bin");
_icons1.load("tavern.icn");
addButton(Common::Rect(281, 108, 305, 128), Common::KEYCODE_ESCAPE, &_icons1, true);
addButton(Common::Rect(242, 108, 266, 128), Common::KEYCODE_s, &_icons1, true);
addButton(Common::Rect(234, 54, 308, 62), Common::KEYCODE_d, &_icons1, false);
addButton(Common::Rect(234, 64, 308, 72), Common::KEYCODE_f, &_icons1, false);
addButton(Common::Rect(234, 74, 308, 82), Common::KEYCODE_t, &_icons1, false);
addButton(Common::Rect(234, 84, 308, 92), Common::KEYCODE_r, &_icons1, false);
_vm->_mode = MODE_17;
sound.playSample(nullptr, 0);
vocName = isDarkCc ? "hello1.voc" : "hello.voc";
break;
case 4:
// Temple
_icons1.load("esc.icn");
addButton(Common::Rect(261, 100, 285, 120), Common::KEYCODE_ESCAPE, &_icons1, true);
addButton(Common::Rect(234, 54, 308, 62), Common::KEYCODE_h, &_icons1, false);
addButton(Common::Rect(234, 64, 308, 72), Common::KEYCODE_d, &_icons1, false);
addButton(Common::Rect(234, 74, 308, 82), Common::KEYCODE_u, &_icons1, false);
addButton(Common::Rect(234, 84, 308, 92), 0, &_icons1, false);
sound.playSample(nullptr, 0);
vocName = isDarkCc ? "help2.voc" : "maywe2.voc";
break;
case 5:
// Training
Common::fill(&_arr1[0], &_arr1[6], 0);
_v2 = 0;
_icons1.load("train.icn");
addButton(Common::Rect(281, 108, 305, 128), Common::KEYCODE_ESCAPE, &_icons1, true);
addButton(Common::Rect(242, 108, 266, 128), Common::KEYCODE_t, &_icons1, false);
sound.playSample(nullptr, 0);
vocName = isDarkCc ? "training.voc" : "youtrn1.voc";
break;
case 6:
// Arena event
arenaEvent();
return false;
case 8:
// Reaper event
reaperEvent();
return false;
case 9:
// Golem event
golemEvent();
return false;
case 10:
case 13:
dwarfEvent();
return false;
case 11:
sphinxEvent();
return false;
default:
break;
}
sound.loadMusic(TOWN_ACTION_MUSIC[actionId], 223);
_townSprites.clear();
for (int idx = 0; idx < TOWN_ACTION_FILES[isDarkCc][actionId]; ++idx) {
Common::String shapesName = Common::String::format("%s%d.twn",
TOWN_ACTION_SHAPES[actionId], idx + 1);
_townSprites[idx].load(shapesName);
}
Common::String title = createTownText();
intf._face1UIFrame = intf._face2UIFrame = 0;
intf._dangerSenseUIFrame = 0;
intf._spotDoorsUIFrame = 0;
intf._batUIFrame = 0;
_townSprites[_townCurrent / 8].draw(screen, _townCurrent % 8, _townPos);
if (actionId == 0 && isDarkCc) {
_townSprites[4].draw(screen, _vm->getRandomNumber(13, 18),
Common::Point(8, 30));
}
intf.assembleBorder();
// Open up the window and write the string
screen._windows[10].open();
screen._windows[10].writeString(title);
drawButtons(&screen);
screen._windows[0].update();
intf.highlightChar(0);
intf.drawTownAnim(1);
if (actionId == 0)
intf._overallFrame = 2;
File voc(vocName);
sound.playSample(&voc, 1);
do {
townWait();
doTownOptions();
screen._windows[10].writeString(title);
drawButtons(&screen);
} while (!_vm->shouldQuit() && _buttonValue != Common::KEYCODE_ESCAPE);
switch (actionId) {
case 1:
// Leave blacksmith
if (isDarkCc) {
sound.playSample(nullptr, 0);
File f("come1.voc");
sound.playSample(&f, 1);
}
break;
case 3: {
// Leave Tavern
sound.playSample(nullptr, 0);
File f(isDarkCc ? "gdluck1.voc" : "goodbye.voc");
sound.playSample(&f, 1);
map.mazeData()._mazeNumber = party._mazeId;
break;
}
default:
break;
}
int result;
if (party._mazeId != 0) {
map.load(party._mazeId);
_v1 += 1440;
party.addTime(_v1);
result = 0;
} else {
_vm->_saves->saveChars();
result = 2;
}
for (uint idx = 0; idx < _townSprites.size(); ++idx)
_townSprites[idx].clear();
intf.mainIconsPrint();
_buttonValue = 0;
return result;
}
void Town::townWait() {
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
while (!_vm->shouldQuit()) {
events.updateGameCounter();
while (!_vm->shouldQuit() && !_buttonValue && events.timeElapsed() < 3) {
checkEvents(_vm);
}
if (_buttonValue)
return;
intf.drawTownAnim(!_vm->_screen->_windows[11]._enabled);
}
}
void Town::pyramidEvent() {
error("TODO: pyramidEvent");
}
void Town::arenaEvent() {
error("TODO: arenaEvent");
}
void Town::reaperEvent() {
error("TODO: repearEvent");
}
void Town::golemEvent() {
error("TODO: golemEvent");
}
void Town::sphinxEvent() {
error("TODO: sphinxEvent");
}
void Town::dwarfEvent() {
error("TODO: dwarfEvent");
}
Common::String Town::createTownText() {
error("TODO");
}
void Town::doTownOptions() {
error("TODO: doTownOptions");
}
} // End of namespace Xeen

75
engines/xeen/town.h Normal file
View File

@ -0,0 +1,75 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef XEEN_TOWN_H
#define XEEN_TOWN_H
#include "common/scummsys.h"
#include "common/str-array.h"
#include "xeen/dialogs.h"
namespace Xeen {
class XeenEngine;
class Town: public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _icons1, _icons2;
Common::StringArray _textStrings;
Common::Array<SpriteResource> _townSprites;
int _townMaxId;
int _townActionId;
int _townCurrent;
int _v1;
int _v2;
Common::Point _townPos;
int _arr1[6];
void loadStrings(const Common::String &name);
void pyramidEvent();
void arenaEvent();
void reaperEvent();
void golemEvent();
void sphinxEvent();
void dwarfEvent();
Common::String createTownText();
void townWait();
void doTownOptions();
public:
Town(XeenEngine *vm);
int townAction(int actionId);
};
} // End of namespace Xeen
#endif /* XEEN_SPELLS_H */

View File

@ -48,6 +48,7 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
_scripts = nullptr;
_sound = nullptr;
_spells = nullptr;
_town = nullptr;
_eventData = nullptr;
_dangerSenseAllowed = false;
_noDirectionSense = false;
@ -69,6 +70,7 @@ XeenEngine::~XeenEngine() {
delete _scripts;
delete _sound;
delete _spells;
delete _town;
delete _eventData;
delete _files;
}
@ -94,6 +96,7 @@ void XeenEngine::initialize() {
_screen->setupWindows();
_sound = new SoundManager(this);
_spells = new Spells(this);
_town = new Town(this);
File f("029.obj");
_eventData = f.readStream(f.size());

View File

@ -44,6 +44,7 @@
#include "xeen/scripts.h"
#include "xeen/sound.h"
#include "xeen/spells.h"
#include "xeen/town.h"
/**
* This is the namespace of the Xeen engine.
@ -142,6 +143,7 @@ public:
Scripts *_scripts;
SoundManager *_sound;
Spells *_spells;
Town *_town;
Treasure _treasure;
Mode _mode;
GameEvent _gameEvent;