src/rail_gui.cpp
branchcpp_gui
changeset 6235 5077e6ed3788
parent 6144 5a0ffbf27ced
child 6237 bce32e54c993
equal deleted inserted replaced
6234:42bf2d268a86 6235:5077e6ed3788
   318 }
   318 }
   319 
   319 
   320 static void BuildRailClick_Remove(Window *w)
   320 static void BuildRailClick_Remove(Window *w)
   321 {
   321 {
   322 	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
   322 	if (IsWindowWidgetDisabled(w, RTW_REMOVE)) return;
   323 	SetWindowDirty(w);
   323 	w->SetDirty();
   324 	SndPlayFx(SND_15_BEEP);
   324 	SndPlayFx(SND_15_BEEP);
   325 
   325 
   326 	ToggleWidgetLoweredState(w, RTW_REMOVE);
   326 	ToggleWidgetLoweredState(w, RTW_REMOVE);
   327 	_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE);
   327 	_remove_button_clicked = IsWindowWidgetLowered(w, RTW_REMOVE);
   328 	SetSelectionRed(_remove_button_clicked);
   328 	SetSelectionRed(_remove_button_clicked);
   522 			}
   522 			}
   523 		}
   523 		}
   524 		break;
   524 		break;
   525 
   525 
   526 	case WE_ABORT_PLACE_OBJ:
   526 	case WE_ABORT_PLACE_OBJ:
   527 		RaiseWindowButtons(w);
   527 		w->RaiseButtons();
   528 		DisableWindowWidget(w, RTW_REMOVE);
   528 		DisableWindowWidget(w, RTW_REMOVE);
   529 		InvalidateWidget(w, RTW_REMOVE);
   529 		InvalidateWidget(w, RTW_REMOVE);
   530 
   530 
   531 		w = FindWindowById(WC_BUILD_STATION, 0);
   531 		w = Window::FindById(WC_BUILD_STATION, 0);
   532 		if (w != NULL) WP(w,def_d).close = true;
   532 		if (w != NULL) WP(w,def_d).close = true;
   533 		w = FindWindowById(WC_BUILD_DEPOT, 0);
   533 		w = Window::FindById(WC_BUILD_DEPOT, 0);
   534 		if (w != NULL) WP(w,def_d).close = true;
   534 		if (w != NULL) WP(w,def_d).close = true;
   535 		break;
   535 		break;
   536 
   536 
   537 	case WE_PLACE_PRESIZE: {
   537 	case WE_PLACE_PRESIZE: {
   538 		TileIndex tile = e->we.place.tile;
   538 		TileIndex tile = e->we.place.tile;
   610 
   610 
   611 	if (!IsValidPlayer(_current_player)) return;
   611 	if (!IsValidPlayer(_current_player)) return;
   612 	if (!ValParamRailtype(railtype)) return;
   612 	if (!ValParamRailtype(railtype)) return;
   613 
   613 
   614 	// don't recreate the window if we're clicking on a button and the window exists.
   614 	// don't recreate the window if we're clicking on a button and the window exists.
   615 	if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
   615 	if (button < 0 || !(w = Window::FindById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
   616 		DeleteWindowById(WC_BUILD_TOOLBAR, 0);
   616 		DeleteWindowById(WC_BUILD_TOOLBAR, 0);
   617 		_cur_railtype = railtype;
   617 		_cur_railtype = railtype;
   618 		w = AllocateWindowDesc(&_build_rail_desc);
   618 		w = AllocateWindowDesc(&_build_rail_desc);
   619 		SetupRailToolbar(railtype, w);
   619 		SetupRailToolbar(railtype, w);
   620 	}
   620 	}
   785 		case 4:
   785 		case 4:
   786 			RaiseWindowWidget(w, _railstation.orientation + 3);
   786 			RaiseWindowWidget(w, _railstation.orientation + 3);
   787 			_railstation.orientation = e->we.click.widget - 3;
   787 			_railstation.orientation = e->we.click.widget - 3;
   788 			LowerWindowWidget(w, _railstation.orientation + 3);
   788 			LowerWindowWidget(w, _railstation.orientation + 3);
   789 			SndPlayFx(SND_15_BEEP);
   789 			SndPlayFx(SND_15_BEEP);
   790 			SetWindowDirty(w);
   790 			w->SetDirty();
   791 			break;
   791 			break;
   792 
   792 
   793 		case 5:
   793 		case 5:
   794 		case 6:
   794 		case 6:
   795 		case 7:
   795 		case 7:
   802 			_railstation.numtracks = (e->we.click.widget - 5) + 1;
   802 			_railstation.numtracks = (e->we.click.widget - 5) + 1;
   803 			_railstation.dragdrop = false;
   803 			_railstation.dragdrop = false;
   804 			LowerWindowWidget(w, _railstation.platlength + 11);
   804 			LowerWindowWidget(w, _railstation.platlength + 11);
   805 			LowerWindowWidget(w, _railstation.numtracks + 4);
   805 			LowerWindowWidget(w, _railstation.numtracks + 4);
   806 			SndPlayFx(SND_15_BEEP);
   806 			SndPlayFx(SND_15_BEEP);
   807 			SetWindowDirty(w);
   807 			w->SetDirty();
   808 			break;
   808 			break;
   809 
   809 
   810 		case 12:
   810 		case 12:
   811 		case 13:
   811 		case 13:
   812 		case 14:
   812 		case 14:
   819 			_railstation.platlength = (e->we.click.widget - 12) + 1;
   819 			_railstation.platlength = (e->we.click.widget - 12) + 1;
   820 			_railstation.dragdrop = false;
   820 			_railstation.dragdrop = false;
   821 			LowerWindowWidget(w, _railstation.platlength + 11);
   821 			LowerWindowWidget(w, _railstation.platlength + 11);
   822 			LowerWindowWidget(w, _railstation.numtracks + 4);
   822 			LowerWindowWidget(w, _railstation.numtracks + 4);
   823 			SndPlayFx(SND_15_BEEP);
   823 			SndPlayFx(SND_15_BEEP);
   824 			SetWindowDirty(w);
   824 			w->SetDirty();
   825 			break;
   825 			break;
   826 
   826 
   827 		case 19:
   827 		case 19:
   828 			_railstation.dragdrop ^= true;
   828 			_railstation.dragdrop ^= true;
   829 			ToggleWidgetLoweredState(w, 19);
   829 			ToggleWidgetLoweredState(w, 19);
   830 			SetWindowWidgetLoweredState(w, _railstation.numtracks + 4, !_railstation.dragdrop);
   830 			SetWindowWidgetLoweredState(w, _railstation.numtracks + 4, !_railstation.dragdrop);
   831 			SetWindowWidgetLoweredState(w, _railstation.platlength + 11, !_railstation.dragdrop);
   831 			SetWindowWidgetLoweredState(w, _railstation.platlength + 11, !_railstation.dragdrop);
   832 			SndPlayFx(SND_15_BEEP);
   832 			SndPlayFx(SND_15_BEEP);
   833 			SetWindowDirty(w);
   833 			w->SetDirty();
   834 			break;
   834 			break;
   835 
   835 
   836 		case 20:
   836 		case 20:
   837 		case 21:
   837 		case 21:
   838 			_station_show_coverage = (e->we.click.widget != 20);
   838 			_station_show_coverage = (e->we.click.widget != 20);
   839 			SetWindowWidgetLoweredState(w, 20, !_station_show_coverage);
   839 			SetWindowWidgetLoweredState(w, 20, !_station_show_coverage);
   840 			SetWindowWidgetLoweredState(w, 21, _station_show_coverage);
   840 			SetWindowWidgetLoweredState(w, 21, _station_show_coverage);
   841 			SndPlayFx(SND_15_BEEP);
   841 			SndPlayFx(SND_15_BEEP);
   842 			SetWindowDirty(w);
   842 			w->SetDirty();
   843 			break;
   843 			break;
   844 
   844 
   845 		case 22:
   845 		case 22:
   846 		case 23:
   846 		case 23:
   847 			ShowDropDownMenu(w, BuildStationClassDropdown(), _railstation.station_class, 23, 0, 1 << STAT_CLASS_WAYP);
   847 			ShowDropDownMenu(w, BuildStationClassDropdown(), _railstation.station_class, 23, 0, 1 << STAT_CLASS_WAYP);
   864 			_railstation.station_type = y;
   864 			_railstation.station_type = y;
   865 
   865 
   866 			CheckSelectedSize(w, statspec);
   866 			CheckSelectedSize(w, statspec);
   867 
   867 
   868 			SndPlayFx(SND_15_BEEP);
   868 			SndPlayFx(SND_15_BEEP);
   869 			SetWindowDirty(w);
   869 			w->SetDirty();
   870 			break;
   870 			break;
   871 		}
   871 		}
   872 		}
   872 		}
   873 	} break;
   873 	} break;
   874 
   874 
   883 			w->vscroll.count = _railstation.station_count;
   883 			w->vscroll.count = _railstation.station_count;
   884 			w->vscroll.pos   = _railstation.station_type;
   884 			w->vscroll.pos   = _railstation.station_type;
   885 		}
   885 		}
   886 
   886 
   887 		SndPlayFx(SND_15_BEEP);
   887 		SndPlayFx(SND_15_BEEP);
   888 		SetWindowDirty(w);
   888 		w->SetDirty();
   889 		break;
   889 		break;
   890 
   890 
   891 	case WE_MOUSELOOP:
   891 	case WE_MOUSELOOP:
   892 		if (WP(w,def_d).close) {
   892 		if (WP(w,def_d).close) {
   893 			DeleteWindow(w);
   893 			w->Close();
   894 			return;
   894 			return;
   895 		}
   895 		}
   896 		CheckRedrawStationCoverage(w);
   896 		CheckRedrawStationCoverage(w);
   897 		break;
   897 		break;
   898 
   898 
  1025 			case 6:
  1025 			case 6:
  1026 				RaiseWindowWidget(w, _build_depot_direction + 3);
  1026 				RaiseWindowWidget(w, _build_depot_direction + 3);
  1027 				_build_depot_direction = (DiagDirection)(e->we.click.widget - 3);
  1027 				_build_depot_direction = (DiagDirection)(e->we.click.widget - 3);
  1028 				LowerWindowWidget(w, _build_depot_direction + 3);
  1028 				LowerWindowWidget(w, _build_depot_direction + 3);
  1029 				SndPlayFx(SND_15_BEEP);
  1029 				SndPlayFx(SND_15_BEEP);
  1030 				SetWindowDirty(w);
  1030 				w->SetDirty();
  1031 				break;
  1031 				break;
  1032 		}
  1032 		}
  1033 		break;
  1033 		break;
  1034 
  1034 
  1035 	case WE_MOUSELOOP:
  1035 	case WE_MOUSELOOP:
  1036 		if (WP(w,def_d).close) DeleteWindow(w);
  1036 		if (WP(w,def_d).close) w->Close();
  1037 		return;
  1037 		return;
  1038 
  1038 
  1039 	case WE_DESTROY:
  1039 	case WE_DESTROY:
  1040 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1040 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1041 		break;
  1041 		break;
  1105 					HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) &&
  1105 					HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) &&
  1106 					GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return;
  1106 					GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return;
  1107 
  1107 
  1108 			_cur_waypoint_type = type;
  1108 			_cur_waypoint_type = type;
  1109 			SndPlayFx(SND_15_BEEP);
  1109 			SndPlayFx(SND_15_BEEP);
  1110 			SetWindowDirty(w);
  1110 			w->SetDirty();
  1111 			break;
  1111 			break;
  1112 		}
  1112 		}
  1113 		}
  1113 		}
  1114 		break;
  1114 		break;
  1115 	}
  1115 	}
  1116 
  1116 
  1117 	case WE_MOUSELOOP:
  1117 	case WE_MOUSELOOP:
  1118 		if (WP(w,def_d).close) DeleteWindow(w);
  1118 		if (WP(w,def_d).close) w->Close();
  1119 		break;
  1119 		break;
  1120 
  1120 
  1121 	case WE_DESTROY:
  1121 	case WE_DESTROY:
  1122 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1122 		if (!WP(w,def_d).close) ResetObjectToPlace();
  1123 		break;
  1123 		break;
  1167 {
  1167 {
  1168 	extern RailType _last_built_railtype;
  1168 	extern RailType _last_built_railtype;
  1169 	if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
  1169 	if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
  1170 		Window *w;
  1170 		Window *w;
  1171 		_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
  1171 		_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
  1172 		w = FindWindowById(WC_BUILD_TOOLBAR, 0);
  1172 		w = Window::FindById(WC_BUILD_TOOLBAR, 0);
  1173 		if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
  1173 		if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
  1174 			SetupRailToolbar(_cur_railtype, w);
  1174 			SetupRailToolbar(_cur_railtype, w);
  1175 			SetWindowDirty(w);
  1175 			w->SetDirty();
  1176 		}
  1176 		}
  1177 	}
  1177 	}
  1178 	MarkWholeScreenDirty();
  1178 	MarkWholeScreenDirty();
  1179 }
  1179 }
  1180 
  1180 
  1181 
  1181 
       
  1182