Skip to content

Commit

Permalink
XEEN: Add custom engine option for showing inventory item costs
Browse files Browse the repository at this point in the history
This first new option displays the effective cost of items
when viewing in the standard character inventory. This makes
it easier to compare the value (and thus relative power)
of items against either other
  • Loading branch information
dreammaster committed Mar 26, 2018
1 parent f198c16 commit 99729bc
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
21 changes: 20 additions & 1 deletion engines/xeen/detection.cpp
Expand Up @@ -28,6 +28,7 @@
#include "common/savefile.h"
#include "engines/advancedDetector.h"
#include "common/system.h"
#include "common/translation.h"

#define MAX_SAVES 99

Expand Down Expand Up @@ -71,11 +72,29 @@ static const PlainGameDescriptor XeenGames[] = {
{0, 0}
};

#define GAMEOPTION_SHOW_ITEM_COSTS GUIO_GAMEOPTIONS1

#include "xeen/detection_tables.h"


static const ADExtraGuiOptionsMap optionsList[] = {
{
GAMEOPTION_SHOW_ITEM_COSTS,
{
_s("Show item costs in standard inventory mode"),
_s("Shows item costs in standard inventory mode, allowing the value of items to be compared"),
"ShowItemCosts",
false
}
},

AD_EXTRA_GUI_OPTIONS_TERMINATOR
};

class XeenMetaEngine : public AdvancedMetaEngine {
public:
XeenMetaEngine() : AdvancedMetaEngine(Xeen::gameDescriptions, sizeof(Xeen::XeenGameDescription), XeenGames) {
XeenMetaEngine() : AdvancedMetaEngine(Xeen::gameDescriptions, sizeof(Xeen::XeenGameDescription),
XeenGames, optionsList) {
_maxScanDepth = 3;
}

Expand Down
12 changes: 6 additions & 6 deletions engines/xeen/detection_tables.h
Expand Up @@ -36,7 +36,7 @@ static const XeenGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
GUIO1(GAMEOPTION_SHOW_ITEM_COSTS)
},
GType_WorldOfXeen,
0
Expand All @@ -55,7 +55,7 @@ static const XeenGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
GUIO1(GAMEOPTION_SHOW_ITEM_COSTS)
},
GType_WorldOfXeen,
0
Expand All @@ -74,7 +74,7 @@ static const XeenGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
GUIO1(GAMEOPTION_SHOW_ITEM_COSTS)
},
GType_WorldOfXeen,
0
Expand All @@ -92,7 +92,7 @@ static const XeenGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
GUIO1(GAMEOPTION_SHOW_ITEM_COSTS)
},
GType_Clouds,
0
Expand All @@ -110,7 +110,7 @@ static const XeenGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
GUIO1(GAMEOPTION_SHOW_ITEM_COSTS)
},
GType_DarkSide,
0
Expand All @@ -128,7 +128,7 @@ static const XeenGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformDOS,
ADGF_NO_FLAGS,
GUIO0()
GUIO1(GAMEOPTION_SHOW_ITEM_COSTS)
},
GType_Swords,
0
Expand Down
7 changes: 4 additions & 3 deletions engines/xeen/dialogs/dialogs_items.cpp
Expand Up @@ -149,16 +149,17 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) {
case CATEGORY_ARMOR:
case CATEGORY_ACCESSORY:
if (i._id) {
if (mode == ITEMMODE_CHAR_INFO || mode == ITEMMODE_8
|| mode == ITEMMODE_ENCHANT || mode == ITEMMODE_RECHARGE) {
if ((mode == ITEMMODE_CHAR_INFO && !g_vm->_extOptions._showItemCosts)
|| mode == ITEMMODE_8 || mode == ITEMMODE_ENCHANT || mode == ITEMMODE_RECHARGE) {
lines.push_back(Common::String::format(Res.ITEMS_DIALOG_LINE1,
arr[idx], idx + 1,
c->_items[category].getFullDescription(idx, arr[idx]).c_str()));
} else {
lines.push_back(Common::String::format(Res.ITEMS_DIALOG_LINE2,
arr[idx], idx + 1,
c->_items[category].getFullDescription(idx, arr[idx]).c_str(),
calcItemCost(c, idx, mode,
calcItemCost(c, idx,
(mode == ITEMMODE_CHAR_INFO) ? ITEMMODE_BLACKSMITH : mode,
mode == ITEMMODE_TO_GOLD ? 1 : startingChar->_skills[MERCHANT],
category)
));
Expand Down
10 changes: 8 additions & 2 deletions engines/xeen/xeen.cpp
Expand Up @@ -114,19 +114,25 @@ bool XeenEngine::initialize() {
syncSoundSettings();

// Load settings
loadSettings();

return true;
}

void XeenEngine::loadSettings() {
_gameWon[0] = ConfMan.hasKey("game_won") && ConfMan.getBool("game_won");
_gameWon[1] = ConfMan.hasKey("game_won2") && ConfMan.getBool("game_won2");
_gameWon[2] = ConfMan.hasKey("game_won3") && ConfMan.getBool("game_won3");
_finalScore = ConfMan.hasKey("final_score") ? ConfMan.getInt("final_score") : 0;

_extOptions._showItemCosts = ConfMan.hasKey("ShowItemCosts") && ConfMan.getBool("ShowItemCosts");

// If requested, load a savegame instead of showing the intro
if (ConfMan.hasKey("save_slot")) {
int saveSlot = ConfMan.getInt("save_slot");
if (saveSlot >= 0 && saveSlot <= 999)
_loadSaveSlot = saveSlot;
}

return true;
}

Common::Error XeenEngine::run() {
Expand Down
14 changes: 14 additions & 0 deletions engines/xeen/xeen.h
Expand Up @@ -106,6 +106,14 @@ struct XeenGameDescription;
#define XEEN_SAVEGAME_VERSION 1

class XeenEngine : public Engine {
/**
* Container to a set of options newly introduced under ScummVM
*/
struct ExtendedOptions {
bool _showItemCosts;

ExtendedOptions() : _showItemCosts(false) {}
};
private:
const XeenGameDescription *_gameDescription;
Common::RandomSource _randomSource;
Expand All @@ -115,6 +123,11 @@ class XeenEngine : public Engine {
*/
bool initialize();

/**
* Load settings
*/
void loadSettings();

// Engine APIs
virtual Common::Error run();
virtual bool hasFeature(EngineFeature f) const;
Expand Down Expand Up @@ -185,6 +198,7 @@ class XeenEngine : public Engine {
uint _endingScore;
bool _gameWon[3];
uint _finalScore;
ExtendedOptions _extOptions;
public:
XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc);
virtual ~XeenEngine();
Expand Down

0 comments on commit 99729bc

Please sign in to comment.