From 920d4e00b47f76d398ea2454c67e4802c6189b15 Mon Sep 17 00:00:00 2001 From: in0finite Date: Sun, 28 Jul 2019 21:54:14 +0200 Subject: [PATCH] apply min button width and height in main menu --- Assets/Scripts/UI/MainMenu.cs | 2 +- Assets/Scripts/Utilities/GUI/GUIUtils.cs | 15 +++++++++++++++ Docs/TODO.md | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index 52ec8988..520ac140 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -100,7 +100,7 @@ namespace SanAndreasUnity.UI public static bool DrawMenuEntry(string text) { - return GUIUtils.ButtonWithCalculatedSize(text); + return GUIUtils.ButtonWithCalculatedSize(text, Instance.minButtonWidth, Instance.minButtonHeight); } public static void RegisterMenuEntry (MenuEntry menuEntry) diff --git a/Assets/Scripts/Utilities/GUI/GUIUtils.cs b/Assets/Scripts/Utilities/GUI/GUIUtils.cs index eba2c16d..cc1baae8 100644 --- a/Assets/Scripts/Utilities/GUI/GUIUtils.cs +++ b/Assets/Scripts/Utilities/GUI/GUIUtils.cs @@ -85,9 +85,24 @@ namespace SanAndreasUnity.Utilities return ButtonWithCalculatedSize(new GUIContent(text)); } + public static bool ButtonWithCalculatedSize(string text, float minWidth, float minHeight) + { + return ButtonWithCalculatedSize(new GUIContent(text), minWidth, minHeight); + } + public static bool ButtonWithCalculatedSize(GUIContent content) + { + return ButtonWithCalculatedSize(content, 0f, 0f); + } + + public static bool ButtonWithCalculatedSize(GUIContent content, float minWidth, float minHeight) { Vector2 size = CalcScreenSizeForContent (content, GUI.skin.button); + + if (size.x < minWidth) + size.x = minWidth; + if (size.y < minHeight) + size.y = minHeight; return GUILayout.Button (content, GUILayout.Width (size.x), GUILayout.Height (size.y)); } diff --git a/Docs/TODO.md b/Docs/TODO.md index bf82c3e1..277bafbc 100644 --- a/Docs/TODO.md +++ b/Docs/TODO.md @@ -25,7 +25,7 @@ - Chat -- Android: set font size to 20 ; adapt UI: StartGame scrollview style, JoinGame scrollview style, main menu, options (save, load, use box as scrollview style, size), Utilities size, file browser size ; sliders should be larger ; camera zoom should be configurable (no need for persistence) ; use unsigned (debug) key alias ; increment build number ; test at 800x480 resolution ; +- Android: set font size to 23 ; adapt UI: main menu (add min button size), options (save, load, size), Utilities size, file browser size ; sliders should be larger ; camera zoom should be configurable (no need for persistence) ; use unsigned (debug) key alias ; increment build number ; test at 800x480 resolution ; - Touch input: