AUDIO: Implement integer and checkbox options

I remove "text" as a possibility for the moment as we're currently not having **any** text option.
This commit is contained in:
Christoph "baka0815" Schwerdtfeger 2019-05-02 20:24:49 +02:00
parent 139ef22408
commit 99033e297c
2 changed files with 19 additions and 3 deletions

View File

@ -14,8 +14,8 @@ void UpdateBuff(u8* pos);
typedef std::vector<std::string> (*audio_option_callback_t)();
enum audio_option_type
{
text = 0
, integer = 1
integer = 0
, checkbox = 1
, list = 2
};

View File

@ -1099,7 +1099,20 @@ static void gui_display_settings()
}
value = (*cfg_entries)[options->cfg_name];
if (options->type == list)
if (options->type == integer)
{
int val = stoi(value);
ImGui::SliderInt(options->caption.c_str(), &val, options->min_value, options->max_value);
(*cfg_entries)[options->cfg_name] = to_string(val);
}
else if (options->type == checkbox)
{
bool check = (value == "1");
ImGui::Checkbox(options->caption.c_str(), &check);
std::string cur = check ? "1" : "0";
(*cfg_entries)[options->cfg_name] = cur;
}
else if (options->type == list)
{
if (ImGui::BeginCombo(options->caption.c_str(), value.c_str(), ImGuiComboFlags_None))
{
@ -1120,6 +1133,9 @@ static void gui_display_settings()
ImGui::EndCombo();
}
}
else {
printf("Unknown option\n");
}
options++;
}