feat(control): 3D-кубики в отдельном окне

Бросок синхронизирован на пульте и презентации; d100 как десятки; оверлей скрывается только кнопкой «Убрать».

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-09-04 13:01:34 +08:00
parent 86d6d157f0
commit 9ac01d217f
137 changed files with 958 additions and 1 deletions
@@ -0,0 +1,33 @@
import { useEffect, useState } from 'react';
import { ipcChannels } from '../../../shared/ipc/contracts';
import type { DiceRollEvent, DiceRollState } from '../../../shared/types';
import { getDndApi } from '../dndApi';
export function useDiceRollState(): readonly [
DiceRollState | null,
{ dispatch: (event: DiceRollEvent) => Promise<DiceRollState> },
] {
const api = getDndApi();
const [state, setState] = useState<DiceRollState | null>(null);
useEffect(() => {
void api.invoke(ipcChannels.diceRoll.getState, {}).then((r) => {
setState(r.state);
});
return api.on(ipcChannels.diceRoll.stateChanged, ({ state: next }) => {
setState(next);
});
}, [api]);
return [
state,
{
dispatch: async (event) => {
const r = await api.invoke(ipcChannels.diceRoll.dispatch, { event });
setState(r.state);
return r.state;
},
},
] as const;
}