(svn r14822) -Change: save 'build station' settings in the config file, like drag'n'drop and and show coverage area (Rexxars)

pull/155/head
rubidium 16 years ago
parent d44ba26cd7
commit a41e60d255

@ -175,8 +175,8 @@ public:
AirportPickerWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->LowerWidget(_selected_airport_type + BAW_SMALL_AIRPORT);
if (_settings_game.economy.station_noise_level) {
@ -214,7 +214,7 @@ public:
int rad = _settings_game.station.modified_catchment ? airport->catchment : (uint)CA_UNMODIFIED;
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
this->DrawWidgets();
@ -250,9 +250,9 @@ public:
break;
case BAW_BTN_DONTHILIGHT: case BAW_BTN_DOHILIGHT:
_station_show_coverage = (widget != BAW_BTN_DONTHILIGHT);
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _station_show_coverage);
_settings_client.gui.station_show_coverage = (widget != BAW_BTN_DONTHILIGHT);
this->SetWidgetLoweredState(BAW_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BAW_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;

@ -330,7 +330,7 @@ private:
public:
BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
this->FindWindowPlacementAndResize(desc);
}
@ -340,7 +340,7 @@ public:
this->DrawWidgets();
if (_station_show_coverage) {
if (_settings_client.gui.station_show_coverage) {
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
} else {
SetTileSelectSize(1, 1);
@ -360,9 +360,9 @@ public:
switch (widget) {
case BDSW_LT_OFF:
case BDSW_LT_ON:
this->RaiseWidget(_station_show_coverage + BDSW_LT_OFF);
_station_show_coverage = (widget != BDSW_LT_OFF);
this->LowerWidget(_station_show_coverage + BDSW_LT_OFF);
this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
_settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;

@ -57,9 +57,6 @@ static const SignalType _default_signal_type[] = {SIGTYPE_NORMAL, SIGTYPE_PBS, S
struct RailStationGUISettings {
Axis orientation; ///< Currently selected rail station orientation
byte numtracks; ///< Currently selected number of tracks in station (if not \c dragdrop )
byte platlength; ///< Currently selected platform length of station (if not \c dragdrop )
bool dragdrop; ///< Use drag & drop to place a station
bool newstations; ///< Are custom station definitions available?
StationClassIDByte station_class; ///< Currently selected custom station class (if newstations is \c true )
@ -187,12 +184,12 @@ static void PlaceRail_Station(TileIndex tile)
if (_remove_button_clicked) {
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
VpSetPlaceSizingLimit(-1);
} else if (_railstation.dragdrop) {
} else if (_settings_client.gui.station_dragdrop) {
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
VpSetPlaceSizingLimit(_settings_game.station.station_spread);
} else {
DoCommandP(tile,
_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
_railstation.orientation | (_settings_client.gui.station_numtracks << 8) | (_settings_client.gui.station_platlength << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16),
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation);
}
@ -482,16 +479,16 @@ static void BuildRailClick_Remove(Window *w)
if (w->IsWidgetLowered(RTW_BUILD_STATION)) {
if (_remove_button_clicked) {
/* starting drag & drop remove */
if (!_railstation.dragdrop) {
if (!_settings_client.gui.station_dragdrop) {
SetTileSelectSize(1, 1);
} else {
VpSetPlaceSizingLimit(-1);
}
} else {
/* starting station build mode */
if (!_railstation.dragdrop) {
int x = _railstation.numtracks;
int y = _railstation.platlength;
if (!_settings_client.gui.station_dragdrop) {
int x = _settings_client.gui.station_numtracks;
int y = _settings_client.gui.station_platlength;
if (_railstation.orientation == 0) Swap(x, y);
SetTileSelectSize(x, y);
} else {
@ -925,30 +922,30 @@ private:
/**
* Verify whether the currently selected station size is allowed after selecting a new station class/type.
* If not, change the station size variables ( _railstation.numtracks and _railstation.platlength ).
* If not, change the station size variables ( _settings_client.gui.station_numtracks and _settings_client.gui.station_platlength ).
* @param statspec Specification of the new station class/type
*/
void CheckSelectedSize(const StationSpec *statspec)
{
if (statspec == NULL || _railstation.dragdrop) return;
if (statspec == NULL || _settings_client.gui.station_dragdrop) return;
/* If current number of tracks is not allowed, make it as big as possible (which is always less than currently selected) */
if (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
_railstation.numtracks = 1;
while (HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
_railstation.numtracks++;
if (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
_settings_client.gui.station_numtracks = 1;
while (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
_settings_client.gui.station_numtracks++;
}
this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
}
if (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
_railstation.platlength = 1;
while (HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
_railstation.platlength++;
if (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
_settings_client.gui.station_platlength = 1;
while (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
_settings_client.gui.station_platlength++;
}
this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
}
}
@ -974,14 +971,14 @@ public:
BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent)
{
this->LowerWidget(_railstation.orientation + BRSW_PLATFORM_DIR_X);
if (_railstation.dragdrop) {
if (_settings_client.gui.station_dragdrop) {
this->LowerWidget(BRSW_PLATFORM_DRAG_N_DROP);
} else {
this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
}
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
this->FindWindowPlacementAndResize(desc);
@ -1002,11 +999,11 @@ public:
DrawPixelInfo tmp_dpi, *old_dpi;
const StationSpec *statspec = newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
if (_railstation.dragdrop) {
if (_settings_client.gui.station_dragdrop) {
SetTileSelectSize(1, 1);
} else {
int x = _railstation.numtracks;
int y = _railstation.platlength;
int x = _settings_client.gui.station_numtracks;
int y = _settings_client.gui.station_platlength;
if (_railstation.orientation == AXIS_X) Swap(x, y);
if (!_remove_button_clicked)
SetTileSelectSize(x, y);
@ -1014,7 +1011,7 @@ public:
int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
if (_station_show_coverage)
if (_settings_client.gui.station_show_coverage)
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
for (uint bits = 0; bits < 7; bits++) {
@ -1106,26 +1103,28 @@ public:
case BRSW_PLATFORM_NUM_5:
case BRSW_PLATFORM_NUM_6:
case BRSW_PLATFORM_NUM_7: {
this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
_railstation.numtracks = widget - BRSW_PLATFORM_NUM_BEGIN;
_railstation.dragdrop = false;
_settings_client.gui.station_numtracks = widget - BRSW_PLATFORM_NUM_BEGIN;
_settings_client.gui.station_dragdrop = false;
_settings_client.gui.station_dragdrop = false;
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
if (statspec != NULL && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
/* The previously selected number of platforms in invalid */
for (uint i = 0; i < 7; i++) {
if (!HasBit(statspec->disallowed_lengths, i)) {
this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
_railstation.platlength = i + 1;
this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
_settings_client.gui.station_platlength = i + 1;
break;
}
}
}
this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;
@ -1138,67 +1137,71 @@ public:
case BRSW_PLATFORM_LEN_5:
case BRSW_PLATFORM_LEN_6:
case BRSW_PLATFORM_LEN_7: {
this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
this->RaiseWidget(BRSW_PLATFORM_DRAG_N_DROP);
_railstation.platlength = widget - BRSW_PLATFORM_LEN_BEGIN;
_railstation.dragdrop = false;
_settings_client.gui.station_platlength = widget - BRSW_PLATFORM_LEN_BEGIN;
_settings_client.gui.station_dragdrop = false;
_settings_client.gui.station_dragdrop = false;
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
if (statspec != NULL && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
/* The previously selected number of tracks in invalid */
for (uint i = 0; i < 7; i++) {
if (!HasBit(statspec->disallowed_platforms, i)) {
this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
_railstation.numtracks = i + 1;
this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
_settings_client.gui.station_numtracks = i + 1;
break;
}
}
}
this->LowerWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
this->LowerWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
this->LowerWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;
}
case BRSW_PLATFORM_DRAG_N_DROP: {
_railstation.dragdrop ^= true;
_settings_client.gui.station_dragdrop ^= true;
this->ToggleWidgetLoweredState(BRSW_PLATFORM_DRAG_N_DROP);
/* get the first allowed length/number of platforms */
const StationSpec *statspec = _railstation.newstations ? GetCustomStationSpec(_railstation.station_class, _railstation.station_type) : NULL;
if (statspec != NULL && HasBit(statspec->disallowed_lengths, _railstation.platlength - 1)) {
if (statspec != NULL && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
for (uint i = 0; i < 7; i++) {
if (!HasBit(statspec->disallowed_lengths, i)) {
this->RaiseWidget(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN);
_railstation.platlength = i + 1;
this->RaiseWidget(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN);
_settings_client.gui.station_platlength = i + 1;
break;
}
}
}
if (statspec != NULL && HasBit(statspec->disallowed_platforms, _railstation.numtracks - 1)) {
if (statspec != NULL && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
for (uint i = 0; i < 7; i++) {
if (!HasBit(statspec->disallowed_platforms, i)) {
this->RaiseWidget(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN);
_railstation.numtracks = i + 1;
this->RaiseWidget(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN);
_settings_client.gui.station_numtracks = i + 1;
break;
}
}
}
this->SetWidgetLoweredState(_railstation.numtracks + BRSW_PLATFORM_NUM_BEGIN, !_railstation.dragdrop);
this->SetWidgetLoweredState(_railstation.platlength + BRSW_PLATFORM_LEN_BEGIN, !_railstation.dragdrop);
this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + BRSW_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop);
this->SetWidgetLoweredState(_settings_client.gui.station_platlength + BRSW_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
} break;
case BRSW_HIGHLIGHT_OFF:
case BRSW_HIGHLIGHT_ON:
_station_show_coverage = (widget != BRSW_HIGHLIGHT_OFF);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_station_show_coverage);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _station_show_coverage);
_settings_client.gui.station_show_coverage = (widget != BRSW_HIGHLIGHT_OFF);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(BRSW_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;
@ -1691,9 +1694,6 @@ static void ShowBuildWaypointPicker(Window *parent)
void InitializeRailGui()
{
_build_depot_direction = DIAGDIR_NW;
_railstation.numtracks = 1;
_railstation.platlength = 1;
_railstation.dragdrop = true;
}
/**

@ -831,7 +831,7 @@ public:
for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) this->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
this->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
this->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BRSW_LT_OFF);
this->FindWindowPlacementAndResize(desc);
}
@ -839,7 +839,7 @@ public:
{
this->DrawWidgets();
if (_station_show_coverage) {
if (_settings_client.gui.station_show_coverage) {
int rad = _settings_game.station.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
} else {
@ -887,9 +887,9 @@ public:
case BRSW_LT_OFF:
case BRSW_LT_ON:
this->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
_station_show_coverage = (widget != BRSW_LT_OFF);
this->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
this->RaiseWidget(_settings_client.gui.station_show_coverage + BRSW_LT_OFF);
_settings_client.gui.station_show_coverage = (widget != BRSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BRSW_LT_OFF);
SndPlayFx(SND_15_BEEP);
this->SetDirty();
break;

@ -1461,6 +1461,10 @@ const SettingDesc _patch_settings[] = {
SDTC_BOOL(gui.show_track_reservation, S, 0, false, STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION, RedrawScreen),
SDTC_VAR(gui.default_signal_type, SLE_UINT8, S, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_DEFAULT_SIGNAL_TYPE, NULL),
SDTC_VAR(gui.cycle_signal_types, SLE_UINT8, S, MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_CYCLE_SIGNAL_TYPES, NULL),
SDTC_VAR(gui.station_numtracks, SLE_UINT8, S, 0, 1, 1, 7, 0, STR_NULL, NULL),
SDTC_VAR(gui.station_platlength, SLE_UINT8, S, 0, 5, 1, 7, 0, STR_NULL, NULL),
SDTC_BOOL(gui.station_dragdrop, S, 0, true, STR_NULL, NULL),
SDTC_BOOL(gui.station_show_coverage, S, 0, false, STR_NULL, NULL),
SDTC_VAR(gui.console_backlog_timeout, SLE_UINT16, S, 0, 100, 10, 65500, 0, STR_NULL, NULL),
SDTC_VAR(gui.console_backlog_length, SLE_UINT16, S, 0, 100, 10, 65500, 0, STR_NULL, NULL),

@ -83,6 +83,10 @@ struct GUISettings {
bool show_track_reservation; ///< highlight reserved tracks.
uint8 default_signal_type; ///< the signal type to build by default.
uint8 cycle_signal_types; ///< what signal types to cycle with the build signal tool.
byte station_numtracks; ///< the number of platforms to default on for rail stations
byte station_platlength; ///< the platform length, in tiles, for rail stations
bool station_dragdrop; ///< whether drag and drop is enabled for stations
bool station_show_coverage; ///< whether to highlight coverage area
uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity.
uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed.

@ -32,8 +32,6 @@
#include "table/strings.h"
#include "table/sprites.h"
bool _station_show_coverage;
/**
* Draw small boxes of cargo amount and ratings data at the given
* coordinates. If amount exceeds 576 units, it is shown 'full', same

@ -57,6 +57,4 @@ enum StationCoverageType {
int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies);
void CheckRedrawStationCoverage(const Window *w);
extern bool _station_show_coverage;
#endif /* STATION_GUI_H */

Loading…
Cancel
Save