XEEN: Control panel dialog now showing

This commit is contained in:
Paul Gilbert 2018-01-27 21:39:40 -05:00
parent 68274d1cc6
commit b1b0f6be2e
7 changed files with 137 additions and 138 deletions

View file

@ -47,11 +47,12 @@ void ButtonContainer::restoreButtons() {
void ButtonContainer::addButton(const Common::Rect &bounds, int val,
SpriteResource *sprites) {
_buttons.push_back(UIButton(bounds, val, sprites, true));
_buttons.push_back(UIButton(bounds, val, _buttons.size() * 2, sprites, sprites != nullptr));
}
void ButtonContainer::addButton(const Common::Rect &bounds, int val) {
_buttons.push_back(UIButton(bounds, val, nullptr, false));
void ButtonContainer::addButton(const Common::Rect &bounds, int val,
uint frameNum, SpriteResource *sprites) {
_buttons.push_back(UIButton(bounds, val, frameNum, sprites, sprites != nullptr));
}
void ButtonContainer::addPartyButtons(XeenEngine *vm) {
@ -106,7 +107,7 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) {
if (btn._draw && btn._value == _buttonValue) {
// Found the correct button
// Draw button depressed
btn._sprites->draw(0, btnIndex * 2 + 1,
btn._sprites->draw(0, btn._frameNum + 1,
Common::Point(btn._bounds.left, btn._bounds.top));
win.setBounds(btn._bounds);
win.update();
@ -116,7 +117,7 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) {
events.wait(2);
// Redraw button in it's original non-depressed form
btn._sprites->draw(0, btnIndex * 2,
btn._sprites->draw(0, btn._frameNum,
Common::Point(btn._bounds.left, btn._bounds.top));
win.setBounds(btn._bounds);
win.update();
@ -134,7 +135,7 @@ 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,
btn._sprites->draw(*surface, btn._frameNum,
Common::Point(btn._bounds.left, btn._bounds.top));
}
}

View file

@ -39,12 +39,14 @@ public:
Common::Rect _bounds;
SpriteResource *_sprites;
int _value;
uint _frameNum;
bool _draw;
UIButton(const Common::Rect &bounds, int value, SpriteResource *sprites, bool draw) :
_bounds(bounds), _value(value), _sprites(sprites), _draw(draw) {}
UIButton(const Common::Rect &bounds, int value, uint frameNum, SpriteResource *sprites, bool draw) :
_bounds(bounds), _value(value), _frameNum(frameNum),
_sprites(sprites), _draw(draw) {}
UIButton() : _value(0), _sprites(nullptr), _draw(false) {}
UIButton() : _value(0), _frameNum(0), _sprites(nullptr), _draw(false) {}
};
class ButtonContainer : public Cutscenes {
@ -89,9 +91,10 @@ public:
void restoreButtons();
void addButton(const Common::Rect &bounds, int val, SpriteResource *sprites);
void addButton(const Common::Rect &bounds, int val);
void addButton(const Common::Rect &bounds, int val,
SpriteResource *sprites = nullptr);
void addButton(const Common::Rect &bounds, int val,
uint frameNum, SpriteResource *sprites = nullptr);
void addPartyButtons(XeenEngine *vm);

View file

@ -50,10 +50,9 @@ int ControlPanel::execute() {
loadButtons();
int result = 0, debugCtr = 0;
while (!g_vm->shouldQuit()) {
w.open();
while (!g_vm->shouldQuit()) {
do {
Common::String btnText = getButtonText();
Common::String text = Common::String::format(Res.CONTROL_PANEL_TEXT, btnText.c_str());
@ -64,7 +63,7 @@ int ControlPanel::execute() {
do {
events.updateGameCounter();
intf.draw3d(false);
intf.draw3d(false, false);
w.writeString("\r");
drawButtons(&w);
w.writeString(text);
@ -81,8 +80,7 @@ int ControlPanel::execute() {
checkEvents(_vm);
if (_vm->shouldQuit())
return 0;
if (!_buttonValue && !events.timeElapsed())
continue;
} while (!_buttonValue && !events.timeElapsed());
switch (_buttonValue) {
case Common::KEYCODE_q:
@ -100,11 +98,11 @@ int ControlPanel::execute() {
if (g_vm->getGameID() == GType_WorldOfXeen) {
map._loadDarkSide = false;
map.load(29);
map.load(28);
party._mazeDirection = DIR_EAST;
} else {
map._loadDarkSide = true;
map.load(28);
map.load(29);
party._mazeDirection = DIR_SOUTH;
}
party.moveToRunLocation();
@ -150,10 +148,11 @@ int ControlPanel::execute() {
debugCtr = 1;
break;
case Common::KEYCODE_o:
debugCtr = (debugCtr == 1) ? 2 : 0;
debugCtr = (debugCtr == 1 || debugCtr == 2) ? 2 : 0;
break;
case Common::KEYCODE_b:
debugCtr = (debugCtr == 2) ? 3 : 0;
break;
case Common::KEYCODE_r:
if (debugCtr == 3)
_debugFlag = true;
@ -165,10 +164,6 @@ int ControlPanel::execute() {
break;
}
} while (!result);
}
}
w.close();
intf.drawParty(true);
@ -185,18 +180,17 @@ int ControlPanel::execute() {
void ControlPanel::loadButtons() {
_iconSprites.load("cpanel.icn");
addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_f);
addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m);
addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, &_iconSprites);
addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s);
addButton(Common::Rect(214, 56, 244, 69), Common::KEYCODE_f, 0, &_iconSprites);
addButton(Common::Rect(214, 75, 244, 88), Common::KEYCODE_m, 0, &_iconSprites);
addButton(Common::Rect(135, 56, 165, 69), Common::KEYCODE_l, 0, &_iconSprites);
addButton(Common::Rect(135, 75, 165, 88), Common::KEYCODE_s, 0, &_iconSprites);
// For ScummVM we've merged both Save and Save As into a single
// save item, so we don't need this one
addButton(Common::Rect(), 0);
_buttons.end()->_draw = false;
addButton(Common::Rect(135, 94, 165, 107), Common::KEYCODE_q);
addButton(Common::Rect(175, 113, 205, 126), Common::KEYCODE_w);
addButton(Common::Rect(135, 94, 165, 107), Common::KEYCODE_q, 0, &_iconSprites);
addButton(Common::Rect(175, 113, 205, 126), Common::KEYCODE_w, 0, &_iconSprites);
}
Common::String ControlPanel::getButtonText() {
@ -215,7 +209,7 @@ Common::String ControlPanel::getTimeText() const {
td.tm_hour == 0 || td.tm_hour == 12 ? 12 : (td.tm_hour % 12),
td.tm_min, td.tm_sec, (td.tm_hour >= 12) ? 'p' : 'c');
uint32 playtime = g_vm->_events->playTime();
uint32 playtime = g_vm->_events->playTime() / GAME_FRAME_RATE;
Common::String playtimeStr = Common::String::format("%d:%.2d:%.2d",
playtime / 3600, (playtime / 60) % 60, playtime % 60);
return Common::String::format(

View file

@ -30,7 +30,8 @@
namespace Xeen {
#define GAME_FRAME_RATE (1000 / 18.2)
#define GAME_FRAME_RATE (1000 / 50)
#define GAME_FRAME_TIME 50
class XeenEngine;

View file

@ -1674,20 +1674,21 @@ const char *const Resources::UNABLE_TO_PICK_LOCK = "\x3""c\v010%s was unable to
const char *const Resources::CONTROL_PANEL_TEXT =
"\x1\xC""00\x3""c\xB""000\t000Control Panel\x3r"
"\xB""022\t045\xC""06E\xC""dfx:\t124\xC""06S\xC""dave:"
"\xB""041\t045\xC""06M\xC""dusic:\t124S\xC""06a\xC""dve:"
"\xB""060\t045\xC""06L\xC""doad:\t124\xC""06Q\xC""duit:"
"\xB""080\t084Mr \xC""06W\xC""dizard:%s\t000";
"\xB""022\t045\xC""06L\xC""doad:\t124\xC""06E\xC""dfx:"
"\xB""041\t045\xC""06S\xC""dave:\t124\xC""06M\xC""dusic:"
"\xB""060\t045\xC""06Q\xC""duit:"
"\xB""080\t084Mr \xC""06W\xC""dizard:%s\t000\x1";
const char *const Resources::CONTROL_PANEL_BUTTONS =
"\x3""c\xB""022\t062load\t141%s"
"\x3""c\f11"
"\xB""022\t062load\t141%s"
"\xB""041\t062save\t141%s"
"\xB""060\t062exit"
"\xB""079\t102Help\xC""d";
const char *const Resources::ON = "on";
const char *const Resources::OFF = "off";
const char *const Resources::ON = "\f15on\f11";
const char *const Resources::OFF = "\f32off\f11";
const char *const Resources::CONFIRM_QUIT = "Are you sure you want to quit?";
const char *const Resources::MR_WIZARD =
"Are you sure you want Mr.Wizard''s Help ?";
"Are you sure you want Mr.Wizard's Help ?";
const char *const Resources::NO_LOADING_IN_COMBAT =
"No Loading Allowed in Combat!";
const char *const Resources::NO_SAVING_IN_COMBAT =

View file

@ -144,11 +144,11 @@ Common::Error XeenEngine::loadGameState(int slot) {
}
bool XeenEngine::canLoadGameStateCurrently() {
return true;
return _mode != MODE_COMBAT;
}
bool XeenEngine::canSaveGameStateCurrently() {
return true;
return _mode != MODE_COMBAT;
}
void XeenEngine::playGame() {

View file

@ -102,7 +102,6 @@ enum QuitMode {
struct XeenGameDescription;
#define XEEN_SAVEGAME_VERSION 1
#define GAME_FRAME_TIME 50
class XeenEngine : public Engine {
private: