diff options
-rw-r--r-- | aircraft_gui.c | 4 | ||||
-rw-r--r-- | depot_gui.c | 5 | ||||
-rw-r--r-- | order_gui.c | 7 | ||||
-rw-r--r-- | roadveh_gui.c | 5 | ||||
-rw-r--r-- | ship_gui.c | 4 | ||||
-rw-r--r-- | train_gui.c | 4 | ||||
-rw-r--r-- | vehicle_gui.c | 4 | ||||
-rw-r--r-- | window.c | 15 | ||||
-rw-r--r-- | window.h | 2 |
9 files changed, 19 insertions, 31 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c index 7d5d1ae81..9bb7d020f 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -183,9 +183,7 @@ static void ShowAircraftDetailsWindow(const Vehicle *v) DeleteWindowById(WC_VEHICLE_ORDERS, veh); DeleteWindowById(WC_VEHICLE_DETAILS, veh); - _alloc_wnd_parent_num = veh; - w = AllocateWindowDesc(&_aircraft_details_desc); - w->window_number = veh; + w = AllocateWindowDescFront(&_aircraft_details_desc, veh); w->caption_color = v->owner; // w->vscroll.cap = 6; // w->traindetails_d.tab = 0; diff --git a/depot_gui.c b/depot_gui.c index 3117922a9..e7b7fbb1c 100644 --- a/depot_gui.c +++ b/depot_gui.c @@ -221,10 +221,7 @@ static const WindowDesc _depot_sell_all_desc = { static void ShowDepotSellAllWindow(TileIndex tile, byte type) { - Window *w; - - _alloc_wnd_parent_num = tile; - w = AllocateWindowDescFront(&_depot_sell_all_desc, tile); + Window *w = AllocateWindowDescFront(&_depot_sell_all_desc, tile); if (w != NULL) { w->caption_color = GetTileOwner(tile); diff --git a/order_gui.c b/order_gui.c index cc2bbe966..52061507e 100644 --- a/order_gui.c +++ b/order_gui.c @@ -649,16 +649,13 @@ void ShowOrdersWindow(const Vehicle *v) DeleteWindowById(WC_VEHICLE_ORDERS, veh); DeleteWindowById(WC_VEHICLE_DETAILS, veh); - _alloc_wnd_parent_num = veh; - if (v->owner != _local_player) { - w = AllocateWindowDesc(&_other_orders_desc); + w = AllocateWindowDescFront(&_other_orders_desc, veh); } else { - w = AllocateWindowDesc((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc); + w = AllocateWindowDescFront((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc, veh); } if (w != NULL) { - w->window_number = veh; w->caption_color = v->owner; w->vscroll.cap = 6; w->resize.step_height = 10; diff --git a/roadveh_gui.c b/roadveh_gui.c index f787a82bf..acf0173de 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -219,9 +219,8 @@ static void ShowRoadVehDetailsWindow(const Vehicle *v) DeleteWindowById(WC_VEHICLE_ORDERS, veh); DeleteWindowById(WC_VEHICLE_DETAILS, veh); - _alloc_wnd_parent_num = veh; - w = AllocateWindowDesc(&_roadveh_details_desc); - w->window_number = veh; + + w = AllocateWindowDescFront(&_roadveh_details_desc, veh); w->caption_color = v->owner; } diff --git a/ship_gui.c b/ship_gui.c index a65270be7..37505a8a9 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -217,9 +217,7 @@ static void ShowShipDetailsWindow(const Vehicle *v) DeleteWindowById(WC_VEHICLE_ORDERS, veh); DeleteWindowById(WC_VEHICLE_DETAILS, veh); - _alloc_wnd_parent_num = veh; - w = AllocateWindowDesc(&_ship_details_desc); - w->window_number = veh; + w = AllocateWindowDescFront(&_ship_details_desc, veh); w->caption_color = v->owner; } diff --git a/train_gui.c b/train_gui.c index 323dd7bed..3f30d61b2 100644 --- a/train_gui.c +++ b/train_gui.c @@ -1216,10 +1216,8 @@ static void ShowTrainDetailsWindow(const Vehicle *v) DeleteWindowById(WC_VEHICLE_ORDERS, veh); DeleteWindowById(WC_VEHICLE_DETAILS, veh); - _alloc_wnd_parent_num = veh; - w = AllocateWindowDesc(&_train_details_desc); + w = AllocateWindowDescFront(&_train_details_desc, veh); - w->window_number = veh; w->caption_color = v->owner; w->vscroll.cap = 6; w->widget[4].data = (w->vscroll.cap << 8) + 1; diff --git a/vehicle_gui.c b/vehicle_gui.c index 0416e7121..849dfb4e6 100644 --- a/vehicle_gui.c +++ b/vehicle_gui.c @@ -442,9 +442,7 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order) DeleteWindowById(WC_VEHICLE_REFIT, v->index); - _alloc_wnd_parent_num = v->index; - - w = AllocateWindowDesc(&_vehicle_refit_desc); + w = AllocateWindowDescFront(&_vehicle_refit_desc, v->index); WP(w, refit_d).order = order; if (w != NULL) { @@ -682,12 +682,17 @@ static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number Point pt; Window *w; - if (desc->parent_cls != WC_MAIN_WINDOW && - (w = FindWindowById(desc->parent_cls, _alloc_wnd_parent_num), _alloc_wnd_parent_num=0, w) != NULL && - w->left < _screen.width-20 && w->left > -60 && w->top < _screen.height-20) { + /* By default position a child window at an offset of 10/10 of its parent. + * However if it falls too extremely outside window positions, reposition + * it to an automatic place */ + if (desc->parent_cls != 0 /* WC_MAIN_WINDOW */ && + (w = FindWindowById(desc->parent_cls, window_number)) != NULL && + w->left < _screen.width - 20 && w->left > -60 && w->top < _screen.height - 20) { + pt.x = w->left + 10; - if (pt.x > _screen.width + 10 - desc->width) + if (pt.x > _screen.width + 10 - desc->width) { pt.x = (_screen.width + 10 - desc->width) - 20; + } pt.y = w->top + 10; } else if (desc->cls == WC_BUILD_TOOLBAR) { // open Build Toolbars aligned /* Override the position if a toolbar is opened according to the place of the maintoolbar @@ -1715,7 +1720,7 @@ int PositionMainToolbar(Window *w) } switch (_patches.toolbar_pos) { - case 1: w->left = (_screen.width - w->width) >> 1; break; + case 1: w->left = (_screen.width - w->width) / 2; break; case 2: w->left = _screen.width - w->width; break; default: w->left = 0; } @@ -840,8 +840,6 @@ VARDEF bool _left_button_clicked; VARDEF bool _right_button_down; VARDEF bool _right_button_clicked; -VARDEF int _alloc_wnd_parent_num; - VARDEF int _scrollbar_start_pos; VARDEF int _scrollbar_size; VARDEF byte _scroller_click_timeout; |