Normalise GetPrefs

This commit is contained in:
Tamás Bálint Misius 2021-04-18 11:04:38 +02:00
parent 60395f50f6
commit 2a23a38120
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
7 changed files with 32 additions and 24 deletions

View File

@ -68,6 +68,7 @@ bool altFullscreen = false;
bool forceIntegerScaling = true; bool forceIntegerScaling = true;
bool resizable = false; bool resizable = false;
bool momentumScroll = true; bool momentumScroll = true;
bool showAvatars = true;
void StartTextInput() void StartTextInput()
{ {
@ -202,6 +203,7 @@ void SDLOpen()
} }
if (Client::Ref().GetPrefBool("AutoDrawLimit", false)) if (Client::Ref().GetPrefBool("AutoDrawLimit", false))
{ {
ui::Engine::Ref().AutoDrawingFrequencyLimit = true;
SDL_DisplayMode displayMode; SDL_DisplayMode displayMode;
if (!SDL_GetCurrentDisplayMode(displayIndex, &displayMode) && displayMode.refresh_rate >= 60) if (!SDL_GetCurrentDisplayMode(displayIndex, &displayMode) && displayMode.refresh_rate >= 60)
{ {
@ -786,6 +788,7 @@ int main(int argc, char * argv[])
altFullscreen = Client::Ref().GetPrefBool("AltFullscreen", false); altFullscreen = Client::Ref().GetPrefBool("AltFullscreen", false);
forceIntegerScaling = Client::Ref().GetPrefBool("ForceIntegerScaling", true); forceIntegerScaling = Client::Ref().GetPrefBool("ForceIntegerScaling", true);
momentumScroll = Client::Ref().GetPrefBool("MomentumScroll", true); momentumScroll = Client::Ref().GetPrefBool("MomentumScroll", true);
showAvatars = Client::Ref().GetPrefBool("ShowAvatars", true);
if(arguments["kiosk"] == "true") if(arguments["kiosk"] == "true")
@ -824,9 +827,13 @@ int main(int argc, char * argv[])
Client::Ref().SetPref("Proxy", arguments["proxy"]); Client::Ref().SetPref("Proxy", arguments["proxy"]);
} }
} }
else if(Client::Ref().GetPrefString("Proxy", "").length()) else
{ {
proxyString = (Client::Ref().GetPrefByteString("Proxy", "")); auto proxyPref = Client::Ref().GetPrefByteString("Proxy", "");
if (proxyPref.length())
{
proxyString = proxyPref;
}
} }
bool disableNetwork = false; bool disableNetwork = false;
@ -870,7 +877,8 @@ int main(int argc, char * argv[])
ui::Engine::Ref().Fullscreen = fullscreen; ui::Engine::Ref().Fullscreen = fullscreen;
ui::Engine::Ref().SetAltFullscreen(altFullscreen); ui::Engine::Ref().SetAltFullscreen(altFullscreen);
ui::Engine::Ref().SetForceIntegerScaling(forceIntegerScaling); ui::Engine::Ref().SetForceIntegerScaling(forceIntegerScaling);
ui::Engine::Ref().SetMomentumScroll(momentumScroll); ui::Engine::Ref().MomentumScroll = momentumScroll;
ui::Engine::Ref().ShowAvatars = showAvatars;
engine = &ui::Engine::Ref(); engine = &ui::Engine::Ref();
engine->SetMaxSize(desktopWidth, desktopHeight); engine->SetMaxSize(desktopWidth, desktopHeight);

View File

@ -216,6 +216,10 @@ public:
bool GetIncludePressure(); bool GetIncludePressure();
void SetIncludePressure(bool includePressure); void SetIncludePressure(bool includePressure);
void SetPerfectCircle(bool perfectCircle); void SetPerfectCircle(bool perfectCircle);
inline bool GetPerfectCircle() const
{
return perfectCircle;
}
std::vector<Notification*> GetNotifications(); std::vector<Notification*> GetNotifications();
void AddNotification(Notification * notification); void AddNotification(Notification * notification);

View File

@ -35,8 +35,7 @@ Engine::Engine():
mousexp_(0), mousexp_(0),
mouseyp_(0), mouseyp_(0),
maxWidth(0), maxWidth(0),
maxHeight(0), maxHeight(0)
momentumScroll(false)
{ {
} }

View File

@ -135,15 +135,9 @@ namespace ui
String textEditingBuf; String textEditingBuf;
public: public:
inline void SetMomentumScroll(bool newMomentumScroll) bool MomentumScroll = true;
{ bool AutoDrawingFrequencyLimit = false;
momentumScroll = newMomentumScroll; bool ShowAvatars = true;
}
inline bool GetMomentumScroll() const
{
return momentumScroll;
}
}; };
} }

View File

