tgui => tgui_ch

This commit is contained in:
Selis
2023-06-19 19:41:48 +02:00
parent 8de94964df
commit 46a8782e5b
83 changed files with 3403 additions and 1399 deletions

View File

@@ -14,6 +14,7 @@
import { perf } from 'common/perf';
import { createAction } from 'common/redux';
import { setupDrag } from './drag';
import { globalEvents } from './events';
import { focusMap } from './focus';
import { createLogger } from './logging';
import { resumeRenderer, suspendRenderer } from './renderer';
@@ -133,10 +134,18 @@ export const backendMiddleware = (store) => {
}
if (type === 'ping') {
Byond.sendMessage('pingReply');
Byond.sendMessage('ping/reply');
return;
}
if (type === 'byond/mousedown') {
globalEvents.emit('byond/mousedown');
}
if (type === 'byond/mouseup') {
globalEvents.emit('byond/mouseup');
}
if (type === 'backend/suspendStart' && !suspendInterval) {
logger.log(`suspending (${Byond.windowId})`);
// Keep sending suspend messages until it succeeds.
@@ -213,8 +222,10 @@ export const backendMiddleware = (store) => {
*/
export const sendAct = (action: string, payload: object = {}) => {
// Validate that payload is an object
const isObject =
typeof payload === 'object' && payload !== null && !Array.isArray(payload);
// prettier-ignore
const isObject = typeof payload === 'object'
&& payload !== null
&& !Array.isArray(payload);
if (!isObject) {
logger.error(`Payload for act() must be an object, got this:`, payload);
return;
@@ -339,13 +350,15 @@ export const useSharedState = <T>(
return [
sharedState,
(nextState) => {
// prettier-ignore
Byond.sendMessage({
type: 'setSharedState',
key,
value:
JSON.stringify(
typeof nextState === 'function' ? nextState(sharedState) : nextState
) || '',
value: JSON.stringify(
typeof nextState === 'function'
? nextState(sharedState)
: nextState
) || '',
});
},
];