Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ It makes use of Assembly Load Contexts to ensure mod dependencies are managed se
- Download and unzip release from [Releases](https://github.com/StarMapLoader/StarMap/releases/latest).
- Run StarMap.exe, this will fail and create a StarMapConfig.json.
- Open StarMapConfig.json and set the location of your KSA installation.
- `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`)
- `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\\`)
- `RepositoryLocation` can be kept empty
- Run StarMap.exe again, this should launch KSA and load your mods.

Expand Down
34 changes: 23 additions & 11 deletions StarMap.Types/LoaderConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,39 @@ public class LoaderConfig

public bool TryLoadConfig()
{
if (!File.Exists("./StarMapConfig.json")) {
if (!File.Exists("./StarMapConfig.json"))
{
Console.WriteLine("Please fill the StarMapConfig.json and restart the program");
File.Create("./StarMapConfig.json").Dispose();
File.WriteAllText("./StarMapConfig.json", JsonSerializer.Serialize(new LoaderConfig()));
Console.ReadLine();
File.WriteAllText("./StarMapConfig.json", JsonSerializer.Serialize(new LoaderConfig(), new JsonSerializerOptions { WriteIndented = true }));
return false;
}

var jsonString = File.ReadAllText("./StarMapConfig.json");
var config = JsonSerializer.Deserialize<LoaderConfig>(jsonString);

if (config is null) return false;

if (string.IsNullOrEmpty(config.GameLocation) || !File.Exists(config.GameLocation))
if (string.IsNullOrEmpty(config.GameLocation))
{
Console.WriteLine("The 'GameLocation' property in StarMapConfig.json is either empty or points to a non-existing file.");
Console.ReadLine();
return false;
}

GameLocation = config.GameLocation;

string path = config.GameLocation;

if (Directory.Exists(path))
{
path = Path.Combine(path, "KSA.dll");
}

if (!File.Exists(path))
{
Console.WriteLine("Could not find KSA.dll. Make sure the folder or file path is correct:");
Console.WriteLine(path);
return false;
}

GameLocation = path;
return true;
}

Expand Down