summaryrefslogtreecommitdiff
path: root/roadveh_gui.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-08-26 22:28:40 +0000
committerbjarni <bjarni@openttd.org>2006-08-26 22:28:40 +0000
commitf938db661947368a6beafd2af7b9c4e7dc886b5e (patch)
tree411f8a92fd3e71e7b66b7681f622b6b263916272 /roadveh_gui.c
parent0fa65dd6f318ea7e091068e8469d6fc72e7ece13 (diff)
downloadopenttd-f938db661947368a6beafd2af7b9c4e7dc886b5e.tar.xz
(svn r6161) -Feature: List of vehicles with the same shared orders
the list is available in the orders window and looks like the list buttons from the station windows (small vehicle) The button is disabled if the vehicle do not have any shared orders or it got shared orders, but an empty order list based on a patch by nycom, thought it ended up getting heavily modified Thanks to TrueLight for proofreading and suggestions
Diffstat (limited to 'roadveh_gui.c')
-rw-r--r--roadveh_gui.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 6fe3c1333..a60d5d125 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -943,7 +943,10 @@ static const Widget _other_player_roadveh_widgets[] = {
static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
{
- StationID station = GB(w->window_number, 16, 16);
+ uint16 order = GB(w->window_number, 16, 16);
+ /* Sorting a shared order list relies on station being set to INVALID_STATION */
+ /* If station is not INVALID_STATION, then order is never used and we don't care what it contains */
+ StationID station = HASBIT(w->window_number, 8) ? INVALID_STATION : order;
PlayerID owner = GB(w->window_number, 0, 8);
vehiclelist_d *vl = &WP(w, vehiclelist_d);
@@ -954,18 +957,24 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
int max;
int i;
- BuildVehicleList(vl, VEH_Road, owner, station);
+ BuildVehicleList(vl, VEH_Road, owner, station, order);
SortVehicleList(vl);
-
SetVScrollCount(w, vl->list_length);
// disable 'Sort By' tooltip on Unsorted sorting criteria
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);
/* draw the widgets */
- if (station == INVALID_STATION) {
+ if (order != INVALID_ORDER) {
+ /* Shared Orders -- (##) Road vehicles */
+ SetDParam(0, w->vscroll.count);
+ w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST;
+ w->widget[9].unkA = STR_EMPTY;
+ w->widget[10].unkA = STR_EMPTY;
+ SETBIT(w->disabled_state, 9);
+ SETBIT(w->disabled_state, 10);
+ } else if (station == INVALID_STATION) {
const Player *p = GetPlayer(owner);
-
/* Company Name -- (###) Road vehicles */
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
@@ -1115,14 +1124,18 @@ static const WindowDesc _other_player_roadveh_desc = {
};
-void ShowPlayerRoadVehicles(PlayerID player, StationID station)
+static void ShowPlayerRoadVehiclesLocal(PlayerID player, StationID station, uint16 order, bool show_shared)
{
Window *w;
- if ( player == _local_player) {
- w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player);
- } else {
- w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player);
+ if (show_shared) {
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (order << 16) | (1 << 8));
+ } else {
+ if ( player == _local_player) {
+ w = AllocateWindowDescFront(&_player_roadveh_desc, (station << 16) | player);
+ } else {
+ w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | player);
+ }
}
if (w != NULL) {
w->caption_color = player;
@@ -1132,3 +1145,14 @@ void ShowPlayerRoadVehicles(PlayerID player, StationID station)
w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */
}
}
+
+void ShowPlayerRoadVehicles(PlayerID player, StationID station)
+{
+ ShowPlayerRoadVehiclesLocal(player, station, 0, false);
+}
+
+void ShowVehWithSharedOrdersRoadVehicles(Vehicle *v)
+{
+ if (v->orders == NULL) return; // no shared list to show
+ ShowPlayerRoadVehiclesLocal(v->owner, INVALID_STATION, v->orders->index, true);
+}