Skip to content

Commit 9cf6bee

Browse files
committed
Fixed 2 errors & added vein counts + cleanup
1 parent 4310f05 commit 9cf6bee

5 files changed

Lines changed: 60 additions & 28 deletions

File tree

ConfigSettingsWindow.jpg

2.26 KB
Loading

DSPSpreadsheetGenMod.cs

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,22 @@ public class SpreadsheetGenMod : BaseUnityPlugin // Plugin config: "C:\Program
3535
{
3636
public const string pluginGuid = "greyhak.dysonsphereprogram.resourcespreadsheetgen";
3737
public const string pluginName = "DSP Star Sector Resource Spreadsheet Generator";
38-
public const string pluginVersion = "3.1.1";
38+
public const string pluginVersion = "3.1.2";
3939

40-
public static BepInEx.Configuration.ConfigEntry<bool> enablePlanetLoadingFlag;
41-
public static bool enableOnStartTrigger = false;
42-
public static bool enableOnPauseTrigger = false;
4340
public static bool spreadsheetGenRequestFlag = false;
4441
public static List<PlanetData> planetsToLoad = new List<PlanetData> { };
4542
public static Dictionary<int, string> planetResourceData = new Dictionary<int, string>();
4643
public static bool checkForPlanetsToUnload = false;
47-
public static BepInEx.Configuration.ConfigEntry<string> spreadsheetFileNameTemplate;
48-
public static BepInEx.Configuration.ConfigEntry<string> spreadsheetColumnSeparator;
4944
public static CultureInfo spreadsheetLocale = CultureInfo.CurrentUICulture;
50-
public static BepInEx.Configuration.ConfigEntry<int> spreadsheetFloatPrecision;
5145
new internal static ManualLogSource Logger;
5246
new internal static BepInEx.Configuration.ConfigFile Config;
5347
public static readonly int[] gases = { 1120, 1121, 1011 };
5448
public static int planetCount = 0;
55-
49+
50+
public static BepInEx.Configuration.ConfigEntry<bool> enablePlanetLoadingFlag;
51+
public static BepInEx.Configuration.ConfigEntry<string> spreadsheetFileNameTemplate;
52+
public static BepInEx.Configuration.ConfigEntry<string> spreadsheetColumnSeparator;
53+
public static BepInEx.Configuration.ConfigEntry<int> spreadsheetFloatPrecision;
5654
public class ConfigExtraFlags
5755
{
5856
public static BepInEx.Configuration.ConfigEntry<bool> starAge;
@@ -73,6 +71,7 @@ public class ConfigExtraFlags
7371
public static BepInEx.Configuration.ConfigEntry<bool> planetRotationPeriod;
7472
public static BepInEx.Configuration.ConfigEntry<bool> planetRotationPhase;
7573
public static BepInEx.Configuration.ConfigEntry<bool> planetSunDistance;
74+
public static BepInEx.Configuration.ConfigEntry<bool> veinCounts;
7675
}
7776

7877
private static Thread veinGenerationThread;
@@ -114,6 +113,7 @@ public void Awake()
114113
ConfigExtraFlags.planetRotationPeriod = Config.Bind<bool>("ExtraData", "PlanetRotationPeriod", false, "Add planets' rotation period to the spreadsheet");
115114
ConfigExtraFlags.planetRotationPhase = Config.Bind<bool>("ExtraData", "PlanetRotationPhase", false, "Add planets' rotation phase to the spreadsheet");
116115
ConfigExtraFlags.planetSunDistance = Config.Bind<bool>("ExtraData", "PlanetSunDistance", false, "Add planets' distance from their star to the spreadsheet");
116+
ConfigExtraFlags.veinCounts = Config.Bind<bool>("ExtraData", "VeinCounts", false, "Add the number of veins for each vein resource in addition to the total number of items.");
117117

118118
Config.SettingChanged += OnConfigSettingChanged;
119119

@@ -140,6 +140,10 @@ public static void OnConfigSettingChanged(object sender, BepInEx.Configuration.S
140140
spreadsheetGenRequestFlag = false;
141141
planetsToLoad.Clear();
142142
planetResourceData.Clear();
143+
if (progressImage != null)
144+
{
145+
progressImage.fillAmount = 0;
146+
}
143147
Monitor.Exit(planetComputeThreadMutexLock);
144148

145149
if (changedSetting.Section == "Output" && changedSetting.Key == "SpreadsheetLocale")
@@ -177,7 +181,7 @@ public static void QueuePlanetLoading()
177181
{
178182
foreach (PlanetData planet in star.planets)
179183
{
180-
if (!planetResourceData.ContainsKey(planet.id) && (planet.type != EPlanetType.Gas) && (planet.veinGroups.Length == 0))
184+
if (enablePlanetLoadingFlag.Value && (planet.type != EPlanetType.Gas) && (planet.veinGroups.Length == 0) && !planetResourceData.ContainsKey(planet.id))
181185
{
182186
planetsToLoad.Add(planet);
183187

@@ -369,9 +373,19 @@ public static void GenerateResourceSpreadsheet()
369373
sb.Append("Singularity").Append(spreadsheetColumnSeparator.Value);
370374
sb.Append("Ocean").Append(spreadsheetColumnSeparator.Value);
371375

376+
EVeinType type = (EVeinType)1;
372377
foreach (VeinProto item in LDB.veins.dataArray)
373378
{
374-
sb.Append(item.name).Append(spreadsheetColumnSeparator.Value);
379+
if (type == EVeinType.Oil || !ConfigExtraFlags.veinCounts.Value)
380+
{
381+
sb.Append(item.name).Append(spreadsheetColumnSeparator.Value);
382+
}
383+
else
384+
{
385+
sb.Append(item.name + " (items)").Append(spreadsheetColumnSeparator.Value);
386+
sb.Append(item.name + " (veins)").Append(spreadsheetColumnSeparator.Value);
387+
}
388+
type++;
375389
}
376390
foreach (int item in gases)
377391
{
@@ -505,9 +519,15 @@ public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb
505519
if (planet.type == EPlanetType.Gas)
506520
{
507521
sb.Append("None").Append(spreadsheetColumnSeparator.Value); // Ocean
522+
EVeinType type = (EVeinType)1;
508523
foreach (VeinProto item in LDB.veins.dataArray)
509524
{
510525
sb.Append("0").Append(spreadsheetColumnSeparator.Value);
526+
if (type != EVeinType.Oil && ConfigExtraFlags.veinCounts.Value)
527+
{
528+
sb.Append("0").Append(spreadsheetColumnSeparator.Value);
529+
}
530+
type++;
511531
}
512532
foreach (int item in gases)
513533
{
@@ -540,9 +560,15 @@ public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb
540560

541561
if (planet.veinGroups.Length == 0)
542562
{
563+
EVeinType type = (EVeinType)1;
543564
foreach (VeinProto item in LDB.veins.dataArray)
544565
{
545566
sb.Append("Unloaded").Append(spreadsheetColumnSeparator.Value);
567+
if (type != EVeinType.Oil && ConfigExtraFlags.veinCounts.Value)
568+
{
569+
sb.Append("Unloaded").Append(spreadsheetColumnSeparator.Value);
570+
}
571+
type++;
546572
}
547573
}
548574
else
@@ -558,6 +584,20 @@ public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb
558584
else
559585
{
560586
sb.Append(amount.ToString(spreadsheetLocale)).Append(spreadsheetColumnSeparator.Value);
587+
588+
if (ConfigExtraFlags.veinCounts.Value)
589+
{
590+
long numVeins = 0;
591+
foreach (PlanetData.VeinGroup veinGroup in planet.veinGroups)
592+
{
593+
if (veinGroup.type == type)
594+
{
595+
numVeins += veinGroup.count;
596+
}
597+
}
598+
599+
sb.Append(numVeins.ToString(spreadsheetLocale)).Append(spreadsheetColumnSeparator.Value);
600+
}
561601
}
562602
type++;
563603
}
@@ -597,7 +637,7 @@ public static void GameMain_Begin_Prefix()
597637

598638
if (GameMain.instance != null && GameObject.Find("Game Menu/button-1-bg"))
599639
{
600-
if (GameObject.Find("greyhak-csv-trigger-button"))
640+
if (progressImage != null)
601641
{
602642
progressImage.fillAmount = 0;
603643
}
@@ -639,20 +679,6 @@ public static void GameMain_Begin_Prefix()
639679
Logger.LogInfo("Button load complete");
640680
}
641681
}
642-
643-
if (enableOnStartTrigger)
644-
{
645-
QueuePlanetLoading();
646-
}
647-
}
648-
649-
[HarmonyPrefix, HarmonyPatch(typeof(GameMain), "Pause")]
650-
public static void GameMain_Pause_Prefix()
651-
{
652-
if (enableOnPauseTrigger)
653-
{
654-
QueuePlanetLoading();
655-
}
656682
}
657683

658684
public static Sprite GetSprite()

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141
// You can specify all the values or you can default the Build and Revision Numbers
4242
// by using the '*' as shown below:
4343
// [assembly: AssemblyVersion("1.0.*")]
44-
[assembly: AssemblyVersion("3.1.1")]
45-
[assembly: AssemblyFileVersion("3.1.1")]
44+
[assembly: AssemblyVersion("3.1.2")]
45+
[assembly: AssemblyFileVersion("3.1.2")]

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The generated spreadsheet will contain columns for the following data.
5252
- _ Optical grating crystal quantity
5353
- _ Spiniform stalagmite crystal quantity
5454
- _ Unipolar magnet quantity
55+
- _ Number of veins for each resource can be configurable enabled
5556
- Gas Planet Resource
5657
- _ Hydrogen rate
5758
- _ Deuterium rate
@@ -162,6 +163,11 @@ The source code for this mod is available for download, review and forking on Gi
162163
在BSD3条例许可下,本mod的源代码可供在[GitHub](https://github.com/GreyHak/dsp-csv-gen)下载、查看、克隆。
163164

164165
## Change Log
166+
### v3.1.2
167+
- Fixed an error which wasn't outputting the available information when configured not to load planets.
168+
- Added new optional output for the number of veins of each resource on a planet.
169+
- Fixed a graphical glitch if config changes were made in game while spreadsheet generation was in progress.
170+
- Minor code cleanup for efficiency.
165171
### v3.1.1
166172
- Minor bug fix in log entry of filename.
167173
### v3.1.0

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "DSP_Star_Sector_Resource_Spreadsheet_Generator",
3-
"version_number": "3.1.1",
3+
"version_number": "3.1.2",
44
"website_url": "https://github.com/GreyHak/dsp-csv-gen",
55
"description": "Generates a spreadsheet of all resources in the star sector.",
66
"dependencies": [

0 commit comments

Comments
 (0)