Browse Source

Switched to passing around metadata for update info

pull/11/head
Anairkoen Schno 5 years ago
parent
commit
9037e43170
3 changed files with 22 additions and 10 deletions
  1. +4
    -3
      BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs
  2. +17
    -6
      BSIPA-ModList/UI/ViewControllers/ModListController.cs
  3. +1
    -1
      IPA.Loader/Loader/PluginLoader.cs

+ 4
- 3
BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs View File

@ -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);


+ 17
- 6
BSIPA-ModList/UI/ViewControllers/ModListController.cs View File

@ -46,8 +46,19 @@ namespace BSIPA_ModList.UI
subtext = "<color=#BFBFBF><i>Unspecified Author</i>";
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<ModInfoViewController>();
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<ModInfoViewController>();
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<ModInfoViewController>();
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<ModInfoViewController>();
infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), "<color=#BFBFBF><i>Unknown Author</i>",
"<color=#A0A0A0>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);


+ 1
- 1
IPA.Loader/Loader/PluginLoader.cs View File

@ -27,7 +27,7 @@ namespace IPA.Loader
});
/// <summary>
/// A class which describes
/// A class which describes a loaded plugin.
/// </summary>
public class PluginMetadata
{


Loading…
Cancel
Save