Skip to content

Commit 1429287

Browse files
Point to the Kitten Space Agency folder only
* Fix package release * No need to point to KSA .dll * Improve error message for empty GameLocation * Clarify GameLocation path in README --------- Co-authored-by: KlaasWhite <45828001+KlaasWhite@users.noreply.github.com>
1 parent 57f3ec4 commit 1429287

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ It makes use of Assembly Load Contexts to ensure mod dependencies are managed se
99
- Download and unzip release from [Releases](https://github.com/StarMapLoader/StarMap/releases/latest).
1010
- Run StarMap.exe, this will fail and create a StarMapConfig.json.
1111
- Open StarMapConfig.json and set the location of your KSA installation.
12-
- `GameLocation` should be set to the location of your KSA.dll, pointing directly to that file (e.g. `C:\\games\\Kitten Space Agency\\KSA.dll`)
12+
- `GameLocation` should be set to the location where Kitten Space Agency was installed, pointing directly to that folder (e.g. `C:\\games\\Kitten Space Agency\\`)
1313
- `RepositoryLocation` can be kept empty
1414
- Run StarMap.exe again, this should launch KSA and load your mods.
1515

StarMap.Types/LoaderConfig.cs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,39 @@ public class LoaderConfig
1313

1414
public bool TryLoadConfig()
1515
{
16-
if (!File.Exists("./StarMapConfig.json")) {
16+
if (!File.Exists("./StarMapConfig.json"))
17+
{
1718
Console.WriteLine("Please fill the StarMapConfig.json and restart the program");
18-
File.Create("./StarMapConfig.json").Dispose();
19-
File.WriteAllText("./StarMapConfig.json", JsonSerializer.Serialize(new LoaderConfig()));
20-
Console.ReadLine();
19+
File.WriteAllText("./StarMapConfig.json", JsonSerializer.Serialize(new LoaderConfig(), new JsonSerializerOptions { WriteIndented = true }));
2120
return false;
2221
}
23-
22+
2423
var jsonString = File.ReadAllText("./StarMapConfig.json");
2524
var config = JsonSerializer.Deserialize<LoaderConfig>(jsonString);
26-
25+
2726
if (config is null) return false;
28-
29-
if (string.IsNullOrEmpty(config.GameLocation) || !File.Exists(config.GameLocation))
27+
28+
if (string.IsNullOrEmpty(config.GameLocation))
3029
{
3130
Console.WriteLine("The 'GameLocation' property in StarMapConfig.json is either empty or points to a non-existing file.");
32-
Console.ReadLine();
3331
return false;
3432
}
35-
36-
GameLocation = config.GameLocation;
33+
34+
string path = config.GameLocation;
35+
36+
if (Directory.Exists(path))
37+
{
38+
path = Path.Combine(path, "KSA.dll");
39+
}
40+
41+
if (!File.Exists(path))
42+
{
43+
Console.WriteLine("Could not find KSA.dll. Make sure the folder or file path is correct:");
44+
Console.WriteLine(path);
45+
return false;
46+
}
47+
48+
GameLocation = path;
3749
return true;
3850
}
3951

0 commit comments

Comments
 (0)