mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-30 19:29:52 +02:00
committed by
Tamás Bálint Misius
parent
e6e4c2ed1d
commit
110250fe6a
@@ -350,7 +350,7 @@ unsigned int lastTick = 0;
|
|||||||
unsigned int lastFpsUpdate = 0;
|
unsigned int lastFpsUpdate = 0;
|
||||||
float fps = 0;
|
float fps = 0;
|
||||||
ui::Engine * engine = NULL;
|
ui::Engine * engine = NULL;
|
||||||
bool showDoubleScreenDialog = false;
|
bool showLargeScreenDialog = false;
|
||||||
float currentWidth, currentHeight;
|
float currentWidth, currentHeight;
|
||||||
|
|
||||||
int mousex = 0, mousey = 0;
|
int mousex = 0, mousey = 0;
|
||||||
@@ -480,12 +480,12 @@ void EventProcess(SDL_Event event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoubleScreenDialog()
|
void LargeScreenDialog()
|
||||||
{
|
{
|
||||||
StringBuilder message;
|
StringBuilder message;
|
||||||
message << "Switching to double size mode since your screen was determined to be large enough: ";
|
message << "Switching to " << scale << "x size mode since your screen was determined to be large enough: ";
|
||||||
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW*2 << "x" << WINDOWH*2 << " required";
|
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW*scale << "x" << WINDOWH*scale << " required";
|
||||||
message << "\nTo undo this, hit Cancel. You can toggle double size mode in settings at any time.";
|
message << "\nTo undo this, hit Cancel. You can change this in settings at any time.";
|
||||||
if (!ConfirmPrompt::Blocking("Large screen detected", message.Build()))
|
if (!ConfirmPrompt::Blocking("Large screen detected", message.Build()))
|
||||||
{
|
{
|
||||||
Client::Ref().SetPref("Scale", 1);
|
Client::Ref().SetPref("Scale", 1);
|
||||||
@@ -547,10 +547,10 @@ void EngineProcess()
|
|||||||
lastTick = frameStart;
|
lastTick = frameStart;
|
||||||
Client::Ref().Tick();
|
Client::Ref().Tick();
|
||||||
}
|
}
|
||||||
if (showDoubleScreenDialog)
|
if (showLargeScreenDialog)
|
||||||
{
|
{
|
||||||
showDoubleScreenDialog = false;
|
showLargeScreenDialog = false;
|
||||||
DoubleScreenDialog();
|
LargeScreenDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -633,6 +633,24 @@ void ChdirToDataDirectory()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr int SCALE_MAXIMUM = 10;
|
||||||
|
constexpr int SCALE_MARGIN = 30;
|
||||||
|
|
||||||
|
int GuessBestScale()
|
||||||
|
{
|
||||||
|
const int widthNoMargin = desktopWidth - SCALE_MARGIN;
|
||||||
|
const int widthGuess = widthNoMargin / WINDOWW;
|
||||||
|
|
||||||
|
const int heightNoMargin = desktopHeight - SCALE_MARGIN;
|
||||||
|
const int heightGuess = heightNoMargin / WINDOWH;
|
||||||
|
|
||||||
|
int guess = std::min(widthGuess, heightGuess);
|
||||||
|
if(guess < 1 || guess > SCALE_MAXIMUM)
|
||||||
|
guess = 1;
|
||||||
|
|
||||||
|
return guess;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG) && defined(_MSC_VER)
|
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||||
@@ -704,17 +722,20 @@ int main(int argc, char * argv[])
|
|||||||
Client::Ref().Initialise(proxyString, disableNetwork);
|
Client::Ref().Initialise(proxyString, disableNetwork);
|
||||||
|
|
||||||
// TODO: maybe bind the maximum allowed scale to screen size somehow
|
// TODO: maybe bind the maximum allowed scale to screen size somehow
|
||||||
if(scale < 1 || scale > 10)
|
if(scale < 1 || scale > SCALE_MAXIMUM)
|
||||||
scale = 1;
|
scale = 1;
|
||||||
|
|
||||||
SDLOpen();
|
SDLOpen();
|
||||||
// TODO: mabe make a nice loop that automagically finds the optimal scale
|
|
||||||
if (Client::Ref().IsFirstRun() && desktopWidth > WINDOWW*2+30 && desktopHeight > WINDOWH*2+30)
|
if (Client::Ref().IsFirstRun())
|
||||||
{
|
{
|
||||||
scale = 2;
|
scale = GuessBestScale();
|
||||||
Client::Ref().SetPref("Scale", 2);
|
if (scale > 1)
|
||||||
SDL_SetWindowSize(sdl_window, WINDOWW * 2, WINDOWH * 2);
|
{
|
||||||
showDoubleScreenDialog = true;
|
Client::Ref().SetPref("Scale", scale);
|
||||||
|
SDL_SetWindowSize(sdl_window, WINDOWW * scale, WINDOWH * scale);
|
||||||
|
showLargeScreenDialog = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OGLI
|
#ifdef OGLI
|
||||||
|
Reference in New Issue
Block a user