254 |
255 |
255 static void BuildRailClick_Waypoint(Window *w) |
256 static void BuildRailClick_Waypoint(Window *w) |
256 { |
257 { |
257 _waypoint_count = GetCustomStationsCount(STAT_CLASS_WAYP); |
258 _waypoint_count = GetCustomStationsCount(STAT_CLASS_WAYP); |
258 if (HandlePlacePushButton(w, 11, SPR_OPENTTD_BASE + 7, 1, PlaceRail_Waypoint) |
259 if (HandlePlacePushButton(w, 11, SPR_OPENTTD_BASE + 7, 1, PlaceRail_Waypoint) |
259 && _waypoint_count > 1) |
260 && _waypoint_count > 0) |
260 ShowBuildWaypointPicker(); |
261 ShowBuildWaypointPicker(); |
261 } |
262 } |
262 |
263 |
263 static void BuildRailClick_Station(Window *w) |
264 static void BuildRailClick_Station(Window *w) |
264 { |
265 { |
857 } |
858 } |
858 |
859 |
859 |
860 |
860 static void BuildWaypointWndProc(Window *w, WindowEvent *e) |
861 static void BuildWaypointWndProc(Window *w, WindowEvent *e) |
861 { |
862 { |
862 switch(e->event) { |
863 switch (e->event) { |
863 case WE_PAINT: { |
864 case WE_PAINT: { |
864 int r; |
865 w->click_state = (1 << 3) << (_cur_waypoint_type - w->hscroll.pos); |
865 |
|
866 w->click_state = (1 << 3) << _cur_waypoint_type; |
|
867 DrawWindowWidgets(w); |
866 DrawWindowWidgets(w); |
868 |
867 |
869 r = 4*w->hscroll.pos; |
868 if(w->hscroll.pos + 0 <= _waypoint_count) DrawWaypointSprite(2, 25, w->hscroll.pos + 0, _cur_railtype); |
870 if(r+0<=_waypoint_count) DrawWaypointSprite(2, 25, r + 0, _cur_railtype); |
869 if(w->hscroll.pos + 1 <= _waypoint_count) DrawWaypointSprite(70, 25, w->hscroll.pos + 1, _cur_railtype); |
871 if(r+1<=_waypoint_count) DrawWaypointSprite(70, 25, r + 1, _cur_railtype); |
870 if(w->hscroll.pos + 2 <= _waypoint_count) DrawWaypointSprite(138, 25, w->hscroll.pos + 2, _cur_railtype); |
872 if(r+2<=_waypoint_count) DrawWaypointSprite(138, 25, r + 2, _cur_railtype); |
871 if(w->hscroll.pos + 3 <= _waypoint_count) DrawWaypointSprite(206, 25, w->hscroll.pos + 3, _cur_railtype); |
873 if(r+3<=_waypoint_count) DrawWaypointSprite(206, 25, r + 3, _cur_railtype); |
872 if(w->hscroll.pos + 4 <= _waypoint_count) DrawWaypointSprite(274, 25, w->hscroll.pos + 4, _cur_railtype); |
874 if(r+4<=_waypoint_count) DrawWaypointSprite(274, 25, r + 4, _cur_railtype); |
873 break; |
875 break; |
874 } |
876 } |
|
877 case WE_CLICK: { |
875 case WE_CLICK: { |
878 switch(e->click.widget) { |
876 switch (e->click.widget) { |
879 case 0: |
877 case 3: case 4: case 5: case 6: case 7: |
880 ResetObjectToPlace(); |
878 _cur_waypoint_type = e->click.widget - 3 + w->hscroll.pos; |
881 break; |
|
882 case 3: |
|
883 case 4: |
|
884 case 5: |
|
885 case 6: |
|
886 case 7: |
|
887 _cur_waypoint_type = e->click.widget - 3; |
|
888 SndPlayFx(SND_15_BEEP); |
879 SndPlayFx(SND_15_BEEP); |
889 SetWindowDirty(w); |
880 SetWindowDirty(w); |
890 break; |
881 break; |
891 } |
882 } |
892 break; |
883 break; |
893 } |
884 } |
894 |
885 |
895 case WE_MOUSELOOP: |
886 case WE_MOUSELOOP: |
896 if (WP(w,def_d).close) |
887 if (WP(w,def_d).close) |
897 DeleteWindow(w); |
888 DeleteWindow(w); |
898 return; |
889 break; |
899 |
890 |
900 case WE_DESTROY: |
891 case WE_DESTROY: |
901 ResetObjectToPlace(); |
892 if (!WP(w,def_d).close) |
|
893 ResetObjectToPlace(); |
902 break; |
894 break; |
903 } |
895 } |
904 } |
896 } |
905 |
897 |
906 static const Widget _build_waypoint_widgets[] = { |
898 static const Widget _build_waypoint_widgets[] = { |