Esempio n. 1
0
	static void ReloadLoginIDBans()
	{
		// init variables
		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scAcctPath = string(szDataPath) + "\\Accts\\MultiPlayer\\loginidbans.ini";
		if (set_iPluginDebug)
			ConPrint(L"NOTICE: Loading Login ID bans from %s\n",stows(scAcctPath).c_str());

		INI_Reader ini;
		set_lstLoginIDBans.clear();
		if (ini.open(scAcctPath.c_str(), false))
		{
			while (ini.read_header())
			{
				while (ini.read_value())
				{
					set_lstLoginIDBans.push_back(Trim(ini.get_name_ptr()));
					if (set_iPluginDebug)
						ConPrint(L"NOTICE: Adding Login ID ban %s\n", stows(ini.get_name_ptr()).c_str());
				}
			}
			ini.close();
		}
		ConPrint(L"ID Bans [%u]\n",set_lstLoginIDBans.size());
	}
Esempio n. 2
0
bool SaveMode::_LoadGame(int id) {
	std::ostringstream f;
	f << GetUserDataPath(true) + "saved_game_" << id << ".lua";
	std::string filename = f.str();

	if (DoesFileExist(filename)) {
		_current_state = SAVE_MODE_FADING_OUT;
		AudioManager->StopAllMusic();

		GlobalManager->LoadGame(filename, (uint32)id);

		// Create a new map mode, and fade out and in
		ModeManager->PopAll();
        try {
            MapMode *MM = new MapMode(GlobalManager->GetMapFilename());
            ModeManager->Push(MM, true, true);
        } catch (const luabind::error& e) {
            PRINT_ERROR << "Map::_Load -- Error loading map " << GlobalManager->GetMapFilename()
				<< ", returning to BootMode." << std::endl
				<< "Exception message:" << std::endl;
            ScriptManager->HandleLuaError(e);
            ModeManager->Push(new BootMode(), true, true);
        }
		return true;
	}
	else {
		PRINT_ERROR << "BOOT: No saved game file exists, can not load game: "
			<< filename << std::endl;
		return false;
	}
}
Esempio n. 3
0
	/** Start automatic zone checking */
	void IPBans::AdminCmd_AuthenticateChar(CCmds* cmds, const wstring &wscCharname)
	{
		if (!(cmds->rights & RIGHT_SUPERADMIN))
		{
			cmds->Print(L"ERR No permission\n");
			return;
		}

		// init variables
		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);

		wstring wscDir;
		if (HkGetAccountDirName(wscCharname, wscDir)!=HKE_OK)
		{
			cmds->Print(L"ERR Account not found\n");
			return;
		}

		string scPath = string(szDataPath) + "\\Accts\\MultiPlayer\\" + wstos(wscDir) + "\\authenticated";
		FILE *fTest = fopen(scPath.c_str(), "w");
		if (!fTest)
		{
			cmds->Print(L"ERR Writing authentication file\n");
			return;
		}

		fclose(fTest);
		cmds->Print(L"OK\n");
	}
