From 52f9ec5cdaffcb7e62373bd2b580233dbfcb1a27 Mon Sep 17 00:00:00 2001 From: MasterHigure Date: Fri, 16 Feb 2024 23:51:12 +0100 Subject: [PATCH 1/4] Add right alignment --- UltimateMedals.as | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/UltimateMedals.as b/UltimateMedals.as index 5897d1d..9823424 100644 --- a/UltimateMedals.as +++ b/UltimateMedals.as @@ -77,6 +77,9 @@ vec2 anchor = vec2(0, 170); [Setting category="Display Settings" name="Lock window position" description="Prevents the window moving when click and drag or when the game window changes size."] bool lockPosition = false; +[Setting category="Display Settings" name="Right-align window" description="Makes it so the right side of the window rather than the left side remains fixed as window size changes."] +bool rightAlign = true; + [Setting category="Display Settings" name="Font face" description="To avoid a memory issue with loading a large number of fonts, you must reload the plugin for font changes to be applied."] string fontFace = ""; @@ -230,6 +233,7 @@ UI::Font@ font = null; uint64 limitMapNameLengthTime = 0; uint64 limitMapNameLengthTimeEnd = 0; +float windowWidth = 0; bool held = false; void OnKeyPress(bool down, VirtualKey key) @@ -280,10 +284,10 @@ void Render() { UI::Begin("Ultimate Medals", windowFlags); - if(!lockPosition) { - anchor = UI::GetWindowPos(); - } - + if(!lockPosition) { + anchor = UI::GetWindowPos(); + } + bool hasComment = string(map.MapInfo.Comments).Length > 0; UI::BeginGroup(); @@ -437,7 +441,15 @@ void Render() { UI::PopTextWrapPos(); UI::EndTooltip(); } - + + float newWidth = UI::GetWindowSize().x; + if (windowWidth != newWidth) { + if(rightAlign) { + UI::SetWindowPos(UI::GetWindowPos() - vec2(newWidth - windowWidth, 0)); + } + windowWidth = newWidth; + } + UI::End(); UI::PopFont(); From fb2e114e8ff107a89b1a67b6874d0db0f7190b4b Mon Sep 17 00:00:00 2001 From: MasterHigure Date: Sat, 17 Feb 2024 00:11:14 +0100 Subject: [PATCH 2/4] Fix spaces vs tabs --- UltimateMedals.as | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/UltimateMedals.as b/UltimateMedals.as index 9823424..4d1841e 100644 --- a/UltimateMedals.as +++ b/UltimateMedals.as @@ -284,9 +284,9 @@ void Render() { UI::Begin("Ultimate Medals", windowFlags); - if(!lockPosition) { - anchor = UI::GetWindowPos(); - } + if(!lockPosition) { + anchor = UI::GetWindowPos(); + } bool hasComment = string(map.MapInfo.Comments).Length > 0; @@ -443,12 +443,12 @@ void Render() { } float newWidth = UI::GetWindowSize().x; - if (windowWidth != newWidth) { - if(rightAlign) { - UI::SetWindowPos(UI::GetWindowPos() - vec2(newWidth - windowWidth, 0)); - } - windowWidth = newWidth; - } + if (windowWidth != newWidth) { + if(rightAlign) { + UI::SetWindowPos(UI::GetWindowPos() - vec2(newWidth - windowWidth, 0)); + } + windowWidth = newWidth; + } UI::End(); From c04b86a0ca76c42308570c750121804af90b6ab1 Mon Sep 17 00:00:00 2001 From: MasterHigure Date: Sat, 17 Feb 2024 00:26:37 +0100 Subject: [PATCH 3/4] Persist position across plugin reloads --- UltimateMedals.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltimateMedals.as b/UltimateMedals.as index 4d1841e..83654a0 100644 --- a/UltimateMedals.as +++ b/UltimateMedals.as @@ -444,7 +444,7 @@ void Render() { float newWidth = UI::GetWindowSize().x; if (windowWidth != newWidth) { - if(rightAlign) { + if(rightAlign && windowWidth != 0) { UI::SetWindowPos(UI::GetWindowPos() - vec2(newWidth - windowWidth, 0)); } windowWidth = newWidth; From 8db88eb9bc8c777f1a3efc9d0f88d7f1471bda50 Mon Sep 17 00:00:00 2001 From: MasterHigure Date: Sat, 17 Feb 2024 00:30:36 +0100 Subject: [PATCH 4/4] Set rightAlign to false as default --- UltimateMedals.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltimateMedals.as b/UltimateMedals.as index 83654a0..94abc12 100644 --- a/UltimateMedals.as +++ b/UltimateMedals.as @@ -78,7 +78,7 @@ vec2 anchor = vec2(0, 170); bool lockPosition = false; [Setting category="Display Settings" name="Right-align window" description="Makes it so the right side of the window rather than the left side remains fixed as window size changes."] -bool rightAlign = true; +bool rightAlign = false; [Setting category="Display Settings" name="Font face" description="To avoid a memory issue with loading a large number of fonts, you must reload the plugin for font changes to be applied."] string fontFace = "";