Browse Source

Added support for updating legacy mods if they are formatted properly

Added default More Info link if no others were provided
pull/11/head
Anairkoen Schno 5 years ago
parent
commit
1882f5db92
12 changed files with 113 additions and 37638 deletions
  1. +1
    -1
      BSIPA-ModList/DownloadController.cs
  2. +2
    -2
      BSIPA-ModList/Properties/AssemblyInfo.cs
  3. +2
    -0
      BSIPA-ModList/UI/FloatingNotification.cs
  4. +21
    -7
      BSIPA-ModList/UI/ViewControllers/ModCells.cs
  5. +47
    -13
      BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs
  6. +8
    -3
      BSIPA-ModList/manifest.json
  7. +1
    -1
      IPA.Loader/Loader/PluginLoader.cs
  8. +1
    -1
      IPA.Loader/Loader/PluginManifest.cs
  9. +30
    -5
      IPA.Loader/Updating/BeatMods/Updater.cs
  10. BIN
      Refs/Assembly-CSharp.dll
  11. BIN
      Refs/UnityEngine.CoreModule.dll
  12. +0
    -37605
      Refs/UnityEngine.CoreModule.xml

+ 1
- 1
BSIPA-ModList/DownloadController.cs View File

@ -139,7 +139,7 @@ namespace BSIPA_ModList
Add(new DownloadObject Add(new DownloadObject
{ {
Mod = dep, Mod = dep,
Icon = Utilities.GetIcon(dep.LocalPluginMeta?.Metadata),
Icon = dep.IsLegacy ? Utilities.DefaultIPAIcon : Utilities.GetIcon(dep.LocalPluginMeta?.Metadata),
State = DownloadObject.States.ToDownload, State = DownloadObject.States.ToDownload,
Progress = 0 Progress = 0
}); });


+ 2
- 2
BSIPA-ModList/Properties/AssemblyInfo.cs View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

+ 2
- 0
BSIPA-ModList/UI/FloatingNotification.cs View File

@ -86,6 +86,7 @@ namespace BSIPA_ModList.UI
private void CheckForUpdatesStart() private void CheckForUpdatesStart()
{ {
StopAllCoroutines();
_showingMessage = false; _showingMessage = false;
_headerText.text = HeaderText; _headerText.text = HeaderText;
_headerText.alignment = TextAlignmentOptions.Left; _headerText.alignment = TextAlignmentOptions.Left;
@ -100,6 +101,7 @@ namespace BSIPA_ModList.UI
if (count == 0) updatesZero = true; if (count == 0) updatesZero = true;
else updatesZero = false; else updatesZero = false;
StopAllCoroutines();
_showingMessage = false; _showingMessage = false;
_headerText.text = $"{count} updates found"; _headerText.text = $"{count} updates found";
_headerText.alignment = TextAlignmentOptions.Left; _headerText.alignment = TextAlignmentOptions.Left;


+ 21
- 7
BSIPA-ModList/UI/ViewControllers/ModCells.cs View File

@ -48,8 +48,7 @@ namespace BSIPA_ModList.UI.ViewControllers
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>(); infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), subtext, infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), subtext,
desc, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) != null ? Plugin.Metadata : null,
Plugin.Metadata.Manifest.Links);
desc, Plugin.Metadata, Plugin.Metadata.Manifest.Links);
} }
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
@ -92,8 +91,7 @@ namespace BSIPA_ModList.UI.ViewControllers
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>(); infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), authorText, infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), authorText,
desc, Plugin.Features.FirstOrDefault(f => f is NoUpdateFeature) != null ? Plugin : null,
Plugin.Manifest.Links);
desc, Plugin, Plugin.Manifest.Links);
} }
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
@ -130,8 +128,7 @@ namespace BSIPA_ModList.UI.ViewControllers
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>(); infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), subtext, infoView.Init(icon, Plugin.Metadata.Name, "v" + Plugin.Metadata.Version.ToString(), subtext,
desc, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) != null ? Plugin.Metadata : null,
Plugin.Metadata.Manifest.Links);
desc, Plugin.Metadata, Plugin.Metadata.Manifest.Links);
} }
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
@ -159,10 +156,27 @@ namespace BSIPA_ModList.UI.ViewControllers
if (infoView == null) if (infoView == null)
{ {
PluginLoader.PluginMetadata updateInfo = null;
try
{
updateInfo = new PluginLoader.PluginMetadata
{
Name = Plugin.Name,
Id = Plugin.Name,
Version = new SemVer.Version(Plugin.Version)
};
}
catch (Exception e)
{
Logger.log.Warn($"Could not generate fake update info for {Plugin.Name}");
Logger.log.Warn(e);
}
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>(); infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), "<color=#BFBFBF><i>Unknown Author</i>", 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. " + "<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.", null);
"Please contact the mod author and ask them to port it to BSIPA to provide more information.", updateInfo);
} }
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);


