forked from phenom/healer-man
Release Healer Man 0.1.29
This commit is contained in:
1 parent
8c9809d3e0
commit
544c1bee91
120 files changed
+4363
-1036
No files matched your search
@@ -1,5 +1,9 @@
|
||||
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { CONTROLLER_SYSTEM_BACK_TOKEN, subscribeControllerToken } from "../input/controller";
|
||||
import { getControllerHeldTokens, subscribeControllerToken } from "../input/controller";
|
||||
import { isControllerMenuBackToken } from "../input/useMenuController";
|
||||
import { controllerBindingMatches, inputKeyForEvent } from "../input/keybinds";
|
||||
import { getInputPreferences, isCapturingInput } from "../input/keybindRuntime";
|
||||
import { useInputBindingLabels } from "../input/useInputBindingLabels";
|
||||
import { resolveDisplayLayout } from "../platform/displayLayout";
|
||||
import { requestDisplaySurface, subscribeDisplaySurface, type DisplaySurface } from "../platform/displayRouting";
|
||||
|
||||
@@ -8,11 +12,13 @@ interface DualDisplayFrameProps {
|
||||
bottom: ReactNode;
|
||||
contextLabel?: string;
|
||||
onActiveSurfaceChange?: (surface: DisplaySurface) => void;
|
||||
companionDisabled?: boolean;
|
||||
}
|
||||
|
||||
const FOCUSABLE = "button:not([disabled]):not([tabindex='-1']), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])";
|
||||
|
||||
export function DualDisplayFrame({ top, bottom, contextLabel = "Companion", onActiveSurfaceChange }: DualDisplayFrameProps) {
|
||||
export function DualDisplayFrame({ top, bottom, contextLabel = "Companion", onActiveSurfaceChange, companionDisabled = false }: DualDisplayFrameProps) {
|
||||
const bindingLabel = useInputBindingLabels();
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const dedicatedSurface = params.get("display");
|
||||
const layout = resolveDisplayLayout({ display: dedicatedSurface, layout: params.get("layout") });
|
||||
@@ -38,17 +44,17 @@ export function DualDisplayFrame({ top, bottom, contextLabel = "Companion", onAc
|
||||
requestDisplaySurface("top");
|
||||
const unsubscribeSurface = subscribeDisplaySurface(showSurface);
|
||||
const unsubscribeController = subscribeControllerToken(({ token, repeat, pressed }) => {
|
||||
if (pressed === false) return;
|
||||
if (token === "Button8" && !repeat) toggleSurface();
|
||||
if ((token === "Button1" || token === CONTROLLER_SYSTEM_BACK_TOKEN) && !repeat && activeRef.current === "bottom") {
|
||||
if (pressed === false || isCapturingInput() || companionDisabled) return;
|
||||
if (controllerBindingMatches(getInputPreferences().controller.companion, token, getControllerHeldTokens()) && !repeat) toggleSurface();
|
||||
if (isControllerMenuBackToken(token) && !repeat && activeRef.current === "bottom") {
|
||||
requestDisplaySurface("top");
|
||||
}
|
||||
});
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.repeat || event.defaultPrevented) return;
|
||||
if (event.repeat || event.defaultPrevented || isCapturingInput() || companionDisabled) return;
|
||||
const target = event.target as HTMLElement | null;
|
||||
const isEditable = target?.matches("input, textarea, select, [contenteditable='true']") ?? false;
|
||||
if (event.code === "KeyC" && !isEditable) {
|
||||
if (inputKeyForEvent(event) && inputKeyForEvent(event) === getInputPreferences().pc.companion && !isEditable) {
|
||||
event.preventDefault();
|
||||
toggleSurface();
|
||||
}
|
||||
@@ -61,7 +67,7 @@ export function DualDisplayFrame({ top, bottom, contextLabel = "Companion", onAc
|
||||
onSurfaceChangeRef.current?.("top");
|
||||
requestDisplaySurface("top");
|
||||
};
|
||||
}, [dedicatedSurface, layout, showSurface, toggleSurface]);
|
||||
}, [companionDisabled, dedicatedSurface, layout, showSurface, toggleSurface]);
|
||||
|
||||
useEffect(() => {
|
||||
if (layout !== "single" || activeSurface !== "bottom") return;
|
||||
@@ -73,8 +79,8 @@ export function DualDisplayFrame({ top, bottom, contextLabel = "Companion", onAc
|
||||
});
|
||||
const onModalKeyDown = (event: KeyboardEvent) => {
|
||||
const dialog = dialogRef.current;
|
||||
if (!dialog) return;
|
||||
if (event.key === "Escape") {
|
||||
if (!dialog || isCapturingInput() || event.defaultPrevented) return;
|
||||
if (inputKeyForEvent(event) && [getInputPreferences().pc["menu-back"], getInputPreferences().pc["menu-back-alt"]].includes(inputKeyForEvent(event))) {
|
||||
event.preventDefault();
|
||||
requestDisplaySurface("top");
|
||||
return;
|
||||
@@ -122,9 +128,9 @@ export function DualDisplayFrame({ top, bottom, contextLabel = "Companion", onAc
|
||||
<div className="single-context-surface">{bottom}</div>
|
||||
</div>
|
||||
)}
|
||||
<button className="single-context-toggle" type="button" onClick={toggleSurface} aria-expanded={contextOpen}>
|
||||
<b>{contextOpen ? "Return" : contextLabel}</b><small>Select / C</small>
|
||||
</button>
|
||||
{!companionDisabled && <button className="single-context-toggle" type="button" onClick={toggleSurface} aria-expanded={contextOpen}>
|
||||
<b>{contextOpen ? "Return" : contextLabel}</b><small>{bindingLabel("controller", "companion")} / {bindingLabel("pc", "companion")}</small>
|
||||
</button>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user