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.
28 #include "ResourceManager.h"
36 class ScriptedAnimation
;
44 unsigned int refcount
;
47 class GEM_EXPORT GameData
: public ResourceManager
56 Actor
*GetCreature(const char *ResRef
, unsigned int PartySlot
=0);
57 /** Returns a PC index, by loading a creature */
58 int LoadCreature(const char *ResRef
, unsigned int PartySlot
, bool character
=false);
61 // 2DA table functions.
62 // (See also the AutoTable class)
64 /** Loads a 2DA Table, returns -1 on error or the Table Index on success */
65 int LoadTable(const char * ResRef
);
66 /** Gets the index of a loaded table, returns -1 on error */
67 int GetTableIndex(const char * ResRef
) const;
68 /** Gets a Loaded Table by its index, returns NULL on error */
69 Holder
<TableMgr
> GetTable(unsigned int index
) const;
70 /** Frees a Loaded Table, returns false on error, true on success */
71 bool DelTable(unsigned int index
);
73 Palette
* GetPalette(const ieResRef resname
);
74 void FreePalette(Palette
*&pal
, const ieResRef name
=NULL
);
76 Item
* GetItem(const ieResRef resname
);
77 void FreeItem(Item
const *itm
, const ieResRef name
, bool free
=false);
78 Spell
* GetSpell(const ieResRef resname
, bool silent
=false);
79 void FreeSpell(Spell
*spl
, const ieResRef name
, bool free
=false);
80 Effect
* GetEffect(const ieResRef resname
);
81 void FreeEffect(Effect
*eff
, const ieResRef name
, bool free
=false);
83 /** creates a vvc/bam animation object at point */
84 ScriptedAnimation
* GetScriptedAnimation( const char *ResRef
, bool doublehint
);
86 /** returns a single sprite (not cached) from a BAM resource */
87 Sprite2D
* GetBAMSprite(const ieResRef ResRef
, int cycle
, int frame
);
89 /** returns factory resource, currently works only with animations */
90 void* GetFactoryResource(const char* resname
, SClass_ID type
,
91 unsigned char mode
= IE_NORMAL
, bool silent
=false);
98 std::vector
<Table
> tables
;
101 extern GEM_EXPORT GameData
* gamedata
;
104 class ResourceHolder
: public Holder
<T
>
110 ResourceHolder(const char* resname
)
111 : Holder
<T
>(static_cast<T
*>(gamedata
->GetResource(resname
,&T::ID
)))
114 ResourceHolder(const char* resname
, const ResourceManager
& manager
, bool silent
= false)
115 : Holder
<T
>(static_cast<T
*>(manager
.GetResource(resname
,&T::ID
,silent
)))