Added support for different files for different versions in mod
This commit is contained in:
parent
02d9df8160
commit
515aa519a4
27
README.md
27
README.md
|
@ -1,4 +1,4 @@
|
||||||
WIP ScrapModLoader
|
WIP ScrapModLoader
|
||||||
==============
|
==============
|
||||||
|
|
||||||
This applications is for managing mods for Scrapland.
|
This applications is for managing mods for Scrapland.
|
||||||
|
@ -25,11 +25,29 @@ ScrapModLoader supports both original and remastered versions of Scrapland.
|
||||||
For now mod for Scrapland is a *.sm file that basically is a zip arhive with following content:
|
For now mod for Scrapland is a *.sm file that basically is a zip arhive with following content:
|
||||||
|
|
||||||
| Filename | Description |
|
| Filename | Description |
|
||||||
|--------------------|----------------------------------------------|
|
|------------------------|--------------------------------------------------|
|
||||||
| icon.png | Icon for mod that will show up in mod loader |
|
| icon.png | Icon for mod that will show up in mod loader |
|
||||||
| config.toml | Information about mod |
|
| config.toml | Information about mod |
|
||||||
|
| <game_version\>\ | Folder that named as game version mod made for |
|
||||||
| <filename\>.packed | Container with all mod game assets |
|
| <filename\>.packed | Container with all mod game assets |
|
||||||
|
|
||||||
|
You can have as many .packed files as you want. Mod loader will load everything.
|
||||||
|
|
||||||
|
.packed files in the root of mod will be copied to the `Mods` folder of Scrapland.
|
||||||
|
|
||||||
|
.pakced files under game version folder will load only to the appopriate game version.
|
||||||
|
|
||||||
|
### .sm structure sample
|
||||||
|
```
|
||||||
|
│ icon.png
|
||||||
|
│ config.toml
|
||||||
|
│ mod_assets.packed
|
||||||
|
├──1.0/
|
||||||
|
│ only_for_original.packed
|
||||||
|
└──1.1/
|
||||||
|
only_for_remastered.packed
|
||||||
|
```
|
||||||
|
|
||||||
### config.toml sample
|
### config.toml sample
|
||||||
```toml
|
```toml
|
||||||
title = "Mod title"
|
title = "Mod title"
|
||||||
|
@ -37,7 +55,7 @@ description = "Mod description"
|
||||||
category = "Mod category"
|
category = "Mod category"
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
requiredLauncher = "1.0"
|
requiredLauncher = "1.0"
|
||||||
requiredGame = "1.0"
|
supportedGameVersions = ["1.0", "1.1"]
|
||||||
|
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Author 1" },
|
{ name = "Author 1" },
|
||||||
|
@ -64,9 +82,10 @@ credits = [
|
||||||
|
|
||||||
- [X] Support for custom *.packed
|
- [X] Support for custom *.packed
|
||||||
- [X] Supoprt for Scrapland Remastered
|
- [X] Supoprt for Scrapland Remastered
|
||||||
|
- [ ] Support for both Scrapland versions in single .sm file
|
||||||
- [ ] Support for custom game files (i.e. `\Traslation\` files or custom `QuickConsole.py`)
|
- [ ] Support for custom game files (i.e. `\Traslation\` files or custom `QuickConsole.py`)
|
||||||
- [ ] Recompiling *.py to *.pyc
|
- [ ] Recompiling *.py to *.pyc
|
||||||
- [ ] Mod settings.
|
- [ ] Mod settings.
|
||||||
- [ ] More meta info in `config.xml`
|
- [ ] More meta info in `config.toml`
|
||||||
- [ ] Multilanguage support
|
- [ ] Multilanguage support
|
||||||
- [ ] More mods :wink:
|
- [ ] More mods :wink:
|
|
@ -34,8 +34,9 @@
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
|
<GridViewColumn Header="Category" DisplayMemberBinding="{Binding Category}" />
|
||||||
<GridViewColumn Header="Mod Version" DisplayMemberBinding="{Binding Version}" />
|
<GridViewColumn Header="Mod Version" DisplayMemberBinding="{Binding Version}" />
|
||||||
<GridViewColumn Header="Game Version" DisplayMemberBinding="{Binding RequiredGame}" />
|
<GridViewColumn Header="Game Version" DisplayMemberBinding="{Binding SupportedGameVersionsDisplay}" />
|
||||||
</GridView>
|
</GridView>
|
||||||
</ListView.View>
|
</ListView.View>
|
||||||
<ListView.ItemContainerStyle>
|
<ListView.ItemContainerStyle>
|
||||||
|
|
|
@ -86,20 +86,17 @@ namespace ScrapModLoader
|
||||||
|
|
||||||
foreach (ScrapMod mod in Mods)
|
foreach (ScrapMod mod in Mods)
|
||||||
{
|
{
|
||||||
if (mod.RequiredGame != SelectedGameVersion)
|
// TODO: Warning about not loading mods that not supports selected version
|
||||||
|
if (!mod.SupportedGameVersions.Contains(SelectedGameVersion))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mod.Checked)
|
if (mod.Checked)
|
||||||
{
|
|
||||||
if (!mod.IsEnabled(gamePath))
|
if (!mod.IsEnabled(gamePath))
|
||||||
mod.Enable(gamePath);
|
mod.Enable(gamePath, SelectedGameVersion);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (mod.IsEnabled(gamePath))
|
if (mod.IsEnabled(gamePath))
|
||||||
mod.Disable(gamePath);
|
mod.Disable(gamePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -20,7 +20,16 @@ namespace ScrapModLoader
|
||||||
public String Category { get; private set; }
|
public String Category { get; private set; }
|
||||||
public String Version { get; private set; }
|
public String Version { get; private set; }
|
||||||
public String RequiredLauncher { get; private set; }
|
public String RequiredLauncher { get; private set; }
|
||||||
public String RequiredGame { get; private set; }
|
public List<String> SupportedGameVersions { get; private set; }
|
||||||
|
public String SupportedGameVersionsDisplay {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
String result = String.Empty;
|
||||||
|
foreach (String version in SupportedGameVersions)
|
||||||
|
result += version + ", ";
|
||||||
|
return result.TrimEnd(',', ' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
public List<String> Authors { get; private set; }
|
public List<String> Authors { get; private set; }
|
||||||
public Dictionary<String, List<String>> Credits { get; private set; }
|
public Dictionary<String, List<String>> Credits { get; private set; }
|
||||||
|
|
||||||
|
@ -34,7 +43,7 @@ namespace ScrapModLoader
|
||||||
Category = String.Empty;
|
Category = String.Empty;
|
||||||
Version = String.Empty;
|
Version = String.Empty;
|
||||||
RequiredLauncher = String.Empty;
|
RequiredLauncher = String.Empty;
|
||||||
RequiredGame = String.Empty;
|
SupportedGameVersions = new List<String>();
|
||||||
Authors = new List<String>();
|
Authors = new List<String>();
|
||||||
Credits = new Dictionary<String, List<String>>();
|
Credits = new Dictionary<String, List<String>>();
|
||||||
LoadFromFile(path);
|
LoadFromFile(path);
|
||||||
|
@ -58,20 +67,18 @@ namespace ScrapModLoader
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Enable(String gamePath)
|
public void Enable(String gamePath, String gameVersion)
|
||||||
{
|
{
|
||||||
if (!IsLoaded(gamePath))
|
if (!IsLoaded(gamePath))
|
||||||
LoadModToGame(gamePath);
|
LoadModToGame(gamePath, gameVersion);
|
||||||
|
|
||||||
if (IsEnabled(gamePath))
|
if (IsEnabled(gamePath))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (String file in Directory.EnumerateFiles(gamePath + @"Mods\" + Name))
|
foreach (String file in Directory.EnumerateFiles(gamePath + @"Mods\" + Name))
|
||||||
{
|
|
||||||
if (Path.GetExtension(file) == ".disabled")
|
if (Path.GetExtension(file) == ".disabled")
|
||||||
File.Move(file, Path.ChangeExtension(file, null));
|
File.Move(file, Path.ChangeExtension(file, null));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Disable(String gamePath)
|
public void Disable(String gamePath)
|
||||||
{
|
{
|
||||||
|
@ -79,13 +86,11 @@ namespace ScrapModLoader
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (String file in Directory.EnumerateFiles(gamePath + @"Mods\" + Name))
|
foreach (String file in Directory.EnumerateFiles(gamePath + @"Mods\" + Name))
|
||||||
{
|
|
||||||
if (Path.GetExtension(file) == ".packed")
|
if (Path.GetExtension(file) == ".packed")
|
||||||
File.Move(file, file + ".disabled");
|
File.Move(file, file + ".disabled");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadModToGame(String gamePath)
|
private void LoadModToGame(String gamePath, String gameVersion)
|
||||||
{
|
{
|
||||||
gamePath += @"Mods\" + Name;
|
gamePath += @"Mods\" + Name;
|
||||||
Directory.CreateDirectory(gamePath);
|
Directory.CreateDirectory(gamePath);
|
||||||
|
@ -94,13 +99,14 @@ namespace ScrapModLoader
|
||||||
{
|
{
|
||||||
foreach (ZipEntry zipEntry in zipFile)
|
foreach (ZipEntry zipEntry in zipFile)
|
||||||
{
|
{
|
||||||
|
if (!Path.GetFullPath(zipEntry.FileName).Contains(gameVersion))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (Path.GetExtension(zipEntry.FileName) == ".packed")
|
if (Path.GetExtension(zipEntry.FileName) == ".packed")
|
||||||
{
|
|
||||||
zipEntry.Extract(gamePath);
|
zipEntry.Extract(gamePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadFromFile(String path)
|
private void LoadFromFile(String path)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +157,9 @@ namespace ScrapModLoader
|
||||||
Category = config["category"];
|
Category = config["category"];
|
||||||
Version = config["version"];
|
Version = config["version"];
|
||||||
RequiredLauncher = config["requiredLauncher"];
|
RequiredLauncher = config["requiredLauncher"];
|
||||||
RequiredGame = config["requiredGame"];
|
|
||||||
|
foreach (TomlNode version in config["supportedGameVersions"])
|
||||||
|
SupportedGameVersions.Add(version);
|
||||||
|
|
||||||
foreach (TomlNode author in config["authors"])
|
foreach (TomlNode author in config["authors"])
|
||||||
Authors.Add(author["name"]);
|
Authors.Add(author["name"]);
|
||||||
|
@ -185,8 +193,8 @@ namespace ScrapModLoader
|
||||||
if (!config.HasKey("requiredLauncher"))
|
if (!config.HasKey("requiredLauncher"))
|
||||||
throw new FileFormatException("No 'name' key in 'config.toml'");
|
throw new FileFormatException("No 'name' key in 'config.toml'");
|
||||||
|
|
||||||
if (!config.HasKey("requiredGame"))
|
if (!config.HasKey("supportedGameVersions"))
|
||||||
throw new FileFormatException("No 'requiredGame' key in 'config.toml'");
|
throw new FileFormatException("No 'supportedGameVersions' key in 'config.toml'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue