mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 17:53:29 +00:00
feat: add icon when player request alliance
To spot who asked alliance on the map add an email icon next to them
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
*.bin
|
*.bin
|
||||||
|
*.svg
|
||||||
*.png
|
*.png
|
||||||
*.jpg
|
*.jpg
|
||||||
*.jpeg
|
*.jpeg
|
||||||
@@ -6,4 +7,4 @@
|
|||||||
*.webp
|
*.webp
|
||||||
*.txt
|
*.txt
|
||||||
.prettierignore
|
.prettierignore
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg fill="#000000" height="800px" width="800px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
viewBox="0 0 75.294 75.294" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<path d="M66.097,12.089h-56.9C4.126,12.089,0,16.215,0,21.286v32.722c0,5.071,4.126,9.197,9.197,9.197h56.9
|
||||||
|
c5.071,0,9.197-4.126,9.197-9.197V21.287C75.295,16.215,71.169,12.089,66.097,12.089z M61.603,18.089L37.647,33.523L13.691,18.089
|
||||||
|
H61.603z M66.097,57.206h-56.9C7.434,57.206,6,55.771,6,54.009V21.457l29.796,19.16c0.04,0.025,0.083,0.042,0.124,0.065
|
||||||
|
c0.043,0.024,0.087,0.047,0.131,0.069c0.231,0.119,0.469,0.215,0.712,0.278c0.025,0.007,0.05,0.01,0.075,0.016
|
||||||
|
c0.267,0.063,0.537,0.102,0.807,0.102c0.001,0,0.002,0,0.002,0c0.002,0,0.003,0,0.004,0c0.27,0,0.54-0.038,0.807-0.102
|
||||||
|
c0.025-0.006,0.05-0.009,0.075-0.016c0.243-0.063,0.48-0.159,0.712-0.278c0.044-0.022,0.088-0.045,0.131-0.069
|
||||||
|
c0.041-0.023,0.084-0.04,0.124-0.065l29.796-19.16v32.551C69.295,55.771,67.86,57.206,66.097,57.206z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -11,6 +11,7 @@ import { Layer } from "./Layer";
|
|||||||
import { TransformHandler } from "../TransformHandler";
|
import { TransformHandler } from "../TransformHandler";
|
||||||
import traitorIcon from "../../../../resources/images/TraitorIcon.svg";
|
import traitorIcon from "../../../../resources/images/TraitorIcon.svg";
|
||||||
import allianceIcon from "../../../../resources/images/AllianceIcon.svg";
|
import allianceIcon from "../../../../resources/images/AllianceIcon.svg";
|
||||||
|
import allianceRequestIcon from "../../../../resources/images/AllianceRequestIcon.svg";
|
||||||
import crownIcon from "../../../../resources/images/CrownIcon.svg";
|
import crownIcon from "../../../../resources/images/CrownIcon.svg";
|
||||||
import targetIcon from "../../../../resources/images/TargetIcon.svg";
|
import targetIcon from "../../../../resources/images/TargetIcon.svg";
|
||||||
import { ClientID } from "../../../core/Schemas";
|
import { ClientID } from "../../../core/Schemas";
|
||||||
@@ -40,6 +41,7 @@ export class NameLayer implements Layer {
|
|||||||
private renders: RenderInfo[] = [];
|
private renders: RenderInfo[] = [];
|
||||||
private seenPlayers: Set<PlayerView> = new Set();
|
private seenPlayers: Set<PlayerView> = new Set();
|
||||||
private traitorIconImage: HTMLImageElement;
|
private traitorIconImage: HTMLImageElement;
|
||||||
|
private allianceRequestIconImage: HTMLImageElement;
|
||||||
private allianceIconImage: HTMLImageElement;
|
private allianceIconImage: HTMLImageElement;
|
||||||
private targetIconImage: HTMLImageElement;
|
private targetIconImage: HTMLImageElement;
|
||||||
private crownIconImage: HTMLImageElement;
|
private crownIconImage: HTMLImageElement;
|
||||||
@@ -57,6 +59,8 @@ export class NameLayer implements Layer {
|
|||||||
this.traitorIconImage.src = traitorIcon;
|
this.traitorIconImage.src = traitorIcon;
|
||||||
this.allianceIconImage = new Image();
|
this.allianceIconImage = new Image();
|
||||||
this.allianceIconImage.src = allianceIcon;
|
this.allianceIconImage.src = allianceIcon;
|
||||||
|
this.allianceRequestIconImage = new Image();
|
||||||
|
this.allianceRequestIconImage.src = allianceRequestIcon;
|
||||||
this.crownIconImage = new Image();
|
this.crownIconImage = new Image();
|
||||||
this.crownIconImage.src = crownIcon;
|
this.crownIconImage.src = crownIcon;
|
||||||
this.targetIconImage = new Image();
|
this.targetIconImage = new Image();
|
||||||
@@ -314,6 +318,23 @@ export class NameLayer implements Layer {
|
|||||||
existingAlliance.remove();
|
existingAlliance.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Alliance request icon
|
||||||
|
const data = '[data-icon="alliance-request"]';
|
||||||
|
const existingRequestAlliance = iconsDiv.querySelector(data);
|
||||||
|
if (myPlayer != null && render.player.isRequestingAllianceWith(myPlayer)) {
|
||||||
|
if (!existingRequestAlliance) {
|
||||||
|
iconsDiv.appendChild(
|
||||||
|
this.createIconElement(
|
||||||
|
this.allianceRequestIconImage.src,
|
||||||
|
iconSize,
|
||||||
|
"alliance-request",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (existingRequestAlliance) {
|
||||||
|
existingRequestAlliance.remove();
|
||||||
|
}
|
||||||
|
|
||||||
// Target icon
|
// Target icon
|
||||||
const existingTarget = iconsDiv.querySelector('[data-icon="target"]');
|
const existingTarget = iconsDiv.querySelector('[data-icon="target"]');
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ClientID } from "../Schemas";
|
import { ClientID } from "../Schemas";
|
||||||
import {
|
import {
|
||||||
|
AllianceRequest,
|
||||||
EmojiMessage,
|
EmojiMessage,
|
||||||
GameUpdates,
|
GameUpdates,
|
||||||
MapPos,
|
MapPos,
|
||||||
@@ -99,6 +100,7 @@ export interface PlayerUpdate {
|
|||||||
outgoingEmojis: EmojiMessage[];
|
outgoingEmojis: EmojiMessage[];
|
||||||
outgoingAttacks: AttackUpdate[];
|
outgoingAttacks: AttackUpdate[];
|
||||||
incomingAttacks: AttackUpdate[];
|
incomingAttacks: AttackUpdate[];
|
||||||
|
outgoingAllianceRequests: PlayerID[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AllianceRequestUpdate {
|
export interface AllianceRequestUpdate {
|
||||||
|
|||||||
@@ -187,6 +187,10 @@ export class PlayerView {
|
|||||||
return this.data.allies.some((n) => other.smallID() == n);
|
return this.data.allies.some((n) => other.smallID() == n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isRequestingAllianceWith(other: PlayerView) {
|
||||||
|
return this.data.outgoingAllianceRequests.some((id) => other.id() == id);
|
||||||
|
}
|
||||||
|
|
||||||
profile(): Promise<PlayerProfile> {
|
profile(): Promise<PlayerProfile> {
|
||||||
return this.game.worker.playerProfile(this.smallID());
|
return this.game.worker.playerProfile(this.smallID());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ export class PlayerImpl implements Player {
|
|||||||
largestClusterBoundingBox: { min: Cell; max: Cell } | null;
|
largestClusterBoundingBox: { min: Cell; max: Cell } | null;
|
||||||
|
|
||||||
toUpdate(): PlayerUpdate {
|
toUpdate(): PlayerUpdate {
|
||||||
|
const outgoingAllianceRequests = this.outgoingAllianceRequests().map((ar) =>
|
||||||
|
ar.recipient().id(),
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: GameUpdateType.Player,
|
type: GameUpdateType.Player,
|
||||||
clientID: this.clientID(),
|
clientID: this.clientID(),
|
||||||
@@ -138,6 +142,7 @@ export class PlayerImpl implements Player {
|
|||||||
troops: a.troops(),
|
troops: a.troops(),
|
||||||
}) as AttackUpdate,
|
}) as AttackUpdate,
|
||||||
),
|
),
|
||||||
|
outgoingAllianceRequests: outgoingAllianceRequests,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user