Skip to content

Commit

Permalink
Merge pull request #132 from tyukara/2b839_modify
Browse files Browse the repository at this point in the history
add Translate() to GS2dev Settings, Main Settings, Init messages
  • Loading branch information
innominata authored Aug 11, 2021
2 parents 36a4989 + 3d7b332 commit f0b5fb3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 120 deletions.
118 changes: 7 additions & 111 deletions GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ private void AddUIElements()
"RedGiant",
"Random"
};

// Val l = false;//preferences.GetBool("ludicrousMode", false);
// GS2.Warn(l);
// UI.Add("safeMode", Options.Add(GSUI.Checkbox("Safe Mode".Translate(), false, "safeMode", o =>
Expand All @@ -295,6 +296,7 @@ private void AddUIElements()
// if ((bool) o) EnableLudicrousMode();
// else DisableLudicrousMode();
// }, "Disabled for now")));


UI.Add("galaxyDensity", Options.Add(GSUI.Slider("Galaxy Spread".Translate(), 1, 5, 9, "galaxyDensity", null, "Lower = Stars are closer to each other".Translate())));
UI.Add("defaultStarCount",
Expand All @@ -308,7 +310,7 @@ private void AddUIElements()
UI.Add("birthPlanetUnlock",
bOptions.Add(GSUI.Checkbox("Starting Planet Unlock".Translate(), false, "birthPlanetUnlock", null, "Allow other habitable themes for birth planet".Translate())));
UI.Add("birthPlanetSiTi", bOptions.Add(GSUI.Checkbox("Starting planet Si/Ti".Translate(), false, "birthPlanetSiTi", null, "Force Silicon and Titanius on the birth planet".Translate())));
UI.Add("birthPlanetStar", bOptions.Add(GSUI.Combobox("BirthPlanet Star", starTypes, 7, "birthStar",null, "Type of Star to Start at")));
UI.Add("birthPlanetStar", bOptions.Add(GSUI.Combobox("BirthPlanet Star".Translate(), starTypes, 7, "birthStar",null, "Type of Star to Start at".Translate())));
Options.Add(GSUI.Group("Birth Planet Settings".Translate(), bOptions, "Settings that only affect the starting planet".Translate()));
UI.Add("moonsAreSmall", Options.Add(GSUI.Checkbox("Moons Are Small".Translate(), true, "moonsAreSmall", null, "Try to ensure moons are 1/2 their planets size or less".Translate())));
UI.Add("moonBias", Options.Add(GSUI.Slider("Gas Giants Moon Bias".Translate(), 0, 50, 100, "moonBias", null, "Lower prefers telluric plants, higher gas giants".Translate())));
Expand All @@ -318,9 +320,11 @@ private void AddUIElements()
UI.Add("innerPlanetDistance", Options.Add(GSUI.Slider("Inner Planet Distance (AU)".Translate(), 0, 1, 100, 0.1f, "innerPlanetDistance", null, "Distance forced tidal locking stops acting".Translate())));
UI.Add("allowResonances", Options.Add(GSUI.Checkbox("Allow Orbital Harmonics".Translate(), true, "allowResonances", null, "Allow Orbital Resonance 1:2 and 1:4".Translate())));
UI.Add("rotationMulti", Options.Add(GSUI.Slider("Day/Night Multiplier".Translate(), 0.5f, 1, 100, 0.5f, "rotationMulti", null, "Increase the duration of night/day".Translate())));
UI.Add("secondarySatellites",
Options.Add(GSUI.Checkbox("Secondary satellites".Translate(), false, "secondarySatellites", null, "Allow moons to have moons")));
UI.Add("secondarySatellites", Options.Add(GSUI.Checkbox("Secondary satellites".Translate(), false, "secondarySatellites", null, "Allow moons to have moons".Translate())));


UI.Add("chanceMoonMoon", Options.Add(GSUI.Slider("Secondary Satellite Chance".Translate(), 0, 5, 99, "chanceMoonMoon", null, "% Chance for a moon to have a moon".Translate())));

var FreqOptions = new GSOptions();
UI.Add("freqK", FreqOptions.Add(GSUI.Slider("Freq. Type K".Translate(), 0, 40, 100, "freqK")));
UI.Add("KminStars", FreqOptions.Add(GSUI.Slider("Minimum Type K".Translate(), 0, 0, 100, "KminStars")));
Expand Down Expand Up @@ -386,16 +390,6 @@ private void AddUIElements()
loaded = true;
}

//private void CreateTypeInclinationCallBack(string key)
//{
// typeCallbacks.Add(key, (o) =>
// {
// GS2.Log(key + " " + o);
// var t = UI[key].RectTransform.GetComponent<GSUISlider>();
// t.negativeIsRandom = true;
// });
//}

