(svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
authordominik
Sun, 14 Nov 2004 20:02:43 +0000
changeset 411 dc46e54bd2ed
parent 410 0efd84450b01
child 412 3b10a6e44e7e
(svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
rail_cmd.c
rail_gui.c
--- a/rail_cmd.c	Sun Nov 14 19:44:06 2004 +0000
+++ b/rail_cmd.c	Sun Nov 14 20:02:43 2004 +0000
@@ -736,7 +736,7 @@
 
 	if (flags & DC_EXEC) {
 		ModifyTile(tile, MP_MAP5, RAIL_TYPE_WAYPOINT | dir);
-		if (p1 & 0x100) {
+		if (p1 & 0x100 && (p1 & 0xff)!=0) { // waypoint type 0 uses default graphics
 			// custom graphics
 			_map3_lo[tile] |= 16;
 			_map3_hi[tile] = p1 & 0xff;
@@ -1631,6 +1631,8 @@
 	DrawTileSprites *cust;
 	DrawTileSeqStruct const *seq;
 	uint32 ormod, img;
+	const DrawTrackSeqStruct *dtss;
+	const byte *t;
 
 	assert(stat);
 
@@ -1644,6 +1646,23 @@
 	x += 33;
 	y += 17;
 
+	// draw default waypoint graphics of ID 0
+	t = _track_depot_layout_table[4];
+	if(stat_id==0)
+	{
+		img = *(const uint16*)t;
+		if (img & 0x8000) img = (img & 0x7FFF) + 0;
+		DrawSprite(img, x, y);
+
+		for(dtss = (const DrawTrackSeqStruct *)(t + sizeof(uint16)); dtss->image != 0; dtss++) {
+			Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0);
+			img = dtss->image;
+			if (img & 0x8000) img |= ormod;
+			DrawSprite(img + 0, x + pt.x, y + pt.y);
+		}
+		return;
+	}
+
 	img = cust->ground_sprite;
 	if (img & 0x8000) img = (img & 0x7FFF);
 	DrawSprite(img, x, y);
--- a/rail_gui.c	Sun Nov 14 19:44:06 2004 +0000
+++ b/rail_gui.c	Sun Nov 14 20:02:43 2004 +0000
@@ -13,7 +13,7 @@
 static uint _cur_railtype;
 static bool _remove_button_clicked;
 static byte _build_depot_direction;
-static byte _waypoint_count;
+static byte _waypoint_count=1;
 static byte _cur_waypoint_type;
 
 struct {
@@ -1069,6 +1069,7 @@
 		if(r+1<=_waypoint_count) DrawWaypointSprite(70,  25, r + 1);
 		if(r+2<=_waypoint_count) DrawWaypointSprite(138, 25, r + 2);
 		if(r+3<=_waypoint_count) DrawWaypointSprite(206, 25, r + 3);
+		if(r+4<=_waypoint_count) DrawWaypointSprite(274, 25, r + 4);
 		break;
 		}
 	case WE_CLICK: {
@@ -1080,6 +1081,7 @@
 		case 4:
 		case 5:
 		case 6:
+		case 7:
 			_cur_waypoint_type = e->click.widget - 3;
 			SndPlayFx(0x13);
 			SetWindowDirty(w);
@@ -1097,20 +1099,21 @@
 
 static const Widget _build_waypoint_widgets[] = {
 {   WWT_CLOSEBOX,     7,     0,    10,     0,    13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{    WWT_CAPTION,     7,    11,   275,     0,    13, STR_WAYPOINT,STR_018C_WINDOW_TITLE_DRAG_THIS},
-{      WWT_PANEL,     7,     0,   275,    14,    91, 0x0, 0},
+{    WWT_CAPTION,     7,    11,   343,     0,    13, STR_WAYPOINT,STR_018C_WINDOW_TITLE_DRAG_THIS},
+{      WWT_PANEL,     7,     0,   343,    14,    91, 0x0, 0},
 
 {      WWT_PANEL,     7,     3,    68,    17,    76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
 {      WWT_PANEL,     7,    71,   136,    17,    76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
 {      WWT_PANEL,     7,   139,   204,    17,    76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
 {      WWT_PANEL,     7,   207,   272,    17,    76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
+{      WWT_PANEL,     7,   275,   340,    17,    76, 0x0, STR_WAYPOINT_GRAPHICS_TIP},
 
-{  WWT_HSCROLLBAR,    7,     1,   275,    80,    91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{  WWT_HSCROLLBAR,    7,     1,   343,    80,    91, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
 {      WWT_LAST},
 };
 
 static const WindowDesc _build_waypoint_desc = {
-	-1,-1, 276, 92,
+	-1,-1, 344, 92,
 	WC_BUILD_DEPOT,WC_BUILD_TOOLBAR,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
 	_build_waypoint_widgets,
@@ -1120,8 +1123,8 @@
 static void ShowBuildWaypointPicker()
 {
 	Window *w = AllocateWindowDesc(&_build_waypoint_desc);
-	w->hscroll.cap = 4;
-	w->hscroll.count = (uint) (_waypoint_count+3) / 4;
+	w->hscroll.cap = 5;
+	w->hscroll.count = (uint) (_waypoint_count+4) / 5;
 }