1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-28 06:34:33 +01:00

Codechange: Use EnumBitSet for GroupFlags.

This commit is contained in:
Peter Nelson
2025-01-29 17:47:50 +00:00
committed by Peter Nelson
parent 4b573b2703
commit 5ef495da78
9 changed files with 25 additions and 26 deletions

View File

@@ -584,7 +584,7 @@ public:
/* If not a default group and the group has replace protection, show an enabled replace sprite. */
uint16_t protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN;
if (!IsDefaultGroupID(this->vli.index) && !IsAllGroupID(this->vli.index) && HasFlag(Group::Get(this->vli.index)->flags, GroupFlags::ReplaceProtection)) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN;
if (!IsDefaultGroupID(this->vli.index) && !IsAllGroupID(this->vli.index) && Group::Get(this->vli.index)->flags.Test(GroupFlag::ReplaceProtection)) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN;
this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->SetSprite(protect_sprite + this->vli.vtype);
/* Set text of "group by" dropdown widget. */
@@ -650,7 +650,7 @@ public:
assert(g->owner == this->owner);
DrawGroupInfo(y1, r.left, r.right, g->index, it->level_mask, it->indent, HasFlag(g->flags, GroupFlags::ReplaceProtection), g->folded || (std::next(it) != std::end(this->groups) && std::next(it)->indent > it->indent));
DrawGroupInfo(y1, r.left, r.right, g->index, it->level_mask, it->indent, g->flags.Test(GroupFlag::ReplaceProtection), g->folded || (std::next(it) != std::end(this->groups) && std::next(it)->indent > it->indent));
y1 += this->tiny_step_height;
}
@@ -868,7 +868,7 @@ public:
case WID_GL_REPLACE_PROTECTION: {
const Group *g = Group::GetIfValid(this->vli.index);
if (g != nullptr) {
Command<CMD_SET_GROUP_FLAG>::Post(this->vli.index, GroupFlags::ReplaceProtection, !HasFlag(g->flags, GroupFlags::ReplaceProtection), _ctrl_pressed);
Command<CMD_SET_GROUP_FLAG>::Post(this->vli.index, GroupFlag::ReplaceProtection, !g->flags.Test(GroupFlag::ReplaceProtection), _ctrl_pressed);
}
break;
}