64 |
64 |
65 static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) |
65 static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) |
66 { |
66 { |
67 int image = GetShipImage(v, 6); |
67 int image = GetShipImage(v, 6); |
68 uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
68 uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)); |
69 DrawSprite(image | ormod, x+32, y+10); |
69 DrawSprite(image | ormod, x + 32, y + 10); |
70 |
70 |
71 if (v->index == selection) { |
71 if (v->index == selection) { |
72 DrawFrameRect(x-5, y-1, x+67, y+21, 15, FR_BORDERONLY); |
72 DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY); |
73 } |
73 } |
74 } |
74 } |
75 |
75 |
76 static void ShipRefitWndProc(Window *w, WindowEvent *e) |
76 static void ShipRefitWndProc(Window *w, WindowEvent *e) |
77 { |
77 { |
289 |
289 |
290 static void ShowShipDetailsWindow(const Vehicle* v) |
290 static void ShowShipDetailsWindow(const Vehicle* v) |
291 { |
291 { |
292 Window *w; |
292 Window *w; |
293 VehicleID veh = v->index; |
293 VehicleID veh = v->index; |
|
294 |
294 DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
295 DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
295 DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
296 DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
296 _alloc_wnd_parent_num = veh; |
297 _alloc_wnd_parent_num = veh; |
297 w = AllocateWindowDesc(&_ship_details_desc); |
298 w = AllocateWindowDesc(&_ship_details_desc); |
298 w->window_number = veh; |
299 w->window_number = veh; |
312 ShowShipViewWindow(v); |
313 ShowShipViewWindow(v); |
313 } |
314 } |
314 |
315 |
315 void CcCloneShip(bool success, uint tile, uint32 p1, uint32 p2) |
316 void CcCloneShip(bool success, uint tile, uint32 p1, uint32 p2) |
316 { |
317 { |
317 if (success) { |
318 if (success) ShowShipViewWindow(GetVehicle(_new_ship_id)); |
318 const Vehicle* v = GetVehicle(_new_ship_id); |
|
319 |
|
320 ShowShipViewWindow(v); |
|
321 } |
|
322 } |
319 } |
323 |
320 |
324 static void NewShipWndProc(Window *w, WindowEvent *e) |
321 static void NewShipWndProc(Window *w, WindowEvent *e) |
325 { |
322 { |
326 switch(e->event) { |
323 switch (e->event) { |
327 case WE_PAINT: |
324 case WE_PAINT: |
328 if (w->window_number == 0) |
325 if (w->window_number == 0) w->disabled_state = 1 << 5; |
329 w->disabled_state = 1 << 5; |
|
330 |
326 |
331 // Setup scroll count |
327 // Setup scroll count |
332 { |
328 { |
333 int count = 0; |
329 int count = 0; |
334 int num = NUM_SHIP_ENGINES; |
330 int num = NUM_SHIP_ENGINES; |
335 const Engine* e = GetEngine(SHIP_ENGINES_INDEX); |
331 const Engine* e = GetEngine(SHIP_ENGINES_INDEX); |
336 |
332 |
337 do { |
333 do { |
338 if (HASBIT(e->player_avail, _local_player)) |
334 if (HASBIT(e->player_avail, _local_player)) count++; |
339 count++; |
|
340 } while (++e,--num); |
335 } while (++e,--num); |
341 SetVScrollCount(w, count); |
336 SetVScrollCount(w, count); |
342 } |
337 } |
343 |
338 |
344 DrawWindowWidgets(w); |
339 DrawWindowWidgets(w); |
758 const Vehicle* v = CheckMouseOverVehicle(); |
753 const Vehicle* v = CheckMouseOverVehicle(); |
759 |
754 |
760 if (v != NULL) HandleCloneVehClick(v, w); |
755 if (v != NULL) HandleCloneVehClick(v, w); |
761 } |
756 } |
762 |
757 |
763 static void ShipDepotWndProc(Window *w, WindowEvent *e) { |
758 static void ShipDepotWndProc(Window* w, WindowEvent* e) |
764 switch(e->event) { |
759 { |
|
760 switch (e->event) { |
765 case WE_PAINT: |
761 case WE_PAINT: |
766 DrawShipDepotWindow(w); |
762 DrawShipDepotWindow(w); |
767 break; |
763 break; |
768 |
764 |
769 case WE_CLICK: |
765 case WE_CLICK: |
894 ShipDepotWndProc |
890 ShipDepotWndProc |
895 }; |
891 }; |
896 |
892 |
897 void ShowShipDepotWindow(TileIndex tile) |
893 void ShowShipDepotWindow(TileIndex tile) |
898 { |
894 { |
899 Window *w; |
895 Window* w = AllocateWindowDescFront(&_ship_depot_desc,tile); |
900 |
896 |
901 w = AllocateWindowDescFront(&_ship_depot_desc,tile); |
897 if (w != NULL) { |
902 if (w) { |
|
903 w->caption_color = GetTileOwner(w->window_number); |
898 w->caption_color = GetTileOwner(w->window_number); |
904 w->vscroll.cap = 2; |
899 w->vscroll.cap = 2; |
905 w->hscroll.cap = 3; |
900 w->hscroll.cap = 3; |
906 w->resize.step_width = 90; |
901 w->resize.step_width = 90; |
907 w->resize.step_height = 24; |
902 w->resize.step_height = 24; |
909 _backup_orders_tile = 0; |
904 _backup_orders_tile = 0; |
910 } |
905 } |
911 } |
906 } |
912 |
907 |
913 |
908 |
914 static void DrawSmallOrderList(const Vehicle *v, int x, int y) { |
909 static void DrawSmallOrderList(const Vehicle* v, int x, int y) |
|
910 { |
915 const Order *order; |
911 const Order *order; |
916 int sel, i = 0; |
912 int sel, i = 0; |
917 |
913 |
918 sel = v->cur_order_index; |
914 sel = v->cur_order_index; |
919 |
915 |
920 FOR_VEHICLE_ORDERS(v, order) { |
916 FOR_VEHICLE_ORDERS(v, order) { |
921 if (sel == 0) { |
917 if (sel == 0) { |
922 _stringwidth_base = 0xE0; |
918 _stringwidth_base = 0xE0; |
923 DoDrawString( "\xAF", x-6, y, 16); |
919 DoDrawString("\xAF", x - 6, y, 16); |
924 _stringwidth_base = 0; |
920 _stringwidth_base = 0; |
925 } |
921 } |
926 sel--; |
922 sel--; |
927 |
923 |
928 if (order->type == OT_GOTO_STATION) { |
924 if (order->type == OT_GOTO_STATION) { |
929 if (!IsBuoy(GetStation(order->station))){ |
925 if (!IsBuoy(GetStation(order->station))){ |
930 SetDParam(0, order->station); |
926 SetDParam(0, order->station); |
931 DrawString(x, y, STR_A036, 0); |
927 DrawString(x, y, STR_A036, 0); |
932 |
928 |
933 y += 6; |
929 y += 6; |
934 if (++i == 4) |
930 if (++i == 4) break; |
935 break; |
|
936 } |
931 } |
937 } |
932 } |
938 } |
933 } |
939 } |
934 } |
940 |
935 |
1079 } break; |
1074 } break; |
1080 |
1075 |
1081 case 9: { /* Build new Vehicle */ |
1076 case 9: { /* Build new Vehicle */ |
1082 TileIndex tile; |
1077 TileIndex tile; |
1083 |
1078 |
1084 if (!IsWindowOfPrototype(w, _player_ships_widgets)) |
1079 if (!IsWindowOfPrototype(w, _player_ships_widgets)) break; |
1085 break; |
|
1086 |
|
1087 |
1080 |
1088 tile = _last_built_ship_depot_tile; |
1081 tile = _last_built_ship_depot_tile; |
1089 do { |
1082 do { |
1090 if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, _local_player)) { |
1083 if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, _local_player)) { |
1091 ShowShipDepotWindow(tile); |
1084 ShowShipDepotWindow(tile); |
1171 |
1163 |
1172 void ShowPlayerShips(PlayerID player, StationID station) |
1164 void ShowPlayerShips(PlayerID player, StationID station) |
1173 { |
1165 { |
1174 Window *w; |
1166 Window *w; |
1175 |
1167 |
1176 if ( player == _local_player) { |
1168 if (player == _local_player) { |
1177 w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player); |
1169 w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player); |
1178 } else { |
1170 } else { |
1179 w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player); |
1171 w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player); |
1180 } |
1172 } |
1181 if (w) { |
1173 if (w != NULL) { |
1182 w->caption_color = w->window_number; |
1174 w->caption_color = w->window_number; |
1183 w->vscroll.cap = 4; |
1175 w->vscroll.cap = 4; |
1184 w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
1176 w->widget[7].unkA = (w->vscroll.cap << 8) + 1; |
1185 w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
1177 w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
1186 } |
1178 } |