Browse Source

Added some default text for when something is not provided or avaliable

pull/11/head
Anairkoen Schno 5 years ago
parent
commit
80b212b7ab
2 changed files with 49 additions and 10 deletions
  1. +4
    -5
      BSIPA-ModList/UI/ViewControllers/ModInfoViewController.cs
  2. +45
    -5
      BSIPA-ModList/UI/ViewControllers/ModListController.cs

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

@ -73,7 +73,7 @@ namespace BSIPA_ModList.UI
titleText.fontSize = 6f;
authorText = BeatSaberUI.CreateText(rectTransform, controller.Author, new Vector2(11f, 22f));
authorText.fontSize = 4.5f;
descText = BeatSaberUI.CreateText(rectTransform, controller.Description, new Vector2(-4.5f, 12.5f));
descText = BeatSaberUI.CreateText(rectTransform, controller.Description, new Vector2(-4.5f, 12f));
descText.enableWordWrapping = true;
descText.overflowMode = TextOverflowModes.ScrollRect;
@ -141,7 +141,7 @@ namespace BSIPA_ModList.UI
Logger.log.Debug($"Position now at {rt.anchoredPosition}");
#endif
#if ADJUST_INFO_ICON_UI_KEYS
var rt = icon.rectTransform;
if (Input.GetKey(KeyCode.Z))
{ // adjust anchormin
@ -215,9 +215,8 @@ namespace BSIPA_ModList.UI
Logger.log.Debug($"Position now at {rt.anchoredPosition}");
}
#endif
}
#endif
}
}
}

+ 45
- 5
BSIPA-ModList/UI/ViewControllers/ModListController.cs View File

@ -42,6 +42,9 @@ namespace BSIPA_ModList.UI
Plugin = plugin;
this.list = list;
if (string.IsNullOrWhiteSpace(subtext))
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
@ -58,9 +61,13 @@ namespace BSIPA_ModList.UI
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(), Plugin.Metadata.Manifest.Author,
Plugin.Metadata.Manifest.Description, Plugin.Metadata.Features.FirstOrDefault(f => f is NoUpdateFeature) == null);
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);
@ -72,20 +79,43 @@ namespace BSIPA_ModList.UI
internal PluginLoader.PluginMetadata Plugin;
private ModListController list;
private const string authorFormat = "{0} <color=#BFBFBF>- <i>Not loaded</i>";
private string authorText;
public BSIPAIgnoredModCell(ModListController list, PluginLoader.PluginMetadata plugin)
: base($"<color=#878787>{plugin.Name} <size=60%>v{plugin.Version}", $"{plugin.Manifest.Author} <color=#BFBFBF>- <i>Not loaded</i>", BSIPAModCell.DefaultIcon)
: base($"<color=#878787>{plugin.Name} <size=60%>v{plugin.Version}", "", BSIPAModCell.DefaultIcon)
{
Plugin = plugin;
this.list = list;
if (string.IsNullOrWhiteSpace(plugin.Manifest.Author))
authorText = "<color=#BFBFBF><i>Unspecified Author</i>";
else
authorText = plugin.Manifest.Author;
subtext = string.Format(authorFormat, authorText);
Logger.log.Debug($"BSIPAIgnoredModCell {plugin.Name} {plugin.Version}");
}
private ModInfoViewController infoView;
public void OnSelect(ModListController cntrl)
{
Logger.log.Debug($"Selected BSIPAIgnoredModCell {Plugin.Name} {Plugin.Version}");
list.flow.ClearSelected();
if (infoView == null)
{
var desc = Plugin.Manifest.Description;
if (string.IsNullOrWhiteSpace(desc))
desc = "<color=#BFBFBF><i>No description</i>";
infoView = BeatSaberUI.CreateViewController<ModInfoViewController>();
infoView.Init(icon, Plugin.Name, "v" + Plugin.Version.ToString(), authorText,
desc, Plugin.Features.FirstOrDefault(f => f is NoUpdateFeature) == null);
}
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
}
}
@ -115,11 +145,21 @@ namespace BSIPA_ModList.UI
Logger.log.Debug($"IPAModCell {plugin.Name} {plugin.Version}");
}
private ModInfoViewController infoView;
public void OnSelect(ModListController cntrl)
{
Logger.log.Debug($"Selected IPAModCell {Plugin.Name} {Plugin.Version}");
list.flow.ClearSelected();
if (infoView == null)
{
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);
}
list.flow.SetSelected(infoView, immediate: list.flow.HasSelected);
}
}
#pragma warning restore


Loading…
Cancel
Save