mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Add rudimentary start for knowledge window.
This commit is contained in:
parent
a1a7487897
commit
19166d8cf4
5 changed files with 131 additions and 11 deletions
|
|
@ -12,6 +12,7 @@ using Penumbra.Interop.Services;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
using Penumbra.Mods.Manager;
|
using Penumbra.Mods.Manager;
|
||||||
using Penumbra.UI;
|
using Penumbra.UI;
|
||||||
|
using Penumbra.UI.Knowledge;
|
||||||
|
|
||||||
namespace Penumbra;
|
namespace Penumbra;
|
||||||
|
|
||||||
|
|
@ -29,11 +30,12 @@ public class CommandHandler : IDisposable, IApiService
|
||||||
private readonly CollectionManager _collectionManager;
|
private readonly CollectionManager _collectionManager;
|
||||||
private readonly Penumbra _penumbra;
|
private readonly Penumbra _penumbra;
|
||||||
private readonly CollectionEditor _collectionEditor;
|
private readonly CollectionEditor _collectionEditor;
|
||||||
|
private readonly KnowledgeWindow _knowledgeWindow;
|
||||||
|
|
||||||
public CommandHandler(IFramework framework, ICommandManager commandManager, IChatGui chat, RedrawService redrawService,
|
public CommandHandler(IFramework framework, ICommandManager commandManager, IChatGui chat, RedrawService redrawService,
|
||||||
Configuration config,
|
Configuration config, ConfigWindow configWindow, ModManager modManager, CollectionManager collectionManager, ActorManager actors,
|
||||||
ConfigWindow configWindow, ModManager modManager, CollectionManager collectionManager, ActorManager actors, Penumbra penumbra,
|
Penumbra penumbra,
|
||||||
CollectionEditor collectionEditor)
|
CollectionEditor collectionEditor, KnowledgeWindow knowledgeWindow)
|
||||||
{
|
{
|
||||||
_commandManager = commandManager;
|
_commandManager = commandManager;
|
||||||
_redrawService = redrawService;
|
_redrawService = redrawService;
|
||||||
|
|
@ -45,6 +47,7 @@ public class CommandHandler : IDisposable, IApiService
|
||||||
_chat = chat;
|
_chat = chat;
|
||||||
_penumbra = penumbra;
|
_penumbra = penumbra;
|
||||||
_collectionEditor = collectionEditor;
|
_collectionEditor = collectionEditor;
|
||||||
|
_knowledgeWindow = knowledgeWindow;
|
||||||
framework.RunOnFrameworkThread(() =>
|
framework.RunOnFrameworkThread(() =>
|
||||||
{
|
{
|
||||||
if (_commandManager.Commands.ContainsKey(CommandName))
|
if (_commandManager.Commands.ContainsKey(CommandName))
|
||||||
|
|
@ -69,7 +72,7 @@ public class CommandHandler : IDisposable, IApiService
|
||||||
var argumentList = arguments.Split(' ', 2);
|
var argumentList = arguments.Split(' ', 2);
|
||||||
arguments = argumentList.Length == 2 ? argumentList[1] : string.Empty;
|
arguments = argumentList.Length == 2 ? argumentList[1] : string.Empty;
|
||||||
|
|
||||||
var _ = argumentList[0].ToLowerInvariant() switch
|
_ = argumentList[0].ToLowerInvariant() switch
|
||||||
{
|
{
|
||||||
"window" => ToggleWindow(arguments),
|
"window" => ToggleWindow(arguments),
|
||||||
"enable" => SetPenumbraState(arguments, true),
|
"enable" => SetPenumbraState(arguments, true),
|
||||||
|
|
@ -83,6 +86,7 @@ public class CommandHandler : IDisposable, IApiService
|
||||||
"collection" => SetCollection(arguments),
|
"collection" => SetCollection(arguments),
|
||||||
"mod" => SetMod(arguments),
|
"mod" => SetMod(arguments),
|
||||||
"bulktag" => SetTag(arguments),
|
"bulktag" => SetTag(arguments),
|
||||||
|
"knowledge" => HandleKnowledge(arguments),
|
||||||
_ => PrintHelp(argumentList[0]),
|
_ => PrintHelp(argumentList[0]),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +308,7 @@ public class CommandHandler : IDisposable, IApiService
|
||||||
identifiers = _actors.FromUserString(split[2], false);
|
identifiers = _actors.FromUserString(split[2], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ActorManager.IdentifierParseError e)
|
catch (ActorIdentifierFactory.IdentifierParseError e)
|
||||||
{
|
{
|
||||||
_chat.Print(new SeStringBuilder().AddText("The argument ").AddRed(split[2], true)
|
_chat.Print(new SeStringBuilder().AddText("The argument ").AddRed(split[2], true)
|
||||||
.AddText($" could not be converted to an identifier. {e.Message}")
|
.AddText($" could not be converted to an identifier. {e.Message}")
|
||||||
|
|
@ -619,4 +623,10 @@ public class CommandHandler : IDisposable, IApiService
|
||||||
if (_config.PrintSuccessfulCommandsToChat)
|
if (_config.PrintSuccessfulCommandsToChat)
|
||||||
_chat.Print(text());
|
_chat.Print(text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool HandleKnowledge(string arguments)
|
||||||
|
{
|
||||||
|
_knowledgeWindow.Toggle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
Penumbra/UI/Knowledge/IKnowledgeTab.cs
Normal file
8
Penumbra/UI/Knowledge/IKnowledgeTab.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace Penumbra.UI.Knowledge;
|
||||||
|
|
||||||
|
public interface IKnowledgeTab
|
||||||
|
{
|
||||||
|
public ReadOnlySpan<byte> Name { get; }
|
||||||
|
public ReadOnlySpan<byte> SearchTags { get; }
|
||||||
|
public void Draw();
|
||||||
|
}
|
||||||
55
Penumbra/UI/Knowledge/KnowledgeWindow.cs
Normal file
55
Penumbra/UI/Knowledge/KnowledgeWindow.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
using System.Text.Unicode;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
|
using Dalamud.Interface.Windowing;
|
||||||
|
using Dalamud.Memory;
|
||||||
|
using ImGuiNET;
|
||||||
|
using OtterGui.Services;
|
||||||
|
using OtterGui.Text;
|
||||||
|
|
||||||
|
namespace Penumbra.UI.Knowledge;
|
||||||
|
|
||||||
|
/// <summary> Draw the progress information for import. </summary>
|
||||||
|
public sealed class KnowledgeWindow() : Window("Penumbra Knowledge Window"), IUiService
|
||||||
|
{
|
||||||
|
private readonly IReadOnlyList<IKnowledgeTab> _tabs =
|
||||||
|
[
|
||||||
|
new RaceCodeTab(),
|
||||||
|
];
|
||||||
|
|
||||||
|
private IKnowledgeTab? _selected;
|
||||||
|
private readonly byte[] _filterStore = new byte[256];
|
||||||
|
|
||||||
|
private TerminatedByteString _filter = TerminatedByteString.Empty;
|
||||||
|
|
||||||
|
public override void Draw()
|
||||||
|
{
|
||||||
|
DrawSelector();
|
||||||
|
ImUtf8.SameLineInner();
|
||||||
|
DrawMain();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawSelector()
|
||||||
|
{
|
||||||
|
using var child = ImUtf8.Child("KnowledgeSelector"u8, new Vector2(250 * ImUtf8.GlobalScale, ImGui.GetContentRegionAvail().Y), true);
|
||||||
|
if (!child)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
|
||||||
|
ImUtf8.InputText("##Filter"u8, _filterStore, out _filter, "Filter..."u8);
|
||||||
|
|
||||||
|
foreach (var tab in _tabs)
|
||||||
|
{
|
||||||
|
if (ImUtf8.Selectable(tab.Name, _selected == tab))
|
||||||
|
_selected = tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawMain()
|
||||||
|
{
|
||||||
|
using var child = ImUtf8.Child("KnowledgeMain"u8, ImGui.GetContentRegionAvail(), true);
|
||||||
|
if (!child || _selected == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_selected.Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
42
Penumbra/UI/Knowledge/RaceCodeTab.cs
Normal file
42
Penumbra/UI/Knowledge/RaceCodeTab.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
using ImGuiNET;
|
||||||
|
using OtterGui.Text;
|
||||||
|
using Penumbra.GameData.Enums;
|
||||||
|
|
||||||
|
namespace Penumbra.UI.Knowledge;
|
||||||
|
|
||||||
|
public sealed class RaceCodeTab : IKnowledgeTab
|
||||||
|
{
|
||||||
|
public ReadOnlySpan<byte> Name
|
||||||
|
=> "Race Codes"u8;
|
||||||
|
|
||||||
|
public ReadOnlySpan<byte> SearchTags
|
||||||
|
=> "deformersracecodesmodel"u8;
|
||||||
|
|
||||||
|
public void Draw()
|
||||||
|
{
|
||||||
|
using var table = ImUtf8.Table("table"u8, 4, ImGuiTableFlags.SizingFixedFit);
|
||||||
|
if (!table)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImUtf8.TableHeader("Race Code"u8);
|
||||||
|
ImUtf8.TableHeader("Race"u8);
|
||||||
|
ImUtf8.TableHeader("Gender"u8);
|
||||||
|
ImUtf8.TableHeader("NPC"u8);
|
||||||
|
|
||||||
|
foreach (var genderRace in Enum.GetValues<GenderRace>())
|
||||||
|
{
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImUtf8.Text(genderRace.ToRaceCode());
|
||||||
|
|
||||||
|
var (gender, race) = genderRace.Split();
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImUtf8.Text($"{race}");
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImUtf8.Text($"{gender}");
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImUtf8.Text(((ushort)genderRace & 0xF) != 1 ? "NPC"u8 : "Normal"u8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.Plugin;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
using Penumbra.UI.AdvancedWindow;
|
using Penumbra.UI.AdvancedWindow;
|
||||||
|
using Penumbra.UI.Knowledge;
|
||||||
using Penumbra.UI.Tabs.Debug;
|
using Penumbra.UI.Tabs.Debug;
|
||||||
|
|
||||||
namespace Penumbra.UI;
|
namespace Penumbra.UI;
|
||||||
|
|
@ -14,20 +15,24 @@ public class PenumbraWindowSystem : IDisposable, IUiService
|
||||||
private readonly FileDialogService _fileDialog;
|
private readonly FileDialogService _fileDialog;
|
||||||
public readonly ConfigWindow Window;
|
public readonly ConfigWindow Window;
|
||||||
public readonly PenumbraChangelog Changelog;
|
public readonly PenumbraChangelog Changelog;
|
||||||
|
public readonly KnowledgeWindow KnowledgeWindow;
|
||||||
|
|
||||||
public PenumbraWindowSystem(IDalamudPluginInterface pi, Configuration config, PenumbraChangelog changelog, ConfigWindow window,
|
public PenumbraWindowSystem(IDalamudPluginInterface pi, Configuration config, PenumbraChangelog changelog, ConfigWindow window,
|
||||||
LaunchButton _, ModEditWindow editWindow, FileDialogService fileDialog, ImportPopup importPopup, DebugTab debugTab)
|
LaunchButton _, ModEditWindow editWindow, FileDialogService fileDialog, ImportPopup importPopup, DebugTab debugTab,
|
||||||
|
KnowledgeWindow knowledgeWindow)
|
||||||
{
|
{
|
||||||
_uiBuilder = pi.UiBuilder;
|
_uiBuilder = pi.UiBuilder;
|
||||||
_fileDialog = fileDialog;
|
_fileDialog = fileDialog;
|
||||||
Changelog = changelog;
|
KnowledgeWindow = knowledgeWindow;
|
||||||
Window = window;
|
Changelog = changelog;
|
||||||
_windowSystem = new WindowSystem("Penumbra");
|
Window = window;
|
||||||
|
_windowSystem = new WindowSystem("Penumbra");
|
||||||
_windowSystem.AddWindow(changelog.Changelog);
|
_windowSystem.AddWindow(changelog.Changelog);
|
||||||
_windowSystem.AddWindow(window);
|
_windowSystem.AddWindow(window);
|
||||||
_windowSystem.AddWindow(editWindow);
|
_windowSystem.AddWindow(editWindow);
|
||||||
_windowSystem.AddWindow(importPopup);
|
_windowSystem.AddWindow(importPopup);
|
||||||
_windowSystem.AddWindow(debugTab);
|
_windowSystem.AddWindow(debugTab);
|
||||||
|
_windowSystem.AddWindow(KnowledgeWindow);
|
||||||
_uiBuilder.OpenMainUi += Window.Toggle;
|
_uiBuilder.OpenMainUi += Window.Toggle;
|
||||||
_uiBuilder.OpenConfigUi += Window.OpenSettings;
|
_uiBuilder.OpenConfigUi += Window.OpenSettings;
|
||||||
_uiBuilder.Draw += _windowSystem.Draw;
|
_uiBuilder.Draw += _windowSystem.Draw;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue