mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
commitea2f32b3ff
Author: tobspr <tobias.springer1@googlemail.com> Date: Tue Feb 15 09:09:30 2022 +0100 Fix examples commit561318b7db
Author: Dimava <dimava2@ya.ru> Date: Tue Feb 15 10:31:47 2022 +0300 mark all abstract functions abstract (#1383) commit81d65e5801
Author: WaffleDevsAlt <81845843+WaffleDevsAlt@users.noreply.github.com> Date: Tue Feb 15 02:31:02 2022 -0500 Removes unwanted ], (#1384) The ], breaks build, with a core error commit4f0af32a5e
Author: Ved_s <53968411+Ved-s@users.noreply.github.com> Date: Mon Feb 14 07:14:34 2022 +1100 Update base-ru.yaml (#1312) * Update base-ru.yaml I think other's comments about the game should stay in English, as Russian translation cannot precisely describe this * Update base-ru.yaml commit3f3a2e0981
Author: Daan Breur <git@daanbreur.systems> Date: Sun Feb 13 21:11:52 2022 +0100 NL Translations for Mods and puzzleDLC (#1381) * [NL] Mods and puzzleDLC * Update base-nl.yaml * Update base-nl.yaml commitc4f26320a4
Author: dobidon <35607008+dobidon@users.noreply.github.com> Date: Sun Feb 13 23:11:38 2022 +0300 Translating new keys (#1380) commitcb5c3f798a
Author: Pimak <37274338+Pimak@users.noreply.github.com> Date: Sun Feb 13 21:11:16 2022 +0100 Update base-fr.yaml for mods translation (#1377) commitdee4f23b7e
Author: Sense101 <67970865+Sense101@users.noreply.github.com> Date: Sun Feb 13 20:11:02 2022 +0000 Fix method for adding variants to an existing building (#1378) commitb7bc2ac1b7
Author: jbelbaz <32191774+jbelbaz@users.noreply.github.com> Date: Sun Feb 13 21:10:11 2022 +0100 Update base-fr.yaml (#1328) Change of a few lines in English. I was unable to verify in-game integration ... I hope my work will fit. glad to help :D commit93b9340ab7
Author: Pimak <37274338+Pimak@users.noreply.github.com> Date: Sun Feb 13 21:09:56 2022 +0100 Update README.md (#1376) Small mistake commitf534a88f80
Author: Bagel03 <70449196+Bagel03@users.noreply.github.com> Date: Sun Feb 13 15:09:41 2022 -0500 Fix that whole export debacle (#1370) * Re-add setting exports * Update webpack.production.config.js * Update mod.js * Slight change * Update mod.js * Update webpack.production.config.js * Update webpack.config.js commitdab4aa9cda
Author: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com> Date: Sun Feb 13 14:07:02 2022 -0600 fix fs-job sanitization (#1375) commit4466821557
Author: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com> Date: Sun Feb 13 21:06:42 2022 +0100 Added display hook for getting the signelton and the drawing (#1374) commit65ae26cb53
Author: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com> Date: Sun Feb 13 21:06:24 2022 +0100 Added hook for storage can accept item (#1373) * Added hook for storage can accept item * Fixed order commite5742fd577
Author: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com> Date: Sun Feb 13 21:06:10 2022 +0100 Added constant signal resolver hook (#1372) * Added constant signal resolver hook * Added apply commit41c6b1c595
Author: Thomas (DJ1TJOO) <44841260+DJ1TJOO@users.noreply.github.com> Date: Sun Feb 13 21:05:58 2022 +0100 Added mod processing requirements (#1371) * Added mod processing requirements * Added missing bind * Renamed to mods
169 lines
4.3 KiB
JavaScript
169 lines
4.3 KiB
JavaScript
/* typehints:start */
|
|
import { GameRoot } from "../root";
|
|
import { DrawParameters } from "../../core/draw_parameters";
|
|
/* typehints:end */
|
|
|
|
import { ClickDetector } from "../../core/click_detector";
|
|
import { KeyActionMapper } from "../key_action_mapper";
|
|
|
|
export class BaseHUDPart {
|
|
/**
|
|
* @param {GameRoot} root
|
|
*/
|
|
constructor(root) {
|
|
this.root = root;
|
|
|
|
/** @type {Array<ClickDetector>} */
|
|
this.clickDetectors = [];
|
|
}
|
|
|
|
/**
|
|
* Should create all require elements
|
|
* @param {HTMLElement} parent
|
|
*/
|
|
createElements(parent) {}
|
|
|
|
/**
|
|
* Should initialize the element, called *after* the elements have been created
|
|
* @abstract
|
|
*/
|
|
initialize() {
|
|
abstract;
|
|
}
|
|
|
|
/**
|
|
* Should update any required logic
|
|
*/
|
|
update() {}
|
|
|
|
/**
|
|
* Should draw the hud
|
|
* @param {DrawParameters} parameters
|
|
*/
|
|
draw(parameters) {}
|
|
|
|
/**
|
|
* Should draw any overlays (screen space)
|
|
* @param {DrawParameters} parameters
|
|
*/
|
|
drawOverlays(parameters) {}
|
|
|
|
/**
|
|
* Should return true if the widget has a modal dialog opened and thus
|
|
* the game does not need to update / redraw
|
|
* @returns {boolean}
|
|
*/
|
|
shouldPauseRendering() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Should return false if the game should be paused
|
|
* @returns {boolean}
|
|
*/
|
|
shouldPauseGame() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Should return true if this overlay is open and currently blocking any user interaction
|
|
*/
|
|
isBlockingOverlay() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Cleans up the hud element, if overridden make sure to call super.cleanup
|
|
*/
|
|
cleanup() {
|
|
this.cleanupClickDetectors();
|
|
}
|
|
|
|
/**
|
|
* Cleans up all click detectors
|
|
*/
|
|
cleanupClickDetectors() {
|
|
if (this.clickDetectors) {
|
|
for (let i = 0; i < this.clickDetectors.length; ++i) {
|
|
this.clickDetectors[i].cleanup();
|
|
}
|
|
this.clickDetectors = [];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Should close the element, in case its supported
|
|
*/
|
|
close() {}
|
|
|
|
// Helpers
|
|
|
|
/**
|
|
* Helper method to construct a new click detector
|
|
* @param {Element} element The element to listen on
|
|
* @param {function} handler The handler to call on this object
|
|
* @param {import("../../core/click_detector").ClickDetectorConstructorArgs=} args Click detector arguments
|
|
*
|
|
*/
|
|
trackClicks(element, handler, args = {}) {
|
|
const detector = new ClickDetector(element, args);
|
|
detector.click.add(handler, this);
|
|
this.registerClickDetector(detector);
|
|
}
|
|
|
|
/**
|
|
* Registers a new click detector
|
|
* @param {ClickDetector} detector
|
|
*/
|
|
registerClickDetector(detector) {
|
|
this.clickDetectors.push(detector);
|
|
if (G_IS_DEV) {
|
|
// @ts-ignore
|
|
detector._src = "hud-" + this.constructor.name;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Closes this element when its background is clicked
|
|
* @param {HTMLElement} element
|
|
* @param {function} closeMethod
|
|
*/
|
|
closeOnBackgroundClick(element, closeMethod = null) {
|
|
const bgClickDetector = new ClickDetector(element, {
|
|
preventDefault: true,
|
|
targetOnly: true,
|
|
applyCssClass: null,
|
|
consumeEvents: true,
|
|
clickSound: null,
|
|
});
|
|
|
|
// If the state defines a close method, use that as fallback
|
|
// @ts-ignore
|
|
bgClickDetector.touchend.add(closeMethod || this.close, this);
|
|
this.registerClickDetector(bgClickDetector);
|
|
}
|
|
|
|
/**
|
|
* Forwards the game speed keybindings so you can toggle pause / Fastforward
|
|
* in the building tooltip and such
|
|
* @param {KeyActionMapper} sourceMapper
|
|
*/
|
|
forwardGameSpeedKeybindings(sourceMapper) {
|
|
sourceMapper.forward(this.root.keyMapper, ["gamespeed_pause", "gamespeed_fastforward"]);
|
|
}
|
|
|
|
/**
|
|
* Forwards the map movement keybindings so you can move the map with the
|
|
* arrow keys
|
|
* @param {KeyActionMapper} sourceMapper
|
|
*/
|
|
forwardMapMovementKeybindings(sourceMapper) {
|
|
sourceMapper.forward(this.root.keyMapper, [
|
|
"mapMoveUp",
|
|
"mapMoveRight",
|
|
"mapMoveDown",
|
|
"mapMoveLeft",
|
|
]);
|
|
}
|
|
}
|