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