void BiLiOBSMainWid::mSaveProjectDeferred() {

	if (mDisableSaving)
		return;

	if (!mProjectChanged)
		return;

	mProjectChanged = false;

	const char *sceneCollection = config_get_string(App()->mGetGlobalConfig(),
			"Basic", "SceneCollectionFile");
	char savePath[512];
	char fileName[512];
	int ret;

	if (!sceneCollection)
		return;

	ret = snprintf(fileName, 512, QString("%1\\%2").arg(QString::fromStdString(gBili_mid)).arg("basic/scenes/%s.json").toUtf8().data(), sceneCollection);
	if (ret <= 0)
		return;

	ret = GetUserDataPath(savePath, sizeof(savePath), fileName);
	if (ret <= 0)
		return;

	mSave(savePath);
}
Esempio n. 5
0
void StringToProfile(char *name, char *string)
{
    if (!szProfileName[0])
    {
        GetUserDataPath(szProfileName);
        strcat(szProfileName,"\\ocide.ini");
    }
        WritePrivateProfileString(szProfileClass, name, string, szProfileName);
}
Esempio n. 6
0
int RestorePreferences(void)
{
    int version;
    FILE *in;
    struct xmlNode *root;
    struct xmlNode *nodes,  *children;
    struct xmlAttr *attribs;
    char  *p; 
    char name[256];
    if (!generalProject.profiles)
        generalProject.profiles = calloc(1, sizeof(PROFILE));
    GetUserDataPath(name);
    strcat(name, PREFFILE);
    in = fopen(name, "r");
    if (!in)
    {
        LoadDefaultRules();
        return 0;
    }
    root = xmlReadFile(in);
    fclose(in);
    if (!root || !IsNode(root, "UIPREFS"))
    {
        LoadDefaultRules();
        return 0;
    }
    nodes = root->children;
    while (nodes)
    {
        if (IsNode(nodes, "VERSION"))
        {
            struct xmlAttr *attribs = nodes->attribs;
            while (attribs)
            {
                if (IsAttrib(attribs, "ID"))
                    version = atoi(attribs->value);
                attribs = attribs->next;
            } 
        }
        else if (IsNode(nodes, "PROPERTIES"))
            RestoreGeneralProps(nodes, version);
        else if (IsNode(nodes, "MEMWND"))
            RestoreMemoryWindowSettings(nodes, version);
        else if (IsNode(nodes, "FIND"))
            RestoreFindflags(nodes, version);
        else if (IsNode(nodes, "PLACEMENT"))
            RestorePlacement(nodes, version);
        else if (IsNode(nodes, "CUSTOMCOLORS"))
            RestoreCustomColors(nodes, version);
        else if (IsNode(nodes, "RULES"))
            RestoreBuildRules(nodes, version);
        nodes = nodes->next;
    }
    xmlFree(root);
    PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0);
    return 1;
}
Esempio n. 7
0
	void LoadSettings(const string &scPluginCfgFile)
	{
		set_iRenameCost = IniGetI(scPluginCfgFile, "Rename", "RenameCost", 5000000);
		set_iRenameTimeLimit = IniGetI(scPluginCfgFile, "Rename", "RenameTimeLimit", 3600);
		set_iMoveCost = IniGetI(scPluginCfgFile, "Rename", "MoveCost", 5000000);
		set_bCharnameTags = IniGetB(scPluginCfgFile, "Rename", "CharnameTag", false);
		set_bAsciiCharnameOnly = IniGetB(scPluginCfgFile, "Rename", "AsciiCharnameOnly", true);
		set_iMakeTagCost = IniGetI(scPluginCfgFile, "Rename", "MakeTagCost", 50000000);

		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scPath = string(szDataPath) + "\\Accts\\MultiPlayer\\tags.ini";

		INI_Reader ini;
		if (ini.open(scPath.c_str(), false))
		{
			while (ini.read_header())
			{
				if (ini.is_header("faction"))
				{
					wstring tag;
					while (ini.read_value())
					{
						if (ini.is_value("tag"))
						{
							ini_get_wstring(ini, tag);
							mapTagToPassword[tag].tag = tag;
						}
						else if (ini.is_value("master_password"))
						{
							wstring pass;
							ini_get_wstring(ini, pass);
							mapTagToPassword[tag].master_password = pass;
						}
						else if (ini.is_value("rename_password"))
						{
							wstring pass;
							ini_get_wstring(ini, pass);
							mapTagToPassword[tag].rename_password = pass;
						}
						else if (ini.is_value("last_access"))
						{
							mapTagToPassword[tag].last_access = ini.get_value_int(0);
						}
						else if (ini.is_value("description"))
						{
							wstring description;
							ini_get_wstring(ini, description);
							mapTagToPassword[tag].description = description;
						}
					}
				}
			}
			ini.close();
		}
	}
