diff options
author | peter1138 <peter1138@openttd.org> | 2019-03-30 07:13:08 +0000 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-04-22 22:57:00 +0200 |
commit | a05bc04b638020e7faa7d990a8dcc5404e58ea91 (patch) | |
tree | adbd80101781ea10901bdf2f2c8324699279a008 /src/autoreplace_gui.cpp | |
parent | c56fce70b440a95914bf374f68ac045ca97b3610 (diff) | |
download | openttd-a05bc04b638020e7faa7d990a8dcc5404e58ea91.tar.xz |
Feature: Per-group wagon removal flag.
Diffstat (limited to 'src/autoreplace_gui.cpp')
-rw-r--r-- | src/autoreplace_gui.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index e952dcf19..d16e0916e 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -375,8 +375,15 @@ public: break; case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { - const Company *c = Company::Get(_local_company); - SetDParam(0, c->settings.renew_keep_length ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); + bool remove_wagon; + const Group *g = Group::GetIfValid(this->sel_group); + if (g != nullptr) { + remove_wagon = HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL); + } else { + const Company *c = Company::Get(_local_company); + remove_wagon = c->settings.renew_keep_length; + } + SetDParam(0, remove_wagon ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); break; } @@ -528,9 +535,16 @@ public: } break; - case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length - DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING); + case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { + const Group *g = Group::GetIfValid(this->sel_group); + if (g != nullptr) { + DoCommandP(0, this->sel_group | (GroupFlags::GF_REPLACE_WAGON_REMOVAL << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL) ? 0 : 1) | (_ctrl_pressed << 1), CMD_SET_GROUP_FLAG); + } else { + // toggle renew_keep_length + DoCommandP(0, GetCompanySettingIndex("company.renew_keep_length"), Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING); + } break; + } case WID_RV_START_REPLACE: { // Start replacing if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { |