diff options
author | rubidium <rubidium@openttd.org> | 2007-07-29 15:48:43 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-29 15:48:43 +0000 |
commit | 26c62dc5c055f53ad2387fae3b8f7190db5eedc7 (patch) | |
tree | fe8c8d75cb358acfec8aae960ce4451d5594f8d8 /src/gfx.cpp | |
parent | ab37af1da5e4e9812a9f1e96007d6ea578ddb039 (diff) | |
download | openttd-26c62dc5c055f53ad2387fae3b8f7190db5eedc7.tar.xz |
(svn r10723) -Codechange: dynamically sized (width) main toolbars and status bar for when the window becomes less than 640 pixels in width.
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r-- | src/gfx.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 45de29f68..5a1d8f00b 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -21,6 +21,7 @@ #include "texteff.hpp" #include "blitter/factory.hpp" #include "video/video_driver.hpp" +#include "window.h" byte _dirkeys; ///< 1 = left, 2 = up, 4 = right, 8 = down bool _fullscreen; @@ -1147,11 +1148,28 @@ void SetAnimatedMouseCursor(const AnimCursor *table) SwitchAnimatedCursor(); } -bool ChangeResInGame(int w, int h) +bool ChangeResInGame(int width, int height) { - return - (_screen.width == w && _screen.height == h) || - _video_driver->ChangeResolution(w, h); + bool ret = (_screen.width == width && _screen.height == height) || _video_driver->ChangeResolution(width, height); + + int new_width = min(_screen.width, 640); + Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); + if (w != NULL && new_width != w->width) { + ResizeWindow(w, new_width - w->width, 0); + + Window *w2 = FindWindowById(WC_STATUS_BAR, 0); + if (w2 != NULL) ResizeWindow(w2, max(new_width, 320) - w2->width, 0); + + WindowEvent e; + e.event = WE_RESIZE; + e.we.sizing.size.x = w->width; + e.we.sizing.size.y = w->height; + e.we.sizing.diff.x = new_width - w->width; + e.we.sizing.diff.y = 0; + w->wndproc(w, &e); + } + + return ret; } void ToggleFullScreen(bool fs) |