Skip to content

Commit

Permalink
show confirm dialog for double screen mode in case of false detections
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Feb 1, 2016
1 parent aa108be commit 36e8f6d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/PowderToy.h
Expand Up @@ -5,3 +5,4 @@ void EngineProcess();
void ClipboardPush(std::string text);
std::string ClipboardPull();
int GetModifiers();
bool LoadWindowPosition(int scale);
22 changes: 22 additions & 0 deletions src/PowderToySDL.cpp
Expand Up @@ -46,6 +46,7 @@ extern "C" {
#include "gui/game/GameView.h"

#include "gui/dialogues/ErrorMessage.h"
#include "gui/dialogues/ConfirmPrompt.h"
#include "gui/interface/Keys.h"
#include "gui/Style.h"

Expand Down Expand Up @@ -453,6 +454,7 @@ int elapsedTime = 0, currentTime = 0, lastTime = 0, currentFrame = 0;
unsigned int lastTick = 0;
float fps = 0, delta = 1.0f, inputScale = 1.0f;
ui::Engine * engine = NULL;
bool showDoubleScreenDialog = false;
float currentWidth, currentHeight;

void EventProcess(SDL_Event event)
Expand Down Expand Up @@ -573,6 +575,20 @@ void EventProcess(SDL_Event event)
}
}

void DoubleScreenDialog()
{
std::stringstream message;
message << "Switching to double size mode since your screen was determined to be large enough: ";
message << desktopWidth << "x" << desktopHeight << " detected, " << WINDOWW*2 << "x" << WINDOWH*2 << " required";
message << "\nTo undo this, hit Cancel. You can toggle double size mode in settings at any time.";
if (!ConfirmPrompt::Blocking("Large screen detected", message.str()))
{
Client::Ref().SetPref("Scale", 1);
engine->SetScale(1);
engine->CloseWindow();
LoadWindowPosition(1);
}
}
void EngineProcess()
{
double frameTimeAvg = 0.0f, correctedFrameTimeAvg = 0.0f;
Expand Down Expand Up @@ -625,6 +641,11 @@ void EngineProcess()
lastTick = frameStart;
Client::Ref().Tick();
}
if (showDoubleScreenDialog)
{
showDoubleScreenDialog = false;
DoubleScreenDialog();
}
}
#ifdef DEBUG
std::cout << "Breaking out of EngineProcess" << std::endl;
Expand Down Expand Up @@ -840,6 +861,7 @@ int main(int argc, char * argv[])
{
tempScale = 2;
Client::Ref().SetPref("Scale", 2);
showDoubleScreenDialog = true;
}
#ifdef WIN
LoadWindowPosition(tempScale);
Expand Down

0 comments on commit 36e8f6d

Please sign in to comment.