/** ****************************************************************************** @file /common/rm/rm.h @brief Common ancestor for all RMs, definition of paths @author Vta @version 1.0 ******************************************************************************/ #ifndef _RM_ #define _RM_ #include "config.h" #include "common/xml/xml.h" #include "common/Msg.h" #include "common/exc.h" #include "common/utils.h" #include "common/Interface.h" #include "SDL/SDL.h" #include "SDL/SDL_mutex.h" #include "SDL/SDL_thread.h" #include "common/priority.h" /// Namespace for Resource Manager namespace rm { #define XML_DIR "xml/" ///< The main resources directory #define BMP_DIR "bitmap/" ///< Directory with bmp files #define TGA_DIR "bitmap/" ///< Directory with tga files #define LANGUAGES_DIR "xml/languages/" ///< Directory with texts (translations) #define UNITS_DIR "xml/units/" ///< Directory with units #define BUILDINGS_DIR "xml/buildings/" ///< Directory with buildings #define SPELLS_DIR "xml/spells/" ///< Directory with spells (not used now) #define BONUSES_DIR "xml/bonuses/" ///< Directory with bonuses #define MAPS_DIR "xml/maps/" ///< Directory with maps #ifdef WIN32 #define SAVEGAME_DIR "savegame/" ///< Directory with savegames for Windows #endif #define SYMBOLS_DIR "xml/symbols/" ///< Directory with symbols #define MODEL_DIR "model/" ///< Directory with models #define SCRIPTS_DIR "xml/scripts/" ///< Directory with scripts #define MUSICS_DIR "sounds/" ///< Directory with music #define SAMPLES_DIR "sounds/" ///< Directory with sounds/voices #ifdef WIN32 #define CONFIG_DIR "./" ///< Path to config.xml for Windows #endif #define DEFAULT_RESOLUTION 0 ///< Default resolution #define DEFAULT_FULLSCREEN 1 ///< Default fullscreen option #define DEFAULT_LANGUAGE 1 ///< Default language #define DEFAULT_SPEED 3 ///< Default game speed #define DEFAULT_SFX_VOLUME 47 ///< Default sfx volume #define DEFAULT_MUSIC_VOLUME 59 ///< Default music volume #define DEFAULT_ANNOUNCE 1 ///< Default annoucement of the game #define DEFAULT_AUTOSAVE 1 ///< Default autosaves each turn #define DEFAULT_K8PACK "./" ///< Default package #define MAX_MAP_WIDTH 30 ///< Max size of Map #define MAX_MAP_HEIGHT 70 ///< Max width of Map /// Class Resource Manager class TRM // CLSDBG1 { public: /** Construktor */ TRM(); /** Destructor */ ~TRM(); /** @name Loading/releasing of the resources */ //@{ /** Nacteni zdroj s indexem id */ virtual void loadData(int id) = 0; /** Odstraneni zdroj s indexem id z pameti */ virtual void freeData(int id) = 0; /** Pozadavek na nacteni zdroje s indexem id @return Vraci kolik pozadavku prednim */ int request(int id); /** Pozadavek na nacteni vsech zdroju daneho typu @return Pocet prvku pridanych do fronty */ int requestAll(); /** Zpracuje vsechny pozadavky - nacte zdroje */ void loadBuffer(void); /** Zjisti celkovy pocet objektu ve fronte pozadvku na nacteni */ int getObjectsToLoad(); /** Zjisti status pri nacitani fronty pozodavku */ int getStatus(); /** Zmeni (zvetsi) aktualni pouzitou skupinu @return vraci cislo nove skupiny */ int startNewGroup(); /** Zapise pro dany id jeho skupinu */ void writeGroup(int id); /** Odstrani z pameti objekty z posledni skupiny, vraci id predposleni skupiny (tj. posledni po uvolneni) */ int freeLastGroup(); /** Odstrani z pameti zdroje s konkretni skupinou */ void freeHavingGroup(int group); /** Vraci nejvetsi (tj aktualni) pouzitou skupinu */ int getCurrentGroup(); /** Vraci skupinu zdroje s indexem id */ int getGroupOfObject(int id); //@} protected: /** Nacte soubor se seznamem vsech jazyku/jednotek/ apod. @param file je jmeno nacitaneho souboru */ int readInfoFile(char *file); /** Zapise indexovy soubor. @param pack aktualni balicek @param file je jmeno prislusneho informacniho souboru @return XML_ERROR_OK v pripade uspechu */ int saveToFile(char * pack, char * file); /** Data z XML databaze. Napr. languages.xml, units.xml atd. - odkaz na vlastni zdroje */ TXMLdata * index; /** Zamkne zamek + osetreni */ void lock(void); /** Odemkne zamek */ void unlock(void); /** Zamek pri pristup k datum, aby se nepristupovalo k necemu, co se zrovna edituje */ SDL_mutex *mutex; /** Fronta na pozadavky nactni */ DA * buffer; /** Informace o skupinach */ DA * groups; /** Aktualni skupina */ int group; /** Pocet objektu ve fronte objektu na nacteni od doby, kdy probehlo nacitani, jinak -1 */ int toload; /** Pocet nactenych objektu od doby, kdy bylo zahajeno nacitani, jinak -1 */ int status; }; } // namespace rm #endif // ifndef RM /*****************************************************************************/