From 51d89740e3dea0a68fd4e365d6f429a51cc6020c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 30 Mar 2017 20:12:39 +0200 Subject: [PATCH] - fixed mouse input for scale slider. --- .../static/zscript/menu/optionmenuitems.txt | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/wadsrc/static/zscript/menu/optionmenuitems.txt b/wadsrc/static/zscript/menu/optionmenuitems.txt index dd4385dbb4..04d2023a2e 100644 --- a/wadsrc/static/zscript/menu/optionmenuitems.txt +++ b/wadsrc/static/zscript/menu/optionmenuitems.txt @@ -1222,6 +1222,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider { String TextZero; String TextNegOne; + int mClickVal; OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "") { @@ -1229,6 +1230,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider mCVar =CVar.FindCVar(command); TextZero = zero; TextNEgOne = negone; + mClickVal = -10; return self; } @@ -1238,7 +1240,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); int Selection = GetSliderValue(); - if (Selection == 0 || Selection == -1) + if ((Selection == 0 || Selection == -1) && mClickVal <= 0) { String text = Selection == 0? TextZero : Selection == -1? TextNegOne : ""; screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue, indent + CursorSpace(), y, text, DTA_CleanNoMove_1, true); @@ -1254,10 +1256,26 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider override bool MouseEvent(int type, int x, int y) { int value = GetSliderValue(); - if (value > 0) return Super.MouseEvent(type, x, y); - if (type == Menu.MOUSE_Release) + switch (type) { - return Menu.GetCurrentMenu().MenuEvent(Menu.MKEY_Enter, true); + case Menu.MOUSE_Click: + mClickVal = value; + if (value <= 0) return false; + return Super.MouseEvent(type, x, y); + + case Menu.MOUSE_Move: + if (mClickVal <= 0) return false; + return Super.MouseEvent(type, x, y); + + case Menu.MOUSE_Release: + if (mClickVal <= 0) + { + mClickVal = -10; + SetSliderValue(value + 1); + return true; + } + mClickVal = -10; + return Super.MouseEvent(type, x, y); } return false; }