mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 21:24:18 +01:00
Rename to Predefined.
This commit is contained in:
parent
b725d919bb
commit
038c230427
7 changed files with 102 additions and 132 deletions
|
|
@ -14,7 +14,7 @@ public class FilenameService(DalamudPluginInterface pi) : IService
|
|||
public readonly string EphemeralConfigFile = Path.Combine(pi.ConfigDirectory.FullName, "ephemeral_config.json");
|
||||
public readonly string FilesystemFile = Path.Combine(pi.ConfigDirectory.FullName, "sort_order.json");
|
||||
public readonly string ActiveCollectionsFile = Path.Combine(pi.ConfigDirectory.FullName, "active_collections.json");
|
||||
public readonly string SharedTagFile = Path.Combine(pi.ConfigDirectory.FullName, "shared_tags.json");
|
||||
public readonly string PredefinedTagFile = Path.Combine(pi.ConfigDirectory.FullName, "predefined_tags.json");
|
||||
|
||||
public readonly string CrashHandlerExe =
|
||||
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Penumbra.CrashHandler.exe");
|
||||
|
|
@ -44,7 +44,7 @@ public class FilenameService(DalamudPluginInterface pi) : IService
|
|||
get
|
||||
{
|
||||
var directory = new DirectoryInfo(CollectionDirectory);
|
||||
return directory.Exists ? directory.EnumerateFiles("*.json") : Array.Empty<FileInfo>();
|
||||
return directory.Exists ? directory.EnumerateFiles("*.json") : [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ public class FilenameService(DalamudPluginInterface pi) : IService
|
|||
get
|
||||
{
|
||||
var directory = new DirectoryInfo(LocalDataDirectory);
|
||||
return directory.Exists ? directory.EnumerateFiles("*.json") : Array.Empty<FileInfo>();
|
||||
return directory.Exists ? directory.EnumerateFiles("*.json") : [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public static class ServiceManagerA
|
|||
private static ServiceManager AddConfiguration(this ServiceManager services)
|
||||
=> services.AddSingleton<Configuration>()
|
||||
.AddSingleton<EphemeralConfig>()
|
||||
.AddSingleton<SharedTagManager>();
|
||||
.AddSingleton<PredefinedTagManager>();
|
||||
|
||||
private static ServiceManager AddCollections(this ServiceManager services)
|
||||
=> services.AddSingleton<CollectionStorage>()
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ public enum ColorId
|
|||
ResTreePlayer,
|
||||
ResTreeNetworked,
|
||||
ResTreeNonNetworked,
|
||||
SharedTagAdd,
|
||||
SharedTagRemove
|
||||
PredefinedTagAdd,
|
||||
PredefinedTagRemove,
|
||||
}
|
||||
|
||||
public static class Colors
|
||||
|
|
@ -75,8 +75,8 @@ public static class Colors
|
|||
ColorId.ResTreePlayer => ( 0xFFC0FFC0, "On-Screen: Other Players", "Other players and what they own, in the On-Screen tab." ),
|
||||
ColorId.ResTreeNetworked => ( 0xFFFFFFFF, "On-Screen: Non-Players (Networked)", "Non-player entities handled by the game server, in the On-Screen tab." ),
|
||||
ColorId.ResTreeNonNetworked => ( 0xFFC0C0FF, "On-Screen: Non-Players (Local)", "Non-player entities handled locally, in the On-Screen tab." ),
|
||||
ColorId.SharedTagAdd => ( 0xFF44AA44, "Shared Tags: Add Tag", "A shared tag that is not present on the current mod and can be added." ),
|
||||
ColorId.SharedTagRemove => ( 0xFF2222AA, "Shared Tags: Remove Tag", "A shared tag that is already present on the current mod and can be removed." ),
|
||||
ColorId.PredefinedTagAdd => ( 0xFF44AA44, "Predefined Tags: Add Tag", "A predefined tag that is not present on the current mod and can be added." ),
|
||||
ColorId.PredefinedTagRemove => ( 0xFF2222AA, "Predefined Tags: Remove Tag", "A predefined tag that is already present on the current mod and can be removed." ),
|
||||
_ => throw new ArgumentOutOfRangeException( nameof( color ), color, null ),
|
||||
// @formatter:on
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,23 +7,16 @@ using Penumbra.Mods.Manager;
|
|||
|
||||
namespace Penumbra.UI.ModsTab;
|
||||
|
||||
public class ModPanelDescriptionTab : ITab
|
||||
public class ModPanelDescriptionTab(
|
||||
ModFileSystemSelector selector,
|
||||
TutorialService tutorial,
|
||||
ModManager modManager,
|
||||
PredefinedTagManager predefinedTagsConfig)
|
||||
: 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, SharedTagManager sharedTagsConfig)
|
||||
{
|
||||
_selector = selector;
|
||||
_tutorial = tutorial;
|
||||
_modManager = modManager;
|
||||
_sharedTagManager = sharedTagsConfig;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> Label
|
||||
=> "Description"u8;
|
||||
|
||||
|
|
@ -36,29 +29,28 @@ public class ModPanelDescriptionTab : ITab
|
|||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(2));
|
||||
|
||||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(2));
|
||||
var sharedTagsEnabled = _sharedTagManager.SharedTags.Count > 0;
|
||||
var sharedTagsEnabled = predefinedTagsConfig.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,
|
||||
+ "If the mod already contains a local tag in its own tags, the local tag will be ignored.", selector.Selected!.LocalTags,
|
||||
out var editedTag, rightEndOffset: sharedTagButtonOffset);
|
||||
_tutorial.OpenTutorial(BasicTutorialSteps.Tags);
|
||||
tutorial.OpenTutorial(BasicTutorialSteps.Tags);
|
||||
if (tagIdx >= 0)
|
||||
_modManager.DataEditor.ChangeLocalTag(_selector.Selected!, tagIdx, editedTag);
|
||||
modManager.DataEditor.ChangeLocalTag(selector.Selected!, tagIdx, editedTag);
|
||||
|
||||
if (sharedTagsEnabled)
|
||||
{
|
||||
_sharedTagManager.DrawAddFromSharedTagsAndUpdateTags(_selector.Selected!.LocalTags, _selector.Selected!.ModTags, true, _selector.Selected!);
|
||||
}
|
||||
predefinedTagsConfig.DrawAddFromSharedTagsAndUpdateTags(selector.Selected!.LocalTags, selector.Selected!.ModTags, true,
|
||||
selector.Selected!);
|
||||
|
||||
if (_selector.Selected!.ModTags.Count > 0)
|
||||
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,
|
||||
selector.Selected!.ModTags, out _, false,
|
||||
ImGui.CalcTextSize("Local ").X - ImGui.CalcTextSize("Mod ").X);
|
||||
|
||||
ImGui.Dummy(ImGuiHelpers.ScaledVector2(2));
|
||||
ImGui.Separator();
|
||||
|
||||
ImGuiUtil.TextWrapped(_selector.Selected!.Description);
|
||||
ImGuiUtil.TextWrapped(selector.Selected!.Description);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,18 +17,20 @@ using Penumbra.UI.AdvancedWindow;
|
|||
|
||||
namespace Penumbra.UI.ModsTab;
|
||||
|
||||
public class ModPanelEditTab : ITab
|
||||
public class ModPanelEditTab(
|
||||
ModManager modManager,
|
||||
ModFileSystemSelector selector,
|
||||
ModFileSystem fileSystem,
|
||||
Services.MessageService messager,
|
||||
ModEditWindow editWindow,
|
||||
ModEditor editor,
|
||||
FilenameService filenames,
|
||||
ModExportManager modExportManager,
|
||||
Configuration config,
|
||||
PredefinedTagManager predefinedTagManager)
|
||||
: ITab
|
||||
{
|
||||
private readonly Services.MessageService _messager;
|
||||
private readonly FilenameService _filenames;
|
||||
private readonly ModManager _modManager;
|
||||
private readonly ModExportManager _modExportManager;
|
||||
private readonly ModFileSystem _fileSystem;
|
||||
private readonly ModFileSystemSelector _selector;
|
||||
private readonly ModEditWindow _editWindow;
|
||||
private readonly ModEditor _editor;
|
||||
private readonly Configuration _config;
|
||||
private readonly SharedTagManager _sharedTagManager;
|
||||
private readonly ModManager _modManager = modManager;
|
||||
|
||||
private readonly TagButtons _modTags = new();
|
||||
|
||||
|
|
@ -37,22 +39,6 @@ public class ModPanelEditTab : ITab
|
|||
private ModFileSystem.Leaf _leaf = null!;
|
||||
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,
|
||||
SharedTagManager sharedTagManager)
|
||||
{
|
||||
_modManager = modManager;
|
||||
_selector = selector;
|
||||
_fileSystem = fileSystem;
|
||||
_messager = messager;
|
||||
_editWindow = editWindow;
|
||||
_editor = editor;
|
||||
_filenames = filenames;
|
||||
_modExportManager = modExportManager;
|
||||
_config = config;
|
||||
_sharedTagManager = sharedTagManager;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<byte> Label
|
||||
=> "Edit Mod"u8;
|
||||
|
||||
|
|
@ -62,8 +48,8 @@ public class ModPanelEditTab : ITab
|
|||
if (!child)
|
||||
return;
|
||||
|
||||
_leaf = _selector.SelectedLeaf!;
|
||||
_mod = _selector.Selected!;
|
||||
_leaf = selector.SelectedLeaf!;
|
||||
_mod = selector.Selected!;
|
||||
|
||||
_cellPadding = ImGui.GetStyle().CellPadding with { X = 2 * UiHelpers.Scale };
|
||||
_itemSpacing = ImGui.GetStyle().CellPadding with { X = 4 * UiHelpers.Scale };
|
||||
|
|
@ -75,15 +61,15 @@ public class ModPanelEditTab : ITab
|
|||
if (Input.Text("Mod Path", Input.Path, Input.None, _leaf.FullName(), out var newPath, 256, UiHelpers.InputTextWidth.X))
|
||||
try
|
||||
{
|
||||
_fileSystem.RenameAndMove(_leaf, newPath);
|
||||
fileSystem.RenameAndMove(_leaf, newPath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_messager.NotificationMessage(e.Message, NotificationType.Warning, false);
|
||||
messager.NotificationMessage(e.Message, NotificationType.Warning, false);
|
||||
}
|
||||
|
||||
UiHelpers.DefaultLineSpace();
|
||||
var sharedTagsEnabled = _sharedTagManager.SharedTags.Count > 0;
|
||||
var sharedTagsEnabled = predefinedTagManager.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, rightEndOffset: sharedTagButtonOffset);
|
||||
|
|
@ -91,12 +77,11 @@ public class ModPanelEditTab : ITab
|
|||
_modManager.DataEditor.ChangeModTag(_mod, tagIdx, editedTag);
|
||||
|
||||
if (sharedTagsEnabled)
|
||||
{
|
||||
_sharedTagManager.DrawAddFromSharedTagsAndUpdateTags(_selector.Selected!.LocalTags, _selector.Selected!.ModTags, false, _selector.Selected!);
|
||||
}
|
||||
predefinedTagManager.DrawAddFromSharedTagsAndUpdateTags(selector.Selected!.LocalTags, selector.Selected!.ModTags, false,
|
||||
selector.Selected!);
|
||||
|
||||
UiHelpers.DefaultLineSpace();
|
||||
AddOptionGroup.Draw(_filenames, _modManager, _mod, _config.ReplaceNonAsciiOnImport);
|
||||
AddOptionGroup.Draw(filenames, _modManager, _mod, config.ReplaceNonAsciiOnImport);
|
||||
UiHelpers.DefaultLineSpace();
|
||||
|
||||
for (var groupIdx = 0; groupIdx < _mod.Groups.Count; ++groupIdx)
|
||||
|
|
@ -144,11 +129,11 @@ public class ModPanelEditTab : ITab
|
|||
{
|
||||
if (ImGui.Button("Update Bibo Material", buttonSize))
|
||||
{
|
||||
_editor.LoadMod(_mod);
|
||||
_editor.MdlMaterialEditor.ReplaceAllMaterials("bibo", "b");
|
||||
_editor.MdlMaterialEditor.ReplaceAllMaterials("bibopube", "c");
|
||||
_editor.MdlMaterialEditor.SaveAllModels(_editor.Compactor);
|
||||
_editWindow.UpdateModels();
|
||||
editor.LoadMod(_mod);
|
||||
editor.MdlMaterialEditor.ReplaceAllMaterials("bibo", "b");
|
||||
editor.MdlMaterialEditor.ReplaceAllMaterials("bibopube", "c");
|
||||
editor.MdlMaterialEditor.SaveAllModels(editor.Compactor);
|
||||
editWindow.UpdateModels();
|
||||
}
|
||||
|
||||
ImGuiUtil.HoverTooltip(
|
||||
|
|
@ -160,7 +145,7 @@ public class ModPanelEditTab : ITab
|
|||
|
||||
private void BackupButtons(Vector2 buttonSize)
|
||||
{
|
||||
var backup = new ModBackup(_modExportManager, _mod);
|
||||
var backup = new ModBackup(modExportManager, _mod);
|
||||
var tt = ModBackup.CreatingBackup
|
||||
? "Already exporting a mod."
|
||||
: backup.Exists
|
||||
|
|
@ -171,16 +156,16 @@ public class ModPanelEditTab : ITab
|
|||
|
||||
ImGui.SameLine();
|
||||
tt = backup.Exists
|
||||
? $"Delete existing mod export \"{backup.Name}\" (hold {_config.DeleteModModifier} while clicking)."
|
||||
? $"Delete existing mod export \"{backup.Name}\" (hold {config.DeleteModModifier} while clicking)."
|
||||
: $"Exported mod \"{backup.Name}\" does not exist.";
|
||||
if (ImGuiUtil.DrawDisabledButton("Delete Export", buttonSize, tt, !backup.Exists || !_config.DeleteModModifier.IsActive()))
|
||||
if (ImGuiUtil.DrawDisabledButton("Delete Export", buttonSize, tt, !backup.Exists || !config.DeleteModModifier.IsActive()))
|
||||
backup.Delete();
|
||||
|
||||
tt = backup.Exists
|
||||
? $"Restore mod from exported file \"{backup.Name}\" (hold {_config.DeleteModModifier} while clicking)."
|
||||
? $"Restore mod from exported file \"{backup.Name}\" (hold {config.DeleteModModifier} while clicking)."
|
||||
: $"Exported mod \"{backup.Name}\" does not exist.";
|
||||
ImGui.SameLine();
|
||||
if (ImGuiUtil.DrawDisabledButton("Restore From Export", buttonSize, tt, !backup.Exists || !_config.DeleteModModifier.IsActive()))
|
||||
if (ImGuiUtil.DrawDisabledButton("Restore From Export", buttonSize, tt, !backup.Exists || !config.DeleteModModifier.IsActive()))
|
||||
backup.Restore(_modManager);
|
||||
if (backup.Exists)
|
||||
{
|
||||
|
|
@ -218,13 +203,13 @@ public class ModPanelEditTab : ITab
|
|||
_delayedActions.Enqueue(() => DescriptionEdit.OpenPopup(_mod, Input.Description));
|
||||
|
||||
ImGui.SameLine();
|
||||
var fileExists = File.Exists(_filenames.ModMetaPath(_mod));
|
||||
var fileExists = File.Exists(filenames.ModMetaPath(_mod));
|
||||
var tt = fileExists
|
||||
? "Open the metadata json file in the text editor of your choice."
|
||||
: "The metadata json file does not exist.";
|
||||
if (ImGuiUtil.DrawDisabledButton($"{FontAwesomeIcon.FileExport.ToIconString()}##metaFile", UiHelpers.IconButtonSize, tt,
|
||||
!fileExists, true))
|
||||
Process.Start(new ProcessStartInfo(_filenames.ModMetaPath(_mod)) { UseShellExecute = true });
|
||||
Process.Start(new ProcessStartInfo(filenames.ModMetaPath(_mod)) { UseShellExecute = true });
|
||||
}
|
||||
|
||||
/// <summary> Do some edits outside of iterations. </summary>
|
||||
|
|
@ -448,7 +433,7 @@ public class ModPanelEditTab : ITab
|
|||
_delayedActions.Enqueue(() => DescriptionEdit.OpenPopup(_mod, groupIdx));
|
||||
|
||||
ImGui.SameLine();
|
||||
var fileName = _filenames.OptionGroupFile(_mod, groupIdx, _config.ReplaceNonAsciiOnImport);
|
||||
var fileName = filenames.OptionGroupFile(_mod, groupIdx, config.ReplaceNonAsciiOnImport);
|
||||
var fileExists = File.Exists(fileName);
|
||||
tt = fileExists
|
||||
? $"Open the {group.Name} json file in the text editor of your choice."
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
using Newtonsoft.Json;
|
||||
using OtterGui;
|
||||
|
|
@ -12,13 +11,14 @@ using Penumbra.UI.Classes;
|
|||
using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
public sealed class SharedTagManager : ISavable
|
||||
|
||||
public sealed class PredefinedTagManager : ISavable
|
||||
{
|
||||
private readonly ModManager _modManager;
|
||||
private readonly SaveService _saveService;
|
||||
|
||||
private static uint _tagButtonAddColor = ColorId.SharedTagAdd.Value();
|
||||
private static uint _tagButtonRemoveColor = ColorId.SharedTagRemove.Value();
|
||||
private static uint _tagButtonAddColor = ColorId.PredefinedTagAdd.Value();
|
||||
private static uint _tagButtonRemoveColor = ColorId.PredefinedTagRemove.Value();
|
||||
|
||||
private static float _minTagButtonWidth = 15;
|
||||
|
||||
|
|
@ -29,12 +29,14 @@ public sealed class SharedTagManager : ISavable
|
|||
// The list also gets re-sorted when first loaded from config in case the config was modified.
|
||||
[JsonRequired]
|
||||
private readonly List<string> _sharedTags = [];
|
||||
|
||||
[JsonIgnore]
|
||||
public IReadOnlyList<string> SharedTags => _sharedTags;
|
||||
public IReadOnlyList<string> SharedTags
|
||||
=> _sharedTags;
|
||||
|
||||
public int ConfigVersion = 1;
|
||||
|
||||
public SharedTagManager(ModManager modManager, SaveService saveService)
|
||||
public PredefinedTagManager(ModManager modManager, SaveService saveService)
|
||||
{
|
||||
_modManager = modManager;
|
||||
_saveService = saveService;
|
||||
|
|
@ -42,9 +44,7 @@ public sealed class SharedTagManager : ISavable
|
|||
}
|
||||
|
||||
public string ToFilename(FilenameService fileNames)
|
||||
{
|
||||
return fileNames.SharedTagFile;
|
||||
}
|
||||
=> fileNames.PredefinedTagFile;
|
||||
|
||||
public void Save(StreamWriter writer)
|
||||
{
|
||||
|
|
@ -65,12 +65,12 @@ public sealed class SharedTagManager : ISavable
|
|||
errorArgs.ErrorContext.Handled = true;
|
||||
}
|
||||
|
||||
if (!File.Exists(_saveService.FileNames.SharedTagFile))
|
||||
if (!File.Exists(_saveService.FileNames.PredefinedTagFile))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var text = File.ReadAllText(_saveService.FileNames.SharedTagFile);
|
||||
var text = File.ReadAllText(_saveService.FileNames.PredefinedTagFile);
|
||||
JsonConvert.PopulateObject(text, this, new JsonSerializerSettings
|
||||
{
|
||||
Error = HandleDeserializationError,
|
||||
|
|
@ -94,9 +94,7 @@ public sealed class SharedTagManager : ISavable
|
|||
|
||||
// In the case of editing a tag, remove what's there prior to doing an insert.
|
||||
if (tagIdx != SharedTags.Count)
|
||||
{
|
||||
_sharedTags.RemoveAt(tagIdx);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(tag))
|
||||
{
|
||||
|
|
@ -109,7 +107,8 @@ public sealed class SharedTagManager : ISavable
|
|||
Save();
|
||||
}
|
||||
|
||||
public void DrawAddFromSharedTagsAndUpdateTags(IReadOnlyCollection<string> localTags, IReadOnlyCollection<string> modTags, bool editLocal, Mods.Mod mod)
|
||||
public void DrawAddFromSharedTagsAndUpdateTags(IReadOnlyCollection<string> localTags, IReadOnlyCollection<string> modTags, bool editLocal,
|
||||
Mods.Mod mod)
|
||||
{
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetFrameHeightWithSpacing());
|
||||
ImGui.SetCursorPosX(ImGui.GetWindowWidth() - ImGui.GetFrameHeight() - ImGui.GetStyle().FramePadding.X);
|
||||
|
|
@ -131,7 +130,8 @@ public sealed class SharedTagManager : ISavable
|
|||
{
|
||||
_modManager.DataEditor.ChangeLocalTag(mod, index, string.Empty);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
|
|
@ -143,15 +143,16 @@ public sealed class SharedTagManager : ISavable
|
|||
_modManager.DataEditor.ChangeModTag(mod, index, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public string DrawAddFromSharedTags(IReadOnlyCollection<string> localTags, IReadOnlyCollection<string> modTags, bool editLocal)
|
||||
{
|
||||
var tagToAdd = string.Empty;
|
||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Tags.ToIconString(), new Vector2(ImGui.GetFrameHeight()), "Add Shared Tag... (Right-click to close popup)",
|
||||
false, true) || _isPopupOpen)
|
||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Tags.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||
"Add Shared Tag... (Right-click to close popup)",
|
||||
false, true)
|
||||
|| _isPopupOpen)
|
||||
return DrawSharedTagsPopup(localTags, modTags, editLocal);
|
||||
|
||||
return tagToAdd;
|
||||
|
|
@ -182,21 +183,18 @@ public sealed class SharedTagManager : ISavable
|
|||
foreach (var (tag, idx) in SharedTags.WithIndex())
|
||||
{
|
||||
if (DrawColoredButton(localTags, modTags, tag, editLocal, idx))
|
||||
{
|
||||
selected = tag;
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
if (ImGui.IsMouseClicked(ImGuiMouseButton.Right))
|
||||
{
|
||||
_isPopupOpen = false;
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
private static bool DrawColoredButton(IReadOnlyCollection<string> localTags, IReadOnlyCollection<string> modTags, string buttonLabel, bool editLocal, int index)
|
||||
private static bool DrawColoredButton(IReadOnlyCollection<string> localTags, IReadOnlyCollection<string> modTags, string buttonLabel,
|
||||
bool editLocal, int index)
|
||||
{
|
||||
var ret = false;
|
||||
|
||||
|
|
@ -247,9 +245,8 @@ public sealed class SharedTagManager : ISavable
|
|||
|
||||
// An ellipsis will be used to indicate trimmed tags
|
||||
if (CalcTextButtonWidth(nextTrim + "...") < maxWidth)
|
||||
{
|
||||
return nextTrim + "...";
|
||||
}
|
||||
|
||||
trimmedText = nextTrim;
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +254,5 @@ public sealed class SharedTagManager : ISavable
|
|||
}
|
||||
|
||||
private static float CalcTextButtonWidth(string text)
|
||||
{
|
||||
return ImGui.CalcTextSize(text).X + 2 * ImGui.GetStyle().FramePadding.X;
|
||||
}
|
||||
=> ImGui.CalcTextSize(text).X + 2 * ImGui.GetStyle().FramePadding.X;
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class SettingsTab : ITab
|
|||
private readonly DalamudConfigService _dalamudConfig;
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly IDataManager _gameData;
|
||||
private readonly SharedTagManager _sharedTagManager;
|
||||
private readonly PredefinedTagManager _predefinedTagManager;
|
||||
|
||||
private int _minimumX = int.MaxValue;
|
||||
private int _minimumY = int.MaxValue;
|
||||
|
|
@ -53,7 +53,7 @@ public class SettingsTab : ITab
|
|||
Penumbra penumbra, FileDialogService fileDialog, ModManager modManager, ModFileSystemSelector selector,
|
||||
CharacterUtility characterUtility, ResidentResourceManager residentResources, ModExportManager modExportManager, HttpApi httpApi,
|
||||
DalamudSubstitutionProvider dalamudSubstitutionProvider, FileCompactor compactor, DalamudConfigService dalamudConfig,
|
||||
IDataManager gameData, SharedTagManager sharedTagConfig)
|
||||
IDataManager gameData, PredefinedTagManager predefinedTagConfig)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
_config = config;
|
||||
|
|
@ -73,7 +73,7 @@ public class SettingsTab : ITab
|
|||
_gameData = gameData;
|
||||
if (_compactor.CanCompact)
|
||||
_compactor.Enabled = _config.UseFileSystemCompression;
|
||||
_sharedTagManager = sharedTagConfig;
|
||||
_predefinedTagManager = predefinedTagConfig;
|
||||
}
|
||||
|
||||
public void DrawHeader()
|
||||
|
|
@ -101,7 +101,7 @@ public class SettingsTab : ITab
|
|||
DrawGeneralSettings();
|
||||
DrawColorSettings();
|
||||
DrawAdvancedSettings();
|
||||
DrawSharedTagsSection();
|
||||
DrawPredefinedTagsSection();
|
||||
DrawSupportButtons();
|
||||
}
|
||||
|
||||
|
|
@ -917,18 +917,16 @@ public class SettingsTab : ITab
|
|||
_penumbra.ForceChangelogOpen();
|
||||
}
|
||||
|
||||
private void DrawSharedTagsSection()
|
||||
private void DrawPredefinedTagsSection()
|
||||
{
|
||||
if (!ImGui.CollapsingHeader("Tags"))
|
||||
return;
|
||||
|
||||
var tagIdx = _sharedTags.Draw("Shared Tags: ",
|
||||
"Predefined tags that can be added or removed from mods with a single click.", _sharedTagManager.SharedTags,
|
||||
var tagIdx = _sharedTags.Draw("Predefined Tags: ",
|
||||
"Predefined tags that can be added or removed from mods with a single click.", _predefinedTagManager.SharedTags,
|
||||
out var editedTag);
|
||||
|
||||
if (tagIdx >= 0)
|
||||
{
|
||||
_sharedTagManager.ChangeSharedTag(tagIdx, editedTag);
|
||||
}
|
||||
_predefinedTagManager.ChangeSharedTag(tagIdx, editedTag);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue