diff --git a/engines/dm/TODOs/methodtree.txt b/engines/dm/TODOs/methodtree.txt index 60f6b470342..064e09581a7 100644 --- a/engines/dm/TODOs/methodtree.txt +++ b/engines/dm/TODOs/methodtree.txt @@ -53,7 +53,7 @@ F0280_CHAMPION_AddCandidateChampionToParty // done, so-so F0333_INVENTORY_OpenAndDrawChest // done F0303_CHAMPION_GetSkillLevel // done F0332_INVENTORY_DrawIconToViewport // done - F0336_INVENTORY_DrawPanel_BuildObjectAttributesString + F0336_INVENTORY_DrawPanel_BuildObjectAttributesString // done F0335_INVENTORY_DrawPanel_ObjectDescriptionString F0339_INVENTORY_DrawPanel_ArrowOrEye G0430_apc_DirectionNames diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index 7124e1b5ef1..b23321bb3c5 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -338,4 +338,35 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP _vm->_objectMan->extractIconFromBitmap(iconIndex, iconBitmap); _vm->_displayMan->blitToScreen(iconBitmap, 16, 0, 0, box, kColorNoTransparency, gDungeonViewport); } + +void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char** attribStrings, char* destString, char* prefixString, char* suffixString) { + 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); +} } diff --git a/engines/dm/inventory.h b/engines/dm/inventory.h index 4b06ce0e797..ac68b544b9d 100644 --- a/engines/dm/inventory.h +++ b/engines/dm/inventory.h @@ -71,6 +71,8 @@ public: void drawPanelScroll(Scroll *scoll); // @ F0341_INVENTORY_DrawPanel_Scroll void openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye); // @ F0333_INVENTORY_OpenAndDrawChest void drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yPos); // @ F0332_INVENTORY_DrawIconToViewport + void buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, char ** attribStrings, + char *destString, char *prefixString, char *suffixString); // @ F0336_INVENTORY_DrawPanel_BuildObjectAttributesString };