mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-30 05:09:42 +00:00
Feat: Quick donate troops via radial menu (#2708)
If this PR fixes an issue, link it below. If not, delete these two lines. Resolves #2705 ## Description: Introduces a quick donation feature in games where the `canDonateTroops` option is enabled. It works by converting the center button in the radial menu from a disabled attack button to a troop donate button when the player right clicked on is friendly (teammate or ally). Also adds donate gold button to Attack slot on radial menu when right clicking friendly troops. ### Video Example https://github.com/user-attachments/assets/d9b2c3f7-b6c0-482a-9dbd-b3841676cbe5 ### New Icon <img width="1310" height="931" alt="image" src="https://github.com/user-attachments/assets/85225858-6971-470d-92f6-db68a5d05bb2" /> ### Donate Gold https://github.com/user-attachments/assets/b116bc06-d53d-47c7-9504-871eada6a21e ## 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 ## Please put your Discord username so you can be contacted if a bug or regression is found: bijx
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
rootMenuElement,
|
||||
} from "./RadialMenuElements";
|
||||
|
||||
import donateTroopIcon from "../../../../resources/images/DonateTroopIconWhite.svg";
|
||||
import swordIcon from "../../../../resources/images/SwordIconWhite.svg";
|
||||
import { ContextMenuEvent } from "../../InputHandler";
|
||||
|
||||
@@ -127,10 +128,22 @@ export class MainRadialMenu extends LitElement implements Layer {
|
||||
playerActionHandler: this.playerActionHandler,
|
||||
playerPanel: this.playerPanel,
|
||||
chatIntegration: this.chatIntegration,
|
||||
uiState: this.uiState,
|
||||
closeMenu: () => this.closeMenu(),
|
||||
eventBus: this.eventBus,
|
||||
};
|
||||
|
||||
const isFriendlyTarget =
|
||||
recipient !== null && recipient.isFriendly(myPlayer);
|
||||
|
||||
this.radialMenu.setCenterButtonAppearance(
|
||||
isFriendlyTarget ? donateTroopIcon : swordIcon,
|
||||
isFriendlyTarget ? "#34D399" : "#2c3e50",
|
||||
isFriendlyTarget
|
||||
? this.radialMenu.getDefaultCenterIconSize() * 0.75
|
||||
: this.radialMenu.getDefaultCenterIconSize(),
|
||||
);
|
||||
|
||||
this.radialMenu.setParams(params);
|
||||
if (screenX !== null && screenY !== null) {
|
||||
this.radialMenu.showRadialMenu(screenX, screenY);
|
||||
|
||||
Reference in New Issue
Block a user