changeset 914:170d57e15667 draft

(svn r1401) -Fix: glitches in train-depot GUI (tnx to Hackykid) -Fix: glitch in Company Overview GUI (Hackykid)
author truelight <truelight@openttd.org>
date Thu, 06 Jan 2005 17:40:57 +0000
parents e71d40e6dc27
children 880e0c9e29aa
files player_gui.c train_gui.c
diffstat 2 files changed, 22 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/player_gui.c
+++ b/player_gui.c
@@ -497,26 +497,25 @@
 	switch(e->event) {
 	case WE_PAINT: {
 		Player *p = DEREF_PLAYER(w->window_number);
-		uint32 dis;
+		uint32 dis = 0;
 
 		if (!IsWindowOfPrototype(w, _other_player_company_widgets)) {
 			AssignWidgetToWindow(w, (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets);
 
 			if (!_networking) w->hidden_state |= (1 << 9); // hide company-password widget
+		} else {
+			if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) dis |= 1 << 9;
+			// Also disable the buy button if 25% is not-owned by someone
+			//   and the player is not an AI
+			if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) dis |= 1 << 9;
+			if (GetAmountOwnedBy(p, _local_player) == 0) dis |= 1 << 10;
+			if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10);
 		}
 
 		SetDParam(0, p->name_1);
 		SetDParam(1, p->name_2);
 		SetDParam(2, GetPlayerNameString((byte)w->window_number, 3));
 
-		dis = 0;
-		if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0) dis |= 1 << 9;
-		// Also disable the buy button if 25% is not-owned by someone
-		//   and the player is not an AI
-		if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai) dis |= 1 << 9;
-		if (GetAmountOwnedBy(p, _local_player) == 0) dis |= 1 << 10;
-		if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10);
-
 		w->disabled_state = dis;
 		DrawWindowWidgets(w);
 
--- a/train_gui.c
+++ b/train_gui.c
@@ -329,6 +329,10 @@
 					}
 		}
 	}
+
+	/* Always have 1 empty row, so people can change the setting of the train */
+	num++;
+
 	SetVScrollCount(w, num);
 	SetHScrollCount(w, hnum);
 
@@ -397,7 +401,7 @@
 	}
 
 	row = (y - 14) / 14;
-	if ( (uint) row >= 6)
+	if ( (uint) row >= w->vscroll.cap)
 		return 1; /* means err */
 
 	row += w->vscroll.pos;
@@ -604,22 +608,22 @@
 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   336,     0,    13, STR_8800_TRAIN_DEPOT,	STR_018C_WINDOW_TITLE_DRAG_THIS},
 {  WWT_STICKYBOX,     RESIZE_LR,    14,   337,   348,     0,    13, 0x0,                   STR_STICKY_BUTTON},
-{     WWT_MATRIX,     RESIZE_RB,    14,     0,   313,    14,    96, 0x601,									STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
+{     WWT_MATRIX,     RESIZE_RB,    14,     0,   313,    14,    97, 0x601,									STR_883F_TRAINS_CLICK_ON_TRAIN_FOR},
 {      WWT_PANEL,    RESIZE_LRB,    14,   314,   336,    14,    13, 0x0,										STR_NULL},
 {      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    14,    54, 0x2A9,									STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE},
-{      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    55,   108, 0x2BF,									STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP},
+{      WWT_PANEL,   RESIZE_LRTB,    14,   314,   336,    55,   109, 0x2BF,									STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP},
 
-{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   337,   348,    14,   108, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   167,   109,   120, STR_8815_NEW_VEHICLES,	STR_8840_BUILD_NEW_TRAIN_VEHICLE},
-{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   168,   336,   109,   120, STR_00E4_LOCATION,			STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},
-{ WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,   313,    97,   108, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{      WWT_PANEL,    RESIZE_RTB,    14,   337,   336,   109,   120, 0x0,										STR_NULL},
-{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   337,   348,   109,   120, 0x0,										STR_RESIZE_BUTTON},
+{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   337,   348,    14,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,   167,   110,   121, STR_8815_NEW_VEHICLES,	STR_8840_BUILD_NEW_TRAIN_VEHICLE},
+{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   168,   336,   110,   121, STR_00E4_LOCATION,			STR_8842_CENTER_MAIN_VIEW_ON_TRAIN},
+{ WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,   313,    98,   109, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{      WWT_PANEL,    RESIZE_RTB,    14,   337,   336,   110,   121, 0x0,										STR_NULL},
+{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   337,   348,   110,   121, 0x0,										STR_RESIZE_BUTTON},
 {   WIDGETS_END},
 };
 
 static const WindowDesc _train_depot_desc = {
-	-1, -1, 349, 121,
+	-1, -1, 349, 122,
 	WC_VEHICLE_DEPOT,0,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
 	_train_depot_widgets,