diff options
| author | Paul Gilbert | 2015-02-10 08:42:59 -0500 | 
|---|---|---|
| committer | Paul Gilbert | 2015-02-10 08:42:59 -0500 | 
| commit | 8256f7c8dfcdefe7da352fd36b42dc0931a111f8 (patch) | |
| tree | 6b6116c9421503019c8deee7ed84deec32585c50 | |
| parent | a612dd686c27303bdbe6b2dba89aef79bc8db8e0 (diff) | |
| download | scummvm-rg350-8256f7c8dfcdefe7da352fd36b42dc0931a111f8.tar.gz scummvm-rg350-8256f7c8dfcdefe7da352fd36b42dc0931a111f8.tar.bz2 scummvm-rg350-8256f7c8dfcdefe7da352fd36b42dc0931a111f8.zip | |
XEEN: Refacored face sprites loading into Roster and Character classes
| -rw-r--r-- | engines/xeen/character.cpp | 2 | ||||
| -rw-r--r-- | engines/xeen/character.h | 3 | ||||
| -rw-r--r-- | engines/xeen/dialogs_dismiss.cpp | 1 | ||||
| -rw-r--r-- | engines/xeen/dialogs_exchange.cpp | 1 | ||||
| -rw-r--r-- | engines/xeen/dialogs_party.cpp | 83 | ||||
| -rw-r--r-- | engines/xeen/dialogs_party.h | 5 | ||||
| -rw-r--r-- | engines/xeen/interface.cpp | 23 | ||||
| -rw-r--r-- | engines/xeen/interface.h | 3 | ||||
| -rw-r--r-- | engines/xeen/party.cpp | 18 | ||||
| -rw-r--r-- | engines/xeen/party.h | 4 | ||||
| -rw-r--r-- | engines/xeen/resources.cpp | 6 | ||||
| -rw-r--r-- | engines/xeen/resources.h | 1 | ||||
| -rw-r--r-- | engines/xeen/xeen.cpp | 1 | 
13 files changed, 74 insertions, 77 deletions
| diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index fb1447d84c..dc193f45be 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -734,6 +734,8 @@ void Character::clear() {  	_armor.clear();  	_accessories.clear();  	_misc.clear(); + +	_faceSprites = nullptr;  }  void Character::synchronize(Common::Serializer &s) { diff --git a/engines/xeen/character.h b/engines/xeen/character.h index 7fc13f1015..53dee33980 100644 --- a/engines/xeen/character.h +++ b/engines/xeen/character.h @@ -28,6 +28,7 @@  #include "common/rect.h"  #include "common/serializer.h"  #include "xeen/combat.h" +#include "xeen/sprites.h"  namespace Xeen { @@ -257,6 +258,8 @@ public:  	uint32 _experience;  	int _currentAdventuringSpell;  	int _currentCombatSpell; + +	SpriteResource *_faceSprites;  public:  	Character(); diff --git a/engines/xeen/dialogs_dismiss.cpp b/engines/xeen/dialogs_dismiss.cpp index 304c7a0cef..c387c28019 100644 --- a/engines/xeen/dialogs_dismiss.cpp +++ b/engines/xeen/dialogs_dismiss.cpp @@ -72,7 +72,6 @@ void Dismiss::execute() {  				} else {  					Character tempChar = party._activeParty[_buttonValue];  					int charIndex = party._partyMembers[_buttonValue]; -					intf._partyFaces[_buttonValue] = 0;  					intf.sortFaces();  //					party.sortParty(); diff --git a/engines/xeen/dialogs_exchange.cpp b/engines/xeen/dialogs_exchange.cpp index 56a310a928..c6a4522c88 100644 --- a/engines/xeen/dialogs_exchange.cpp +++ b/engines/xeen/dialogs_exchange.cpp @@ -54,7 +54,6 @@ void ExchangeDialog::execute(Character *&c, int &charIndex) {  			if (_buttonValue < party._partyCount) {  				SWAP(party._activeParty[charIndex], party._activeParty[_buttonValue]);  				SWAP(party._partyMembers[charIndex], party._partyMembers[_buttonValue]); -				SWAP(intf._partyFaces[charIndex], intf._partyFaces[_buttonValue]);  				charIndex = _buttonValue;  				c = &party._activeParty[charIndex]; diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp index 3da4a2ae3a..c8689f0656 100644 --- a/engines/xeen/dialogs_party.cpp +++ b/engines/xeen/dialogs_party.cpp @@ -21,6 +21,7 @@   */  #include "common/scummsys.h" +#include "xeen/dialogs_char_info.h"  #include "xeen/dialogs_party.h"  #include "xeen/character.h"  #include "xeen/events.h" @@ -41,6 +42,7 @@ void PartyDialog::execute() {  	Party &party = *_vm->_party;  	Screen &screen = *_vm->_screen;  	bool modeFlag = false; +	int startingChar = 0;  	loadButtons();  	setupBackground(); @@ -62,7 +64,7 @@ void PartyDialog::execute() {  		Window &w = screen._windows[11];  		w.open(); -		setupFaces(0, xeenSideChars, false); +		setupFaces(startingChar, xeenSideChars, false);  		w.writeString(_displayText);  		w.drawList(&_faceDrawStructs[0], 4); @@ -122,18 +124,30 @@ void PartyDialog::execute() {  					party.copyPartyToRoster();  					_vm->_saves->writeCharFile(); -					breakFlag = true; -					break; +					return;  				}  				break; -			case Common::KEYCODE_1: + +			case Common::KEYCODE_F1: +			case Common::KEYCODE_F2: +			case Common::KEYCODE_F3: +			case Common::KEYCODE_F4: +			case Common::KEYCODE_F5: +			case Common::KEYCODE_F6: +				// Show character info +				_buttonValue -= Common::KEYCODE_F1; +				if (_buttonValue < party._partyCount) +					CharacterInfo::show(_vm, _buttonValue);  				break; + +			case Common::KEYCODE_1:  			case Common::KEYCODE_2: -				break;  			case Common::KEYCODE_3: -				break;  			case Common::KEYCODE_4: +				_buttonValue -= Common::KEYCODE_1 - 7; +				// TODO  				break; +  			case Common::KEYCODE_c:  				if (xeenSideChars.size() == 24) {  					ErrorScroll::show(_vm, YOUR_ROSTER_IS_FULL); @@ -154,28 +168,17 @@ void PartyDialog::execute() {  					// TODO  				}  				break; -			case 201: -				// TODO -				break; -			case 202: -				// TODO -				break; -			case 203: -				// TODO -				break; -			case 204: -				// TODO -				break; -			case 205: -				// TODO -				break; -			case 206: -				// TODO -				break; -			case 242: + +			case Common::KEYCODE_UP: +			case Common::KEYCODE_KP8: +				if (startingChar > 0) { +					startingChar -= 4; +					startingCharChanged(xeenSideChars, startingChar); +				}  				// TODO  				break; -			case 243: +			case Common::KEYCODE_DOWN: +			case Common::KEYCODE_KP2:  				// TODO  				break;  			default: @@ -215,7 +218,7 @@ void PartyDialog::setupBackground() {  /**   * Sets up the faces for display in the party dialog   */ -void PartyDialog::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bool updateFlag) { +void PartyDialog::setupFaces(int firstDisplayChar, Common::Array<int> xeenSideChars, bool updateFlag) {  	Party &party = *_vm->_party;  	Resources &res = *_vm->_resources;  	Common::String charNames[4]; @@ -226,10 +229,11 @@ void PartyDialog::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bo  	int charId;  	for (posIndex = 0; posIndex < 4; ++posIndex) { -		charId = xeenSideChars[charIndex]; +		charId = (firstDisplayChar + posIndex) >= xeenSideChars.size() ? -1 : +			xeenSideChars[firstDisplayChar + posIndex];  		bool isInParty = party.isInParty(charId); -		if (charId == 0xff) { +		if (charId == -1) {  			while ((int)_buttons.size() >(7 + posIndex))  				_buttons.remove_at(_buttons.size() - 1);  			break; @@ -237,7 +241,7 @@ void PartyDialog::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bo  		Common::Rect &b = _buttons[7 + posIndex]._bounds;  		b.moveTo((posIndex & 1) ? 117 : 16, b.top); -		Character &ps = party._roster[xeenSideChars[charIndex + posIndex]]; +		Character &ps = party._roster[xeenSideChars[firstDisplayChar + posIndex]];  		charNames[posIndex] = isInParty ? IN_PARTY : ps._name;  		charRaces[posIndex] = RACE_NAMES[ps._race];  		charSex[posIndex] = SEX_NAMES[ps._sex]; @@ -247,14 +251,12 @@ void PartyDialog::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bo  	charIconsPrint(updateFlag);  	// Set up the sprite set to use for each face -	charId = xeenSideChars[charIndex]; -	_faceDrawStructs[0]._sprites = (charId == 0xff) ? (SpriteResource *)nullptr : &res._charFaces[charId]; -	charId = xeenSideChars[charIndex + 1]; -	_faceDrawStructs[1]._sprites = (charId == 0xff) ? (SpriteResource *)nullptr : &res._charFaces[charId]; -	charId = xeenSideChars[charIndex + 2]; -	_faceDrawStructs[2]._sprites = (charId == 0xff) ? (SpriteResource *)nullptr : &res._charFaces[charId]; -	charId = xeenSideChars[charIndex + 3]; -	_faceDrawStructs[3]._sprites = (charId == 0xff) ? (SpriteResource *)nullptr : &res._charFaces[charId]; +	for (int posIndex = 0; posIndex < 4; ++posIndex) { +		if ((firstDisplayChar + posIndex) >= xeenSideChars.size()) +			_faceDrawStructs[posIndex]._sprites = nullptr; +		else +			_faceDrawStructs[posIndex]._sprites = party._roster[posIndex]._faceSprites; +	}  	_displayText = Common::String::format(PARTY_DETAILS,  		charNames[0].c_str(), charRaces[0].c_str(), charSex[0].c_str(), charClasses[0].c_str(), @@ -264,4 +266,9 @@ void PartyDialog::setupFaces(int charIndex, Common::Array<int> xeenSideChars, bo  		);  } +void PartyDialog::startingCharChanged(Common::Array<int> &charList, int firstDisplayChar) { +	Party &party = *_vm->_party; + +} +  } // End of namespace Xeen diff --git a/engines/xeen/dialogs_party.h b/engines/xeen/dialogs_party.h index c2768e9994..4450f3f6cd 100644 --- a/engines/xeen/dialogs_party.h +++ b/engines/xeen/dialogs_party.h @@ -23,6 +23,7 @@  #ifndef XEEN_DIALOGS_PARTY_H  #define XEEN_DIALOGS_PARTY_H +#include "common/array.h"  #include "xeen/dialogs.h"  #include "xeen/screen.h"  #include "xeen/sprites.h" @@ -48,7 +49,9 @@ private:  	void charIconsPrint(bool updateFlag); -	void setupFaces(int charIndex, Common::Array<int> xeenSideChars, bool updateFlag); +	void setupFaces(int firstDisplayChar, Common::Array<int> xeenSideChars, bool updateFlag); + +	void startingCharChanged(Common::Array<int> &charList, int firstDisplayChar);  public:  	static void show(XeenEngine *vm);  }; diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index 13a12f085a..15f19c57be 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -34,7 +34,6 @@  namespace Xeen {  Interface::Interface(XeenEngine *vm) : ButtonContainer(), InterfaceMap(vm), _vm(vm) { -	Common::fill(&_partyFaces[0], &_partyFaces[MAX_ACTIVE_PARTY], (SpriteResource *)nullptr);  	_buttonsLoaded = false;  	_hiliteChar = -1;  	_intrIndex1 = 0; @@ -76,14 +75,6 @@ void Interface::setup() {  	party._newDay = party._minutes >= 300;  } -void Interface::loadPartyIcons() { -	Party &party = *_vm->_party; -	Resources &res = *_vm->_resources; - -	for (int i = 0; i < party._partyCount; ++i) -		_partyFaces[i] = &res._charFaces[_vm->_party->_partyMembers[i]]; -} -  void Interface::charIconsPrint(bool updateFlag) {  	Screen &screen = *_vm->_screen;  	bool stateFlag = _vm->_mode == MODE_COMBAT; @@ -97,7 +88,7 @@ void Interface::charIconsPrint(bool updateFlag) {  		Condition charCondition = ps.worstCondition();  		int charFrame = FACE_CONDITION_FRAMES[charCondition]; -		SpriteResource *sprites = (charFrame > 4) ? &_dseFace : _partyFaces[charIndex]; +		SpriteResource *sprites = (charFrame > 4) ? &_dseFace : ps._faceSprites;  		if (charFrame > 4)  			charFrame -= 5; @@ -139,17 +130,7 @@ void Interface::charIconsPrint(bool updateFlag) {   * Removes any empty character entries from the faces list   */  void Interface::sortFaces() { -	for (uint charIdx = 0; charIdx < MAX_ACTIVE_PARTY; ++charIdx) { -		if (!_partyFaces[charIdx]) { -			for (uint charIdx2 = charIdx + 1; charIdx2 < 8; ++charIdx2) { -				if (_partyFaces[charIdx2]) { -					_partyFaces[charIdx] = _partyFaces[charIdx2]; -					_partyFaces[charIdx2] = 0; -					break; -				} -			} -		} -	} +	// No implementation needed  }  void Interface::startup() { diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index 3d496aa2b1..7dc1b53170 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -69,7 +69,6 @@ private:  public:  	int _intrIndex1;  	Common::String _interfaceText; -	SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];  public:  	Interface(XeenEngine *vm); @@ -79,8 +78,6 @@ public:  	void manageCharacters(bool soundPlayed); -	void loadPartyIcons(); -  	void startup();  	void mainIconsPrint(); diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 6bff8fd995..e0110856a6 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -32,10 +32,22 @@  namespace Xeen { -void Roster::synchronize(Common::Serializer &s) { -	if (s.isLoading()) -		resize(30); +Roster::Roster() { +	resize(TOTAL_CHARACTERS); + +	for (int idx = 0; idx < TOTAL_CHARACTERS; ++idx) { +		if (idx < XEEN_TOTAL_CHARACTERS) { +			// Load new character resource +			Common::String name = Common::String::format("char%02d.fac", idx + 1); +			_charFaces[idx].load(name); +			operator[](idx)._faceSprites = &_charFaces[idx]; +		} else { +			operator[](idx)._faceSprites = nullptr; +		} +	} +} +void Roster::synchronize(Common::Serializer &s) {  	for (uint i = 0; i < 30; ++i)  		(*this)[i].synchronize(s);  } diff --git a/engines/xeen/party.h b/engines/xeen/party.h index c37a673ee5..a91b398931 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -50,7 +50,9 @@ enum Difficulty { ADVENTURER = 0, WARRIOR = 1 };  class Roster: public Common::Array<Character> {  public: -	Roster() {} +	SpriteResource _charFaces[TOTAL_CHARACTERS]; +public: +	Roster();  	void synchronize(Common::Serializer &s);  }; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 7067886c87..11b209274d 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -31,12 +31,6 @@ Resources::Resources() {  	while (f.pos() < f.size())  		_maeNames.push_back(f.readString());  	f.close(); - -	for (int i = 0; i < XEEN_TOTAL_CHARACTERS; ++i) { -		// Load new character resource -		Common::String name = Common::String::format("char%02d.fac", i + 1); -		_charFaces[i].load(name); -	}  }  /*------------------------------------------------------------------------*/ diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index dd3a77504a..de99c984eb 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -35,7 +35,6 @@ class Resources {  public:  	// Magic and equipment names  	Common::StringArray _maeNames; -	SpriteResource _charFaces[TOTAL_CHARACTERS];  public:  	Resources();  }; diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp index 3c2b7a2c77..e0a2bebacd 100644 --- a/engines/xeen/xeen.cpp +++ b/engines/xeen/xeen.cpp @@ -295,7 +295,6 @@ void XeenEngine::play() {  	_interface->setup();  	_screen->loadBackground("back.raw");  	_screen->loadPalette("mm4.pal"); -	_interface->loadPartyIcons();  	if (getGameID() != GType_WorldOfXeen && !_map->_loadDarkSide) {  		_map->_loadDarkSide = true; | 
