Slight modifications to button offset PR.

This commit is contained in:
Ottermandias 2021-11-29 16:41:31 +01:00
parent 5802f6b6d7
commit 0e552d24a6
3 changed files with 322 additions and 318 deletions

View file

@ -37,7 +37,7 @@ namespace Penumbra
public Dictionary< string, string > ModSortOrder { get; set; } = new();
public bool InvertModListOrder { internal get; set; }
public Vector2 ManageModsButtonOffset { get; set; } = Vector2.Zero;
public Vector2 ManageModsButtonOffset { get; set; } = 50 * Vector2.One;
public static Configuration Load()
{

View file

@ -1,22 +1,19 @@
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
using Penumbra.UI.Custom;
namespace Penumbra.UI;
namespace Penumbra.UI
{
public partial class SettingsInterface
{
private class ManageModsButton
{
// magic numbers
private const int Padding = 50;
private const int Width = 200;
private const int Height = 45;
private const string MenuButtonsName = "Penumbra Menu Buttons";
private const string MenuButtonLabel = "Manage Mods";
private static readonly Vector2 WindowSize = new( Width, Height );
private static readonly Vector2 WindowPosOffset = new( Padding + Width, Padding + Height );
private const ImGuiWindowFlags ButtonFlags =
ImGuiWindowFlags.AlwaysAutoResize
| ImGuiWindowFlags.NoBackground
@ -24,6 +21,7 @@ namespace Penumbra.UI
| ImGuiWindowFlags.NoMove
| ImGuiWindowFlags.NoScrollbar
| ImGuiWindowFlags.NoResize
| ImGuiWindowFlags.NoFocusOnAppearing
| ImGuiWindowFlags.NoSavedSettings;
private readonly SettingsInterface _base;
@ -31,20 +29,26 @@ namespace Penumbra.UI
public ManageModsButton( SettingsInterface ui )
=> _base = ui;
internal bool ForceDraw = false;
public void Draw()
{
if( Dalamud.Conditions.Any() || _base._menu.Visible )
if( !ForceDraw && ( Dalamud.Conditions.Any() || _base._menu.Visible ) )
{
return;
}
using var color = ImGuiRaii.PushColor( ImGuiCol.Button, 0xFF0000C8, ForceDraw );
var ss = ImGui.GetMainViewport().Size + ImGui.GetMainViewport().Pos;
ImGui.SetNextWindowViewport( ImGui.GetMainViewport().ID );
ImGui.SetNextWindowPos( ss - WindowPosOffset + Penumbra.Config.ManageModsButtonOffset, ImGuiCond.Always );
var windowSize = ImGuiHelpers.ScaledVector2( Width, Height );
ImGui.SetNextWindowPos( ss - windowSize - Penumbra.Config.ManageModsButtonOffset * ImGuiHelpers.GlobalScale, ImGuiCond.Always );
if( ImGui.Begin( MenuButtonsName, ButtonFlags )
&& ImGui.Button( MenuButtonLabel, WindowSize ) )
&& ImGui.Button( MenuButtonLabel, windowSize ) )
{
_base.FlipVisibility();
}
@ -53,4 +57,3 @@ namespace Penumbra.UI
}
}
}
}

View file

@ -12,8 +12,8 @@ using Penumbra.Mods;
using Penumbra.UI.Custom;
using Penumbra.Util;
namespace Penumbra.UI
{
namespace Penumbra.UI;
public partial class SettingsInterface
{
private class TabSettings
@ -34,7 +34,7 @@ namespace Penumbra.UI
private const string LabelDisableNotifications = "Disable filesystem change notifications";
private const string LabelEnableHttpApi = "Enable HTTP API";
private const string LabelReloadResource = "Reload Player Resource";
private const string LabelManageModsOffset = "\"Manage mods\" title screen button offset";
private const string LabelManageModsOffset = "\"Manage mods\"-Button Offset";
private readonly SettingsInterface _base;
private readonly Configuration _config;
@ -160,15 +160,17 @@ namespace Penumbra.UI
}
}
private void DrawManageModsButtonOffset()
private void DrawManageModsButtonOffsetButton()
{
var manageModsButtonOffset = _config.ManageModsButtonOffset;
ImGui.SetNextItemWidth( 150f );
ImGui.SetNextItemWidth( 150 * ImGuiHelpers.GlobalScale );
if( ImGui.DragFloat2( LabelManageModsOffset, ref manageModsButtonOffset, 1f ) )
{
_config.ManageModsButtonOffset = manageModsButtonOffset;
_configChanged = true;
}
_base._manageModsButton.ForceDraw = ImGui.IsItemActive();
}
private void DrawSortFoldersFirstBox()
@ -317,7 +319,7 @@ namespace Penumbra.UI
ImGuiCustom.VerticalDistance( DefaultVerticalSpace );
DrawScaleModSelectorBox();
DrawSortFoldersFirstBox();
DrawManageModsButtonOffset();
DrawManageModsButtonOffsetButton();
DrawShowAdvancedBox();
if( _config.ShowAdvanced )
@ -333,4 +335,3 @@ namespace Penumbra.UI
}
}
}
}