mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-21 07:17:53 +01:00
Add shared tag system for tagging individual mods
Adds a new system of shared tags that are saved in the Penumbra config, and can then be 1-click added or removed to/from mods via a popup menu. The use case for this new system is to allow users to more easily re-use tags and to allow them to quickly tag individual mods. Shared tags can be added/removed/modified via a new Tags section of the main Penumbra Settings tab. Once any shared tags have been saved, they can be added via a new tags button that shows up in the Description and Edit Mod tabs, to the right of the existing + button that already existed for typing in new tags. Shared tags have the same restrictions as regular mod tags, and the application of shared tags should respect the same limits as application of normal tags. Signed-off-by: AeAstralis <causal_inverse@fastmail.com>
This commit is contained in:
parent
0220257efa
commit
7128326ab9
7 changed files with 248 additions and 6 deletions
|
|
@ -12,14 +12,16 @@ public class ModPanelDescriptionTab : ITab
|
|||
private readonly ModFileSystemSelector _selector;
|
||||
private readonly TutorialService _tutorial;
|
||||
private readonly ModManager _modManager;
|
||||
private readonly SharedTagManager _sharedTagManager;
|
||||
private readonly TagButtons _localTags = new();
|
||||
private readonly TagButtons _modTags = new();
|
||||
|
||||
public ModPanelDescriptionTab(ModFileSystemSelector selector, TutorialService tutorial, ModManager modManager)
|
||||
public ModPanelDescriptionTab(ModFileSystemSelector selector, TutorialService tutorial, ModManager modManager, SharedTagManager sharedTagsConfig)
|
||||
{
|
||||
_selector = selector;
|
||||
_tutorial = tutorial;
|
||||
_modManager = modManager;
|
||||
_sharedTagManager = sharedTagsConfig;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> Label
|
||||
|
|
@ -34,14 +36,37 @@ public class ModPanelDescriptionTab : ITab
|
|||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(2));
|
||||
|
||||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(2));
|
||||
var sharedTagsEnabled = _sharedTagManager.SharedTags.Count() > 0;
|
||||
var sharedTagButtonOffset = sharedTagsEnabled ? ImGui.GetFrameHeight() + ImGui.GetStyle().FramePadding.X : 0;
|
||||
var tagIdx = _localTags.Draw("Local Tags: ",
|
||||
"Custom tags you can set personally that will not be exported to the mod data but only set for you.\n"
|
||||
+ "If the mod already contains a local tag in its own tags, the local tag will be ignored.", _selector.Selected!.LocalTags,
|
||||
out var editedTag);
|
||||
out var editedTag, rightEndOffset: sharedTagButtonOffset);
|
||||
_tutorial.OpenTutorial(BasicTutorialSteps.Tags);
|
||||
if (tagIdx >= 0)
|
||||
_modManager.DataEditor.ChangeLocalTag(_selector.Selected!, tagIdx, editedTag);
|
||||
|
||||
if (sharedTagsEnabled)
|
||||
{
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetFrameHeightWithSpacing());
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowWidth() - ImGui.GetFrameHeight() - ImGui.GetStyle().FramePadding.X);
|
||||
var sharedTag = _sharedTagManager.DrawAddFromSharedTags(_selector.Selected!.LocalTags, _selector.Selected!.ModTags, true);
|
||||
if (sharedTag.Length > 0)
|
||||
{
|
||||
var index = _selector.Selected!.LocalTags.IndexOf(sharedTag);
|
||||
if (index < 0)
|
||||
{
|
||||
index = _selector.Selected!.LocalTags.Count;
|
||||
_modManager.DataEditor.ChangeLocalTag(_selector.Selected, index, sharedTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
_modManager.DataEditor.ChangeLocalTag(_selector.Selected, index, string.Empty);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (_selector.Selected!.ModTags.Count > 0)
|
||||
_modTags.Draw("Mod Tags: ", "Tags assigned by the mod creator and saved with the mod data. To edit these, look at Edit Mod.",
|
||||
_selector.Selected!.ModTags, out var _, false,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class ModPanelEditTab : ITab
|
|||
private readonly ModEditWindow _editWindow;
|
||||
private readonly ModEditor _editor;
|
||||
private readonly Configuration _config;
|
||||
private readonly SharedTagManager _sharedTagManager;
|
||||
|
||||
private readonly TagButtons _modTags = new();
|
||||
|
||||
|
|
@ -37,7 +38,8 @@ public class ModPanelEditTab : ITab
|
|||
private Mod _mod = null!;
|
||||
|
||||
public ModPanelEditTab(ModManager modManager, ModFileSystemSelector selector, ModFileSystem fileSystem, Services.MessageService messager,
|
||||
ModEditWindow editWindow, ModEditor editor, FilenameService filenames, ModExportManager modExportManager, Configuration config)
|
||||
ModEditWindow editWindow, ModEditor editor, FilenameService filenames, ModExportManager modExportManager, Configuration config,
|
||||
SharedTagManager sharedTagManager)
|
||||
{
|
||||
_modManager = modManager;
|
||||
_selector = selector;
|
||||
|
|
@ -48,6 +50,7 @@ public class ModPanelEditTab : ITab
|
|||
_filenames = filenames;
|
||||
_modExportManager = modExportManager;
|
||||
_config = config;
|
||||
_sharedTagManager = sharedTagManager;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> Label
|
||||
|
|
@ -80,11 +83,34 @@ public class ModPanelEditTab : ITab
|
|||
}
|
||||
|
||||
UiHelpers.DefaultLineSpace();
|
||||
var sharedTagsEnabled = _sharedTagManager.SharedTags.Count() > 0;
|
||||
var sharedTagButtonOffset = sharedTagsEnabled ? ImGui.GetFrameHeight() + ImGui.GetStyle().FramePadding.X : 0;
|
||||
var tagIdx = _modTags.Draw("Mod Tags: ", "Edit tags by clicking them, or add new tags. Empty tags are removed.", _mod.ModTags,
|
||||
out var editedTag);
|
||||
out var editedTag, rightEndOffset: sharedTagButtonOffset);
|
||||
if (tagIdx >= 0)
|
||||
_modManager.DataEditor.ChangeModTag(_mod, tagIdx, editedTag);
|
||||
|
||||
if (sharedTagsEnabled)
|
||||
{
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetFrameHeightWithSpacing());
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowWidth() - ImGui.GetFrameHeight() - ImGui.GetStyle().FramePadding.X);
|
||||
var sharedTag = _sharedTagManager.DrawAddFromSharedTags(_selector.Selected!.LocalTags, _selector.Selected!.ModTags, false);
|
||||
if (sharedTag.Length > 0)
|
||||
{
|
||||
var index = _selector.Selected!.ModTags.IndexOf(sharedTag);
|
||||
if (index < 0)
|
||||
{
|
||||
index = _selector.Selected!.ModTags.Count;
|
||||
_modManager.DataEditor.ChangeModTag(_selector.Selected, index, sharedTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
_modManager.DataEditor.ChangeModTag(_selector.Selected, index, string.Empty);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
UiHelpers.DefaultLineSpace();
|
||||
AddOptionGroup.Draw(_filenames, _modManager, _mod, _config.ReplaceNonAsciiOnImport);
|
||||
UiHelpers.DefaultLineSpace();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue