diff options
author | Strangerke | 2016-09-03 12:33:51 +0200 |
---|---|---|
committer | Strangerke | 2016-09-03 13:13:50 +0200 |
commit | 2fec2241e446b19baf2f3a4bb09bc4ba10ec6a13 (patch) | |
tree | a09a196379528e6b756d60c4062f5748b8f12772 | |
parent | d059a1cd4b7491e04d10af728ae55a74f0d5035c (diff) | |
download | scummvm-rg350-2fec2241e446b19baf2f3a4bb09bc4ba10ec6a13.tar.gz scummvm-rg350-2fec2241e446b19baf2f3a4bb09bc4ba10ec6a13.tar.bz2 scummvm-rg350-2fec2241e446b19baf2f3a4bb09bc4ba10ec6a13.zip |
DM: More renaming and refactoring in InventoryMan
-rw-r--r-- | engines/dm/inventory.cpp | 159 |
1 files changed, 74 insertions, 85 deletions
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 516bc467dc..4320374707 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -786,105 +786,95 @@ void InventoryMan::setDungeonViewPalette() { } void InventoryMan::decreaseTorchesLightPower() { - bool L1048_B_TorchChargeCountChanged = false; - int16 L1046_i_ChampionCount = _vm->_championMan->_partyChampionCount; - if (_vm->_championMan->_candidateChampionOrdinal) { - L1046_i_ChampionCount--; - } - Champion *L1050_ps_Champion = _vm->_championMan->_champions; - while (L1046_i_ChampionCount--) { - int16 L1047_i_SlotIndex = k1_ChampionSlotActionHand + 1; - while (L1047_i_SlotIndex--) { - int16 L1049_i_IconIndex = _vm->_objectMan->getIconIndex(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); - if ((L1049_i_IconIndex >= k4_IconIndiceWeaponTorchUnlit) && (L1049_i_IconIndex <= k7_IconIndiceWeaponTorchLit)) { - Weapon *L1051_ps_Weapon = (Weapon *)_vm->_dungeonMan->getThingData(L1050_ps_Champion->_slots[L1047_i_SlotIndex]); - if (L1051_ps_Weapon->getChargeCount()) { - if (L1051_ps_Weapon->setChargeCount(L1051_ps_Weapon->getChargeCount() - 1) == 0) { - L1051_ps_Weapon->setDoNotDiscard(false); + bool torchChargeCountChanged = false; + int16 championCount = _vm->_championMan->_partyChampionCount; + if (_vm->_championMan->_candidateChampionOrdinal) + championCount--; + + Champion *curChampion = _vm->_championMan->_champions; + while (championCount--) { + int16 slotIndex = k1_ChampionSlotActionHand + 1; + while (slotIndex--) { + int16 iconIndex = _vm->_objectMan->getIconIndex(curChampion->_slots[slotIndex]); + if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit) && (iconIndex <= k7_IconIndiceWeaponTorchLit)) { + Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[slotIndex]); + if (curWeapon->getChargeCount()) { + if (curWeapon->setChargeCount(curWeapon->getChargeCount() - 1) == 0) { + curWeapon->setDoNotDiscard(false); } - L1048_B_TorchChargeCountChanged = true; + torchChargeCountChanged = true; } } } - L1050_ps_Champion++; + curChampion++; } - if (L1048_B_TorchChargeCountChanged) { + + if (torchChargeCountChanged) { setDungeonViewPalette(); _vm->_championMan->drawChangedObjectIcons(); } } void InventoryMan::drawChampionSkillsAndStatistics() { + static const char* statisticNamesEN[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"}; + static const char* statisticNamesDE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"}; + static const char* statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"}; + + const char **statisticNames; - uint16 L1090_ui_Multiple; -#define AL1090_ui_SkillIndex L1090_ui_Multiple -#define AL1090_ui_StatisticIndex L1090_ui_Multiple - int16 L1091_i_Y; - int16 L1092_i_Multiple; -#define AL1092_i_SkillLevel L1092_i_Multiple -#define AL1092_i_StatisticCurrentValue L1092_i_Multiple - uint16 L1093_ui_ChampionIndex; - Champion* L1094_ps_Champion; - int16 L1095_i_StatisticColor; - uint16 L1096_ui_StatisticMaximumValue; - char L1097_ac_String[20]; - - static const char* G0431_apc_StatisticNames_EN_ANY[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"}; - static const char* G0431_apc_StatisticNames_DE_DEU[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"}; - static const char* G0431_apc_StatisticNames_FR_FRA[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"}; - const char **G0431_apc_StatisticNames; switch (_vm->getGameLanguage()) { // localized + case Common::DE_DEU: + statisticNames = statisticNamesDE; + break; + case Common::FR_FRA: + statisticNames = statisticNamesFR; + break; default: - case Common::EN_ANY: G0431_apc_StatisticNames = G0431_apc_StatisticNames_EN_ANY; break; - case Common::DE_DEU: G0431_apc_StatisticNames = G0431_apc_StatisticNames_DE_DEU; break; - case Common::FR_FRA: G0431_apc_StatisticNames = G0431_apc_StatisticNames_FR_FRA; break; + statisticNames = statisticNamesEN; + break; } closeChest(); - L1094_ps_Champion = &_vm->_championMan->_champions[L1093_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal)]; + uint16 championIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal); + Champion *curChampion = &_vm->_championMan->_champions[championIndex]; _vm->_displayMan->blitToViewport(_vm->_displayMan->getNativeBitmapOrGraphic(k20_PanelEmptyIndice), _boxPanel, k72_byteWidth, k8_ColorRed, 73); - L1091_i_Y = 58; - for (AL1090_ui_SkillIndex = k0_ChampionSkillFighter; AL1090_ui_SkillIndex <= k3_ChampionSkillWizard; AL1090_ui_SkillIndex++) { - AL1092_i_SkillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(L1093_ui_ChampionIndex, AL1090_ui_SkillIndex | k0x8000_IgnoreTemporaryExperience)); - if (AL1092_i_SkillLevel == 1) + int16 textPosY = 58; + for (uint16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) { + int16 skillLevel = MIN((uint16)16, _vm->_championMan->getSkillLevel(championIndex, idx | k0x8000_IgnoreTemporaryExperience)); + if (skillLevel == 1) continue; + Common::String displayString; + switch (_vm->getGameLanguage()) { // localized - default: - case Common::EN_ANY: - case Common::DE_DEU: // english and german versions are the same - strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]); - strcat(L1097_ac_String, " "); - strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]); - break; case Common::FR_FRA: - strcat(L1097_ac_String, _vm->_championMan->_baseSkillName[AL1090_ui_SkillIndex]); - strcat(L1097_ac_String, " "); - strcpy(L1097_ac_String, _skillLevelNames[AL1092_i_SkillLevel - 2]); + // Fix original bug: Due to a copy&paste error, the string was concatenate then overwritten be the last part + displayString = Common::String::format("%s %s", _vm->_championMan->_baseSkillName[idx], _skillLevelNames[skillLevel - 2]); + break; + default: // English and German versions are built the same way + displayString = Common::String::format("%s %s", _skillLevelNames[skillLevel - 2], _vm->_championMan->_baseSkillName[idx]); break; } - _vm->_textMan->printToViewport(108, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String); - L1091_i_Y += 7; + _vm->_textMan->printToViewport(108, textPosY, k13_ColorLightestGray, displayString.c_str()); + textPosY += 7; } - L1091_i_Y = 86; - for (AL1090_ui_StatisticIndex = k1_ChampionStatStrength; AL1090_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1090_ui_StatisticIndex++) { - _vm->_textMan->printToViewport(108, L1091_i_Y, k13_ColorLightestGray, G0431_apc_StatisticNames[AL1090_ui_StatisticIndex]); - AL1092_i_StatisticCurrentValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k1_ChampionStatCurrent]; - L1096_ui_StatisticMaximumValue = L1094_ps_Champion->_statistics[AL1090_ui_StatisticIndex][k0_ChampionStatMaximum]; - if (AL1092_i_StatisticCurrentValue < L1096_ui_StatisticMaximumValue) { - L1095_i_StatisticColor = k8_ColorRed; - } else { - if (AL1092_i_StatisticCurrentValue > L1096_ui_StatisticMaximumValue) { - L1095_i_StatisticColor = k7_ColorLightGreen; - } else { - L1095_i_StatisticColor = k13_ColorLightestGray; - } - } - _vm->_textMan->printToViewport(174, L1091_i_Y, (Color)L1095_i_StatisticColor, _vm->_championMan->getStringFromInteger(AL1092_i_StatisticCurrentValue, true, 3).c_str()); - strcpy(L1097_ac_String, "/"); - strcat(L1097_ac_String, _vm->_championMan->getStringFromInteger(L1096_ui_StatisticMaximumValue, true, 3).c_str()); - _vm->_textMan->printToViewport(192, L1091_i_Y, k13_ColorLightestGray, L1097_ac_String); - L1091_i_Y += 7; + textPosY = 86; + for (uint16 idx = k1_ChampionStatStrength; idx <= k6_ChampionStatAntifire; idx++) { + _vm->_textMan->printToViewport(108, textPosY, k13_ColorLightestGray, statisticNames[idx]); + int16 statisticCurrentValue = curChampion->_statistics[idx][k1_ChampionStatCurrent]; + uint16 statisticMaximumValue = curChampion->_statistics[idx][k0_ChampionStatMaximum]; + int16 statisticColor; + if (statisticCurrentValue < statisticMaximumValue) + statisticColor = k8_ColorRed; + else if (statisticCurrentValue > statisticMaximumValue) + statisticColor = k7_ColorLightGreen; + else + statisticColor = k13_ColorLightestGray; + + _vm->_textMan->printToViewport(174, textPosY, (Color)statisticColor, _vm->_championMan->getStringFromInteger(statisticCurrentValue, true, 3).c_str()); + Common::String displayString = "/" + _vm->_championMan->getStringFromInteger(statisticMaximumValue, true, 3); + _vm->_textMan->printToViewport(192, textPosY, k13_ColorLightestGray, displayString.c_str()); + textPosY += 7; } } @@ -898,14 +888,13 @@ void InventoryMan::drawStopPressingMouth() { } void InventoryMan::drawStopPressingEye() { - Thing L1100_T_LeaderHandObject; - drawIconToViewport(k202_IconIndiceEyeNotLooking, 12, 13); drawPanel(); _vm->_displayMan->drawViewport(k0_viewportNotDungeonView); - if ((L1100_T_LeaderHandObject = _vm->_championMan->_leaderHandObject) != Thing::_none) { - _vm->_objectMan->drawLeaderObjectName(L1100_T_LeaderHandObject); - } + Thing leaderHandObject = _vm->_championMan->_leaderHandObject; + if (leaderHandObject != Thing::_none) + _vm->_objectMan->drawLeaderObjectName(leaderHandObject); + _vm->_eventMan->showMouse(); _vm->_eventMan->showMouse(); _vm->_eventMan->showMouse(); @@ -943,9 +932,9 @@ void InventoryMan::clickOnMouth() { if (_vm->_championMan->_leaderEmptyHanded) { - if (_panelContent == k0_PanelContentFoodWaterPoisoned) { + if (_panelContent == k0_PanelContentFoodWaterPoisoned) return; - } + _vm->_eventMan->_ignoreMouseMovements = true; _vm->_pressingMouth = true; if (!_vm->_eventMan->isMouseButtonDown(k1_LeftMouseButton)) { @@ -960,14 +949,14 @@ void InventoryMan::clickOnMouth() { } return; } - if (_vm->_championMan->_candidateChampionOrdinal) { + + if (_vm->_championMan->_candidateChampionOrdinal) return; - } L1078_T_Thing = _vm->_championMan->_leaderHandObject; - if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) { + if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth)) return; - } + L1079_ui_IconIndex = _vm->_objectMan->getIconIndex(L1078_T_Thing); AL1088_ui_ThingType = L1078_T_Thing.getType(); L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing); |