2016-08-26 22:36:31 +02:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Based on the Reverse Engineering work of Christophe Fontanel,
|
|
|
|
* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
|
|
|
|
*/
|
|
|
|
|
2016-06-19 16:17:28 +02:00
|
|
|
#include "inventory.h"
|
2016-06-19 18:05:19 +02:00
|
|
|
#include "dungeonman.h"
|
|
|
|
#include "eventman.h"
|
|
|
|
#include "menus.h"
|
2016-06-20 18:12:22 +02:00
|
|
|
#include "gfx.h"
|
2016-08-26 22:35:29 +02:00
|
|
|
#include "text.h"
|
2016-06-28 01:13:52 +02:00
|
|
|
#include "objectman.h"
|
2016-06-19 16:17:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
Box g41_BoxFloppyZzzCross = Box(174, 218, 2, 12); // @ G0041_s_Graphic562_Box_ViewportFloppyZzzCross
|
|
|
|
Box g32_BoxPanel = Box(80, 223, 52, 124); // @ G0032_s_Graphic562_Box_Panel
|
|
|
|
Box g35_BoxFood = Box(112, 159, 60, 68); // @ G0035_s_Graphic562_Box_Food
|
|
|
|
Box g36_BoxWater = Box(112, 159, 83, 91); // @ G0036_s_Graphic562_Box_Water
|
|
|
|
Box g37_BoxPoisoned = Box(112, 207, 105, 119); // @ G0037_s_Graphic562_Box_Poisoned
|
2016-06-19 16:17:28 +02:00
|
|
|
|
2016-06-21 14:55:57 +02:00
|
|
|
InventoryMan::InventoryMan(DMEngine *vm) : _vm(vm) {
|
2016-07-02 12:57:31 +02:00
|
|
|
_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
|
2016-06-23 03:16:36 +02:00
|
|
|
for (uint16 i = 0; i < 8; ++i)
|
2016-07-02 12:57:31 +02:00
|
|
|
_g425_chestSlots[i] = Thing::_none;
|
|
|
|
_g426_openChest = Thing::_none;
|
|
|
|
_g426_openChest = Thing::_none;
|
2016-06-21 14:55:57 +02:00
|
|
|
}
|
2016-06-19 16:17:28 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f355_toggleInventory(ChampionIndex championIndex) {
|
2016-06-19 18:05:19 +02:00
|
|
|
ChampionMan &cm = *_vm->_championMan;
|
|
|
|
EventManager &em = *_vm->_eventMan;
|
|
|
|
DisplayMan &dm = *_vm->_displayMan;
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
if ((championIndex != k4_ChampionCloseInventory) && !cm._gK71_champions[championIndex]._currHealth)
|
2016-06-19 18:05:19 +02:00
|
|
|
return;
|
2016-08-26 22:43:17 +02:00
|
|
|
if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth)
|
2016-06-19 18:05:19 +02:00
|
|
|
return;
|
2016-08-26 22:43:17 +02:00
|
|
|
_vm->_g321_stopWaitingForPlayerInput = true;
|
2016-07-02 12:57:31 +02:00
|
|
|
int16 invChampOrdinal = _g432_inventoryChampionOrdinal; // copy, as the original will be edited
|
2016-08-26 22:47:44 +02:00
|
|
|
if (_vm->M0_indexToOrdinal(championIndex) == invChampOrdinal) {
|
2016-07-02 01:55:48 +02:00
|
|
|
championIndex = k4_ChampionCloseInventory;
|
2016-06-19 18:05:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Champion *champion;
|
|
|
|
if (invChampOrdinal) {
|
2016-08-26 22:47:44 +02:00
|
|
|
_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(kM1_ChampionNone);
|
|
|
|
f334_closeChest();
|
|
|
|
champion = &cm._gK71_champions[_vm->M1_ordinalToIndex(invChampOrdinal)];
|
2016-07-02 01:55:48 +02:00
|
|
|
if (champion->_currHealth && !cm._g299_candidateChampionOrdinal) {
|
|
|
|
champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
|
2016-08-26 22:47:44 +02:00
|
|
|
cm.f292_drawChampionState((ChampionIndex)_vm->M1_ordinalToIndex(invChampOrdinal));
|
2016-06-19 18:05:19 +02:00
|
|
|
}
|
2016-07-02 01:55:48 +02:00
|
|
|
if (cm._g300_partyIsSleeping) {
|
2016-06-19 18:05:19 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-07-02 01:55:48 +02:00
|
|
|
if (championIndex == k4_ChampionCloseInventory) {
|
2016-07-02 02:58:44 +02:00
|
|
|
em._g326_refreshMousePointerInMainLoop = true;
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_menuMan->f395_drawMovementArrows();
|
2016-07-02 02:58:44 +02:00
|
|
|
em._g442_secondaryMouseInput = g448_SecondaryMouseInput_Movement;
|
2016-06-19 18:05:19 +02:00
|
|
|
warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
|
|
|
|
warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-02 00:27:05 +02:00
|
|
|
dm._g578_useByteBoxCoordinates = false;
|
2016-08-26 22:47:44 +02:00
|
|
|
_g432_inventoryChampionOrdinal = _vm->M0_indexToOrdinal(championIndex);
|
2016-06-19 18:05:19 +02:00
|
|
|
if (!invChampOrdinal) {
|
|
|
|
warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox");
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
champion = &cm._gK71_champions[championIndex];
|
|
|
|
dm.f466_loadIntoBitmap(k17_InventoryGraphicIndice, dm._g296_bitmapViewport);
|
2016-07-02 01:55:48 +02:00
|
|
|
if (cm._g299_candidateChampionOrdinal) {
|
2016-07-02 23:10:05 +02:00
|
|
|
dm.f135_fillBoxBitmap(dm._g296_bitmapViewport, g41_BoxFloppyZzzCross, k12_ColorDarkestGray, k112_byteWidthViewport * 2, k136_heightViewport);
|
2016-06-19 18:05:19 +02:00
|
|
|
}
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_textMan->f52_printToViewport(5, 116, k13_ColorLightestGray, "HEALTH");
|
|
|
|
_vm->_textMan->f52_printToViewport(5, 124, k13_ColorLightestGray, "STAMINA");
|
|
|
|
_vm->_textMan->f52_printToViewport(5, 132, k13_ColorLightestGray, "MANA");
|
2016-06-19 18:05:19 +02:00
|
|
|
|
2016-07-02 01:55:48 +02:00
|
|
|
for (uint16 slotIndex = k0_ChampionSlotReadyHand; slotIndex < k30_ChampionSlotChest_1; slotIndex++) {
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_championMan->f291_drawSlot(championIndex, (ChampionSlot)slotIndex);
|
2016-06-23 03:16:36 +02:00
|
|
|
}
|
2016-06-19 18:05:19 +02:00
|
|
|
|
2016-07-02 01:55:48 +02:00
|
|
|
champion->setAttributeFlag(k0x4000_ChampionAttributeViewport, true);
|
|
|
|
champion->setAttributeFlag(k0x1000_ChampionAttributeStatusBox, true);
|
|
|
|
champion->setAttributeFlag(k0x0800_ChampionAttributePanel, true);
|
|
|
|
champion->setAttributeFlag(k0x0200_ChampionAttributeLoad, true);
|
|
|
|
champion->setAttributeFlag(k0x0100_ChampionAttributeStatistics, true);
|
|
|
|
champion->setAttributeFlag(k0x0080_ChampionAttributeNameTitle, true);
|
2016-06-19 18:05:19 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
cm.f292_drawChampionState(championIndex);
|
2016-07-02 02:58:44 +02:00
|
|
|
em._g598_mousePointerBitmapUpdated = true;
|
|
|
|
em._g442_secondaryMouseInput = g449_SecondaryMouseInput_ChampionInventory;
|
2016-06-19 18:05:19 +02:00
|
|
|
warning("MISSING CODE: set G0444_ps_SecondaryKeyboardInput");
|
|
|
|
warning("MISSING CODE: F0357_COMMAND_DiscardAllInput");
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f354_drawStatusBoxPortrait(ChampionIndex championIndex) {
|
2016-06-20 18:12:22 +02:00
|
|
|
DisplayMan &dispMan = *_vm->_displayMan;
|
2016-07-02 00:27:05 +02:00
|
|
|
dispMan._g578_useByteBoxCoordinates = false;
|
2016-06-20 18:12:22 +02:00
|
|
|
Box box;
|
|
|
|
box._y1 = 0;
|
2016-07-03 03:07:38 +02:00
|
|
|
box._y2 = 28;
|
2016-07-02 12:57:31 +02:00
|
|
|
box._x1 = championIndex * k69_ChampionStatusBoxSpacing + 7;
|
2016-07-03 03:07:38 +02:00
|
|
|
box._x2 = box._x1 + 31;
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(_vm->_championMan->_gK71_champions[championIndex]._portrait, dispMan._g348_bitmapScreen, box, 0, 0, 32, k160_byteWidthScreen * 2, k255_ColorNoTransparency);
|
2016-06-20 18:12:22 +02:00
|
|
|
}
|
2016-06-19 18:05:19 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f343_drawPanelHorizontalBar(int16 x, int16 y, int16 pixelWidth, Color color) {
|
2016-06-20 22:10:55 +02:00
|
|
|
Box box;
|
|
|
|
box._x1 = x;
|
2016-07-03 03:07:38 +02:00
|
|
|
box._x2 = box._x1 + pixelWidth;
|
2016-06-20 22:10:55 +02:00
|
|
|
box._y1 = y;
|
2016-07-03 03:07:38 +02:00
|
|
|
box._y2 = box._y1 + 6;
|
2016-07-02 00:27:05 +02:00
|
|
|
_vm->_displayMan->_g578_useByteBoxCoordinates = false;
|
2016-07-03 01:15:10 +02:00
|
|
|
_vm->_displayMan->D24_fillScreenBox(box, color);
|
2016-06-20 22:10:55 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f344_drawPanelFoodOrWaterBar(int16 amount, int16 y, Color color) {
|
2016-06-20 22:20:58 +02:00
|
|
|
if (amount < -512) {
|
2016-07-02 00:27:05 +02:00
|
|
|
color = k8_ColorRed;
|
2016-06-21 01:15:06 +02:00
|
|
|
} else if (amount < 0) {
|
2016-07-02 00:27:05 +02:00
|
|
|
color = k11_ColorYellow;
|
2016-06-20 22:20:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 pixelWidth = amount + 1024;
|
|
|
|
if (pixelWidth == 3072) {
|
|
|
|
pixelWidth = 3071;
|
|
|
|
}
|
|
|
|
pixelWidth /= 32;
|
2016-08-26 22:47:44 +02:00
|
|
|
f343_drawPanelHorizontalBar(115, y + 2, pixelWidth, k0_ColorBlack);
|
|
|
|
f343_drawPanelHorizontalBar(113, y, pixelWidth, color);
|
2016-06-20 22:20:58 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f345_drawPanelFoodWaterPoisoned() {
|
|
|
|
Champion &champ = _vm->_championMan->_gK71_champions[_g432_inventoryChampionOrdinal];
|
|
|
|
f334_closeChest();
|
2016-06-21 01:15:06 +02:00
|
|
|
DisplayMan &dispMan = *_vm->_displayMan;
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed);
|
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k30_FoodLabelIndice), dispMan._g348_bitmapScreen, g35_BoxFood, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
|
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k31_WaterLabelIndice), dispMan._g348_bitmapScreen, g36_BoxWater, 0, 0, 48, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
|
2016-06-21 01:15:06 +02:00
|
|
|
if (champ._poisonEventCount) {
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k32_PoisionedLabelIndice), dispMan._g348_bitmapScreen, g37_BoxPoisoned, 0, 0, 96, k160_byteWidthScreen * 2, k12_ColorDarkestGray);
|
2016-06-21 01:15:06 +02:00
|
|
|
}
|
2016-08-26 22:47:44 +02:00
|
|
|
f344_drawPanelFoodOrWaterBar(champ._food, 69, k5_ColorLightBrown);
|
|
|
|
f344_drawPanelFoodOrWaterBar(champ._water, 92, k14_ColorBlue);
|
2016-06-21 01:15:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f346_drawPanelResurrectReincarnate() {
|
2016-07-02 12:57:31 +02:00
|
|
|
_g424_panelContent = k5_PanelContentResurrectReincarnate;
|
2016-07-03 01:06:54 +02:00
|
|
|
_vm->_displayMan->f132_blitToBitmap(_vm->_displayMan->f489_getBitmap(k40_PanelResurectReincaranteIndice), _vm->_displayMan->_g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k6_ColorDarkGreen);
|
2016-06-21 14:55:57 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f347_drawPanel() {
|
2016-08-26 22:40:13 +02:00
|
|
|
warning("possible reintroduction of BUG0_48");
|
2016-08-26 22:47:44 +02:00
|
|
|
f334_closeChest(); // possibility of BUG0_48
|
2016-06-21 15:09:24 +02:00
|
|
|
|
|
|
|
ChampionMan &cm = *_vm->_championMan;
|
2016-07-02 01:55:48 +02:00
|
|
|
if (cm._g299_candidateChampionOrdinal) {
|
2016-08-26 22:47:44 +02:00
|
|
|
f346_drawPanelResurrectReincarnate();
|
2016-06-21 15:09:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
Thing thing = cm._gK71_champions[_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal)].getSlot(k1_ChampionSlotActionHand);
|
2016-06-21 15:09:24 +02:00
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
_g424_panelContent = k0_PanelContentFoodWaterPoisoned;
|
2016-06-21 15:09:24 +02:00
|
|
|
switch (thing.getType()) {
|
2016-08-26 22:43:17 +02:00
|
|
|
case k9_ContainerThingType:
|
2016-07-02 12:57:31 +02:00
|
|
|
_g424_panelContent = k4_PanelContentChest;
|
2016-06-21 15:09:24 +02:00
|
|
|
break;
|
2016-08-26 22:43:17 +02:00
|
|
|
case k7_ScrollThingType:
|
2016-07-02 12:57:31 +02:00
|
|
|
_g424_panelContent = k2_PanelContentScroll;
|
2016-06-21 15:09:24 +02:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-30 13:29:42 +02:00
|
|
|
thing = Thing::_none;
|
2016-06-21 15:09:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-06-30 13:29:42 +02:00
|
|
|
if (thing == Thing::_none) {
|
2016-08-26 22:47:44 +02:00
|
|
|
f345_drawPanelFoodWaterPoisoned();
|
2016-06-21 15:09:24 +02:00
|
|
|
} else {
|
2016-08-26 22:47:44 +02:00
|
|
|
f342_drawPanelObject(thing, false);
|
2016-06-21 15:09:24 +02:00
|
|
|
}
|
|
|
|
}
|
2016-08-26 22:40:13 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f334_closeChest() {
|
2016-08-26 22:40:13 +02:00
|
|
|
DungeonMan &dunMan = *_vm->_dungeonMan;
|
|
|
|
|
|
|
|
bool processFirstChestSlot = true;
|
2016-07-02 12:57:31 +02:00
|
|
|
if (_g426_openChest == Thing::_none)
|
2016-08-26 22:40:13 +02:00
|
|
|
return;
|
2016-08-26 22:47:44 +02:00
|
|
|
Container *container = (Container*)dunMan.f156_getThingData(_g426_openChest);
|
2016-07-02 12:57:31 +02:00
|
|
|
_g426_openChest = Thing::_none;
|
2016-06-30 13:29:42 +02:00
|
|
|
container->getSlot() = Thing::_endOfList;
|
2016-08-26 22:40:13 +02:00
|
|
|
Thing prevThing;
|
|
|
|
for (int16 chestSlotIndex = 0; chestSlotIndex < 8; ++chestSlotIndex) {
|
2016-07-02 12:57:31 +02:00
|
|
|
Thing thing = _g425_chestSlots[chestSlotIndex];
|
2016-06-30 13:29:42 +02:00
|
|
|
if (thing != Thing::_none) {
|
2016-07-02 12:57:31 +02:00
|
|
|
_g425_chestSlots[chestSlotIndex] = Thing::_none; // CHANGE8_09_FIX
|
2016-08-26 22:40:13 +02:00
|
|
|
|
|
|
|
if (processFirstChestSlot) {
|
|
|
|
processFirstChestSlot = false;
|
2016-08-26 22:47:44 +02:00
|
|
|
*dunMan.f156_getThingData(thing) = Thing::_endOfList.toUint16();
|
2016-08-26 22:40:13 +02:00
|
|
|
container->getSlot() = prevThing = thing;
|
|
|
|
} else {
|
2016-08-26 22:47:44 +02:00
|
|
|
dunMan.f163_linkThingToList(thing, prevThing, kM1_MapXNotOnASquare, 0);
|
2016-08-26 22:40:13 +02:00
|
|
|
prevThing = thing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f340_drawPanelScrollTextLine(int16 yPos, char* text) {
|
2016-06-27 23:38:37 +02:00
|
|
|
warning("CHANGE5_03_IMPROVEMENT");
|
|
|
|
for (char* iter = text; *iter != '\0'; ++iter) {
|
|
|
|
if ((*iter >= 'A') && (*iter <= 'Z')) {
|
|
|
|
*iter -= 64;
|
|
|
|
} else if (*iter >= '{') { // this branch is CHANGE5_03_IMPROVEMENT
|
|
|
|
*iter -= 96;
|
|
|
|
}
|
|
|
|
}
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_textMan->f52_printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
|
2016-06-27 23:38:37 +02:00
|
|
|
}
|
2016-06-28 00:30:32 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f341_drawPanelScroll(Scroll* scroll) {
|
2016-06-28 00:30:32 +02:00
|
|
|
DisplayMan &dispMan = *_vm->_displayMan;
|
|
|
|
|
|
|
|
char stringFirstLine[300];
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_dungeonMan->f168_decodeText(stringFirstLine, Thing(scroll->getTextStringThingIndex()), (TextType)(k2_TextTypeScroll | k0x8000_DecodeEvenIfInvisible));
|
2016-06-28 00:30:32 +02:00
|
|
|
char *charRed = stringFirstLine;
|
|
|
|
while (*charRed && (*charRed != '\n')) {
|
2016-06-28 01:13:52 +02:00
|
|
|
charRed++;
|
2016-06-28 00:30:32 +02:00
|
|
|
}
|
|
|
|
*charRed = '\0';
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k23_PanelOpenScrollIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed);
|
2016-06-28 00:30:32 +02:00
|
|
|
int16 lineCount = 1;
|
|
|
|
charRed++;
|
|
|
|
char *charGreen = charRed; // first char of the second line
|
|
|
|
while (*charGreen) {
|
|
|
|
warning("BUG0_47");
|
|
|
|
/* BUG0_47 Graphical glitch when you open a scroll. If there is a single line of text in a scroll
|
|
|
|
(with no carriage return) then charGreen points to undefined data. This may result in a graphical
|
2016-06-28 01:13:52 +02:00
|
|
|
glitch and also corrupt other memory. This is not an issue in the original dungeons where all
|
2016-06-28 00:30:32 +02:00
|
|
|
scrolls contain at least one carriage return character */
|
|
|
|
if (*charGreen == '\n') {
|
|
|
|
lineCount++;
|
|
|
|
}
|
|
|
|
charGreen++;
|
|
|
|
}
|
|
|
|
if (*(charGreen - 1) != '\n') {
|
|
|
|
lineCount++;
|
|
|
|
} else if (*(charGreen - 2) == '\n') {
|
|
|
|
lineCount--;
|
|
|
|
}
|
|
|
|
int16 yPos = 92 - (7 * lineCount) / 2; // center the text vertically
|
2016-08-26 22:47:44 +02:00
|
|
|
f340_drawPanelScrollTextLine(yPos, stringFirstLine);
|
2016-06-28 00:30:32 +02:00
|
|
|
charGreen = charRed;
|
|
|
|
while (*charGreen) {
|
|
|
|
yPos += 7;
|
|
|
|
while (*charRed && (*charRed != '\n')) {
|
|
|
|
charRed++;
|
|
|
|
}
|
|
|
|
if (!(*charRed)) {
|
|
|
|
charRed[1] = '\0';
|
|
|
|
}
|
|
|
|
*charRed++ = '\0';
|
2016-08-26 22:47:44 +02:00
|
|
|
f340_drawPanelScrollTextLine(yPos, charGreen);
|
2016-06-28 00:30:32 +02:00
|
|
|
charGreen = charRed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f333_openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
|
2016-06-28 01:13:52 +02:00
|
|
|
DisplayMan &dispMan = *_vm->_displayMan;
|
|
|
|
ObjectMan &objMan = *_vm->_objectMan;
|
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
if (_g426_openChest == thingToOpen)
|
2016-06-28 01:13:52 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
warning("CHANGE8_09_FIX");
|
2016-07-02 12:57:31 +02:00
|
|
|
if (_g426_openChest != Thing::_none)
|
2016-08-26 22:47:44 +02:00
|
|
|
f334_closeChest(); // CHANGE8_09_FIX
|
2016-06-28 01:13:52 +02:00
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
_g426_openChest = thingToOpen;
|
2016-06-28 01:13:52 +02:00
|
|
|
if (!isPressingEye) {
|
2016-08-26 22:47:44 +02:00
|
|
|
objMan.f38_drawIconInSlotBox(k9_SlotBoxInventoryActionHand, k145_IconIndiceContainerChestOpen);
|
2016-06-28 01:13:52 +02:00
|
|
|
}
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k25_PanelOpenChestIndice), dispMan._g348_bitmapScreen, g32_BoxPanel, 0, 0, 144, k160_byteWidthScreen * 2, k8_ColorRed);
|
2016-06-28 13:07:50 +02:00
|
|
|
|
2016-06-28 01:13:52 +02:00
|
|
|
int16 chestSlotIndex = 0;
|
|
|
|
Thing thing = chest->getSlot();
|
|
|
|
int16 thingCount = 0;
|
2016-06-30 13:29:42 +02:00
|
|
|
while (thing != Thing::_endOfList) {
|
2016-06-28 01:13:52 +02:00
|
|
|
warning("CHANGE8_08_FIX");
|
|
|
|
if (++thingCount > 8)
|
|
|
|
break; // CHANGE8_08_FIX, make sure that no more than the first 8 objects in a chest are drawn
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, objMan.f33_getIconIndex(thing));
|
2016-07-02 12:57:31 +02:00
|
|
|
_g425_chestSlots[chestSlotIndex++] = thing;
|
2016-08-26 22:47:44 +02:00
|
|
|
thing = _vm->_dungeonMan->f159_getNextThing(thing);
|
2016-06-28 01:13:52 +02:00
|
|
|
}
|
|
|
|
while (chestSlotIndex < 8) {
|
2016-08-26 22:47:44 +02:00
|
|
|
objMan.f38_drawIconInSlotBox(chestSlotIndex + k38_SlotBoxChestFirstSlot, kM1_IconIndiceNone);
|
2016-07-02 12:57:31 +02:00
|
|
|
_g425_chestSlots[chestSlotIndex++] = Thing::_none;
|
2016-06-28 01:13:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f332_drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos) {
|
2016-06-28 13:07:50 +02:00
|
|
|
static byte iconBitmap[16 * 16];
|
|
|
|
Box box;
|
2016-07-03 03:07:38 +02:00
|
|
|
box._x2 = (box._x1 = xPos) + 15;
|
|
|
|
box._y2 = (box._y1 = yPos) + 15;
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_objectMan->f36_extractIconFromBitmap(iconIndex, iconBitmap);
|
2016-07-03 01:06:54 +02:00
|
|
|
_vm->_displayMan->f132_blitToBitmap(iconBitmap, _vm->_displayMan->_g296_bitmapViewport, box, 0, 0, 16, k112_byteWidthViewport * 2, k255_ColorNoTransparency);
|
2016-06-28 13:07:50 +02:00
|
|
|
}
|
2016-06-28 13:23:12 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f336_buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) {
|
2016-06-28 13:23:12 +02:00
|
|
|
uint16 identicalBitCount = 0;
|
|
|
|
int16 attribMask = 1;
|
|
|
|
for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
|
|
|
|
if (attribMask & potentialAttribMask & actualAttribMask) {
|
|
|
|
identicalBitCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (identicalBitCount == 0) {
|
|
|
|
*destString = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(destString, prefixString);
|
|
|
|
|
|
|
|
attribMask = 1;
|
|
|
|
for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
|
|
|
|
if (attribMask & potentialAttribMask & actualAttribMask) {
|
|
|
|
strcat(destString, attribStrings[stringIndex]);
|
|
|
|
if (identicalBitCount-- > 2) {
|
|
|
|
strcat(destString, ", ");
|
|
|
|
} else if (identicalBitCount == 1) {
|
|
|
|
strcat(destString, " AND "); // TODO: localization
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
strcat(destString, suffixString);
|
|
|
|
}
|
2016-06-28 13:36:58 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f335_drawPanelObjectDescriptionString(char* descString) {
|
2016-06-28 13:36:58 +02:00
|
|
|
if (descString[0] == '\f') { // form feed
|
|
|
|
descString++;
|
2016-07-02 12:57:31 +02:00
|
|
|
_g421_objDescTextXpos = 108;
|
|
|
|
_g422_objDescTextYpos = 59;
|
2016-06-28 13:36:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (descString[0]) {
|
|
|
|
char stringTmpBuff[128];
|
|
|
|
strcpy(stringTmpBuff, descString);
|
|
|
|
|
|
|
|
char *stringLine = stringTmpBuff;
|
|
|
|
bool severalLines = false;
|
|
|
|
char *string = nullptr;
|
|
|
|
while (*stringLine) {
|
|
|
|
if (strlen(stringLine) > 18) { // if string is too long to fit on one line
|
|
|
|
string = &stringLine[17];
|
|
|
|
while (*string != ' ') // go back to the last space character
|
|
|
|
string--;
|
|
|
|
|
|
|
|
*string = '\0'; // and split the string there
|
|
|
|
severalLines = true;
|
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
_vm->_textMan->f52_printToViewport(_g421_objDescTextXpos, _g422_objDescTextYpos, k13_ColorLightestGray, stringLine);
|
2016-07-02 12:57:31 +02:00
|
|
|
_g422_objDescTextYpos += 7;
|
2016-06-28 13:36:58 +02:00
|
|
|
if (severalLines) {
|
|
|
|
severalLines = false;
|
|
|
|
stringLine = ++string;
|
|
|
|
} else {
|
|
|
|
*stringLine = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-28 13:43:05 +02:00
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
Box g33_BoxArrowOrEye = Box(83, 98, 57, 65); // @ G0033_s_Graphic562_Box_ArrowOrEye
|
2016-06-28 13:43:05 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f339_drawPanelArrowOrEye(bool pressingEye) {
|
2016-06-28 13:43:05 +02:00
|
|
|
DisplayMan &dispMan = *_vm->_displayMan;
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(pressingEye ? k19_EyeForObjectDescriptionIndice : k18_ArrowForChestContentIndice), dispMan._g296_bitmapViewport, g33_BoxArrowOrEye, 0, 0, 16, k112_byteWidthViewport * 2, k8_ColorRed);
|
2016-06-28 13:43:05 +02:00
|
|
|
}
|
|
|
|
|
2016-06-28 18:04:32 +02:00
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
Box g34_BoxObjectDescCircle = Box(105, 136, 53, 79); // @ G0034_s_Graphic562_Box_ObjectDescriptionCircle
|
2016-06-28 18:04:32 +02:00
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
#define k0x0001_DescriptionMaskConsumable 0x0001 // @ MASK0x0001_DESCRIPTION_CONSUMABLE
|
|
|
|
#define k0x0002_DescriptionMaskPoisoned 0x0002 // @ MASK0x0002_DESCRIPTION_POISONED
|
|
|
|
#define k0x0004_DescriptionMaskBroken 0x0004 // @ MASK0x0004_DESCRIPTION_BROKEN
|
|
|
|
#define k0x0008_DescriptionMaskCursed 0x0008 // @ MASK0x0008_DESCRIPTION_CURSED
|
2016-06-28 18:04:32 +02:00
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
void InventoryMan::f342_drawPanelObject(Thing thingToDraw, bool pressingEye) {
|
2016-06-28 18:04:32 +02:00
|
|
|
DungeonMan &dunMan = *_vm->_dungeonMan;
|
|
|
|
ObjectMan &objMan = *_vm->_objectMan;
|
|
|
|
DisplayMan &dispMan = *_vm->_displayMan;
|
|
|
|
ChampionMan &champMan = *_vm->_championMan;
|
|
|
|
TextMan &textMan = *_vm->_textMan;
|
|
|
|
|
2016-08-26 22:43:17 +02:00
|
|
|
if (_vm->_g331_pressingEye || _vm->_g333_pressingMouth) {
|
2016-06-28 18:04:32 +02:00
|
|
|
warning("BUG0_48 The contents of a chest are reorganized when an object with a statistic modifier is placed or removed on a champion");
|
2016-08-26 22:47:44 +02:00
|
|
|
f334_closeChest();
|
2016-06-28 18:04:32 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
uint16 *rawThingPtr = dunMan.f156_getThingData(thingToDraw);
|
|
|
|
f335_drawPanelObjectDescriptionString("\f"); // form feed
|
2016-06-28 18:04:32 +02:00
|
|
|
ThingType thingType = thingToDraw.getType();
|
2016-08-26 22:43:17 +02:00
|
|
|
if (thingType == k7_ScrollThingType) {
|
2016-08-26 22:47:44 +02:00
|
|
|
f341_drawPanelScroll((Scroll*)rawThingPtr);
|
2016-08-26 22:43:17 +02:00
|
|
|
} else if (thingType == k9_ContainerThingType) {
|
2016-08-26 22:47:44 +02:00
|
|
|
f333_openAndDrawChest(thingToDraw, (Container*)rawThingPtr, pressingEye);
|
2016-06-28 18:04:32 +02:00
|
|
|
} else {
|
2016-08-26 22:47:44 +02:00
|
|
|
IconIndice iconIndex = objMan.f33_getIconIndex(thingToDraw);
|
2016-07-03 01:06:54 +02:00
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k20_PanelEmptyIndice), dispMan._g296_bitmapViewport, g32_BoxPanel, 0, 0, 144, k112_byteWidthViewport * 2, k8_ColorRed);
|
|
|
|
dispMan.f132_blitToBitmap(dispMan.f489_getBitmap(k29_ObjectDescCircleIndice), dispMan._g296_bitmapViewport, g34_BoxObjectDescCircle, 0, 0, 32, k112_byteWidthViewport * 2, k12_ColorDarkestGray);
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
char *descString = nullptr;
|
|
|
|
char str[40];
|
2016-07-02 01:55:48 +02:00
|
|
|
if (iconIndex == k147_IconIndiceJunkChampionBones) {
|
2016-08-26 22:47:44 +02:00
|
|
|
strcpy(str, champMan._gK71_champions[((Junk*)rawThingPtr)->getChargeCount()]._name); // TODO: localization
|
2016-06-28 18:04:32 +02:00
|
|
|
strcat(str, " "); // TODO: localization
|
2016-07-02 12:57:31 +02:00
|
|
|
strcat(str, objMan._g352_objectNames[iconIndex]); // TODO: localization
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
descString = str;
|
2016-08-26 22:43:17 +02:00
|
|
|
} else if ((thingType == k8_PotionThingType)
|
2016-07-02 01:55:48 +02:00
|
|
|
&& (iconIndex != k163_IconIndicePotionWaterFlask)
|
2016-08-26 22:47:44 +02:00
|
|
|
&& (champMan.f303_getSkillLevel((ChampionIndex)_vm->M1_ordinalToIndex(_g432_inventoryChampionOrdinal), k2_ChampionSkillPriest) > 1)) {
|
2016-06-28 18:04:32 +02:00
|
|
|
str[0] = '_' + ((Potion*)rawThingPtr)->getPower() / 40;
|
|
|
|
str[1] = ' ';
|
|
|
|
str[2] = '\0';
|
2016-07-02 12:57:31 +02:00
|
|
|
strcat(str, objMan._g352_objectNames[iconIndex]);
|
2016-06-28 18:04:32 +02:00
|
|
|
descString = str;
|
|
|
|
} else {
|
2016-07-02 12:57:31 +02:00
|
|
|
descString = objMan._g352_objectNames[iconIndex];
|
2016-06-28 18:04:32 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
textMan.f52_printToViewport(134, 68, k13_ColorLightestGray, descString);
|
|
|
|
f332_drawIconToViewport(iconIndex, 111, 59);
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
char *attribString[4] = {"CONSUMABLE", "POISONED", "BROKEN", "CURSED"}; // TODO: localization
|
|
|
|
|
2016-07-02 12:57:31 +02:00
|
|
|
_g422_objDescTextYpos = 87;
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
uint16 potentialAttribMask;
|
|
|
|
uint16 actualAttribMask;
|
|
|
|
switch (thingType) {
|
2016-08-26 22:43:17 +02:00
|
|
|
case k5_WeaponThingType: {
|
2016-07-02 12:57:31 +02:00
|
|
|
potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0002_DescriptionMaskPoisoned | k0x0004_DescriptionMaskBroken;
|
2016-06-28 18:04:32 +02:00
|
|
|
Weapon *weapon = (Weapon*)rawThingPtr;
|
|
|
|
actualAttribMask = (weapon->getCursed() << 3) | (weapon->getPoisoned() << 1) | (weapon->getBroken() << 2);
|
2016-07-02 01:55:48 +02:00
|
|
|
if ((iconIndex >= k4_IconIndiceWeaponTorchUnlit)
|
|
|
|
&& (iconIndex <= k7_IconIndiceWeaponTorchLit)
|
2016-06-28 18:04:32 +02:00
|
|
|
&& (weapon->getChargeCount() == 0)) {
|
2016-08-26 22:47:44 +02:00
|
|
|
f335_drawPanelObjectDescriptionString("(BURNT OUT)"); // TODO: localization
|
2016-06-28 18:04:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-08-26 22:43:17 +02:00
|
|
|
case k6_ArmourThingType: {
|
2016-07-02 12:57:31 +02:00
|
|
|
potentialAttribMask = k0x0008_DescriptionMaskCursed | k0x0004_DescriptionMaskBroken;
|
2016-06-28 18:04:32 +02:00
|
|
|
Armour *armour = (Armour*)rawThingPtr;
|
|
|
|
actualAttribMask = (armour->getCursed() << 3) | (armour->getBroken() << 2);
|
|
|
|
break;
|
|
|
|
}
|
2016-08-26 22:43:17 +02:00
|
|
|
case k8_PotionThingType: {
|
2016-07-02 12:57:31 +02:00
|
|
|
actualAttribMask = k0x0001_DescriptionMaskConsumable;
|
2016-06-28 18:04:32 +02:00
|
|
|
Potion *potion = (Potion*)rawThingPtr;
|
2016-08-26 22:43:17 +02:00
|
|
|
actualAttribMask = g237_ObjectInfo[k2_ObjectInfoIndexFirstPotion + potion->getType()].getAllowedSlots();
|
2016-06-28 18:04:32 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-08-26 22:43:17 +02:00
|
|
|
case k10_JunkThingType: {
|
2016-06-28 18:04:32 +02:00
|
|
|
Junk *junk = (Junk*)rawThingPtr;
|
2016-07-02 01:55:48 +02:00
|
|
|
if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
|
2016-06-28 18:04:32 +02:00
|
|
|
potentialAttribMask = 0;
|
|
|
|
switch (junk->getChargeCount()) {
|
|
|
|
case 0:
|
|
|
|
descString = "(EMPTY)"; // TODO: localization
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
descString = "(ALMOST EMPTY)"; // TODO: localization
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
descString = "(ALMOST FULL)"; // TODO: localization
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
descString = "(FULL)"; // TODO: localization
|
|
|
|
break;
|
|
|
|
}
|
2016-08-26 22:47:44 +02:00
|
|
|
f335_drawPanelObjectDescriptionString(descString);
|
2016-07-02 01:55:48 +02:00
|
|
|
} else if ((iconIndex >= k0_IconIndiceJunkCompassNorth) && (iconIndex <= k3_IconIndiceJunkCompassWest)) {
|
2016-06-28 18:04:32 +02:00
|
|
|
potentialAttribMask = 0;
|
|
|
|
strcpy(str, "PARTY FACING "); // TODO: localization
|
|
|
|
static char* directionName[4] = {"NORTH", "EAST", "SOUTH", "WEST"}; // G0430_apc_DirectionNames // TODO: localization
|
|
|
|
strcat(str, directionName[iconIndex]);
|
2016-08-26 22:47:44 +02:00
|
|
|
f335_drawPanelObjectDescriptionString(str);
|
2016-06-28 18:04:32 +02:00
|
|
|
} else {
|
2016-07-02 12:57:31 +02:00
|
|
|
potentialAttribMask = k0x0001_DescriptionMaskConsumable;
|
2016-08-26 22:43:17 +02:00
|
|
|
actualAttribMask = g237_ObjectInfo[k127_ObjectInfoIndexFirstJunk + junk->getType()].getAllowedSlots();
|
2016-06-28 18:04:32 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} // end of switch
|
|
|
|
|
|
|
|
if (potentialAttribMask) {
|
2016-08-26 22:47:44 +02:00
|
|
|
f336_buildObjectAttributeString(potentialAttribMask, actualAttribMask, attribString, str, "(", ")");
|
|
|
|
f335_drawPanelObjectDescriptionString(str);
|
2016-06-28 18:04:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(str, "WEIGHS "); // TODO: localization
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
uint16 weight = dunMan.f140_getObjectWeight(thingToDraw);
|
|
|
|
strcat(str, champMan.f288_getStringFromInteger(weight / 10, false, 3).c_str());
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
strcat(str, "."); // TODO: localization
|
|
|
|
|
|
|
|
weight -= (weight / 10) * 10;
|
2016-07-03 01:06:54 +02:00
|
|
|
strcat(str, champMan.f288_getStringFromInteger(weight, false, 1).c_str());
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
strcat(str, " KG."); // TODO: localization
|
|
|
|
|
2016-08-26 22:47:44 +02:00
|
|
|
f335_drawPanelObjectDescriptionString(str);
|
2016-06-28 18:04:32 +02:00
|
|
|
}
|
2016-08-26 22:47:44 +02:00
|
|
|
f339_drawPanelArrowOrEye(pressingEye);
|
2016-06-28 18:04:32 +02:00
|
|
|
|
|
|
|
}
|
2016-06-20 18:12:22 +02:00
|
|
|
}
|