Skip to content

Commit

Permalink
XEEN: Add difficulty selection dialog to WOX starting menu
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Feb 25, 2018
1 parent 18235e4 commit 72e540e
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 2 deletions.
3 changes: 3 additions & 0 deletions devtools/create_xeen/constants.cpp
Expand Up @@ -1767,6 +1767,8 @@ const char *const MUSIC_FILES2[6][7] = {
{ "sf05.m", "sf05.m", "sf05.m", "sf05.m", "sf05.m", "sf05.m", "sf05.m" }
};

const char *const DIFFICULTY_TEXT = "\v000\t000\x3""cSelect Game Preference";

void writeConstants(CCArchive &cc) {
Common::MemFile file;
file.syncString(CREDITS);
Expand Down Expand Up @@ -2093,6 +2095,7 @@ void writeConstants(CCArchive &cc) {
file.syncStrings(GOOBER, 3);
file.syncStrings(MUSIC_FILES1, 5);
file.syncStrings2D((const char *const *)MUSIC_FILES2, 6, 7);
file.syncString(DIFFICULTY_TEXT);

cc.add("CONSTANTS", file);
}
Binary file added dists/engine-data/dark.cc
Binary file not shown.
Binary file modified dists/engine-data/xeen.ccs
Binary file not shown.
2 changes: 1 addition & 1 deletion engines/xeen/combat.cpp
Expand Up @@ -1708,7 +1708,7 @@ void Combat::getWeaponDamage(Character &c, RangeType rangeType) {

if (_weaponDamage < 1)
_weaponDamage = 0;
if (!party._difficulty) {
if (party._difficulty == ADVENTURER) {
_hitChanceBonus += 5;
_weaponDamage *= 3;
}
Expand Down
77 changes: 77 additions & 0 deletions engines/xeen/dialogs_difficulty.cpp
@@ -0,0 +1,77 @@
/* 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/dialogs_difficulty.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"

namespace Xeen {

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

return result;
}

DifficultyDialog::DifficultyDialog(XeenEngine *vm) : ButtonContainer(vm) {
loadButtons();
}

int DifficultyDialog::execute() {
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Party &party = *_vm->_party;
Windows &windows = *_vm->_windows;

Window &w = windows[6];
w.open();
w.writeString(Res.DIFFICULTY_TEXT);
drawButtons(&w);

int result = -1;
while (!_vm->shouldExit()) {
events.pollEventsAndWait();
checkEvents(_vm);

if (_buttonValue == Common::KEYCODE_a)
result = ADVENTURER;
else if (_buttonValue == Common::KEYCODE_w)
result = WARRIOR;
else if (_buttonValue != Common::KEYCODE_ESCAPE)
continue;

break;
}

w.close();
return result;
}

void DifficultyDialog::loadButtons() {
_sprites.load("choice.icn");
addButton(Common::Rect(68, 167, 158, 187), Common::KEYCODE_a, &_sprites);
addButton(Common::Rect(166, 167, 256, 187), Common::KEYCODE_w, &_sprites);
}

} // End of namespace Xeen
60 changes: 60 additions & 0 deletions engines/xeen/dialogs_difficulty.h
@@ -0,0 +1,60 @@
/* 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_DIALOGS_DIFFICULTY_H
#define XEEN_DIALOGS_DIFFICULTY_H

#include "xeen/dialogs.h"
#include "xeen/party.h"

namespace Xeen {

class DifficultyDialog : public ButtonContainer {
private:
SpriteResource _sprites;

/**
* Constructor
*/
DifficultyDialog(XeenEngine *vm);

/**
* Shows the dialog
*/
int execute();

/**
* Loads buttons for the dialog
*/
void loadButtons();
public:
/**
* Shows the difficulty selection dialog
* @param vm Engine reference
* @returns 0=Adventurer, 1=Warrior, -1 exit
*/
static int show(XeenEngine *vm);
};

} // End of namespace Xeen

#endif /* XEEN_DIALOGS_DIFFICULTY_H */
1 change: 1 addition & 0 deletions engines/xeen/module.mk
Expand Up @@ -18,6 +18,7 @@ MODULE_OBJS := \
dialogs_char_info.o \
dialogs_control_panel.o \
dialogs_create_char.o \
dialogs_difficulty.o \
dialogs_dismiss.o \
dialogs_exchange.o \
dialogs_info.o \
Expand Down
1 change: 1 addition & 0 deletions engines/xeen/resources.cpp
Expand Up @@ -386,6 +386,7 @@ void Resources::loadData() {
file.syncStrings(GOOBER, 3);
file.syncStrings(MUSIC_FILES1, 5);
file.syncStrings2D(&MUSIC_FILES2[0][0], 6, 7);
file.syncString(DIFFICULTY_TEXT);
}

} // End of namespace Xeen
1 change: 1 addition & 0 deletions engines/xeen/resources.h
Expand Up @@ -441,6 +441,7 @@ class Resources {
const char *GOOBER[3];
const char *MUSIC_FILES1[5];
const char *MUSIC_FILES2[6][7];
const char *DIFFICULTY_TEXT;
public:
/**
* Constructor
Expand Down
8 changes: 7 additions & 1 deletion engines/xeen/worldofxeen/worldofxeen_menu.cpp
Expand Up @@ -22,8 +22,9 @@

#include "common/scummsys.h"
#include "xeen/worldofxeen/worldofxeen_menu.h"
#include "xeen/resources.h"
#include "xeen/worldofxeen/worldofxeen.h"
#include "xeen/dialogs_difficulty.h"
#include "xeen/resources.h"

namespace Xeen {
namespace WorldOfXeen {
Expand Down Expand Up @@ -104,6 +105,11 @@ void WorldOfXeenMenu::execute() {
break;
} else if (key == 'S') {
// Start new game
int result = DifficultyDialog::show(_vm);
if (result == -1)
break;

_vm->_party->_difficulty = (Difficulty)result;
WOX_VM._pendingAction = WOX_PLAY_GAME;
closeWindow();
return;
Expand Down

2 comments on commit 72e540e

@darkstar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you wanted to add the original data file, dark.cc, to this commit?

@dreammaster
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah damn, no. I'd temporarily put it there to make it easier to generate the data file. Thanks for letting me know.

Please sign in to comment.