Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: add xiv config ui submodule.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 11, 2024
1 parent 1e839a7 commit 2046c66
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 151 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "XIVConfigUI"]
path = XIVConfigUI
url = https://github.com/ArchiDog1998/XIVConfigUI
16 changes: 16 additions & 0 deletions FakeName.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@ VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeName", "FakeName\FakeName.csproj", "{13C812E9-0D42-4B95-8646-40EEBF30636F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XIVConfigUI", "XIVConfigUI\XIVConfigUI\XIVConfigUI.csproj", "{80A88CF6-CD24-4B87-997C-771342D6E376}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.ActiveCfg = Debug|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.Build.0 = Release|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|Any CPU
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Debug|x64.ActiveCfg = Debug|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Debug|x64.Build.0 = Debug|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Release|Any CPU.Build.0 = Release|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Release|x64.ActiveCfg = Release|Any CPU
{80A88CF6-CD24-4B87-997C-771342D6E376}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
14 changes: 10 additions & 4 deletions FakeName/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using XIVConfigUI;

namespace FakeName;

Expand All @@ -26,12 +27,17 @@ public bool Enabled
}
}

public bool enabled = false;
public bool OnlyInStream = true;
[UI("Enable")]
public bool enabled { get; set; } = false;

public bool AllPlayerReplace = false;
[UI("Only Change in Stream")]
public bool OnlyInStream { get; set; } = true;

public string FakeNameText = "";
[UI("Change All Player's Name")]
public bool AllPlayerReplace { get; set; } = false;

[UI("Character Name")]
public string FakeNameText { get; set; } = Service.ClientState.LocalPlayer?.Name.TextValue ?? string.Empty;

public HashSet<string> CharacterNames = [];
public HashSet<string> FriendList = [];
Expand Down
4 changes: 3 additions & 1 deletion FakeName/FakeName.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Authors>ArchiTed</Authors>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -16,6 +17,8 @@

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" MakeZip="true" />
<ProjectReference Include="..\XIVConfigUI\XIVConfigUI\XIVConfigUI.csproj" />

<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
Expand Down Expand Up @@ -45,5 +48,4 @@
<Private>false</Private>
</Reference>
</ItemGroup>

</Project>
19 changes: 7 additions & 12 deletions FakeName/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Dalamud.Game.Command;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using FakeName.Windows;
using System;
using XIVConfigUI;

namespace FakeName;

Expand All @@ -12,33 +11,29 @@ public class Plugin : IDalamudPlugin

internal WindowManager WindowManager { get; }

public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager)
public Plugin(DalamudPluginInterface pluginInterface)
{
pluginInterface.Create<Service>();
Service.Config = Service.Interface.GetPluginConfig() as Configuration ?? new Configuration();

XIVConfigUIMain.Init(pluginInterface, "ArchiDog1998", "FakeName", "/fakename", "Open a config window about fake name.", OnCommand);

WindowManager = new WindowManager();

Hooker = new Hooker();

Service.CommandManager.AddHandler("/fakename", new CommandInfo(OnCommand)
{
HelpMessage = "Open a config window about fake name.",
});
}

public void Dispose()
{
Service.CommandManager.RemoveHandler("/fakename");

Hooker.Dispose();
WindowManager.Dispose();

XIVConfigUIMain.Dispose();
GC.SuppressFinalize(this);
}

private void OnCommand(string command, string arguments)
private void OnCommand(string arguments)
{
WindowManager.ConfigWindow.Open();
WindowManager.ConfigWindow.Toggle();
}
}
3 changes: 0 additions & 3 deletions FakeName/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ internal class Service
[PluginService]
internal static IClientState ClientState { get; private set; } = null!;

[PluginService]
internal static ICommandManager CommandManager { get; private set; } = null!;

[PluginService]
internal static IObjectTable ObjectTable { get; private set; } = null!;

Expand Down
127 changes: 0 additions & 127 deletions FakeName/Windows/ConfigWindow.cs

This file was deleted.

110 changes: 110 additions & 0 deletions FakeName/Windows/FakeNameConfigWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using Dalamud.Interface;
using Dalamud.Interface.Internal;
using ImGuiNET;
using System.Linq;
using XIVConfigUI;
using XIVConfigUI.SearchableConfigs;

namespace FakeName.Windows;

internal class FakeNameConfigWindow() : ConfigWindow(typeof(FakeNameConfigWindow).Assembly.GetName())
{
public class Config : SearchableConfig
{
public override void AfterConfigChange(Searchable item)
{
Service.Config.SaveConfig();
}
}

public class SettingItem : ConfigWindowItem
{
public override void Draw(ConfigWindow window)
{
window.Collection.DrawItems(0);

ImGui.Separator();

if (!Service.Config.NameDict.Any(p => string.IsNullOrEmpty(p.Item1)))
{
Service.Config.NameDict.Add((string.Empty, string.Empty));
}

if (ImGui.BeginTable("Name Dict things", 3, ImGuiTableFlags.Borders
| ImGuiTableFlags.Resizable
| ImGuiTableFlags.SizingStretchProp))
{
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableNextRow(ImGuiTableRowFlags.Headers);

ImGui.TableNextColumn();
ImGui.TableHeader("Original Name");

ImGui.TableNextColumn();
ImGui.TableHeader("Replaced Name");

ImGui.TableNextColumn();
ImGui.TableHeader("Delete");

var index = 0;

var removeIndex = -1;
var changedIndex = -1;

var changedValue = (string.Empty, string.Empty);
foreach ((var key, var value) in Service.Config.NameDict)
{
ImGui.TableNextRow();
ImGui.TableNextColumn();

var str = key;
if (ImGui.InputTextWithHint($"##NameDict Key{index}", "Original Name", ref str, 1024))
{
changedIndex = index;
changedValue = (str, value);
}
ImGui.TableNextColumn();

str = value;

if (ImGui.InputTextWithHint($"##NameDict Value{index}", "Replace Name", ref str, 1024))
{
changedIndex = index;
changedValue = (key, str);
}
ImGui.TableNextColumn();

ImGui.PushFont(UiBuilder.IconFont);
var result = ImGui.Button(FontAwesomeIcon.Ban.ToIconString() + $"##Remove NameDict Key{index}");
ImGui.PopFont();

if (result)
{
removeIndex = index;
}

index++;
}

ImGui.EndTable();
if (removeIndex > -1)
{
Service.Config.NameDict.RemoveAt(removeIndex);
Service.Config.SaveConfig();
}
if (changedIndex > -1)
{
Service.Config.NameDict[changedIndex] = changedValue;
Service.Config.SaveConfig();
}
}
}

public override bool GetIcon(out IDalamudTextureWrap texture)
{
return ImageLoader.GetTexture(14, out texture);
}
}

public override SearchableCollection Collection { get; } = new(Service.Config, new Config());
}
Loading

0 comments on commit 2046c66

Please sign in to comment.