1164 w->caption_color = v->owner; |
1165 w->caption_color = v->owner; |
1165 w->vscroll.cap = 6; |
1166 w->vscroll.cap = 6; |
1166 WP(w,traindetails_d).tab = 0; |
1167 WP(w,traindetails_d).tab = 0; |
1167 } |
1168 } |
1168 |
1169 |
1169 // used to get a sorted list of the vehicles |
1170 |
1170 static SortStruct _train_sort[NUM_NORMAL_VEHICLES]; |
1171 static Widget _player_trains_widgets[] = { |
1171 static uint16 _num_train_sort[MAX_PLAYERS]; |
|
1172 |
|
1173 static void GlobalSortTrainList() |
|
1174 { |
|
1175 const Vehicle *v; |
|
1176 uint16 *i; |
|
1177 uint32 n = 0; |
|
1178 |
|
1179 // reset #-of trains to 0 because ++ is used for value-assignment |
|
1180 for (i = _num_train_sort; i != endof(_num_train_sort); i++) {*i = 0;} |
|
1181 |
|
1182 FOR_ALL_VEHICLES(v) { |
|
1183 if(v->type == VEH_Train && v->subtype == 0) { |
|
1184 _train_sort[n].index = v->index; |
|
1185 _train_sort[n++].owner = v->owner; |
|
1186 _num_train_sort[v->owner]++; // add number of trains of player |
|
1187 } |
|
1188 } |
|
1189 |
|
1190 // create cumulative train-ownership |
|
1191 // trains are stored as a cummulative index, eg 25, 41, 43. This means |
|
1192 // Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 |
|
1193 for (i = &_num_train_sort[1]; i != endof(_num_train_sort); i++) {*i += *(i-1);} |
|
1194 |
|
1195 qsort(_train_sort, n, sizeof(_train_sort[0]), GeneralOwnerSorter); // sort by owner |
|
1196 |
|
1197 // since indexes are messed up after adding/removing a station, mark all lists dirty |
|
1198 memset(_train_sort_dirty, true, sizeof(_train_sort_dirty)); |
|
1199 _vehicle_sort_dirty[VEHTRAIN] = false; |
|
1200 |
|
1201 DEBUG(misc, 1) ("Resorting global trains list..."); |
|
1202 } |
|
1203 |
|
1204 static void MakeSortedTrainList(byte owner) |
|
1205 { |
|
1206 SortStruct *firstelement; |
|
1207 uint32 n = 0; |
|
1208 |
|
1209 if (owner == 0) { // first element starts at 0th element and has n elements as described above |
|
1210 firstelement = &_train_sort[0]; |
|
1211 n = _num_train_sort[0]; |
|
1212 } else { // nth element starts at the end of the previous one, and has n elements as described above |
|
1213 firstelement = &_train_sort[_num_train_sort[owner-1]]; |
|
1214 n = _num_train_sort[owner] - _num_train_sort[owner-1]; |
|
1215 } |
|
1216 |
|
1217 _internal_sort_order = _train_sort_order[owner]; |
|
1218 _internal_name_sorter_id = STR_SV_TRAIN_NAME; |
|
1219 _last_vehicle_idx = 0; // used for "cache" in namesorting |
|
1220 qsort(firstelement, n, sizeof(_train_sort[0]), _vehicle_sorter[_train_sort_type[owner]]); |
|
1221 |
|
1222 _train_sort_dirty[owner] = false; |
|
1223 |
|
1224 DEBUG(misc, 1) ("Resorting Trains list player %d...", owner+1); |
|
1225 } |
|
1226 |
|
1227 static void PlayerTrainsWndProc(Window *w, WindowEvent *e) |
|
1228 { |
|
1229 switch(e->event) { |
|
1230 case WE_PAINT: { |
|
1231 uint32 i; |
|
1232 const byte window_number = (byte)w->window_number; |
|
1233 |
|
1234 if (_train_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria |
|
1235 w->disabled_state |= (1 << 2); |
|
1236 |
|
1237 // resort trains window if roadvehicles have been added/removed |
|
1238 if (_vehicle_sort_dirty[VEHTRAIN]) |
|
1239 GlobalSortTrainList(); |
|
1240 |
|
1241 if (_train_sort_dirty[window_number]) { |
|
1242 MakeSortedTrainList(window_number); |
|
1243 /* reset sorting timeout */ |
|
1244 w->custom[0] = DAY_TICKS; |
|
1245 w->custom[1] = PERIODIC_RESORT_DAYS; |
|
1246 } |
|
1247 |
|
1248 // Trains are stored as a cummulative index, eg 25, 41, 43. This means |
|
1249 // Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 trains |
|
1250 i = (window_number == 0) ? 0 : _num_train_sort[window_number-1]; |
|
1251 SetVScrollCount(w, _num_train_sort[window_number] - i); |
|
1252 |
|
1253 /* draw the widgets */ |
|
1254 { |
|
1255 Player *p = DEREF_PLAYER(window_number); |
|
1256 /* Company Name -- (###) Trains */ |
|
1257 SetDParam(0, p->name_1); |
|
1258 SetDParam(1, p->name_2); |
|
1259 SetDParam(2, w->vscroll.count); |
|
1260 DrawWindowWidgets(w); |
|
1261 } |
|
1262 /* draw sorting criteria string */ |
|
1263 DrawString(85, 15, _vehicle_sort_listing[_train_sort_type[window_number]], 0x10); |
|
1264 /* draw arrow pointing up/down for ascending/descending soring */ |
|
1265 DoDrawString(_train_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10); |
|
1266 |
|
1267 /* draw the trains */ |
|
1268 { |
|
1269 Vehicle *v; |
|
1270 int n = 0; |
|
1271 const int x = 2; // offset from left side of widget |
|
1272 int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; // offset from top of widget |
|
1273 i += w->vscroll.pos; // offset from sorted trains list of current player |
|
1274 |
|
1275 while (i < _num_train_sort[window_number]) { |
|
1276 StringID str; |
|
1277 v = DEREF_VEHICLE(_train_sort[i].index); |
|
1278 |
|
1279 assert(v->type == VEH_Train && v->subtype == 0 && v->owner == window_number); |
|
1280 |
|
1281 DrawTrainImage(v, x + 21, y + 6 + _traininfo_vehicle_pitch, 10, 0, INVALID_VEHICLE); |
|
1282 DrawVehicleProfitButton(v, x, y+13); |
|
1283 |
|
1284 SetDParam(0, v->unitnumber); |
|
1285 if (IsTrainDepotTile(v->tile)) { |
|
1286 str = STR_021F; |
|
1287 } else { |
|
1288 str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
1289 } |
|
1290 DrawString(x, y+2, str, 0); |
|
1291 |
|
1292 SetDParam(0, v->profit_this_year); |
|
1293 SetDParam(1, v->profit_last_year); |
|
1294 DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1295 |
|
1296 if (v->string_id != STR_SV_TRAIN_NAME) { |
|
1297 SetDParam(0, v->string_id); |
|
1298 DrawString(x+21, y, STR_01AB, 0); |
|
1299 } |
|
1300 |
|
1301 y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
1302 i++; // next train |
|
1303 if (++n == w->vscroll.cap) { break;} // max number of trains in the window |
|
1304 } |
|
1305 } |
|
1306 } break; |
|
1307 |
|
1308 case WE_CLICK: { |
|
1309 switch(e->click.widget) { |
|
1310 case 2: /* Flip sorting method ascending/descending */ |
|
1311 _train_sort_order[(byte)w->window_number] ^= 1; |
|
1312 _train_sort_dirty[(byte)w->window_number] = true; |
|
1313 SetWindowDirty(w); |
|
1314 break; |
|
1315 case 3: case 4:/* Select sorting criteria dropdown menu */ |
|
1316 ShowDropDownMenu(w, _vehicle_sort_listing, _train_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4 |
|
1317 return; |
|
1318 case 6: { /* Matrix to show vehicles */ |
|
1319 uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
1320 |
|
1321 if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
|
1322 |
|
1323 id_v += w->vscroll.pos; |
|
1324 |
|
1325 { |
|
1326 const byte owner = (byte)w->window_number; |
|
1327 Vehicle *v; |
|
1328 id_v += (owner == 0) ? 0 : _num_train_sort[owner - 1]; // first element in list |
|
1329 |
|
1330 if (id_v >= _num_train_sort[owner]) { return;} // click out of vehicle bound |
|
1331 |
|
1332 v = DEREF_VEHICLE(_train_sort[id_v].index); // add the offset id_x to that |
|
1333 |
|
1334 assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner); |
|
1335 |
|
1336 ShowTrainViewWindow(v); |
|
1337 } |
|
1338 } break; |
|
1339 |
|
1340 case 8: { /* Build new Vehicle */ |
|
1341 uint tile; |
|
1342 |
|
1343 tile = _last_built_train_depot_tile; |
|
1344 do { |
|
1345 if (_map_owner[tile] == _local_player && IsTrainDepotTile(tile)) { |
|
1346 ShowTrainDepotWindow(tile); |
|
1347 ShowBuildTrainWindow(tile); |
|
1348 return; |
|
1349 } |
|
1350 |
|
1351 tile = TILE_MASK(tile + 1); |
|
1352 } while(tile != _last_built_train_depot_tile); |
|
1353 |
|
1354 ShowBuildTrainWindow(0); |
|
1355 } break; |
|
1356 } |
|
1357 } break; |
|
1358 |
|
1359 case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
|
1360 if (_train_sort_type[(byte)w->window_number] != e->dropdown.index) // if value hasn't changed, dont resort list |
|
1361 _train_sort_dirty[(byte)w->window_number] = true; |
|
1362 |
|
1363 _train_sort_type[(byte)w->window_number] = e->dropdown.index; |
|
1364 |
|
1365 if (_train_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen |
|
1366 w->disabled_state &= ~(1 << 2); |
|
1367 |
|
1368 SetWindowDirty(w); |
|
1369 break; |
|
1370 case WE_CREATE: /* set up resort timer */ |
|
1371 w->custom[0] = DAY_TICKS; |
|
1372 w->custom[1] = PERIODIC_RESORT_DAYS; |
|
1373 break; |
|
1374 case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
|
1375 if (--w->custom[0] == 0) { |
|
1376 w->custom[0] = DAY_TICKS; |
|
1377 if (--w->custom[1] == 0) { |
|
1378 w->custom[1] = PERIODIC_RESORT_DAYS; |
|
1379 _train_sort_dirty[(byte)w->window_number] = true; |
|
1380 DEBUG(misc, 1) ("Periodic resort Trains list player %d...", w->window_number+1); |
|
1381 SetWindowDirty(w); |
|
1382 } |
|
1383 } |
|
1384 break; |
|
1385 } |
|
1386 } |
|
1387 |
|
1388 static const Widget _player_trains_widgets[] = { |
|
1389 { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1172 { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1390 { WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1173 { WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1391 { WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
1174 { WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
1392 { WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP}, |
1175 { WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP}, |
1393 { WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP}, |
1176 { WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP}, |
1397 { WWT_PUSHTXTBTN, 14, 0, 161, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES}, |
1180 { WWT_PUSHTXTBTN, 14, 0, 161, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES}, |
1398 { WWT_PANEL, 14, 162, 324, 208, 219, 0x0, STR_NULL}, |
1181 { WWT_PANEL, 14, 162, 324, 208, 219, 0x0, STR_NULL}, |
1399 { WIDGETS_END}, |
1182 { WIDGETS_END}, |
1400 }; |
1183 }; |
1401 |
1184 |
1402 static const WindowDesc _player_trains_desc = { |
1185 static Widget _other_player_trains_widgets[] = { |
1403 -1, -1, 325, 220, |
|
1404 WC_TRAINS_LIST,0, |
|
1405 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1406 _player_trains_widgets, |
|
1407 PlayerTrainsWndProc |
|
1408 }; |
|
1409 |
|
1410 static const Widget _other_player_trains_widgets[] = { |
|
1411 { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1186 { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1412 { WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1187 { WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
1413 { WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
1188 { WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP}, |
1414 { WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP}, |
1189 { WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP}, |
1415 { WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP}, |
1190 { WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP}, |
1417 { WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
1192 { WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR}, |
1418 { WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1193 { WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
1419 { WIDGETS_END}, |
1194 { WIDGETS_END}, |
1420 }; |
1195 }; |
1421 |
1196 |
|
1197 static void PlayerTrainsWndProc(Window *w, WindowEvent *e) |
|
1198 { |
|
1199 int station = (int)w->window_number >> 16; |
|
1200 int owner = w->window_number & 0xff; |
|
1201 vehiclelist_d *vl = &WP(w, vehiclelist_d); |
|
1202 |
|
1203 switch(e->event) { |
|
1204 case WE_PAINT: { |
|
1205 int x = 2; |
|
1206 int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
1207 int max; |
|
1208 int i; |
|
1209 |
|
1210 BuildVehicleList(vl, VEH_Train, owner, station); |
|
1211 SortVehicleList(vl); |
|
1212 |
|
1213 SetVScrollCount(w, vl->list_length); |
|
1214 |
|
1215 // disable 'Sort By' tooltip on Unsorted sorting criteria |
|
1216 if (vl->sort_type == SORT_BY_UNSORTED) |
|
1217 w->disabled_state |= (1 << 2); |
|
1218 |
|
1219 /* draw the widgets */ |
|
1220 { |
|
1221 const Player *p = DEREF_PLAYER(owner); |
|
1222 /* XXX hack */ |
|
1223 if (station == -1) { |
|
1224 /* Company Name -- (###) Trains */ |
|
1225 SetDParam(0, p->name_1); |
|
1226 SetDParam(1, p->name_2); |
|
1227 SetDParam(2, w->vscroll.count); |
|
1228 _player_trains_widgets[1].unkA = STR_881B_TRAINS; |
|
1229 _other_player_trains_widgets[1].unkA = STR_881B_TRAINS; |
|
1230 } else { |
|
1231 /* Station Name -- (###) Trains */ |
|
1232 SetDParam(0, DEREF_STATION(station)->index); |
|
1233 SetDParam(1, w->vscroll.count); |
|
1234 _player_trains_widgets[1].unkA = STR_SCHEDULED_TRAINS; |
|
1235 _other_player_trains_widgets[1].unkA = STR_SCHEDULED_TRAINS; |
|
1236 } |
|
1237 DrawWindowWidgets(w); |
|
1238 } |
|
1239 /* draw sorting criteria string */ |
|
1240 DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
|
1241 /* draw arrow pointing up/down for ascending/descending sorting */ |
|
1242 DoDrawString( |
|
1243 vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10); |
|
1244 |
|
1245 max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
|
1246 for (i = w->vscroll.pos; i < max; ++i) { |
|
1247 Vehicle *v = DEREF_VEHICLE(vl->sort_list[i].index); |
|
1248 StringID str; |
|
1249 |
|
1250 assert(v->type == VEH_Train && v->owner == owner); |
|
1251 |
|
1252 DrawTrainImage( |
|
1253 v, x + 21, y + 6 + _traininfo_vehicle_pitch, 10, 0, INVALID_VEHICLE); |
|
1254 DrawVehicleProfitButton(v, x, y + 13); |
|
1255 |
|
1256 SetDParam(0, v->unitnumber); |
|
1257 if (IsTrainDepotTile(v->tile)) |
|
1258 str = STR_021F; |
|
1259 else |
|
1260 str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
|
1261 DrawString(x, y + 2, str, 0); |
|
1262 |
|
1263 SetDParam(0, v->profit_this_year); |
|
1264 SetDParam(1, v->profit_last_year); |
|
1265 DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1266 |
|
1267 if (v->string_id != STR_SV_TRAIN_NAME) { |
|
1268 SetDParam(0, v->string_id); |
|
1269 DrawString(x + 21, y, STR_01AB, 0); |
|
1270 } |
|
1271 |
|
1272 y += PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
1273 } |
|
1274 break; |
|
1275 } |
|
1276 |
|
1277 case WE_CLICK: { |
|
1278 switch(e->click.widget) { |
|
1279 case 2: /* Flip sorting method ascending/descending */ |
|
1280 vl->flags ^= VL_DESC; |
|
1281 vl->flags |= VL_RESORT; |
|
1282 SetWindowDirty(w); |
|
1283 break; |
|
1284 |
|
1285 case 3: case 4:/* Select sorting criteria dropdown menu */ |
|
1286 ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 4, 0); |
|
1287 return; |
|
1288 |
|
1289 case 6: { /* Matrix to show vehicles */ |
|
1290 uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL; |
|
1291 |
|
1292 if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
|
1293 |
|
1294 id_v += w->vscroll.pos; |
|
1295 |
|
1296 { |
|
1297 Vehicle *v; |
|
1298 |
|
1299 if (id_v >= vl->list_length) return; // click out of list bound |
|
1300 |
|
1301 v = DEREF_VEHICLE(vl->sort_list[id_v].index); |
|
1302 |
|
1303 assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner); |
|
1304 |
|
1305 ShowTrainViewWindow(v); |
|
1306 } |
|
1307 } break; |
|
1308 |
|
1309 case 8: { /* Build new Vehicle */ |
|
1310 uint tile; |
|
1311 |
|
1312 tile = _last_built_train_depot_tile; |
|
1313 do { |
|
1314 if (_map_owner[tile] == _local_player && IsTrainDepotTile(tile)) { |
|
1315 ShowTrainDepotWindow(tile); |
|
1316 ShowBuildTrainWindow(tile); |
|
1317 return; |
|
1318 } |
|
1319 |
|
1320 tile = TILE_MASK(tile + 1); |
|
1321 } while(tile != _last_built_train_depot_tile); |
|
1322 |
|
1323 ShowBuildTrainWindow(0); |
|
1324 } break; |
|
1325 } |
|
1326 } break; |
|
1327 |
|
1328 case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
|
1329 if (vl->sort_type != e->dropdown.index) { |
|
1330 // value has changed -> resort |
|
1331 vl->flags |= VL_RESORT; |
|
1332 vl->sort_type = e->dropdown.index; |
|
1333 |
|
1334 // enable 'Sort By' if a sorter criteria is chosen |
|
1335 if (vl->sort_type != SORT_BY_UNSORTED) |
|
1336 w->disabled_state &= ~(1 << 2); |
|
1337 } |
|
1338 SetWindowDirty(w); |
|
1339 break; |
|
1340 |
|
1341 case WE_CREATE: /* set up resort timer */ |
|
1342 vl->sort_list = NULL; |
|
1343 vl->flags = VL_REBUILD; |
|
1344 vl->sort_type = SORT_BY_UNSORTED; |
|
1345 vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1346 break; |
|
1347 |
|
1348 case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
|
1349 if (--vl->resort_timer == 0) { |
|
1350 DEBUG(misc, 1) ("Periodic resort trains list player %d station %d", |
|
1351 owner, station); |
|
1352 vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1353 vl->flags |= VL_RESORT; |
|
1354 SetWindowDirty(w); |
|
1355 } |
|
1356 break; |
|
1357 } |
|
1358 } |
|
1359 |
|
1360 static const WindowDesc _player_trains_desc = { |
|
1361 -1, -1, 325, 220, |
|
1362 WC_TRAINS_LIST,0, |
|
1363 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
1364 _player_trains_widgets, |
|
1365 PlayerTrainsWndProc |
|
1366 }; |
|
1367 |
1422 static const WindowDesc _other_player_trains_desc = { |
1368 static const WindowDesc _other_player_trains_desc = { |
1423 -1, -1, 325, 208, |
1369 -1, -1, 325, 208, |
1424 WC_TRAINS_LIST,0, |
1370 WC_TRAINS_LIST,0, |
1425 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1371 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
1426 _other_player_trains_widgets, |
1372 _other_player_trains_widgets, |
1427 PlayerTrainsWndProc |
1373 PlayerTrainsWndProc |
1428 }; |
1374 }; |
1429 |
1375 |
1430 void ShowPlayerTrains(int player) |
1376 void ShowPlayerTrains(int player, int station) |
1431 { |
1377 { |
1432 Window *w; |
1378 Window *w; |
1433 |
1379 |
1434 if (player == _local_player) { |
1380 if (player == _local_player) { |
1435 w = AllocateWindowDescFront(&_player_trains_desc, player); |
1381 w = AllocateWindowDescFront(&_player_trains_desc, (station << 16) | player); |
1436 } else { |
1382 } else { |
1437 w = AllocateWindowDescFront(&_other_player_trains_desc, player); |
1383 w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player); |
1438 } |
1384 } |
1439 if (w) { |
1385 if (w) { |
1440 w->caption_color = w->window_number; |
1386 w->caption_color = w->window_number; |
1441 w->vscroll.cap = 7; // maximum number of vehicles shown |
1387 w->vscroll.cap = 7; // maximum number of vehicles shown |
1442 } |
1388 } |