Initial HSMappy release (fork of Mappy)
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Interface.GameFonts;
|
||||
using Dalamud.Plugin;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using KamiLib.Classes;
|
||||
using KamiLib.CommandManager;
|
||||
using KamiLib.Window;
|
||||
using Mappy.Controllers;
|
||||
using Mappy.Data;
|
||||
using Mappy.Windows;
|
||||
|
||||
namespace Mappy;
|
||||
|
||||
public sealed class MappyPlugin : IDalamudPlugin
|
||||
{
|
||||
private static bool _minimapPushedPadding;
|
||||
|
||||
public MappyPlugin(IDalamudPluginInterface pluginInterface)
|
||||
{
|
||||
pluginInterface.Create<Service>();
|
||||
|
||||
System.LargeAxisFontHandle = Service.PluginInterface.UiBuilder.FontAtlas.NewGameFontHandle(new GameFontStyle
|
||||
{
|
||||
SizePt = 72.0f,
|
||||
FamilyAndSize = GameFontFamilyAndSize.Axis36,
|
||||
Italic = true,
|
||||
BaseSkewStrength = 16f,
|
||||
});
|
||||
|
||||
System.SystemConfig = SystemConfig.Load();
|
||||
System.IconConfig = IconConfig.Load();
|
||||
System.FlagConfig = FlagConfig.Load();
|
||||
|
||||
System.Teleporter = new Teleporter(Service.PluginInterface);
|
||||
|
||||
System.CommandManager = new CommandManager(Service.PluginInterface, "hsmappy");
|
||||
|
||||
System.MapRenderer = new MapRenderer.MapRenderer();
|
||||
|
||||
System.ConfigWindow = new ConfigurationWindow();
|
||||
System.MapWindow = new MapWindow();
|
||||
System.MinimapWindow = new MinimapWindow();
|
||||
|
||||
// Push zero padding before window system draw so the first window (minimap) gets it.
|
||||
Service.PluginInterface.UiBuilder.Draw += SetMinimapZeroPadding;
|
||||
System.WindowManager = new WindowManager(Service.PluginInterface);
|
||||
Service.PluginInterface.UiBuilder.Draw += PopMinimapPadding;
|
||||
|
||||
// Minimap is added first so it's drawn first and receives the zero padding.
|
||||
System.WindowManager.AddWindow(System.MinimapWindow, WindowFlags.RequireLoggedIn);
|
||||
System.WindowManager.AddWindow(System.ConfigWindow, WindowFlags.IsConfigWindow | WindowFlags.RequireLoggedIn);
|
||||
System.WindowManager.AddWindow(System.MapWindow, WindowFlags.RequireLoggedIn);
|
||||
|
||||
if (System.SystemConfig.ShowMinimap)
|
||||
System.MinimapWindow.UnCollapseOrShow();
|
||||
|
||||
// PopMinimapPadding already registered above (after WindowManager)
|
||||
|
||||
System.FlagController = new FlagController();
|
||||
System.AreaMapController = new AddonAreaMapController();
|
||||
System.IntegrationsController = new IntegrationsController();
|
||||
|
||||
Service.PluginInterface.UiBuilder.OpenMainUi += OpenMapWindow;
|
||||
|
||||
System.CommandManager.RegisterCommand(new ToggleCommandHandler
|
||||
{
|
||||
BaseActivationPath = "/fatelist",
|
||||
EnableDelegate = _ => System.WindowManager.OpenOrCreateUnique<FateListWindow>(WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn),
|
||||
DisableDelegate = _ => System.WindowManager.GetWindow<FateListWindow>()?.Close(),
|
||||
ToggleDelegate = _ => System.WindowManager.GetWindow<FateListWindow>()?.UnCollapseOrToggle(),
|
||||
});
|
||||
|
||||
System.CommandManager.RegisterCommand(new ToggleCommandHandler
|
||||
{
|
||||
BaseActivationPath = "/questlist",
|
||||
EnableDelegate = _ => System.WindowManager.OpenOrCreateUnique<QuestListWindow>(WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn),
|
||||
DisableDelegate = _ => System.WindowManager.GetWindow<QuestListWindow>()?.Close(),
|
||||
ToggleDelegate = _ => System.WindowManager.GetWindow<QuestListWindow>()?.UnCollapseOrToggle(),
|
||||
});
|
||||
|
||||
System.CommandManager.RegisterCommand(new ToggleCommandHandler
|
||||
{
|
||||
BaseActivationPath = "/flaglist",
|
||||
EnableDelegate = _ => System.WindowManager.OpenOrCreateUnique<FlagHistoryWindow>(WindowFlags.OpenImmediately | WindowFlags.RequireLoggedIn),
|
||||
DisableDelegate = _ => System.WindowManager.GetWindow<FlagHistoryWindow>()?.Close(),
|
||||
ToggleDelegate = _ => System.WindowManager.GetWindow<FlagHistoryWindow>()?.UnCollapseOrToggle(),
|
||||
});
|
||||
}
|
||||
|
||||
private unsafe void OpenMapWindow() => AgentMap.Instance()->Show();
|
||||
|
||||
/// <summary>
|
||||
/// Called first each frame so the first window (minimap) gets zero padding when visible.
|
||||
/// </summary>
|
||||
private static void SetMinimapZeroPadding()
|
||||
{
|
||||
if (System.SystemConfig.ShowMinimap && IntegrationsController.ShouldShowMinimap()) {
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0f, 0f));
|
||||
_minimapPushedPadding = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after window system draw to pop the padding we pushed (keeps style stack balanced).
|
||||
/// </summary>
|
||||
private static void PopMinimapPadding()
|
||||
{
|
||||
if (_minimapPushedPadding) {
|
||||
ImGui.PopStyleVar();
|
||||
_minimapPushedPadding = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Service.PluginInterface.UiBuilder.Draw -= SetMinimapZeroPadding;
|
||||
Service.PluginInterface.UiBuilder.Draw -= PopMinimapPadding;
|
||||
System.MapWindow.OnClose();
|
||||
System.WindowManager.Dispose();
|
||||
System.IntegrationsController.Dispose();
|
||||
System.AreaMapController.Dispose();
|
||||
System.FlagController.Dispose();
|
||||
System.MapRenderer.Dispose();
|
||||
|
||||
Service.PluginInterface.UiBuilder.OpenMainUi -= OpenMapWindow;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user