717 /* Check if the currently selected station size is allowed */ |
717 /* Check if the currently selected station size is allowed */ |
718 static void CheckSelectedSize(Window *w, const StationSpec *statspec) |
718 static void CheckSelectedSize(Window *w, const StationSpec *statspec) |
719 { |
719 { |
720 if (statspec == NULL || _railstation.dragdrop) return; |
720 if (statspec == NULL || _railstation.dragdrop) return; |
721 |
721 |
722 if (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
722 if (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
723 RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
723 RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
724 _railstation.numtracks = 1; |
724 _railstation.numtracks = 1; |
725 while (HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
725 while (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
726 _railstation.numtracks++; |
726 _railstation.numtracks++; |
727 } |
727 } |
728 LowerWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
728 LowerWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
729 } |
729 } |
730 |
730 |
731 if (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
731 if (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
732 RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
732 RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
733 _railstation.platlength = 1; |
733 _railstation.platlength = 1; |
734 while (HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
734 while (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
735 _railstation.platlength++; |
735 _railstation.platlength++; |
736 } |
736 } |
737 LowerWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
737 LowerWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
738 } |
738 } |
739 } |
739 } |
779 bool disable = bits >= _patches.station_spread; |
779 bool disable = bits >= _patches.station_spread; |
780 if (statspec == NULL) { |
780 if (statspec == NULL) { |
781 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_NUM_1, disable); |
781 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_NUM_1, disable); |
782 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_LEN_1, disable); |
782 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_LEN_1, disable); |
783 } else { |
783 } else { |
784 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_NUM_1, HASBIT(statspec->disallowed_platforms, bits) || disable); |
784 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable); |
785 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_LEN_1, HASBIT(statspec->disallowed_lengths, bits) || disable); |
785 SetWindowWidgetDisabledState(w, bits + BRSW_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable); |
786 } |
786 } |
787 } |
787 } |
788 |
788 |
789 SetDParam(0, GetStationClassName(_railstation.station_class)); |
789 SetDParam(0, GetStationClassName(_railstation.station_class)); |
790 DrawWindowWidgets(w); |
790 DrawWindowWidgets(w); |
823 |
823 |
824 for (uint16 i = w->vscroll.pos; i < _railstation.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) { |
824 for (uint16 i = w->vscroll.pos; i < _railstation.station_count && i < (uint)(w->vscroll.pos + w->vscroll.cap); i++) { |
825 const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i); |
825 const StationSpec *statspec = GetCustomStationSpec(_railstation.station_class, i); |
826 |
826 |
827 if (statspec != NULL && statspec->name != 0) { |
827 if (statspec != NULL && statspec->name != 0) { |
828 if (HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) { |
828 if (HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) { |
829 GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT)); |
829 GfxFillRect(8, y - 2, 127, y + 10, (1 << PALETTE_MODIFIER_GREYOUT)); |
830 } |
830 } |
831 |
831 |
832 DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118); |
832 DrawStringTruncated(9, y, statspec->name, i == _railstation.station_type ? TC_WHITE : TC_BLACK, 118); |
833 } else { |
833 } else { |
862 |
862 |
863 _railstation.numtracks = e->we.click.widget - BRSW_PLATFORM_NUM_BEGIN; |
863 _railstation.numtracks = e->we.click.widget - BRSW_PLATFORM_NUM_BEGIN; |
864 _railstation.dragdrop = false; |
864 _railstation.dragdrop = false; |
865 |
865 |
866 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
866 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
867 if (statspec != NULL && HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
867 if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
868 /* The previously selected number of platforms in invalid */ |
868 /* The previously selected number of platforms in invalid */ |
869 for (uint i = 0; i < 7; i++) { |
869 for (uint i = 0; i < 7; i++) { |
870 if (!HASBIT(statspec->disallowed_lengths, i)) { |
870 if (!HasBit(statspec->disallowed_lengths, i)) { |
871 RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
871 RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
872 _railstation.platlength = i + 1; |
872 _railstation.platlength = i + 1; |
873 break; |
873 break; |
874 } |
874 } |
875 } |
875 } |
894 |
894 |
895 _railstation.platlength = e->we.click.widget - BRSW_PLATFORM_LEN_BEGIN; |
895 _railstation.platlength = e->we.click.widget - BRSW_PLATFORM_LEN_BEGIN; |
896 _railstation.dragdrop = false; |
896 _railstation.dragdrop = false; |
897 |
897 |
898 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
898 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
899 if (statspec != NULL && HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
899 if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
900 /* The previously selected number of tracks in invalid */ |
900 /* The previously selected number of tracks in invalid */ |
901 for (uint i = 0; i < 7; i++) { |
901 for (uint i = 0; i < 7; i++) { |
902 if (!HASBIT(statspec->disallowed_platforms, i)) { |
902 if (!HasBit(statspec->disallowed_platforms, i)) { |
903 RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
903 RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
904 _railstation.numtracks = i + 1; |
904 _railstation.numtracks = i + 1; |
905 break; |
905 break; |
906 } |
906 } |
907 } |
907 } |
918 _railstation.dragdrop ^= true; |
918 _railstation.dragdrop ^= true; |
919 ToggleWidgetLoweredState(w, BRSW_PLATFORM_DRAG_N_DROP); |
919 ToggleWidgetLoweredState(w, BRSW_PLATFORM_DRAG_N_DROP); |
920 |
920 |
921 /* get the first allowed length/number of platforms */ |
921 /* get the first allowed length/number of platforms */ |
922 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
922 const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL; |
923 if (statspec != NULL && HASBIT(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
923 if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) { |
924 for (uint i = 0; i < 7; i++) { |
924 for (uint i = 0; i < 7; i++) { |
925 if (!HASBIT(statspec->disallowed_lengths, i)) { |
925 if (!HasBit(statspec->disallowed_lengths, i)) { |
926 RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
926 RaiseWindowWidget(w, _railstation.platlength + BRSW_PLATFORM_LEN_BEGIN); |
927 _railstation.platlength = i + 1; |
927 _railstation.platlength = i + 1; |
928 break; |
928 break; |
929 } |
929 } |
930 } |
930 } |
931 } |
931 } |
932 if (statspec != NULL && HASBIT(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
932 if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) { |
933 for (uint i = 0; i < 7; i++) { |
933 for (uint i = 0; i < 7; i++) { |
934 if (!HASBIT(statspec->disallowed_platforms, i)) { |
934 if (!HasBit(statspec->disallowed_platforms, i)) { |
935 RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
935 RaiseWindowWidget(w, _railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN); |
936 _railstation.numtracks = i + 1; |
936 _railstation.numtracks = i + 1; |
937 break; |
937 break; |
938 } |
938 } |
939 } |
939 } |
968 if (y >= _railstation.station_count) return; |
968 if (y >= _railstation.station_count) return; |
969 |
969 |
970 /* Check station availability callback */ |
970 /* Check station availability callback */ |
971 statspec = GetCustomStationSpec(_railstation.station_class, y); |
971 statspec = GetCustomStationSpec(_railstation.station_class, y); |
972 if (statspec != NULL && |
972 if (statspec != NULL && |
973 HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && |
973 HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && |
974 GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
974 GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
975 |
975 |
976 _railstation.station_type = y; |
976 _railstation.station_type = y; |
977 |
977 |
978 CheckSelectedSize(w, statspec); |
978 CheckSelectedSize(w, statspec); |
1219 const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, w->hscroll.pos + i); |
1219 const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, w->hscroll.pos + i); |
1220 |
1220 |
1221 DrawWaypointSprite(2 + i * 68, 25, w->hscroll.pos + i, _cur_railtype); |
1221 DrawWaypointSprite(2 + i * 68, 25, w->hscroll.pos + i, _cur_railtype); |
1222 |
1222 |
1223 if (statspec != NULL && |
1223 if (statspec != NULL && |
1224 HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && |
1224 HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && |
1225 GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) { |
1225 GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) { |
1226 GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, (1 << PALETTE_MODIFIER_GREYOUT)); |
1226 GfxFillRect(4 + i * 68, 18, 67 + i * 68, 75, (1 << PALETTE_MODIFIER_GREYOUT)); |
1227 } |
1227 } |
1228 } |
1228 } |
1229 } |
1229 } |
1239 byte type = e->we.click.widget - BRWW_WAYPOINT_1 + w->hscroll.pos; |
1239 byte type = e->we.click.widget - BRWW_WAYPOINT_1 + w->hscroll.pos; |
1240 |
1240 |
1241 /* Check station availability callback */ |
1241 /* Check station availability callback */ |
1242 const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type); |
1242 const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, type); |
1243 if (statspec != NULL && |
1243 if (statspec != NULL && |
1244 HASBIT(statspec->callbackmask, CBM_STATION_AVAIL) && |
1244 HasBit(statspec->callbackmask, CBM_STATION_AVAIL) && |
1245 GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
1245 GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, NULL, INVALID_TILE) == 0) return; |
1246 |
1246 |
1247 _cur_waypoint_type = type; |
1247 _cur_waypoint_type = type; |
1248 SndPlayFx(SND_15_BEEP); |
1248 SndPlayFx(SND_15_BEEP); |
1249 SetWindowDirty(w); |
1249 SetWindowDirty(w); |