Esempio n. 8
0
std::string SaveMode::_BuildSaveFilename(uint32_t id, bool autosave)
{
    std::ostringstream file;
    file << GetUserDataPath() + "saved_game_" << id;
    if (autosave)
        file << "_autosave.lua";
    else
        file << ".lua";
    return file.str();
}
Esempio n. 9
0
void _InitLog()
{
#ifdef _DEBUG
	QLogImpl::GetInstance()->SetLogLevel(LV_PRO);
#else
	QLogImpl::GetInstance()->SetLogLevel(LV_APP);
#endif
	std::wstring dir = GetUserDataPath();
	QLogImpl::GetInstance()->SetLogFile(dir + kLogFile);
}
// Generates the fully qualified path to the file used to store the access token 
CString SCToken::GetTokenFilePath(void)
{
	TCHAR userDataPath[MAX_PATH];
	GetUserDataPath(userDataPath);

	CString fileName;
	fileName.Format(_T("%s.scx"), m_ClientId);
	PathAppend(userDataPath, fileName);

	return CString(userDataPath);
}
Esempio n. 11
0
char *getprofilestring(char *name, char *def, HKEY rootkey)
{
    static char buf[512];
    if (!szProfileName[0])
    {
        GetUserDataPath(szProfileName);
        strcat(szProfileName,"\\ocide.ini");
    }
        GetPrivateProfileString(szProfileClass, name, def, buf, 256,
            szProfileName);
    return buf;
}
Esempio n. 12
0
/**
Determine the path name of a file in the charname account directory with the
provided extension. The resulting path is returned in the path parameter.
*/
string GetUserFilePath(const wstring &charname)
{
	// init variables
	char datapath[MAX_PATH];
	GetUserDataPath(datapath);
	string scAcctPath = string(datapath) + "\\Accts\\MultiPlayer\\";

	wstring wscDir;
	wstring wscFile;
	if (HkGetAccountDirName(charname, wscDir)!=HKE_OK)
		return "";
	if (HkGetCharFileName(charname, wscFile)!=HKE_OK)
		return "";

	return scAcctPath + wstos(wscDir) + "\\" + wstos(wscFile) + ".fl";
}
Esempio n. 13
0
// ****************************************************************************
// ***** BootMode menu setup and refresh methods
// ****************************************************************************
bool BootMode::_SavesAvailable()
{
    int32_t savesAvailable = 0;
    std::string data_path = GetUserDataPath();
    uint32_t max_slot_id = SystemManager->GetGameSaveSlots();
    for(uint32_t id = 0; id < max_slot_id; ++id) {
        std::ostringstream f;
        f << data_path + "saved_game_" << id << ".lua";
        const std::string filename = f.str();

        if(DoesFileExist(filename)) {
            ++savesAvailable;
        }
    }
    return (savesAvailable > 0);
}
Esempio n. 14
0
// ****************************************************************************
// ***** BootMode menu setup and refresh methods
// ****************************************************************************
bool BootMode::_SavesAvailable(int32_t maxId)
{
    assert(maxId > 0);
    int32_t savesAvailable = 0;
    std::string data_path = GetUserDataPath();
    for(int id = 0; id < maxId; ++id) {
        std::ostringstream f;
        f << data_path + "saved_game_" << id << ".lua";
        const std::string filename = f.str();

        if(DoesFileExist(filename)) {
            ++savesAvailable;
        }
    }
    return (savesAvailable > 0);
}
Esempio n. 15
0
/* copy pasta from playercntl as to provide independance*/
string GetUserFilePath(const wstring &wscCharname, const string &scExtension)
{
	// init variables
	char szDataPath[MAX_PATH];
	GetUserDataPath(szDataPath);
	string scAcctPath = string(szDataPath) + "\\Accts\\MultiPlayer\\";

	wstring wscDir;
	wstring wscFile;
	if (HkGetAccountDirName(wscCharname, wscDir) != HKE_OK)
		return "";
	if (HkGetCharFileName(wscCharname, wscFile) != HKE_OK)
		return "";

	return scAcctPath + wstos(wscDir) + "\\" + wstos(wscFile) + scExtension;
}
Esempio n. 16
0
//-------------------------------------------------------------------------
void SavePreferences(void)
{
    int i;
    char name[256];
    WINDOWPLACEMENT wp;
    FILE *out;
    GetUserDataPath(name);
    strcat(name, PREFFILE);
    out = fopen(name, "w");
    if (!out)
        return;
    fprintf(out, "<UIPREFS>\n");
    fprintf(out, "\t<VERSION ID=\"%d\"/>\n", PREFVERS);
    wp.length = sizeof(wp);
    GetWindowPlacement(hwndFrame, &wp);
    fprintf(out, "\t<PLACEMENT VALUE=\"%d %d %d %d %d %d %d %d %d %d\"/>\n",
        wp.flags, wp.showCmd, wp.ptMinPosition.x, wp.ptMinPosition.y,
        wp.ptMaxPosition.x, wp.ptMaxPosition.y, wp.rcNormalPosition.left,
        wp.rcNormalPosition.top, wp.rcNormalPosition.right,
        wp.rcNormalPosition.bottom);
    fprintf(out, "\t<CUSTOMCOLORS>\n\t\t");
    for (i = 0; i < 16; i++)
    {
        fprintf(out, "%d ", custColors[i]);
        if (i == 7)
            fprintf(out, "\n\t\t");
    }
    fprintf(out, "\n\t</CUSTOMCOLORS>\n");
    fprintf(out, "\t<MEMWND WORDSIZE=\"%d\"/>\n", memoryWordSize);
    fprintf(out, "\t<FIND FMODE=\"%d\" RMODE=\"%d\" FIFFINDMODE=\"%d\" FIFREPLACEMODE=\"%d\">\n", findmode, replacemode, fiffindmode, fifreplacemode);
    for (i=0; i < F_M_MAX; i++)
    {
        fprintf(out, "\t\t<MODE INDEX=\"%d\" FIND=\"%d\" REPLACE=\"%d\"/>\n", i, findflags[i], replaceflags[i]);
    }			
    fprintf(out, "\t</FIND>\n");
    fprintf(out, "\t<PROPERTIES>\n");
    SaveProps(out, generalProject.profiles->debugSettings, 2);
    fprintf(out, "\t</PROPERTIES>\n");
    fprintf(out, "\t<RULES>\n");
    SaveBuildRules(out);
    fprintf(out, "\t</RULES>\n");
    fprintf(out, "</UIPREFS>\n");
    fclose(out);
}
Esempio n. 17
0
	static bool IsBanned(wstring charname)
	{
		char datapath[MAX_PATH];
		GetUserDataPath(datapath);

		wstring dir;
		HkGetAccountDirName(charname, dir);

		string banfile = string(datapath) + "\\Accts\\MultiPlayer\\" + wstos(dir) + "\\banned";

		// Prevent ships from banned accounts from being moved.
		FILE *f = fopen(banfile.c_str(), "r");
		if (f)
		{
			fclose(f);
			return true;
		}
		return false;
	}
