/** ****************************************************************************** @file /common/rm/rmconfi.cpp @brief Interface k RMconf @author Vta @version 1.0 ******************************************************************************/ #include "common/rm/rmconfi.h" #include "common/compatibility.h" using namespace rm; char * TRM_conf_i::getPack() // vrati aktualni balicek { return this->k8pack; } char * TRM_conf_i::getOtherFile() // vrati jmeno souobru, ktere obsahuje informace o misc. xml souborech { this->rmconf->getFromFiles(&(this->data),"other",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getModelFile() // vrati jmeno souobru, ktere obsahuje informace o vsech modelech { this->rmconf->getFromFiles(&(this->data),"model",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getSoundFile() // vrati jmeno souobru, ktere obsahuje informace o vsech jednotkach { this->rmconf->getFromFiles(&(this->data),"sound",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getUnitFile() // vrati jmeno souobru, ktere obsahuje informace o vsech jednotkach { this->rmconf->getFromFiles(&(this->data),"unit",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getBuildingFile() // vrati jmeno souobru, ktere obsahuje informace o vsech budovach { this->rmconf->getFromFiles(&(this->data),"building",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getBonusFile() { this->rmconf->getFromFiles(&(this->data),"bonus",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getRasterFile() // vrati jmeno souobru, ktere obsahuje informace o vsech rastrovych obrazcich { this->rmconf->getFromFiles(&(this->data),"raster",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getSymbolFile() // vrati jmeno souobru, ktere obsahuje informace o vsech symbolech { this->rmconf->getFromFiles(&(this->data),"symbol",(this->sizeofdata)); // i==-1 osetri RM return this->data; } char * TRM_conf_i::getLanguageFile() // vrati jmeno souobru, ktere obsahuje informace o vsech jazycich { this->rmconf->getFromFiles(&(this->data),"lang",(this->sizeofdata)); // i==-1 osetri RM return this->data; } void TRM_conf_i::getProfiles(DA ** profiles) { this->rmconf->getProfiles(profiles); } void TRM_conf_i::deleteProfile(int id) { DA * profiles; this->rmconf->getProfiles(&profiles); int who=id; if ((*profiles)[who]!=NULL) { KMemFree((*profiles)[who]); (*profiles)[who]=NULL; } // this->rmconf->saveConfigBeforeExit(); } int TRM_conf_i::addProfile(TProfile * profile) { DA * profiles; this->rmconf->getProfiles(&profiles); int i=1; while ((*profiles)[i]!=NULL) { i++; } profile->id=i; (*profiles)[i]=(TProfile*)KMemAlloc(sizeof(TProfile)); strcpy((*profiles)[i]->name,profile->name); (*profiles)[i]->id=i; (*profiles)[i]->speed=DEFAULT_SPEED; (*profiles)[i]->sfx_volume=DEFAULT_SFX_VOLUME; (*profiles)[i]->music_volume=DEFAULT_MUSIC_VOLUME; (*profiles)[i]->fullscreen=DEFAULT_FULLSCREEN; (*profiles)[i]->language_id=DEFAULT_LANGUAGE; (*profiles)[i]->announce=DEFAULT_ANNOUNCE; (*profiles)[i]->autosave=DEFAULT_AUTOSAVE; return i; // this->rmconf->saveConfigBeforeExit(); } void TRM_conf_i::setDefaultFullscreen(int fullscr) { snprintf(this->data,this->sizeofdata-1,"%i",fullscr); this->rmconf->setToConfig("default_fullscreen",this->data); } int TRM_conf_i::getDefaultFullscreen() { this->rmconf->getFromConfig(&(this->data),"default_fullscreen",(this->sizeofdata)); // i==-1 osetri RM int fs=atoi(this->data); if (fs!=0) return 1; else return 0; } void TRM_conf_i::setDefaultResolution(int sizeId) { snprintf(this->data,this->sizeofdata-1,"%i",sizeId); this->rmconf->setToConfig("default_resolution",this->data); } int TRM_conf_i::getDefaultResolution() { this->rmconf->getFromConfig(&(this->data),"default_resolution",(this->sizeofdata)); // i==-1 osetri RM int fs=atoi(this->data); if (fs>4) return 4; else if (fs<0) return 0; else return fs; } void TRM_conf_i::setDefaultLanguage(int langId) { snprintf(this->data,this->sizeofdata-1,"%i",langId); this->rmconf->setToConfig("default_language",this->data); } int TRM_conf_i::getDefaultLanguage() // vrati vychozi jazyk z configu { this->rmconf->getFromConfig(&(this->data),"default_language",(this->sizeofdata)); // i==-1 osetri RM return (atoi(this->data)); } void TRM_conf_i::setLastUsedProfile(int id) { sprintf(this->data,"%i",id); this->rmconf->setToConfig("last_profile",this->data); } int TRM_conf_i::getLastUsedProfile() { try { this->rmconf->getFromConfig(&(this->data),"last_profile",(this->sizeofdata)); // i==-1 osetri RM int pr=atoi(this->data); DA * profiles; this->rmconf->getProfiles(&profiles); if ((*profiles)[pr]==NULL) return -1; else return pr; } catch (E_8K_RM) { return -1; } } void TRM_conf_i::getGUIconfig(TGUIconfig * cfg) { } TRM_conf_i::TRM_conf_i(TRM_conf * globalrmconf) { this->rmconf=globalrmconf; this->sizeofdata=100; this->data=(char*) KMemAlloc(sizeof(char)*100); this->sizeofk8pack=100; size_t size=0; this->rmconf->getFromConfig(&(this->k8pack),"default_K8pack",(size)); // i==-1 osetri RM this->sizeofk8pack=strlen(this->k8pack)+1; GLOBALLOGID(PRIORITY_CONFIRM ,"RMconfi was created"); this->changeinconfig=0; } TRM_conf_i::~TRM_conf_i() { GLOBALLOGID(PRIORITY_CONFIRM ,"RMconfi was destroyed"); KMemFree(this->data); KMemFree(this->k8pack); }