diff --git a/CREDITS.md b/CREDITS.md index 01de8a95b..e17b2b575 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -49,3 +49,4 @@ Copyright © opentopography.org. All Rights Reserved. [Terms of Use](https://ope ### [The Noun Project](https://thenounproject.com/) Stats icon by [Meko](https://thenounproject.com/mekoda/) – https://thenounproject.com/icon/stats-4942475/ +Pay Per Click icon by [Fauzan Adiima](https://thenounproject.com/creator/fauzan94/) – https://thenounproject.com/icon/pay-per-click-2586454/ diff --git a/resources/images/CursorPriceIconWhite.svg b/resources/images/CursorPriceIconWhite.svg new file mode 100644 index 000000000..edc28312d --- /dev/null +++ b/resources/images/CursorPriceIconWhite.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + pay per click, ppc, click, cost per click, mouse + + + + + Created by Fauzan Adiima + from the Noun Project + diff --git a/resources/lang/en.json b/resources/lang/en.json index 8a81345f3..ad8f421aa 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -376,6 +376,8 @@ "special_effects_desc": "Toggle special effects. Deactivate to improve performances", "structure_sprites_label": "Structure Sprites", "structure_sprites_desc": "Toggle structure sprites", + "cursor_cost_label_label": "Cursor Build Cost", + "cursor_cost_label_desc": "Show a cost pill under the build cursor icon", "anonymous_names_label": "Hidden Names", "anonymous_names_desc": "Hide real player names with random ones on your screen.", "lobby_id_visibility_label": "Hidden Lobby IDs", diff --git a/src/client/UserSettingModal.ts b/src/client/UserSettingModal.ts index 3fa54b34d..39f2967c7 100644 --- a/src/client/UserSettingModal.ts +++ b/src/client/UserSettingModal.ts @@ -143,6 +143,15 @@ export class UserSettingModal extends LitElement { console.log("🏠 Structure sprites:", enabled ? "ON" : "OFF"); } + private toggleCursorCostLabel(e: CustomEvent<{ checked: boolean }>) { + const enabled = e.detail?.checked; + if (typeof enabled !== "boolean") return; + + this.userSettings.set("settings.cursorCostLabel", enabled); + + console.log("💰 Cursor build cost:", enabled ? "ON" : "OFF"); + } + private toggleAnonymousNames(e: CustomEvent<{ checked: boolean }>) { const enabled = e.detail?.checked; if (typeof enabled !== "boolean") return; @@ -309,6 +318,15 @@ export class UserSettingModal extends LitElement { @change=${this.toggleStructureSprites} > + + + + + + + + ${translateText("user_setting.cursor_cost_label_label")} + + + ${translateText("user_setting.cursor_cost_label_desc")} + + + + ${this.userSettings.cursorCostLabel() + ? translateText("user_setting.on") + : translateText("user_setting.off")} + + + u.type === this.ghostUnit!.buildableUnit.type, ); + const showPrice = this.game.config().userSettings().cursorCostLabel(); if (!unit) { Object.assign(this.ghostUnit.buildableUnit, { canBuild: false, canUpgrade: false, }); - this.updateGhostPrice(0); + this.updateGhostPrice(0, showPrice); this.ghostUnit.container.filters = [ new OutlineFilter({ thickness: 2, color: "rgba(255, 0, 0, 1)" }), ]; @@ -283,7 +285,7 @@ export class StructureIconsLayer implements Layer { } this.ghostUnit.buildableUnit = unit; - this.updateGhostPrice(unit.cost ?? 0); + this.updateGhostPrice(unit.cost ?? 0, showPrice); const targetLevel = this.resolveGhostRangeLevel(unit); this.updateGhostRange(targetLevel); @@ -318,9 +320,12 @@ export class StructureIconsLayer implements Layer { }); } - private updateGhostPrice(cost: bigint | number) { + private updateGhostPrice(cost: bigint | number, showPrice: boolean) { if (!this.ghostUnit) return; - const { priceText, priceBg, priceBox } = this.ghostUnit; + const { priceText, priceBg, priceBox, priceGroup } = this.ghostUnit; + priceGroup.visible = showPrice; + if (!showPrice) return; + priceText.text = renderNumber(cost); priceText.position.set(0, priceBox.y); @@ -407,11 +412,13 @@ export class StructureIconsLayer implements Layer { container: ghost.container, priceText: ghost.priceText, priceBg: ghost.priceBg, + priceGroup: ghost.priceGroup, priceBox: ghost.priceBox, range: null, buildableUnit: { type, canBuild: false, canUpgrade: false, cost: 0n }, }; - this.updateGhostPrice(0); + const showPrice = this.game.config().userSettings().cursorCostLabel(); + this.updateGhostPrice(0, showPrice); const baseLevel = this.resolveGhostRangeLevel(this.ghostUnit.buildableUnit); this.updateGhostRange(baseLevel); } diff --git a/src/core/game/UserSettings.ts b/src/core/game/UserSettings.ts index ad1eb4249..ba74b9ae8 100644 --- a/src/core/game/UserSettings.ts +++ b/src/core/game/UserSettings.ts @@ -73,6 +73,11 @@ export class UserSettings { return this.get("settings.territoryPatterns", true); } + cursorCostLabel() { + const legacy = this.get("settings.ghostPricePill", true); + return this.get("settings.cursorCostLabel", legacy); + } + focusLocked() { return false; // TODO: re-enable when performance issues are fixed. @@ -115,6 +120,10 @@ export class UserSettings { this.set("settings.structureSprites", !this.structureSprites()); } + toggleCursorCostLabel() { + this.set("settings.cursorCostLabel", !this.cursorCostLabel()); + } + toggleTerritoryPatterns() { this.set("settings.territoryPatterns", !this.territoryPatterns()); }