-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new configuration available for the config.json for all mods - it is possible to define directories as optional and connect it to a condition like a mod variable or an installed mod - it is possible to define more than one Data directory and connect them to a condition like a mod variable or an installed mod
- Loading branch information
Showing
11 changed files
with
219 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Newtonsoft.Json; | ||
using System.ComponentModel; | ||
|
||
namespace DigglesModManager.Model | ||
{ | ||
public class ModDirectory | ||
{ | ||
/// <summary> | ||
/// The type of the directory. [REQUIRED] | ||
/// </summary> | ||
[JsonProperty(PropertyName = "type", Required = Required.Always)] | ||
public ModDirectoryType Type { get; set; } | ||
|
||
/// <summary> | ||
/// Path of directory relative to mod root. [REQUIRED] | ||
/// </summary> | ||
[JsonProperty(PropertyName = "path", Required = Required.Always)] | ||
public string Path | ||
{ | ||
get | ||
{ | ||
return path; | ||
} | ||
set | ||
{ | ||
//replace backslashes with slashes | ||
path = value.Replace("\\", "/"); | ||
} | ||
} | ||
|
||
private string path; | ||
|
||
/// <summary> | ||
/// Condition that has to be true to add this directory. | ||
/// </summary> | ||
[DefaultValue(null)] | ||
[JsonProperty(PropertyName = "condition", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Populate)] | ||
public ModDirectroyCondition Condition { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace DigglesModManager.Model | ||
{ | ||
/// <summary> | ||
/// The available and possible types of mod directories. | ||
/// </summary> | ||
public enum ModDirectoryType | ||
{ | ||
Data, Optional | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
|
||
namespace DigglesModManager.Model | ||
{ | ||
public class ModDirectroyCondition | ||
{ | ||
/// <summary> | ||
/// The type of the directory condition. [REQUIRED] | ||
/// </summary> | ||
[JsonProperty(PropertyName = "type", Required = Required.Always)] | ||
public ModDirectroyConditionType Type { get; set; } | ||
|
||
/// <summary> | ||
/// ID of the variable or mod that has to be checked. [REQUIRED] | ||
/// (Type Mod: mod directory name; Type Variable: mod variable id) | ||
/// </summary> | ||
[JsonProperty(PropertyName = "id", Required = Required.Always)] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// The variable has to have this value to evaluate the condtion as true. | ||
/// (required for type "variable") | ||
/// </summary> | ||
[DefaultValue(null)] | ||
[JsonProperty(PropertyName = "value", Required = Required.Default, DefaultValueHandling = DefaultValueHandling.Populate)] | ||
public object Value { get; set; } | ||
|
||
public bool isTrue(Mod mod, List<Mod> activeMods) | ||
{ | ||
switch (Type) | ||
{ | ||
case ModDirectroyConditionType.Mod: | ||
foreach (var activeMod in activeMods) | ||
{ | ||
if (activeMod.ModDirectoryName.Equals(this.Id)) | ||
{ | ||
return true; | ||
} | ||
} | ||
//no warning, because the existence of a mod is checked. | ||
break; | ||
case ModDirectroyConditionType.Variable: | ||
if (this.Value == null) | ||
{ | ||
Log.Warning(mod.ModDirectoryName + ": Variable with ID \"" + this.Id + "\" needs a value."); | ||
break; | ||
} | ||
foreach (var modVariable in mod.Config.SettingsVariables) | ||
{ | ||
if (modVariable.ID.Equals(this.Id)) | ||
{ | ||
return modVariable.Value.Equals(this.Value); | ||
} | ||
} | ||
Log.Warning(mod.ModDirectoryName + ": Variable with ID \"" + this.Id + "\" not found"); | ||
break; | ||
default: | ||
Log.Warning(mod.ModDirectoryName + ": Unhandled ModDirectroyConditionType \"" + Type + "\""); | ||
break; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace DigglesModManager.Model | ||
{ | ||
public enum ModDirectroyConditionType | ||
{ | ||
Mod, Variable | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters