mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-19 06:31:26 +02:00
Fix issues with render ui checkboxes: (fixes #970)
Render mode checkboxes each control multiple bit flags, but they would fully unset all bits they control, even if they shared flags with other render modes (which they always do). This would cause more things to turn off than intended when deselecting options, and all other checkboxes would appear unchecked. Now it will recalculate render mode based on what's checked instead. Air display mode checkboxes are supposed to act as radio buttons, but it was letting all air modes be selected at once. They are mutually exclusive because only one display background can be drawn at once. Now, they act as exclusive radio buttons again.
This commit is contained in:
@@ -50,15 +50,7 @@ RenderView::RenderView():
|
||||
renderModeCheckbox->mode = mode;
|
||||
renderModeCheckbox->SetIcon(icon);
|
||||
renderModeCheckbox->SetActionCallback({ [this, renderModeCheckbox] {
|
||||
auto renderMode = c->GetRenderMode();
|
||||
if (renderModeCheckbox->GetChecked())
|
||||
{
|
||||
renderMode |= renderModeCheckbox->mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderMode &= ~renderModeCheckbox->mode;
|
||||
}
|
||||
auto renderMode = CalculateRenderMode();
|
||||
c->SetRenderMode(renderMode);
|
||||
} });
|
||||
AddComponent(renderModeCheckbox);
|
||||
@@ -78,6 +70,11 @@ RenderView::RenderView():
|
||||
displayModeCheckbox->SetIcon(icon);
|
||||
displayModeCheckbox->SetActionCallback({ [this, displayModeCheckbox] {
|
||||
auto displayMode = c->GetDisplayMode();
|
||||
// Air display modes are mutually exclusive
|
||||
if (displayModeCheckbox->mode & DISPLAY_AIR)
|
||||
{
|
||||
displayMode &= ~DISPLAY_AIR;
|
||||
}
|
||||
if (displayModeCheckbox->GetChecked())
|
||||
{
|
||||
displayMode |= displayModeCheckbox->mode;
|
||||
@@ -128,6 +125,18 @@ RenderView::RenderView():
|
||||
line4 = 340;
|
||||
}
|
||||
|
||||
uint32_t RenderView::CalculateRenderMode()
|
||||
{
|
||||
uint32_t renderMode = 0;
|
||||
for (auto &checkbox : renderModes)
|
||||
{
|
||||
if (checkbox->GetChecked())
|
||||
renderMode |= checkbox->mode;
|
||||
}
|
||||
|
||||
return renderMode;
|
||||
}
|
||||
|
||||
void RenderView::OnMouseDown(int x, int y, unsigned button)
|
||||
{
|
||||
if(x > XRES || y < YRES)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "gui/interface/Window.h"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
class ModeCheckbox;
|
||||
@@ -21,6 +22,7 @@ class RenderView: public ui::Window {
|
||||
int toolTipPresence;
|
||||
bool isToolTipFadingIn;
|
||||
int line1, line2, line3, line4;
|
||||
uint32_t CalculateRenderMode();
|
||||
public:
|
||||
RenderView();
|
||||
void NotifyRendererChanged(RenderModel * sender);
|
||||
|
Reference in New Issue
Block a user