mirror of
https://github.com/ayozetr/bloodborne_linux.git
synced 2026-11-09 01:09:47 -10:00
Menu: checkboxes and sliders keep their changes with any compiler
Store(value, v, ImGui::Checkbox(label, &v)) read v before the checkbox had changed it on compilers that evaluate arguments left to right: C++ leaves the order unspecified. GCC happens to call the widget first, so our builds worked; clang lost every change. The widget now runs before Store. From Supermedo/bloodborne_pc#19 (5c660f9).
This commit is contained in:
1 parent
9e629d2efd
commit
542e9ada19
1 file changed
+4
-2
@@ -162,12 +162,14 @@ void Store(std::atomic<T>& target, T value, bool changed) {
|
||||
|
||||
void Checkbox(const char* label, std::atomic<bool>& value) {
|
||||
bool v = value;
|
||||
Store(value, v, ImGui::Checkbox(label, &v));
|
||||
const bool changed = ImGui::Checkbox(label, &v);
|
||||
Store(value, v, changed);
|
||||
}
|
||||
|
||||
void Slider(const char* label, std::atomic<float>& value, float lo, float hi) {
|
||||
float v = value;
|
||||
Store(value, v, ImGui::SliderFloat(label, &v, lo, hi, "%.2f"));
|
||||
const bool changed = ImGui::SliderFloat(label, &v, lo, hi, "%.2f");
|
||||
Store(value, v, changed);
|
||||
}
|
||||
|
||||
void Hint(const char* text) {
|
||||
|
||||
Reference in new issue
Block a user