mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
38 lines
983 B
C++
38 lines
983 B
C++
#include "setting.hpp"
|
|
|
|
#include "../util/stringutil.hpp"
|
|
|
|
std::string NumberSetting::toString() const {
|
|
switch (getFormat()) {
|
|
case setting_format::simple:
|
|
return util::to_string(value);
|
|
case setting_format::percent:
|
|
return std::to_string(static_cast<integer_t>(round(value * 100))) + "%";
|
|
default:
|
|
return "invalid format";
|
|
}
|
|
}
|
|
|
|
std::string IntegerSetting::toString() const {
|
|
switch (getFormat()) {
|
|
case setting_format::simple:
|
|
return util::to_string(value);
|
|
case setting_format::percent:
|
|
return std::to_string(value) + "%";
|
|
default:
|
|
return "invalid format";
|
|
}
|
|
}
|
|
|
|
std::string FlagSetting::toString() const {
|
|
switch (getFormat()) {
|
|
case setting_format::simple:
|
|
return value ? "true" : "false";
|
|
default:
|
|
return "invalid format";
|
|
}
|
|
}
|
|
|
|
std::string StringSetting::toString() const {
|
|
return value;
|
|
}
|