diff options
| author | Paul Gilbert | 2014-03-17 23:14:54 -0400 | 
|---|---|---|
| committer | Paul Gilbert | 2014-03-17 23:14:54 -0400 | 
| commit | d494db888e24c04261a46aa89d946ff3c7db3851 (patch) | |
| tree | c294a56d32b8ef001e12b4c969b1216626a5ad40 | |
| parent | 0c8a3a47e28075bd559be43bde910587af35d8ab (diff) | |
| download | scummvm-rg350-d494db888e24c04261a46aa89d946ff3c7db3851.tar.gz scummvm-rg350-d494db888e24c04261a46aa89d946ff3c7db3851.tar.bz2 scummvm-rg350-d494db888e24c04261a46aa89d946ff3c7db3851.zip | |
MADS: Beginnings of code for UI inventory item animation
| -rw-r--r-- | engines/mads/mads.cpp | 2 | ||||
| -rw-r--r-- | engines/mads/mads.h | 2 | ||||
| -rw-r--r-- | engines/mads/sprites.cpp | 4 | ||||
| -rw-r--r-- | engines/mads/user_interface.cpp | 63 | ||||
| -rw-r--r-- | engines/mads/user_interface.h | 12 | 
5 files changed, 70 insertions, 13 deletions
| diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp index 1785ce3f00..781fd7d01d 100644 --- a/engines/mads/mads.cpp +++ b/engines/mads/mads.cpp @@ -39,7 +39,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :  	// Initialise fields  	_easyMouse = true; -	_invObjectStill = false; +	_invObjectsAnimated = true;  	_textWindowStill = false;  	_screenFade = SCREEN_FADE_SMOOTH;  	_musicFlag = false; diff --git a/engines/mads/mads.h b/engines/mads/mads.h index f19abb3889..3152e84f25 100644 --- a/engines/mads/mads.h +++ b/engines/mads/mads.h @@ -100,7 +100,7 @@ public:  	ScreenSurface _screen;  	SoundManager *_sound;  	bool _easyMouse; -	bool _invObjectStill; +	bool _invObjectsAnimated;  	bool _textWindowStill;  	ScreenFade _screenFade;  	bool _musicFlag; diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 18f6a642fd..e519c6966b 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -379,7 +379,9 @@ SpriteSets::~SpriteSets() {  }  int SpriteSets::add(SpriteAsset *asset, int idx) { -	if (!idx) +	if (idx) +		idx = idx + 49; +	else  		idx = size();  	if (idx >= (int)size()) diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index fd9f4c0153..2b5e6c4558 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -30,8 +30,8 @@ namespace MADS {  UISlot::UISlot() {  	_slotType = ST_NONE;  	_field2 = 0; -	_field3 = 0; -	_field4 = 0; +	_spritesIndex = 0; +	_frameNumber = 0;  	_field6 = 0;  	_field8 = 0;  } @@ -46,7 +46,7 @@ void UISlots::fullRefresh() {  	push_back(slot);  } -void UISlots::add(int v1, int v2, int v3, int v4) { +void UISlots::add(int v1, int v2, int frameNumber, int spritesIndex) {  	assert(size() < 50);  	UISlot ie; @@ -54,8 +54,8 @@ void UISlots::add(int v1, int v2, int v3, int v4) {  	ie._field2 = 201;  	ie._field6 = v1;  	ie._field8 = v2; -	ie._field4 = v3; -	ie._field3 = v4; +	ie._frameNumber = frameNumber; +	ie._spritesIndex = spritesIndex;  	push_back(ie);  } @@ -68,6 +68,7 @@ void UISlots::call(int v1, int v2) {  UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {  	_invSpritesIndex = -1; +	_invFrameNumber = 1;  	_category = CAT_NONE;  	_screenObjectsCount = 0;  	_inventoryTopIndex = 0; @@ -432,7 +433,23 @@ void UserInterface::drawTalkList() {  }  void UserInterface::loadInventoryAnim(int objectId) { +	Scene &scene = _vm->_game->_scene; +	noInventoryAnim(); +	bool flag = true; + +	if (_vm->_invObjectsAnimated) { +		Common::String resName = Common::String::format("*OB%.3dI", objectId); +		SpriteAsset *asset = new SpriteAsset(_vm, resName, 8); +		_invSpritesIndex = scene._sprites.add(asset, 1); +		if (_invSpritesIndex >= 0) { +			_invFrameNumber = 1; +			flag = false; +		} +	} +	if (flag) { +		// TODO: Use of inv_object_data? +	}  }  void UserInterface::noInventoryAnim() { @@ -449,9 +466,41 @@ void UserInterface::noInventoryAnim() {  }  void UserInterface::refresh() { +	_uiSlots.clear(); +	_uiSlots.fullRefresh(); +	_uiSlots.call(0, 0); + +	drawTextElements(); +} + +void UserInterface::inventoryAnim() {  	Scene &scene = _vm->_game->_scene; -	scene._userInterface._uiSlots.clear(); -//	scene._userInterface._uiSlots.new() +	if (scene._screenObjects._v832EC == 1 || scene._screenObjects._v832EC == 2 +			|| _invSpritesIndex < 0) +		return; + +	// Move to the next frame number in the sequence, resetting if at the end +	SpriteAsset *asset = scene._sprites[_invSpritesIndex]; +	if (++_invFrameNumber > asset->getCount()) +		_invFrameNumber = 1; + +	// Loop through the slots list for ?? entry +	for (uint i = 0; i < _uiSlots.size(); ++i) { +		if (_uiSlots[i]._field2 == 200) +			_uiSlots[i]._slotType = -5; +	} + +	// Add a new slot entry for the inventory animation +	UISlot slot; +	slot._slotType = ST_FOREGROUND; +	slot._field2 = 200; +	slot._frameNumber = _invFrameNumber; +	slot._spritesIndex = _invSpritesIndex; +	slot._field6 = 160; +	slot._field8 = 3; + +	_uiSlots.push_back(slot);  } +  } // End of namespace MADS diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h index 65c7e1ce55..8b87b4e65d 100644 --- a/engines/mads/user_interface.h +++ b/engines/mads/user_interface.h @@ -40,8 +40,8 @@ class UISlot {  public:  	int _slotType;  	int _field2; -	int _field3; -	int _field4; +	int _spritesIndex; +	int _frameNumber;  	int _field6;  	int _field8; @@ -50,7 +50,7 @@ public:  class UISlots : public Common::Array<UISlot> {  public: -	void add(int v1, int v2, int v3, int v4); +	void add(int v1, int v2, int frameNumber, int spritesIndex);  	void fullRefresh();  	void call(int v1, int v2); @@ -61,6 +61,7 @@ class UserInterface : public MSurface {  private:  	MADSEngine *_vm;  	int _invSpritesIndex; +	int _invFrameNumber;  	/**  	 * Loads the elements of the user interface @@ -108,6 +109,11 @@ private:  	void writeVocab(ScrCategory category, int id);  	void refresh(); + +	/** +	 * Handles queuing a new frame of an inventory animation for drawing +	 */ +	void inventoryAnim();  public:  	ScrCategory _category;  	int _screenObjectsCount; | 
