From 9037e43170899326650be0373dd7154c03856a31 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Fri, 19 Apr 2019 23:01:43 -0500 Subject: [PATCH] Switched to passing around metadata for update info --- .../ViewControllers/ModInfoViewController.cs | 7 +++--- .../UI/ViewControllers/ModListController.cs | 23 ++++++++++++++----- IPA.Loader/Loader/PluginLoader.cs | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs index 35e23ddb..a889685c 100644 --- a/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs @@ -1,5 +1,6 @@ using CustomUI.BeatSaber; using CustomUI.Utilities; +using IPA.Loader; using System; using System.Collections.Generic; using System.Linq; @@ -19,11 +20,11 @@ namespace BSIPA_ModList.UI internal string Version; internal string Author; internal string Description; - internal bool CanUpdate; + internal PluginLoader.PluginMetadata UpdateInfo; private ModInfoView view; - public void Init(Sprite icon, string name, string version, string author, string description, bool canUpdate) + public void Init(Sprite icon, string name, string version, string author, string description, PluginLoader.PluginMetadata updateInfo) { Logger.log.Debug($"init info view controller"); @@ -32,7 +33,7 @@ namespace BSIPA_ModList.UI Version = version; Author = author; Description = description; - CanUpdate = canUpdate; + UpdateInfo = updateInfo; // i also have no clue why this is necessary rectTransform.anchorMin = new Vector2(0f, 0f); diff --git a/BSIPA-ModList/UI/ViewControllers/ModListController.cs b/BSIPA-ModList/UI/ViewControllers/ModListController.cs index 91a19968..29778374 100644 --- a/BSIPA-ModList/UI/ViewControllers/ModListController.cs +++ b/BSIPA-ModList/UI/ViewControllers/ModListController.cs @@ -46,8 +46,19 @@ namespace BSIPA_ModList.UI subtext = "Unspecified Author"; if (plugin.Metadata.Manifest.IconPath != null) - icon = UIUtilities.LoadSpriteRaw(UIUtilities.GetResource(plugin.Metadata.Assembly, plugin.Metadata.Manifest.IconPath)); - else + { + try + { + icon = UIUtilities.LoadSpriteRaw(UIUtilities.GetResource(plugin.Metadata.Assembly, plugin.Metadata.Manifest.IconPath)); + } + catch (Exception e) + { + Logger.log.Error($"Error loading icon for {plugin.Metadata.Name}"); + Logger.log.Error(e); + } + } + + if (icon == null) icon = DefaultIcon; Logger.log.Debug($"BSIPAModCell {plugin.Metadata.Name} {plugin.Metadata.Version}"); @@ -67,7 +78,7 @@ namespace BSIPA_ModList.UI infoView = BeatSaberUI.CreateViewController(); infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), subtext, - desc, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) == null); + desc, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) != null ? Plugin.Metadata : null); } list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); @@ -112,7 +123,7 @@ namespace BSIPA_ModList.UI infoView = BeatSaberUI.CreateViewController(); infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), authorText, - desc, Plugin.Features.FirstOrDefault(f => f is NoUpdateFeature) == null); + desc, Plugin.Features.FirstOrDefault(f => f is NoUpdateFeature) != null ? Plugin : null); } list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); @@ -162,7 +173,7 @@ namespace BSIPA_ModList.UI infoView = BeatSaberUI.CreateViewController(); infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), subtext, - desc, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) == null); + desc, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) != null ? Plugin.Metadata : null); } list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); @@ -206,7 +217,7 @@ namespace BSIPA_ModList.UI infoView = BeatSaberUI.CreateViewController(); infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), "Unknown Author", "This mod was written for IPA Reloaded. No metadata is avaliable for this mod. " + - "Please contact the mod author and ask them to port it to BSIPA to provide more information.", false); + "Please contact the mod author and ask them to port it to BSIPA to provide more information.", null); } list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index dd4756a4..c44cb6cd 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -27,7 +27,7 @@ namespace IPA.Loader }); /// - /// A class which describes + /// A class which describes a loaded plugin. /// public class PluginMetadata {