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