src/vehicle_gui.cpp
changeset 9116 f2491d3c321b
parent 9115 47ae980bace3
child 9117 87f472043e9e
equal deleted inserted replaced
9115:47ae980bace3 9116:f2491d3c321b
   117 			case WC_TRAINS_LIST:
   117 			case WC_TRAINS_LIST:
   118 			case WC_ROADVEH_LIST:
   118 			case WC_ROADVEH_LIST:
   119 			case WC_SHIPS_LIST:
   119 			case WC_SHIPS_LIST:
   120 			case WC_AIRCRAFT_LIST:
   120 			case WC_AIRCRAFT_LIST:
   121 				WP(w, vehiclelist_d).l.flags |= sl_flag;
   121 				WP(w, vehiclelist_d).l.flags |= sl_flag;
   122 				SetWindowDirty(w);
   122 				w->SetDirty();
   123 				break;
   123 				break;
   124 
   124 
   125 			default: break;
   125 			default: break;
   126 		}
   126 		}
   127 	}
   127 	}
   379 			switch (e->we.click.widget) {
   379 			switch (e->we.click.widget) {
   380 				case 3: { // listbox
   380 				case 3: { // listbox
   381 					int y = e->we.click.pt.y - w->widget[3].top;
   381 					int y = e->we.click.pt.y - w->widget[3].top;
   382 					if (y >= 0) {
   382 					if (y >= 0) {
   383 						WP(w, refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
   383 						WP(w, refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
   384 						SetWindowDirty(w);
   384 						w->SetDirty();
   385 					}
   385 					}
   386 				} break;
   386 				} break;
   387 				case 6: // refit button
   387 				case 6: // refit button
   388 					if (WP(w, refit_d).cargo != NULL) {
   388 					if (WP(w, refit_d).cargo != NULL) {
   389 						const Vehicle *v = GetVehicle(w->window_number);
   389 						const Vehicle *v = GetVehicle(w->window_number);
   739 	Window *w = FindWindowById(WC_VEHICLE_VIEW, from_index);
   739 	Window *w = FindWindowById(WC_VEHICLE_VIEW, from_index);
   740 
   740 
   741 	if (w != NULL) {
   741 	if (w != NULL) {
   742 		w->window_number = to_index;
   742 		w->window_number = to_index;
   743 		WP(w, vp_d).follow_vehicle = to_index;
   743 		WP(w, vp_d).follow_vehicle = to_index;
   744 		SetWindowDirty(w);
   744 		w->SetDirty();
   745 
   745 
   746 		w = FindWindowById(WC_VEHICLE_ORDERS, from_index);
   746 		w = FindWindowById(WC_VEHICLE_ORDERS, from_index);
   747 		if (w != NULL) {
   747 		if (w != NULL) {
   748 			w->window_number = to_index;
   748 			w->window_number = to_index;
   749 			SetWindowDirty(w);
   749 			w->SetDirty();
   750 		}
   750 		}
   751 
   751 
   752 		w = FindWindowById(WC_VEHICLE_REFIT, from_index);
   752 		w = FindWindowById(WC_VEHICLE_REFIT, from_index);
   753 		if (w != NULL) {
   753 		if (w != NULL) {
   754 			w->window_number = to_index;
   754 			w->window_number = to_index;
   755 			SetWindowDirty(w);
   755 			w->SetDirty();
   756 		}
   756 		}
   757 
   757 
   758 		w = FindWindowById(WC_VEHICLE_DETAILS, from_index);
   758 		w = FindWindowById(WC_VEHICLE_DETAILS, from_index);
   759 		if (w != NULL) {
   759 		if (w != NULL) {
   760 			w->window_number = to_index;
   760 			w->window_number = to_index;
   761 			SetWindowDirty(w);
   761 			w->SetDirty();
   762 		}
   762 		}
   763 
   763 
   764 		w = FindWindowById(WC_VEHICLE_TIMETABLE, from_index);
   764 		w = FindWindowById(WC_VEHICLE_TIMETABLE, from_index);
   765 		if (w != NULL) {
   765 		if (w != NULL) {
   766 			w->window_number = to_index;
   766 			w->window_number = to_index;
   767 			SetWindowDirty(w);
   767 			w->SetDirty();
   768 		}
   768 		}
   769 	}
   769 	}
   770 }
   770 }
   771 
   771 
   772 enum VehicleListWindowWidgets {
   772 enum VehicleListWindowWidgets {
  1080 				case VLW_WIDGET_SORT_ORDER: /* Flip sorting method ascending/descending */
  1080 				case VLW_WIDGET_SORT_ORDER: /* Flip sorting method ascending/descending */
  1081 					vl->l.flags ^= VL_DESC;
  1081 					vl->l.flags ^= VL_DESC;
  1082 					vl->l.flags |= VL_RESORT;
  1082 					vl->l.flags |= VL_RESORT;
  1083 
  1083 
  1084 					vl->_sorting->order = !!(vl->l.flags & VL_DESC);
  1084 					vl->_sorting->order = !!(vl->l.flags & VL_DESC);
  1085 					SetWindowDirty(w);
  1085 					w->SetDirty();
  1086 					break;
  1086 					break;
  1087 				case VLW_WIDGET_SORT_BY_PULLDOWN:/* Select sorting criteria dropdown menu */
  1087 				case VLW_WIDGET_SORT_BY_PULLDOWN:/* Select sorting criteria dropdown menu */
  1088 					ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, VLW_WIDGET_SORT_BY_PULLDOWN, 0, (vl->vehicle_type == VEH_TRAIN || vl->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
  1088 					ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, VLW_WIDGET_SORT_BY_PULLDOWN, 0, (vl->vehicle_type == VEH_TRAIN || vl->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
  1089 					return;
  1089 					return;
  1090 				case VLW_WIDGET_LIST: { /* Matrix to show vehicles */
  1090 				case VLW_WIDGET_LIST: { /* Matrix to show vehicles */
  1167 						default: NOT_REACHED();
  1167 						default: NOT_REACHED();
  1168 					}
  1168 					}
  1169 					break;
  1169 					break;
  1170 				default: NOT_REACHED();
  1170 				default: NOT_REACHED();
  1171 			}
  1171 			}
  1172 			SetWindowDirty(w);
  1172 			w->SetDirty();
  1173 			break;
  1173 			break;
  1174 
  1174 
  1175 		case WE_DESTROY:
  1175 		case WE_DESTROY:
  1176 			free((void*)vl->sort_list);
  1176 			free((void*)vl->sort_list);
  1177 			break;
  1177 			break;
  1183 				PlayerID owner = (PlayerID)w->caption_color;
  1183 				PlayerID owner = (PlayerID)w->caption_color;
  1184 
  1184 
  1185 				DEBUG(misc, 3, "Periodic resort %d list player %d at station %d", vl->vehicle_type, owner, station);
  1185 				DEBUG(misc, 3, "Periodic resort %d list player %d at station %d", vl->vehicle_type, owner, station);
  1186 				vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
  1186 				vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
  1187 				vl->l.flags |= VL_RESORT;
  1187 				vl->l.flags |= VL_RESORT;
  1188 				SetWindowDirty(w);
  1188 				w->SetDirty();
  1189 			}
  1189 			}
  1190 			break;
  1190 			break;
  1191 
  1191 
  1192 		case WE_RESIZE: /* Update the scroll + matrix */
  1192 		case WE_RESIZE: /* Update the scroll + matrix */
  1193 			w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
  1193 			w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
  1632 						VLD_WIDGET_DETAILS_TOTAL_CARGO,
  1632 						VLD_WIDGET_DETAILS_TOTAL_CARGO,
  1633 						e->we.click.widget,
  1633 						e->we.click.widget,
  1634 						WIDGET_LIST_END);
  1634 						WIDGET_LIST_END);
  1635 
  1635 
  1636 					WP(w, vehicledetails_d).tab = e->we.click.widget - VLD_WIDGET_DETAILS_CARGO_CARRIED;
  1636 					WP(w, vehicledetails_d).tab = e->we.click.widget - VLD_WIDGET_DETAILS_CARGO_CARRIED;
  1637 					SetWindowDirty(w);
  1637 					w->SetDirty();
  1638 					break;
  1638 					break;
  1639 			}
  1639 			}
  1640 		} break;
  1640 		} break;
  1641 
  1641 
  1642 		case WE_ON_EDIT_TEXT:
  1642 		case WE_ON_EDIT_TEXT:
  2166 				w->SetWidgetHiddenState(VVW_WIDGET_CLONE_VEH, !veh_stopped); // clone
  2166 				w->SetWidgetHiddenState(VVW_WIDGET_CLONE_VEH, !veh_stopped); // clone
  2167 				if (v->type == VEH_ROAD || v->type == VEH_TRAIN) {
  2167 				if (v->type == VEH_ROAD || v->type == VEH_TRAIN) {
  2168 					w->SetWidgetHiddenState( VVW_WIDGET_REFIT_VEH, !veh_stopped); // refit
  2168 					w->SetWidgetHiddenState( VVW_WIDGET_REFIT_VEH, !veh_stopped); // refit
  2169 					w->SetWidgetHiddenState(VVW_WIDGET_TURN_AROUND, veh_stopped);  // force turn around
  2169 					w->SetWidgetHiddenState(VVW_WIDGET_TURN_AROUND, veh_stopped);  // force turn around
  2170 				}
  2170 				}
  2171 				SetWindowDirty(w);
  2171 				w->SetDirty();
  2172 			}
  2172 			}
  2173 		} break;
  2173 		} break;
  2174 	}
  2174 	}
  2175 }
  2175 }
  2176 
  2176