bool TextureController::_SaveTempTextures() {
	bool success = true;

	for (map<string, ImageTexture*>::iterator i = _images.begin(); i != _images.end(); i++) {
		ImageTexture *image = i->second;

		// Check that this is a temporary texture and if so, save it to disk as a .png file
		if (image->tags.find("<T>") != string::npos) {
			IF_PRINT_DEBUG(VIDEO_DEBUG) << " saving temporary texture " << image->filename << endl;
			ImageMemory buffer;
			buffer.CopyFromImage(image);
			string path = GetUserDataPath(true);
			if (buffer.SaveImage(path + image->filename + ".png", true) == false) {
				success = false;
				IF_PRINT_WARNING(VIDEO_DEBUG) << "call to ImageMemory::SaveImage() failed" << endl;
			}
		}
	}
	return success;
}
Esempio n. 19
0
	void SaveSettings()
	{
		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scPath = string(szDataPath) + "\\Accts\\MultiPlayer\\tags.ini";

		FILE *file = fopen(scPath.c_str(), "w");
		if (file)
		{
			for (std::map<wstring, TAG_DATA>::iterator i = mapTagToPassword.begin(); i != mapTagToPassword.end(); ++i)
			{
				fprintf(file, "[faction]\n");
				ini_write_wstring(file, "tag", i->second.tag);
				ini_write_wstring(file, "master_password", i->second.master_password);
				ini_write_wstring(file, "rename_password", i->second.rename_password);
				ini_write_wstring(file, "description", i->second.description);
				fprintf(file, "last_access = %u\n", i->second.last_access);
			}
			fclose(file);
		}
	}
