From ef5ed59e08661f637782b59786027ffeb5dcc86d Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 12 Jun 2025 10:13:55 -0700 Subject: [PATCH] dynamic radial menu build options (#1152) ## Description: Show different build options depending on where player clicked. If they clicked on their own territory show structures, if not show nukes & warship. ## 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: --- .../graphics/layers/RadialMenuElements.ts | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/client/graphics/layers/RadialMenuElements.ts b/src/client/graphics/layers/RadialMenuElements.ts index a8b180ef6..2bcd5d765 100644 --- a/src/client/graphics/layers/RadialMenuElements.ts +++ b/src/client/graphics/layers/RadialMenuElements.ts @@ -3,6 +3,7 @@ import { Cell, PlayerActions, TerraNullius, + UnitType, } from "../../../core/game/Game"; import { TileRef } from "../../../core/game/GameMap"; import { GameView, PlayerView } from "../../../core/game/GameView"; @@ -309,8 +310,23 @@ export const buildMenuElement: MenuElement = { color: COLORS.build, subMenu: (params: MenuElementParams) => { - const buildElements: MenuElement[] = flattenedBuildTable.map( - (item: BuildItemDisplay) => ({ + const unitTypes: Set = new Set(); + if (params.selected === params.myPlayer) { + unitTypes.add(UnitType.City); + unitTypes.add(UnitType.DefensePost); + unitTypes.add(UnitType.Port); + unitTypes.add(UnitType.MissileSilo); + unitTypes.add(UnitType.SAMLauncher); + } else { + unitTypes.add(UnitType.Warship); + unitTypes.add(UnitType.HydrogenBomb); + unitTypes.add(UnitType.MIRV); + unitTypes.add(UnitType.AtomBomb); + } + + const buildElements: MenuElement[] = flattenedBuildTable + .filter((item) => unitTypes.has(item.unitType)) + .map((item: BuildItemDisplay) => ({ id: `build_${item.unitType}`, name: item.key ? item.key.replace("unit_type.", "") @@ -341,19 +357,7 @@ export const buildMenuElement: MenuElement = { ); params.closeMenu(); }, - }), - ); - - buildElements.push({ - id: "build_menu", - name: "build", - disabled: () => false, - color: COLORS.build, - icon: buildIcon, - action: (params: MenuElementParams) => { - params.buildMenu.showMenu(params.tile); - }, - }); + })); return buildElements; },