Fixed multiple segfaults
This commit is contained in:
parent
b4c35124c3
commit
2ad5684594
32 changed files with 1035 additions and 1010 deletions
|
|
@ -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(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue