Factorize permission code
This commit is contained in:
committed by
Guillaume Meunier
parent
1623769816
commit
76626b8133
@@ -380,12 +380,10 @@ void scenes::lobby::gui_settings()
|
||||
vibrate_on_hover();
|
||||
}
|
||||
|
||||
bool enabled = config.microphone and audio::check_mic_permission();
|
||||
bool enabled = config.check_feature(feature::microphone);
|
||||
if (ImGui::Checkbox(_S("Enable microphone"), &enabled))
|
||||
{
|
||||
config.microphone = enabled;
|
||||
if (config.microphone)
|
||||
audio::request_mic_permission();
|
||||
config.set_feature(feature::microphone, enabled);
|
||||
config.save();
|
||||
}
|
||||
vibrate_on_hover();
|
||||
@@ -590,7 +588,7 @@ static void ScrollWhenDraggingOnVoid(ImVec2 delta)
|
||||
void scenes::lobby::draw_mic_status()
|
||||
{
|
||||
auto & config = application::get_config();
|
||||
bool enabled = config.microphone and audio::check_mic_permission();
|
||||
const bool enabled = config.check_feature(feature::microphone);
|
||||
const char * text = enabled ? ICON_FA_MICROPHONE : ICON_FA_MICROPHONE_SLASH;
|
||||
float win_width = ImGui::GetWindowSize().x;
|
||||
float text_width = ImGui::CalcTextSize(text).x;
|
||||
@@ -601,9 +599,8 @@ void scenes::lobby::draw_mic_status()
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, enabled ? ImGui::GetColorU32(ImGuiCol_Text) : IM_COL32(255, 0, 0, 255));
|
||||
if (ImGui::Button(text))
|
||||
{
|
||||
config.microphone = not enabled;
|
||||
if (config.microphone)
|
||||
audio::request_mic_permission();
|
||||
// button doesn't alter the bool
|
||||
config.set_feature(feature::microphone, not enabled);
|
||||
config.save();
|
||||
}
|
||||
vibrate_on_hover();
|
||||
|
||||
Reference in New Issue
Block a user