+ 47
- 13
BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs View File

@ -1,8 +1,10 @@
using CustomUI.BeatSaber; using CustomUI.BeatSaber;
using CustomUI.MenuButton; using CustomUI.MenuButton;
using CustomUI.Utilities;
using IPA.Loader; using IPA.Loader;
using IPA.Updating.BeatMods;
using IPA.Utilities;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -60,8 +62,16 @@ namespace BSIPA_ModList.UI
view.Init(this); view.Init(this);
go.SetActive(true); go.SetActive(true);
if (links != null)
SetupLinks(links);
}
private void SetupLinks(PluginManifest.LinksObject links = null, Uri moreInfoLink = null)
{
bool addedLink = false;
if (links != null || moreInfoLink != null)
{ {
Logger.log.Debug($"Adding links");
rowTransform = Instantiate(rowTransformOriginal, rectTransform); rowTransform = Instantiate(rowTransformOriginal, rectTransform);
rowTransform.anchorMin = new Vector2(0f, 0f); rowTransform.anchorMin = new Vector2(0f, 0f);
rowTransform.anchorMax = new Vector2(1f, .15f); rowTransform.anchorMax = new Vector2(1f, .15f);
@ -73,25 +83,53 @@ namespace BSIPA_ModList.UI
Destroy(child.gameObject); Destroy(child.gameObject);
} }
if (links.ProjectHome != null)
if (links?.ProjectHome != null)
{ {
linkHomeButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Home",
linkHomeButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Home",
onClick: () => Process.Start(links.ProjectHome.ToString())); onClick: () => Process.Start(links.ProjectHome.ToString()));
linkHomeButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0); linkHomeButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
addedLink = true;
} }
if (links.ProjectSource != null)
if (links?.ProjectSource != null)
{ {
linkSourceButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Source",
linkSourceButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Source",
onClick: () => Process.Start(links.ProjectSource.ToString())); onClick: () => Process.Start(links.ProjectSource.ToString()));
linkSourceButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0); linkSourceButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
addedLink = true;
} }
if (links.Donate != null)
if (links?.Donate != null)
{ {
linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Donate",
linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "Donate",
onClick: () => Process.Start(links.Donate.ToString())); onClick: () => Process.Start(links.Donate.ToString()));
linkDonateButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0); linkDonateButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
addedLink = true;
}
if (moreInfoLink != null)
{
linkDonateButton = BeatSaberUI.CreateUIButton(rowTransform, "QuitButton", buttonText: "More Info",
onClick: () => Process.Start(moreInfoLink.ToString()));
linkDonateButton.GetComponentInChildren<HorizontalLayoutGroup>().padding = new RectOffset(6, 6, 0, 0);
addedLink = true;
} }
} }
if (UpdateInfo != null && !addedLink)
StartCoroutine(GetMoreInfoLink());
}
private IEnumerator GetMoreInfoLink()
{
Logger.log.Debug($"Getting more info link");
Ref<ApiEndpoint.Mod> mod = new Ref<ApiEndpoint.Mod>(null);
if (UpdateInfo.Id == null) yield break;
yield return Updater.GetModInfo(UpdateInfo.Id, UpdateInfo.Version.ToString(), mod);
try { mod.Verify(); }
catch (Exception e)
{
Logger.log.Warn($"Error getting more info link for mod {UpdateInfo.Id}");
Logger.log.Warn(e);
yield break;
}
SetupLinks(null, mod.Value.Link);
} }
#if DEBUG #if DEBUG
@ -130,8 +168,6 @@ namespace BSIPA_ModList.UI
internal class ModInfoView : MonoBehaviour internal class ModInfoView : MonoBehaviour
{ {
private ModInfoViewController controller;
private TextMeshProUGUI titleText; private TextMeshProUGUI titleText;
private TextMeshProUGUI authorText; private TextMeshProUGUI authorText;
private TextMeshProUGUI descText; private TextMeshProUGUI descText;
@ -139,8 +175,6 @@ namespace BSIPA_ModList.UI
public void Init(ModInfoViewController controller) public void Init(ModInfoViewController controller)
{ {
this.controller = controller;
var rectTransform = transform as RectTransform; var rectTransform = transform as RectTransform;
rectTransform.sizeDelta = new Vector2(60f, 10f); rectTransform.sizeDelta = new Vector2(60f, 10f);
@ -163,7 +197,7 @@ namespace BSIPA_ModList.UI
icon.sprite = controller.Icon; icon.sprite = controller.Icon;
icon.preserveAspect = true; icon.preserveAspect = true;
icon.useSpriteMesh = true; icon.useSpriteMesh = true;
icon.material = UIUtilities.NoGlowMaterial;
icon.material = CustomUI.Utilities.UIUtilities.NoGlowMaterial;
icon.gameObject.SetActive(true); icon.gameObject.SetActive(true);
} }


+ 8
- 3
BSIPA-ModList/manifest.json View File

@ -5,11 +5,16 @@
"gameVersion": "0.13.2", "gameVersion": "0.13.2",
"id": "BSIPA Mod List", "id": "BSIPA Mod List",
"name": "BSIPA Mod List", "name": "BSIPA Mod List",
"version": "1.0.1",
"version": "1.1.0",
"icon": "BSIPA_ModList.Icons.self.png", "icon": "BSIPA_ModList.Icons.self.png",
"dependsOn": { "dependsOn": {
"BSIPA": "^3.12.13",
"BSIPA": "^3.12.14",
"CustomUI": "^1.5.4" "CustomUI": "^1.5.4"
}, },
"features": []
"features": [],
"links": {
"project-home": "https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded/tree/master/BSIPA-ModList",
"project-source": "https://github.com/beat-saber-modding-group/BeatSaber-IPA-Reloaded",
"donate": "https://ko-fi.com/danike"
}
} }

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

