Skip to content

Commit

Permalink
DM: Add F0386_MENUS_DrawActionIcon
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent d9ed599 commit 7782754
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 35 deletions.
1 change: 1 addition & 0 deletions engines/dm/champion.h
Expand Up @@ -297,6 +297,7 @@ class Champion {
void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }

uint16 getAttributes() { return _attributes; }
uint16 getAttributes(ChampionAttribute flag) { return _attributes & flag; }
void setAttributeFlag(ChampionAttribute flag, bool value) {
if (value) {
_attributes |= flag;
Expand Down
4 changes: 3 additions & 1 deletion engines/dm/gfx.h
Expand Up @@ -44,6 +44,7 @@ class Box {
uint16 _y2;

Box(uint16 x1, uint16 x2, uint16 y1, uint16 y2): _x1(x1), _x2(x2 + 1), _y1(y1), _y2(y2 + 1) {}
Box() {}
bool isPointInside(Common::Point point) {
return (_x1 <= point.x) && (point.x < _x2) && (_y1 <= point.y) && (point.y < _y2);
}
Expand Down Expand Up @@ -257,9 +258,10 @@ class DisplayMan {

bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF

public:
// some methods use this for a stratchpad, don't make assumptions about content between function calls
byte *_tmpBitmap;
public:

DisplayMan(DMEngine *dmEngine);
~DisplayMan();

Expand Down
102 changes: 70 additions & 32 deletions engines/dm/menus.cpp
@@ -1,32 +1,70 @@
#include "menus.h"
#include "gfx.h"
#include "champion.h"
#include "dungeonman.h"


namespace DM {

byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon

MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}

void MenuMan::drawMovementArrows() {
DisplayMan &disp = *_vm->_displayMan;
byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
Box &dest = gBoxMovementArrows;
uint16 w = disp.getWidth(kMovementArrowsIndice);

disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
}
void MenuMan::clearActingChampion() {
ChampionMan &cm = *_vm->_championMan;
if (cm._actingChampionOrdinal) {
cm._actingChampionOrdinal--;
cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
warning("MISSING CODE: F0292_CHAMPION_DrawState");
cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
_shouldRefreshActionArea = true;
}
}

}
#include "menus.h"
#include "gfx.h"
#include "champion.h"
#include "dungeonman.h"
#include "objectman.h"


namespace DM {

byte gPalChangesActionAreaObjectIcon[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0}; // @ G0498_auc_Graphic560_PaletteChanges_ActionAreaObjectIcon

MenuMan::MenuMan(DMEngine *vm): _vm(vm) {}

void MenuMan::drawMovementArrows() {
DisplayMan &disp = *_vm->_displayMan;
byte *arrowsBitmap = disp.getBitmap(kMovementArrowsIndice);
Box &dest = gBoxMovementArrows;
uint16 w = disp.getWidth(kMovementArrowsIndice);

disp.blitToScreen(arrowsBitmap, w, 0, 0, dest._x1, dest._x2, dest._y1, dest._y2, kColorNoTransparency);
}
void MenuMan::clearActingChampion() {
ChampionMan &cm = *_vm->_championMan;
if (cm._actingChampionOrdinal) {
cm._actingChampionOrdinal--;
cm._champions[cm._actingChampionOrdinal].setAttributeFlag(kChampionAttributeActionHand, true);
warning("MISSING CODE: F0292_CHAMPION_DrawState");
cm._actingChampionOrdinal = indexToOrdinal(kChampionNone);
_shouldRefreshActionArea = true;
}
}

void MenuMan::drawActionIcon(ChampionIndex championIndex) {
if (!_actionAreaContainsIcons)
return;
DisplayMan &dm = *_vm->_displayMan;
Champion &champion = _vm->_championMan->_champions[championIndex];

Box box;
box._x1 = championIndex * 22 + 233;
box._x2 = box._x1 + 19 + 1;
box._y1 = 86;
box._y2 = 120 + 1;
dm._useByteBoxCoordinates = false;
if (!champion._currHealth) {
dm.clearScreenBox(kColorBlack, box);
return;
}
byte *bitmapIcon = dm._tmpBitmap;
Thing thing = champion.getSlot(kChampionSlotActionHand);
IconIndice iconIndex;
if (thing == Thing::_thingNone) {
iconIndex = kIconIndiceActionEmptyHand;
} else if (gObjectInfo[_vm->_dungeonMan->getObjectInfoIndex(thing)]._actionSetIndex) {
iconIndex = _vm->_objectMan->getIconIndex(thing);
} else {
dm.clearBitmap(bitmapIcon, 16, 16, kColorCyan);
goto T0386006;
}
_vm->_objectMan->extractIconFromBitmap(iconIndex, bitmapIcon);
dm.blitToBitmapShrinkWithPalChange(bitmapIcon, 16, 16, bitmapIcon, 16, 16, gPalChangesActionAreaObjectIcon);
T0386006:
dm.clearScreenBox(kColorCyan, box);
Box box2;
box2._x1 = box._x1 + 2;
box2._x2 = box._x2 - 2; // no need to add +1 for exclusive boundaries, box already has that
box2._y1 = 95;
box2._y2 = 110 + 1;
dm.blitToScreen(bitmapIcon, 16, 0, 0, box2._x1, box2._x2, box2._y1, box2._y2);
if (champion.getAttributes(kChampionAttributeDisableAction) || _vm->_championMan->_candidateChampionOrdinal || _vm->_championMan->_partyIsSleeping) { warning("MISSING CODE: F0136_VIDEO_ShadeScreenBox"); }}}
Expand Down
2 changes: 2 additions & 0 deletions engines/dm/menus.h
Expand Up @@ -2,6 +2,7 @@
#define DM_MENUS_H

#include "dm.h"
#include "champion.h"

namespace DM {

Expand All @@ -12,6 +13,7 @@ class MenuMan {
bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
MenuMan(DMEngine *vm);
void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon

void drawMovementArrows();
};
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/objectman.cpp
Expand Up @@ -30,7 +30,7 @@ IconIndice ObjectMan::getObjectType(Thing thing) {

byte gChargeCountToTorchType[16] = {0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3}; // @ G0029_auc_Graphic562_ChargeCountToTorchType

int16 ObjectMan::getIconIndex(Thing thing) {
IconIndice ObjectMan::getIconIndex(Thing thing) {
IconIndice iconIndex = getObjectType(thing);

if ((iconIndex != kIconIndiceNone) &&
Expand Down
2 changes: 1 addition & 1 deletion engines/dm/objectman.h
Expand Up @@ -9,7 +9,7 @@ class ObjectMan {
public:
ObjectMan(DMEngine *vm);
IconIndice getObjectType(Thing thing); // @ F0032_OBJECT_GetType
int16 getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
IconIndice getIconIndex(Thing thing); // @ F0033_OBJECT_GetIconIndex
void extractIconFromBitmap(uint16 iconIndex, byte *srcBitmap); // F0036_OBJECT_ExtractIconFromBitmap
};

Expand Down

0 comments on commit 7782754

Please sign in to comment.