summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt3
-rw-r--r--src/main_gui.cpp21
-rw-r--r--src/rail_cmd.cpp4
-rw-r--r--src/vehicle_gui.cpp16
-rw-r--r--src/vehicle_gui.h3
-rw-r--r--src/vehiclelist.cpp16
-rw-r--r--src/viewport.cpp6
-rw-r--r--src/waypoint.h2
-rw-r--r--src/waypoints_gui.cpp111
-rw-r--r--src/window_type.h1
10 files changed, 156 insertions, 27 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index b2a2d297f..66ee4d023 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2902,6 +2902,9 @@ STR_886A_RENAME_TRAIN_VEHICLE_TYPE :{WHITE}Rename t
STR_886B_CAN_T_RENAME_TRAIN_VEHICLE :{WHITE}Can't rename train vehicle type...
STR_CLEAR_TIME :{BLACK}Clear Time
STR_RESET_LATENESS :{BLACK}Reset Late Counter
+STR_CHANGE_WAYPOINT_NAME :{BLACK}Change waypoint name
+STR_SHOW_TRAINS_ON_WAYPOINT :{BLACK}Show Trains
+STR_WAYPOINT_NAME :{WHITE}{WAYPOINT}
STR_TRAIN_STOPPING :{RED}Stopping
STR_TRAIN_STOPPING_VEL :{RED}Stopping, {VELOCITY}
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 218705527..39d44d9c6 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -66,10 +66,6 @@ void HandleOnEditText(const char *str)
_cmd_text = str;
switch (_rename_what) {
- case 1: // Rename a waypoint
- if (*str == '\0') return;
- DoCommandP(0, id, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
- break;
#ifdef ENABLE_NETWORK
case 3: { // Give money, you can only give money in excess of loan
const Player *p = GetPlayer(_current_player);
@@ -131,23 +127,6 @@ void ShowNetworkGiveMoneyWindow(PlayerID player)
}
#endif /* ENABLE_NETWORK */
-void ShowRenameWaypointWindow(const Waypoint *wp)
-{
- int id = wp->index;
-
- /* Are we allowed to change the name of the waypoint? */
- if (!CheckTileOwnership(wp->xy)) {
- ShowErrorMessage(_error_message, STR_CANT_CHANGE_WAYPOINT_NAME,
- TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
- return;
- }
-
- _rename_id = id;
- _rename_what = 1;
- SetDParam(0, id);
- ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, NULL, CS_ALPHANUMERAL);
-}
-
/* Zooms a viewport in a window in or out */
/* No button handling or what so ever */
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 26b24da8b..2b5227c03 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2307,8 +2307,8 @@ static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode,
static void ClickTile_Track(TileIndex tile)
{
switch (GetRailTileType(tile)) {
- case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); break;
- case RAIL_TILE_WAYPOINT: ShowRenameWaypointWindow(GetWaypointByTile(tile)); break;
+ case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); break;
+ case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); break;
default: break;
}
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 84ff470b9..d2e262666 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -789,6 +789,7 @@ struct VehicleListWindow : public Window, public VehicleListBase {
case VLW_SHARED_ORDERS:
this->widget[VLW_WIDGET_CAPTION].data = STR_VEH_WITH_SHARED_ORDERS_LIST;
break;
+
case VLW_STANDARD: /* Company Name - standard widget setup */
switch (this->vehicle_type) {
case VEH_TRAIN: this->widget[VLW_WIDGET_CAPTION].data = STR_881B_TRAINS; break;
@@ -798,6 +799,11 @@ struct VehicleListWindow : public Window, public VehicleListBase {
default: NOT_REACHED(); break;
}
break;
+
+ case VLM_WAYPOINT_LIST:
+ this->widget[VLW_WIDGET_CAPTION].data = STR_WAYPOINT_VIEWPORT;
+ break;
+
case VLW_STATION_LIST: /* Station Name */
switch (this->vehicle_type) {
case VEH_TRAIN: this->widget[VLW_WIDGET_CAPTION].data = STR_SCHEDULED_TRAINS; break;
@@ -893,6 +899,10 @@ struct VehicleListWindow : public Window, public VehicleListBase {
SetDParam(1, this->vscroll.count);
break;
+ case VLM_WAYPOINT_LIST:
+ SetDParam(0, index);
+ break;
+
case VLW_STATION_LIST: /* Station Name */
SetDParam(0, index);
SetDParam(1, this->vscroll.count);
@@ -1167,6 +1177,12 @@ void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
}
}
+void ShowVehicleListWindow(const Waypoint *wp)
+{
+ if (wp == NULL) return;
+ ShowVehicleListWindowLocal(GetTileOwner(wp->xy), VLM_WAYPOINT_LIST, VEH_TRAIN, wp->index);
+}
+
void ShowVehicleListWindow(const Vehicle *v)
{
ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->FirstShared()->index);
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 43a99c919..a6c35cdc7 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -11,6 +11,7 @@
#include "order_type.h"
#include "station_type.h"
#include "engine_type.h"
+#include "waypoint.h"
void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order);
@@ -51,6 +52,7 @@ enum {
VLW_STATION_LIST = 2 << 8,
VLW_DEPOT_LIST = 3 << 8,
VLW_GROUP_LIST = 4 << 8,
+ VLM_WAYPOINT_LIST = 5 << 8,
VLW_MASK = 0x700,
};
@@ -72,6 +74,7 @@ uint ShowAdditionalText(int x, int y, uint w, EngineID engine);
uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine);
void ShowVehicleListWindow(const Vehicle *v);
+void ShowVehicleListWindow(const Waypoint *wp);
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type);
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station);
void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile);
diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp
index 2341a31ad..14798b655 100644
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -67,6 +67,7 @@ void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engine
* <li>VLW_STANDARD: not used<li>
* <li>VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for</li>
* <li>VLW_GROUP_LIST: index of group to generate a list for</li>
+ * <li>VLM_WAYPOINT_LIST: index of waypoint to generate a list for</li>
* </ul>
* @param window_type The type of window the list is for, using the VLW_ flags in vehicle_gui.h
*/
@@ -122,6 +123,21 @@ void GenerateVehicleSortList(VehicleList *list, VehicleType type, PlayerID owner
}
break;
+ case VLM_WAYPOINT_LIST:
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == type && v->IsPrimaryVehicle()) {
+ const Order *order;
+
+ FOR_VEHICLE_ORDERS(v, order) {
+ if (order->IsType(OT_GOTO_WAYPOINT) && order->GetDestination() == index) {
+ *list->Append() = v;
+ break;
+ }
+ }
+ }
+ }
+ break;
+
case VLW_GROUP_LIST:
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->IsPrimaryVehicle() &&
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 552ccf177..9e54e21d7 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1934,7 +1934,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
y < wp->sign.top + 12 &&
x >= wp->sign.left &&
x < wp->sign.left + wp->sign.width_1) {
- ShowRenameWaypointWindow(wp);
+ ShowWaypointWindow(wp);
return true;
}
}
@@ -1948,7 +1948,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
y < wp->sign.top + 24 &&
x >= wp->sign.left &&
x < wp->sign.left + wp->sign.width_1 * 2) {
- ShowRenameWaypointWindow(wp);
+ ShowWaypointWindow(wp);
return true;
}
}
@@ -1964,7 +1964,7 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
y < wp->sign.top + ScaleByZoom(12, vp->zoom) &&
x >= wp->sign.left &&
x < wp->sign.left + ScaleByZoom(wp->sign.width_2, vp->zoom)) {
- ShowRenameWaypointWindow(wp);
+ ShowWaypointWindow(wp);
return true;
}
}
diff --git a/src/waypoint.h b/src/waypoint.h
index 36014f7ca..ee664e605 100644
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -65,7 +65,7 @@ static inline Waypoint *GetWaypointByTile(TileIndex tile)
CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
Station *ComposeWaypointStation(TileIndex tile);
-void ShowRenameWaypointWindow(const Waypoint *cp);
+void ShowWaypointWindow(const Waypoint *wp);
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);
void FixOldWaypoints();
void UpdateAllWaypointSigns();
diff --git a/src/waypoints_gui.cpp b/src/waypoints_gui.cpp
new file mode 100644
index 000000000..bf95ee8d1
--- /dev/null
+++ b/src/waypoints_gui.cpp
@@ -0,0 +1,111 @@
+/* $Id$ */
+
+/** @file waypoint_gui.cpp Handling of waypoints gui. */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "window_gui.h"
+#include "gui.h"
+#include "textbuf_gui.h"
+#include "vehicle_gui.h"
+#include "waypoint.h"
+#include "viewport_func.h"
+#include "string_func.h"
+#include "strings_func.h"
+#include "gfx_func.h"
+#include "command_func.h"
+#include "functions.h"
+
+#include "table/strings.h"
+
+struct WaypointWindow : Window {
+private:
+ Waypoint *wp;
+
+ enum WaypointViewWidget {
+ WAYPVW_CLOSEBOX = 0,
+ WAYPVW_CAPTION,
+ WAYPVW_STICKY,
+ WAYPVW_VIEWPORTPANEL,
+ WAYPVW_SPACER,
+ WAYPVW_CENTERVIEW,
+ WAYPVW_RENAME,
+ WAYPVW_SHOW_TRAINS,
+ };
+
+public:
+ WaypointWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
+ {
+ this->wp = GetWaypoint(this->window_number);
+
+ this->flags4 |= WF_DISABLE_VP_SCROLL;
+ InitializeWindowViewport(this, 3, 17, 254, 86, this->wp->xy, ZOOM_LVL_MIN);
+
+ this->FindWindowPlacementAndResize(desc);
+ }
+
+ virtual void OnPaint()
+ {
+ /* You can only change your own waypoints */
+ this->SetWidgetDisabledState(WAYPVW_RENAME, !CheckTileOwnership(this->wp->xy));
+ SetDParam(0, this->wp->index);
+ this->DrawWidgets();
+
+ this->DrawViewport();
+ }
+
+ virtual void OnClick(Point pt, int widget)
+ {
+ switch (widget) {
+ case WAYPVW_CENTERVIEW: /* scroll to location */
+ if (_ctrl_pressed) {
+ ShowExtraViewPortWindow(this->wp->xy);
+ } else {
+ ScrollMainWindowToTile(this->wp->xy);
+ }
+ break;
+
+ case WAYPVW_RENAME: /* rename */
+ SetDParam(0, this->wp->index);
+ ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, this, CS_ALPHANUMERAL);
+ break;
+
+ case WAYPVW_SHOW_TRAINS: /* show list of trains having this waypoint in their orders*/
+ ShowVehicleListWindow(this->wp);
+ break;
+ }
+ }
+
+ virtual void OnQueryTextFinished(char *str)
+ {
+ if (!StrEmpty(str)) {
+ _cmd_text = str;
+ DoCommandP(0, this->window_number, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
+ }
+ }
+
+};
+
+static const Widget _waypoint_view_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // WAYPVW_CLOSEBOX
+{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 247, 0, 13, STR_WAYPOINT_VIEWPORT, STR_018C_WINDOW_TITLE_DRAG_THIS}, // WAYPVW_CAPTION
+{ WWT_STICKYBOX, RESIZE_NONE, COLOUR_GREY, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, // WAYPVW_STICKY
+{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 259, 14, 105, 0x0, STR_NULL}, // WAYPVW_VIEWPORTPANEL
+{ WWT_INSET, RESIZE_NONE, COLOUR_GREY, 2, 257, 16, 103, 0x0, STR_NULL}, // WAYPVW_SPACER
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 121, 106, 117, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // WAYPVW_CENTERVIEW
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 122, 244, 106, 117, STR_0130_RENAME, STR_CHANGE_WAYPOINT_NAME}, // WAYPVW_RENAME
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 245, 259, 106, 117, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // WAYPVW_SHOW_TRAINS
+{ WIDGETS_END},
+};
+
+static const WindowDesc _waypoint_view_desc = {
+ WDP_AUTO, WDP_AUTO, 260, 118, 260, 118,
+ WC_WAYPOINT_VIEW, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
+ _waypoint_view_widgets,
+};
+
+void ShowWaypointWindow(const Waypoint *wp)
+{
+ AllocateWindowDescFront<WaypointWindow>(&_waypoint_view_desc, wp->index);
+}
diff --git a/src/window_type.h b/src/window_type.h
index 2dc4ba584..0150f64da 100644
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -94,6 +94,7 @@ enum WindowClass {
WC_BUILD_SIGNAL,
WC_COMPANY_PASSWORD_WINDOW,
WC_OSK,
+ WC_WAYPOINT_VIEW,
WC_INVALID = 0xFFFF
};