Browse Source

Added support for bare manifests

pull/11/head
Anairkoen Schno 5 years ago
parent
commit
2665c0a751
7 changed files with 86 additions and 4 deletions
  1. +3
    -0
      BSIPA-ModList/BSIPA-ModList.csproj
  2. BIN
      BSIPA-ModList/Icons/Thumbs.db
  3. BIN
      BSIPA-ModList/Icons/library.png
  4. +53
    -1
      BSIPA-ModList/UI/ViewControllers/ModListController.cs
  5. +29
    -2
      IPA.Loader/Loader/PluginLoader.cs
  6. +1
    -1
      IPA.Loader/Loader/manifest.json
  7. BIN
      Refs/BeatSaberCustomUI.dll

+ 3
- 0
BSIPA-ModList/BSIPA-ModList.csproj View File

@ -97,6 +97,9 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Icons\self.png" /> <EmbeddedResource Include="Icons\self.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Icons\library.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild"> <Target Name="AfterBuild">
<Message Text="Packing..." Importance="normal" /> <Message Text="Packing..." Importance="normal" />


BIN
BSIPA-ModList/Icons/Thumbs.db View File


BIN
BSIPA-ModList/Icons/library.png View File

Before After
Width: 512  |  Height: 512  |  Size: 35 KiB

+ 53
- 1
BSIPA-ModList/UI/ViewControllers/ModListController.cs View File

@ -118,6 +118,56 @@ namespace BSIPA_ModList.UI
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected); list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
} }
} }
private class LibraryModCell : CustomCellInfo, IClickableCell
{
private static Sprite _defaultIcon;
public static Sprite DefaultIcon
{
get
{
if (_defaultIcon == null)
_defaultIcon = UIUtilities.LoadSpriteFromResources("BSIPA_ModList.Icons.library.png");
return _defaultIcon;
}
}
internal PluginLoader.PluginInfo Plugin;
private ModListController list;
public LibraryModCell(ModListController list, PluginLoader.PluginInfo plugin)
: base($"{plugin.Metadata.Name} <size=60%>v{plugin.Metadata.Version}", plugin.Metadata.Manifest.Author, null)
{
Plugin = plugin;
this.list = list;
if (string.IsNullOrWhiteSpace(subtext))
subtext = "<color=#BFBFBF><i>Unspecified Author</i>";
icon = DefaultIcon;
Logger.log.Debug($"LibraryModCell {plugin.Metadata.Name} {plugin.Metadata.Version}");
}
private ModInfoViewController infoView;
public void OnSelect(ModListController cntrl)
{
Logger.log.Debug($"Selected LibraryModCell {Plugin.Metadata.Name} {Plugin.Metadata.Version}");
if (infoView == null)
{
var desc = Plugin.Metadata.Manifest.Description;
if (string.IsNullOrWhiteSpace(desc))
desc = "<color=#BFBFBF><i>No description</i>";
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);
}
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
}
}
#pragma warning disable CS0618 #pragma warning disable CS0618
private class IPAModCell : CustomCellInfo, IClickableCell private class IPAModCell : CustomCellInfo, IClickableCell
@ -190,10 +240,12 @@ namespace BSIPA_ModList.UI
reuseIdentifier = "BSIPAModListTableCell"; reuseIdentifier = "BSIPAModListTableCell";
foreach (var plugin in bsipaPlugins)
foreach (var plugin in bsipaPlugins.Where(p => !p.Metadata.IsBare))
Data.Add(new BSIPAModCell(this, plugin)); Data.Add(new BSIPAModCell(this, plugin));
foreach (var plugin in ignoredPlugins) foreach (var plugin in ignoredPlugins)
Data.Add(new BSIPAIgnoredModCell(this, plugin)); Data.Add(new BSIPAIgnoredModCell(this, plugin));
foreach (var plugin in bsipaPlugins.Where(p => p.Metadata.IsBare))
Data.Add(new LibraryModCell(this, plugin));
foreach (var plugin in ipaPlugins) foreach (var plugin in ipaPlugins)
Data.Add(new IPAModCell(this, plugin)); Data.Add(new IPAModCell(this, plugin));
} }


+ 29
- 2
IPA.Loader/Loader/PluginLoader.cs View File

@ -71,6 +71,8 @@ namespace IPA.Loader
internal bool IsSelf; internal bool IsSelf;
internal bool IsBare;
private PluginManifest manifest; private PluginManifest manifest;
internal HashSet<PluginMetadata> Dependencies { get; } = new HashSet<PluginMetadata>(); internal HashSet<PluginMetadata> Dependencies { get; } = new HashSet<PluginMetadata>();
@ -212,6 +214,31 @@ namespace IPA.Loader
Logger.loader.Error(e); Logger.loader.Error(e);
} }
} }
IEnumerable<string> bareManifests = Directory.GetFiles(BeatSaber.PluginsPath, "*.json");
bareManifests = bareManifests.Concat(Directory.GetFiles(BeatSaber.PluginsPath, "*.manifest"));
foreach (var manifest in bareManifests)
{
try
{
var metadata = new PluginMetadata
{
File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, manifest)),
IsSelf = false,
IsBare = true,
};
metadata.Manifest = JsonConvert.DeserializeObject<PluginManifest>(File.ReadAllText(manifest));
Logger.loader.Debug($"Adding info for bare manifest {Path.GetFileName(manifest)}");
PluginsMetadata.Add(metadata);
}
catch (Exception e)
{
Logger.loader.Error($"Could not load data for bare manifest {Path.GetFileName(manifest)}");
Logger.loader.Error(e);
}
}
} }
// keep track of these for the updater; it should still be able to update mods not loaded // keep track of these for the updater; it should still be able to update mods not loaded
@ -219,7 +246,7 @@ namespace IPA.Loader
internal static void Resolve() internal static void Resolve()
{ // resolves duplicates and conflicts, etc { // resolves duplicates and conflicts, etc
PluginsMetadata.Sort((a, b) => a.Version.CompareTo(b.Version));
PluginsMetadata.Sort((a, b) => b.Version.CompareTo(a.Version));
var ids = new HashSet<string>(); var ids = new HashSet<string>();
var ignore = new HashSet<PluginMetadata>(); var ignore = new HashSet<PluginMetadata>();
@ -431,7 +458,7 @@ namespace IPA.Loader
internal static void Load(PluginMetadata meta) internal static void Load(PluginMetadata meta)
{ {
if (meta.Assembly == null)
if (meta.Assembly == null && meta.PluginType != null)
meta.Assembly = Assembly.LoadFrom(meta.File.FullName); meta.Assembly = Assembly.LoadFrom(meta.File.FullName);
} }


+ 1
- 1
IPA.Loader/Loader/manifest.json View File

@ -1,5 +1,5 @@
{ {
"$schema": "https://raw.githubusercontent.com/nike4613/ModSaber-MetadataFileSchema/master/Schema.json",
"$schema": "https://raw.githubusercontent.com/beat-saber-modding-group/BSIPA-MetadataFileSchema/master/Schema.json",
"author": "DaNike", "author": "DaNike",
"description": "A mod loader specifically for Beat Saber.", "description": "A mod loader specifically for Beat Saber.",
"gameVersion": "0.13.2", "gameVersion": "0.13.2",


BIN
Refs/BeatSaberCustomUI.dll View File


Loading…
Cancel
Save