truelight@0: #include "stdafx.h" truelight@0: #include "ttd.h" tron@1299: #include "debug.h" tron@1309: #include "strings.h" tron@507: #include "table/strings.h" truelight@0: #include "window.h" truelight@0: #include "gui.h" truelight@0: #include "station.h" truelight@0: #include "gfx.h" truelight@0: #include "player.h" truelight@0: #include "town.h" truelight@0: #include "command.h" truelight@0: truelight@0: static void StationsWndShowStationRating(int x, int y, int type, uint acceptance, int rating) truelight@0: { truelight@0: static const byte _rating_colors[NUM_CARGO] = {152,32,15,174,208,194,191,55,184,10,191,48}; truelight@0: int color = _rating_colors[type]; truelight@0: uint w; truelight@0: truelight@0: if (acceptance > 575) truelight@0: acceptance = 575; truelight@193: truelight@0: acceptance = (acceptance + 7) >> 3; truelight@0: truelight@0: /* draw cargo */ truelight@0: if ( (w=acceptance>>3) != 0) { truelight@0: GfxFillRect(x, y, x+w-1, y+6, color); truelight@0: x += w; truelight@0: } truelight@0: truelight@0: if ( (w=acceptance&7) != 0) { truelight@0: if (w==7) w--; truelight@0: GfxFillRect(x, y+(w-1), x, y+6, color); truelight@0: } truelight@0: truelight@0: x -= (acceptance>>3); truelight@193: truelight@0: DrawString(x+1, y, _cargoc.names_short[type], 0x10); truelight@0: truelight@0: /* draw green/red ratings bar */ truelight@0: GfxFillRect(x+1, y+8, x+7, y+8, 0xB8); truelight@193: truelight@0: rating = (rating >> 5); truelight@0: truelight@0: if (rating != 0) { truelight@0: GfxFillRect(x+1, y+8, x+rating, y+8, 0xD0); truelight@0: } truelight@0: } truelight@0: truelight@0: static uint16 _num_station_sort[MAX_PLAYERS]; truelight@0: truelight@0: static char _bufcache[64]; truelight@0: static uint16 _last_station_idx; truelight@0: darkvater@164: static int CDECL StationNameSorter(const void *a, const void *b) truelight@0: { truelight@0: char buf1[64]; truelight@0: Station *st; darkvater@222: const SortStruct *cmp1 = (const SortStruct*)a; darkvater@222: const SortStruct *cmp2 = (const SortStruct*)b; truelight@0: truelight@919: st = GetStation(cmp1->index); tron@534: SetDParam(0, st->town->townnametype); tron@534: SetDParam(1, st->town->townnameparts); darkvater@164: GetString(buf1, st->string_id); darkvater@164: darkvater@164: if ( cmp2->index != _last_station_idx) { darkvater@164: _last_station_idx = cmp2->index; truelight@919: st = GetStation(cmp2->index); tron@534: SetDParam(0, st->town->townnametype); tron@534: SetDParam(1, st->town->townnameparts); darkvater@164: GetString(_bufcache, st->string_id); darkvater@164: } truelight@0: darkvater@164: return strcmp(buf1, _bufcache); // sort by name truelight@0: } truelight@0: tron@1093: static void GlobalSortStationList(void) truelight@0: { darkvater@243: const Station *st; darkvater@174: uint32 n = 0; truelight@0: uint16 *i; darkvater@243: darkvater@243: // reset #-of stations to 0 because ++ is used for value-assignment truelight@919: for (i = _num_station_sort; i != endof(_num_station_sort); i++) truelight@919: *i = 0; truelight@919: truelight@919: /* Create array for sorting */ truelight@1272: _station_sort = realloc(_station_sort, GetStationPoolSize() * sizeof(_station_sort[0])); truelight@919: if (_station_sort == NULL) truelight@919: error("Could not allocate memory for the station-sorting-list"); truelight@0: truelight@0: FOR_ALL_STATIONS(st) { truelight@0: if(st->xy && st->owner != OWNER_NONE) { truelight@0: _station_sort[n].index = st->index; truelight@0: _station_sort[n++].owner = st->owner; truelight@0: _num_station_sort[st->owner]++; // add number of stations of player truelight@0: } truelight@0: } truelight@0: darkvater@243: // create cumulative station-ownership truelight@0: // stations are stored as a cummulative index, eg 25, 41, 43. This means truelight@0: // Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 truelight@0: for (i = &_num_station_sort[1]; i != endof(_num_station_sort); i++) {*i += *(i-1);} truelight@0: darkvater@243: qsort(_station_sort, n, sizeof(_station_sort[0]), GeneralOwnerSorter); // sort by owner darkvater@164: darkvater@243: // since indexes are messed up after adding/removing a station, mark all lists dirty darkvater@243: memset(_station_sort_dirty, true, sizeof(_station_sort_dirty)); darkvater@243: _global_station_sort_dirty = false; darkvater@243: darkvater@243: DEBUG(misc, 1) ("Resorting global station list..."); darkvater@243: } darkvater@243: darkvater@243: static void MakeSortedStationList(byte owner) darkvater@243: { darkvater@243: SortStruct *firstelement; darkvater@243: uint32 n = 0; darkvater@164: darkvater@174: if (owner == 0) { // first element starts at 0th element and has n elements as described above darkvater@174: firstelement = &_station_sort[0]; darkvater@174: n = _num_station_sort[0]; darkvater@174: } else { // nth element starts at the end of the previous one, and has n elements as described above darkvater@174: firstelement = &_station_sort[_num_station_sort[owner-1]]; darkvater@174: n = _num_station_sort[owner] - _num_station_sort[owner-1]; darkvater@174: } darkvater@174: darkvater@243: _last_station_idx = 0; // used for "cache" in namesorting darkvater@243: qsort(firstelement, n, sizeof(_station_sort[0]), StationNameSorter); // sort by name truelight@193: darkvater@243: _station_sort_dirty[owner] = false; darkvater@243: darkvater@243: DEBUG(misc, 1) ("Resorting Stations list player %d...", owner+1); truelight@0: } truelight@0: truelight@0: static void PlayerStationsWndProc(Window *w, WindowEvent *e) truelight@0: { truelight@0: switch(e->event) { truelight@0: case WE_PAINT: { darkvater@174: uint32 i; darkvater@174: const byte window_number = (byte)w->window_number; darkvater@174: darkvater@243: // resort station window if stations have been added/removed darkvater@243: if (_global_station_sort_dirty) darkvater@243: GlobalSortStationList(); darkvater@243: darkvater@243: if (_station_sort_dirty[window_number]) { // resort in case of a station rename. darkvater@174: MakeSortedStationList(window_number); truelight@0: } truelight@0: truelight@0: // stations are stored as a cummulative index, eg 25, 41, 43. This means truelight@0: // Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 stations darkvater@174: i = (window_number == 0) ? 0 : _num_station_sort[window_number-1]; darkvater@174: SetVScrollCount(w, _num_station_sort[window_number] - i); truelight@0: truelight@0: /* draw widgets, with player's name in the caption */ truelight@0: { darkvater@174: Player *p = DEREF_PLAYER(window_number); tron@534: SetDParam(0, p->name_1); tron@534: SetDParam(1, p->name_2); tron@534: SetDParam(2, w->vscroll.count); truelight@0: DrawWindowWidgets(w); truelight@0: } truelight@0: truelight@0: { truelight@0: byte p = 0; truelight@0: Station *st; truelight@0: int x,xb = 2; truelight@0: int y = 16; // offset from top of widget truelight@0: int j; truelight@0: truelight@0: if (w->vscroll.count == 0) { // player has no stations truelight@0: DrawString(xb, y, STR_304A_NONE, 0); truelight@0: return; truelight@0: } truelight@193: truelight@0: i += w->vscroll.pos; // offset from sorted station list of current player darkvater@174: assert(i < _num_station_sort[window_number]); // at least one station must exist truelight@0: darkvater@174: while (i < _num_station_sort[window_number]) { // do until max number of stations of owner truelight@919: st = GetStation(_station_sort[i].index); truelight@0: darkvater@174: assert(st->xy && st->owner == window_number); darkvater@174: tron@534: SetDParam(0, st->index); tron@534: SetDParam(1, st->facilities); truelight@0: x = DrawString(xb, y, STR_3049_0, 0) + 5; truelight@0: truelight@0: // show cargo waiting and station ratings truelight@0: for(j=0; j!=NUM_CARGO; j++) { truelight@0: int acc = (st->goods[j].waiting_acceptance & 0xFFF); truelight@0: if (acc != 0) { truelight@0: StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating); truelight@0: x += 10; truelight@0: } truelight@0: } truelight@0: y += 10; truelight@0: i++; // next station darkvater@164: if (++p == w->vscroll.cap) { break;} // max number of stations in 1 window truelight@0: } truelight@0: } truelight@0: } break; truelight@0: case WE_CLICK: { truelight@0: switch(e->click.widget) { darkvater@758: case 3: { darkvater@174: uint32 id_v = (e->click.pt.y - 15) / 10; truelight@0: darkvater@174: if (id_v >= w->vscroll.cap) { return;} // click out of bounds darkvater@174: darkvater@174: id_v += w->vscroll.pos; darkvater@174: darkvater@174: { darkvater@174: const byte owner = (byte)w->window_number; darkvater@174: Station *st; darkvater@174: id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list darkvater@174: darkvater@174: if (id_v >= _num_station_sort[owner]) { return;} // click out of station bound darkvater@174: truelight@919: st = GetStation(_station_sort[id_v].index); darkvater@174: darkvater@174: assert(st->xy && st->owner == owner); darkvater@174: darkvater@174: ScrollMainWindowToTile(st->xy); truelight@0: } truelight@0: } break; truelight@0: } truelight@0: } break; truelight@0: truelight@0: case WE_4: truelight@0: WP(w,plstations_d).refresh_counter++; truelight@0: if (WP(w,plstations_d).refresh_counter==5) { truelight@0: WP(w,plstations_d).refresh_counter = 0; truelight@0: SetWindowDirty(w); truelight@0: } truelight@0: break; truelight@867: truelight@867: case WE_RESIZE: truelight@867: w->vscroll.cap += e->sizing.diff.y / 10; truelight@867: break; truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _player_stations_widgets[] = { truelight@867: { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, darkvater@893: { WWT_PANEL, RESIZE_RB, 14, 0, 345, 14, 137, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, darkvater@893: { WWT_SCROLLBAR, RESIZE_LRB, 14, 346, 357, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@893: { WWT_RESIZEBOX, RESIZE_LRTB, 14, 346, 357, 126, 137, 0x0, STR_RESIZE_BUTTON}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _player_stations_desc = { truelight@0: -1, -1, 358, 138, truelight@0: WC_STATION_LIST,0, truelight@867: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, truelight@0: _player_stations_widgets, truelight@0: PlayerStationsWndProc truelight@0: }; truelight@0: truelight@0: truelight@0: void ShowPlayerStations(int player) truelight@0: { truelight@0: Window *w; truelight@0: truelight@0: w = AllocateWindowDescFront(&_player_stations_desc, player); truelight@0: if (w) { truelight@0: w->caption_color = (byte)w->window_number; truelight@0: w->vscroll.cap = 12; truelight@867: w->resize.step_height = 10; truelight@867: w->resize.height = w->height - 10 * 7; // minimum if 5 in the list truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _station_view_expanded_widgets[] = { truelight@867: { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, darkvater@893: { WWT_IMGBTN, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, darkvater@893: { WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, truelight@867: { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 14, 0, 248, 66, 197, 0x0, STR_NULL}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 198, 209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 198, 209, STR_3033_ACCEPTS, STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 198, 209, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 198, 209, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 198, 209, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 198, 209, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 198, 209, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const Widget _station_view_widgets[] = { truelight@867: { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@867: { WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@867: { WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, darkvater@893: { WWT_IMGBTN, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, darkvater@893: { WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, truelight@867: { WWT_IMGBTN, RESIZE_NONE, 14, 0, 248, 66, 97, 0x0, STR_NULL}, truelight@867: { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, truelight@867: { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static void DrawStationViewWindow(Window *w) truelight@0: { truelight@0: Station *st; truelight@0: int i; truelight@0: int num; truelight@0: int x,y; truelight@0: int pos; truelight@0: StringID str; truelight@817: uint16 station_id; truelight@0: byte *b; truelight@0: truelight@0: truelight@1272: station_id = (uint16)w->window_number; truelight@0: truelight@919: st = GetStation(w->window_number); truelight@0: truelight@0: num = 1; truelight@0: for(i=0; i!=NUM_CARGO; i++) { truelight@0: if ((st->goods[i].waiting_acceptance & 0xFFF) != 0) { truelight@0: num++; truelight@0: if (st->goods[i].enroute_from != station_id) truelight@0: num++; truelight@0: } truelight@0: } truelight@0: SetVScrollCount(w, num); truelight@0: darkvater@758: w->disabled_state = st->owner == _local_player ? 0 : (1 << 9); tron@588: darkvater@758: if (!(st->facilities & FACIL_TRAIN)) SETBIT(w->disabled_state, 10); tron@588: if (!(st->facilities & FACIL_TRUCK_STOP) && darkvater@758: !(st->facilities & FACIL_BUS_STOP)) SETBIT(w->disabled_state, 11); darkvater@758: if (!(st->facilities & FACIL_AIRPORT)) SETBIT(w->disabled_state, 12); darkvater@758: if (!(st->facilities & FACIL_DOCK)) SETBIT(w->disabled_state, 13); tron@588: tron@534: SetDParam(0, st->index); tron@534: SetDParam(1, st->facilities); truelight@0: DrawWindowWidgets(w); truelight@0: truelight@0: x = 2; truelight@0: y = 15; truelight@0: pos = w->vscroll.pos; truelight@0: truelight@0: if (--pos < 0) { truelight@0: str = STR_00D0_NOTHING; truelight@0: for(i=0; i!=NUM_CARGO; i++) truelight@0: if (st->goods[i].waiting_acceptance & 0xFFF) truelight@0: str = STR_EMPTY; tron@534: SetDParam(0, str); truelight@0: DrawString(x, y, STR_0008_WAITING, 0); truelight@0: y += 10; truelight@0: } truelight@0: truelight@0: i = 0; truelight@0: do { truelight@0: uint waiting = (st->goods[i].waiting_acceptance & 0xFFF); truelight@0: if (waiting == 0) truelight@0: continue; truelight@193: truelight@0: num = (waiting + 5) / 10; truelight@0: if (num != 0) { truelight@0: int cur_x = x; truelight@0: num = min(num, 23); truelight@0: do { truelight@0: DrawSprite(_cargoc.sprites[i], cur_x, y); truelight@0: cur_x += 10; truelight@0: } while (--num); truelight@0: } truelight@0: truelight@0: if ( st->goods[i].enroute_from == station_id) { truelight@0: if (--pos < 0) { tron@534: SetDParam(1, waiting); tron@534: SetDParam(0, _cargoc.names_long_s[i] + (waiting==1 ? 0 : 32)); truelight@0: DrawStringRightAligned(x + 234, y, STR_0009, 0); truelight@0: y += 10; truelight@0: } truelight@0: } else { truelight@0: /* enroute */ truelight@0: if (--pos < 0) { tron@534: SetDParam(1, waiting); tron@534: SetDParam(0, _cargoc.names_long_s[i] + (waiting==1 ? 0 : 32)); truelight@0: DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); truelight@0: y += 10; truelight@0: } truelight@0: truelight@0: if (pos > -5 && --pos < 0) { tron@534: SetDParam(0, st->goods[i].enroute_from); truelight@0: DrawStringRightAligned(x + 234, y, STR_000B, 0); truelight@0: y += 10; truelight@0: } truelight@0: } truelight@0: } while (pos > -5 && ++i != 12); truelight@193: truelight@867: if (IsWindowOfPrototype(w, _station_view_widgets)) { truelight@0: b = _userstring; truelight@0: b[0] = 0x81; truelight@0: b[1] = STR_000C_ACCEPTS; truelight@0: b[2] = STR_000C_ACCEPTS >> 8; truelight@0: b += 3; truelight@0: truelight@0: for(i=0; i!=NUM_CARGO; i++) { pasky@487: if ((b - (byte *) &_userstring) + 5 > USERSTRING_LEN - 1) pasky@485: break; truelight@0: if (st->goods[i].waiting_acceptance & 0x8000) { truelight@0: b[0] = 0x81; truelight@0: WRITE_LE_UINT16(b+1, _cargoc.names_s[i]); truelight@0: WRITE_LE_UINT16(b+3, 0x202C); truelight@0: b += 5; truelight@0: } truelight@0: } truelight@193: truelight@0: if (b == (byte*)&_userstring[3]) { truelight@0: b[0] = 0x81; truelight@0: b[1] = STR_00D0_NOTHING; truelight@0: b[2] = STR_00D0_NOTHING >> 8; truelight@0: b[3] = 0; truelight@0: } else { truelight@0: b[-2] = 0; truelight@0: } truelight@0: truelight@0: DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245); truelight@0: } else { truelight@193: truelight@0: DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); truelight@0: truelight@0: y = 77; truelight@0: for(i=0; i!=NUM_CARGO; i++) { truelight@1266: if (st->goods[i].enroute_from != INVALID_STATION) { tron@534: SetDParam(0, _cargoc.names_s[i]); tron@534: SetDParam(2, st->goods[i].rating * 101 >> 8); tron@534: SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); truelight@0: DrawString(8, y, STR_303D, 0); truelight@0: y += 10; truelight@0: } truelight@0: } truelight@0: } truelight@0: } truelight@0: truelight@0: truelight@0: static void StationViewWndProc(Window *w, WindowEvent *e) truelight@0: { truelight@0: switch(e->event) { truelight@0: case WE_PAINT: truelight@0: DrawStationViewWindow(w); truelight@0: break; truelight@0: truelight@0: case WE_CLICK: truelight@0: switch(e->click.widget) { darkvater@758: case 7: truelight@919: ScrollMainWindowToTile(GetStation(w->window_number)->xy); truelight@0: break; truelight@0: darkvater@758: case 8: truelight@0: SetWindowDirty(w); truelight@193: truelight@0: /* toggle height/widget set */ truelight@867: if (IsWindowOfPrototype(w, _station_view_expanded_widgets)) { truelight@867: AssignWidgetToWindow(w, _station_view_widgets); truelight@867: w->height = 110; truelight@867: } else { truelight@867: AssignWidgetToWindow(w, _station_view_expanded_widgets); darkvater@893: w->height = 210; truelight@867: } truelight@0: truelight@0: SetWindowDirty(w); truelight@0: break; truelight@0: darkvater@758: case 9: { truelight@919: Station *st = GetStation(w->window_number); tron@534: SetDParam(0, st->town->townnametype); tron@534: SetDParam(1, st->town->townnameparts); truelight@0: ShowQueryString(st->string_id, STR_3030_RENAME_STATION_LOADING, 31, 180, w->window_class, w->window_number); truelight@0: } break; tron@588: darkvater@758: case 10: { truelight@919: const Station *st = GetStation(w->window_number); tron@588: ShowPlayerTrains(st->owner, w->window_number); tron@588: break; tron@588: } tron@588: darkvater@758: case 11: { truelight@919: const Station *st = GetStation(w->window_number); tron@588: ShowPlayerRoadVehicles(st->owner, w->window_number); tron@588: break; tron@588: } tron@588: darkvater@758: case 12: { truelight@919: const Station *st = GetStation(w->window_number); tron@588: ShowPlayerAircraft(st->owner, w->window_number); tron@588: break; tron@588: } tron@588: darkvater@758: case 13: { truelight@919: const Station *st = GetStation(w->window_number); tron@588: ShowPlayerShips(st->owner, w->window_number); tron@588: break; tron@588: } truelight@0: } truelight@0: break; truelight@0: truelight@0: case WE_ON_EDIT_TEXT: { truelight@0: Station *st; tron@1323: const char *b = e->edittext.str; truelight@0: if (*b == 0) truelight@0: return; truelight@0: memcpy(_decode_parameters, b, 32); truelight@0: truelight@919: st = GetStation(w->window_number); truelight@0: DoCommandP(st->xy, w->window_number, 0, NULL, CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION)); truelight@193: } break; tron@588: tron@588: case WE_DESTROY: { tron@588: WindowNumber wno = truelight@919: (w->window_number << 16) | GetStation(w->window_number)->owner; tron@588: tron@588: DeleteWindowById(WC_TRAINS_LIST, wno); tron@588: DeleteWindowById(WC_ROADVEH_LIST, wno); tron@588: DeleteWindowById(WC_SHIPS_LIST, wno); tron@588: DeleteWindowById(WC_AIRCRAFT_LIST, wno); tron@588: break; tron@588: } truelight@0: } truelight@0: } truelight@0: truelight@0: truelight@0: static const WindowDesc _station_view_desc = { truelight@0: -1, -1, 249, 110, truelight@0: WC_STATION_VIEW,0, darkvater@758: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, truelight@0: _station_view_widgets, truelight@0: StationViewWndProc truelight@0: }; truelight@0: truelight@0: void ShowStationViewWindow(int station) truelight@0: { truelight@0: Window *w; truelight@0: byte color; truelight@0: truelight@0: w = AllocateWindowDescFront(&_station_view_desc, station); truelight@0: if (w) { truelight@919: color = GetStation(w->window_number)->owner; truelight@0: if (color != 0x10) truelight@0: w->caption_color = color; truelight@0: w->vscroll.cap = 5; truelight@0: } truelight@0: }