- fixed mouse input for scale slider.

This commit is contained in:
Christoph Oelckers 2017-03-30 20:12:39 +02:00
parent 228c57fae3
commit 51d89740e3

View file

@ -1222,6 +1222,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
{ {
String TextZero; String TextZero;
String TextNegOne; String TextNegOne;
int mClickVal;
OptionMenuItemScaleSlider Init(String label, Name command, double min, double max, double step, String zero, String negone = "") 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); mCVar =CVar.FindCVar(command);
TextZero = zero; TextZero = zero;
TextNEgOne = negone; TextNEgOne = negone;
mClickVal = -10;
return self; return self;
} }
@ -1238,7 +1240,7 @@ class OptionMenuItemScaleSlider : OptionMenuItemSlider
drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor);
int Selection = GetSliderValue(); int Selection = GetSliderValue();
if (Selection == 0 || Selection == -1) if ((Selection == 0 || Selection == -1) && mClickVal <= 0)
{ {
String text = Selection == 0? TextZero : Selection == -1? TextNegOne : ""; String text = Selection == 0? TextZero : Selection == -1? TextNegOne : "";
screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue, indent + CursorSpace(), y, text, DTA_CleanNoMove_1, true); 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) override bool MouseEvent(int type, int x, int y)
{ {
int value = GetSliderValue(); int value = GetSliderValue();
if (value > 0) return Super.MouseEvent(type, x, y); switch (type)
if (type == Menu.MOUSE_Release)
{ {
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; return false;
} }