Skip to content
Permalink
Browse files

Get widths in order, various other things

  • Loading branch information...
LBPHacker committed Jul 4, 2019
1 parent bc5fd4f commit 5391fc3ee0352ec61df08b41f4ffb9f28ca1bd96
Showing with 125 additions and 78 deletions.
  1. +125 −78 src/gui/options/OptionsView.cpp
@@ -22,16 +22,36 @@
#include "graphics/Graphics.h"

OptionsView::OptionsView():
ui::Window(ui::Point(-1, -1), ui::Point(320, 389)){
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;
};

ui::Label * tempLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 14), "Simulation Options");
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;
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
autowidth(tempLabel);
AddComponent(tempLabel);

class Separator : public ui::Component
{
public:
Separator(ui::Point position, ui::Point size) : Component(position, size){}
virtual ~Separator(){}

void Draw(const ui::Point& screenPos)
{
GetGraphics()->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 180);
}
};

Separator *tmpSeparator = new Separator(ui::Point(0, 22), ui::Point(Size.X, 1));
AddComponent(tmpSeparator);

int currentY = 10;
scrollPanel = new ui::ScrollPanel(ui::Point(1, 17), ui::Point(Size.X-2, Size.Y-33));
int currentY = 6;
scrollPanel = new ui::ScrollPanel(ui::Point(1, 23), ui::Point(Size.X-2, Size.Y-39));

AddComponent(scrollPanel);

@@ -45,12 +65,15 @@ OptionsView::OptionsView():
}
};

heatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Heat simulation \bgIntroduced in version 34", "");
heatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Heat simulation \bgIntroduced in version 34", "");
autowidth(heatSimulation);
heatSimulation->SetActionCallback(new HeatSimulationAction(this));
scrollPanel->AddChild(heatSimulation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(Size.X-28, 16), "\bgCan cause odd behaviour when disabled");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
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);

class AmbientHeatSimulationAction: public ui::CheckboxAction
@@ -63,13 +86,16 @@ OptionsView::OptionsView():
}
};

currentY+=16;
ambientHeatSimulation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Ambient heat simulation \bgIntroduced in version 50", "");
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(new AmbientHeatSimulationAction(this));
scrollPanel->AddChild(ambientHeatSimulation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(Size.X-28, 16), "\bgCan cause odd / broken behaviour with many saves");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
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);

class NewtonianGravityAction: public ui::CheckboxAction
@@ -82,13 +108,16 @@ OptionsView::OptionsView():
}
};

currentY+=16;
newtonianGravity = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Newtonian gravity \bgIntroduced in version 48", "");
currentY+=16;
newtonianGravity = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Newtonian gravity \bgIntroduced in version 48", "");
autowidth(newtonianGravity);
newtonianGravity->SetActionCallback(new NewtonianGravityAction(this));
scrollPanel->AddChild(newtonianGravity);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(Size.X-28, 16), "\bgMay cause poor performance on older computers");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
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);

class WaterEqualisationAction: public ui::CheckboxAction
@@ -101,13 +130,16 @@ OptionsView::OptionsView():
}
};

currentY+=16;
waterEqualisation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Water equalisation \bgIntroduced in version 61", "");
currentY+=16;
waterEqualisation = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Water equalisation \bgIntroduced in version 61", "");
autowidth(waterEqualisation);
waterEqualisation->SetActionCallback(new WaterEqualisationAction(this));
scrollPanel->AddChild(waterEqualisation);
currentY+=14;
tempLabel = new ui::Label(ui::Point(24, currentY), ui::Point(Size.X-28, 16), "\bgMay cause poor performance with a lot of water");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
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);

class AirModeChanged: public ui::DropDownAction
@@ -119,7 +151,7 @@ OptionsView::OptionsView():
v->c->SetAirMode(option.second);
}
};
currentY+=19;
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));
@@ -130,7 +162,8 @@ OptionsView::OptionsView():
airMode->SetActionCallback(new AirModeChanged(this));

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;
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);

class GravityModeChanged: public ui::DropDownAction
@@ -143,7 +176,7 @@ OptionsView::OptionsView():
}
};

currentY+=20;
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));
@@ -152,7 +185,8 @@ OptionsView::OptionsView():
gravityMode->SetActionCallback(new GravityModeChanged(this));

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;
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);

class EdgeModeChanged: public ui::DropDownAction
@@ -164,7 +198,7 @@ OptionsView::OptionsView():
v->c->SetEdgeMode(option.second);
}
};
currentY+=20;
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));
@@ -173,23 +207,12 @@ OptionsView::OptionsView():
edgeMode->SetActionCallback(new EdgeModeChanged(this));

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;
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);

class Separator : public ui::Component
{
public:
Separator(ui::Point position, ui::Point size) : Component(position, size){}
virtual ~Separator(){}

void Draw(const ui::Point& screenPos)
{
GetGraphics()->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 180);
}
};

currentY+=20;
Separator *tmpSeparator = new Separator(ui::Point(0, currentY), ui::Point(Size.X, 1));
currentY+=20;
tmpSeparator = new Separator(ui::Point(0, currentY), ui::Point(Size.X, 1));
scrollPanel->AddChild(tmpSeparator);

