mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Replace manage mods button with title screen menu
This commit is contained in:
parent
40bb7567dd
commit
b6817c47ed
6 changed files with 65 additions and 88 deletions
|
|
@ -1,32 +1,34 @@
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.ClientState;
|
using Dalamud.Game.ClientState;
|
||||||
using Dalamud.Game.ClientState.Conditions;
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
using Dalamud.Game.ClientState.Objects;
|
using Dalamud.Game.ClientState.Objects;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Game.Gui;
|
using Dalamud.Game.Gui;
|
||||||
using Dalamud.IoC;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Plugin;
|
using Dalamud.IoC;
|
||||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local
|
using Dalamud.Plugin;
|
||||||
|
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local
|
||||||
namespace Penumbra
|
|
||||||
{
|
namespace Penumbra
|
||||||
public class Dalamud
|
{
|
||||||
{
|
public class Dalamud
|
||||||
public static void Initialize(DalamudPluginInterface pluginInterface)
|
{
|
||||||
=> pluginInterface.Create<Dalamud>();
|
public static void Initialize(DalamudPluginInterface pluginInterface)
|
||||||
|
=> pluginInterface.Create<Dalamud>();
|
||||||
// @formatter:off
|
|
||||||
[PluginService][RequiredVersion("1.0")] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
|
// @formatter:off
|
||||||
[PluginService][RequiredVersion("1.0")] public static CommandManager Commands { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static SigScanner SigScanner { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static CommandManager Commands { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static DataManager GameData { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static SigScanner SigScanner { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static ClientState ClientState { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static DataManager GameData { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static ChatGui Chat { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static ClientState ClientState { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static Framework Framework { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static ChatGui Chat { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static Condition Conditions { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static Framework Framework { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static TargetManager Targets { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static Condition Conditions { get; private set; } = null!;
|
||||||
[PluginService][RequiredVersion("1.0")] public static ObjectTable Objects { get; private set; } = null!;
|
[PluginService][RequiredVersion("1.0")] public static TargetManager Targets { get; private set; } = null!;
|
||||||
// @formatter:on
|
[PluginService][RequiredVersion("1.0")] public static ObjectTable Objects { get; private set; } = null!;
|
||||||
}
|
[PluginService][RequiredVersion("1.0")] public static TitleScreenMenu TitleScreenMenu { get; private set; } = null!;
|
||||||
}
|
// @formatter:on
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -29,6 +29,12 @@
|
||||||
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
|
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="tsmLogo.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Dalamud">
|
<Reference Include="Dalamud">
|
||||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
|
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
|
||||||
|
|
@ -62,7 +68,7 @@
|
||||||
<PackageReference Include="SharpZipLib" Version="1.3.1" />
|
<PackageReference Include="SharpZipLib" Version="1.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Penumbra.GameData\Penumbra.GameData.csproj" />
|
<ProjectReference Include="..\Penumbra.GameData\Penumbra.GameData.csproj" />
|
||||||
<ProjectReference Include="..\Penumbra.PlayerWatch\Penumbra.PlayerWatch.csproj" />
|
<ProjectReference Include="..\Penumbra.PlayerWatch\Penumbra.PlayerWatch.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -72,4 +78,4 @@
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,59 +1,44 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
using ImGuiScene;
|
||||||
using Penumbra.UI.Custom;
|
using Penumbra.UI.Custom;
|
||||||
|
|
||||||
namespace Penumbra.UI;
|
namespace Penumbra.UI;
|
||||||
|
|
||||||
public partial class SettingsInterface
|
public partial class SettingsInterface
|
||||||
{
|
{
|
||||||
private class ManageModsButton
|
private class ManageModsButton : IDisposable
|
||||||
{
|
{
|
||||||
// magic numbers
|
// magic numbers
|
||||||
private const int Width = 200;
|
|
||||||
private const int Height = 45;
|
|
||||||
private const string MenuButtonsName = "Penumbra Menu Buttons";
|
|
||||||
private const string MenuButtonLabel = "Manage Mods";
|
private const string MenuButtonLabel = "Manage Mods";
|
||||||
|
|
||||||
private const ImGuiWindowFlags ButtonFlags =
|
private readonly SettingsInterface _base;
|
||||||
ImGuiWindowFlags.AlwaysAutoResize
|
private readonly TextureWrap _icon;
|
||||||
| ImGuiWindowFlags.NoBackground
|
private readonly TitleScreenMenu.TitleScreenMenuEntry _entry;
|
||||||
| ImGuiWindowFlags.NoDecoration
|
|
||||||
| ImGuiWindowFlags.NoMove
|
|
||||||
| ImGuiWindowFlags.NoScrollbar
|
|
||||||
| ImGuiWindowFlags.NoResize
|
|
||||||
| ImGuiWindowFlags.NoFocusOnAppearing
|
|
||||||
| ImGuiWindowFlags.NoSavedSettings;
|
|
||||||
|
|
||||||
private readonly SettingsInterface _base;
|
|
||||||
|
|
||||||
public ManageModsButton( SettingsInterface ui )
|
public ManageModsButton( SettingsInterface ui )
|
||||||
=> _base = ui;
|
|
||||||
|
|
||||||
internal bool ForceDraw = false;
|
|
||||||
|
|
||||||
public void Draw()
|
|
||||||
{
|
{
|
||||||
if( !ForceDraw && ( Dalamud.Conditions.Any() || _base._menu.Visible ) )
|
_base = ui;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
using var color = ImGuiRaii.PushColor( ImGuiCol.Button, 0xFF0000C8, ForceDraw );
|
_icon = Dalamud.PluginInterface.UiBuilder.LoadImage( Path.Combine( Dalamud.PluginInterface.AssemblyLocation.DirectoryName!,
|
||||||
|
"tsmLogo.png" ) );
|
||||||
|
if( _icon == null )
|
||||||
|
throw new Exception( "Could not load title screen icon." );
|
||||||
|
|
||||||
var ss = ImGui.GetMainViewport().Size + ImGui.GetMainViewport().Pos;
|
_entry = Dalamud.TitleScreenMenu.AddEntry( MenuButtonLabel, _icon, OnTriggered );
|
||||||
ImGui.SetNextWindowViewport( ImGui.GetMainViewport().ID );
|
}
|
||||||
|
|
||||||
var windowSize = ImGuiHelpers.ScaledVector2( Width, Height );
|
private void OnTriggered()
|
||||||
|
{
|
||||||
|
_base.FlipVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.SetNextWindowPos( ss - windowSize - Penumbra.Config.ManageModsButtonOffset * ImGuiHelpers.GlobalScale, ImGuiCond.Always );
|
public void Dispose()
|
||||||
|
{
|
||||||
if( ImGui.Begin( MenuButtonsName, ButtonFlags )
|
_icon.Dispose();
|
||||||
&& ImGui.Button( MenuButtonLabel, windowSize ) )
|
Dalamud.TitleScreenMenu.RemoveEntry( _entry );
|
||||||
{
|
|
||||||
_base.FlipVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.End();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -150,21 +150,6 @@ public partial class SettingsInterface
|
||||||
+ "This is required to enable manually editing any mod information." );
|
+ "This is required to enable manually editing any mod information." );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawManageModsButtonOffsetButton()
|
|
||||||
{
|
|
||||||
var manageModsButtonOffset = _config.ManageModsButtonOffset;
|
|
||||||
ImGui.SetNextItemWidth( 150 * ImGuiHelpers.GlobalScale );
|
|
||||||
if( ImGui.DragFloat2( "\"Manage Mods\"-Button Offset", ref manageModsButtonOffset, 1f ) )
|
|
||||||
{
|
|
||||||
_config.ManageModsButtonOffset = manageModsButtonOffset;
|
|
||||||
_configChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_base._manageModsButton.ForceDraw = ImGui.IsItemActive();
|
|
||||||
ImGuiComponents.HelpMarker(
|
|
||||||
"Shift the \"Manage Mods\"-Button displayed in the login-lobby by the given amount of pixels in X/Y-direction." );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawSortFoldersFirstBox()
|
private void DrawSortFoldersFirstBox()
|
||||||
{
|
{
|
||||||
var foldersFirst = _config.SortFoldersFirst;
|
var foldersFirst = _config.SortFoldersFirst;
|
||||||
|
|
@ -360,7 +345,6 @@ public partial class SettingsInterface
|
||||||
ImGuiCustom.VerticalDistance( DefaultVerticalSpace );
|
ImGuiCustom.VerticalDistance( DefaultVerticalSpace );
|
||||||
DrawScaleModSelectorBox();
|
DrawScaleModSelectorBox();
|
||||||
DrawSortFoldersFirstBox();
|
DrawSortFoldersFirstBox();
|
||||||
DrawManageModsButtonOffsetButton();
|
|
||||||
DrawShowAdvancedBox();
|
DrawShowAdvancedBox();
|
||||||
|
|
||||||
if( _config.ShowAdvanced )
|
if( _config.ShowAdvanced )
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ namespace Penumbra.UI
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
_manageModsButton.Dispose();
|
||||||
_menu.InstalledTab.Selector.Cache.Dispose();
|
_menu.InstalledTab.Selector.Cache.Dispose();
|
||||||
Dalamud.PluginInterface.UiBuilder.Draw -= Draw;
|
Dalamud.PluginInterface.UiBuilder.Draw -= Draw;
|
||||||
Dalamud.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig;
|
Dalamud.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig;
|
||||||
|
|
@ -51,7 +52,6 @@ namespace Penumbra.UI
|
||||||
public void Draw()
|
public void Draw()
|
||||||
{
|
{
|
||||||
_menuBar.Draw();
|
_menuBar.Draw();
|
||||||
_manageModsButton.Draw();
|
|
||||||
_menu.Draw();
|
_menu.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
BIN
Penumbra/tsmLogo.png
Normal file
BIN
Penumbra/tsmLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
Loading…
Add table
Add a link
Reference in a new issue