Skip to content

Commit 93cf256

Browse files
VariableVincePhantasm0009
authored andcommitted
Alert frame: add to in-game settings, orange for attack instead of red (openfrontio#2561)
## Description: The red alert frame for betrayals was added in openfrontio#1195. It also flashes red for incoming land attacks since openfrontio#2358. The same color for betrayals and attacks leads to confusion. And possibly red alert fatigue. But when players find themselves fatigued and want to shut it off for awhile, they can't because the setting doesn't exist in-game. Also, the setting description on the homepage settings didn't yet reflect that the alert frame flashes for attacks too. This PR fixes this by: - making the color for land attacks orange. This is well discernable from red for various colorblindness types, while still looking alarming. - adding the setting to in-game SettingsModal - adding land attack to setting description Reference to comments on it on Dev Discord: https://discord.com/channels/1359946986937258015/1381347989464809664/1441232666065240064 https://discord.com/channels/1359946986937258015/1360078040222142564/1434574256704061523 Orange alert frame on being attacked over land: https://github.com/user-attachments/assets/e0772d62-5b25-4213-a393-dd5af13e8bc9 Settings description change and addition to in-game toggles: <img width="560" height="160" alt="Added to description what was added in PR 2358" src="https://github.com/user-attachments/assets/bc6e2206-b7ac-498d-9009-d2b6e302d3cf" /> <img width="665" height="425" alt="In SettingsModal and with attacks added to description" src="https://github.com/user-attachments/assets/d489830c-e359-4a5f-8eb4-3caa7d0c21b2" /> ## 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: tryout33
1 parent d0a047b commit 93cf256

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed
Lines changed: 11 additions & 0 deletions
Loading

resources/lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
"emojis_label": "Emojis",
337337
"emojis_desc": "Toggle whether emojis are shown in game",
338338
"alert_frame_label": "Alert Frame",
339-
"alert_frame_desc": "Toggle the alert frame. When enabled, the frame will be displayed when you are betrayed.",
339+
"alert_frame_desc": "Toggle the alert frame. When enabled, the frame will be displayed when you are betrayed or attacked over land.",
340340
"special_effects_label": "Special effects",
341341
"special_effects_desc": "Toggle special effects. Deactivate to improve performances",
342342
"structure_sprites_label": "Structure Sprites",

src/client/graphics/layers/AlertFrame.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export class AlertFrame extends LitElement implements Layer {
2121

2222
@state()
2323
private isActive = false;
24+
@state()
25+
private alertType: "betrayal" | "land-attack" = "betrayal";
2426

2527
private animationTimeout: number | null = null;
2628
private seenAttackIds: Set<string> = new Set();
@@ -36,12 +38,20 @@ export class AlertFrame extends LitElement implements Layer {
3638
width: 100%;
3739
height: 100%;
3840
pointer-events: none;
39-
border: 17px solid #ee0000;
41+
border: 17px solid;
4042
box-sizing: border-box;
4143
z-index: 40;
4244
opacity: 0;
4345
}
4446
47+
.alert-border.betrayal {
48+
border-color: #ee0000;
49+
}
50+
51+
.alert-border.land-attack {
52+
border-color: #ffa500;
53+
}
54+
4555
.alert-border.animate {
4656
animation: alertBlink ${ALERT_SPEED}s ease-in-out ${ALERT_COUNT};
4757
}
@@ -119,6 +129,7 @@ export class AlertFrame extends LitElement implements Layer {
119129

120130
// Only trigger alert if the current player is the betrayed one
121131
if (betrayed === myPlayer) {
132+
this.alertType = "betrayal";
122133
this.activateAlert();
123134
}
124135
}
@@ -202,6 +213,7 @@ export class AlertFrame extends LitElement implements Layer {
202213
// 3. The attack is too small (less than 1/5 of our troops)
203214
if (!inCooldown && !isRetaliation && !isSmallAttack) {
204215
this.seenAttackIds.add(attack.id);
216+
this.alertType = "land-attack";
205217
this.activateAlert();
206218
} else {
207219
// Still mark as seen so we don't alert later
@@ -237,7 +249,7 @@ export class AlertFrame extends LitElement implements Layer {
237249

238250
return html`
239251
<div
240-
class="alert-border animate"
252+
class=${`alert-border animate ${this.alertType}`}
241253
@animationend=${() => this.dismissAlert()}
242254
></div>
243255
`;

src/client/graphics/layers/SettingsModal.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import explosionIcon from "../../../../resources/images/ExplosionIconWhite.svg";
88
import mouseIcon from "../../../../resources/images/MouseIconWhite.svg";
99
import ninjaIcon from "../../../../resources/images/NinjaIconWhite.svg";
1010
import settingsIcon from "../../../../resources/images/SettingIconWhite.svg";
11+
import sirenIcon from "../../../../resources/images/SirenIconWhite.svg";
1112
import treeIcon from "../../../../resources/images/TreeIconWhite.svg";
1213
import musicIcon from "../../../../resources/images/music.svg";
1314
import { EventBus } from "../../../core/EventBus";
@@ -130,6 +131,11 @@ export class SettingsModal extends LitElement implements Layer {
130131
this.requestUpdate();
131132
}
132133

134+
private onToggleAlertFrameButtonClick() {
135+
this.userSettings.toggleAlertFrame();
136+
this.requestUpdate();
137+
}
138+
133139
private onToggleDarkModeButtonClick() {
134140
this.userSettings.toggleDarkMode();
135141
this.eventBus.emit(new RefreshGraphicsEvent());
@@ -346,6 +352,26 @@ export class SettingsModal extends LitElement implements Layer {
346352
</div>
347353
</button>
348354
355+
<button
356+
class="flex gap-3 items-center w-full text-left p-3 hover:bg-slate-700 rounded text-white transition-colors"
357+
@click="${this.onToggleAlertFrameButtonClick}"
358+
>
359+
<img src=${sirenIcon} alt="alertFrame" width="20" height="20" />
360+
<div class="flex-1">
361+
<div class="font-medium">
362+
${translateText("user_setting.alert_frame_label")}
363+
</div>
364+
<div class="text-sm text-slate-400">
365+
${translateText("user_setting.alert_frame_desc")}
366+
</div>
367+
</div>
368+
<div class="text-sm text-slate-400">
369+
${this.userSettings.alertFrame()
370+
? translateText("user_setting.on")
371+
: translateText("user_setting.off")}
372+
</div>
373+
</button>
374+
349375
<button
350376
class="flex gap-3 items-center w-full text-left p-3 hover:bg-slate-700 rounded text-white transition-colors"
351377
@click="${this.onToggleStructureSpritesButtonClick}"

0 commit comments

Comments
 (0)