aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/CommonSrc/Util/OptionMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Samples/CommonSrc/Util/OptionMenu.cpp')
-rw-r--r--Samples/CommonSrc/Util/OptionMenu.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/Samples/CommonSrc/Util/OptionMenu.cpp b/Samples/CommonSrc/Util/OptionMenu.cpp
index 2d3c3d0..b2cc0c9 100644
--- a/Samples/CommonSrc/Util/OptionMenu.cpp
+++ b/Samples/CommonSrc/Util/OptionMenu.cpp
@@ -5,7 +5,7 @@ Content : Option selection and editing for OculusWorldDemo
Created : March 7, 2014
Authors : Michael Antonov, Caleb Leak
-Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2012 Oculus VR, LLC All Rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -150,6 +150,7 @@ OptionVar::OptionVar(const char* name, void* pvar, VarType type,
ShortcutDown.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::PrevValue);
}
+
OptionVar::OptionVar(const char* name, int32_t* pvar,
int32_t min, int32_t max, int32_t stepSize,
const char* formatString,
@@ -164,6 +165,11 @@ OptionVar::OptionVar(const char* name, int32_t* pvar,
pNotify = 0;
FormatString= formatString;
+ MaxFloat = MATH_FLOAT_MAXVALUE;
+ MinFloat = -MATH_FLOAT_MAXVALUE;
+ StepFloat = 1.0f;
+ FormatScale = 1.0f;
+
MinInt = min;
MaxInt = max;
StepInt = stepSize;
@@ -194,6 +200,10 @@ OptionVar::OptionVar(const char* name, float* pvar,
StepFloat = stepSize;
FormatScale = formatScale;
+ MaxInt = 0x7FFFFFFF;
+ MinInt = -(MaxInt) - 1;
+ StepInt = 1;
+
SelectedIndex = 0;
ShortcutUp.pNotify = new FunctionNotifyContext<OptionVar, bool>(this, &OptionVar::NextValue);
@@ -243,9 +253,12 @@ void OptionVar::PrevValue(bool* pFastStep)
switch (Type)
{
case Type_Enum:
- *AsInt() = ((GetEnumIndex() + (uint32_t)EnumValues.GetSize() - 1) % EnumValues.GetSize());
+ {
+ uint32_t size = (uint32_t)(EnumValues.GetSize() ? EnumValues.GetSize() : 1);
+ *AsInt() = ((GetEnumIndex() + (size - 1)) % size);
break;
-
+ }
+
case Type_Int:
*AsInt() = Alg::Max<int32_t>(*AsInt() - StepInt * (fastStep ? 5 : 1), MinInt);
break;