overlay: refactor code for lights (#539)

No functional change.
This commit is contained in:
bicarus
2026-01-29 16:13:56 -08:00
committed by GitHub
parent 4feca23240
commit 7a6cadb176
2 changed files with 100 additions and 92 deletions
+15 -9
View File
@@ -2183,9 +2183,16 @@ namespace overlay::windows {
// check lights
if (lights) {
for (auto &light_in : *lights) {
build_light(&light_in);
}
}
ImGui::EndTable();
}
}
void Config::build_light(Light *light) {
// get light based on page
auto light = &light_in;
auto &light_alternatives = light->getAlternatives();
if (this->lights_page > 0) {
while ((int) light_alternatives.size() < this->lights_page) {
@@ -2228,11 +2235,7 @@ namespace overlay::windows {
if (light_display.size() > 0) {
ImGui::SameLine();
if (ImGui::DeleteButton("Remove")) {
light->setDeviceIdentifier("");
light->setIndex(0xFF);
::Config::getInstance().updateBinding(
games_list[games_selected], *light,
lights_page - 1);
clear_light(light);
}
}
@@ -2276,10 +2279,13 @@ namespace overlay::windows {
// clean up
ImGui::PopID();
}
}
ImGui::EndTable();
}
void Config::clear_light(Light *light) {
light->setDeviceIdentifier("");
light->setIndex(0xFF);
::Config::getInstance().updateBinding(
games_list[games_selected], *light,
lights_page - 1);
}
void Config::edit_light_popup(Light *light) {
+2
View File
@@ -94,6 +94,8 @@ namespace overlay::windows {
void edit_analog_popup(Analog &analog);
void build_lights(const std::string &name, std::vector<Light> *lights);
void build_light(Light *light);
void clear_light(Light *light);
void edit_light_popup(Light *light);
void build_cards();