/// <summary> /// 账号信息写入本地文件 /// </summary> /// <param name="isloginSuccess">是否登陆成功后写账号文件</param> private void WriteAccountConfig(bool isloginSuccess = true) { string accountInipath = GameDefine.AppPersistentDataPath + GameDefine.AccountInfoFile; INIParser IniFile = new INIParser(); IniFile.Open(accountInipath); if (isloginSuccess) { if (GameMain.hall_.GetPlayerData().GetBindPhoneNumber() == 0) { VisitorAccountId = GameMain.hall_.GetPlayerId(); } else { BindMobileAccountId = GameMain.hall_.GetPlayerId(); } #if !WINDOWS_GUEST IniFile.WriteValue("Account", "VisitorId", VisitorAccountId.ToString()); IniFile.WriteValue("Account", "BindPlayerId", BindMobileAccountId.ToString()); #endif } else { #if !WINDOWS_GUEST IniFile.WriteValue("Account", "BindPlayerId", BindMobileAccountId.ToString()); #endif } IniFile.Close(); }
private void Awake() { self = this; DontDestroyOnLoad(this.gameObject); UThread.initUnityThread(); accountparser = new INIParser(); string path = Application.dataPath.Replace("/", "\\").Replace("\\Assets", string.Empty); accountparser.Open(path + "\\account.dat", true); if (!accountparser.IsKeyExists("basic", "username")) { accountparser.WriteValue("basic", "username", "admin"); } if (!accountparser.IsKeyExists("basic", "password")) { accountparser.WriteValue("basic", "password", "admin"); } var date = DateTime.Now; var formattedDate = string.Format("{0}/{1}/{2}", date.Month, date.Day, date.Year); var time = new DateTime(DateTime.Now.TimeOfDay.Ticks); // Date part is 01-01-0001 var formattedTime = formattedDate + "-" + time.ToString("h:mm:sstt", CultureInfo.InvariantCulture); accountparser.WriteValue("basic", "lastlogin", formattedTime); }
void LoadSettingsConfig() { if (Directory.Exists(skinDirectory)) { // Load in all settings INIParser iniparse = new INIParser(); iniparse.Open(skinDirectory + "\\settings.ini"); System.Text.RegularExpressions.Regex hexRegex = new System.Text.RegularExpressions.Regex("#[a-fA-F0-9]{8,8}"); for (int i = 0; i < customSkin.sustain_mats.Length; ++i) { string hex = iniparse.ReadValue("Sustain Colors", i.ToString(), "#00000000"); if (hex.Length == 9 && hexRegex.IsMatch(hex)) // # r g b a { try { int r = int.Parse(new string(new char[] { hex[1], hex[2] }), System.Globalization.NumberStyles.HexNumber); int g = int.Parse(new string(new char[] { hex[3], hex[4] }), System.Globalization.NumberStyles.HexNumber); int b = int.Parse(new string(new char[] { hex[5], hex[6] }), System.Globalization.NumberStyles.HexNumber); int a = int.Parse(new string(new char[] { hex[7], hex[8] }), System.Globalization.NumberStyles.HexNumber); if (a > 0) { customSkin.sustain_mats[i] = new Material(sustainResources.sustainColours[i]); customSkin.sustain_mats[i].name = i.ToString(); customSkin.sustain_mats[i].SetColor("_Color", new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f)); } } catch (Exception e) { Debug.LogError(e.Message); } } //iniparse.WriteValue("Sustain Colors", i.ToString(), customSkin.sustain_colors[i].GetHex()); } iniparse.Close(); iniparse.Open(skinDirectory + "\\settings.ini"); for (int i = 0; i < customSkin.sustain_mats.Length; ++i) { if (customSkin.sustain_mats[i]) { iniparse.WriteValue("Sustain Colors", i.ToString(), "#" + customSkin.sustain_mats[i].GetColor("_Color").GetHex()); } else { iniparse.WriteValue("Sustain Colors", i.ToString(), "#00000000"); } } iniparse.Close(); } }
public static void test1() { INIParser ini = new INIParser(); ini.Open($"D:/SDKDomeProject/TestProject/Outputs/Android/sjoys_app.ini"); ini.WriteValue("Player", "app_id", "123"); ini.WriteValue("Player", "sdkversion", "5.3.3"); ini.WriteValue("Player", "debug", 1); ini.Close(); }
/// <summary> /// 写微信授权用户信息到本地 /// </summary> private void WriteWeChatAuthInfo() { string AccountConfigPath = GameDefine.AppPersistentDataPath + GameDefine.AccountInfoFile; INIParser IniFile = new INIParser(); IniFile.Open(AccountConfigPath); IniFile.WriteValue("WXUser", "nickname", GetUserNickname()); IniFile.WriteValue("WXUser", "sex", GetUserSex().ToString()); IniFile.WriteValue("WXUser", "headimgurl", GetUserHeadImgUrl()); IniFile.WriteValue("WXUser", "unionid", GetUserUnionId()); IniFile.Close(); }
/// <summary> /// Writes the current settings to the ini /// </summary> public void SaveSettings() { INIParser ini = new INIParser(); ini.Open(settingsPath); ini.WriteValue("Options", "Disable Close Chase Cam", disableSecondChaseCam); ini.WriteValue("VR Interface", "Position Offset", JsonUtility.ToJson(vrInterfaceOffset)); ini.WriteValue("VR Interface", "Scale", JsonUtility.ToJson(vrInterfaceScale)); ini.WriteValue("VR Interface", "Curve Amount", (int)vrInterfaceCurve); ini.Close(); }
public void saveToFile(string _filename = "") { if (_filename == "") { _filename = filename; } var ini = new INIParser(); ini.Open(Application.streamingAssetsPath + g.MapPath + _filename + ".ini"); ini.WriteValue("Map", "width", width); ini.WriteValue("Map", "height", height); ini.WriteValue("Map", "cells", exportCells()); ini.Close(); }
public Song(Song song) : this() { metaData = new Metadata(song.metaData); offset = song.offset; resolution = song.resolution; _events.Clear(); _syncTrack.Clear(); _events.AddRange(song._events); _syncTrack.AddRange(song._syncTrack); manualLength = song.manualLength; charts = new Chart[song.charts.Length]; for (int i = 0; i < charts.Length; ++i) { charts[i] = new Chart(song.charts[i], this); } for (int i = 0; i < audioLocations.Length; ++i) { audioLocations[i] = song.audioLocations[i]; } iniProperties = new INIParser(); iniProperties.OpenFromString(string.Empty); iniProperties.WriteValue(song.iniProperties); }
/// <summary> /// 写入当前服务器资源版本号到本地 /// </summary> /// <returns></returns> bool WriteLocalResConfig() { string localResVerPath = GameDefine.AppPersistentDataPath + GameDefine.LocalResVersionFile; INIParser IniFile = new INIParser(); IniFile.Open(localResVerPath); IniFile.WriteValue("AppConfig", "LocalResVer", m_SvrResVerStr); if (!bAppFirstRun) { IniFile.WriteValue("AppConfig", "AppFirstRun", false); } IniFile.Close(); return(true); }
/// <summary> /// Writes the current cockpit settings to the ini /// </summary> public void SaveCockpitSettings(ShipRefs r) { INIParser ini = new INIParser(); ini.Open(settingsPath); ini.WriteValue("Options", "Enable Lean", leanEnabled); ini.WriteValue("Options", "Lean Scale", leanScaler); var shipName = r.name; ini.WriteValue(shipName, "Cockpit Offset", JsonUtility.ToJson(cockpitOffset)); ini.WriteValue(shipName, "Cockpit Scale", JsonUtility.ToJson(cockpitScale)); ini.Close(); }
static void GenerateSongIni(string path, Song song, float songLengthSeconds, bool isChPackage = false) { Metadata metaData = song.metaData; INIParser parser = new INIParser(); try { parser.Open(Path.Combine(path, "song.ini")); // Clone explicit properties parser.WriteValue(song.iniProperties); SongIniFunctions.AddDefaultIniTags(song, parser, songLengthSeconds); if (isChPackage) { // Write defaults for any missing CH tags SongIniFunctions.AddCloneHeroIniTags(song, parser, songLengthSeconds); } } catch (System.Exception e) { Debug.LogError("Error encountered when trying to generate song.ini. " + e.Message); } finally { parser.Close(); } }
/// <summary> /// called when the player dies at x,y. writes values to the ini /// </summary> public int PlayerDeathINI(float x, float y) { EmptyInventory(true); //empty the inventory and destroy the player's weapon //FillInventoryFromINI(); ini.Open(DetermineINIPath()); //jump to the current death section int DeathSectionNumber = 0; while (ini.IsSectionExists("Death" + ((DeathSectionNumber).ToString()))) { DeathSectionNumber++; } //variables to be used later string DeathSection = "Death" + ((DeathSectionNumber).ToString()); bool InventoryItemsExist = false; for (int i = 0; i < InventoryItems.Length; i++) { if (ini.ReadValue("Inventory", InventoryItems[i].ItemID, 0) >= 1) { //if the ini read value of the InventoryItems iterated item is >=1 //then we want to write that value to [Death] in the ini file //finally, delete the found key in "Inventory" section so the player doesnt have the items until he collects them again if (!isPurchasable(InventoryItems[i].ItemID)) //only write in non purchasable items { if (!InventoryItemsExist) //only write the level and x,y once so that it does not write repeatedly if no items are passed { InventoryItemsExist = true; //write level of death ini.WriteValue(DeathSection, "Level", SceneManager.GetActiveScene().name); //write X and Y Values ini.WriteValue(DeathSection, "x", x); ini.WriteValue(DeathSection, "y", y); } ini.WriteValue(DeathSection, InventoryItems[i].ItemID, ini.ReadValue("Inventory", InventoryItems[i].ItemID, 0)); //write the a death key for each inventory item found ini.KeyDelete("Inventory", InventoryItems[i].ItemID); // delete the found key so it doesnt spawn with the player again } } } ini.Close(); //ini.RemoveBlankLines(DetermineINIPath()); return(DeathSectionNumber); }
/// <summary> /// <para>Eng. Init option data with option ini file. </para> /// <para>Kor. 옵션 정보를 저장합니다. </para> /// </summary> public void SaveOptionData() { INIParser _iniParser = new INIParser(); _iniParser.Open(Application.dataPath + "/option.ini"); // -------------- Graphic -------------- _iniParser.WriteValue("Graphic", "ResolutionWidth", _optionData._resolution.width); _iniParser.WriteValue("Graphic", "ResolutionHeight", _optionData._resolution.height); _iniParser.WriteValue("Graphic", "FullscreenMode", _optionData._fullscreenModeIndex); _iniParser.WriteValue("Graphic", "Quality", _optionData._qualityIndex); // -------------- Sound -------------- _iniParser.WriteValue("Sound", "BGM", _optionData._bgmVolume); _iniParser.WriteValue("Sound", "Effect", _optionData._effectVolume); // -------------- Game -------------- _iniParser.WriteValue("Game", "DialogueSpeed", _optionData._dialogueSpeedIndex); // -------------- End -------------- _iniParser.Close(); }
public void ForceWrite() { string path = m_controller.RootPath + saveFileName; INIParser ini = new INIParser(); ini.Open(path); ini.WriteValue("ret", "名称", m_controller.GameNameCn); ini.WriteValue("ret", "种类", "2"); ini.WriteValue("ret", "开始时间", TGUtility.ParseDateTimeToString(m_controller.startTime)); ini.WriteValue("ret", "结束时间", TGUtility.ParseDateTimeToString(m_controller.endTime)); WriteExtraData(ini); ini.Close(); Debug.Log("Finished Write"); }
private void WriteExtraData(INIParser ini) { Dictionary <string, string> keys = m_controller.mainGame.extraData; foreach (string k in keys.Keys) { ini.WriteValue("ret", k, keys[k]); } }
private void WriteExtraData(INIParser _ini) { var dict = TGData.extraData; foreach (string k in dict.Keys) { _ini.WriteValue("ret", k, dict[k]); } }
public void ForceWrite() { string path = TGPaths.Root + SAVE_FILENAME; INIParser ini = new INIParser(); ini.Open(path); ini.WriteValue("ret", "名称", TGData.GameNameCn); ini.WriteValue("ret", "种类", "2"); ini.WriteValue("ret", "开始时间", TGData.startTime.ToDateString()); ini.WriteValue("ret", "结束时间", TGData.endTime.ToDateString()); WriteExtraData(ini); ini.Close(); Debug.Log("Writing Finished"); }
// [FILE] must be provided without extension. // Write [VALUE] to [FILE], under [SECTION], at the entry identifed with [KEY] // Credit: https://www.assetstore.unity3d.com/en/#!/content/23706 public void writeIni(string section, string key, string value) { INIParser ini = new INIParser(); ini.Open(iniFile); ini.WriteValue(section, key, value); ini.Close(); Debug.Log("Wrote value: '" + value + "' " + section + ", " + key); return; }
//这里封装了一个简单的通用方法。 static bool BulidTarget(string sKey, string apkName) { string app_name = apkName; string target_name = app_name + ".apk"; //BuildTargetGroup targetGroup = BuildTargetGroup.Android; BuildTarget buildTarget = BuildTarget.Android; string applicationPath = Application.dataPath.Replace("/Assets", ""); #if UNITY_ANDROID target_name = app_name + ".apk"; PlayerSettings.keystorePass = "******"; PlayerSettings.keyaliasPass = "******"; //targetGroup = BuildTargetGroup.Android; //PlayerSettings.bundleIdentifier = "com.game.qq"; #elif UNITY_IOS #endif //PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, sKey); string iniPath = Application.dataPath + "/Resources/SDKManager.bytes"; INIParser ini = new INIParser(); ini.Open(iniPath); ini.WriteValue("platform", "name", sKey); ini.Close(); //每次build删除之前的残留 if (Directory.Exists(Out_Path)) { if (File.Exists(Out_Path + "/" + target_name)) { File.Delete(Out_Path + "/" + target_name); } } else { Directory.CreateDirectory(Out_Path); } PlayerSettings.bundleVersion = ClientDefine.LOCAL_PROGRAM_VERSION; int code = 0; if (int.TryParse(_versionCode, out code)) { PlayerSettings.Android.bundleVersionCode = code; } else { _log = "version code 错误!"; return(false); } AssetDatabase.Refresh(); //==================这里是比较重要的东西======================= //开始Build场景,等待吧~ return(GenericBuild(SCENES, Out_Path + "/" + target_name, buildTarget, BuildOptions.None)); }
public static void Init() { string path = Path.Combine(Application.dataPath, "..", INIPath); if (!File.Exists(path)) { Debug.LogWarning("can't find config.ini, try to create one."); File.Create(path).Dispose(); } configs[Keys.UseTest] = false; configs[Keys.UseBot] = true; configs[Keys.WaitInGame] = false; configs[Keys.ProxyObserve] = false; configs[Keys.AutoUpdate] = true; configs[Keys.UpdateAddress] = "http://39.105.200.223:81/thd2/bots/script.pak"; INIParser ini = new INIParser(); ini.Open(path); ini.WriteValue(INISection, "UseTest", false); ini.WriteValue(INISection, "UseBot", true); ini.WriteValue(INISection, "WaitInGame", false); ini.WriteValue(INISection, "ProxyObserve", false); ini.WriteValue(INISection, "AutoUpdate", true); ini.WriteValue(INISection, "UpdateAddress", "http://39.105.200.223:81/thd2/bots/script.pak"); ini.Close(); Debug.Log("new config.ini created."); }
void Authenticate() { INIParser ini = new INIParser(); if (System.IO.File.Exists(Application.persistentDataPath + "/config.ini")) { ini.Open(Application.persistentDataPath + "/config.ini"); username = ini.ReadValue("vCenter", "username", "*****@*****.**"); password = ini.ReadValue("vCenter", "password", "VMware1!"); hostUrl = ini.ReadValue("vCenter", "hosturl", "https://*****:*****@vsphere.local"); ini.WriteValue("vCenter", "password", "VMware1!"); ini.WriteValue("vCenter", "hosturl", "https://VC01"); username = ini.ReadValue("vCenter", "username", "*****@*****.**"); password = ini.ReadValue("vCenter", "password", "VMware1!"); hostUrl = ini.ReadValue("vCenter", "hosturl", "https://localhost:8082"); } ini.Close(); HttpWebRequest request = CreatePostRequest("/rest/com/vmware/cis/session"); String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); request.Headers.Add("Authorization", "Basic " + encoded); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if ((int)response.StatusCode == 200) { cookie = response.Headers["Set-Cookie"]; cookie = cookie.Substring(cookie.IndexOf('=') + 1); cookie = cookie.Substring(0, cookie.IndexOf(';')); } }
public static void AddCloneHeroIniTags(Song song, INIParser ini, float songLengthSeconds) { AddTagFn AddTagIfNonExistant = (string key, string defaultVal) => { string realKey = key.Trim() + " "; ini.WriteValue(INI_SECTION_HEADER, realKey, ini.ReadValue(INI_SECTION_HEADER, realKey, PrefixSpaceToINIValue(defaultVal))); }; AddDefaultIniTags(song, ini, songLengthSeconds); foreach (var tag in chTags) { AddTagIfNonExistant(tag.Key, tag.Value); } }
public static void AddDefaultIniTags(Song song, INIParser ini, float songLengthSeconds) { Metadata metaData = song.metaData; AddTagFn AddTagIfNonExistant = (string key, string defaultVal) => { ini.WriteValue(INI_SECTION_HEADER, key.Trim() + " ", ini.ReadValue(INI_SECTION_HEADER, key, PrefixSpaceToINIValue(defaultVal))); }; AddTagIfNonExistant("name", song.name); AddTagIfNonExistant("artist", metaData.artist); AddTagIfNonExistant("album", metaData.album); AddTagIfNonExistant("genre", metaData.genre); AddTagIfNonExistant("year", metaData.year); AddTagIfNonExistant("song_length", ((int)(songLengthSeconds * 1000)).ToString()); AddTagIfNonExistant("charter", metaData.charter); }
public static void PopulateIniWithSongMetadata(Song song, INIParser ini, float songLengthSeconds) { Metadata metaData = song.metaData; int songLength = (int)(songLengthSeconds * 1000); ini.WriteValue(INI_SECTION_HEADER, "name ", PrefixSpaceToINIValue(song.name)); ini.WriteValue(INI_SECTION_HEADER, "artist ", PrefixSpaceToINIValue(metaData.artist)); ini.WriteValue(INI_SECTION_HEADER, "album ", PrefixSpaceToINIValue(metaData.album)); ini.WriteValue(INI_SECTION_HEADER, "genre ", PrefixSpaceToINIValue(metaData.genre)); ini.WriteValue(INI_SECTION_HEADER, "year ", PrefixSpaceToINIValue(metaData.year)); ini.WriteValue(INI_SECTION_HEADER, "song_length ", PrefixSpaceToINIValue(songLength.ToString())); ini.WriteValue(INI_SECTION_HEADER, "charter ", PrefixSpaceToINIValue(metaData.charter)); }
/// <summary> /// Saves the song data in a .chart format to the specified path. /// </summary> /// <param name="filepath">The path and filename to save to.</param> /// <param name="forced">Will the notes from each chart have their flag properties saved into the file?</param> void SaveSong(Song song, string filepath, ExportOptions exportOptions) { string saveErrorMessage; try { new ChartWriter(filepath).Write(song, exportOptions, out saveErrorMessage); Debug.Log("Save complete!"); if (saveErrorMessage != string.Empty) { errorManager.QueueErrorMessage("Save completed with the following errors: " + Globals.LINE_ENDING + saveErrorMessage); } string iniPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filepath), SongIniFunctions.INI_FILENAME); if (!song.iniProperties.IsEmpty) { Debug.Log("Saving song.ini"); INIParser parser = new INIParser(); try { parser.Open(iniPath); parser.WriteValue(song.iniProperties); } catch (System.Exception e) { Debug.LogError("Error encountered when trying to write song.ini. " + e.Message); } finally { parser.Close(); } Debug.Log("song.ini save complete!"); } else if (System.IO.File.Exists(iniPath)) { System.IO.File.Delete(iniPath); } } catch (System.Exception e) { errorManager.QueueErrorMessage(Logger.LogException(e, "Save failed!")); } }
/// <summary> /// Creates the settings ini file. /// </summary> private void CreateSettings() { INIParser ini = new INIParser(); ini.Open(IniLocation); ini.WriteValue("Settings", "Mod Active", CustomShieldActive); ini.WriteValue("Settings", "Use Team Color", UseTeamColor); ini.WriteValue("Settings", "Custom Shield Color R", CustomShieldColor.r); ini.WriteValue("Settings", "Custom Shield Color G", CustomShieldColor.g); ini.WriteValue("Settings", "Custom Shield Color B", CustomShieldColor.b); ini.WriteValue("Settings", "Custom Shield Color A", CustomShieldColor.a); ini.Close(); }
public static INIParser SongIniFromString(string str) { INIParser newProperties = new INIParser(); string[] seperatingTags = { System.Environment.NewLine.ToString(), "\n" }; string[] customIniLines = str.Split(seperatingTags, System.StringSplitOptions.None); foreach (string line in customIniLines) { string[] keyVal = line.Split(new char[] { '=' }, 2); if (keyVal.Length >= 1) { string key = keyVal[0].Trim(); string val = keyVal.Length > 1 ? keyVal[1].Trim() : string.Empty; if (!string.IsNullOrEmpty(key)) { newProperties.WriteValue(INI_SECTION_HEADER, key + " ", " " + val); } } } return(newProperties); }
public static void SaveGameSettings() { INIParser ini = new INIParser(); ini.Open(GameSettings.GetDirectory() + "settings.ini"); { ini.WriteValue("Display", "Screen Width", Screen.width); ini.WriteValue("Display", "Screen Height", Screen.height); ini.WriteValue("Display", "Fullscreen", GameSettings.GS_FULLSCREEN); ini.WriteValue("Display", "Framecap", GameSettings.GS_FRAMECAP); ini.WriteValue("Rendering", "Draw Distance", GameSettings.GS_DRAWDISTANCE); ini.WriteValue("Rendering", "Bloom", GameSettings.GS_BLOOM); ini.WriteValue("Rendering", "Dynamic Resolution", GameSettings.GS_DYNAMICRESOLUTION); ini.WriteValue("Rendering", "AA", GameSettings.GS_AA); ini.WriteValue("Rendering", "AO", GameSettings.GS_AO); ini.WriteValue("Rendering", "CAMDMG", GameSettings.GS_CAMERADAMAGE); ini.WriteValue("Rendering", "TONEMAP", GameSettings.GS_TONEMAPPING); ini.WriteValue("Audio", "Master Volume", AudioSettings.VOLUME_MAIN); ini.WriteValue("Audio", "SFX Volume", AudioSettings.VOLUME_SFX); ini.WriteValue("Audio", "Voices Volume", AudioSettings.VOLUME_VOICES); ini.WriteValue("Audio", "Music Volume", AudioSettings.VOLUME_MUSIC); ini.WriteValue("Audio", "Custom Music", AudioSettings.customMusicEnabled); ini.WriteValue("Gameplay", "Default Camera", GameSettings.G_DEFAULTCAMERA); ini.WriteValue("Gameplay", "Countdown Mode", GameSettings.G_COUNTDOWNTYPE); ini.WriteValue("Gameplay", "Intro Voices", GameSettings.G_TRACKINTROVOICES); ini.WriteValue("Gameplay", "Mirror", GameSettings.G_MIRROR); ini.WriteValue("Gameplay", "Language", (int)GameSettings.G_LANGUAGE); ini.WriteValue("Gameplay", "Custom HUD Color R", GameSettings.G_CUSTOMHUDCOLOR.r); ini.WriteValue("Gameplay", "Custom HUD Color B", GameSettings.G_CUSTOMHUDCOLOR.b); ini.WriteValue("Gameplay", "Custom HUD Color G", GameSettings.G_CUSTOMHUDCOLOR.g); ini.WriteValue("Gameplay", "Custom HUD Color A", GameSettings.G_CUSTOMHUDCOLOR.a); ini.WriteValue("Control Settings", "Vibration", GameSettings.IN_VIBRATION); ini.WriteValue("Control Settings", "Analog Steer Deadzone", GameSettings.steerDeadZone); ini.WriteValue("Control Settings", "Analog Pitch Deadzone", GameSettings.pitchDeadZone); ini.WriteValue("Controls", "Thrust 1", (int)GameSettings.IN_KB_THRUST); ini.WriteValue("Controls", "Thrust 2", (int)GameSettings.IN_GP_THRUST); ini.WriteValue("Controls", "Camera 1", (int)GameSettings.IN_KB_CAMERA); ini.WriteValue("Controls", "Camera 2", (int)GameSettings.IN_GP_CAMERA); ini.WriteValue("Controls", "Look Behind 1", (int)GameSettings.IN_KB_LOOKBEHIND); ini.WriteValue("Controls", "Look Behind 2", (int)GameSettings.IN_GP_LOOKBEHIND); ini.WriteValue("Controls", "Afterburner 1", (int)GameSettings.IN_KB_AFTERBURN); ini.WriteValue("Controls", "Afterburner 2", (int)GameSettings.IN_GP_AFTERBURN); ini.WriteValue("Controls", "Airbrake Left 1", (int)GameSettings.IN_KB_AIRBRAKE_LEFT); ini.WriteValue("Controls", "Airbrake Left 2", (int)GameSettings.IN_GP_AIRBRAKE_LEFT); ini.WriteValue("Controls", "Airbrake Right 1", (int)GameSettings.IN_KB_AIRBRAKE_RIGHT); ini.WriteValue("Controls", "Airbrake Right 2", (int)GameSettings.IN_GP_AIRBRAKE_RIGHT); ini.WriteValue("Controls", "Pause 1", (int)GameSettings.IN_KB_PAUSE); ini.WriteValue("Controls", "Pause 2", (int)GameSettings.IN_GP_PAUSE); ini.WriteValue("Controls", "Steer -1", (int)GameSettings.IN_KB_STEER_LEFT); ini.WriteValue("Controls", "Steer 1", (int)GameSettings.IN_KB_STEER_RIGHT); ini.WriteValue("Controls", "Pitch -1", (int)GameSettings.IN_KB_PITCH_UP); ini.WriteValue("Controls", "Pitch 1", (int)GameSettings.IN_KB_PITCH_DOWN); } ini.Close(); }
private static void SavePicToLocal(string key, string sUrl) { string sPath = Application.persistentDataPath; sPath = sPath.Replace("\\", "/"); if (picUrlList.ContainsKey(key)) { picUrlList[key] = sUrl; } else { picUrlList.Add(key, sUrl); } Texture2D imgage = savePic[key]; var bys = imgage.EncodeToPNG();//转换图片资源 //创建临时文件 string filePath = string.Format("{0}/ShareIcon/{1}/{2}.png", sPath, userId, key); string tempFilePath = string.Format("{0}/ShareIcon/{1}/{2}_temp.png", sPath, userId, key); string dirPath = Path.GetDirectoryName(filePath); FileStream stream; try { stream = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write); //stream = File.Create(tempFilePath); } catch (System.Exception ex) { Debug.LogException(ex); return; } //写临时文件 try { stream.Write(bys, 0, bys.Length); stream.Flush(); stream.Close(); } catch (System.Exception e) { Debug.LogException(e); return; } //名字改为正式 try { if (System.IO.File.Exists(filePath)) { System.IO.File.SetAttributes(filePath, FileAttributes.Normal); System.IO.File.Delete(filePath); } System.IO.File.Move(tempFilePath, filePath); } catch (System.Exception e) { Debug.LogException(e); return; } INIParser pIniFile = new INIParser(); pIniFile.Open(string.Format("{0}/ShareIcon/IconConfig.ini", sPath)); pIniFile.WriteValue("IconList", key, sUrl); pIniFile.Close(); }
public static void Save(string configFilepath, string controllerBindingsFilepath) { INIParser iniparse = new INIParser(); try { Debug.Log("Saving game settings"); iniparse.Open(configFilepath); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Framerate", targetFramerate); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Hyperspeed", hyperspeed); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Highway Length", highwayLength); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Audio calibration", audioCalibrationMS); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Clap calibration", clapCalibrationMS); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Clap", (int)clapProperties); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Extended sustains", extendedSustainsEnabled); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Sustain Gap", sustainGapEnabled); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Sustain Gap Step", sustainGap); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Note Placement Mode", (int)notePlacementMode); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Gameplay Start Delay", gameplayStartDelayTime); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Reset After Play", resetAfterPlay); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Reset After Gameplay", resetAfterGameplay); iniparse.WriteValue(SECTION_NAME_SETTINGS, "Custom Background Swap Time", customBgSwapTime); // Audio levels iniparse.WriteValue(SECTION_NAME_AUDIO, "Master", vol_master); iniparse.WriteValue(SECTION_NAME_AUDIO, "Music Stream", vol_song); iniparse.WriteValue(SECTION_NAME_AUDIO, "Guitar Stream", vol_guitar); iniparse.WriteValue(SECTION_NAME_AUDIO, "Bass Stream", vol_bass); iniparse.WriteValue(SECTION_NAME_AUDIO, "Rhythm Stream", vol_rhythm); iniparse.WriteValue(SECTION_NAME_AUDIO, "Drum Stream", vol_drum); iniparse.WriteValue(SECTION_NAME_AUDIO, "Audio Pan", audio_pan); iniparse.WriteValue(SECTION_NAME_AUDIO, "SFX", sfxVolume); } catch (System.Exception e) { Debug.LogError("Error encountered when trying to save game settings. " + e.Message); } finally { iniparse.Close(); } controls.UpdateSaveData(); var controlsJson = JsonUtility.ToJson(controls, true); try { Debug.Log("Saving input settings"); // Save to file File.WriteAllText(controllerBindingsFilepath, controlsJson, System.Text.Encoding.UTF8); } catch (System.Exception e) { Logger.LogException(e, "Error encountered while saving control bindings. " + e.Message); } }
public void SaveCities() { numberOfCities = 0; if (!encrypted) { INIParser ini = new INIParser(); File.Delete(Application.dataPath + "/SAVES/" + saveName + ".SAV"); ini.Open(Application.dataPath + "/SAVES/" + saveName + ".SAV"); ini.SectionDelete("NUMBER_OF_CITIES"); foreach (GameObject g in StaticCitiesList.Cities) { numberOfCities += 1; City cityInfo = g.GetComponent <City>(); //print(cityInfo._Y); ini.WriteValue("City" + numberOfCities, "CityName", cityInfo._CityName); //City ints ini.WriteValue("City" + numberOfCities, "XPos", cityInfo._X * 10000f); ini.WriteValue("City" + numberOfCities, "YPos", cityInfo._Y * 10000f); ini.WriteValue("City" + numberOfCities, "ZPos", cityInfo._Z * 10000f); ini.WriteValue("City" + numberOfCities, "Castle", cityInfo._Castle); ini.WriteValue("City" + numberOfCities, "KnightsCastle", cityInfo._KnightsCastle); ini.WriteValue("City" + numberOfCities, "Wall", cityInfo._Wall); ini.WriteValue("City" + numberOfCities, "SecondWall", cityInfo._SecondWall); ini.WriteValue("City" + numberOfCities, "ThirdWall", cityInfo._ThirdWall); ini.WriteValue("City" + numberOfCities, "GuardTowers", cityInfo._GuardTowers); ini.WriteValue("City" + numberOfCities, "Barracks", cityInfo._Barracks); ini.WriteValue("City" + numberOfCities, "PatrollCentre", cityInfo._PatrollCentre); ini.WriteValue("City" + numberOfCities, "Blacksmith", cityInfo._Blacksmith); ini.WriteValue("City" + numberOfCities, "Housing", cityInfo._Housing); ini.WriteValue("City" + numberOfCities, "Aphothecary", cityInfo._Aphothecary); ini.WriteValue("City" + numberOfCities, "Treasurery", cityInfo._Treasurery); ini.WriteValue("City" + numberOfCities, "Granary", cityInfo._Granary); ini.WriteValue("City" + numberOfCities, "StorageHouse", cityInfo._StorageHouse); ini.WriteValue("City" + numberOfCities, "TradingGuild", cityInfo._TradingGuild); ini.WriteValue("City" + numberOfCities, "School", cityInfo._School); ini.WriteValue("City" + numberOfCities, "Mill", cityInfo._Mill); ini.WriteValue("City" + numberOfCities, "GoldMine", cityInfo._GoldMine); ini.WriteValue("City" + numberOfCities, "IronMine", cityInfo._IronMine); ini.WriteValue("City" + numberOfCities, "CoalMine", cityInfo._CoalMine); ini.WriteValue("City" + numberOfCities, "WoodcuttersCamp", cityInfo._WoodcuttersCamp); ini.WriteValue("City" + numberOfCities, "WoodMill", cityInfo._WoodMill); ini.WriteValue("City" + numberOfCities, "Plains", cityInfo._Plains); } ini.WriteValue("NUMBER_OF_CITIES", "ammount", numberOfCities); ini.Close(); } else { SaveCityData saveCityData = new SaveCityData(); BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.dataPath + "/SAVES/save.SAV"); foreach (GameObject g in StaticCitiesList.Cities) { numberOfCities += 1; City cityInfo = g.GetComponent <City>(); saveCityData.CityName = cityInfo._CityName; //City ints saveCityData.castle = cityInfo._Castle; saveCityData.knightsCastle = cityInfo._KnightsCastle; saveCityData.wall = cityInfo._Wall; saveCityData.secondWall = cityInfo._SecondWall; saveCityData.thirdWall = cityInfo._ThirdWall; saveCityData.guardTowers = cityInfo._GuardTowers; saveCityData.barracks = cityInfo._Barracks; saveCityData.patrollCentre = cityInfo._PatrollCentre; saveCityData.blacksmith = cityInfo._Blacksmith; saveCityData.housing = cityInfo._Housing; saveCityData.aphothecary = cityInfo._Aphothecary; saveCityData.treasurery = cityInfo._Treasurery; saveCityData.granary = cityInfo._Granary; saveCityData.storageHouse = cityInfo._StorageHouse; saveCityData.tradingGuild = cityInfo._TradingGuild; saveCityData.school = cityInfo._School; saveCityData.mill = cityInfo._Mill; saveCityData.goldMine = cityInfo._GoldMine; saveCityData.ironMine = cityInfo._IronMine; saveCityData.coalMine = cityInfo._CoalMine; saveCityData.woodcuttersCamp = cityInfo._WoodcuttersCamp; saveCityData.woodMill = cityInfo._WoodMill; saveCityData.plains = cityInfo._Plains; bf.Serialize(file, saveCityData); } CityCount cityCount = new CityCount(); cityCount.cities = numberOfCities; bf.Serialize(file, cityCount); file.Close(); } }
public static void SaveGameSettings() { INIParser ini = new INIParser(); ini.Open(GameSettings.GetDirectory() + "settings.ini"); { ini.WriteValue("Display", "Screen Width", Screen.width); ini.WriteValue("Display", "Screen Height", Screen.height); ini.WriteValue("Display", "Fullscreen", GameSettings.GS_FULLSCREEN); ini.WriteValue("Display", "Framecap", GameSettings.GS_FRAMECAP); ini.WriteValue("Rendering", "Draw Distance", GameSettings.GS_DRAWDISTANCE); ini.WriteValue("Rendering", "Bloom", GameSettings.GS_BLOOM); ini.WriteValue("Rendering", "FXAA", GameSettings.GS_FXAA); ini.WriteValue("Rendering", "CRT", GameSettings.GS_CRT); ini.WriteValue("Rendering", "Vape", GameSettings.GS_VAPORWAVE); ini.WriteValue("Audio", "Master Volume", Mathf.RoundToInt(AudioSettings.VOLUME_MAIN)); ini.WriteValue("Audio", "SFX Volume", Mathf.RoundToInt(AudioSettings.VOLUME_SFX)); ini.WriteValue("Audio", "Voices Volume", Mathf.RoundToInt(AudioSettings.VOLUME_VOICES)); ini.WriteValue("Audio", "Music Volume", Mathf.RoundToInt(AudioSettings.VOLUME_MUSIC)); } ini.Close(); }