Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 663832c

Browse files
author
Sam Byass
committed
3.3: Big cleanup + ShitRimworldSays support
1 parent d423139 commit 663832c

32 files changed

+505
-251
lines changed

1.3/Assemblies/BetterLoading.dll

8 KB
Binary file not shown.

1.3/Assemblies/Tomlet.dll

68.5 KB
Binary file not shown.

About/About.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<name>BetterLoading</name>
44
<author>Samboy063</author>
55
<packageId>me.samboycoding.betterloading.dev</packageId>
6-
<url></url>
6+
<url>https://github.com/SamboyCoding/RimworldBetterLoading</url>
77
<supportedVersions>
88
<li>1.0</li>
99
<li>1.1</li>

About/Manifest.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<Manifest>
33
<identifier>BetterLoading</identifier>
4-
<version>3.2.0.1</version>
4+
<version>3.3.0.0</version>
55
<loadBefore>
66
<li>Core &gt;= 1.0</li>
77
<li>Startupimpact</li>

README.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
# RimworldBetterLoading
1+
# BetterLoading
2+
## A mod to make RimWorld loading screens look nice
23

34
See the [steam workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=1999454301) page for a full description.
45

5-
If you encounter issues, feel free to @ me on the Rimworld discord (my name there is `Samboy [BetterLoading]`) or DM me (Samboy#0063) - I do want to know of them, and will fix them ASAP.
6+
If you encounter issues, I would really appreciate knowing about them. You can reach me via several methods:
7+
- I have a [dedicated discord server](https://discord.gg/https://discord.gg/3d8xvnBJgX) for my code projects, including BetterLoading.
8+
- I'm in the [official RimWorld discord](https://discord.gg/rimworld) as `Samboy [BetterLoading]`, and you can mention me in the mod-general channel.
9+
- You can DM me (Samboy#0063) on discord, I accept random friend requests.
10+
- You can leave a comment on the steam workshop page (though these don't get checked quite as often)
11+
- You can open an issue here on github, which will send a message to my discord server.

Source/BetterLoading.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<TargetFramework>TargetFramework</TargetFramework>
44
<OutputType>Library</OutputType>
55
<TargetFramework>net48</TargetFramework>
6-
<LangVersion>8</LangVersion>
7-
<Nullable>annotations</Nullable>
6+
<LangVersion>10</LangVersion>
7+
<Nullable>enable</Nullable>
88
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
99
</PropertyGroup>
1010
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -45,5 +45,6 @@
4545
</ItemGroup>
4646
<ItemGroup>
4747
<PackageReference Include="Lib.Harmony" Version="2.1.0" />
48+
<PackageReference Include="Samboy063.Tomlet" Version="3.1.3" />
4849
</ItemGroup>
4950
</Project>

Source/BetterLoading.sln

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ VisualStudioVersion = 16.0.30011.22
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterLoading", "BetterLoading.csproj", "{E08CFC22-1BA8-41FE-A60B-491C308B8B65}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{46226B08-22BA-455E-8B99-F496E90EDCBC}"
9+
ProjectSection(SolutionItems) = preProject
10+
.gitignore = ..\.gitignore
11+
README.md = ..\README.md
12+
LoadFolders.xml = ..\LoadFolders.xml
13+
About\About.xml = ..\About\About.xml
14+
About\Manifest.xml = ..\About\Manifest.xml
15+
EndProjectSection
16+
EndProject
817
Global
918
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1019
Debug|Any CPU = Debug|Any CPU

Source/BetterLoadingConfig.cs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using Tomlet.Attributes;
3+
4+
namespace BetterLoading;
5+
6+
public class BetterLoadingConfig
7+
{
8+
9+
public static BetterLoadingConfig CreateDefault()
10+
{
11+
return new()
12+
{
13+
TipCache = new()
14+
{
15+
Version = TipCacheConfig.SupportedVersion,
16+
}
17+
};
18+
}
19+
20+
[TomlPrecedingComment("The TipCache caches information about loading screen tips so that they can be displayed as soon as the loading screen starts after the first run.")]
21+
public TipCacheConfig TipCache;
22+
23+
[TomlDoNotInlineObject]
24+
public class TipCacheConfig
25+
{
26+
public static readonly int SupportedVersion = 1;
27+
28+
[TomlPrecedingComment("The internal version number of the TipCache tip blob. If this number is different from the one expected by the mod, the TipCache will be cleared.")]
29+
public int Version;
30+
[TomlPrecedingComment("The raw tip blob. NOT intended to be manually edited.")]
31+
public byte[] Tips = Array.Empty<byte>();
32+
}
33+
}

Source/BetterLoadingConfigManager.cs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.IO;
3+
using Tomlet;
4+
using Tomlet.Exceptions;
5+
using Tomlet.Models;
6+
using Verse;
7+
8+
namespace BetterLoading;
9+
10+
/// <summary>
11+
/// This class exists because XML is the spawn of the devil and I refuse to use it for config files.
12+
/// </summary>
13+
public static class BetterLoadingConfigManager
14+
{
15+
private static string _oldCachedLoadingTipsPath = Path.Combine(GenFilePaths.ConfigFolderPath, "BetterLoading_Cached_Tips");
16+
public static string ConfigFilePath = Path.Combine(GenFilePaths.ConfigFolderPath, "BetterLoading.toml");
17+
18+
public static BetterLoadingConfig Config { get; private set; } = new();
19+
20+
static BetterLoadingConfigManager()
21+
{
22+
//Register a byte array <=> base64 string converter
23+
TomletMain.RegisterMapper(bytes => new TomlString(Convert.ToBase64String(bytes ?? throw new NullReferenceException("Cannot serialize a null byte array"))), tomlValue =>
24+
{
25+
if (tomlValue is not TomlString tomlString)
26+
throw new TomlTypeMismatchException(typeof(TomlString), tomlValue.GetType(), typeof(byte[]));
27+
return Convert.FromBase64String(tomlString.Value);
28+
});
29+
}
30+
31+
public static void Load()
32+
{
33+
if(File.Exists(_oldCachedLoadingTipsPath))
34+
File.Delete(_oldCachedLoadingTipsPath);
35+
36+
if (!File.Exists(ConfigFilePath))
37+
{
38+
Config = BetterLoadingConfig.CreateDefault();
39+
return;
40+
}
41+
42+
try
43+
{
44+
var doc = TomlParser.ParseFile(ConfigFilePath);
45+
Config = TomletMain.To<BetterLoadingConfig>(doc);
46+
LoadingScreenTipManager.TryReadCachedTipsFromConfig();
47+
}
48+
catch (TomlException e)
49+
{
50+
Log.Error($"[BetterLoading] {e.GetType()} thrown while parsing config file: {e.Message}. Config will be reset.");
51+
File.Delete(ConfigFilePath);
52+
Config = BetterLoadingConfig.CreateDefault();
53+
}
54+
}
55+
56+
public static void Save()
57+
{
58+
var tomlString = TomletMain.TomlStringFrom(Config);
59+
File.WriteAllText(ConfigFilePath, tomlString);
60+
}
61+
}

0 commit comments

Comments
 (0)