class ScaleAction: public ui::DropDownAction
@@ -201,7 +224,7 @@ OptionsView::OptionsView():
v->c->SetScale(option.second);
}
};
currentY+=4;
currentY+=4;
scale = new ui::DropDown(ui::Point(8, currentY), ui::Point(40, 16));
{
int current_scale = ui::Engine::Ref().GetScale();
@@ -221,8 +244,9 @@ OptionsView::OptionsView():
scale->SetActionCallback(new ScaleAction(this));
scrollPanel->AddChild(scale);

tempLabel = new ui::Label(ui::Point(scale->Position.X+scale->Size.X+3, currentY), ui::Point(Size.X-28, 16), "\bg- Window scale factor for larger screens");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
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);


@@ -236,11 +260,14 @@ OptionsView::OptionsView():
v->c->SetResizable(sender->GetChecked());
}
};
currentY+=20;
resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Resizable", "");
currentY+=20;
resizable = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Resizable", "");
autowidth(resizable);
resizable->SetActionCallback(new ResizableAction(this));
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::textwidth(resizable->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- Allow resizing and maximizing window");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(resizable->Position.X+Graphics::textwidth(resizable->GetText())+20, 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);

@@ -255,11 +282,14 @@ OptionsView::OptionsView():
}
};

currentY+=20;
fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Fullscreen", "");
currentY+=20;
fullscreen = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fullscreen", "");
autowidth(fullscreen);
fullscreen->SetActionCallback(new FullscreenAction(this));
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- Fill the entire screen");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(fullscreen->Position.X+Graphics::textwidth(fullscreen->GetText())+20, 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);

@@ -273,11 +303,14 @@ OptionsView::OptionsView():
v->c->SetAltFullscreen(sender->GetChecked());
}
};
currentY+=20;
altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(Size.X-6, 16), "Change Resolution", "");
currentY+=20;
altFullscreen = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Change Resolution", "");
autowidth(altFullscreen);
altFullscreen->SetActionCallback(new AltFullscreenAction(this));
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(altFullscreen->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- Set optimial screen resolution");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(altFullscreen->GetText())+20, currentY), ui::Point(1, 16), "\bg- Set optimial screen resolution");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);
scrollPanel->AddChild(altFullscreen);

@@ -292,11 +325,14 @@ OptionsView::OptionsView():
}
};

currentY+=20;
forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(Size.X-6, 16), "Force Integer Scaling", "");
currentY+=20;
forceIntegerScaling = new ui::Checkbox(ui::Point(23, currentY), ui::Point(1, 16), "Force Integer Scaling", "");
autowidth(forceIntegerScaling);
forceIntegerScaling->SetActionCallback(new ForceIntegerScalingAction(this));
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(forceIntegerScaling->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- less blurry");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(altFullscreen->Position.X+Graphics::textwidth(forceIntegerScaling->GetText())+20, 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);

@@ -310,11 +346,14 @@ OptionsView::OptionsView():
v->c->SetFastQuit(sender->GetChecked());
}
};
currentY+=20;
fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Fast Quit", "");
currentY+=20;
fastquit = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Fast Quit", "");
autowidth(fastquit);
fastquit->SetActionCallback(new FastQuitAction(this));
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- Always exit completely when hitting close");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(fastquit->Position.X+Graphics::textwidth(fastquit->GetText())+20, 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);

@@ -327,11 +366,14 @@ OptionsView::OptionsView():
v->c->SetShowAvatars(sender->GetChecked());
}
};
currentY+=20;
showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Show Avatars", "");
currentY+=20;
showAvatars = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Show Avatars", "");
autowidth(showAvatars);
showAvatars->SetActionCallback(new ShowAvatarsAction(this));
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- Disable if you have a slow connection");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(showAvatars->Position.X+Graphics::textwidth(showAvatars->GetText())+20, 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);

@@ -344,11 +386,14 @@ OptionsView::OptionsView():
v->c->SetMouseClickrequired(sender->GetChecked());
}
};
currentY+=20;
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(Size.X-6, 16), "Sticky Categories", "");
currentY+=20;
mouseClickRequired = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Sticky Categories", "");
autowidth(mouseClickRequired);
mouseClickRequired->SetActionCallback(new MouseClickRequiredAction(this));
tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::textwidth(mouseClickRequired->GetText().c_str())+20, currentY), ui::Point(Size.X-28, 16), "\bg- Switch between categories by clicking");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(mouseClickRequired->Position.X+Graphics::textwidth(mouseClickRequired->GetText())+20, 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);

@@ -373,13 +418,15 @@ OptionsView::OptionsView():
delete[] workingDirectory;
}
};
currentY+=20;
currentY+=20;
ui::Button * dataFolderButton = new ui::Button(ui::Point(8, currentY), ui::Point(90, 16), "Open Data Folder");
dataFolderButton->SetActionCallback(new DataFolderAction());
scrollPanel->AddChild(dataFolderButton);

tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, currentY), ui::Point(Size.X-28, 16), "\bg- Open the data and preferences folder");
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
tempLabel = new ui::Label(ui::Point(dataFolderButton->Position.X+dataFolderButton->Size.X+3, currentY), ui::Point(1, 16), "\bg- Open the data and preferences folder");
autowidth(tempLabel);
tempLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tempLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
scrollPanel->AddChild(tempLabel);

class CloseAction: public ui::ButtonAction
@@ -398,7 +445,7 @@ OptionsView::OptionsView():
AddComponent(tempButton);
SetCancelButton(tempButton);
SetOkayButton(tempButton);
currentY+=20;
currentY+=20;
scrollPanel->InnerSize = ui::Point(Size.X, currentY);
}

0 comments on commit 5391fc3

Please sign in to comment.
You can’t perform that action at this time.