Fixed multiple segfaults

This commit is contained in:
Yousef Khadadeh 2026-03-30 18:51:14 +03:00
parent b4c35124c3
commit 2ad5684594
32 changed files with 1035 additions and 1010 deletions

View file

@ -6,14 +6,14 @@ namespace GUIStuff { namespace ElementHelpers {
void radio_button_field(GUIManager& gui, const char* id, std::string_view name, const std::function<bool()>& isTicked, const std::function<void()>& onClick);
template <typename T> void radio_button_selector(GUIManager& gui, const char* id, T* data, const std::vector<std::pair<std::string_view, T>>& options, const std::function<void()>& onClick = nullptr) {
gui.push_id(id);
for(size_t i = 0; i < options.size(); i++) {
gui.push_id(i);
auto& option = options[i];
radio_button_field(gui, "Option", option.first, [data, optionVal = option.second]{ return *data == optionVal; }, [data, optionVal = option.second, onClick]{ *data = optionVal; if(onClick) onClick(); });
gui.pop_id();
}
gui.pop_id();
gui.new_id(id, [&] {
for(size_t i = 0; i < options.size(); i++) {
gui.new_id(i, [&] {
auto& option = options[i];
radio_button_field(gui, "Option", option.first, [data, optionVal = option.second]{ return *data == optionVal; }, [data, optionVal = option.second, onClick]{ *data = optionVal; if(onClick) onClick(); });
});
}
});
}
}}