mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-22 21:55:22 +00:00
move TransformHandler/UIState/Controller out of graphics/, drop dead GhostStructureChangedEvent
graphics/ was a canvas2D-era directory name — TransformHandler, UIState, and the Controller interface aren't graphics, they're cross-cutting client state. Hoist them to src/client/ so the path matches what they are. GhostStructureChangedEvent had three emitters and zero listeners; removed.
This commit is contained in:
@@ -46,6 +46,7 @@ import {
|
||||
} from "./InputHandler";
|
||||
import { endGame, startGame, startTime } from "./LocalPersistantStats";
|
||||
import { terrainMapFileLoader } from "./TerrainMapFileLoader";
|
||||
import { GoToPlayerEvent } from "./TransformHandler";
|
||||
import {
|
||||
MoveWarshipIntentEvent,
|
||||
SendAllianceExtensionIntentEvent,
|
||||
@@ -61,7 +62,6 @@ import {
|
||||
import { createCanvas } from "./Utils";
|
||||
import { WebGLFrameBuilder } from "./WebGLFrameBuilder";
|
||||
import { createRenderer, GameRenderer } from "./graphics/GameRenderer";
|
||||
import { GoToPlayerEvent } from "./graphics/TransformHandler";
|
||||
import { GameView as WebGLGameView } from "./render/gl";
|
||||
import { ALL_UNIT_TYPES } from "./render/types";
|
||||
import { SoundManager } from "./sound/SoundManager";
|
||||
@@ -299,7 +299,7 @@ function mountWebGLDebugRenderer(
|
||||
view: WebGLGameView,
|
||||
glCanvas: HTMLCanvasElement,
|
||||
cachedWebGLFrameCallback: { current: FrameRequestCallback | null },
|
||||
transformHandler: import("./graphics/TransformHandler").TransformHandler,
|
||||
transformHandler: import("./TransformHandler").TransformHandler,
|
||||
gameView: GameView,
|
||||
eventBus: EventBus,
|
||||
): { builder: WebGLFrameBuilder } {
|
||||
|
||||
@@ -2,8 +2,8 @@ import { EventBus, GameEvent } from "../core/EventBus";
|
||||
import { PlayerBuildableUnitType, UnitType } from "../core/game/Game";
|
||||
import { GameView, UnitView } from "../core/game/GameView";
|
||||
import { UserSettings } from "../core/game/UserSettings";
|
||||
import { UIState } from "./graphics/UIState";
|
||||
import { Platform } from "./Platform";
|
||||
import { UIState } from "./UIState";
|
||||
import { ReplaySpeedMultiplier } from "./utilities/ReplaySpeedMultiplier";
|
||||
|
||||
export class MouseUpEvent implements GameEvent {
|
||||
@@ -92,10 +92,6 @@ export class ToggleStructureEvent implements GameEvent {
|
||||
) {}
|
||||
}
|
||||
|
||||
export class GhostStructureChangedEvent implements GameEvent {
|
||||
constructor(public readonly ghostStructure: PlayerBuildableUnitType | null) {}
|
||||
}
|
||||
|
||||
export class ConfirmGhostStructureEvent implements GameEvent {}
|
||||
|
||||
export class SwapRocketDirectionEvent implements GameEvent {
|
||||
@@ -850,7 +846,6 @@ export class InputHandler {
|
||||
|
||||
private setGhostStructure(ghostStructure: PlayerBuildableUnitType | null) {
|
||||
this.uiState.ghostStructure = ghostStructure;
|
||||
this.eventBus.emit(new GhostStructureChangedEvent(ghostStructure));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { EventBus, GameEvent } from "../../core/EventBus";
|
||||
import { Cell } from "../../core/game/Game";
|
||||
import { GameView, PlayerView, UnitView } from "../../core/game/GameView";
|
||||
import { CenterCameraEvent, DragEvent, ZoomEvent } from "../InputHandler";
|
||||
import { EventBus, GameEvent } from "../core/EventBus";
|
||||
import { Cell } from "../core/game/Game";
|
||||
import { GameView, PlayerView, UnitView } from "../core/game/GameView";
|
||||
import { CenterCameraEvent, DragEvent, ZoomEvent } from "./InputHandler";
|
||||
|
||||
export class GoToPlayerEvent implements GameEvent {
|
||||
constructor(
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PlayerBuildableUnitType } from "../../core/game/Game";
|
||||
import { TileRef } from "../../core/game/GameMap";
|
||||
import { PlayerBuildableUnitType } from "../core/game/Game";
|
||||
import { TileRef } from "../core/game/GameMap";
|
||||
|
||||
export interface UIState {
|
||||
attackRatio: number;
|
||||
@@ -16,21 +16,20 @@ import {
|
||||
} from "../../core/game/Game";
|
||||
import { TileRef } from "../../core/game/GameMap";
|
||||
import { GameView } from "../../core/game/GameView";
|
||||
import { Controller } from "../graphics/layers/Controller";
|
||||
import { TransformHandler } from "../graphics/TransformHandler";
|
||||
import { UIState } from "../graphics/UIState";
|
||||
import { Controller } from "../Controller";
|
||||
import {
|
||||
ConfirmGhostStructureEvent,
|
||||
GhostStructureChangedEvent,
|
||||
MouseMoveEvent,
|
||||
MouseUpEvent,
|
||||
} from "../InputHandler";
|
||||
import { GameView as WebGLGameView } from "../render/gl";
|
||||
import type { GhostPreviewData } from "../render/types";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import {
|
||||
BuildUnitIntentEvent,
|
||||
SendUpgradeStructureIntentEvent,
|
||||
} from "../Transport";
|
||||
import { UIState } from "../UIState";
|
||||
|
||||
/** True for nuke types (AtomBomb, HydrogenBomb): ghost is preserved after placement so user can place multiple or keep selection (Enter/key confirm). */
|
||||
export function shouldPreserveGhostAfterBuild(unitType: UnitType): boolean {
|
||||
@@ -314,7 +313,6 @@ export class BuildPreviewController implements Controller {
|
||||
private removeGhostStructure() {
|
||||
this.clearGhostStructure();
|
||||
this.uiState.ghostStructure = null;
|
||||
this.eventBus.emit(new GhostStructureChangedEvent(null));
|
||||
}
|
||||
|
||||
private resolveGhostRangeLevel(
|
||||
|
||||
@@ -3,8 +3,7 @@ import { EventBus } from "../../core/EventBus";
|
||||
import { UnitType } from "../../core/game/Game";
|
||||
import { TileRef } from "../../core/game/GameMap";
|
||||
import { GameView, UnitView } from "../../core/game/GameView";
|
||||
import { Controller } from "../graphics/layers/Controller";
|
||||
import { TransformHandler } from "../graphics/TransformHandler";
|
||||
import { Controller } from "../Controller";
|
||||
import {
|
||||
CloseViewEvent,
|
||||
ContextMenuEvent,
|
||||
@@ -17,6 +16,7 @@ import {
|
||||
WarshipSelectionBoxUpdateEvent,
|
||||
} from "../InputHandler";
|
||||
import { GameView as WebGLGameView } from "../render/gl";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { MoveWarshipIntentEvent } from "../Transport";
|
||||
|
||||
const WARSHIP_SELECTION_RADIUS = 10;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { EventBus } from "../../core/EventBus";
|
||||
import { GameView } from "../../core/game/GameView";
|
||||
import { UserSettings } from "../../core/game/UserSettings";
|
||||
import { Controller } from "../Controller";
|
||||
import { GameStartingModal } from "../GameStartingModal";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { UIState } from "../UIState";
|
||||
import { BuildPreviewController } from "../controllers/BuildPreviewController";
|
||||
import { WarshipSelectionController } from "../controllers/WarshipSelectionController";
|
||||
import { GameView as WebGLGameView } from "../render/gl";
|
||||
import { FrameProfiler } from "./FrameProfiler";
|
||||
import { TransformHandler } from "./TransformHandler";
|
||||
import { UIState } from "./UIState";
|
||||
import { AlertFrame } from "./layers/AlertFrame";
|
||||
import { AttackingTroopsOverlay } from "./layers/AttackingTroopsOverlay";
|
||||
import { AttacksDisplay } from "./layers/AttacksDisplay";
|
||||
@@ -15,7 +16,6 @@ import { BuildMenu } from "./layers/BuildMenu";
|
||||
import { ChatDisplay } from "./layers/ChatDisplay";
|
||||
import { ChatModal } from "./layers/ChatModal";
|
||||
import { ControlPanel } from "./layers/ControlPanel";
|
||||
import { Controller } from "./layers/Controller";
|
||||
import { EmojiTable } from "./layers/EmojiTable";
|
||||
import { EventsDisplay } from "./layers/EventsDisplay";
|
||||
import { GameLeftSidebar } from "./layers/GameLeftSidebar";
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../../../core/game/GameUpdates";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { UserSettings } from "../../../core/game/UserSettings";
|
||||
import { Controller } from "./Controller";
|
||||
import { Controller } from "../../Controller";
|
||||
|
||||
// Parameters for the alert animation
|
||||
const ALERT_SPEED = 1.6;
|
||||
|
||||
@@ -2,10 +2,10 @@ import { EventBus } from "../../../core/EventBus";
|
||||
import { Cell, PlayerType } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { UserSettings } from "../../../core/game/UserSettings";
|
||||
import { Controller } from "../../Controller";
|
||||
import { AlternateViewEvent } from "../../InputHandler";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
import { renderTroops } from "../../Utils";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
// Match AttacksDisplay: aquarius for outgoing, red-400 for incoming.
|
||||
const OUTGOING_COLOR = "var(--color-aquarius)";
|
||||
|
||||
@@ -9,20 +9,20 @@ import {
|
||||
UnitIncomingUpdate,
|
||||
} from "../../../core/game/GameUpdates";
|
||||
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
GoToPlayerEvent,
|
||||
GoToPositionEvent,
|
||||
GoToUnitEvent,
|
||||
} from "../../TransformHandler";
|
||||
import {
|
||||
CancelAttackIntentEvent,
|
||||
CancelBoatIntentEvent,
|
||||
SendAttackIntentEvent,
|
||||
} from "../../Transport";
|
||||
import { UIState } from "../../UIState";
|
||||
import { renderTroops, translateText } from "../../Utils";
|
||||
import { getColoredSprite } from "../SpriteLoader";
|
||||
import {
|
||||
GoToPlayerEvent,
|
||||
GoToPositionEvent,
|
||||
GoToUnitEvent,
|
||||
} from "../TransformHandler";
|
||||
import { UIState } from "../UIState";
|
||||
import { Controller } from "./Controller";
|
||||
const soldierIcon = assetUrl("images/SoldierIcon.svg");
|
||||
const swordIcon = assetUrl("images/SwordIcon.svg");
|
||||
|
||||
|
||||
@@ -12,20 +12,20 @@ import {
|
||||
} from "../../../core/game/Game";
|
||||
import { TileRef } from "../../../core/game/GameMap";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
CloseViewEvent,
|
||||
MouseDownEvent,
|
||||
ShowBuildMenuEvent,
|
||||
ShowEmojiMenuEvent,
|
||||
} from "../../InputHandler";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
import {
|
||||
BuildUnitIntentEvent,
|
||||
SendUpgradeStructureIntentEvent,
|
||||
} from "../../Transport";
|
||||
import { UIState } from "../../UIState";
|
||||
import { renderNumber } from "../../Utils";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { UIState } from "../UIState";
|
||||
import { Controller } from "./Controller";
|
||||
const warshipIcon = assetUrl("images/BattleshipIconWhite.svg");
|
||||
const cityIcon = assetUrl("images/CityIconWhite.svg");
|
||||
const factoryIcon = assetUrl("images/FactoryIconWhite.svg");
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "../../../core/game/GameUpdates";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { onlyImages } from "../../../core/Util";
|
||||
import { Controller } from "./Controller";
|
||||
import { Controller } from "../../Controller";
|
||||
|
||||
interface ChatEvent {
|
||||
description: string;
|
||||
|
||||
@@ -6,10 +6,10 @@ import { Gold } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { UserSettings } from "../../../core/game/UserSettings";
|
||||
import { ClientID } from "../../../core/Schemas";
|
||||
import { Controller } from "../../Controller";
|
||||
import { AttackRatioEvent } from "../../InputHandler";
|
||||
import { UIState } from "../../UIState";
|
||||
import { renderNumber, renderTroops } from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
import { Controller } from "./Controller";
|
||||
const goldCoinIcon = assetUrl("images/GoldCoinIcon.svg");
|
||||
const soldierIcon = assetUrl("images/SoldierIcon.svg");
|
||||
const swordIcon = assetUrl("images/SwordIcon.svg");
|
||||
|
||||
@@ -6,8 +6,8 @@ import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { TerraNulliusImpl } from "../../../core/game/TerraNulliusImpl";
|
||||
import { Emoji, flattenedEmojiTable } from "../../../core/Util";
|
||||
import { CloseViewEvent, ShowEmojiMenuEvent } from "../../InputHandler";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
import { SendEmojiIntentEvent } from "../../Transport";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
|
||||
@customElement("emoji-table")
|
||||
export class EmojiTable extends LitElement {
|
||||
|
||||
@@ -24,21 +24,21 @@ import {
|
||||
TargetPlayerUpdate,
|
||||
UnitIncomingUpdate,
|
||||
} from "../../../core/game/GameUpdates";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
SendAllianceExtensionIntentEvent,
|
||||
SendAllianceRejectIntentEvent,
|
||||
SendAllianceRequestIntentEvent,
|
||||
} from "../../Transport";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
|
||||
import { onlyImages } from "../../../core/Util";
|
||||
import { GoToPlayerEvent, GoToUnitEvent } from "../../TransformHandler";
|
||||
import { renderNumber } from "../../Utils";
|
||||
import { GoToPlayerEvent, GoToUnitEvent } from "../TransformHandler";
|
||||
|
||||
import { PlaySoundEffectEvent } from "../../sound/Sounds";
|
||||
import { UIState } from "../../UIState";
|
||||
import { getMessageTypeClasses, translateText } from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
const allianceIcon = assetUrl("images/AllianceIconWhite.svg");
|
||||
const chatIcon = assetUrl("images/ChatIconWhite.svg");
|
||||
const donateGoldIcon = assetUrl("images/DonateGoldIconWhite.svg");
|
||||
|
||||
@@ -5,9 +5,9 @@ import { assetUrl } from "../../../core/AssetUrls";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { GameMode, Team } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { Platform } from "../../Platform";
|
||||
import { getTranslatedPlayerTeamLabel, translateText } from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
import { ImmunityBarVisibleEvent } from "./ImmunityTimer";
|
||||
import { SpawnBarVisibleEvent } from "./SpawnTimer";
|
||||
const leaderboardRegularIcon = assetUrl(
|
||||
|
||||
@@ -4,11 +4,11 @@ import { assetUrl } from "../../../core/AssetUrls";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { GameType } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { crazyGamesSDK } from "../../CrazyGamesSDK";
|
||||
import { TogglePauseIntentEvent } from "../../InputHandler";
|
||||
import { PauseGameIntentEvent, SendWinnerEvent } from "../../Transport";
|
||||
import { translateText } from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
import { ImmunityBarVisibleEvent } from "./ImmunityTimer";
|
||||
import { ShowReplayPanelEvent } from "./ReplayPanel";
|
||||
import { ShowSettingsModalEvent } from "./SettingsModal";
|
||||
|
||||
@@ -3,8 +3,8 @@ import { customElement, state } from "lit/decorators.js";
|
||||
import { GameType } from "../../../core/game/Game";
|
||||
import { GameUpdateType } from "../../../core/game/GameUpdates";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { translateText } from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
@customElement("heads-up-message")
|
||||
export class HeadsUpMessage extends LitElement implements Controller {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { customElement } from "lit/decorators.js";
|
||||
import { EventBus, GameEvent } from "../../../core/EventBus";
|
||||
import { GameMode } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "./Controller";
|
||||
import { Controller } from "../../Controller";
|
||||
|
||||
export class ImmunityBarVisibleEvent implements GameEvent {
|
||||
constructor(public readonly visible: boolean) {}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement } from "lit/decorators.js";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { crazyGamesSDK } from "../../CrazyGamesSDK";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
const AD_TYPES = [
|
||||
{ type: "standard_iab_left1", selectorId: "in-game-bottom-left-ad" },
|
||||
|
||||
@@ -4,9 +4,9 @@ import { repeat } from "lit/directives/repeat.js";
|
||||
import { renderTroops, translateText } from "../../../client/Utils";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { GoToPlayerEvent } from "../../TransformHandler";
|
||||
import { formatPercentage, renderNumber } from "../../Utils";
|
||||
import { GoToPlayerEvent } from "../TransformHandler";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
interface Entry {
|
||||
name: string;
|
||||
|
||||
@@ -5,11 +5,11 @@ import { EventBus } from "../../../core/EventBus";
|
||||
import { PlayerActions } from "../../../core/game/Game";
|
||||
import { TileRef } from "../../../core/game/GameMap";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { UIState } from "../UIState";
|
||||
import { Controller } from "../../Controller";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
import { UIState } from "../../UIState";
|
||||
import { BuildMenu } from "./BuildMenu";
|
||||
import { ChatIntegration } from "./ChatIntegration";
|
||||
import { Controller } from "./Controller";
|
||||
import { EmojiTable } from "./EmojiTable";
|
||||
import { PlayerActionHandler } from "./PlayerActionHandler";
|
||||
import { PlayerPanel } from "./PlayerPanel";
|
||||
|
||||
@@ -4,9 +4,9 @@ import { ClientEnv } from "src/client/ClientEnv";
|
||||
import { GameEnv } from "../../../core/configuration/Config";
|
||||
import { GameType } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { MultiTabDetector } from "../../MultiTabDetector";
|
||||
import { translateText } from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
@customElement("multi-tab-modal")
|
||||
export class MultiTabModal extends LitElement implements Controller {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
USER_SETTINGS_CHANGED_EVENT,
|
||||
UserSettings,
|
||||
} from "../../../core/game/UserSettings";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
TickMetricsEvent,
|
||||
TogglePerformanceOverlayEvent,
|
||||
@@ -13,7 +14,6 @@ import {
|
||||
import type { LangSelector } from "../../LangSelector";
|
||||
import { translateText } from "../../Utils";
|
||||
import { FrameProfiler } from "../FrameProfiler";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
@customElement("performance-overlay")
|
||||
export class PerformanceOverlay extends LitElement implements Controller {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
SendSpawnIntentEvent,
|
||||
SendTargetPlayerIntentEvent,
|
||||
} from "../../Transport";
|
||||
import { UIState } from "../UIState";
|
||||
import { UIState } from "../../UIState";
|
||||
|
||||
export class PlayerActionHandler {
|
||||
constructor(
|
||||
|
||||
@@ -12,11 +12,13 @@ import {
|
||||
import { TileRef } from "../../../core/game/GameMap";
|
||||
import { AllianceView } from "../../../core/game/GameUpdates";
|
||||
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
ContextMenuEvent,
|
||||
MouseMoveEvent,
|
||||
TouchEvent,
|
||||
} from "../../InputHandler";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
import {
|
||||
getTranslatedPlayerTeamLabel,
|
||||
renderDuration,
|
||||
@@ -30,8 +32,6 @@ import {
|
||||
getPlayerIcons,
|
||||
IMAGE_ICON_KIND,
|
||||
} from "../PlayerIcons";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { Controller } from "./Controller";
|
||||
import { ImmunityBarVisibleEvent } from "./ImmunityTimer";
|
||||
import { CloseRadialMenuEvent } from "./RadialMenu";
|
||||
import "./RelationSmiley";
|
||||
|
||||
@@ -15,6 +15,7 @@ import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { Emoji, flattenedEmojiTable } from "../../../core/Util";
|
||||
import { actionButton } from "../../components/ui/ActionButton";
|
||||
import "../../components/ui/Divider";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
CloseViewEvent,
|
||||
MouseUpEvent,
|
||||
@@ -28,15 +29,14 @@ import {
|
||||
SendEmojiIntentEvent,
|
||||
SendTargetPlayerIntentEvent,
|
||||
} from "../../Transport";
|
||||
import { UIState } from "../../UIState";
|
||||
import {
|
||||
renderDuration,
|
||||
renderNumber,
|
||||
renderTroops,
|
||||
translateText,
|
||||
} from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
import { ChatModal } from "./ChatModal";
|
||||
import { Controller } from "./Controller";
|
||||
import { EmojiTable } from "./EmojiTable";
|
||||
import "./PlayerModerationModal";
|
||||
import "./SendResourceModal";
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as d3 from "d3";
|
||||
import { assetUrl } from "../../../core/AssetUrls";
|
||||
import { EventBus, GameEvent } from "../../../core/EventBus";
|
||||
import { Controller } from "../../Controller";
|
||||
import { CloseViewEvent } from "../../InputHandler";
|
||||
import { PlaySoundEffectEvent } from "../../sound/Sounds";
|
||||
import { getSvgAspectRatio, translateText } from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
import {
|
||||
CenterButtonElement,
|
||||
MenuElement,
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
import { TileRef } from "../../../core/game/GameMap";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { Emoji, findClosestBy, flattenedEmojiTable } from "../../../core/Util";
|
||||
import { UIState } from "../../UIState";
|
||||
import { renderNumber, translateText } from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
import { BuildItemDisplay, BuildMenu, flattenedBuildTable } from "./BuildMenu";
|
||||
import { ChatIntegration } from "./ChatIntegration";
|
||||
import { EmojiTable } from "./EmojiTable";
|
||||
|
||||
@@ -2,13 +2,13 @@ import { html, LitElement } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators.js";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import { ReplaySpeedChangeEvent } from "../../InputHandler";
|
||||
import {
|
||||
defaultReplaySpeedMultiplier,
|
||||
ReplaySpeedMultiplier,
|
||||
} from "../../utilities/ReplaySpeedMultiplier";
|
||||
import { translateText } from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
export class ShowReplayPanelEvent {
|
||||
constructor(
|
||||
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
SendDonateGoldIntentEvent,
|
||||
SendDonateTroopsIntentEvent,
|
||||
} from "../../Transport";
|
||||
import { UIState } from "../../UIState";
|
||||
import { renderTroops, translateText } from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
|
||||
@customElement("send-resource-modal")
|
||||
export class SendResourceModal extends LitElement {
|
||||
|
||||
@@ -5,13 +5,13 @@ import { PauseGameIntentEvent } from "src/client/Transport";
|
||||
import { assetUrl } from "../../../core/AssetUrls";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { UserSettings } from "../../../core/game/UserSettings";
|
||||
import { Controller } from "../../Controller";
|
||||
import { AlternateViewEvent, RefreshGraphicsEvent } from "../../InputHandler";
|
||||
import { translateText } from "../../Utils";
|
||||
import {
|
||||
SetBackgroundMusicVolumeEvent,
|
||||
SetSoundEffectsVolumeEvent,
|
||||
} from "../../sound/Sounds";
|
||||
import { Controller } from "./Controller";
|
||||
const structureIcon = assetUrl("images/CityIconWhite.svg");
|
||||
const cursorPriceIcon = assetUrl("images/CursorPriceIconWhite.svg");
|
||||
const darkModeIcon = assetUrl("images/DarkModeIconWhite.svg");
|
||||
|
||||
@@ -3,8 +3,8 @@ import { customElement } from "lit/decorators.js";
|
||||
import { EventBus, GameEvent } from "../../../core/EventBus";
|
||||
import { GameMode, GameType, Team } from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { Controller } from "./Controller";
|
||||
import { Controller } from "../../Controller";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
|
||||
export class SpawnBarVisibleEvent implements GameEvent {
|
||||
constructor(public readonly visible: boolean) {}
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
UnitType,
|
||||
} from "../../../core/game/Game";
|
||||
import { GameView, PlayerView, UnitView } from "../../../core/game/GameView";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
const anchorIcon = assetUrl("images/AnchorIcon.v1.png");
|
||||
const cityIcon = assetUrl("images/CityIcon.v1.png");
|
||||
const factoryIcon = assetUrl("images/FactoryUnit.v1.png");
|
||||
|
||||
@@ -3,13 +3,13 @@ import { customElement, property } from "lit/decorators.js";
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { GameMode, Team, UnitType } from "../../../core/game/Game";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
formatPercentage,
|
||||
renderNumber,
|
||||
renderTroops,
|
||||
translateText,
|
||||
} from "../../Utils";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
interface TeamEntry {
|
||||
teamName: string;
|
||||
|
||||
@@ -11,13 +11,10 @@ import {
|
||||
} from "../../../core/game/Game";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { UserSettings } from "../../../core/game/UserSettings";
|
||||
import {
|
||||
GhostStructureChangedEvent,
|
||||
ToggleStructureEvent,
|
||||
} from "../../InputHandler";
|
||||
import { Controller } from "../../Controller";
|
||||
import { ToggleStructureEvent } from "../../InputHandler";
|
||||
import { UIState } from "../../UIState";
|
||||
import { renderNumber, translateText } from "../../Utils";
|
||||
import { UIState } from "../UIState";
|
||||
import { Controller } from "./Controller";
|
||||
const warshipIcon = assetUrl("images/BattleshipIconWhite.svg");
|
||||
const cityIcon = assetUrl("images/CityIconWhite.svg");
|
||||
const factoryIcon = assetUrl("images/FactoryIconWhite.svg");
|
||||
@@ -268,10 +265,8 @@ export class UnitDisplay extends LitElement implements Controller {
|
||||
@click=${() => {
|
||||
if (selected) {
|
||||
this.uiState.ghostStructure = null;
|
||||
this.eventBus?.emit(new GhostStructureChangedEvent(null));
|
||||
} else if (this.canBuild(unitType)) {
|
||||
this.uiState.ghostStructure = unitType;
|
||||
this.eventBus?.emit(new GhostStructureChangedEvent(unitType));
|
||||
}
|
||||
this.requestUpdate();
|
||||
}}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { GameUpdateType } from "../../../core/game/GameUpdates";
|
||||
import { GameView } from "../../../core/game/GameView";
|
||||
import { getUserMe } from "../../Api";
|
||||
import "../../components/CosmeticButton";
|
||||
import { Controller } from "../../Controller";
|
||||
import {
|
||||
fetchCosmetics,
|
||||
purchaseCosmetic,
|
||||
@@ -20,7 +21,6 @@ import {
|
||||
import { crazyGamesSDK } from "../../CrazyGamesSDK";
|
||||
import { Platform } from "../../Platform";
|
||||
import { SendWinnerEvent } from "../../Transport";
|
||||
import { Controller } from "./Controller";
|
||||
|
||||
@customElement("win-modal")
|
||||
export class WinModal extends LitElement implements Controller {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Cell } from "src/core/game/Game";
|
||||
import { TransformHandler } from "../TransformHandler";
|
||||
import { TransformHandler } from "../../TransformHandler";
|
||||
import { UIElement } from "./UIElement";
|
||||
|
||||
const MIN_TEXT_ZOOM = 1.1;
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
WarshipSelectionBoxCompleteEvent,
|
||||
WarshipSelectionBoxUpdateEvent,
|
||||
} from "../src/client/InputHandler";
|
||||
import { UIState } from "../src/client/graphics/UIState";
|
||||
import { UIState } from "../src/client/UIState";
|
||||
import { EventBus } from "../src/core/EventBus";
|
||||
import { UnitType } from "../src/core/game/Game";
|
||||
import { GameView, PlayerView } from "../src/core/game/GameView";
|
||||
@@ -928,13 +928,10 @@ describe("Warship box selection (Shift+drag)", () => {
|
||||
|
||||
test("Shift keydown discards active ghostStructure", () => {
|
||||
uiState.ghostStructure = UnitType.Warship;
|
||||
const emitSpy = vi.spyOn(eventBus, "emit");
|
||||
|
||||
window.dispatchEvent(new KeyboardEvent("keydown", { code: "ShiftLeft" }));
|
||||
|
||||
expect(uiState.ghostStructure).toBeNull();
|
||||
const types = emitSpy.mock.calls.map((c) => c[0].constructor.name);
|
||||
expect(types).toContain("GhostStructureChangedEvent");
|
||||
});
|
||||
|
||||
test("Shift+drag emits WarshipSelectionBoxUpdateEvent", () => {
|
||||
|
||||
Reference in New Issue
Block a user