1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-14 10:41:52 +00:00

Fix all instances of "reciever" typo

This commit is contained in:
Даниїл Григор'єв 2024-07-21 02:27:06 +03:00
parent 178744e065
commit a2b21cc6dd
No known key found for this signature in database
GPG Key ID: B890DF16341D8C1D
18 changed files with 139 additions and 140 deletions

View File

@ -3,13 +3,13 @@ import { Application } from "../application";
import { StateManager } from "./state_manager"; import { StateManager } from "./state_manager";
/* typehints:end */ /* typehints:end */
import { globalConfig } from "./config";
import { ClickDetector } from "./click_detector";
import { logSection, createLogger } from "./logging";
import { InputReceiver } from "./input_receiver";
import { waitNextFrame } from "./utils";
import { RequestChannel } from "./request_channel";
import { MUSIC } from "../platform/sound"; import { MUSIC } from "../platform/sound";
import { ClickDetector } from "./click_detector";
import { globalConfig } from "./config";
import { InputReceiver } from "./input_receiver";
import { createLogger, logSection } from "./logging";
import { RequestChannel } from "./request_channel";
import { waitNextFrame } from "./utils";
const logger = createLogger("game_state"); const logger = createLogger("game_state");
@ -38,8 +38,8 @@ export class GameState {
this.clickDetectors = []; this.clickDetectors = [];
// Every state captures keyboard events by default // Every state captures keyboard events by default
this.inputReciever = new InputReceiver("state-" + key); this.inputReceiver = new InputReceiver("state-" + key);
this.inputReciever.backButton.add(this.onBackButton, this); this.inputReceiver.backButton.add(this.onBackButton, this);
// A channel we can use to perform async ops // A channel we can use to perform async ops
this.asyncChannel = new RequestChannel(); this.asyncChannel = new RequestChannel();
@ -267,7 +267,7 @@ export class GameState {
*/ */
internalEnterCallback(payload, callCallback = true) { internalEnterCallback(payload, callCallback = true) {
logSection(this.key, "#26a69a"); logSection(this.key, "#26a69a");
this.app.inputMgr.pushReciever(this.inputReciever); this.app.inputMgr.pushReceiver(this.inputReceiver);
this.htmlElement = this.getDivElement(); this.htmlElement = this.getDivElement();
this.htmlElement.classList.add("active"); this.htmlElement.classList.add("active");
@ -293,7 +293,7 @@ export class GameState {
this.onLeave(); this.onLeave();
this.htmlElement.classList.remove("active"); this.htmlElement.classList.remove("active");
this.app.inputMgr.popReciever(this.inputReciever); this.app.inputMgr.popReceiver(this.inputReceiver);
this.internalCleanUpClickDetectors(); this.internalCleanUpClickDetectors();
this.asyncChannel.cancelAll(); this.asyncChannel.cancelAll();
} }

View File

@ -1,14 +1,14 @@
import type { Application } from "../application"; import type { Application } from "../application";
import type { InputReceiver, ReceiverId } from "./input_receiver"; import type { InputReceiver, ReceiverId } from "./input_receiver";
import { Signal, STOP_PROPAGATION } from "./signal";
import { createLogger } from "./logging"; import { createLogger } from "./logging";
import { Signal, STOP_PROPAGATION } from "./signal";
import { arrayDeleteValue, fastArrayDeleteValue } from "./utils"; import { arrayDeleteValue, fastArrayDeleteValue } from "./utils";
const logger = createLogger("input_distributor"); const logger = createLogger("input_distributor");
export class InputDistributor { export class InputDistributor {
public recieverStack: InputReceiver[] = []; public receiverStack: InputReceiver[] = [];
public filters: ((arg: string) => boolean)[] = []; public filters: ((arg: string) => boolean)[] = [];
/** /**
@ -34,71 +34,71 @@ export class InputDistributor {
fastArrayDeleteValue(this.filters, filter); fastArrayDeleteValue(this.filters, filter);
} }
pushReciever(reciever: InputReceiver) { pushReceiver(receiver: InputReceiver) {
if (this.isRecieverAttached(reciever)) { if (this.isReceiverAttached(receiver)) {
assert(false, "Can not add reciever " + reciever.context + " twice"); assert(false, "Can not add receiver " + receiver.context + " twice");
logger.error("Can not add reciever", reciever.context, "twice"); logger.error("Can not add receiver", receiver.context, "twice");
return; return;
} }
this.recieverStack.push(reciever); this.receiverStack.push(receiver);
if (this.recieverStack.length > 10) { if (this.receiverStack.length > 10) {
logger.error( logger.error(
"Reciever stack is huge, probably some dead receivers arround:", "Receiver stack is huge, probably some dead receivers arround:",
this.recieverStack.map(x => x.context) this.receiverStack.map(x => x.context)
); );
} }
} }
popReciever(reciever: InputReceiver) { popReceiver(receiver: InputReceiver) {
if (this.recieverStack.indexOf(reciever) < 0) { if (this.receiverStack.indexOf(receiver) < 0) {
assert(false, "Can not pop reciever " + reciever.context + " since its not contained"); assert(false, "Can not pop receiver " + receiver.context + " since its not contained");
logger.error("Can not pop reciever", reciever.context, "since its not contained"); logger.error("Can not pop receiver", receiver.context, "since its not contained");
return; return;
} }
if (this.recieverStack[this.recieverStack.length - 1] !== reciever) { if (this.receiverStack[this.receiverStack.length - 1] !== receiver) {
logger.warn( logger.warn(
"Popping reciever", "Popping receiver",
reciever.context, receiver.context,
"which is not on top of the stack. Stack is: ", "which is not on top of the stack. Stack is: ",
this.recieverStack.map(x => x.context) this.receiverStack.map(x => x.context)
); );
} }
arrayDeleteValue(this.recieverStack, reciever); arrayDeleteValue(this.receiverStack, receiver);
} }
isRecieverAttached(reciever: InputReceiver) { isReceiverAttached(receiver: InputReceiver) {
return this.recieverStack.indexOf(reciever) >= 0; return this.receiverStack.indexOf(receiver) >= 0;
} }
isRecieverOnTop(reciever: InputReceiver) { isReceiverOnTop(receiver: InputReceiver) {
return ( return (
this.isRecieverAttached(reciever) && this.isReceiverAttached(receiver) &&
this.recieverStack[this.recieverStack.length - 1] === reciever this.receiverStack[this.receiverStack.length - 1] === receiver
); );
} }
makeSureAttachedAndOnTop(reciever: InputReceiver) { makeSureAttachedAndOnTop(receiver: InputReceiver) {
this.makeSureDetached(reciever); this.makeSureDetached(receiver);
this.pushReciever(reciever); this.pushReceiver(receiver);
} }
makeSureDetached(reciever: InputReceiver) { makeSureDetached(receiver: InputReceiver) {
if (this.isRecieverAttached(reciever)) { if (this.isReceiverAttached(receiver)) {
arrayDeleteValue(this.recieverStack, reciever); arrayDeleteValue(this.receiverStack, receiver);
} }
} }
destroyReceiver(reciever: InputReceiver) { destroyReceiver(receiver: InputReceiver) {
this.makeSureDetached(reciever); this.makeSureDetached(receiver);
reciever.cleanup(); receiver.cleanup();
} }
// Internal // Internal
getTopReciever() { getTopReceiver() {
if (this.recieverStack.length > 0) { if (this.receiverStack.length > 0) {
return this.recieverStack[this.recieverStack.length - 1]; return this.receiverStack[this.receiverStack.length - 1];
} }
return null; return null;
} }
@ -129,12 +129,12 @@ export class InputDistributor {
} }
} }
const reciever = this.getTopReciever(); const receiver = this.getTopReceiver();
if (!reciever) { if (!receiver) {
logger.warn("Dismissing event because not reciever was found:", eventId); logger.warn("Dismissing event because not receiver was found:", eventId);
return; return;
} }
const signal = reciever[eventId]; const signal = receiver[eventId];
assert(signal instanceof Signal, "Not a valid event id"); assert(signal instanceof Signal, "Not a valid event id");
// probably not possible to type properly, since the types of `signal` and `payload` are correlated // probably not possible to type properly, since the types of `signal` and `payload` are correlated
return signal.dispatch(payload as never); return signal.dispatch(payload as never);

View File

@ -1,15 +1,15 @@
import type { Application } from "../application"; import type { Application } from "../application";
import { getStringForKeyCode } from "../game/key_action_mapper";
import { SOUNDS } from "../platform/sound";
import { T } from "../translations";
import { ClickDetector, ClickDetectorConstructorArgs } from "./click_detector";
import { globalConfig } from "./config";
import { InputReceiver, KeydownEvent } from "./input_receiver";
import { createLogger } from "./logging";
import { FormElement } from "./modal_dialog_forms";
import { Signal, STOP_PROPAGATION } from "./signal"; import { Signal, STOP_PROPAGATION } from "./signal";
import { arrayDeleteValue, waitNextFrame } from "./utils"; import { arrayDeleteValue, waitNextFrame } from "./utils";
import { ClickDetector, ClickDetectorConstructorArgs } from "./click_detector";
import { SOUNDS } from "../platform/sound";
import { InputReceiver, KeydownEvent } from "./input_receiver";
import { FormElement } from "./modal_dialog_forms";
import { globalConfig } from "./config";
import { getStringForKeyCode } from "../game/key_action_mapper";
import { createLogger } from "./logging";
import { T } from "../translations";
/* /*
* *************************************************** * ***************************************************
@ -51,7 +51,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
public timeouts: number[] = []; public timeouts: number[] = [];
public clickDetectors: ClickDetector[] = []; public clickDetectors: ClickDetector[] = [];
public inputReciever: InputReceiver; public inputReceiver: InputReceiver;
public enterHandler: T = null; public enterHandler: T = null;
public escapeHandler: T = null; public escapeHandler: T = null;
@ -103,9 +103,9 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
this.buttonSignals[buttonId] = new Signal(); this.buttonSignals[buttonId] = new Signal();
} }
this.inputReciever = new InputReceiver("dialog-" + this.title); this.inputReceiver = new InputReceiver("dialog-" + this.title);
this.inputReciever.keydown.add(this.handleKeydown, this); this.inputReceiver.keydown.add(this.handleKeydown, this);
} }
/** /**
@ -124,7 +124,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
} }
internalButtonHandler(id: T | "close-button", ...payload: U | []) { internalButtonHandler(id: T | "close-button", ...payload: U | []) {
this.app.inputMgr.popReciever(this.inputReciever); this.app.inputMgr.popReceiver(this.inputReceiver);
if (id !== "close-button") { if (id !== "close-button") {
this.buttonSignals[id].dispatch(...payload); this.buttonSignals[id].dispatch(...payload);
@ -160,7 +160,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
}); });
title.appendChild(closeBtn); title.appendChild(closeBtn);
this.inputReciever.backButton.add(() => this.internalButtonHandler("close-button")); this.inputReceiver.backButton.add(() => this.internalButtonHandler("close-button"));
} }
const content = document.createElement("div"); const content = document.createElement("div");
@ -231,7 +231,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
} }
this.element = elem; this.element = elem;
this.app.inputMgr.pushReciever(this.inputReciever); this.app.inputMgr.pushReceiver(this.inputReceiver);
return this.element; return this.element;
} }
@ -248,7 +248,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
// We need to do this here, because if the backbutton event gets // We need to do this here, because if the backbutton event gets
// dispatched to the modal dialogs, it will not call the internalButtonHandler, // dispatched to the modal dialogs, it will not call the internalButtonHandler,
// and thus our receiver stays attached the whole time // and thus our receiver stays attached the whole time
this.app.inputMgr.destroyReceiver(this.inputReciever); this.app.inputMgr.destroyReceiver(this.inputReceiver);
for (let i = 0; i < this.clickDetectors.length; ++i) { for (let i = 0; i < this.clickDetectors.length; ++i) {
this.clickDetectors[i].cleanup(); this.clickDetectors[i].cleanup();
@ -300,8 +300,8 @@ export class DialogLoading extends Dialog {
}); });
// Loading dialog can not get closed with back button // Loading dialog can not get closed with back button
this.inputReciever.backButton.removeAll(); this.inputReceiver.backButton.removeAll();
this.inputReciever.context = "dialog-loading"; this.inputReceiver.context = "dialog-loading";
} }
createElement() { createElement() {
@ -322,7 +322,7 @@ export class DialogLoading extends Dialog {
loader.classList.add("loadingIndicator"); loader.classList.add("loadingIndicator");
elem.appendChild(loader); elem.appendChild(loader);
this.app.inputMgr.pushReciever(this.inputReciever); this.app.inputMgr.pushReceiver(this.inputReceiver);
return elem; return elem;
} }

View File

@ -57,7 +57,7 @@ export class UndergroundBeltComponent extends Component {
/** /**
* Used on both receiver and sender. * Used on both receiver and sender.
* Reciever: Used to store the next item to transfer, and to block input while doing this * Receiver: Used to store the next item to transfer, and to block input while doing this
* Sender: Used to store which items are currently "travelling" * Sender: Used to store which items are currently "travelling"
* @type {Array<[BaseItem, number]>} Format is [Item, ingame time to eject the item] * @type {Array<[BaseItem, number]>} Format is [Item, ingame time to eject the item]
*/ */

View File

@ -17,13 +17,16 @@ import { Rectangle } from "../core/rectangle";
import { ORIGINAL_SPRITE_SCALE } from "../core/sprites"; import { ORIGINAL_SPRITE_SCALE } from "../core/sprites";
import { lerp, randomInt, round2Digits } from "../core/utils"; import { lerp, randomInt, round2Digits } from "../core/utils";
import { Vector } from "../core/vector"; import { Vector } from "../core/vector";
import { MOD_SIGNALS } from "../mods/mod_signals";
import { Savegame } from "../savegame/savegame"; import { Savegame } from "../savegame/savegame";
import { SavegameSerializer } from "../savegame/savegame_serializer"; import { SavegameSerializer } from "../savegame/savegame_serializer";
import { AchievementProxy } from "./achievement_proxy";
import { AutomaticSave } from "./automatic_save"; import { AutomaticSave } from "./automatic_save";
import { MetaHubBuilding } from "./buildings/hub"; import { MetaHubBuilding } from "./buildings/hub";
import { Camera } from "./camera"; import { Camera } from "./camera";
import { DynamicTickrate } from "./dynamic_tickrate"; import { DynamicTickrate } from "./dynamic_tickrate";
import { EntityManager } from "./entity_manager"; import { EntityManager } from "./entity_manager";
import { GameMode } from "./game_mode";
import { GameSystemManager } from "./game_system_manager"; import { GameSystemManager } from "./game_system_manager";
import { HubGoals } from "./hub_goals"; import { HubGoals } from "./hub_goals";
import { GameHUD } from "./hud/hud"; import { GameHUD } from "./hud/hud";
@ -31,14 +34,11 @@ import { KeyActionMapper } from "./key_action_mapper";
import { GameLogic } from "./logic"; import { GameLogic } from "./logic";
import { MapView } from "./map_view"; import { MapView } from "./map_view";
import { defaultBuildingVariant } from "./meta_building"; import { defaultBuildingVariant } from "./meta_building";
import { GameMode } from "./game_mode";
import { ProductionAnalytics } from "./production_analytics"; import { ProductionAnalytics } from "./production_analytics";
import { GameRoot } from "./root"; import { GameRoot } from "./root";
import { ShapeDefinitionManager } from "./shape_definition_manager"; import { ShapeDefinitionManager } from "./shape_definition_manager";
import { AchievementProxy } from "./achievement_proxy";
import { SoundProxy } from "./sound_proxy"; import { SoundProxy } from "./sound_proxy";
import { GameTime } from "./time/game_time"; import { GameTime } from "./time/game_time";
import { MOD_SIGNALS } from "../mods/mod_signals";
const logger = createLogger("ingame/core"); const logger = createLogger("ingame/core");
@ -101,7 +101,7 @@ export class GameCore {
const root = this.root; const root = this.root;
// This isn't nice, but we need it right here // This isn't nice, but we need it right here
root.keyMapper = new KeyActionMapper(root, this.root.gameState.inputReciever); root.keyMapper = new KeyActionMapper(root, this.root.gameState.inputReceiver);
// Init game mode // Init game mode
root.gameMode = GameMode.create(root, gameModeId, parentState.creationPayload.gameModeParameters); root.gameMode = GameMode.create(root, gameModeId, parentState.creationPayload.gameModeParameters);
@ -142,7 +142,7 @@ export class GameCore {
// @todo Find better place // @todo Find better place
if (G_IS_DEV && globalConfig.debug.manualTickOnly) { if (G_IS_DEV && globalConfig.debug.manualTickOnly) {
this.root.gameState.inputReciever.keydown.add(key => { this.root.gameState.inputReceiver.keydown.add(key => {
if (key.keyCode === 84) { if (key.keyCode === 84) {
// 'T' // 'T'

View File

@ -1,20 +1,19 @@
import { globalConfig } from "../../../core/config";
import { gMetaBuildingRegistry } from "../../../core/global_registries"; import { gMetaBuildingRegistry } from "../../../core/global_registries";
import { Signal, STOP_PROPAGATION } from "../../../core/signal"; import { Signal, STOP_PROPAGATION } from "../../../core/signal";
import { TrackedState } from "../../../core/tracked_state"; import { TrackedState } from "../../../core/tracked_state";
import { safeModulo } from "../../../core/utils";
import { Vector } from "../../../core/vector"; import { Vector } from "../../../core/vector";
import { SOUNDS } from "../../../platform/sound";
import { getBuildingDataFromCode, getCodeFromBuildingData } from "../../building_codes";
import { MetaHubBuilding } from "../../buildings/hub";
import { enumMinerVariants, MetaMinerBuilding } from "../../buildings/miner";
import { enumMouseButton } from "../../camera"; import { enumMouseButton } from "../../camera";
import { StaticMapEntityComponent } from "../../components/static_map_entity"; import { StaticMapEntityComponent } from "../../components/static_map_entity";
import { Entity } from "../../entity"; import { Entity } from "../../entity";
import { KEYMAPPINGS } from "../../key_action_mapper"; import { KEYMAPPINGS } from "../../key_action_mapper";
import { defaultBuildingVariant, MetaBuilding } from "../../meta_building"; import { defaultBuildingVariant, MetaBuilding } from "../../meta_building";
import { BaseHUDPart } from "../base_hud_part";
import { SOUNDS } from "../../../platform/sound";
import { MetaMinerBuilding, enumMinerVariants } from "../../buildings/miner";
import { enumHubGoalRewards } from "../../tutorial_goals"; import { enumHubGoalRewards } from "../../tutorial_goals";
import { getBuildingDataFromCode, getCodeFromBuildingData } from "../../building_codes"; import { BaseHUDPart } from "../base_hud_part";
import { MetaHubBuilding } from "../../buildings/hub";
import { safeModulo } from "../../../core/utils";
/** /**
* Contains all logic for the building placer - this doesn't include the rendering * Contains all logic for the building placer - this doesn't include the rendering
@ -122,7 +121,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
.add(this.switchDirectionLockSide, this); .add(this.switchDirectionLockSide, this);
keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.abortPlacement, this); keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.abortPlacement, this);
keyActionMapper.getBinding(KEYMAPPINGS.placement.pipette).add(this.startPipette, this); keyActionMapper.getBinding(KEYMAPPINGS.placement.pipette).add(this.startPipette, this);
this.root.gameState.inputReciever.keyup.add(this.checkForDirectionLockSwitch, this); this.root.gameState.inputReceiver.keyup.add(this.checkForDirectionLockSwitch, this);
// BINDINGS TO GAME EVENTS // BINDINGS TO GAME EVENTS
this.root.hud.signals.buildingsSelectedForCopy.add(this.abortPlacement, this); this.root.hud.signals.buildingsSelectedForCopy.add(this.abortPlacement, this);

View File

@ -27,7 +27,7 @@ export class HUDEntityDebugger extends BaseHUDPart {
} }
initialize() { initialize() {
this.root.gameState.inputReciever.keydown.add(key => { this.root.gameState.inputReceiver.keydown.add(key => {
if (key.keyCode === 119) { if (key.keyCode === 119) {
// F8 // F8
this.pickEntity(); this.pickEntity();

View File

@ -24,7 +24,7 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart {
} }
createElements(parent) { createElements(parent) {
this.inputReciever = new InputReceiver("puzzle-complete"); this.inputReceiver = new InputReceiver("puzzle-complete");
this.element = makeDiv(parent, "ingame_HUD_PuzzleCompleteNotification", ["noBlur"]); this.element = makeDiv(parent, "ingame_HUD_PuzzleCompleteNotification", ["noBlur"]);
@ -86,13 +86,13 @@ export class HUDPuzzleCompleteNotification extends BaseHUDPart {
show() { show() {
this.root.soundProxy.playUi(SOUNDS.levelComplete); this.root.soundProxy.playUi(SOUNDS.levelComplete);
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
this.visible = true; this.visible = true;
this.timeOfCompletion = this.root.time.now(); this.timeOfCompletion = this.root.time.now();
} }
cleanup() { cleanup() {
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
} }
isBlockingOverlay() { isBlockingOverlay() {

View File

@ -139,7 +139,7 @@ export class HUDSandboxController extends BaseHUDPart {
initialize() { initialize() {
// Allow toggling the controller overlay // Allow toggling the controller overlay
this.root.gameState.inputReciever.keydown.add(key => { this.root.gameState.inputReceiver.keydown.add(key => {
if (key.keyCode === 117) { if (key.keyCode === 117) {
// F6 // F6
this.toggle(); this.toggle();

View File

@ -1,11 +1,11 @@
import { BaseHUDPart } from "../base_hud_part";
import { makeDiv, formatBigNumberFull } from "../../../core/utils";
import { DynamicDomAttach } from "../dynamic_dom_attach";
import { InputReceiver } from "../../../core/input_receiver"; import { InputReceiver } from "../../../core/input_receiver";
import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper"; import { formatBigNumberFull, makeDiv } from "../../../core/utils";
import { T } from "../../../translations"; import { T } from "../../../translations";
import { StaticMapEntityComponent } from "../../components/static_map_entity";
import { BeltComponent } from "../../components/belt"; import { BeltComponent } from "../../components/belt";
import { StaticMapEntityComponent } from "../../components/static_map_entity";
import { KEYMAPPINGS, KeyActionMapper } from "../../key_action_mapper";
import { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach";
export class HUDSettingsMenu extends BaseHUDPart { export class HUDSettingsMenu extends BaseHUDPart {
createElements(parent) { createElements(parent) {
@ -83,8 +83,8 @@ export class HUDSettingsMenu extends BaseHUDPart {
attachClass: "visible", attachClass: "visible",
}); });
this.inputReciever = new InputReceiver("settingsmenu"); this.inputReceiver = new InputReceiver("settingsmenu");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReciever); this.keyActionMapper = new KeyActionMapper(this.root, this.inputReceiver);
this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this);
this.close(); this.close();
@ -92,7 +92,7 @@ export class HUDSettingsMenu extends BaseHUDPart {
show() { show() {
this.visible = true; this.visible = true;
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
const totalMinutesPlayed = Math.ceil(this.root.time.now() / 60); const totalMinutesPlayed = Math.ceil(this.root.time.now() / 60);
@ -119,7 +119,7 @@ export class HUDSettingsMenu extends BaseHUDPart {
close() { close() {
this.visible = false; this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
this.update(); this.update();
} }

View File

@ -1,7 +1,7 @@
import { InputReceiver } from "../../../core/input_receiver"; import { InputReceiver } from "../../../core/input_receiver";
import { makeDiv, removeAllChildren } from "../../../core/utils"; import { makeDiv, removeAllChildren } from "../../../core/utils";
import { T } from "../../../translations"; import { T } from "../../../translations";
import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper"; import { KEYMAPPINGS, KeyActionMapper } from "../../key_action_mapper";
import { ShapeDefinition } from "../../shape_definition"; import { ShapeDefinition } from "../../shape_definition";
import { BaseHUDPart } from "../base_hud_part"; import { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach"; import { DynamicDomAttach } from "../dynamic_dom_attach";
@ -38,8 +38,8 @@ export class HUDShapeViewer extends BaseHUDPart {
this.currentShapeKey = null; this.currentShapeKey = null;
this.inputReciever = new InputReceiver("shape_viewer"); this.inputReceiver = new InputReceiver("shape_viewer");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReciever); this.keyActionMapper = new KeyActionMapper(this.root, this.inputReceiver);
this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this);
@ -67,7 +67,7 @@ export class HUDShapeViewer extends BaseHUDPart {
*/ */
close() { close() {
this.visible = false; this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
this.update(); this.update();
} }
@ -77,7 +77,7 @@ export class HUDShapeViewer extends BaseHUDPart {
*/ */
renderForShape(definition) { renderForShape(definition) {
this.visible = true; this.visible = true;
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
removeAllChildren(this.renderArea); removeAllChildren(this.renderArea);

View File

@ -3,7 +3,7 @@ import { InputReceiver } from "../../../core/input_receiver";
import { formatBigNumber, getRomanNumber, makeDiv } from "../../../core/utils"; import { formatBigNumber, getRomanNumber, makeDiv } from "../../../core/utils";
import { SOUNDS } from "../../../platform/sound"; import { SOUNDS } from "../../../platform/sound";
import { T } from "../../../translations"; import { T } from "../../../translations";
import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper"; import { KEYMAPPINGS, KeyActionMapper } from "../../key_action_mapper";
import { BaseHUDPart } from "../base_hud_part"; import { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach"; import { DynamicDomAttach } from "../dynamic_dom_attach";
@ -193,8 +193,8 @@ export class HUDShop extends BaseHUDPart {
attachClass: "visible", attachClass: "visible",
}); });
this.inputReciever = new InputReceiver("shop"); this.inputReceiver = new InputReceiver("shop");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReciever); this.keyActionMapper = new KeyActionMapper(this.root, this.inputReceiver);
this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this);
this.keyActionMapper.getBinding(KEYMAPPINGS.ingame.menuClose).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.ingame.menuClose).add(this.close, this);
@ -224,13 +224,13 @@ export class HUDShop extends BaseHUDPart {
show() { show() {
this.visible = true; this.visible = true;
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
this.rerenderFull(); this.rerenderFull();
} }
close() { close() {
this.visible = false; this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
this.update(); this.update();
} }

View File

@ -1,11 +1,11 @@
import { InputReceiver } from "../../../core/input_receiver"; import { InputReceiver } from "../../../core/input_receiver";
import { makeButton, makeDiv, removeAllChildren } from "../../../core/utils"; import { makeButton, makeDiv, removeAllChildren } from "../../../core/utils";
import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper"; import { T } from "../../../translations";
import { KEYMAPPINGS, KeyActionMapper } from "../../key_action_mapper";
import { enumAnalyticsDataSource } from "../../production_analytics"; import { enumAnalyticsDataSource } from "../../production_analytics";
import { BaseHUDPart } from "../base_hud_part"; import { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach"; import { DynamicDomAttach } from "../dynamic_dom_attach";
import { enumDisplayMode, HUDShapeStatisticsHandle, statisticsUnitsSeconds } from "./statistics_handle"; import { HUDShapeStatisticsHandle, enumDisplayMode, statisticsUnitsSeconds } from "./statistics_handle";
import { T } from "../../../translations";
/** /**
* Capitalizes the first letter * Capitalizes the first letter
@ -115,8 +115,8 @@ export class HUDStatistics extends BaseHUDPart {
attachClass: "visible", attachClass: "visible",
}); });
this.inputReciever = new InputReceiver("statistics"); this.inputReceiver = new InputReceiver("statistics");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReciever); this.keyActionMapper = new KeyActionMapper(this.root, this.inputReceiver);
this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this);
this.keyActionMapper.getBinding(KEYMAPPINGS.ingame.menuClose).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.ingame.menuClose).add(this.close, this);
@ -157,14 +157,14 @@ export class HUDStatistics extends BaseHUDPart {
show() { show() {
this.visible = true; this.visible = true;
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
this.rerenderFull(); this.rerenderFull();
this.update(); this.update();
} }
close() { close() {
this.visible = false; this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
this.update(); this.update();
} }

View File

@ -1,10 +1,10 @@
import { InputReceiver } from "../../../core/input_receiver"; import { InputReceiver } from "../../../core/input_receiver";
import { TrackedState } from "../../../core/tracked_state"; import { TrackedState } from "../../../core/tracked_state";
import { makeDiv } from "../../../core/utils"; import { makeDiv } from "../../../core/utils";
import { T } from "../../../translations";
import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper"; import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper";
import { BaseHUDPart } from "../base_hud_part"; import { BaseHUDPart } from "../base_hud_part";
import { DynamicDomAttach } from "../dynamic_dom_attach"; import { DynamicDomAttach } from "../dynamic_dom_attach";
import { T } from "../../../translations";
const tutorialVideos = [3, 4, 5, 6, 7, 9, 10, 11]; const tutorialVideos = [3, 4, 5, 6, 7, 9, 10, 11];
@ -46,8 +46,8 @@ export class HUDPartTutorialHints extends BaseHUDPart {
this.videoAttach.update(false); this.videoAttach.update(false);
this.enlarged = false; this.enlarged = false;
this.inputReciever = new InputReceiver("tutorial_hints"); this.inputReceiver = new InputReceiver("tutorial_hints");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReciever); this.keyActionMapper = new KeyActionMapper(this.root, this.inputReceiver);
this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this); this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this);
this.domAttach = new DynamicDomAttach(this.root, this.element); this.domAttach = new DynamicDomAttach(this.root, this.element);
@ -71,14 +71,14 @@ export class HUDPartTutorialHints extends BaseHUDPart {
close() { close() {
this.enlarged = false; this.enlarged = false;
this.element.classList.remove("enlarged", "noBlur"); this.element.classList.remove("enlarged", "noBlur");
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
this.update(); this.update();
} }
show() { show() {
this.element.classList.add("enlarged", "noBlur"); this.element.classList.add("enlarged", "noBlur");
this.enlarged = true; this.enlarged = true;
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
this.update(); this.update();
this.videoElement.currentTime = 0; this.videoElement.currentTime = 0;

View File

@ -31,7 +31,7 @@ export class HUDUnlockNotification extends BaseHUDPart {
} }
createElements(parent) { createElements(parent) {
this.inputReciever = new InputReceiver("unlock-notification"); this.inputReceiver = new InputReceiver("unlock-notification");
this.element = makeDiv(parent, "ingame_HUD_UnlockNotification", ["noBlur"]); this.element = makeDiv(parent, "ingame_HUD_UnlockNotification", ["noBlur"]);
@ -67,7 +67,7 @@ export class HUDUnlockNotification extends BaseHUDPart {
return; return;
} }
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever); this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReceiver);
this.elemTitle.innerText = T.ingame.levelCompleteNotification.levelTitle.replace( this.elemTitle.innerText = T.ingame.levelCompleteNotification.levelTitle.replace(
"<level>", "<level>",
("" + level).padStart(2, "0") ("" + level).padStart(2, "0")
@ -118,7 +118,7 @@ export class HUDUnlockNotification extends BaseHUDPart {
} }
cleanup() { cleanup() {
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
if (this.buttonShowTimeout) { if (this.buttonShowTimeout) {
clearTimeout(this.buttonShowTimeout); clearTimeout(this.buttonShowTimeout);
this.buttonShowTimeout = null; this.buttonShowTimeout = null;
@ -158,7 +158,7 @@ export class HUDUnlockNotification extends BaseHUDPart {
} }
close() { close() {
this.root.app.inputMgr.makeSureDetached(this.inputReciever); this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
if (this.buttonShowTimeout) { if (this.buttonShowTimeout) {
clearTimeout(this.buttonShowTimeout); clearTimeout(this.buttonShowTimeout);
this.buttonShowTimeout = null; this.buttonShowTimeout = null;

View File

@ -1,11 +1,11 @@
/* typehints:start */ /* typehints:start */
import { GameRoot } from "./root";
import { InputReceiver } from "../core/input_receiver";
import { Application } from "../application"; import { Application } from "../application";
import { InputReceiver } from "../core/input_receiver";
import { GameRoot } from "./root";
/* typehints:end */ /* typehints:end */
import { Signal, STOP_PROPAGATION } from "../core/signal";
import { IS_MOBILE } from "../core/config"; import { IS_MOBILE } from "../core/config";
import { Signal, STOP_PROPAGATION } from "../core/signal";
import { T } from "../translations"; import { T } from "../translations";
export function keyToKeyCode(str) { export function keyToKeyCode(str) {
@ -353,9 +353,9 @@ export class Keybinding {
get pressed() { get pressed() {
// Check if the key is down // Check if the key is down
if (this.app.inputMgr.keysDown.has(this.keyCode)) { if (this.app.inputMgr.keysDown.has(this.keyCode)) {
// Check if it is the top reciever // Check if it is the top receiver
const reciever = this.keyMapper.inputReceiver; const receiver = this.keyMapper.inputReceiver;
return this.app.inputMgr.getTopReciever() === reciever; return this.app.inputMgr.getTopReceiver() === receiver;
} }
return false; return false;
} }
@ -412,14 +412,14 @@ export class KeyActionMapper {
/** /**
* *
* @param {GameRoot} root * @param {GameRoot} root
* @param {InputReceiver} inputReciever * @param {InputReceiver} inputReceiver
*/ */
constructor(root, inputReciever) { constructor(root, inputReceiver) {
this.root = root; this.root = root;
this.inputReceiver = inputReciever; this.inputReceiver = inputReceiver;
inputReciever.keydown.add(this.handleKeydown, this); inputReceiver.keydown.add(this.handleKeydown, this);
inputReciever.keyup.add(this.handleKeyup, this); inputReceiver.keyup.add(this.handleKeyup, this);
/** @type {Object.<string, Keybinding>} */ /** @type {Object.<string, Keybinding>} */
this.keybindings = {}; this.keybindings = {};
@ -443,8 +443,8 @@ export class KeyActionMapper {
} }
} }
inputReciever.pageBlur.add(this.onPageBlur, this); inputReceiver.pageBlur.add(this.onPageBlur, this);
inputReciever.destroyed.add(this.cleanup, this); inputReceiver.destroyed.add(this.cleanup, this);
} }
/** /**

View File

@ -11,7 +11,7 @@ import {
enumDirectionToVector, enumDirectionToVector,
enumInvertedDirections, enumInvertedDirections,
} from "../../core/vector"; } from "../../core/vector";
import { enumUndergroundBeltMode, UndergroundBeltComponent } from "../components/underground_belt"; import { UndergroundBeltComponent, enumUndergroundBeltMode } from "../components/underground_belt";
import { Entity } from "../entity"; import { Entity } from "../entity";
import { GameSystemWithFilter } from "../game_system_with_filter"; import { GameSystemWithFilter } from "../game_system_with_filter";
@ -243,7 +243,7 @@ export class UndergroundBeltSystem extends GameSystemWithFilter {
* @param {Entity} entity * @param {Entity} entity
* @returns {import("../components/underground_belt").LinkedUndergroundBelt} * @returns {import("../components/underground_belt").LinkedUndergroundBelt}
*/ */
findRecieverForSender(entity) { findReceiverForSender(entity) {
const staticComp = entity.components.StaticMapEntity; const staticComp = entity.components.StaticMapEntity;
const undergroundComp = entity.components.UndergroundBelt; const undergroundComp = entity.components.UndergroundBelt;
const searchDirection = staticComp.localDirectionToWorld(enumDirection.top); const searchDirection = staticComp.localDirectionToWorld(enumDirection.top);
@ -299,7 +299,7 @@ export class UndergroundBeltSystem extends GameSystemWithFilter {
let cacheEntry = undergroundComp.cachedLinkedEntity; let cacheEntry = undergroundComp.cachedLinkedEntity;
if (!cacheEntry) { if (!cacheEntry) {
// Need to recompute cache // Need to recompute cache
cacheEntry = undergroundComp.cachedLinkedEntity = this.findRecieverForSender(entity); cacheEntry = undergroundComp.cachedLinkedEntity = this.findReceiverForSender(entity);
} }
if (!cacheEntry.entity) { if (!cacheEntry.entity) {

View File

@ -93,7 +93,7 @@ export class KeybindingsState extends TextualGameState {
type: "info", type: "info",
}); });
dialog.inputReciever.keydown.add(({ keyCode, shift, alt, event }) => { dialog.inputReceiver.keydown.add(({ keyCode, shift, alt, event }) => {
if (keyCode === 27) { if (keyCode === 27) {
this.dialogs.closeDialog(dialog); this.dialogs.closeDialog(dialog);
return; return;
@ -125,7 +125,7 @@ export class KeybindingsState extends TextualGameState {
this.updateKeybindings(); this.updateKeybindings();
}); });
dialog.inputReciever.backButton.add(() => {}); dialog.inputReceiver.backButton.add(() => {});
this.dialogs.internalShowDialog(dialog); this.dialogs.internalShowDialog(dialog);
this.app.sound.playUiSound(SOUNDS.dialogOk); this.app.sound.playUiSound(SOUNDS.dialogOk);