summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-05 16:31:49 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-05 16:31:49 (GMT)
commitd61690bc091af0e253abe18832cc06f6c998724a (patch)
treebc152e2abb2790d03d9c24b9576954d307fbcafc /src
parentd379390d066add46513da73a690ef20414b6627b (diff)
downloadpowder-d61690bc091af0e253abe18832cc06f6c998724a.zip
powder-d61690bc091af0e253abe18832cc06f6c998724a.tar.gz
Prevent setting double scale on smaller screens. Fixes #166
Diffstat (limited to 'src')
-rw-r--r--src/PowderToySDL.cpp6
-rw-r--r--src/dialogues/ErrorMessage.cpp8
-rw-r--r--src/interface/DropDown.cpp2
-rw-r--r--src/interface/Engine.cpp8
-rw-r--r--src/interface/Engine.h7
-rw-r--r--src/options/OptionsController.cpp15
6 files changed, 42 insertions, 4 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
index 61ca94d..75c1861 100644
--- a/src/PowderToySDL.cpp
+++ b/src/PowderToySDL.cpp
@@ -50,6 +50,8 @@ using namespace std;
extern "C" IMAGE_DOS_HEADER __ImageBase;
#endif
+int desktopWidth = 1280, desktopHeight = 1024;
+
SDL_Surface * sdl_scrn;
int scale = 1;
bool fullscreen = false;
@@ -173,6 +175,9 @@ int SDLOpen()
fprintf(stderr, "Initializing SDL: %s\n", SDL_GetError());
return 1;
}
+ const SDL_VideoInfo * vidInfo = SDL_GetVideoInfo();
+ desktopWidth = vidInfo->current_w;
+ desktopHeight = vidInfo->current_h;
SDL_EnableUNICODE(1);
#if defined(WIN) && defined(WINCONSOLE)
//On Windows, SDL redirects stdout to stdout.txt, which can be annoying when debugging, here we redirect back to the console
@@ -492,6 +497,7 @@ int main(int argc, char * argv[])
ui::Engine::Ref().Fullscreen = fullscreen;
engine = &ui::Engine::Ref();
+ engine->SetMaxSize(desktopWidth, desktopHeight);
engine->Begin(XRES+BARSIZE, YRES+MENUSIZE);
GameController * gameController = new GameController();
diff --git a/src/dialogues/ErrorMessage.cpp b/src/dialogues/ErrorMessage.cpp
index 083e541..796e37b 100644
--- a/src/dialogues/ErrorMessage.cpp
+++ b/src/dialogues/ErrorMessage.cpp
@@ -12,7 +12,7 @@
#include "PowderToy.h"
ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessageCallback * callback_):
- ui::Window(ui::Point(-1, -1), ui::Point(200, 75)),
+ ui::Window(ui::Point(-1, -1), ui::Point(200, 35)),
callback(callback_)
{
ui::Label * titleLabel = new ui::Label(ui::Point(4, 5), ui::Point(Size.X-8, 16), title);
@@ -21,11 +21,15 @@ ErrorMessage::ErrorMessage(std::string title, std::string message, ErrorMessage
titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(titleLabel);
- ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(Size.X-8, 60), message);
+ ui::Label * messageLabel = new ui::Label(ui::Point(4, 24), ui::Point(Size.X-8, -1), message);
+ messageLabel->SetMultiline(true);
messageLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
messageLabel->Appearance.VerticalAlign = ui::Appearance::AlignTop;
AddComponent(messageLabel);
+ Size.Y += messageLabel->Size.Y+12;
+ Position.Y = (ui::Engine::Ref().GetHeight()-Size.Y)/2;
+
class DismissAction: public ui::ButtonAction
{
ErrorMessage * message;
diff --git a/src/interface/DropDown.cpp b/src/interface/DropDown.cpp
index 7e8ee7f..0b05aac 100644
--- a/src/interface/DropDown.cpp
+++ b/src/interface/DropDown.cpp
@@ -88,7 +88,7 @@ DropDown::DropDown(Point position, Point size):
void DropDown::OnMouseClick(int x, int y, unsigned int button)
{
DropDownWindow * newWindow = new DropDownWindow(this);
- ui::Engine().Ref().ShowWindow(newWindow);
+ ui::Engine::Ref().ShowWindow(newWindow);
}
void DropDown::Draw(const Point& screenPos)
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index 1a8ad95..044b5e5 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -14,6 +14,8 @@ using namespace std;
Engine::Engine():
state_(NULL),
+ maxWidth(0),
+ maxHeight(0),
mousex_(0),
mousey_(0),
mousexp_(0),
@@ -148,6 +150,12 @@ void Engine::SetSize(int width, int height)
height_ = height;
}
+void Engine::SetMaxSize(int width, int height)
+{
+ maxWidth = width;
+ maxHeight = height;
+}
+
void Engine::Tick()
{
if(state_ != NULL)
diff --git a/src/interface/Engine.h b/src/interface/Engine.h
index e9c4354..bcf10e6 100644
--- a/src/interface/Engine.h
+++ b/src/interface/Engine.h
@@ -57,6 +57,10 @@ namespace ui
inline int GetMouseY() { return mousey_; }
inline int GetWidth() { return width_; }
inline int GetHeight() { return height_; }
+ inline int GetMaxWidth() { return maxWidth; }
+ inline int GetMaxHeight() { return maxHeight; }
+
+ inline void SetMaxSize(int width, int height);
inline void SetSize(int width, int height);
@@ -90,6 +94,9 @@ namespace ui
int mouseyp_;
int width_;
int height_;
+
+ int maxWidth;
+ int maxHeight;
};
}
diff --git a/src/options/OptionsController.cpp b/src/options/OptionsController.cpp
index 93d3062..add8cf7 100644
--- a/src/options/OptionsController.cpp
+++ b/src/options/OptionsController.cpp
@@ -6,6 +6,7 @@
*/
#include "OptionsController.h"
+#include "dialogues/ErrorMessage.h"
OptionsController::OptionsController(Simulation * sim, ControllerCallback * callback_):
callback(callback_),
@@ -61,7 +62,19 @@ void OptionsController::SetFullscreen(bool fullscreen)
void OptionsController::SetScale(bool scale)
{
- model->SetScale(scale);
+ if(scale)
+ {
+ if(ui::Engine::Ref().GetMaxWidth() >= ui::Engine::Ref().GetWidth() * 2 && ui::Engine::Ref().GetMaxHeight() >= ui::Engine::Ref().GetHeight() * 2)
+ model->SetScale(scale);
+ else
+ {
+ new ErrorMessage("Screen resolution error", "Your screen size is too small to use this scale mode.");
+ model->SetScale(false);
+ }
+ }
+ else
+ model->SetScale(scale);
+
}
OptionsView * OptionsController::GetView()