mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:00:42 +00:00
bug fix?: Hide UnitDisplay frame when all unit types are disabled (#1392)
## Description: This PR updates the UnitDisplay component so that when all unit types (City, Factory, Port, Defense Post, Missile Silo, SAM Launcher) are disabled in the game config, the UI frame itself will also be hidden. This is a box that shows how many and what types of units the player currently owns. There’s a feature where, if unit types are disabled in the settings, the corresponding parts of the UI will disappear. However, if all unit types are disabled, for some reason the outer container still remains visible. While this might not be a critical issue, I feel it’s unnecessary and redundant, so I’d like to remove it. Alternatively, we could consider keeping the box as a kind of placeholder to indicate that some kind of menu might appear there. But since it serves no purpose during gameplay in that state, I think it would just be meaningless UI. before <img width="1049" alt="スクリーンショット 2025-07-10 12 49 37" src="https://github.com/user-attachments/assets/b0cf12ba-0c20-4b21-bf9f-cb17fec6817b" /> <img width="44" alt="スクリーンショット 2025-07-10 12 49 47" src="https://github.com/user-attachments/assets/61e1960b-56d4-4dc8-80e7-27e49cb2d0e3" /> after <img width="967" alt="スクリーンショット 2025-07-10 12 48 08" src="https://github.com/user-attachments/assets/dfc90243-e4d6-4663-bff5-5be34453e80b" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: aotumuri
This commit is contained in:
@@ -24,12 +24,21 @@ export class UnitDisplay extends LitElement implements Layer {
|
||||
private _port = 0;
|
||||
private _defensePost = 0;
|
||||
private _samLauncher = 0;
|
||||
private allDisabled = false;
|
||||
|
||||
createRenderRoot() {
|
||||
return this;
|
||||
}
|
||||
|
||||
init() {
|
||||
const config = this.game.config();
|
||||
this.allDisabled =
|
||||
config.isUnitDisabled(UnitType.City) &&
|
||||
config.isUnitDisabled(UnitType.Factory) &&
|
||||
config.isUnitDisabled(UnitType.Port) &&
|
||||
config.isUnitDisabled(UnitType.DefensePost) &&
|
||||
config.isUnitDisabled(UnitType.MissileSilo) &&
|
||||
config.isUnitDisabled(UnitType.SAMLauncher);
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
@@ -89,6 +98,10 @@ export class UnitDisplay extends LitElement implements Layer {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.allDisabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return html`
|
||||
<div
|
||||
class="fixed bottom-4 left-1/2 transform -translate-x-1/2 z-[1100] bg-gray-800/70 backdrop-blur-sm border border-slate-400 rounded-lg p-2 hidden lg:block"
|
||||
|
||||
Reference in New Issue
Block a user