1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22 
23 /*
24 * Based on the Reverse Engineering work of Christophe Fontanel,
25 -* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
26 */
27 
28 #ifndef DM_MENUS_H
29 #define DM_MENUS_H
30 
31 #include "dm/dm.h"
32 #include "dm/champion.h"
33 #include "dm/dungeonman.h"
34 
35 namespace DM {
36 
37 enum Damage {
38 	kDMDamageCantReach = -1,   // @ CM1_DAMAGE_CANT_REACH
39 	kDMDamageNoAmmunition = -2 // @ CM2_DAMAGE_NO_AMMUNITION
40 };
41 
42 enum SpellArea {
43 	kDMSpellAreaAvailableSymbols = 2, // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
44 	kDMSpellAreaChampionSymbols = 3   // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
45 };
46 
47 enum ActionMask {
48 	kDMActionMaskRequiresCharge = 0x0080,         // @ MASK0x0080_ACTION_REQUIRES_CHARGE
49 	kDMActionMaskHitNonMaterialCreatures = 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES
50 };
51 
52 class ActionList {
53 public:
54 	byte _minimumSkillLevel[3]; /* Bit 7: requires charge, Bit 6-0: minimum skill level. */
55 	ChampionAction _actionIndices[3];
ActionList()56 	ActionList() { resetToZero(); }
resetToZero()57 	void resetToZero() {
58 		for (uint16 i = 0; i < 3; ++i) {
59 			_minimumSkillLevel[i] = 0;
60 			_actionIndices[i] = (ChampionAction)0;
61 		}
62 	}
63 }; // @ ACTION_LIST
64 
65 class ActionSet {
66 public:
67 	byte _actionIndices[3]; /* 1 byte of padding inserted by compiler on Atari ST, not on Amiga */
68 	byte _actionProperties[2]; /* Bit 7: requires charge, Bit 6-0: minimum skill level */
ActionSet(byte a1,byte a2,byte a3,byte b1,byte b2)69 	ActionSet(byte a1, byte a2, byte a3, byte b1, byte b2) {
70 		_actionIndices[0] = a1;
71 		_actionIndices[1] = a2;
72 		_actionIndices[2] = a3;
73 		_actionProperties[0] = b1;
74 		_actionProperties[1] = b2;
75 	}
76 }; // @ ACTION_SET
77 
78 class MenuMan {
79 	DMEngine *_vm;
80 public:
81 	explicit MenuMan(DMEngine *vm);
82 	~MenuMan();
83 
84 	bool _refreshActionArea; // @ G0508_B_RefreshActionArea
85 	bool _actionAreaContainsIcons; // @ G0509_B_ActionAreaContainsIcons
86 	int16 _actionDamage; // @ G0513_i_ActionDamage
87 	ActionList _actionList; // @ G0713_s_ActionList
88 	byte *_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
89 	byte *_bitmapSpellAreaLines; // @ K0073_puc_Bitmap_SpellAreaLines
90 	Thing _actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing
91 	uint16 _actionCount; // @ G0507_ui_ActionCount
92 
93 	void clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
94 	void drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
95 
96 	void drawMovementArrows(); // @ F0395_MENUS_DrawMovementArrows
97 	void drawDisabledMenu(); // @ F0456_START_DrawDisabledMenus
98 	void refreshActionAreaAndSetChampDirMaxDamageReceived(); // @ F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived
99 	void drawActionArea(); // @ F0387_MENUS_DrawActionArea
100 	const char *getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
101 	void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
102 	void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
103 	void setMagicCasterAndDrawSpellArea(ChampionIndex champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
104 	void drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
105 	int16 getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
106 	int16 getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult
107 	Spell *getSpellFromSymbols(byte *symbols); // @ F0409_MENUS_GetSpellFromSymbols
108 	void menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex); // @ F0410_MENUS_PrintSpellFailureMessage
109 	Potion *getEmptyFlaskInHand(Champion *champ, Thing *potionThing); // @ F0411_MENUS_GetEmptyFlaskInHand
110 	void createEvent70_light(int16 lightPower, int16 ticks); // @ F0404_MENUS_CreateEvent70_Light
111 	bool isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana); // @ F0403_MENUS_IsPartySpellOrFireShieldSuccessful
112 	void drawAvailableSymbols(uint16 symbolStep); // @ F0397_MENUS_DrawAvailableSymbols
113 	void drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols
114 	void addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol
115 	void deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol
116 	bool didClickTriggerAction(int16 actionListIndex); // @ F0391_MENUS_DidClickTriggerAction
117 	bool isActionPerformed(uint16 champIndex, int16 actionIndex); // @ F0407_MENUS_IsActionPerformed
118 	void setChampionDirectionToPartyDirection(Champion *champ); // @ F0406_MENUS_SetChampionDirectionToPartyDirection
119 	void decrementCharges(Champion *champ); // @ F0405_MENUS_DecrementCharges
120 	bool isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX,
121 									 int16 targetMapY, int16 skillIndex); // @ F0402_MENUS_IsMeleeActionPerformed
122 	bool isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction
123 	void printMessageAfterReplacements(const char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
124 	void processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
125 	void setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
126 	int16 getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
127 	void drawActionDamage(int16 damage); // @ F0385_MENUS_DrawActionDamage
128 
129 	Box _boxActionArea3ActionMenu; // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
130 	Box _boxActionArea2ActionMenu; // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
131 	Box _boxActionArea1ActionMenu; // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
132 	Box _boxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
133 	Box _boxSpellArea;
134 	unsigned char _actionSkillIndex[44]; // @ G0496_auc_Graphic560_ActionSkillIndex
135 	unsigned char _actionDisabledTicks[44];
136 
137 	void initConstants();
138 };
139 }
140 
141 #endif // DM_MENUS_H
142