Make OptionsView somewhat more manageable

This commit is contained in:
Tamás Bálint Misius 2023-06-11 19:58:56 +02:00
parent 958ab1df96
commit 5b610f0b0e
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 210 additions and 326 deletions

View File

@ -23,20 +23,20 @@
#include <cmath>
#include <SDL.h>
OptionsView::OptionsView():
ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
{
auto autowidth = [this](ui::Component *c) {
c->Size.X = Size.X - c->Position.X - 12;
auto autoWidth = [this](ui::Component *c, int extra) {
c->Size.X = Size.X - c->Position.X - 12 - extra;
};
ui::Label * tempLabel = new ui::Label(ui::Point(4, 1), ui::Point(Size.X-8, 22), "Simulation Options");
tempLabel->SetTextColour(style::Colour::InformationTitle);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
autowidth(tempLabel);
AddComponent(tempLabel);
{
auto *label = new ui::Label(ui::Point(4, 1), ui::Point(Size.X-8, 22), "Simulation Options");
label->SetTextColour(style::Colour::InformationTitle);
label->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
label->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
autoWidth(label, 0);
AddComponent(label);
}
class Separator : public ui::Component
{
@ -53,74 +53,74 @@ OptionsView::OptionsView():
Separator *tmpSeparator = new Separator(ui::Point(0, 22), ui::Point(Size.X, 1));
AddComponent(tmpSeparator);
int currentY = 6;
scrollPanel = new ui::ScrollPanel(ui::Point(1, 23), ui::Point(Size.X-2, Size.Y-39));
AddComponent(scrollPanel);
heatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Heat simulation \bgIntroduced in version 34", "");
autowidth(heatSimulation);
heatSimulation->SetActionCallback({ [this] { c->SetHeatSimulation(heatSimulation->GetChecked()); } });
scrollPanel->AddChild(heatSimulation);
int currentY = 8;
auto addCheckbox = [this, &currentY, &autoWidth](int indent, String text, String info, std::function<void ()> action) {
auto *checkbox = new ui::Checkbox(ui::Point(8 + indent * 15, currentY), ui::Point(1, 16), text, "");
autoWidth(checkbox, 0);
checkbox->SetActionCallback({ action });
scrollPanel->AddChild(checkbox);
currentY += 14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgCan cause odd behaviour when disabled");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=16;
ambientHeatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Ambient heat simulation \bgIntroduced in version 50", "");
autowidth(ambientHeatSimulation);
ambientHeatSimulation->SetActionCallback({ [this] { c->SetAmbientHeatSimulation(ambientHeatSimulation->GetChecked()); } });
scrollPanel->AddChild(ambientHeatSimulation);
if (info.size())
{
auto *label = new ui::Label(ui::Point(22 + indent * 15, currentY), ui::Point(1, 16), "\bg" + info);
autoWidth(label, 0);
label->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
label->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(label);
currentY += 14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgCan cause odd / broken behaviour with many saves");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=16;
newtonianGravity = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Newtonian gravity \bgIntroduced in version 48", "");
autowidth(newtonianGravity);
newtonianGravity->SetActionCallback({ [this] { c->SetNewtonianGravity(newtonianGravity->GetChecked()); } });
scrollPanel->AddChild(newtonianGravity);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgMay cause poor performance on older computers");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=16;
waterEqualisation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Water equalisation \bgIntroduced in version 61", "");
autowidth(waterEqualisation);
waterEqualisation->SetActionCallback({ [this] { c->SetWaterEqualisation(waterEqualisation->GetChecked()); } });
scrollPanel->AddChild(waterEqualisation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(1, 16), "\bgMay cause poor performance with a lot of water");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=19;
airMode = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(airMode);
airMode->AddOption(std::pair<String, int>("On", 0));
airMode->AddOption(std::pair<String, int>("Pressure off", 1));
airMode->AddOption(std::pair<String, int>("Velocity off", 2));
airMode->AddOption(std::pair<String, int>("Off", 3));
airMode->AddOption(std::pair<String, int>("No Update", 4));
airMode->SetActionCallback({ [this] { c->SetAirMode(airMode->GetOption().second); } });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Air Simulation Mode");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
}
currentY += 4;
return checkbox;
};
auto addDropDown = [this, &currentY, &autoWidth](String info, std::vector<std::pair<String, int>> options, std::function<void ()> action) {
auto *dropDown = new ui::DropDown(ui::Point(Size.X - 95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(dropDown);
for (auto &option : options)
{
dropDown->AddOption(option);
}
dropDown->SetActionCallback({ action });
auto *label = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X - 96, 16), info);
label->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
label->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(label);
autoWidth(label, 85);
currentY += 20;
return dropDown;
};
auto addSeparator = [this, &currentY]() {
currentY += 6;
auto *separator = new Separator(ui::Point(0, currentY), ui::Point(Size.X, 1));
scrollPanel->AddChild(separator);
currentY += 11;
};
heatSimulation = addCheckbox(0, "Heat simulation \bgIntroduced in version 34", "Can cause odd behaviour when disabled", [this] {
c->SetHeatSimulation(heatSimulation->GetChecked());
});
newtonianGravity = addCheckbox(0, "Newtonian gravity \bgIntroduced in version 48", "May cause poor performance on older computers", [this] {
c->SetNewtonianGravity(newtonianGravity->GetChecked());
});
ambientHeatSimulation = addCheckbox(0, "Ambient heat simulation \bgIntroduced in version 50", "Can cause odd / broken behaviour with many saves", [this] {
c->SetAmbientHeatSimulation(ambientHeatSimulation->GetChecked());
});
waterEqualisation = addCheckbox(0, "Water equalisation \bgIntroduced in version 61", "May cause poor performance with a lot of water", [this] {
c->SetWaterEqualisation(waterEqualisation->GetChecked());
});
airMode = addDropDown("Air simulation mode", {
{ "On", 0 },
{ "Pressure off", 1 },
{ "Velocity off", 2 },
{ "Off", 3 },
{ "No update", 4 },
}, [this] {
c->SetAirMode(airMode->GetOption().second);
});
{
ambientAirTemp = new ui::Textbox(ui::Point(Size.X-95, currentY), ui::Point(60, 16));
ambientAirTemp->SetActionCallback({ [this] {
UpdateAirTemp(ambientAirTemp->GetText(), false);
@ -129,23 +129,14 @@ OptionsView::OptionsView():
UpdateAirTemp(ambientAirTemp->GetText(), true);
}});
scrollPanel->AddChild(ambientAirTemp);
ambientAirTempPreview = new ui::Button(ui::Point(Size.X-31, currentY), ui::Point(16, 16), "", "Preview");
scrollPanel->AddChild(ambientAirTempPreview);
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Ambient Air Temperature");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
auto *label = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Ambient air temperature");
label->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
label->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(label);
currentY += 20;
gravityMode = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(gravityMode);
gravityMode->AddOption(std::pair<String, int>("Vertical", 0));
gravityMode->AddOption(std::pair<String, int>("Off", 1));
gravityMode->AddOption(std::pair<String, int>("Radial", 2));
gravityMode->AddOption(std::pair<String, int>("Custom", 3));
}
class GravityWindow : public ui::Window
{
void OnTryExit(ExitMethod method) override
@ -210,237 +201,135 @@ OptionsView::OptionsView():
MakeActiveWindow();
}
};
gravityMode->SetActionCallback({ [this] {
gravityMode = addDropDown("Gravity simulation mode", {
{ "Vertical", 0 },
{ "Off", 1 },
{ "Radial", 2 },
{ "Custom", 3 },
}, [this] {
c->SetGravityMode(gravityMode->GetOption().second);
if (gravityMode->GetOption().second == 3)
new GravityWindow(ui::Point(-1, -1), 0.05f, 40, customGravityX, customGravityY, c);
} });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Gravity Simulation Mode");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
edgeMode = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(edgeMode);
edgeMode->AddOption(std::pair<String, int>("Void", 0));
edgeMode->AddOption(std::pair<String, int>("Solid", 1));
edgeMode->AddOption(std::pair<String, int>("Loop", 2));
edgeMode->SetActionCallback({ [this] { c->SetEdgeMode(edgeMode->GetOption().second); } });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Edge Mode");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
temperatureScale = new ui::DropDown(ui::Point(Size.X-95, currentY), ui::Point(80, 16));
scrollPanel->AddChild(temperatureScale);
temperatureScale->AddOption(std::pair<String, int>("Kelvin", 0));
temperatureScale->AddOption(std::pair<String, int>("Celsius", 1));
temperatureScale->AddOption(std::pair<String, int>("Fahrenheit", 2));
temperatureScale->SetActionCallback({ [this] { c->SetTemperatureScale(temperatureScale->GetOption().second); } });
tempLabel = new ui::Label(ui::Point(8, currentY), ui::Point(Size.X-96, 16), "Temperature Scale");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
tmpSeparator = new Separator(ui::Point(0, currentY), ui::Point(Size.X, 1));
scrollPanel->AddChild(tmpSeparator);
currentY+=4;
scale = new ui::DropDown(ui::Point(8, currentY), ui::Point(40, 16));
{
int current_scale = ui::Engine::Ref().GetScale();
int ix_scale = 1;
bool current_scale_valid = false;
new GravityWindow(ui::Point(-1, -1), 0.05f, 40, customGravityX, customGravityY, c);
}
});
edgeMode = addDropDown("Edge mode", {
{ "Void", 0 },
{ "Solid", 1 },
{ "Loop", 2 },
}, [this] {
c->SetEdgeMode(edgeMode->GetOption().second);
});
temperatureScale = addDropDown("Temperature scale", {
{ "Kelvin", 0 },
{ "Celsius", 1 },
{ "Fahrenheit", 2 },
}, [this] {
c->SetTemperatureScale(temperatureScale->GetOption().second);
});
addSeparator();
{
std::vector<std::pair<String, int>> options;
int currentScale = ui::Engine::Ref().GetScale();
int scaleIndex = 1;
bool currentScaleValid = false;
do
{
if (current_scale == ix_scale)
current_scale_valid = true;
scale->AddOption(std::pair<String, int>(String::Build(ix_scale), ix_scale));
ix_scale += 1;
if (currentScale == scaleIndex)
{
currentScaleValid = true;
}
while (desktopWidth >= GetGraphics()->Size().X * ix_scale && desktopHeight >= GetGraphics()->Size().Y * ix_scale);
if (!current_scale_valid)
scale->AddOption(std::pair<String, int>("current", current_scale));
options.push_back({ String::Build(scaleIndex), scaleIndex });
scaleIndex += 1;
}
scale->SetActionCallback({ [this] { c->SetScale(scale->GetOption().second); } });
scrollPanel->AddChild(scale);
while (desktopWidth >= GetGraphics()->Size().X * scaleIndex && desktopHeight >= GetGraphics()->Size().Y * scaleIndex);
if (!currentScaleValid)
{
options.push_back({ "current", currentScale });
}
scale = addDropDown("Window scale factor for larger screens", options, [this] {
c->SetScale(scale->GetOption().second);
});
}
resizable = addCheckbox(0, "Resizable \bg- allow resizing and maximizing window", "", [this] {
c->SetResizable(resizable->GetChecked());
});
fullscreen = addCheckbox(0, "Fullscreen \bg- fill the entire screen", "", [this] {
c->SetFullscreen(fullscreen->GetChecked());
});
altFullscreen = addCheckbox(1, "Set optimal screen resolution", "", [this] {
c->SetAltFullscreen(altFullscreen->GetChecked());
});
forceIntegerScaling = addCheckbox(1, "Force integer scaling \bg- less blurry", "", [this] {
c->SetForceIntegerScaling(forceIntegerScaling->GetChecked());
});
addSeparator();
fastquit = addCheckbox(0, "Fast quit", "Always exit completely when hitting close", [this] {
c->SetFastQuit(fastquit->GetChecked());
});
showAvatars = addCheckbox(0, "Show avatars", "Disable if you have a slow connection", [this] {
c->SetShowAvatars(showAvatars->GetChecked());
});
momentumScroll = addCheckbox(0, "Momentum (old) scrolling", "Accelerating instead of step scroll", [this] {
c->SetMomentumScroll(momentumScroll->GetChecked());
});
mouseClickRequired = addCheckbox(0, "Sticky categories", "Switch between categories by clicking", [this] {
c->SetMouseClickrequired(mouseClickRequired->GetChecked());
});
includePressure = addCheckbox(0, "Include pressure", "When saving, copying, stamping, etc.", [this] {
c->SetIncludePressure(includePressure->GetChecked());
});
perfectCircle = addCheckbox(0, "Perfect circle brush", "Better circle brush, without incorrect points on edges", [this] {
c->SetPerfectCircle(perfectCircle->GetChecked());
});
graveExitsConsole = addCheckbox(0, "Key under Esc exits console", "Disable if that key is 0 on your keyboard", [this] {
c->SetGraveExitsConsole(graveExitsConsole->GetChecked());
});
decoSpace = addDropDown("Colour space used by decoration tools", {
{ "sRGB", 0 },
{ "Linear", 1 },
{ "Gamma 2.2", 2 },
{ "Gamma 1.8", 3 },
}, [this] {
c->SetDecoSpace(decoSpace->GetOption().second);
});
tempLabel = new ui::Label(ui::Point(scale->Position.X+scale->Size.X+3, currentY), ui::Point(Size.X-40, 16), "\bg- Window scale factor for larger screens");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Resizable", "");
autowidth(resizable);
resizable->SetActionCallback({ [this] { c->SetResizable(resizable->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::TextSize(resizable->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Allow resizing and maximizing window");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(resizable);
currentY+=20;
fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fullscreen", "");
autowidth(fullscreen);
fullscreen->SetActionCallback({ [this] { c->SetFullscreen(fullscreen->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::TextSize(fullscreen->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Fill the entire screen");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(fullscreen);
currentY+=20;
altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Change Resolution", "");
autowidth(altFullscreen);
altFullscreen->SetActionCallback({ [this] { c->SetAltFullscreen(altFullscreen->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::TextSize(altFullscreen->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Set optimal screen resolution");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(altFullscreen);
currentY+=20;
forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Force Integer Scaling", "");
autowidth(forceIntegerScaling);
forceIntegerScaling->SetActionCallback({ [this] { c->SetForceIntegerScaling(forceIntegerScaling->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::TextSize(forceIntegerScaling->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Less blurry");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(forceIntegerScaling);
currentY+=20;
fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fast Quit", "");
autowidth(fastquit);
fastquit->SetActionCallback({ [this] { c->SetFastQuit(fastquit->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::TextSize(fastquit->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Always exit completely when hitting close");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(fastquit);
currentY+=20;
showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Show Avatars", "");
autowidth(showAvatars);
showAvatars->SetActionCallback({ [this] { c->SetShowAvatars(showAvatars->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::TextSize(showAvatars->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Disable if you have a slow connection");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(showAvatars);
currentY += 20;
momentumScroll = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Momentum/Old Scrolling", "");
autowidth(momentumScroll);
momentumScroll->SetActionCallback({ [this] { c->SetMomentumScroll(momentumScroll->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(momentumScroll->Position.X + Graphics::TextSize(momentumScroll->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Accelerating instead of step scroll");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(momentumScroll);
currentY+=20;
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
autowidth(mouseClickRequired);
mouseClickRequired->SetActionCallback({ [this] { c->SetMouseClickrequired(mouseClickRequired->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::TextSize(mouseClickRequired->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Switch between categories by clicking");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(mouseClickRequired);
currentY+=20;
includePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Include Pressure", "");
autowidth(includePressure);
includePressure->SetActionCallback({ [this] { c->SetIncludePressure(includePressure->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(includePressure->Position.X+Graphics::TextSize(includePressure->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- When saving, copying, stamping, etc.");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(includePressure);
currentY+=20;
perfectCircle = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Perfect Circle", "");
autowidth(perfectCircle);
perfectCircle->SetActionCallback({ [this] { c->SetPerfectCircle(perfectCircle->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(perfectCircle->Position.X+Graphics::TextSize(perfectCircle->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Better circle brush, without incorrect points on edges");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(perfectCircle);
currentY+=20;
graveExitsConsole = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Key Under Esc Exits Console", "");
autowidth(graveExitsConsole);
graveExitsConsole->SetActionCallback({ [this] { c->SetGraveExitsConsole(graveExitsConsole->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(graveExitsConsole->Position.X+Graphics::TextSize(graveExitsConsole->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Uncheck this if that key is 0 on your keyboard");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(graveExitsConsole);
currentY+=20;
decoSpace = new ui::DropDown(ui::Point(8, currentY), ui::Point(60, 16));
decoSpace->SetActionCallback({ [this] { c->SetDecoSpace(decoSpace->GetOption().second); } });
scrollPanel->AddChild(decoSpace);
decoSpace->AddOption(std::pair<String, int>("sRGB", 0));
decoSpace->AddOption(std::pair<String, int>("Linear", 1));
decoSpace->AddOption(std::pair<String, int>("Gamma 2.2", 2));
decoSpace->AddOption(std::pair<String, int>("Gamma 1.8", 3));
tempLabel = new ui::Label(ui::Point(decoSpace->Position.X+decoSpace->Size.X+3, currentY), ui::Point(Size.X-40, 16), "\bg- Colour space used by decoration tools");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
currentY+=20;
ui::Button * dataFolderButton = new ui::Button(ui::Point(8, currentY), ui::Point(90, 16), "Open Data Folder");
{
currentY += 4;
auto *dataFolderButton = new ui::Button(ui::Point(10, currentY), ui::Point(90, 16), "Open data folder");
dataFolderButton->SetActionCallback({ [] {
ByteString cwd = Platform::GetCwd();
if (!cwd.empty())
{
Platform::OpenURI(cwd);
}
else
fprintf(stderr, "cannot open data folder: Platform::GetCwd(...) failed\n");
{
std::cerr << "Cannot open data folder: Platform::GetCwd(...) failed" << std::endl;
}
} });
scrollPanel->AddChild(dataFolderButton);
ui::Button * migrationButton = new ui::Button(ui::Point(Size.X - 178, currentY), ui::Point(163, 16), "Migrate to shared data directory");
auto *migrationButton = new ui::Button(ui::Point(Size.X - 178, currentY), ui::Point(163, 16), "Migrate to shared data directory");
migrationButton->SetActionCallback({ [] {
ByteString from = Platform::originalCwd;
ByteString to = Platform::sharedCwd;
new ConfirmPrompt("Do Migration?", "This will migrate all stamps, saves, and scripts from\n\bt" + from.FromUtf8() + "\bw\nto the shared data directory at\n\bt" + to.FromUtf8() + "\bw\n\n" +
"Files that already exist will not be overwritten.", { [=] () {
new ConfirmPrompt("Do Migration?", "This will migrate all stamps, saves, and scripts from\n\bt" + from.FromUtf8() + "\bw\nto the shared data directory at\n\bt" + to.FromUtf8() + "\bw\n\n" + "Files that already exist will not be overwritten.", { [from, to]() {
String ret = Client::Ref().DoMigration(from, to);
new InformationMessage("Migration Complete", ret, false);
} });
} });
scrollPanel->AddChild(migrationButton);
ui::Button * tempButton = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
tempButton->SetActionCallback({ [this] { c->Exit(); } });
AddComponent(tempButton);
SetCancelButton(tempButton);
SetOkayButton(tempButton);
currentY+=20;
currentY += 26;
}
{
ui::Button *ok = new ui::Button(ui::Point(0, Size.Y-16), ui::Point(Size.X, 16), "OK");
ok->SetActionCallback({ [this] {
c->Exit();
} });
AddComponent(ok);
SetCancelButton(ok);
SetOkayButton(ok);
}
scrollPanel->InnerSize = ui::Point(Size.X, currentY);
}
@ -560,7 +449,3 @@ void OptionsView::OnTryExit(ExitMethod method)
{
c->Exit();
}
OptionsView::~OptionsView() {
}

View File

@ -50,5 +50,4 @@ public:
void AttachController(OptionsController * c_);
void OnDraw() override;
void OnTryExit(ExitMethod method) override;
virtual ~OptionsView();
};