melee / ranged effects
[gemrb.git] / gemrb / core / Interface.h
blobaf152df030688dc9abfc0426112481345d71a94a
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * @file Interface.h
23 * Declaration of Interface class, central interconnect for various GemRB parts
26 #ifndef INTERFACE_H
27 #define INTERFACE_H
29 //skip messy warnings in MSVC6
30 #include "win32def.h"
32 #include "SClassID.h"
33 #include "exports.h"
35 #include "Cache.h"
36 #include "GlobalTimer.h"
37 #include "Holder.h"
39 #include <map>
40 #include <string>
42 #ifdef _MSC_VER // No SFINAE
43 #include "Audio.h"
44 #include "DataFileMgr.h"
45 #include "MusicMgr.h"
46 #include "SaveGame.h"
47 #include "ScriptEngine.h"
48 #include "StringMgr.h"
49 #include "SymbolMgr.h"
50 #include "Video.h"
51 #endif
53 class Actor;
54 class Audio;
55 class CREItem;
56 class Calendar;
57 class Console;
58 class Container;
59 class Control;
60 class DataFileMgr;
61 struct Effect;
62 class EffectQueue;
63 struct EffectRef;
64 class EventMgr;
65 class Factory;
66 class Font;
67 class Game;
68 class GameControl;
69 class ITMExtHeader;
70 class Image;
71 class Item;
72 class Label;
73 class Map;
74 class MusicMgr;
75 class Palette;
76 class ProjectileServer;
77 class Resource;
78 class SPLExtHeader;
79 class SaveGame;
80 class SaveGameIterator;
81 class ScriptEngine;
82 class ScriptedAnimation;
83 class Spell;
84 class Store;
85 class StringMgr;
86 class SymbolMgr;
87 class TableMgr;
88 class TextArea;
89 class Variables;
90 class Video;
91 class Window;
92 class WindowMgr;
93 class WorldMap;
94 class WorldMapArray;
96 struct Symbol {
97 Holder<SymbolMgr> sm;
98 char ResRef[8];
101 struct SlotType {
102 ieDword slot;
103 ieDword slottype;
104 ieDword slottip;
105 ieDword slotid;
106 ieDword sloteffects;
107 ieDword slotflags;
108 ieResRef slotresref;
111 struct DamageInfoStruct {
112 unsigned int strref;
113 unsigned int resist_stat;
114 unsigned int value;
115 int iwd_mod_type;
116 // maybe also add the ac bonus and/or the DL_ constants
119 struct ModalStatesStruct {
120 ieResRef spell;
121 char action[16];
122 unsigned int entering_str;
123 unsigned int leaving_str;
124 unsigned int failed_str;
125 bool aoe_spell;
128 struct TimeStruct {
129 unsigned int round_sec;
130 unsigned int turn_sec;
131 unsigned int round_size; // in ticks
132 unsigned int rounds_per_turn;
135 class ItemList {
136 public:
137 ieResRef *ResRefs;
138 unsigned int Count;
139 //if count is odd and the column titles start with 2, the random roll should be 2d((c+1)/2)-1
140 bool WeightOdds;
142 ItemList(unsigned int size, int label) {
143 ResRefs = (ieResRef *) calloc(size, sizeof(ieResRef) );
144 Count = size;
145 if ((size&1) && (label==2)) {
146 WeightOdds=true;
147 } else {
148 WeightOdds=false;
151 ~ItemList() {
152 if (ResRefs) {
153 free(ResRefs);
158 // Colors of modal window shadow
159 // !!! Keep these synchronized with GUIDefines.py !!!
160 #define MODAL_SHADOW_NONE 0
161 #define MODAL_SHADOW_GRAY 1
162 #define MODAL_SHADOW_BLACK 2
164 #define WINDOW_INVALID -1
165 #define WINDOW_INVISIBLE 0
166 #define WINDOW_VISIBLE 1
167 #define WINDOW_GRAYED 2
168 #define WINDOW_FRONT 3
170 //quitflags
171 #define QF_NORMAL 0
172 #define QF_QUITGAME 1
173 #define QF_EXITGAME 2
174 #define QF_CHANGESCRIPT 4
175 #define QF_LOADGAME 8
176 #define QF_ENTERGAME 16
178 //events that are called out of drawwindow
179 //they wait until the condition is right
180 #define EF_CONTROL 1 //updates the game window statuses
181 #define EF_SHOWMAP 2 //starts worldmap
182 #define EF_PORTRAIT 4 //updates portraits
183 #define EF_ACTION 8 //updates the actions bar
184 #define EF_UPDATEANIM 16 //updates avatar animation
185 #define EF_SEQUENCER 32 //starts sequencer/contingency creation
186 #define EF_IDENTIFY 64 //starts identify screen
187 #define EF_SELECTION 128 //selection changed
188 #define EF_OPENSTORE 256 //open store window
189 #define EF_EXPANSION 512 //upgrade game request
191 //autopause
192 #define AP_UNUSABLE 0
193 #define AP_ATTACKED 1
194 #define AP_HIT 2
195 #define AP_WOUNDED 3
196 #define AP_DEAD 4
197 #define AP_NOTARGET 5
198 #define AP_ENDROUND 6
199 #define AP_ENEMY 7
200 #define AP_TRAP 8
201 #define AP_SPELLCAST 9
203 /** ea relations (derivated from 2 actor's EA value) */
204 #define EAR_FRIEND 0
205 #define EAR_NEUTRAL 1
206 #define EAR_HOSTILE 2
208 /** Max size of actor's ground circle (PST) */
209 #define MAX_CIRCLE_SIZE 3
211 /** Summoning */
212 #define EAM_SOURCEALLY 0
213 #define EAM_SOURCEENEMY 1
214 #define EAM_ENEMY 2
215 #define EAM_ALLY 3
216 #define EAM_NEUTRAL 4
217 #define EAM_DEFAULT 5
219 #define STAT_CON_HP_NORMAL 0
220 #define STAT_CON_HP_WARRIOR 1
221 #define STAT_CON_HP_MIN 2
222 #define STAT_CON_HP_REGEN 3
223 #define STAT_CON_FATIGUE 4
225 #define STAT_DEX_REACTION 0
226 #define STAT_DEX_MISSILE 1
227 #define STAT_DEX_AC 2
229 #define STAT_INT_LEARN 0
230 #define STAT_INT_MAXLEVEL 1
231 #define STAT_INT_MAXNUMBER 2
233 //sloteffects (querysloteffect returns it)
234 #define SLOT_EFFECT_NONE 0
235 #define SLOT_EFFECT_ITEM 1 //normal equipped item
236 #define SLOT_EFFECT_FIST 2 //fist slot
237 #define SLOT_EFFECT_MAGIC 3 //magic weapon slot
238 #define SLOT_EFFECT_MELEE 4 //normal weapon slot
239 #define SLOT_EFFECT_MISSILE 5 //quiver slots
240 #define SLOT_EFFECT_LEFT 6 //shield (left hand) slot
241 #define SLOT_EFFECT_HEAD 7 //head slot
243 //fog of war bits
244 #define FOG_DRAWFOG 1
245 #define FOG_DRAWSEARCHMAP 2
246 #define FOG_DITHERSPRITES 4
248 enum PluginFlagsType {
249 PLF_NORMAL,
250 PLF_SKIP,
251 PLF_DELAY
255 * @class Interface
256 * Central interconnect for all GemRB parts, driving functions and utility functions possibly belonging to a better place
259 class GEM_EXPORT Interface
261 private:
262 Holder<Video> video;
263 Holder<Audio> AudioDriver;
264 std::string VideoDriverName;
265 std::string AudioDriverName;
266 ProjectileServer * projserv;
267 Image * pal256;
268 Image * pal32;
269 Image * pal16;
270 std::vector<Font*> fonts;
271 EventMgr * evntmgr;
272 Holder<WindowMgr> windowmgr;
273 Window* ModalWindow;
274 char WindowPack[10];
275 Holder<ScriptEngine> guiscript;
276 SaveGameIterator *sgiterator;
277 /** Windows Array */
278 std::vector<Window*> windows;
279 std::vector<int> topwin;
280 Variables * vars;
281 Variables * tokens;
282 Variables * lists;
283 Holder<MusicMgr> music;
284 std::vector<Symbol> symbols;
285 Holder<DataFileMgr> INIparty;
286 Holder<DataFileMgr> INIbeasts;
287 Holder<DataFileMgr> INIquests;
288 Holder<DataFileMgr> INIresdata;
289 Game * game;
290 Calendar * calendar;
291 WorldMapArray* worldmap;
292 ieDword GameFeatures[(GF_COUNT+31)/32];
293 //ieDword GameFeatures; //the first 32 bits
294 //ieDword GameFeatures2;//the second 32 bits
295 ieResRef ButtonFont;
296 ieResRef CursorBam;
297 ieResRef ScrollCursorBam;
298 ieResRef GroundCircleBam[MAX_CIRCLE_SIZE];
299 int GroundCircleScale[MAX_CIRCLE_SIZE];
300 ieResRef TooltipFont;
301 ieResRef TooltipBackResRef;
302 ieResRef MovieFont;
303 ieResRef *DefSound; //default sounds
304 int DSCount;
305 Color TooltipColor;
306 int TooltipMargin;
307 ieResRef Palette16;
308 ieResRef Palette32;
309 ieResRef Palette256;
310 ieDword* slotmatrix; //itemtype vs slottype
311 SlotType* slottypes;
312 int ItemTypes;
313 int tooltip_x;
314 int tooltip_y;
315 int tooltip_currtextw;
316 // the control owning the tooltip
317 Control* tooltip_ctrl;
318 // Currently dragged item or NULL
319 CREItem* DraggedItem;
320 int DraggedPortrait;
321 // Current Store
322 Store* CurrentStore;
323 // Index of current container
324 Container* CurrentContainer;
325 bool UseContainer;
326 // Scrolling speed
327 int mousescrollspd;
328 bool update_scripts;
329 /** Next Script Name */
330 char NextScript[64];
331 public:
332 Holder<StringMgr> strings;
333 GlobalTimer * timer;
334 Palette *InfoTextPalette;
335 int SaveAsOriginal; //if true, saves files in compatible mode
336 int QuitFlag;
337 int EventFlag;
338 Holder<SaveGame> LoadGameIndex;
339 int VersionOverride;
340 unsigned int SlotTypes; //this is the same as the inventory size
341 ieResRef GlobalScript;
342 ieResRef WorldMapName[2];
343 Variables * AreaAliasTable;
344 Variables * ItemExclTable;
345 Variables * ItemDialTable, *ItemDial2Table;
346 Variables * ItemTooltipTable;
347 Sprite2D **Cursors;
348 int CursorCount;
349 //Sprite2D *ArrowSprites[MAX_ORIENT/2];
350 Sprite2D *FogSprites[32];
351 Sprite2D **TooltipBack;
352 Sprite2D *WindowFrames[4];
353 Sprite2D *GroundCircles[MAX_CIRCLE_SIZE][6];
354 std::vector<char *> musiclist;
355 std::multimap<ieDword, DamageInfoStruct> DamageInfoMap;
356 std::vector<ModalStatesStruct> ModalStates;
357 TimeStruct Time;
358 public:
359 Interface(int iargc, char *iargv[]);
360 ~Interface(void);
361 int Init(void);
362 //TODO: Core Methods in Interface Class
363 void SetFeature(int value, int position);
364 /* don't rely on the exact return value of this function */
365 ieDword HasFeature(int position) const;
366 bool IsAvailable(SClass_ID filetype) const;
367 const char * TypeExt(SClass_ID type) const;
368 ProjectileServer* GetProjectileServer() const;
369 Video * GetVideoDriver() const;
370 /* create or change a custom string */
371 ieStrRef UpdateString(ieStrRef strref, const char *text) const;
372 /* returns a newly created string */
373 char * GetString(ieStrRef strref, ieDword options = 0) const;
374 /* makes sure the string is freed in TLKImp */
375 void FreeString(char *&str) const;
376 /* sets the floattext color */
377 void SetInfoTextColor(const Color &color);
378 /** returns a gradient set */
379 Color * GetPalette(unsigned index, int colors, Color *buffer) const;
380 /** Returns a preloaded Font */
381 Font * GetFont(const char *) const;
382 Font * GetFont(unsigned int index) const;
383 /** Returns the button font */
384 Font * GetButtonFont() const;
385 /** Returns the Event Manager */
386 EventMgr * GetEventMgr() const;
387 /** Returns the Window Manager */
388 WindowMgr * GetWindowMgr() const;
389 /** Get GUI Script Manager */
390 ScriptEngine * GetGUIScriptEngine() const;
391 /** core for summoning creatures, returns the last created Actor
392 may apply a single fx on the summoned creature normally an unsummon effect */
393 Actor *SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, const Point &position, int eamod, int level, Effect *fx, bool sexmod=1);
394 /** Loads a WindowPack (CHUI file) in the Window Manager */
395 bool LoadWindowPack(const char *name);
396 /** Loads a Window in the Window Manager */
397 int LoadWindow(unsigned short WindowID);
398 /** Creates a Window in the Window Manager */
399 #ifdef WIN32
400 #ifdef CreateWindow
401 #undef CreateWindow
402 #endif
403 #endif
404 int CreateWindow(unsigned short WindowID, int XPos, int YPos, unsigned int Width, unsigned int Height, char* Background);
405 /** Sets a Window on the Top */
406 void SetOnTop(int Index);
407 /** Add a window to the Window List */
408 void AddWindow(Window * win);
409 /** Get a Control on a Window */
410 int GetControl(unsigned short WindowIndex, unsigned long ControlID) const;
411 /** Adjust the scrolling of the control (if applicable) */
412 int AdjustScrolling(unsigned short WindowIndex, unsigned short ControlIndex, short x, short y);
413 /** Set the Text of a Control */
414 int SetText(unsigned short WindowIndex, unsigned short ControlIndex, const char * string);
415 /** Set the Tooltip text of a Control */
416 int SetTooltip(unsigned short WindowIndex, unsigned short ControlIndex, const char * string);
417 /** sets tooltip to be displayed */
418 void DisplayTooltip(int x, int y, Control* ctrl);
419 /** Actually draws tooltip on the screen. Called from SDLVideoDriver */
420 void DrawTooltip();
421 /** returns the label which should receive game messages (overrides messagetextarea) */
422 Label *GetMessageLabel() const;
423 /** returns the textarea of the main game screen */
424 TextArea *GetMessageTextArea() const;
425 /** returns the Window Visible Flag */
426 int GetVisible(unsigned short WindowIndex) const;
427 /** Set a Window Visible Flag */
428 int SetVisible(unsigned short WindowIndex, int visible);
429 /** Show a Window in Modal Mode */
430 int ShowModal(unsigned short WindowIndex, int Shadow);
431 /** Set the Status of a Control in a Window */
432 int SetControlStatus(unsigned short WindowIndex, unsigned short ControlIndex, unsigned long Status);
433 /** Get a Window from the Loaded Window List */
434 Window * GetWindow(unsigned short WindowIndex) const;
435 /** Returns true if wnd is a valid window with WindowIndex */
436 bool IsValidWindow(unsigned short WindowID, Window *wnd) const;
437 /** Removes a Loaded Window */
438 int DelWindow(unsigned short WindowIndex);
439 /** Removes all Loaded Windows */
440 void DelAllWindows();
441 /** Redraws all window */
442 void RedrawAll();
443 /** Refreshes any control associated with the variable name with value*/
444 void RedrawControls(const char *varname, unsigned int value);
445 /** Popup the Console */
446 void PopupConsole();
447 /** Draws the Console */
448 void DrawConsole();
449 /** Get the SaveGameIterator */
450 SaveGameIterator * GetSaveGameIterator() const;
451 /** Get the Variables Dictionary */
452 Variables * GetDictionary() const;
453 /** Get the Token Dictionary */
454 Variables * GetTokenDictionary() const;
455 /** Get the Music Manager */
456 MusicMgr * GetMusicMgr() const;
457 /** Loads an IDS Table, returns -1 on error or the Symbol Table Index on success */
458 int LoadSymbol(const char * ResRef);
459 /** Gets the index of a loaded Symbol Table, returns -1 on error */
460 int GetSymbolIndex(const char * ResRef) const;
461 /** Gets a Loaded Symbol Table by its index, returns NULL on error */
462 Holder<SymbolMgr> GetSymbol(unsigned int index) const;
463 /** Frees a Loaded Symbol Table, returns false on error, true on success */
464 bool DelSymbol(unsigned int index);
465 /** Plays a Movie */
466 int PlayMovie(const char * ResRef);
467 /** Generates traditional random number xdy+z */
468 int Roll(int dice, int size, int add) const;
469 /** Loads a Game Compiled Script */
470 int LoadScript(const char * ResRef);
471 /** Enables/Disables the CutScene Mode */
472 void SetCutSceneMode(bool active);
473 /** returns true if in cutscene mode */
474 bool InCutSceneMode() const;
475 /** Updates the Game Script Engine State */
476 void GSUpdate(bool update_scripts)
478 if(update_scripts) {
479 timer->Update();
481 else {
482 timer->Freeze();
485 /** Get the Party INI Interpreter */
486 DataFileMgr * GetPartyINI() const
488 return INIparty.get();
490 DataFileMgr * GetBeastsINI() const
492 return INIbeasts.get();
494 DataFileMgr * GetQuestsINI() const
496 return INIquests.get();
498 DataFileMgr * GetResDataINI() const
500 return INIresdata.get();
502 /** Gets the Game class */
503 Game * GetGame() const
505 return game;
507 /** Gets the Calendar class */
508 Calendar * GetCalendar() const
510 return calendar;
513 /** Gets the WorldMap class, returns the current worldmap or the first worldmap containing the area*/
514 WorldMap * GetWorldMap(const char *area = NULL);
515 void SetWindowFrame(int i, Sprite2D *Picture);
516 /** hides the game control window (if it exists), and reports success */
517 bool HideGCWindow();
518 /** unhides the game control window, if it exists */
519 void UnhideGCWindow();
520 GameControl *GetGameControl() const;
521 /** if backtomain is not null then goes back to main screen */
522 void QuitGame(int backtomain);
523 /** sets up load game */
524 void SetupLoadGame(Holder<SaveGame> save, int ver_override);
525 /** load saved game by index (-1 is default), ver_override is an optional parameter
526 to override the saved game's version */
527 void LoadGame(SaveGame *save, int ver_override);
528 /** fix changes in global script/worldmap*/
529 void UpdateMasterScript();
530 /*reads the filenames of the portraits folder into a list */
531 int GetPortraits(TextArea* ta, bool smallorlarge);
532 /*reads the filenames of the sounds folder into a list */
533 int GetCharSounds(TextArea *ta);
534 /*reads the filenames of the characters folder into a list */
535 int GetCharacters(TextArea *ta);
536 unsigned int GetInventorySize() const { return SlotTypes-1; }
537 ieDword FindSlot(unsigned int idx) const;
538 ieDword QuerySlot(unsigned int idx) const;
539 ieDword QuerySlotType(unsigned int idx) const;
540 ieDword QuerySlottip(unsigned int idx) const;
541 ieDword QuerySlotID(unsigned int idx) const;
542 ieDword QuerySlotFlags(unsigned int idx) const;
543 ieDword QuerySlotEffects(unsigned int idx) const;
544 const char * QuerySlotResRef(unsigned int idx) const;
545 /*returns true if an itemtype is acceptable for a slottype, also checks the usability flags */
546 int CanUseItemType(int slottype, Item *item, Actor *actor=NULL, bool feedback=false, bool equipped=false) const;
547 /*removes single file from cache*/
548 void RemoveFromCache(const ieResRef resref, SClass_ID SClassID);
549 /*removes all files from directory*/
550 void DelTree(const char *path, bool onlysaved);
551 /*returns 0,1,2 based on how the file should be saved */
552 int SavedExtension(const char *filename);
553 /*returns true if the file should never be deleted accidentally */
554 bool ProtectedExtension(const char *filename);
555 /*returns true if the directory path isn't good as a Cache */
556 bool StupidityDetector(const char* Pt);
557 /*handles the load screen*/
558 void LoadProgress(int percent);
560 Palette* CreatePalette(const Color &color, const Color &back);
562 void DragItem(CREItem* item, const ieResRef Picture);
563 CREItem* GetDraggedItem() const { return DraggedItem; }
564 /* use this only when the dragged item is dropped */
565 void ReleaseDraggedItem();
566 int GetDraggedPortrait() const { return DraggedPortrait; }
567 void SetDraggedPortrait(int dp, int cursor=-1);
568 CREItem *ReadItem(DataStream *str);
569 bool ResolveRandomItem(CREItem *itm);
570 ieStrRef GetRumour(const ieResRef resname);
571 Container *GetCurrentContainer();
572 int CloseCurrentContainer();
573 void SetCurrentContainer(Actor *actor, Container *arg, bool flag=false);
574 Store *GetCurrentStore();
575 int CloseCurrentStore();
576 Store *SetCurrentStore(const ieResRef resname, ieDword owner);
577 void SetMouseScrollSpeed(int speed);
578 int GetMouseScrollSpeed();
579 // FIXME: due to Win32 we have to allocate/release all common
580 // memory from Interface. Yes, it is ugly.
581 ITMExtHeader *GetITMExt(int count);
582 SPLExtHeader *GetSPLExt(int count);
583 //creates a standalone effect with opcode
584 Effect *GetEffect(ieDword opcode);
585 Effect *GetFeatures(int count);
586 void FreeITMExt(ITMExtHeader *p, Effect *e);
587 void FreeSPLExt(SPLExtHeader *p, Effect *e);
588 WorldMapArray *NewWorldMapArray(int count);
589 void DoTheStoreHack(Store *s);
590 /** plays stock gui sound referenced by index */
591 void PlaySound(int idx);
592 /** returns the first selected PC, if forced is set, then it returns
593 first PC if none was selected */
594 Actor *GetFirstSelectedPC(bool forced);
595 Actor *GetFirstSelectedActor();
596 /** returns a cursor sprite (not cached) */
597 Sprite2D *GetCursorSprite();
598 /** returns a scroll cursor sprite */
599 Sprite2D *GetScrollCursorSprite(int frameNum, int spriteNum);
600 /** returns 0 for unmovable, -1 for movable items, otherwise it
601 returns gold value! */
602 int CanMoveItem(const CREItem *item) const;
603 int GetMaximumAbility() const;
604 int GetStrengthBonus(int column, int value, int ex) const;
605 int GetIntelligenceBonus(int column, int value) const;
606 int GetDexterityBonus(int column, int value) const;
607 int GetConstitutionBonus(int column, int value) const;
608 int GetCharismaBonus(int column, int value) const;
609 int GetLoreBonus(int column, int value) const;
610 int GetWisdomBonus(int column, int value) const;
611 int GetReputationMod(int column) const;
613 /** applies the spell on the target */
614 void ApplySpell(const ieResRef resname, Actor *target, Scriptable *caster, int level);
615 /** applies the spell on the area or on a scriptable object */
616 void ApplySpellPoint(const ieResRef resname, Map *area, const Point &pos, Scriptable *caster, int level);
617 /** applies a single effect on the target */
618 int ApplyEffect(Effect *fx, Actor *target, Scriptable *caster);
619 /** applies an effect queue on the target */
620 int ApplyEffectQueue(EffectQueue *fxqueue, Actor *actor, Scriptable *caster);
621 int ApplyEffectQueue(EffectQueue *fxqueue, Actor *actor, Scriptable *caster, Point p);
622 Effect *GetEffect(const ieResRef resname, int level, const Point &p);
623 /** dumps an area object to the cache */
624 int SwapoutArea(Map *map);
625 /** saves (exports a character to the characters folder */
626 int WriteCharacter(const char *name, Actor *actor);
627 /** saves the game object to the destination folder */
628 int WriteGame(const char *folder);
629 /** saves the worldmap object to the destination folder */
630 int WriteWorldMap(const char *folder);
631 /** saves the .are and .sto files to the destination folder */
632 int CompressSave(const char *folder);
633 /** receives an autopause reason, returns 1 if pause was triggered by this call, -1 if it was already triggered */
634 int Autopause(ieDword reason);
635 /** registers engine opcodes */
636 void RegisterOpcodes(int count, const EffectRef *opcodes);
637 /** reads a list of resrefs into an array, returns array size */
638 int ReadResRefTable(const ieResRef tablename, ieResRef *&data);
639 /** frees the data */
640 void FreeResRefTable(ieResRef *&table, int &count);
641 /** Returns the item tooltip value for the xth extension header */
642 int GetItemTooltip(const ieResRef itemname, int idx, int identified);
643 /** Returns the item exclusion value */
644 int GetItemExcl(const ieResRef itemname) const;
645 /** Returns the strref for the item dialog */
646 int GetItemDialStr(const ieResRef itemname) const;
647 /** Returns the strref for the item dialog */
648 int GetItemDialRes(const ieResRef itemname, ieResRef dialog) const;
649 /** Returns the virtual worldmap entry of a sub-area */
650 int GetAreaAlias(const ieResRef areaname) const;
651 /** Returns up to 3 resources from resref, choosing rows randomly
652 unwanted return variables could be omitted */
653 void GetResRefFrom2DA(const ieResRef resref, ieResRef resource1, ieResRef resource2 = NULL, ieResRef resource3 = NULL);
654 /** returns a numeric list read from a 2da. The 0th element is the number of elements in the list */
655 ieDword *GetListFrom2DA(const ieResRef resref);
656 /** translates a stat symbol to numeric value */
657 ieDword TranslateStat(const char *stat_name);
658 /** Opens CD prompt window and waits for the specified disc */
659 void WaitForDisc(int disc_number, const char* path);
660 /** Returns the music playlist corresponding to the provided type */
661 /** it allows scrapping the entry, hence it isn't const */
662 char *GetMusicPlaylist(int SongType) const;
663 /** Removes the extraneus EOL newline and carriage return */
664 void StripLine(char * string, size_t size);
665 /** Returns the DeathVarFormat of the day */
666 static const char *GetDeathVarFormat();
667 private:
668 int LoadSprites();
669 bool LoadConfig(void);
670 bool LoadConfig(const char *filename);
671 bool LoadGemRBINI();
672 bool LoadINI(const char * filename);
673 bool InitItemTypes();
674 bool ReadRandomItems();
675 bool ReadItemTable(const ieResRef item, const char *Prefix);
676 bool ReadAbilityTables();
677 bool ReadAbilityTable(const ieResRef name, ieWordSigned *mem, int cols, int rows);
678 bool ReadMusicTable(const ieResRef name, int col);
679 bool ReadDamageTypeTable();
680 bool ReadReputationModTable();
681 bool ReadGameTimeTable();
682 bool ReadModalStates();
683 /** Reads table of area name mappings for WorldMap (PST only) */
684 bool ReadAreaAliasTable(const ieResRef name);
685 /** Reads itemexcl, itemdial, tooltip */
686 bool ReadAuxItemTables();
687 /** handles the QuitFlag bits (main loop events) */
688 void HandleFlags();
689 /** handles the EventFlag bits (conditional events) */
690 void HandleEvents();
691 /** handles hardcoded gui behaviour */
692 void HandleGUIBehaviour();
693 /** Creates a game control, closes all other windows */
694 GameControl* StartGameControl();
695 /** Executes everything (non graphical) in the main game loop */
696 void GameLoop(void);
697 /** the internal (without cache) part of GetListFrom2DA */
698 ieDword *GetListFrom2DAInternal(const ieResRef resref);
699 public:
700 char GameDataPath[_MAX_PATH];
701 char GameOverridePath[_MAX_PATH];
702 char GameSoundsPath[_MAX_PATH];
703 char GameScriptsPath[_MAX_PATH];
704 char GamePortraitsPath[_MAX_PATH];
705 char GameCharactersPath[_MAX_PATH];
706 char GemRBOverridePath[_MAX_PATH];
707 ieResRef GameNameResRef;
708 ieResRef GoldResRef; //MISC07.itm
709 Variables *RtRows;
710 char UserDir[_MAX_PATH];
711 int argc;
712 char **argv;
713 char GameName[_MAX_PATH];
714 char GameType[_MAX_PATH];
715 char GemRBPath[_MAX_PATH];
716 char PluginsPath[_MAX_PATH];
717 char CachePath[_MAX_PATH];
718 char GUIScriptsPath[_MAX_PATH];
719 char SavePath[_MAX_PATH];
720 char INIConfig[_MAX_PATH];
721 char GamePath[_MAX_PATH];
722 std::vector<std::string> CD[MAX_CD];
723 std::vector<std::string> ModPath;
724 int Width, Height, Bpp, ForceStereo;
725 unsigned int TooltipDelay;
726 unsigned int FogOfWar;
727 bool CaseSensitive, GameOnCD, SkipIntroVideos, DrawFPS;
728 bool GUIEnhancements;
729 bool KeepCache;
730 Variables *plugin_flags;
731 /** The Main program loop */
732 void Main(void);
733 /** returns true if the game is paused */
734 bool IsFreezed();
735 /** Draws the Visible windows in the Windows Array */
736 void DrawWindows(void);
737 /** Sends a termination signal to the Video Driver */
738 bool Quit(void);
739 /** CheatKey support */
740 inline void EnableCheatKeys(int Flag)
742 CheatFlag=(Flag > 0);
745 inline bool CheatEnabled()
747 return CheatFlag;
750 inline void SetEventFlag(int Flag)
752 EventFlag|=Flag;
754 inline void ResetEventFlag(int Flag)
756 EventFlag&=~Flag;
759 static void SanityCheck(const char *ver);
761 /** Set Next Script */
762 void SetNextScript(const char *script);
763 /** Console is on Screen */
764 bool ConsolePopped;
765 /** Cheats enabled? */
766 bool CheatFlag;
767 /** The Console Object */
768 Console * console;
770 Audio* GetAudioDrv(void) const;
772 #ifdef _DEBUG
773 int FileStreamPtrCount;
774 int CachedFileStreamPtrCount;
775 #endif
778 extern GEM_EXPORT Interface * core;
780 #endif