summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2004-11-14 20:02:43 +0000
committerdominik <dominik@openttd.org>2004-11-14 20:02:43 +0000
commit0bcc9b7573fea66107b134a9036849bc5e4d95e7 (patch)
treec24d588a7fbe212a5a87be9a326683a75b7b3764
parent249a170acef352b40c7fa67fe65bdc62cbae4ff1 (diff)
downloadopenttd-0bcc9b7573fea66107b134a9036849bc5e4d95e7.tar.xz
(svn r608) [newgrf] enabled possibility to build default waypoint when custom waypoints are enabled
-rw-r--r--rail_cmd.c21
-rw-r--r--rail_gui.c17
2 files changed, 30 insertions, 8 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index e771e333e..b17509822 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -736,7 +736,7 @@ int32 CmdBuildTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 @@ void DrawWaypointSprite(int x, int y, int stat_id)
DrawTileSprites *cust;
DrawTileSeqStruct const *seq;
uint32 ormod, img;
+ const DrawTrackSeqStruct *dtss;
+ const byte *t;
assert(stat);
@@ -1644,6 +1646,23 @@ void DrawWaypointSprite(int x, int y, int stat_id)
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);
diff --git a/rail_gui.c b/rail_gui.c
index d33a62d19..4ffc60c33 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -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 @@ static void BuildWaypointWndProc(Window *w, WindowEvent *e)
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 @@ static void BuildWaypointWndProc(Window *w, WindowEvent *e)
case 4:
case 5:
case 6:
+ case 7:
_cur_waypoint_type = e->click.widget - 3;
SndPlayFx(0x13);
SetWindowDirty(w);
@@ -1097,20 +1099,21 @@ static void BuildWaypointWndProc(Window *w, WindowEvent *e)
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 const WindowDesc _build_waypoint_desc = {
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;
}