1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-20 21:19:10 +00:00

Change: Hide all variants from UI when (display) parent is hidden. (#10708)

This commit is contained in:
2023-04-25 20:34:10 +01:00
committed by GitHub
parent 5794590b36
commit 1697dff744
4 changed files with 41 additions and 5 deletions

View File

@@ -475,6 +475,30 @@ StringID Engine::GetAircraftTypeText() const
}
}
/**
* Check whether the engine variant chain is hidden in the GUI for the given company.
* @param c Company to check.
* @return \c true iff the engine variant chain is hidden in the GUI for the given company.
*/
bool Engine::IsVariantHidden(CompanyID c) const
{
/* In case company is spectator. */
if (c >= MAX_COMPANIES) return false;
/* Shortcut if this engine is explicitly hidden. */
if (this->IsHidden(c)) return true;
/* Check for hidden parent variants. This is a bit convoluted as we must check hidden status of
* the last display variant rather than the actual parent variant. */
const Engine *re = this;
const Engine *ve = re->GetDisplayVariant();
while (!(ve->IsHidden(c)) && re->info.variant_id != INVALID_ENGINE && re->info.variant_id != re->index) {
re = Engine::Get(re->info.variant_id);
ve = re->GetDisplayVariant();
}
return ve->IsHidden(c);
}
/**
* Initializes the #EngineOverrideManager with the default engines.
*/