SHERLOCK: RT: Implement initial inventory

This commit is contained in:
Paul Gilbert 2015-06-28 13:29:32 -04:00
parent 631be5b658
commit d5c1f8b8d6
9 changed files with 98 additions and 7 deletions

View File

@ -33,6 +33,13 @@ InventoryItem::InventoryItem(int requiredFlag, const Common::String &name,
_examine(examine), _lookFlag(0) {
}
InventoryItem::InventoryItem(int requiredFlag, const Common::String &name,
const Common::String &description, const Common::String &examine, const Common::String &verbName) :
_requiredFlag(requiredFlag), _name(name), _description(description),
_examine(examine), _lookFlag(0) {
_verb._verb = verbName;
}
void InventoryItem::synchronize(Serializer &s) {
s.syncAsSint16LE(_requiredFlag);
s.syncAsSint16LE(_lookFlag);

View File

@ -69,6 +69,8 @@ struct InventoryItem {
InventoryItem() : _requiredFlag(0), _lookFlag(0), _requiredFlag1(0) {}
InventoryItem(int requiredFlag, const Common::String &name,
const Common::String &description, const Common::String &examine);
InventoryItem(int requiredFlag, const Common::String &name,
const Common::String &description, const Common::String &examine, const Common::String &verbName);
/**
* Synchronize the data for an inventory item

View File

@ -30,6 +30,8 @@ namespace Sherlock {
namespace Scalpel {
class ScalpelInventory : public Inventory {
public:
int _invIndex;
public:
ScalpelInventory(SherlockEngine *vm);
~ScalpelInventory();

View File

@ -22,6 +22,7 @@
#include "engines/util.h"
#include "sherlock/tattoo/tattoo.h"
#include "sherlock/tattoo/tattoo_fixed_text.h"
#include "sherlock/tattoo/tattoo_resources.h"
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/widget_base.h"
@ -68,6 +69,9 @@ void TattooEngine::initialize() {
PORTRAITS[idx], nullptr, nullptr));
}
// Load the inventory
loadInventory();
// Starting scene
_scene->_goToScene = STARTING_INTRO_SCENE;
@ -98,6 +102,41 @@ void TattooEngine::loadInitialPalette() {
delete stream;
}
void TattooEngine::loadInventory() {
Inventory &inv = *_inventory;
Common::String inv1 = _fixedText->getText(kFixedText_Inv1);
Common::String inv2 = _fixedText->getText(kFixedText_Inv2);
Common::String inv3 = _fixedText->getText(kFixedText_Inv3);
Common::String inv4 = _fixedText->getText(kFixedText_Inv4);
Common::String inv5 = _fixedText->getText(kFixedText_Inv5);
Common::String inv6 = _fixedText->getText(kFixedText_Inv6);
Common::String inv7 = _fixedText->getText(kFixedText_Inv7);
Common::String inv8 = _fixedText->getText(kFixedText_Inv8);
Common::String invDesc1 = _fixedText->getText(kFixedText_InvDesc1);
Common::String invDesc2 = _fixedText->getText(kFixedText_InvDesc2);
Common::String invDesc3 = _fixedText->getText(kFixedText_InvDesc3);
Common::String invDesc4 = _fixedText->getText(kFixedText_InvDesc4);
Common::String invDesc5 = _fixedText->getText(kFixedText_InvDesc5);
Common::String invDesc6 = _fixedText->getText(kFixedText_InvDesc6);
Common::String invDesc7 = _fixedText->getText(kFixedText_InvDesc7);
Common::String invDesc8 = _fixedText->getText(kFixedText_InvDesc8);
Common::String solve = _fixedText->getText(kFixedText_Solve);
// Initial inventory
inv._holdings = 5;
inv.push_back(InventoryItem(0, inv1, invDesc1, "_ITEM01A"));
inv.push_back(InventoryItem(0, inv2, invDesc2, "_ITEM02A"));
inv.push_back(InventoryItem(0, inv3, invDesc3, "_ITEM03A"));
inv.push_back(InventoryItem(0, inv4, invDesc4, "_ITEM04A"));
inv.push_back(InventoryItem(0, inv5, invDesc5, "_ITEM05A"));
// Hidden items
inv.push_back(InventoryItem(0, inv6, invDesc6, "_PAP212D", solve));
inv.push_back(InventoryItem(0, inv7, invDesc7, "_PAP212I"));
inv.push_back(InventoryItem(0, inv8, invDesc8, "_LANT02I"));
}
void TattooEngine::drawCredits() {
// TODO
}

View File

@ -51,6 +51,11 @@ private:
* Loads the initial palette for the game
*/
void loadInitialPalette();
/**
* Load the initial inventory
*/
void loadInventory();
protected:
/**
* Initialize the engine

View File

@ -28,12 +28,31 @@ namespace Sherlock {
namespace Tattoo {
static const char *const FIXED_TEXT_ENGLISH[] = {
"Money",
"Card",
"Tobacco",
"Timetable",
"Summons",
"Foolscap",
"Damp Paper",
"Bull's Eye",
"Money",
"Card",
"Tobacco",
"Timetable",
"Summons",
"Foolscap",
"Foolscap",
"Bull's Eye Lantern",
"Open",
"Look",
"Talk",
"Journal",
"Inventory",
"Options"
"Options",
"Solve"
};
TattooFixedText::TattooFixedText(SherlockEngine *vm) : FixedText(vm) {

View File

@ -30,12 +30,29 @@ namespace Sherlock {
namespace Tattoo {
enum FixedTextId {
kFixedText_Inv1,
kFixedText_Inv2,
kFixedText_Inv3,
kFixedText_Inv4,
kFixedText_Inv5,
kFixedText_Inv6,
kFixedText_Inv7,
kFixedText_Inv8,
kFixedText_InvDesc1,
kFixedText_InvDesc2,
kFixedText_InvDesc3,
kFixedText_InvDesc4,
kFixedText_InvDesc5,
kFixedText_InvDesc6,
kFixedText_InvDesc7,
kFixedText_InvDesc8,
kFixedText_Open,
kFixedText_Look,
kFixedText_Talk,
kFixedText_Journal,
kFixedText_Inventory,
kFixedText_Options
kFixedText_Options,
kFixedText_Solve
};
class TattooFixedText: public FixedText {

View File

@ -90,7 +90,7 @@ void WidgetInventory::load(int mode) {
void WidgetInventory::drawInventory() {
Inventory &inv = *_vm->_inventory;
// TODO: Refactor _invIndexinto this widget class
// TODO: Refactor _invIndex into this widget class
for (int idx= 0, itemId = inv._invIndex; idx < NUM_INVENTORY_SHOWN; ++idx) {
// Figure out the drawing position
Common::Point pt(3 + (INVENTORY_XSIZE + 3) * (idx % (NUM_INVENTORY_SHOWN / 2)),
@ -151,9 +151,9 @@ void WidgetInventory::drawScrollBar() {
r.right / 2, r.bottom - 1 - BUTTON_SIZE + 3 + BUTTON_SIZE / 2), color);
// Draw the scroll position bar
int idx= inv._holdings;
if (idx% (NUM_INVENTORY_SHOWN / 2))
idx= (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2)*(NUM_INVENTORY_SHOWN / 2);
int idx = inv._holdings;
if (idx % (NUM_INVENTORY_SHOWN / 2))
idx = (idx + (NUM_INVENTORY_SHOWN / 2)) / (NUM_INVENTORY_SHOWN / 2) * (NUM_INVENTORY_SHOWN / 2);
int barHeight = NUM_INVENTORY_SHOWN * (_bounds.height() - BUTTON_SIZE * 2) / idx;
barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2);

View File

@ -136,7 +136,7 @@ void WidgetVerbs::render() {
_surface.writeString(_verbCommands[idx], Common::Point((_bounds.width() - _surface.stringWidth(_verbCommands[idx])) / 2,
(_surface.fontHeight() + 7) * idx + 5), INFO_TOP);
if (idx < ((int)_verbCommands.size() - 1)) {
if (idx < (_verbCommands.size() - 1)) {
_surface.hLine(3, (_surface.fontHeight() + 7) * (idx + 1), _bounds.width() - 4, INFO_TOP);
_surface.hLine(3, (_surface.fontHeight() + 7) * (idx + 1) + 1, _bounds.width() - 4, INFO_MIDDLE);
_surface.hLine(3, (_surface.fontHeight() + 7) * (idx + 1) + 2, _bounds.width() - 4, INFO_BOTTOM);