1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-11 09:11:50 +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";
/* 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 { 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");
@ -38,8 +38,8 @@ export class GameState {
this.clickDetectors = [];
// Every state captures keyboard events by default
this.inputReciever = new InputReceiver("state-" + key);
this.inputReciever.backButton.add(this.onBackButton, this);
this.inputReceiver = new InputReceiver("state-" + key);
this.inputReceiver.backButton.add(this.onBackButton, this);
// A channel we can use to perform async ops
this.asyncChannel = new RequestChannel();
@ -267,7 +267,7 @@ export class GameState {
*/
internalEnterCallback(payload, callCallback = true) {
logSection(this.key, "#26a69a");
this.app.inputMgr.pushReciever(this.inputReciever);
this.app.inputMgr.pushReceiver(this.inputReceiver);
this.htmlElement = this.getDivElement();
this.htmlElement.classList.add("active");
@ -293,7 +293,7 @@ export class GameState {
this.onLeave();
this.htmlElement.classList.remove("active");
this.app.inputMgr.popReciever(this.inputReciever);
this.app.inputMgr.popReceiver(this.inputReceiver);
this.internalCleanUpClickDetectors();
this.asyncChannel.cancelAll();
}

View File

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

View File

@ -1,15 +1,15 @@
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 { 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 clickDetectors: ClickDetector[] = [];
public inputReciever: InputReceiver;
public inputReceiver: InputReceiver;
public enterHandler: 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.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 | []) {
this.app.inputMgr.popReciever(this.inputReciever);
this.app.inputMgr.popReceiver(this.inputReceiver);
if (id !== "close-button") {
this.buttonSignals[id].dispatch(...payload);
@ -160,7 +160,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
});
title.appendChild(closeBtn);
this.inputReciever.backButton.add(() => this.internalButtonHandler("close-button"));
this.inputReceiver.backButton.add(() => this.internalButtonHandler("close-button"));
}
const content = document.createElement("div");
@ -231,7 +231,7 @@ export class Dialog<T extends string = never, U extends unknown[] = []> {
}
this.element = elem;
this.app.inputMgr.pushReciever(this.inputReciever);
this.app.inputMgr.pushReceiver(this.inputReceiver);
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
// dispatched to the modal dialogs, it will not call the internalButtonHandler,
// 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) {
this.clickDetectors[i].cleanup();
@ -300,8 +300,8 @@ export class DialogLoading extends Dialog {
});
// Loading dialog can not get closed with back button
this.inputReciever.backButton.removeAll();
this.inputReciever.context = "dialog-loading";
this.inputReceiver.backButton.removeAll();
this.inputReceiver.context = "dialog-loading";
}
createElement() {
@ -322,7 +322,7 @@ export class DialogLoading extends Dialog {
loader.classList.add("loadingIndicator");
elem.appendChild(loader);
this.app.inputMgr.pushReciever(this.inputReciever);
this.app.inputMgr.pushReceiver(this.inputReceiver);
return elem;
}

View File

@ -57,7 +57,7 @@ export class UndergroundBeltComponent extends Component {
/**
* 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"
* @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 { lerp, randomInt, round2Digits } from "../core/utils";
import { Vector } from "../core/vector";
import { MOD_SIGNALS } from "../mods/mod_signals";
import { Savegame } from "../savegame/savegame";
import { SavegameSerializer } from "../savegame/savegame_serializer";
import { AchievementProxy } from "./achievement_proxy";
import { AutomaticSave } from "./automatic_save";
import { MetaHubBuilding } from "./buildings/hub";
import { Camera } from "./camera";
import { DynamicTickrate } from "./dynamic_tickrate";
import { EntityManager } from "./entity_manager";
import { GameMode } from "./game_mode";
import { GameSystemManager } from "./game_system_manager";
import { HubGoals } from "./hub_goals";
import { GameHUD } from "./hud/hud";
@ -31,14 +34,11 @@ import { KeyActionMapper } from "./key_action_mapper";
import { GameLogic } from "./logic";
import { MapView } from "./map_view";
import { defaultBuildingVariant } from "./meta_building";
import { GameMode } from "./game_mode";
import { ProductionAnalytics } from "./production_analytics";
import { GameRoot } from "./root";
import { ShapeDefinitionManager } from "./shape_definition_manager";
import { AchievementProxy } from "./achievement_proxy";
import { SoundProxy } from "./sound_proxy";
import { GameTime } from "./time/game_time";
import { MOD_SIGNALS } from "../mods/mod_signals";
const logger = createLogger("ingame/core");
@ -101,7 +101,7 @@ export class GameCore {
const root = this.root;
// 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
root.gameMode = GameMode.create(root, gameModeId, parentState.creationPayload.gameModeParameters);
@ -142,7 +142,7 @@ export class GameCore {
// @todo Find better place
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) {
// 'T'

View File

@ -1,20 +1,19 @@
import { globalConfig } from "../../../core/config";
import { gMetaBuildingRegistry } from "../../../core/global_registries";
import { Signal, STOP_PROPAGATION } from "../../../core/signal";
import { TrackedState } from "../../../core/tracked_state";
import { safeModulo } from "../../../core/utils";
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 { StaticMapEntityComponent } from "../../components/static_map_entity";
import { Entity } from "../../entity";
import { KEYMAPPINGS } from "../../key_action_mapper";
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 { getBuildingDataFromCode, getCodeFromBuildingData } from "../../building_codes";
import { MetaHubBuilding } from "../../buildings/hub";
import { safeModulo } from "../../../core/utils";
import { BaseHUDPart } from "../base_hud_part";
/**
* 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);
keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.abortPlacement, 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
this.root.hud.signals.buildingsSelectedForCopy.add(this.abortPlacement, this);

View File

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

View File

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

View File

@ -139,7 +139,7 @@ export class HUDSandboxController extends BaseHUDPart {
initialize() {
// Allow toggling the controller overlay
this.root.gameState.inputReciever.keydown.add(key => {
this.root.gameState.inputReceiver.keydown.add(key => {
if (key.keyCode === 117) {
// F6
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 { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper";
import { formatBigNumberFull, makeDiv } from "../../../core/utils";
import { T } from "../../../translations";
import { StaticMapEntityComponent } from "../../components/static_map_entity";
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 {
createElements(parent) {
@ -83,8 +83,8 @@ export class HUDSettingsMenu extends BaseHUDPart {
attachClass: "visible",
});
this.inputReciever = new InputReceiver("settingsmenu");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReciever);
this.inputReceiver = new InputReceiver("settingsmenu");
this.keyActionMapper = new KeyActionMapper(this.root, this.inputReceiver);
this.keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.close, this);
this.close();
@ -92,7 +92,7 @@ export class HUDSettingsMenu extends BaseHUDPart {
show() {
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);
@ -119,7 +119,7 @@ export class HUDSettingsMenu extends BaseHUDPart {
close() {
this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever);
this.root.app.inputMgr.makeSureDetached(this.inputReceiver);
this.update();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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