summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-08-16 21:02:06 +0000
committerdarkvater <darkvater@openttd.org>2004-08-16 21:02:06 +0000
commit31911a93255dbe14137b7ac1faeb405862bd2530 (patch)
tree9aaa10a76f27b3f53d5836ddb9573a69eef5eb17 /window.c
parent255a1ad941f4f852b65257cf179294ee4f5acdd4 (diff)
downloadopenttd-31911a93255dbe14137b7ac1faeb405862bd2530.tar.xz
(svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
-Feature: added callback feature to patches options
Diffstat (limited to 'window.c')
-rw-r--r--window.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/window.c b/window.c
index 0a8539603..19115e0ee 100644
--- a/window.c
+++ b/window.c
@@ -531,6 +531,16 @@ Window *AllocateWindowDesc(const WindowDesc *desc)
if (pt.x > _screen.width + 10 - desc->width)
pt.x = (_screen.width + 10 - desc->width) - 20;
pt.y = w->top + 10;
+ // open Build Toolbars and Terraforming Toolbar aligned
+ } else if (desc->cls == WC_BUILD_TOOLBAR || desc->cls == WC_SCEN_LAND_GEN) {
+ /* Override the position if a toolbar is opened according to the place of the maintoolbar
+ * The main toolbar (WC_MAIN_TOOLBAR) is 640px in width */
+ switch (_patches.toolbar_pos) {
+ case 1: pt.x = ((_screen.width + 640) >> 1) - desc->width; break;
+ case 2: pt.x = _screen.width - desc->width; break;
+ default: pt.x = 640 - desc->width;
+ }
+ pt.y = desc->top;
} else {
pt.x = desc->left;
pt.y = desc->top;
@@ -1013,7 +1023,7 @@ void MouseLoop()
}
if (click == 1) {
- DEBUG(misc, 1) ("cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
+ //DEBUG(misc, 1) ("cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
if (_thd.place_mode != 0 &&
// query button and place sign button work in pause mode
!(_cursor.sprite == 0x2CF || _cursor.sprite == 0x2D2) &&
@@ -1164,6 +1174,22 @@ void DeleteNonVitalWindows()
}
}
+int PositionMainToolbar(Window *w)
+{
+ //DEBUG(misc, 1) ("Repositioning Main Toolbar...");
+
+ if (w == NULL || w->window_class != WC_MAIN_TOOLBAR)
+ w = FindWindowById(WC_MAIN_TOOLBAR, 0);
+
+ switch (_patches.toolbar_pos) {
+ case 1: w->left = (_screen.width - w->width) >> 1; break;
+ case 2: w->left = _screen.width - w->width; break;
+ default: w->left = 0;
+ }
+ SetDirtyBlocks(0, 0, _screen.width, w->height); // invalidate the whole top part
+ return w->left;
+}
+
void RelocateAllWindows(int neww, int newh)
{
Window *w;
@@ -1182,7 +1208,7 @@ void RelocateAllWindows(int neww, int newh)
if (w->window_class == WC_MAIN_TOOLBAR) {
top = w->top;
- left = (neww - w->width) >> 1;
+ left = PositionMainToolbar(w); // changes toolbar orientation
} else if (w->window_class == WC_SELECT_GAME || w->window_class == WC_GAME_OPTIONS || w->window_class == WC_NETWORK_WINDOW){
top = (newh - w->height) >> 1;
left = (neww - w->width) >> 1;
@@ -1208,4 +1234,3 @@ void RelocateAllWindows(int neww, int newh)
w->top = top;
}
}
-