@ -47,7 +47,7 @@ namespace IPA.Loader
public string Name { get; internal set; } public string Name { get; internal set; }
/// <summary> /// <summary>
/// The ModSaber ID of the plugin, or null if it doesn't have one.
/// The BeatMods ID of the plugin, or null if it doesn't have one.
/// </summary> /// </summary>
public string Id { get; internal set; } public string Id { get; internal set; }


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

@ -59,6 +59,6 @@ namespace IPA.Loader
} }
[JsonProperty("links", Required = Required.DisallowNull)] [JsonProperty("links", Required = Required.DisallowNull)]
public LinksObject Links = new LinksObject();
public LinksObject Links = null;
} }
} }

+ 30
- 5
IPA.Loader/Updating/BeatMods/Updater.cs View File

@ -67,9 +67,11 @@ namespace IPA.Updating.BeatMods
public HashSet<string> Consumers { get; set; } = new HashSet<string>(); public HashSet<string> Consumers { get; set; } = new HashSet<string>();
public bool MetaRequestFailed { get; set; } public bool MetaRequestFailed { get; set; }
public PluginLoader.PluginInfo LocalPluginMeta { get; set; } public PluginLoader.PluginInfo LocalPluginMeta { get; set; }
public bool IsLegacy { get; set; } = false;
public override string ToString() public override string ToString()
{ {
return $"{Name}@{Version}{(Resolved ? $" -> {ResolvedVersion}" : "")} - ({Requirement} ! {Conflicts}) {(Has ? " Already have" : "")}"; return $"{Name}@{Version}{(Resolved ? $" -> {ResolvedVersion}" : "")} - ({Requirement} ! {Conflicts}) {(Has ? " Already have" : "")}";
@ -121,7 +123,7 @@ namespace IPA.Updating.BeatMods
} }
private static readonly Dictionary<string, ApiEndpoint.Mod> modCache = new Dictionary<string, ApiEndpoint.Mod>(); private static readonly Dictionary<string, ApiEndpoint.Mod> modCache = new Dictionary<string, ApiEndpoint.Mod>();
private static IEnumerator GetModInfo(string modName, string ver, Ref<ApiEndpoint.Mod> result)
internal static IEnumerator GetModInfo(string modName, string ver, Ref<ApiEndpoint.Mod> result)
{ {
var uri = string.Format(ApiEndpoint.GetModInfoEndpoint, Uri.EscapeUriString(modName), Uri.EscapeUriString(ver)); var uri = string.Format(ApiEndpoint.GetModInfoEndpoint, Uri.EscapeUriString(modName), Uri.EscapeUriString(ver));
@ -149,7 +151,7 @@ namespace IPA.Updating.BeatMods
} }
private static readonly Dictionary<string, List<ApiEndpoint.Mod>> modVersionsCache = new Dictionary<string, List<ApiEndpoint.Mod>>(); private static readonly Dictionary<string, List<ApiEndpoint.Mod>> modVersionsCache = new Dictionary<string, List<ApiEndpoint.Mod>>();
private static IEnumerator GetModVersionsMatching(string modName, Range range, Ref<List<ApiEndpoint.Mod>> result)
internal static IEnumerator GetModVersionsMatching(string modName, Range range, Ref<List<ApiEndpoint.Mod>> result)
{ {
var uri = string.Format(ApiEndpoint.GetModsByName, Uri.EscapeUriString(modName)); var uri = string.Format(ApiEndpoint.GetModsByName, Uri.EscapeUriString(modName));
@ -182,7 +184,6 @@ namespace IPA.Updating.BeatMods
var depList = new Ref<List<DependencyObject>>(new List<DependencyObject>()); var depList = new Ref<List<DependencyObject>>(new List<DependencyObject>());
foreach (var plugin in BSMetas) foreach (var plugin in BSMetas)
//.Where(m => m.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) == null))
{ // initialize with data to resolve (1.1) { // initialize with data to resolve (1.1)
if (plugin.Metadata.Id != null) if (plugin.Metadata.Id != null)
{ // updatable { // updatable
@ -205,7 +206,6 @@ namespace IPA.Updating.BeatMods
} }
foreach (var meta in PluginLoader.ignoredPlugins.Where(m => m.Id != null)) foreach (var meta in PluginLoader.ignoredPlugins.Where(m => m.Id != null))
//.Where(m => m.Features.FirstOrDefault(f => f is NoUpdateFeature) == null))
{ {
if (meta.Id != null) if (meta.Id != null)
{ // updatable { // updatable
@ -230,6 +230,31 @@ namespace IPA.Updating.BeatMods
} }
} }
#pragma warning disable CS0618 // Type or member is obsolete
foreach (var plug in Plugins)
{ // throw these in the updater on the off chance that they are set up properly
try
{
var dep = new DependencyObject
{
Name = plug.Name,
Version = new Version(plug.Version),
Requirement = new Range($">={plug.Version}"),
IsLegacy = true,
LocalPluginMeta = null
};
depList.Value.Add(dep);
}
catch (Exception e)
{
Logger.updater.Warn($"Error trying to add legacy plugin {plug.Name} to updater");
Logger.updater.Warn(e);
}
}
#pragma warning restore CS0618 // Type or member is obsolete
foreach (var dep in depList.Value) foreach (var dep in depList.Value)
Logger.updater.Debug($"Phantom Dependency: {dep}"); Logger.updater.Debug($"Phantom Dependency: {dep}");


BIN
Refs/Assembly-CSharp.dll View File


BIN
Refs/UnityEngine.CoreModule.dll View File


+ 0
- 37605
Refs/UnityEngine.CoreModule.xml
File diff suppressed because it is too large
View File


Loading…
Cancel
Save