X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fucioption.cpp;h=80efb87a911f7a0449b6d961fc1266cedd216f5f;hp=d281d40d649738a46900a0f2beb48ed4e9d0f36f;hb=82f7d507eaf83e27a33bf0b433be08d23320b6fe;hpb=f7cc0026e3291cd281d2e3975a5f01f63be162aa diff --git a/src/ucioption.cpp b/src/ucioption.cpp index d281d40d..80efb87a 100644 --- a/src/ucioption.cpp +++ b/src/ucioption.cpp @@ -92,11 +92,13 @@ std::ostream& operator<<(std::ostream& os, const OptionsMap& om) { const Option& o = it.second; os << "\noption name " << it.first << " type " << o.type; - if (o.type != "button") + if (o.type == "string" || o.type == "check" || o.type == "combo") os << " default " << o.defaultValue; if (o.type == "spin") - os << " min " << o.min << " max " << o.max; + os << " default " << int(stof(o.defaultValue)) + << " min " << o.min + << " max " << o.max; break; } @@ -116,15 +118,15 @@ Option::Option(bool v, OnChange f) : type("check"), min(0), max(0), on_change(f) Option::Option(OnChange f) : type("button"), min(0), max(0), on_change(f) {} -Option::Option(int v, int minv, int maxv, OnChange f) : type("spin"), min(minv), max(maxv), on_change(f) +Option::Option(double v, int minv, int maxv, OnChange f) : type("spin"), min(minv), max(maxv), on_change(f) { defaultValue = currentValue = std::to_string(v); } Option::Option(const char* v, const char* cur, OnChange f) : type("combo"), min(0), max(0), on_change(f) { defaultValue = v; currentValue = cur; } -Option::operator int() const { +Option::operator double() const { assert(type == "check" || type == "spin"); - return (type == "spin" ? stoi(currentValue) : currentValue == "true"); + return (type == "spin" ? stof(currentValue) : currentValue == "true"); } Option::operator std::string() const { @@ -160,7 +162,7 @@ Option& Option::operator=(const string& v) { if ( (type != "button" && v.empty()) || (type == "check" && v != "true" && v != "false") - || (type == "spin" && (stoi(v) < min || stoi(v) > max))) + || (type == "spin" && (stof(v) < min || stof(v) > max))) return *this; if (type != "button")