public static void _OnOpen(ref UIGalaxySelect __instance) { CreateDensitySlider(__instance); DensityDTO.SetDensityInformation(starDensitySlider?.value); OnDensityChanged(); Debug.Log("Started modifying star density"); }
// Save density information public static void SaveDensityInfo(string saveName, DensityDTO densityInformation) { string path = $"{configFolder}/{saveName}.txt"; Debug.Log($"More or Less Dense -- Saving {saveName} at {path}"); if (!Directory.Exists(configFolder)) { Directory.CreateDirectory(configFolder); } File.WriteAllText(path, densityInformation.ToString()); }
// Methods public static void OnDensityChanged() { // Null checkup if (!starDensitySlider || !starDensitySliderText) { Debug.LogError($"More or Less Dense::OnDensityChanged() -- FATAL ERROR: missing slider or text for star density info"); return; } // Update text starDensitySliderText.text = Math.Round(starDensitySlider.value * 0.25f, 2).ToString() + "x"; // Regenerate galaxy DensityDTO.SetDensityInformation(starDensitySlider?.value); uiGalaxySelect.SetStarmapGalaxy(); }
// Load density information public static bool LoadDensityInfo(string saveName, out DensityDTO density) { density = null; if (!Directory.Exists(configFolder)) { Directory.CreateDirectory(configFolder); } string path = $"{configFolder}/{saveName}.txt"; Debug.Log($"More or Less Dense -- Loading save {saveName} at {path}"); try { if (!File.Exists(path)) { Debug.Log($"More or Less Dense -- No save file found"); return(false); } density = DensityDTO.FromString(File.ReadAllText(path)); return(true); } catch { Debug.LogWarning($"More or Less Dense -- possible bad path for save file at '{path}'"); return(false); } }