@ -45,7 +45,7 @@ void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d)
{ {
if (!d) if (!d)
return; return;
if (ui::Engine::Ref().GetMomentumScroll()) if (ui::Engine::Ref().MomentumScroll)
yScrollVel -= d * 2; yScrollVel -= d * 2;
else else
yScrollVel -= d * 20; yScrollVel -= d * 20;
@ -143,7 +143,7 @@ void ScrollPanel::XTick(float dt)
offsetX += xScrollVel; offsetX += xScrollVel;
if (ui::Engine::Ref().GetMomentumScroll()) if (ui::Engine::Ref().MomentumScroll)
{ {
if (yScrollVel > -0.5f && yScrollVel < 0.5) if (yScrollVel > -0.5f && yScrollVel < 0.5)
yScrollVel = 0; yScrollVel = 0;

View File

@ -181,18 +181,19 @@ void OptionsModel::SetDecoSpace(int decoSpace)
bool OptionsModel::GetShowAvatars() bool OptionsModel::GetShowAvatars()
{ {
return Client::Ref().GetPrefBool("ShowAvatars", true); return ui::Engine::Ref().ShowAvatars;
} }
void OptionsModel::SetShowAvatars(bool state) void OptionsModel::SetShowAvatars(bool state)
{ {
ui::Engine::Ref().ShowAvatars = state;
Client::Ref().SetPref("ShowAvatars", state); Client::Ref().SetPref("ShowAvatars", state);
notifySettingsChanged(); notifySettingsChanged();
} }
bool OptionsModel::GetMouseClickRequired() bool OptionsModel::GetMouseClickRequired()
{ {
return Client::Ref().GetPrefBool("MouseClickRequired", false); return gModel->GetMouseClickRequired();
} }
void OptionsModel::SetMouseClickRequired(bool mouseClickRequired) void OptionsModel::SetMouseClickRequired(bool mouseClickRequired)
@ -204,7 +205,7 @@ void OptionsModel::SetMouseClickRequired(bool mouseClickRequired)
bool OptionsModel::GetIncludePressure() bool OptionsModel::GetIncludePressure()
{ {
return Client::Ref().GetPrefBool("Simulation.IncludePressure", true); return gModel->GetIncludePressure();
} }
void OptionsModel::SetIncludePressure(bool includePressure) void OptionsModel::SetIncludePressure(bool includePressure)
@ -216,7 +217,7 @@ void OptionsModel::SetIncludePressure(bool includePressure)
bool OptionsModel::GetPerfectCircle() bool OptionsModel::GetPerfectCircle()
{ {
return Client::Ref().GetPrefBool("PerfectCircleBrush", true); return gModel->GetPerfectCircle();
} }
void OptionsModel::SetPerfectCircle(bool perfectCircle) void OptionsModel::SetPerfectCircle(bool perfectCircle)
@ -228,23 +229,24 @@ void OptionsModel::SetPerfectCircle(bool perfectCircle)
bool OptionsModel::GetMomentumScroll() bool OptionsModel::GetMomentumScroll()
{ {
return Client::Ref().GetPrefBool("MomentumScroll", true); return ui::Engine::Ref().MomentumScroll;
} }
void OptionsModel::SetMomentumScroll(bool state) void OptionsModel::SetMomentumScroll(bool state)
{ {
Client::Ref().SetPref("MomentumScroll", state); Client::Ref().SetPref("MomentumScroll", state);
ui::Engine::Ref().SetMomentumScroll(state); ui::Engine::Ref().MomentumScroll = state;
notifySettingsChanged(); notifySettingsChanged();
} }
bool OptionsModel::GetAutoDrawLimit() bool OptionsModel::GetAutoDrawLimit()
{ {
return Client::Ref().GetPrefBool("AutoDrawLimit", false); return ui::Engine::Ref().AutoDrawingFrequencyLimit;
} }
void OptionsModel::SetAutoDrawLimit(bool state) void OptionsModel::SetAutoDrawLimit(bool state)
{ {
ui::Engine::Ref().AutoDrawingFrequencyLimit = state;
Client::Ref().SetPref("AutoDrawLimit", state); Client::Ref().SetPref("AutoDrawLimit", state);
notifySettingsChanged(); notifySettingsChanged();
} }

View File

@ -16,6 +16,7 @@
#include "gui/interface/CopyTextButton.h" #include "gui/interface/CopyTextButton.h"
#include "gui/interface/Label.h" #include "gui/interface/Label.h"
#include "gui/interface/Textbox.h" #include "gui/interface/Textbox.h"
#include "gui/interface/Engine.h"
#include "gui/dialogues/ErrorMessage.h" #include "gui/dialogues/ErrorMessage.h"
#include "gui/interface/Point.h" #include "gui/interface/Point.h"
#include "gui/interface/Window.h" #include "gui/interface/Window.h"
@ -45,7 +46,7 @@ PreviewView::PreviewView():
commentBoxHeight(20), commentBoxHeight(20),
commentHelpText(false) commentHelpText(false)
{ {
showAvatars = Client::Ref().GetPrefBool("ShowAvatars", true); showAvatars = ui::Engine::Ref().ShowAvatars;
favButton = new ui::Button(ui::Point(50, Size.Y-19), ui::Point(51, 19), "Fav"); favButton = new ui::Button(ui::Point(50, Size.Y-19), ui::Point(51, 19), "Fav");
favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;