Make Grave (the key under Esc) exiting the console optional

Also fix perfectCirclePressure copypasta.
This commit is contained in:
Tamás Bálint Misius 2023-06-11 18:52:18 +02:00
parent d296cf5d77
commit 958ab1df96
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
9 changed files with 45 additions and 8 deletions

View File

@ -277,6 +277,7 @@ int main(int argc, char * argv[])
auto &prefs = GlobalPrefs::Ref();
scale = prefs.Get("Scale", 1);
auto graveExitsConsole = prefs.Get("GraveExitsConsole", true);
resizable = prefs.Get("Resizable", false);
fullscreen = prefs.Get("Fullscreen", false);
altFullscreen = prefs.Get("AltFullscreen", false);
@ -381,6 +382,7 @@ int main(int argc, char * argv[])
auto &engine = ui::Engine::Ref();
engine.g = new Graphics();
engine.Scale = scale;
engine.GraveExitsConsole = graveExitsConsole;
engine.SetResizable(resizable);
engine.Fullscreen = fullscreen;
engine.SetAltFullscreen(altFullscreen);

View File

@ -5,6 +5,7 @@
#include "ConsoleCommand.h"
#include "gui/interface/Label.h"
#include "gui/interface/Textbox.h"
#include "gui/interface/Engine.h"
#include "SimulationConfig.h"
#include <deque>
#include <SDL.h>
@ -24,7 +25,7 @@ ConsoleView::ConsoleView():
void ConsoleView::DoKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt)
{
if ((scan == SDL_SCANCODE_GRAVE && key != '~') || key == SDLK_ESCAPE)
if ((ui::Engine::Ref().GraveExitsConsole && scan == SDL_SCANCODE_GRAVE && key != '~') || key == SDLK_ESCAPE)
{
if (!repeat)
doClose = true;

View File

@ -82,6 +82,7 @@ namespace ui
int drawingFrequencyLimit;
Graphics * g;
int Scale;
bool GraveExitsConsole;
bool Fullscreen;
unsigned int FrameIndex;

View File

@ -97,6 +97,11 @@ void OptionsController::SetScale(int scale)
model->SetScale(scale);
}
void OptionsController::SetGraveExitsConsole(bool graveExitsConsole)
{
model->SetGraveExitsConsole(graveExitsConsole);
}
void OptionsController::SetResizable(bool resizable)
{
model->SetResizable(resizable);

View File

@ -28,6 +28,7 @@ public:
void SetAltFullscreen(bool altFullscreen);
void SetForceIntegerScaling(bool forceIntegerScaling);
void SetScale(int scale);
void SetGraveExitsConsole(bool graveExitsConsole);
void SetResizable(bool resizable);
void SetFastQuit(bool fastquit);
void SetDecoSpace(int decoSpace);

View File

@ -156,6 +156,18 @@ void OptionsModel::SetScale(int scale)
notifySettingsChanged();
}
bool OptionsModel::GetGraveExitsConsole()
{
return ui::Engine::Ref().GraveExitsConsole;
}
void OptionsModel::SetGraveExitsConsole(bool graveExitsConsole)
{
ui::Engine::Ref().GraveExitsConsole = graveExitsConsole;
GlobalPrefs::Ref().Set("GraveExitsConsole", graveExitsConsole);
notifySettingsChanged();
}
bool OptionsModel::GetResizable()
{
return ui::Engine::Ref().GetResizable();

View File

@ -39,6 +39,8 @@ public:
void SetCustomGravityY(float y);
int GetScale();
void SetScale(int scale);
bool GetGraveExitsConsole();
void SetGraveExitsConsole(bool graveExitsConsole);
bool GetResizable();
void SetResizable(bool resizable);
bool GetFullscreen();

View File

@ -377,15 +377,26 @@ OptionsView::OptionsView():
scrollPanel->AddChild(includePressure);
currentY+=20;
perfectCirclePressure = new ui::Checkbox(ui::Point(8, currentY), ui::Point(1, 16), "Perfect Circle", "");
autowidth(perfectCirclePressure);
perfectCirclePressure->SetActionCallback({ [this] { c->SetPerfectCircle(perfectCirclePressure->GetChecked()); } });
tempLabel = new ui::Label(ui::Point(perfectCirclePressure->Position.X+Graphics::TextSize(perfectCirclePressure->GetText()).X+19, currentY), ui::Point(1, 16), "\bg- Better circle brush, without incorrect points on edges");
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(perfectCirclePressure);
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));
@ -528,7 +539,8 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
showAvatars->SetChecked(sender->GetShowAvatars());
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
includePressure->SetChecked(sender->GetIncludePressure());
perfectCirclePressure->SetChecked(sender->GetPerfectCircle());
perfectCircle->SetChecked(sender->GetPerfectCircle());
graveExitsConsole->SetChecked(sender->GetGraveExitsConsole());
momentumScroll->SetChecked(sender->GetMomentumScroll());
}

View File

@ -37,7 +37,8 @@ class OptionsView: public ui::Window
ui::Checkbox * momentumScroll;
ui::Checkbox * mouseClickRequired;
ui::Checkbox * includePressure;
ui::Checkbox * perfectCirclePressure;
ui::Checkbox * perfectCircle;
ui::Checkbox * graveExitsConsole;
ui::ScrollPanel * scrollPanel;
float customGravityX, customGravityY;
void UpdateAmbientAirTempPreview(float airTemp, bool isValid);