mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +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.Game;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local
|
||||
|
||||
namespace Penumbra
|
||||
{
|
||||
public class Dalamud
|
||||
{
|
||||
public static void Initialize(DalamudPluginInterface pluginInterface)
|
||||
=> pluginInterface.Create<Dalamud>();
|
||||
|
||||
// @formatter:off
|
||||
[PluginService][RequiredVersion("1.0")] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static CommandManager Commands { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static SigScanner SigScanner { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static DataManager GameData { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static ClientState ClientState { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static ChatGui Chat { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static Framework Framework { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static Condition Conditions { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static TargetManager Targets { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static ObjectTable Objects { get; private set; } = null!;
|
||||
// @formatter:on
|
||||
}
|
||||
}
|
||||
using Dalamud.Data;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Game.Command;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Local
|
||||
|
||||
namespace Penumbra
|
||||
{
|
||||
public class Dalamud
|
||||
{
|
||||
public static void Initialize(DalamudPluginInterface pluginInterface)
|
||||
=> pluginInterface.Create<Dalamud>();
|
||||
|
||||
// @formatter:off
|
||||
[PluginService][RequiredVersion("1.0")] public static DalamudPluginInterface PluginInterface { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static CommandManager Commands { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static SigScanner SigScanner { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static DataManager GameData { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static ClientState ClientState { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static ChatGui Chat { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static Framework Framework { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static Condition Conditions { get; private set; } = null!;
|
||||
[PluginService][RequiredVersion("1.0")] public static TargetManager Targets { get; private set; } = null!;
|
||||
[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>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="tsmLogo.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Dalamud">
|
||||
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
|
||||
|
|
@ -62,7 +68,7 @@
|
|||
<PackageReference Include="SharpZipLib" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Penumbra.GameData\Penumbra.GameData.csproj" />
|
||||
<ProjectReference Include="..\Penumbra.PlayerWatch\Penumbra.PlayerWatch.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
@ -72,4 +78,4 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
@ -1,59 +1,44 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
using ImGuiScene;
|
||||
using Penumbra.UI.Custom;
|
||||
|
||||
namespace Penumbra.UI;
|
||||
|
||||
public partial class SettingsInterface
|
||||
{
|
||||
private class ManageModsButton
|
||||
private class ManageModsButton : IDisposable
|
||||
{
|
||||
// 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 ImGuiWindowFlags ButtonFlags =
|
||||
ImGuiWindowFlags.AlwaysAutoResize
|
||||
| ImGuiWindowFlags.NoBackground
|
||||
| ImGuiWindowFlags.NoDecoration
|
||||
| ImGuiWindowFlags.NoMove
|
||||
| ImGuiWindowFlags.NoScrollbar
|
||||
| ImGuiWindowFlags.NoResize
|
||||
| ImGuiWindowFlags.NoFocusOnAppearing
|
||||
| ImGuiWindowFlags.NoSavedSettings;
|
||||
|
||||
private readonly SettingsInterface _base;
|
||||
private readonly SettingsInterface _base;
|
||||
private readonly TextureWrap _icon;
|
||||
private readonly TitleScreenMenu.TitleScreenMenuEntry _entry;
|
||||
|
||||
public ManageModsButton( SettingsInterface ui )
|
||||
=> _base = ui;
|
||||
|
||||
internal bool ForceDraw = false;
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if( !ForceDraw && ( Dalamud.Conditions.Any() || _base._menu.Visible ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
_base = ui;
|
||||
|
||||
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;
|
||||
ImGui.SetNextWindowViewport( ImGui.GetMainViewport().ID );
|
||||
_entry = Dalamud.TitleScreenMenu.AddEntry( MenuButtonLabel, _icon, OnTriggered );
|
||||
}
|
||||
|
||||
var windowSize = ImGuiHelpers.ScaledVector2( Width, Height );
|
||||
private void OnTriggered()
|
||||
{
|
||||
_base.FlipVisibility();
|
||||
}
|
||||
|
||||
ImGui.SetNextWindowPos( ss - windowSize - Penumbra.Config.ManageModsButtonOffset * ImGuiHelpers.GlobalScale, ImGuiCond.Always );
|
||||
|
||||
if( ImGui.Begin( MenuButtonsName, ButtonFlags )
|
||||
&& ImGui.Button( MenuButtonLabel, windowSize ) )
|
||||
{
|
||||
_base.FlipVisibility();
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
public void Dispose()
|
||||
{
|
||||
_icon.Dispose();
|
||||
Dalamud.TitleScreenMenu.RemoveEntry( _entry );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -150,21 +150,6 @@ public partial class SettingsInterface
|
|||
+ "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()
|
||||
{
|
||||
var foldersFirst = _config.SortFoldersFirst;
|
||||
|
|
@ -360,7 +345,6 @@ public partial class SettingsInterface
|
|||
ImGuiCustom.VerticalDistance( DefaultVerticalSpace );
|
||||
DrawScaleModSelectorBox();
|
||||
DrawSortFoldersFirstBox();
|
||||
DrawManageModsButtonOffsetButton();
|
||||
DrawShowAdvancedBox();
|
||||
|
||||
if( _config.ShowAdvanced )
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ namespace Penumbra.UI
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
_manageModsButton.Dispose();
|
||||
_menu.InstalledTab.Selector.Cache.Dispose();
|
||||
Dalamud.PluginInterface.UiBuilder.Draw -= Draw;
|
||||
Dalamud.PluginInterface.UiBuilder.OpenConfigUi -= OpenConfig;
|
||||
|
|
@ -51,7 +52,6 @@ namespace Penumbra.UI
|
|||
public void Draw()
|
||||
{
|
||||
_menuBar.Draw();
|
||||
_manageModsButton.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