diff options
Diffstat (limited to 'engines/dm')
-rw-r--r-- | engines/dm/champion.cpp | 74 | ||||
-rw-r--r-- | engines/dm/champion.h | 6 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 8 | ||||
-rw-r--r-- | engines/dm/loadsave.cpp | 2 | ||||
-rw-r--r-- | engines/dm/movesens.cpp | 2 |
5 files changed, 83 insertions, 9 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index d2df2ac022..1d9e19ed9a 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -122,6 +122,10 @@ void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int1 _vm->_textMan->printToViewport(79, posY, kColorLightestGray, tmp.c_str());
}
+uint16 ChampionMan::handSlotIndex(uint16 slotBoxIndex) {
+ return slotBoxIndex & 0x1;
+}
+
Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
using namespace Common;
String valToStr = String::format("%d", val);
@@ -288,6 +292,74 @@ bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) return false;
}
+void ChampionMan::drawChangedObjectIcons() {
+ InventoryMan &invMan = *_vm->_inventoryMan;
+ ObjectMan &objMan = *_vm->_objectMan;
+ MenuMan &menuMan = *_vm->_menuMan;
+
+ uint16 invChampOrdinal = invMan._inventoryChampionOrdinal;
+ if (_candidateChampionOrdinal && !invChampOrdinal)
+ return;
+
+ _mousePointerHiddenToDrawChangedObjIconOnScreen = false;
+ IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex;
+
+ if (((leaderHandObjIconIndex < kIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kIconIndiceJunkCompassNorth)) // < instead of <= is correct
+ || ((leaderHandObjIconIndex >= kIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kIconIndicePotionWaterFlask))
+ || (leaderHandObjIconIndex == kIconIndicePotionEmptyFlask)) {
+ IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
+ if (iconIndex != leaderHandObjIconIndex) {
+ _mousePointerHiddenToDrawChangedObjIconOnScreen = true;
+ warning("MISSING CODE: F0077_MOUSE_HidePointer_CPSE");
+ objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer);
+ warning("MISSING CODE: F0068_MOUSE_SetPointerToObject");
+ _leaderHandObjectIconIndex = iconIndex;
+ objMan.drawLeaderObjectName(_leaderHandObject);
+ }
+ }
+
+ for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
+ int16 champIndex = slotBoxIndex >> 1;
+ if(invChampOrdinal == _vm->indexToOrdinal(champIndex))
+ continue;
+
+ if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)handSlotIndex(slotBoxIndex)))
+ && (handSlotIndex(slotBoxIndex) == kChampionSlotActionHand)) {
+
+ menuMan.drawActionIcon((ChampionIndex)champIndex);
+ }
+ }
+
+ if (invChampOrdinal) {
+ Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
+ Thing *thing = &champ->getSlot(kChampionSlotReadyHand);
+ uint16 drawViewport = 0;
+
+ for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++, thing++) {
+ uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
+ drawViewport |= objIconChanged;
+ if (objIconChanged && (slotIndex == kChampionSlotActionHand)) {
+ menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+ }
+ }
+
+ if (invMan._panelContent = kPanelContentChest) {
+ thing = invMan._chestSlots;
+ for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
+ drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + kSlotBoxChestFirstSlot, *thing) ? 1 : 0);
+ }
+ }
+
+ if (drawViewport) {
+ champ->setAttributeFlag(kChampionAttributeViewport, true);
+ drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
+ }
+ }
+
+ if (_mousePointerHiddenToDrawChangedObjIconOnScreen)
+ warning("MISSING CODE: F0078_MOUSE_ShowPointer");
+}
+
ChampionIndex ChampionMan::getIndexInCell(ViewCell cell) {
for (uint16 i = 0; i < _partyChampionCount; ++i) {
if ((_champions[i]._cell == cell) && _champions[i]._currHealth)
@@ -303,7 +375,7 @@ void ChampionMan::resetDataToStartGame() { assert(false);
}
- _leaderHand = Thing::_thingNone;
+ _leaderHandObject = Thing::_thingNone;
_leaderHandObjectIconIndex = kIconIndiceNone;
_leaderEmptyHanded = true;
}
diff --git a/engines/dm/champion.h b/engines/dm/champion.h index a85ab57537..f3a411646d 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -365,7 +365,7 @@ public: int16 _shieldDefense; byte _portrait[464]; // 32 x 29 pixel portrait - Thing getSlot(ChampionSlot slot) { return _slots[slot]; } + Thing &getSlot(ChampionSlot slot) { return _slots[slot]; } void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } Skill &getSkill(ChampionSkill skill) { return _skills[skill]; } @@ -430,11 +430,12 @@ class ChampionMan { ChampionIndex getIndexInCell(ViewCell cell); // @ F0285_CHAMPION_GetIndexInCell int16 getDecodedValue(char *string, uint16 characterCount); // @ F0279_CHAMPION_GetDecodedValue void drawHealthOrStaminaOrManaValue(int16 posy, int16 currVal, int16 maxVal); // @ F0289_CHAMPION_DrawHealthOrStaminaOrManaValue + uint16 handSlotIndex(uint16 slotBoxIndex);// @ M70_HAND_SLOT_INDEX public: Champion _champions[4]; uint16 _partyChampionCount; // @ G0305_ui_PartyChampionCount bool _partyDead; // @ G0303_B_PartyDead - Thing _leaderHand; // @ G0414_T_LeaderHandObject + Thing _leaderHandObject; // @ G0414_T_LeaderHandObject ChampionIndex _leaderIndex; // @ G0411_i_LeaderIndex uint16 _candidateChampionOrdinal; // @ G0299_ui_CandidateChampionOrdinal bool _partyIsSleeping; // @ G0300_B_PartyIsSleeping @@ -461,6 +462,7 @@ public: void applyModifiersToStatistics(Champion *champ, ChampionSlot slotIndex, IconIndice iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics bool hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing); // @ F0295_CHAMPION_HasObjectIconInSlotBoxChanged + void drawChangedObjectIcons(); // @ F0296_CHAMPION_DrawChangedObjectIcons }; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index 5c9e68bc05..20c2888aec 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -486,7 +486,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { leaderIndex = cm._leaderIndex; cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeLoad, true); cm._champions[leaderIndex].setAttributeFlag(kChampionAttributeNameTitle, true); - cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + cm._champions[leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject); cm._leaderIndex = kChampionNone; cm.drawChampionState(leaderIndex); } @@ -497,7 +497,7 @@ void EventManager::commandSetLeader(ChampionIndex champIndex) { cm._leaderIndex = champIndex; Champion *champion = &cm._champions[cm._leaderIndex]; champion->_dir = _vm->_dungeonMan->_currMap._partyDir; - cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHand); + cm._champions[champIndex]._load += _vm->_dungeonMan->getObjectWeight(cm._leaderHandObject); if (_vm->indexToOrdinal(champIndex) != cm._candidateChampionOrdinal) { champion->setAttributeFlag(kChampionAttributeIcon, true); champion->setAttributeFlag(kChampionAttributeNameTitle, true); @@ -554,7 +554,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } } } else { - Thing thing = champMan._leaderHand; + Thing thing = champMan._leaderHandObject; uint16 *rawThingPointer = dunMan.getThingData(thing); if (dunMan._squareAheadElement == kElementTypeWall) { for (int16 viewCell = kViewCellFronLeft; viewCell <= kViewCellFrontRight; ++viewCell) { @@ -578,7 +578,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY } else { goto T0377019; } - warning("MISSING CODE: F0296_CHAMPION_DrawChangedObjectIcons"); + champMan.drawChangedObjectIcons(); champMan._champions[champMan._leaderIndex]._load += dunMan.getObjectWeight(thing) - weight; } T0377019: diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 0251e8b0f2..7ac9283a17 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -43,7 +43,7 @@ LoadgameResponse LoadsaveMan::loadgame() { if (newGame) { _vm->_restartGameAllowed = false; cm._partyChampionCount = 0; - cm._leaderHand = Thing::_thingNone; + cm._leaderHandObject = Thing::_thingNone; _vm->_gameId = _vm->_rnd->getRandomNumber(65536) * _vm->_rnd->getRandomNumber(65536); } else { assert(false); diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 2c25251761..8a833a37c3 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -44,7 +44,7 @@ bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 bool atLeastOneSensorWasTriggered = false; - Thing leaderHandObject = champMan._leaderHand; + Thing leaderHandObject = champMan._leaderHandObject; int16 sensorCountToProcessPerCell[4]; uint16 cell; for (cell = kCellNorthWest; cell < kCellSouthWest; ++cell) { |