private void planetCountLow(Val o)
{
Warn(o);
Expand Down Expand Up @@ -423,31 +417,6 @@ private void planetSize(Val o)
{
Warn(o);
}
// private GSOptionCallback CreateTypeMinPlanetSizeCallback(string type)
// {
// return o =>
// {
// var maxSize = preferences.GetFloat($"{type}maxPlanetSize");
// if (maxSize == -1f) maxSize = 510;
// if (maxSize < (float) o) o = maxSize;
// if (preferences.GetBool("safeMode")) preferences.Set($"{type}minPlanetSize", SafePlanetSize((float) o));
// else preferences.Set($"{type}minPlanetSize", Utils.ParsePlanetSize((float) o));
// UI[$"{type}minPlanetSize"].Set(preferences.GetFloat($"{type}minPlanetSize"));
// };
// }
//
// private GSOptionCallback CreateTypeMaxPlanetSizeCallback(string type)
// {
// return o =>
// {
// var minSize = preferences.GetFloat($"{type}minPlanetSize");
// if (minSize == -1f) minSize = 5;
// if (minSize > (float) o) o = minSize;
// if (preferences.GetBool("safeMode")) preferences.Set($"{type}maxPlanetSize", SafePlanetSize((float) o));
// else preferences.Set($"{type}maxPlanetSize", Utils.ParsePlanetSize((float) o));
// UI[$"{type}maxPlanetSize"].Set(preferences.GetFloat($"{type}maxPlanetSize"));
// };
// }

private void SizeBiasCallback(Val o)
{
Expand Down Expand Up @@ -475,36 +444,6 @@ private void SystemDensityCallback(Val o)
SetAllStarTypeOptions("systemDensity", o);
}

// private void MinPlanetCountCallback(Val o)
// {
// var maxCount = preferences.GetInt("maxPlanetCount");
// if (maxCount == -1f) maxCount = 25;
// if (maxCount < o)
// {
// //GS2.Warn("<");
// o = maxCount;
// preferences.Set("minPlanetCount", maxCount);
// UI["minPlanetCount"].Set(o);
// }
//
// SetAllStarTypeOptions("minPlanetCount", o);
// }
//
// private void MaxPlanetCountCallback(Val o)
// {
// var minCount = preferences.GetInt("minPlanetCount");
// if (minCount == -1f) minCount = 1;
// if (minCount > o)
// {
// //GS2.Warn(">");
// o = minCount;
// preferences.Set("maxPlanetCount", minCount);
// UI["maxPlanetCount"].Set(o);
// }
//
// SetAllStarTypeOptions("maxPlanetCount", o);
// }

private void SetAllStarTypeOptions(string key, Val value)
{
for (var i = 0; i < 14; i++) UI[$"{typeLetter[i]}{key}"].Set(value);
Expand All @@ -527,46 +466,6 @@ private void SetAllStarTypeRSMax(string key, Val value)
preferences.Set($"{typeLetter[i]}{key}", (low, value));
}
}
// private void SetAllStarTypeMinSize(Val value)
// {
// for (var i = 0; i < 14; i++) typeCallbacks[$"{typeLetter[i]}minPlanetSize"](value);
// }
//
// private void SetAllStarTypeMaxSize(Val value)
// {
// for (var i = 0; i < 14; i++) typeCallbacks[$"{typeLetter[i]}maxPlanetSize"](value);
// }

// private void MinPlanetSizeCallback(Val o)
// {
// var maxSize = preferences.GetFloat("maxPlanetSize");
// if (maxSize == -1f) maxSize = 510;
// if (maxSize < o) o = maxSize;
// if (preferences.GetBool("safeMode")) preferences.Set("minPlanetSize", SafePlanetSize(o));
// else preferences.Set("minPlanetSize", Utils.ParsePlanetSize(o));
// UI["minPlanetSize"].Set(preferences.GetFloat("minPlanetSize"));
// SetAllStarTypeMinSize(o);
// }
//
// private void MaxPlanetSizeCallback(Val o)
// {
// var t = o;
// var minSize = preferences.GetFloat("minPlanetSize");
// if (minSize == -1f) minSize = 5;
// if (minSize > o) o = minSize;
// if (preferences.GetBool("safeMode")) preferences.Set("maxPlanetSize", SafePlanetSize(o));
// else preferences.Set("maxPlanetSize", Utils.ParsePlanetSize(o));
// UI["maxPlanetSize"].Set(preferences.GetFloat("maxPlanetSize"));
// SetAllStarTypeMaxSize(o);
// }

// private float SafePlanetSize(float size)
// {
// if (size > 350) return 400;
// if (size > 250) return 300;
// if (size > 150) return 200;
// return 100;
// }

