public static void LoadSettingsJson(bool regenConfig = false) { //If it doesn't exist, we need to gen a new one. if (regenConfig || !File.Exists(configFilePath)) { //Gen new config will autoload the new config. if (!failsafeThingy && File.Exists(Path.Combine(Application.persistentDataPath, "NRConfig.json"))) { File.Move(Path.Combine(Application.persistentDataPath, "NRConfig.json"), Path.Combine(Application.persistentDataPath, "NRConfig.txt")); failsafeThingy = true; LoadSettingsJson(); return; } GenNewConfig(); return; } try { config = JsonUtility.FromJson <NRJsonSettings>(File.ReadAllText(configFilePath)); } catch (Exception e) { Debug.LogError(e); } isLoaded = true; foreach (var pendingAction in pendingActions) { pendingAction(); } pendingActions.Clear(); }
public static void LoadSettingsJson(bool regenConfig = false) { if (!regenConfig) { RemoveOldAutosaves(); } //If it doesn't exist, we need to gen a new one. if (regenConfig || !File.Exists(configFilePath)) { //Gen new config will autoload the new config. if (!failsafeThingy && File.Exists(Path.Combine(Application.persistentDataPath, "NRConfig.json"))) { File.Move(Path.Combine(Application.persistentDataPath, "NRConfig.json"), Path.Combine(Application.persistentDataPath, "NRConfig.txt")); failsafeThingy = true; LoadSettingsJson(); return; } GenNewConfig(); // Load config on first startup. LoadSettingsJson(); return; } try { config = JsonUtility.FromJson <NRJsonSettings>(File.ReadAllText(configFilePath)); string winConfigDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "CircuitCubed", "NotReaper", "BG1.png"); // Check if Linux / Mac user is using an old cfg. if (!(Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)) { if (config.bgImagePath == winConfigDir) { config.bgImagePath = GetbgImagePath(); } } if (!(File.Exists(config.bgImagePath))) { GenNewConfig(true); } } catch (Exception e) { Debug.LogError(e); } isLoaded = true; foreach (var pendingAction in pendingActions) { pendingAction(); } pendingActions.Clear(); }
private static void GenNewConfig() { //Debug.Log("Generating new configuration file..."); NRJsonSettings temp = new NRJsonSettings(); config = temp; isLoaded = true; if (File.Exists(configFilePath)) { File.Delete(configFilePath); } File.WriteAllText(configFilePath, JsonUtility.ToJson(temp, true)); string destPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "CircuitCubed", "NotReaper"); //It's release time and I need a fix ok, don't make fun of my code. if (File.Exists(Path.Combine(destPath, "BG1.png"))) { return; } if (File.Exists(Path.Combine(destPath, "BG2.png"))) { return; } if (File.Exists(Path.Combine(destPath, "BG3.png"))) { return; } if (File.Exists(Path.Combine(destPath, "BG4.jpg"))) { return; } //Copy bg images over File.Copy(Path.Combine(Application.streamingAssetsPath, "BG1.png"), destPath + "/BG1.png", false); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG2.png"), destPath + "/BG2.png", false); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG3.png"), destPath + "/BG3.png", false); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG4.jpg"), destPath + "/BG4.jpg", false); }
public static void LoadSettingsJson(bool regenConfig = false) { //If it doesn't exist, we need to gen a new one. if (regenConfig || !File.Exists(configFilePath)) { GenNewConfig(); } try { config = JsonUtility.FromJson <NRJsonSettings>(File.ReadAllText(configFilePath)); } catch (Exception e) { Debug.LogError(e); } //config.leftColor = new Color((float)config.userLeftColor.r, (float)config.userLeftColor.g, (float)config.userLeftColor.b); //config.rightColor = new Color((float)config.userRightColor.r, (float)config.userRightColor.g, (float)config.userRightColor.b); //config.selectedHighlightColor = new Color((float)config.userSelectedHighlightColor.r, (float)config.userSelectedHighlightColor.g, (float)config.userSelectedHighlightColor.b); isLoaded = true; }
private static void GenNewConfig() { Debug.Log("Generating new configuration file..."); NRJsonSettings temp = new NRJsonSettings(); if (File.Exists(configFilePath)) { File.Delete(configFilePath); } File.WriteAllText(configFilePath, JsonUtility.ToJson(temp, true)); string destPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "CircuitCubed", "NotReaper"); //Copy bg images over File.Copy(Path.Combine(Application.streamingAssetsPath, "BG1.png"), destPath + "/BG1.png"); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG2.png"), destPath + "/BG2.png"); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG3.png"), destPath + "/BG3.png"); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG4.jpg"), destPath + "/BG4.jpg"); }
private static void GenNewConfig(bool regenConfig = false) { //Debug.Log("Generating new configuration file..."); NRJsonSettings temp = new NRJsonSettings(); config = temp; isLoaded = true; if (File.Exists(configFilePath)) { File.Delete(configFilePath); } File.WriteAllText(configFilePath, JsonUtility.ToJson(temp, true)); string destPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", Application.companyName, Application.productName); if ((Application.platform == RuntimePlatform.LinuxEditor) || (Application.platform == RuntimePlatform.LinuxPlayer)) { destPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.config/unity3d/" + Application.companyName + "/" + Application.productName); } // On OSX the folder that unity creates is different based on if NotReaper is being launched in the editor/player. if (Application.platform == RuntimePlatform.OSXEditor) { destPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Library/Application Support/" + Application.companyName + "/" + Application.productName); } if (Application.platform == RuntimePlatform.OSXPlayer) { destPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Library/Application Support/" + Application.identifier); } //It's release time and I need a fix ok, don't make fun of my code. if (!regenConfig) { if (File.Exists(Path.Combine(destPath, "BG1.png"))) { return; } if (File.Exists(Path.Combine(destPath, "BG2.png"))) { return; } if (File.Exists(Path.Combine(destPath, "BG3.png"))) { return; } if (File.Exists(Path.Combine(destPath, "BG4.jpg"))) { return; } } //Copy bg images over File.Copy(Path.Combine(Application.streamingAssetsPath, "BG1.png"), destPath + "/BG1.png", false); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG2.png"), destPath + "/BG2.png", false); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG3.png"), destPath + "/BG3.png", false); File.Copy(Path.Combine(Application.streamingAssetsPath, "BG4.jpg"), destPath + "/BG4.jpg", false); }