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