[Scummvm-cvs-logs] SF.net SVN: scummvm:[39773] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Tue Mar 31 17:45:56 CEST 2009
Revision: 39773
http://scummvm.svn.sourceforge.net/scummvm/?rev=39773&view=rev
Author: peres001
Date: 2009-03-31 15:45:44 +0000 (Tue, 31 Mar 2009)
Log Message:
-----------
Added basic multiple inventory support. This will be used for the GIVE and SWAP commands.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/inventory.cpp
scummvm/trunk/engines/parallaction/inventory.h
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parallaction_br.cpp
scummvm/trunk/engines/parallaction/parallaction_ns.cpp
Modified: scummvm/trunk/engines/parallaction/inventory.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.cpp 2009-03-31 14:35:06 UTC (rev 39772)
+++ scummvm/trunk/engines/parallaction/inventory.cpp 2009-03-31 15:45:44 UTC (rev 39773)
@@ -102,56 +102,31 @@
}
int Parallaction::addInventoryItem(ItemName item) {
- return _inventory->addItem(item);
+ return getActiveInventory()->addItem(item);
}
int Parallaction::addInventoryItem(ItemName item, uint32 value) {
- return _inventory->addItem(item, value);
+ return getActiveInventory()->addItem(item, value);
}
void Parallaction::dropItem(uint16 v) {
- _inventory->removeItem(v);
+ getActiveInventory()->removeItem(v);
}
bool Parallaction::isItemInInventory(int32 v) {
- return (_inventory->findItem(v) != -1);
+ return (getActiveInventory()->findItem(v) != -1);
}
const InventoryItem* Parallaction::getInventoryItem(int16 pos) {
- return _inventory->getItem(pos);
+ return getActiveInventory()->getItem(pos);
}
int16 Parallaction::getInventoryItemIndex(int16 pos) {
- return _inventory->getItemName(pos);
+ return getActiveInventory()->getItemName(pos);
}
-void Parallaction::initInventory() {
- InventoryProperties *props;
- InventoryItem *verbs;
-
- if (getGameType() == GType_Nippon) {
- props = &_invProps_NS;
- verbs = _verbs_NS;
- } else {
- props = &_invProps_BR;
- verbs = _verbs_BR;
- }
-
- _inventory = new Inventory(props, verbs);
- _inventoryRenderer = new InventoryRenderer(this, props);
- _inventoryRenderer->bindInventory(_inventory);
-}
-
-void Parallaction::destroyInventory() {
- delete _inventory;
- delete _inventoryRenderer;
-
- _inventory = 0;
- _inventoryRenderer = 0;
-}
-
void Parallaction::cleanInventory(bool keepVerbs) {
- _inventory->clear(keepVerbs);
+ getActiveInventory()->clear(keepVerbs);
}
void Parallaction::openInventory() {
@@ -361,7 +336,47 @@
return &_items[pos];
}
+Inventory *Parallaction::getActiveInventory() {
+ return _inventoryRenderer->getBoundInventory();
+}
+void Parallaction_ns::initInventory() {
+ _inventory = new Inventory(&_invProps_NS, _verbs_NS);
+ assert(_inventory);
+ _inventoryRenderer = new InventoryRenderer(this, &_invProps_NS);
+ assert(_inventoryRenderer);
+ _inventoryRenderer->bindInventory(_inventory);
+}
+
+void Parallaction_br::initInventory() {
+ for (int i = 0; i < 3; ++i) {
+ _inventory[i] = new Inventory(&_invProps_BR, _verbs_BR);
+ assert(_inventory[i]);
+ }
+ _inventoryRenderer = new InventoryRenderer(this, &_invProps_BR);
+ assert(_inventoryRenderer);
+ // don't bind here, wait for changeCharacter()
+}
+
+void Parallaction_ns::destroyInventory() {
+ delete _inventoryRenderer;
+ delete _inventory;
+ _inventory = 0;
+ _inventoryRenderer = 0;
+}
+
+void Parallaction_br::destroyInventory() {
+ delete _inventoryRenderer;
+ delete _inventory[0];
+ delete _inventory[1];
+ delete _inventory[2];
+ _inventory[0] = 0;
+ _inventory[1] = 0;
+ _inventory[2] = 0;
+ _inventoryRenderer = 0;
+}
+
+
} // namespace Parallaction
Modified: scummvm/trunk/engines/parallaction/inventory.h
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.h 2009-03-31 14:35:06 UTC (rev 39772)
+++ scummvm/trunk/engines/parallaction/inventory.h 2009-03-31 15:45:44 UTC (rev 39773)
@@ -105,6 +105,7 @@
virtual ~InventoryRenderer();
void bindInventory(Inventory *inv) { _inv = inv; }
+ Inventory *getBoundInventory() const { return _inv; }
void showInventory();
void hideInventory();
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2009-03-31 14:35:06 UTC (rev 39772)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2009-03-31 15:45:44 UTC (rev 39773)
@@ -93,8 +93,6 @@
delete _balloonMan;
_balloonMan = 0;
- destroyInventory();
-
delete _localFlagNames;
delete _gfx;
delete _soundMan;
@@ -124,8 +122,6 @@
memset(_locationNames, 0, NUM_LOCATIONS * 32);
- initInventory(); // needs to be pushed into subclass
-
// this needs _disk to be already setup
_input = new Input(this);
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2009-03-31 14:35:06 UTC (rev 39772)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2009-03-31 15:45:44 UTC (rev 39773)
@@ -296,7 +296,6 @@
Table *_localFlagNames;
CommandExec *_cmdExec;
ProgramExec *_programExec;
- Inventory *_inventory;
BalloonManager *_balloonMan;
DialogueManager *_dialogueMan;
InventoryRenderer *_inventoryRenderer;
@@ -366,11 +365,10 @@
bool isItemInInventory(int32 v);
const InventoryItem* getInventoryItem(int16 pos);
int16 getInventoryItemIndex(int16 pos);
- void initInventory();
- void destroyInventory();
void cleanInventory(bool keepVerbs = true);
void openInventory();
void closeInventory();
+ Inventory *getActiveInventory();
virtual void parseLocation(const char* name) = 0;
virtual void changeLocation() = 0;
@@ -406,7 +404,6 @@
virtual void cleanupGame();
virtual void updateWalkers();
virtual void scheduleWalk(int16 x, int16 y, bool fromUser);
-
virtual DialogueManager *createDialogueManager(ZonePtr z);
void switchBackground(const char* background, const char* mask);
@@ -415,11 +412,14 @@
bool _inTestResult;
LocationParser_ns *_locationParser;
ProgramParser_ns *_programParser;
+ Inventory *_inventory;
private:
void initFonts();
void freeFonts();
void initResources();
+ void initInventory();
+ void destroyInventory();
void startGui();
void startCreditSequence();
void startEndPartSequence();
@@ -536,12 +536,15 @@
LocationParser_br *_locationParser;
ProgramParser_br *_programParser;
SoundMan_br *_soundManI;
+ Inventory *_inventory[3];
int32 _counters[32];
Table *_countersNames;
private:
void initResources();
+ void initInventory();
+ void destroyInventory();
void initFonts();
void freeFonts();
void freeLocation(bool removeAll);
Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp 2009-03-31 14:35:06 UTC (rev 39772)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp 2009-03-31 15:45:44 UTC (rev 39773)
@@ -96,6 +96,8 @@
_saveLoad = new SaveLoad_br(this, _saveFileMan);
+ initInventory();
+
Parallaction::init();
return Common::kNoError;
@@ -105,6 +107,8 @@
freeFonts();
freeCharacter();
+ destroyInventory();
+
delete _objects;
delete _locationParser;
@@ -406,6 +410,9 @@
_char.setName(name);
_char._ani->gfxobj = _gfx->loadCharacterAnim(name);
_char._talk = _disk->loadTalk(name);
+
+ // TODO: select the inventory according to character
+ _inventoryRenderer->bindInventory(_inventory[0]);
}
_char._ani->_flags |= kFlagsActive;
@@ -515,4 +522,5 @@
}
}
+
} // namespace Parallaction
Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2009-03-31 14:35:06 UTC (rev 39772)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp 2009-03-31 15:45:44 UTC (rev 39773)
@@ -202,6 +202,8 @@
_saveLoad = new SaveLoad_ns(this, _saveFileMan);
+ initInventory();
+
Parallaction::init();
return Common::kNoError;
@@ -211,6 +213,8 @@
freeFonts();
freeCharacter();
+ destroyInventory();
+
delete _locationParser;
delete _programParser;
freeLocation(true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list