1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00
tobspr_shapez.io/src/js/platform/wrapper.js

136 lines
2.8 KiB
JavaScript
Raw Normal View History

/* typehints:start */
import { Application } from "../application";
/* typehints:end */
import { IS_MOBILE } from "../core/config";
export class PlatformWrapperInterface {
constructor(app) {
/** @type {Application} */
this.app = app;
}
/** @returns {string} */
getId() {
abstract;
return "unknown-platform";
}
/**
* Returns the UI scale, called on every resize
* @returns {number} */
getUiScale() {
return 1;
}
/** @returns {boolean} */
getSupportsRestart() {
abstract;
return false;
}
/**
* Returns the strength of touch pans with the mouse
*/
getTouchPanStrength() {
return 1;
}
/** @returns {Promise<void>} */
initialize() {
document.documentElement.classList.add("p-" + this.getId());
return Promise.resolve();
}
/**
* Should initialize the apps ad provider in case supported
* @returns {Promise<void>}
*/
initializeAdProvider() {
return Promise.resolve();
}
/**
* Should return the minimum supported zoom level
* @returns {number}
*/
getMinimumZoom() {
return 0.1 * this.getScreenScale();
}
/**
* Should return the maximum supported zoom level
* @returns {number}
*/
getMaximumZoom() {
return 3.5 * this.getScreenScale();
}
getScreenScale() {
return Math.min(window.innerWidth, window.innerHeight) / 1024.0;
}
/**
* Should return if this platform supports ads at all
*/
getSupportsAds() {
return false;
}
/**
* Attempt to open an external url
* @param {string} url
* @param {boolean=} force Whether to always open the url even if not allowed
Squashed commit of the following: commit ea2f32b3ffe4f385a1c87196c10667e3157c50d5 Author: tobspr <tobias.springer1@googlemail.com> Date: Tue Feb 15 09:09:30 2022 +0100 Fix examples commit 561318b7dbb7f78e8ff2a60011ae7065c9c90c80 Author: Dimava <dimava2@ya.ru> Date: Tue Feb 15 10:31:47 2022 +0300 mark all abstract functions abstract (#1383) commit 81d65e5801f7a56500bb95abaceb8a8264d60f9f 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 commit 4f0af32a5e964905d89eab76be12387ec27bb308 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 commit 3f3a2e0981135b9ec63d7d58c4fec14f01feed05 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 commit c4f26320a45450d6bc66a5fa746b1c881a4d94b2 Author: dobidon <35607008+dobidon@users.noreply.github.com> Date: Sun Feb 13 23:11:38 2022 +0300 Translating new keys (#1380) commit cb5c3f798a29c667acd2c4586a976937f534047a 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) commit dee4f23b7ec696eaa69fe7298dfa5e3e4765af06 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) commit b7bc2ac1b7aae772753005ba4dc1cdb6d21f21fd 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 commit 93b9340ab70554c113e23071c14913067d3d53e2 Author: Pimak <37274338+Pimak@users.noreply.github.com> Date: Sun Feb 13 21:09:56 2022 +0100 Update README.md (#1376) Small mistake commit f534a88f80f7dbc09b13910f6aca65dac0fffa27 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 commit dab4aa9cda19eaf069227ab3a104a87bb2b35a70 Author: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com> Date: Sun Feb 13 14:07:02 2022 -0600 fix fs-job sanitization (#1375) commit 4466821557d246e5926b5ef07cef161dacbb8f84 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) commit 65ae26cb5332a534bec649a579d20c62e078ccc0 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 commit e5742fd577613b2a43792819432ed8303ac4c4fc 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 commit 41c6b1c59508c48f6f172601efbd4ea960260275 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
2022-02-15 11:02:00 +00:00
* @abstract
*/
openExternalLink(url, force = false) {
abstract;
}
/**
* Attempt to restart the app
Squashed commit of the following: commit ea2f32b3ffe4f385a1c87196c10667e3157c50d5 Author: tobspr <tobias.springer1@googlemail.com> Date: Tue Feb 15 09:09:30 2022 +0100 Fix examples commit 561318b7dbb7f78e8ff2a60011ae7065c9c90c80 Author: Dimava <dimava2@ya.ru> Date: Tue Feb 15 10:31:47 2022 +0300 mark all abstract functions abstract (#1383) commit 81d65e5801f7a56500bb95abaceb8a8264d60f9f 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 commit 4f0af32a5e964905d89eab76be12387ec27bb308 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 commit 3f3a2e0981135b9ec63d7d58c4fec14f01feed05 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 commit c4f26320a45450d6bc66a5fa746b1c881a4d94b2 Author: dobidon <35607008+dobidon@users.noreply.github.com> Date: Sun Feb 13 23:11:38 2022 +0300 Translating new keys (#1380) commit cb5c3f798a29c667acd2c4586a976937f534047a 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) commit dee4f23b7ec696eaa69fe7298dfa5e3e4765af06 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) commit b7bc2ac1b7aae772753005ba4dc1cdb6d21f21fd 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 commit 93b9340ab70554c113e23071c14913067d3d53e2 Author: Pimak <37274338+Pimak@users.noreply.github.com> Date: Sun Feb 13 21:09:56 2022 +0100 Update README.md (#1376) Small mistake commit f534a88f80f7dbc09b13910f6aca65dac0fffa27 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 commit dab4aa9cda19eaf069227ab3a104a87bb2b35a70 Author: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com> Date: Sun Feb 13 14:07:02 2022 -0600 fix fs-job sanitization (#1375) commit 4466821557d246e5926b5ef07cef161dacbb8f84 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) commit 65ae26cb5332a534bec649a579d20c62e078ccc0 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 commit e5742fd577613b2a43792819432ed8303ac4c4fc 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 commit 41c6b1c59508c48f6f172601efbd4ea960260275 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
2022-02-15 11:02:00 +00:00
* @abstract
*/
performRestart() {
abstract;
}
/**
* Returns whether this platform supports a toggleable fullscreen
*/
getSupportsFullscreen() {
return false;
}
/**
* Should set the apps fullscreen state to the desired state
* @param {boolean} flag
Squashed commit of the following: commit ea2f32b3ffe4f385a1c87196c10667e3157c50d5 Author: tobspr <tobias.springer1@googlemail.com> Date: Tue Feb 15 09:09:30 2022 +0100 Fix examples commit 561318b7dbb7f78e8ff2a60011ae7065c9c90c80 Author: Dimava <dimava2@ya.ru> Date: Tue Feb 15 10:31:47 2022 +0300 mark all abstract functions abstract (#1383) commit 81d65e5801f7a56500bb95abaceb8a8264d60f9f 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 commit 4f0af32a5e964905d89eab76be12387ec27bb308 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 commit 3f3a2e0981135b9ec63d7d58c4fec14f01feed05 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 commit c4f26320a45450d6bc66a5fa746b1c881a4d94b2 Author: dobidon <35607008+dobidon@users.noreply.github.com> Date: Sun Feb 13 23:11:38 2022 +0300 Translating new keys (#1380) commit cb5c3f798a29c667acd2c4586a976937f534047a 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) commit dee4f23b7ec696eaa69fe7298dfa5e3e4765af06 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) commit b7bc2ac1b7aae772753005ba4dc1cdb6d21f21fd 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 commit 93b9340ab70554c113e23071c14913067d3d53e2 Author: Pimak <37274338+Pimak@users.noreply.github.com> Date: Sun Feb 13 21:09:56 2022 +0100 Update README.md (#1376) Small mistake commit f534a88f80f7dbc09b13910f6aca65dac0fffa27 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 commit dab4aa9cda19eaf069227ab3a104a87bb2b35a70 Author: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com> Date: Sun Feb 13 14:07:02 2022 -0600 fix fs-job sanitization (#1375) commit 4466821557d246e5926b5ef07cef161dacbb8f84 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) commit 65ae26cb5332a534bec649a579d20c62e078ccc0 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 commit e5742fd577613b2a43792819432ed8303ac4c4fc 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 commit 41c6b1c59508c48f6f172601efbd4ea960260275 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
2022-02-15 11:02:00 +00:00
* @abstract
*/
setFullscreen(flag) {
abstract;
}
/**
* Returns whether this platform supports quitting the app
*/
getSupportsAppExit() {
return false;
}
/**
* Attempts to quit the app
Squashed commit of the following: commit ea2f32b3ffe4f385a1c87196c10667e3157c50d5 Author: tobspr <tobias.springer1@googlemail.com> Date: Tue Feb 15 09:09:30 2022 +0100 Fix examples commit 561318b7dbb7f78e8ff2a60011ae7065c9c90c80 Author: Dimava <dimava2@ya.ru> Date: Tue Feb 15 10:31:47 2022 +0300 mark all abstract functions abstract (#1383) commit 81d65e5801f7a56500bb95abaceb8a8264d60f9f 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 commit 4f0af32a5e964905d89eab76be12387ec27bb308 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 commit 3f3a2e0981135b9ec63d7d58c4fec14f01feed05 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 commit c4f26320a45450d6bc66a5fa746b1c881a4d94b2 Author: dobidon <35607008+dobidon@users.noreply.github.com> Date: Sun Feb 13 23:11:38 2022 +0300 Translating new keys (#1380) commit cb5c3f798a29c667acd2c4586a976937f534047a 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) commit dee4f23b7ec696eaa69fe7298dfa5e3e4765af06 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) commit b7bc2ac1b7aae772753005ba4dc1cdb6d21f21fd 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 commit 93b9340ab70554c113e23071c14913067d3d53e2 Author: Pimak <37274338+Pimak@users.noreply.github.com> Date: Sun Feb 13 21:09:56 2022 +0100 Update README.md (#1376) Small mistake commit f534a88f80f7dbc09b13910f6aca65dac0fffa27 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 commit dab4aa9cda19eaf069227ab3a104a87bb2b35a70 Author: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com> Date: Sun Feb 13 14:07:02 2022 -0600 fix fs-job sanitization (#1375) commit 4466821557d246e5926b5ef07cef161dacbb8f84 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) commit 65ae26cb5332a534bec649a579d20c62e078ccc0 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 commit e5742fd577613b2a43792819432ed8303ac4c4fc 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 commit 41c6b1c59508c48f6f172601efbd4ea960260275 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
2022-02-15 11:02:00 +00:00
* @abstract
*/
exitApp() {
abstract;
}
/**
* Whether this platform supports a keyboard
*/
getSupportsKeyboard() {
return !IS_MOBILE;
}
}