Esempio n. 20
0
// Save mission status every 100 seconds
void HkTimerCheckKick()
{
	if ((time(0) % 100) == 0)
	{
		char szDataPath[MAX_PATH];
		GetUserDataPath(szDataPath);
		string scStatsPath = string(szDataPath) + "\\Accts\\MultiPlayer\\event_stats.txt";	

		FILE *file = fopen(scStatsPath.c_str(), "w");
		if (file)
		{
			fprintf(file, "[Missions]\n");
			for (multimap<uint, NPC_MISSION>::iterator i = set_mapNpcMissions.begin(); i != set_mapNpcMissions.end(); ++i)
			{
				fprintf(file, "npc = %s, %d, %d\n", i->second.nickname.c_str(), i->second.required_amount, i->second.curr_amount);
			}
			for (multimap<uint, CARGO_MISSION>::iterator i = set_mapCargoMissions.begin(); i != set_mapCargoMissions.end(); ++i)
			{
				fprintf(file, "cargo = %s, %d, %d\n", i->second.nickname.c_str(), i->second.required_amount, i->second.curr_amount);
			}
			fclose(file);
		}
	}
}
Esempio n. 21
0
QString CWizDatabase::GetUserAttachmentsDataPath() const
{
    QString strPath = GetUserDataPath() + "attachments/";
    WizEnsurePathExists(strPath);
    return  strPath;
}
Esempio n. 22
0
void LoadSettings()
{
	// The path to the configuration file.
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(sizeof(szCurDir), szCurDir);
	string scPluginCfgFile = string(szCurDir) + "\\flhook_plugins\\event.cfg";

	INI_Reader ini;
	set_mapCargoMissions.clear();
	set_mapNpcMissions.clear();
	if (ini.open(scPluginCfgFile.c_str(), false))
	{
		while (ini.read_header())
		{	
			if (ini.is_header("General"))
			{
				while (ini.read_value())
				{
					if (ini.is_value("debug"))
					{ 
						set_iPluginDebug = ini.get_value_int(0);
					}
					else if (ini.is_value("cargo"))
					{
						CARGO_MISSION mis;
						mis.nickname = ini.get_value_string(0);
						mis.base = CreateID(ini.get_value_string(1));
						mis.item = CreateID(ini.get_value_string(2));
						mis.required_amount = ini.get_value_int(3);
						set_mapCargoMissions.insert(multimap<uint, CARGO_MISSION>::value_type(mis.base, mis));
					}
					else if (ini.is_value("npc"))
					{
						NPC_MISSION mis;
						mis.nickname = ini.get_value_string(0);
						mis.system = CreateID(ini.get_value_string(1));
						mis.sector = ini.get_value_string(2);
						pub::Reputation::GetReputationGroup(mis.reputation, ini.get_value_string(3));
						mis.required_amount = ini.get_value_int(4);
						set_mapNpcMissions.insert(multimap<uint, NPC_MISSION>::value_type(mis.reputation, mis));
					}
				}
			}
			ini.close();
		}

		if (set_iPluginDebug&1)
		{
			ConPrint(L"CargoMissionSettings loaded [%d]\n",set_mapCargoMissions.size());
			ConPrint(L"NpcMissionSettings loaded [%d]\n",set_mapNpcMissions.size());
		}
		ini.close();
	}
	
	// Read the last saved event status
	char szDataPath[MAX_PATH];
	GetUserDataPath(szDataPath);
	string scStatsPath = string(szDataPath) + "\\Accts\\MultiPlayer\\event_stats.txt";	
	if (ini.open(scStatsPath.c_str(), false))
	{
		while (ini.read_header())
		{	
			if (ini.is_header("Missions"))
			{
				while (ini.read_value())
				{
					if (ini.is_value("cargo"))
					{
						string nickname = ini.get_value_string(0);
						int curr_amount = ini.get_value_int(2);

						for (multimap<uint, CARGO_MISSION>::iterator i = set_mapCargoMissions.begin();
							i != set_mapCargoMissions.end(); ++i)
						{
							if (i->second.nickname == nickname)
							{
								i->second.curr_amount = curr_amount;
							}
						}
					}
					else if (ini.is_value("npc"))
					{
						NPC_MISSION mis;
						string nickname = ini.get_value_string(0);
						int curr_amount = ini.get_value_int(2);

						for (multimap<uint, NPC_MISSION>::iterator i = set_mapNpcMissions.begin();
							i != set_mapNpcMissions.end(); ++i)
						{
							if (i->second.nickname == nickname)
							{
								i->second.curr_amount = curr_amount;
							}
						}
					}
				}
			}
		}
		ini.close();
	}
}
Esempio n. 23
0
bool BootMode::_SaveSettingsFile(const std::string &filename)
{

    // No need to save the settings if we haven't edited anything!
    if(!_has_modified_settings)
        return false;

    std::string file;
    std::string fileTemp;

    // Load the settings file for reading in the original data
    fileTemp = GetUserDataPath(false) + "/settings.lua";

    if(filename.empty())
        file = fileTemp;
    else
        file = GetUserDataPath(false) + "/" + filename;

    //copy the default file so we have an already set up lua file and then we can modify its settings
    if(!DoesFileExist(file))
        CopyFile(std::string("dat/config/settings.lua"), file);

    WriteScriptDescriptor settings_lua;
    if(!settings_lua.OpenFile(file)) {
        PRINT_ERROR << "Failed to open settings file: " <<
            file << std::endl;
        return false;
    }

    settings_lua.WriteComment("--General settings--");
    settings_lua.BeginTable("settings");

    // Write the current settings into the .lua file
    settings_lua.WriteComment("Show the first time help window");
    settings_lua.WriteInt("first_start", 0);


    //Save language settings
    settings_lua.WriteComment("The GUI and in game dialogues language used");
    settings_lua.WriteString("language", SystemManager->GetLanguage());

    // video
    settings_lua.InsertNewLine();
    settings_lua.WriteComment("--Video settings--");
    settings_lua.BeginTable("video_settings");
    settings_lua.WriteComment("Screen resolution");
    settings_lua.WriteInt("screen_resx", VideoManager->GetScreenWidth());
    settings_lua.WriteInt("screen_resy", VideoManager->GetScreenHeight());
    settings_lua.WriteComment("Run the screen fullscreen/in a window");
    settings_lua.WriteBool("full_screen", VideoManager->IsFullscreen());
    settings_lua.WriteComment("Used smoothed tile sprites when playing");
    settings_lua.WriteBool("smooth_graphics", VideoManager->ShouldSmoothPixelArt());
    settings_lua.EndTable(); // video_settings

    // audio
    settings_lua.InsertNewLine();
    settings_lua.WriteComment("--Audio settings--");
    settings_lua.BeginTable("audio_settings");
    settings_lua.WriteComment("Music and sounds volumes: [0.0 - 1.0]");
    settings_lua.WriteFloat("music_vol", AudioManager->GetMusicVolume());
    settings_lua.WriteFloat("sound_vol", AudioManager->GetSoundVolume());
    settings_lua.EndTable(); // audio_settings

    // input
    settings_lua.InsertNewLine();
    settings_lua.WriteComment("--Keyboard settings--");
    settings_lua.BeginTable("key_settings");
    settings_lua.WriteComment("Keyboard key SDL values.");
    settings_lua.WriteInt("up", InputManager->GetUpKey());
    settings_lua.WriteInt("down", InputManager->GetDownKey());
    settings_lua.WriteInt("left", InputManager->GetLeftKey());
    settings_lua.WriteInt("right", InputManager->GetRightKey());
    settings_lua.WriteInt("confirm", InputManager->GetConfirmKey());
    settings_lua.WriteInt("cancel", InputManager->GetCancelKey());
    settings_lua.WriteInt("menu", InputManager->GetMenuKey());
    settings_lua.WriteInt("pause", InputManager->GetPauseKey());
    settings_lua.EndTable(); // key_settings

    settings_lua.InsertNewLine();
    settings_lua.WriteComment("--Joystick settings--");
    settings_lua.BeginTable("joystick_settings");
    settings_lua.WriteComment("Tells whether joysticks input should be taken in account");
    settings_lua.WriteBool("input_disabled", (!InputManager->GetJoysticksEnabled()));
    settings_lua.WriteComment("The axis index number to be used as x/y axis");
    settings_lua.WriteInt("x_axis", InputManager->GetXAxisJoy());
    settings_lua.WriteInt("y_axis", InputManager->GetYAxisJoy());
    settings_lua.WriteComment("The joystick x/y axis dead zone [0-N] (Default: 8192)");
    settings_lua.WriteInt("threshold", InputManager->GetThresholdJoy());
    settings_lua.WriteComment("Joystick keys index number [0-N] (0 is the first button)");
    settings_lua.WriteInt("confirm", InputManager->GetConfirmJoy());
    settings_lua.WriteInt("cancel", InputManager->GetCancelJoy());
    settings_lua.WriteInt("menu", InputManager->GetMenuJoy());
    settings_lua.WriteInt("pause", InputManager->GetPauseJoy());
    settings_lua.WriteInt("quit", InputManager->GetQuitJoy());
    settings_lua.EndTable(); // joystick_settings

    settings_lua.EndTable(); // settings

    // and save it!
    settings_lua.SaveFile();
    settings_lua.CloseFile();

    _has_modified_settings = false;

    return true;
} // bool BootMode::_SaveSettingsFile(const std::string& filename)
Esempio n. 24
0
plFileName plFileSystem::GetInitPath()
{
    static plFileName _initPath = plFileName::Join(GetUserDataPath(), "Init");
    plFileSystem::CreateDir(_initPath);
    return _initPath;
}
Esempio n. 25
0
plFileName plFileSystem::GetLogPath()
{
    static plFileName _logPath = plFileName::Join(GetUserDataPath(), "Log");
    plFileSystem::CreateDir(_logPath);
    return _logPath;
}
Esempio n. 26
0
bool SaveMode::_PreviewGame(int id) {
	std::ostringstream f;
	f << GetUserDataPath(true) + "saved_game_" << id << ".lua";
	std::string filename = f.str();

	// Check for the file existence, prevents a useless warning
	if (!hoa_utils::DoesFileExist(filename)) {
		_ClearSaveData();
		return false;
	}

	ReadScriptDescriptor file, map_file;

	if (!file.OpenFile(filename, true)) {
		_ClearSaveData();
		return false;
	}

	if (!file.DoesTableExist("save_game1")) {
		file.CloseFile();
		_ClearSaveData();
		return false;
	}

	// open the namespace that the save game is encapsulated in.
	file.OpenTable("save_game1");

	std::string map_filename = file.ReadString("map_filename");

	// using ints to store temp data to populate text boxes
	int hours, minutes, seconds, drunes;
	hours = file.ReadInt("play_hours");
	minutes = file.ReadInt("play_minutes");
	seconds = file.ReadInt("play_seconds");
	drunes = file.ReadInt("drunes");

	if (!file.DoesTableExist("characters")) {
		file.CloseFile();
		_ClearSaveData();
		return false;
	}

	file.OpenTable("characters");
	std::vector<uint32> char_ids;
	file.ReadUIntVector("order", char_ids);
	GlobalCharacter* character[4];

	// Loads only up to the first four slots (Visible battle characters)
	for (uint32 i = 0; i < 4 && i < char_ids.size(); ++i) {
		// Create a new GlobalCharacter object using the provided id
		// This loads all of the character's "static" data, such as their name, etc.
		character[i] = new GlobalCharacter(char_ids[i], false);

		if (!file.DoesTableExist(char_ids[i]))
			continue;

		file.OpenTable(char_ids[i]);

		// Read in all of the character's stats data
		character[i]->SetExperienceLevel(file.ReadUInt("experience_level"));
		character[i]->SetExperiencePoints(file.ReadUInt("experience_points"));

		character[i]->SetMaxHitPoints(file.ReadUInt("max_hit_points"));
		character[i]->SetHitPoints(file.ReadUInt("hit_points"));
		character[i]->SetMaxSkillPoints(file.ReadUInt("max_skill_points"));
		character[i]->SetSkillPoints(file.ReadUInt("skill_points"));

		file.CloseTable();
	}
	file.CloseTable();


	// Report any errors detected from the previous read operations
	if (file.IsErrorDetected()) {
		if (GLOBAL_DEBUG) {
			PRINT_WARNING << "one or more errors occurred while reading the save game file - they are listed below"
				<< std::endl << file.GetErrorMessages() << std::endl;
			file.ClearErrors();
		}
	}

	file.CloseFile();

	// Loads the map file to get location name
	if (!map_file.OpenFile(map_filename)) {
		_ClearSaveData();
		return false;
	}

	// Determine the map's tablespacename and then open it. The tablespace is the name of the map file without
	// file extension or path information (for example, 'dat/maps/demo.lua' has a tablespace name of 'demo').
	int32 period = map_filename.find(".");
	int32 last_slash = map_filename.find_last_of("/");
	std::string map_tablespace = map_filename.substr(last_slash + 1, period - (last_slash + 1));
	map_file.OpenTable(map_tablespace);

	// Read the name of the map
	ustring map_name = MakeUnicodeString(map_file.ReadString("map_name"));

	map_file.CloseTable();
	map_file.CloseFile();

	for (uint32 i = 0; i < 4 && i < char_ids.size(); ++i) {
		_character_window[i].SetCharacter(character[i]);
	}

	_map_name_textbox.SetDisplayText(map_name);

	std::ostringstream time_text;
	time_text << "Time - ";
	time_text << (hours < 10 ? "0" : "") << static_cast<uint32>(hours) << ":";
	time_text << (minutes < 10 ? "0" : "") << static_cast<uint32>(minutes) << ":";
	time_text << (seconds < 10 ? "0" : "") << static_cast<uint32>(seconds);

	_time_textbox.SetDisplayText(time_text.str());

	std::ostringstream drunes_text;
	drunes_text << "Drunes - " << drunes;

	_drunes_textbox.SetDisplayText(drunes_text.str());
	return true;
} // bool SaveMode::_PreviewGame(string& filename)
Esempio n. 27
0
void SaveMode::Update() {
	if (InputManager->QuitPress() == true) {
		ModeManager->Pop();
		return;
	}

	_file_list.Update();

	// Screen is in the process of fading out, in order to load a game
	if (_current_state == SAVE_MODE_FADING_OUT) {
		return;
	}
	// Otherwise, it's time to start handling events.
	else if (InputManager->ConfirmPress()) {
		switch (_current_state) {
			case SAVE_MODE_SAVING:
				if (_file_list.GetSelection() > -1) {
					_current_state = SAVE_MODE_CONFIRMING_SAVE;
				}
				break;

			case SAVE_MODE_CONFIRMING_SAVE:
				if (_confirm_save_optionbox.GetSelection() == 0) {
					// note: using int here, because uint8 will NOT work
					// do not change unless you understand this and can test it properly!
					int id = _file_list.GetSelection();
					std::ostringstream f;
					f << GetUserDataPath(true) + "saved_game_" << id << ".lua";
					std::string filename = f.str();
					// now, attempt to save the game.  If failure, we need to tell the user that!
					if (GlobalManager->SaveGame(filename, (uint32)id, _x_position, _y_position)) {
						_current_state = SAVE_MODE_SAVE_COMPLETE;
						AudioManager->PlaySound("snd/save_successful_nick_bowler_oga.wav");
					}
					else {
						_current_state = SAVE_MODE_SAVE_FAILED;
						AudioManager->PlaySound("snd/cancel.wav");
					}
				}
				else {
					_current_state = SAVE_MODE_SAVING;
				}
				break;

			case SAVE_MODE_SAVE_COMPLETE: case SAVE_MODE_SAVE_FAILED:
				_current_state = SAVE_MODE_SAVING;
				_PreviewGame(_file_list.GetSelection());
				break;

			case SAVE_MODE_LOADING:
				if (_file_list.GetSelection() > -1) {
					_LoadGame(_file_list.GetSelection());
				}
				else {
					// Leave right away where there is nothing else
					// to do than loading.
					ModeManager->Pop();
				}
				break;
		} // end switch (_current_state)
	} // end if (InputManager->ConfirmPress())

	else if (InputManager->CancelPress()) {
		switch (_current_state) {
			case SAVE_MODE_SAVING: case SAVE_MODE_LOADING:
				// Leave right away where there is nothing else to do than
				// loading.
				ModeManager->Pop();
				break;

			case SAVE_MODE_CONFIRMING_SAVE:
				_current_state = SAVE_MODE_SAVING;
				_PreviewGame(_file_list.GetSelection());
				break;
		} // end switch (_current_state)
	} // end if (InputManager->CancelPress())

	else if (InputManager->UpPress()) {
		switch (_current_state) {
			case SAVE_MODE_SAVING: case SAVE_MODE_LOADING:
				_file_list.InputUp();
				if (_file_list.GetSelection() > -1) {
					_PreviewGame(_file_list.GetSelection());
				}
				else {
					_map_name_textbox.SetDisplayText(" ");
					_time_textbox.SetDisplayText(" ");
					_drunes_textbox.SetDisplayText(" ");
				}
				break;

			case SAVE_MODE_CONFIRMING_SAVE:
				_confirm_save_optionbox.InputUp();
				break;
		} // end switch (_current_state)
	} // end if (InputManager->UpPress())

	else if (InputManager->DownPress()) {
		switch (_current_state) {
			case SAVE_MODE_SAVING: case SAVE_MODE_LOADING:
				_file_list.InputDown();
				if (_file_list.GetSelection() > -1) {
					_PreviewGame(_file_list.GetSelection());
				}
				break;

			case SAVE_MODE_CONFIRMING_SAVE:
				_confirm_save_optionbox.InputDown();
				break;
		} // end switch (_current_state)
	} // end if (InputManager->DownPress())
} // void SaveMode::Update()
Esempio n. 28
0
QString CWizDatabase::GetUserIndexFileName() const
{
    QString strPath = GetUserDataPath();
    return strPath + "index.db";
}
Esempio n. 29
0
QString CWizDatabase::GetUserThumbFileName() const
{
    QString strPath = GetUserDataPath();
    return strPath + "wizthumb.db";
}
Esempio n. 30
0
QString CWizDatabase::GetUserDocumentsDataPath() const
{
    QString strPath = GetUserDataPath() + "notes/";
    WizEnsurePathExists(strPath);
    return  strPath;
}