Add button for remove building (#1609)

## Description:

Added a red delete button with trash can icon to the right-click radial
menu that allows players to voluntarily delete their own units.

## 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 have read and accepted the CLA agreement (only required once).

## Please put your Discord username so you can be contacted if a bug or
regression is found:

Kipstz

<img width="286" height="209" alt="image"
src="https://github.com/user-attachments/assets/85142be3-2aa5-4c84-ab30-0c68289c8f85"
/>

---------

Co-authored-by: Drills Kibo <59177241+drillskibo@users.noreply.github.com>
This commit is contained in:
Kipstz
2025-09-03 16:06:07 -07:00
committed by evanpelle
co-authored by Drills Kibo
parent 209de56ae6
commit 4b129a2f7f
15 changed files with 359 additions and 7 deletions
+12 -2
View File
@@ -2,11 +2,13 @@ import * as d3 from "d3";
import backIcon from "../../../../resources/images/BackIconWhite.svg";
import { EventBus, GameEvent } from "../../../core/EventBus";
import { CloseViewEvent } from "../../InputHandler";
import { translateText } from "../../Utils";
import { Layer } from "./Layer";
import {
CenterButtonElement,
MenuElement,
MenuElementParams,
TooltipKey,
} from "./RadialMenuElements";
export class CloseRadialMenuEvent implements GameEvent {
@@ -386,6 +388,8 @@ export class RadialMenu implements Layer {
const disabled = this.params === null || d.data.disabled(this.params);
if (d.data.tooltipItems && d.data.tooltipItems.length > 0) {
this.showTooltip(d.data.tooltipItems);
} else if (d.data.tooltipKeys && d.data.tooltipKeys.length > 0) {
this.showTooltip(d.data.tooltipKeys);
}
if (
disabled ||
@@ -1008,7 +1012,7 @@ export class RadialMenu implements Layer {
return timeSinceHide >= this.reopenCooldownMs;
}
private showTooltip(items: TooltipItem[]) {
private showTooltip(items: TooltipItem[] | TooltipKey[]) {
if (!this.tooltipElement) return;
this.tooltipElement.innerHTML = "";
@@ -1016,7 +1020,13 @@ export class RadialMenu implements Layer {
for (const item of items) {
const div = document.createElement("div");
div.className = item.className;
div.textContent = item.text;
if ("key" in item) {
div.textContent = translateText(item.key, item.params);
} else {
div.textContent = item.text;
}
this.tooltipElement.appendChild(div);
}