Skip to content

Commit

Permalink
Add main menu warning if outdated mods detected
Browse files Browse the repository at this point in the history
- Show yellow triangle next to "Mods" if SW detects at least one outdated mode
- Add settings config if warning should be displayed, defaults to true
  • Loading branch information
Falki-git committed Jul 10, 2023
1 parent fd4eb9e commit 6d5a922
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 4 additions & 5 deletions SpaceWarp/SpaceWarpPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public sealed class SpaceWarpPlugin : BaseSpaceWarpPlugin
public const string ModVer = MyPluginInfo.PLUGIN_VERSION;
internal ConfigEntry<Color> ConfigAllColor;
internal ConfigEntry<bool> ConfigCheckVersions;
internal ConfigEntry<bool> ConfigShowMainMenuWarningForOutdatedMods;
internal ConfigEntry<Color> ConfigDebugColor;
internal ConfigEntry<int> ConfigDebugMessageLimit;


internal ConfigEntry<Color> ConfigErrorColor;
private ConfigEntry<bool> _configFirstLaunch;
Expand Down Expand Up @@ -120,9 +120,10 @@ private void SetupSpaceWarpConfiguration()
"Whether or not this is the first launch of space warp, used to show the version checking prompt to the user.");
ConfigCheckVersions = Config.Bind("Version Checking", "Check Versions", false,
"Whether or not Space Warp should check mod versions using their swinfo.json files");
ConfigShowMainMenuWarningForOutdatedMods = Config.Bind("Version Checking", "Show Warning for Outdated Mods", true,
"Whether or not Space Warp should display a warning in main menu if there are outdated mods");
}


private void SetupLuaState()
{
// I have been warned and I do not care
Expand All @@ -149,7 +150,6 @@ private void SetupLuaState()
}
}


public override void OnInitialized()
{
base.OnInitialized();
Expand Down Expand Up @@ -188,10 +188,9 @@ public override void OnInitialized()
public override void OnPostInitialized()
{
InitializeSettingsUI();
SpaceWarpManager.ModListController.AddMainMenuItem();
}



public void ClearVersions()
{
foreach (var plugin in SpaceWarpManager.AllPlugins)
Expand Down
12 changes: 11 additions & 1 deletion SpaceWarp/UI/ModList/ModListController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,18 @@ private void Awake()
{
_listEntryTemplate = AssetManager.GetAsset<VisualTreeAsset>($"{SpaceWarpPlugin.ModGuid}/modlist/modlistitem.uxml");
_dependencyTemplate = AssetManager.GetAsset<VisualTreeAsset>($"{SpaceWarpPlugin.ModGuid}/modlist/modlistdependency.uxml");
}

internal void AddMainMenuItem()
{
string term;

if (SpaceWarpPlugin.Instance.ConfigShowMainMenuWarningForOutdatedMods.Value && SpaceWarpManager.ModsOutdated.ContainsValue(true))
term = "SpaceWarp/Mods/Outdated";
else
term = "SpaceWarp/Mods";

MainMenu.RegisterLocalizedMenuButton("SpaceWarp/Mods", ToggleWindow);
MainMenu.RegisterLocalizedMenuButton(term, ToggleWindow);
}

private void OnEnable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SpaceWarp/ModList/DisabledDependency,Text,,Dependency is disabled,Esta dependên
SpaceWarp/ModList/UnspecifiedDependency,Text,,Dependency was not specified in SW info,Esta dependência não está presente no swinfo
SpaceWarp/ModList/UnsupportedDependency,Text,,Dependency is of an unsupported version,Esta dependência é de uma versão nao suportada
SpaceWarp/Mods,Text,,Mods,Mods
SpaceWarp/Mods/Outdated,Text,,Mods <color=yellow>⚠</color>,Mods <color=yellow>⚠</color>
SpaceWarp,Text,,Space Warp,Space Warp
SpaceWarp/VersionChecking,Text,,Allow Space Warp to check versions for mods over the network?,Deixar SpaceWarp verificar a versão dos mods na internet?
SpaceWarp/Yes,Text,,Yes,Sim
Expand Down

0 comments on commit 6d5a922

Please sign in to comment.