private void CalculateFrequencies()
{
Expand Down Expand Up @@ -613,7 +512,6 @@ private void CalculateFrequencies()
starFreq.Add(element.type, element.chance + previousElement.chance);
StarFreqTupleArray[i].chance += previousElement.chance;
}
//GS2.LogJson(starFreq, true);
}
private List<string> ForcedStars = new List<string>();
private void InitForcedStars()
Expand All @@ -626,8 +524,6 @@ private void InitForcedStars()
var count = preferences.GetInt($"{typeLetter[i]}minStars", 0);
for (var j = 0; j < count; j++) ForcedStars.Add(typeLetter[i]);
}
// GS2.Warn("Forced Stars:");
// GS2.WarnJson(ForcedStars);
}
private (EStarType type, ESpectrType spectr) ChooseStarType(bool birth = false)
{
Expand Down
10 changes: 5 additions & 5 deletions GalacticScale2/Scripts/GalacticScale2.0/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public static AssetBundle Bundle

if (bundle == null)
{
Error("Failed to load AssetBundle!");
Error("Failed to load AssetBundle!".Translate());
UIMessageBox.Show("Error",
"Asset Bundle not found. \r\nPlease ensure your directory structure is correct.\r\n Installation instructions can be found at http://customizing.space/release. \r\nAn error log has been generated in the plugin/ErrorLog Directory",
"Return", 0);
"Asset Bundle not found. \r\nPlease ensure your directory structure is correct.\r\n Installation instructions can be found at http://customizing.space/release. \r\nAn error log has been generated in the plugin/ErrorLog Directory".Translate(),
"Return".Translate(), 0);

return null;
}
Expand All @@ -88,7 +88,7 @@ public static void Init()
if (File.Exists(Path.Combine(AssemblyPath, "icon.png")))
{
updateMessage +=
"Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease note the settings panel is under construction, and missing options will reappear in future updates\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward";
"Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease note the settings panel is under construction, and missing options will reappear in future updates\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward".Translate();
File.Delete(Path.Combine(AssemblyPath, "icon.png"));
}
Warn("Start");
Expand All @@ -98,7 +98,7 @@ public static void Init()
Warn($"Moving Configs from {OldDataDir} to {DataDir}");
Directory.Move(OldDataDir, DataDir);
updateMessage +=
"Galactic Scale config Directory has changed to \r\n ...\\BepInEx\\config\\GalacticScale \r\nThis is to prevent data being lost when updating using the mod manager.\r\n";
"Galactic Scale config Directory has changed to \r\n ...\\BepInEx\\config\\GalacticScale \r\nThis is to prevent data being lost when updating using the mod manager.\r\n".Translate();
}

if (!Directory.Exists(DataDir)) Directory.CreateDirectory(DataDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ public void Init()
DebugOptions.Add(GSUI.Checkbox("Force Rare Spawn".Translate(), false, "Force Rare Spawn", null, "Ignore randomness/distance checks".Translate()));
_cheatModeCheckbox = DebugOptions.Add(GSUI.Checkbox("Cheat Mode".Translate(), false, "Cheat Mode", null, "All Research, TP by ctrl-click nav arrow".Translate()));
DebugOptions.Add(GSUI.Slider("Ship Speed Multiplier".Translate(), 1f, 1f, 100f, "Logistics Ship Multi", null, "Multiplier for Warp Speed of Ships".Translate()));
Options.Add(GSUI.Group("Debug Options", DebugOptions, "Useful for testing galaxies/themes".Translate()));
Options.Add(GSUI.Group("Debug Options".Translate(), DebugOptions, "Useful for testing galaxies/themes".Translate()));
var JsonOptions = new GSOptions();
JsonOptions.Add(GSUI.Input("Export Filename".Translate(), "My First Custom Galaxy", "Export Filename", null, "Excluding .json".Translate()));
JsonOptions.Add(GSUI.Checkbox("Minify Exported JSON".Translate(), false, "Minify JSON", null, "Only save changes".Translate()));
_exportButton = JsonOptions.Add(GSUI.Button("Export Custom Galaxy".Translate(), "Export".Translate(), ExportJsonGalaxy, null, "Save Galaxy to File".Translate()));
Options.Add(GSUI.Group("Custom Galaxy Export", JsonOptions, "Usable once in game".Translate()));
Options.Add(GSUI.Group("Custom Galaxy Export".Translate(), JsonOptions, "Usable once in game".Translate()));
}

public void SetResourceMultiplier(float val)
Expand All @@ -117,7 +117,7 @@ public void SetExternalTheme(string folder, string name, bool value)
public void InitThemePanel()
{
var externalThemesGroupOptions = new List<GSUI>() {
GSUI.Button("Export All Themes".Translate(), "Export", ExportAllThemes)
GSUI.Button("Export All Themes".Translate(), "Export".Translate(), ExportAllThemes)
};
// GS2.Warn("ExternalThemeNames");
// GS2.WarnJson(ExternalThemeNames);
Expand Down Expand Up @@ -183,7 +183,7 @@ public void InitThemePanel()
}
}

var externalThemesGroup = Options.Add(GSUI.Group("External Themes", externalThemesGroupOptions));
var externalThemesGroup = Options.Add(GSUI.Group("External Themes".Translate(), externalThemesGroupOptions));
}
private void ExportAllThemes(Val o)
{
Expand Down

0 comments on commit f0b5fb3

Please sign in to comment.