Skip to content

Commit

Permalink
v8.1.16: Fix for #328, #332, #326, #330
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Aug 5, 2024
1 parent aa2adee commit d6d1f53
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 8 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
// name: "makevm",
// host: "backend.make-vm.com:8001",
// },
// noNetworking: true,
// noCloud: true,
onEvent: (event, ci) => {
console.log("Event", event)
if (event === "ci-ready") {
Expand All @@ -64,6 +66,8 @@
// renderBackend: "webgl",
// imageRendering: "smooth",
});

window.props = props;
});

const diabloConf = `
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-dos",
"version": "8.1.15",
"version": "8.1.16",
"description": "Full-featured DOS player with multiple emulator backends",
"type": "module",
"keywords": [
Expand Down
52 changes: 51 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { loadBundleFromConfg, loadBundleFromUrl } from "./load";

import { DosOptions, DosProps, DosFn, ImageRendering, RenderBackend } from "./public/types";
import { browserSetFullScreen } from "./host/fullscreen";
import { NonSerializableStore, Store, makeNonSerializableStore, makeStore, postJsDosEvent } from "./store";
import { NonSerializableStore, Store, getNonSerializableStore,
makeNonSerializableStore, makeStore, postJsDosEvent } from "./store";
import { authSlice } from "./store/auth";

export const Dos: DosFn = (element: HTMLDivElement,
Expand Down Expand Up @@ -134,6 +135,26 @@ export const Dos: DosFn = (element: HTMLDivElement,
store.dispatch(dosSlice.actions.renderAspect(aspect));
}

function setNoNetworking(networking: boolean) {
store.dispatch(uiSlice.actions.noNetworking(networking));
}

function setNoCloud(cloud: boolean) {
store.dispatch(uiSlice.actions.noCloud(cloud));
}

function setPaused(paused: boolean) {
store.dispatch(dosSlice.actions.paused(paused));
}

function setScaleControls(scale: number) {
store.dispatch(dosSlice.actions.scaleControls(scale));
}

function setMouseSensitivity(sensitivity: number) {
store.dispatch(dosSlice.actions.mouseSensitivity(sensitivity));
}

if (options.theme) {
setTheme(options.theme);
}
Expand Down Expand Up @@ -198,6 +219,22 @@ export const Dos: DosFn = (element: HTMLDivElement,
setRenderAspect(options.renderAspect);
}

if (options.noNetworking !== undefined) {
setNoNetworking(options.noNetworking);
}

if (options.noCloud !== undefined) {
setNoCloud(options.noCloud);
}

if (options.scaleControls !== undefined) {
setScaleControls(options.scaleControls);
}

if (options.mouseSensitivity !== undefined) {
setMouseSensitivity(options.mouseSensitivity);
}

render(
<Provider store={store}>
{<Ui /> as any}
Expand All @@ -222,6 +259,19 @@ export const Dos: DosFn = (element: HTMLDivElement,
setImageRendering,
setRenderBackend,
setRenderAspect,
setNoNetworking,
setNoCloud,
setPaused,
setScaleControls,
setMouseSensitivity,

stop: async () => {
store.dispatch(uiSlice.actions.hidden(true));
const nonSerializableStore = getNonSerializableStore(store);
if (nonSerializableStore.ci) {
return nonSerializableStore.ci.exit();
}
},
};
};

Expand Down
11 changes: 11 additions & 0 deletions src/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export interface DosOptions {
imageRendering: ImageRendering,
renderBackend: RenderBackend,
renderAspect: RenderAspect,
noNetworking: boolean,
noCloud: boolean,
scaleControls: number,
mouseSensitivity: number,
}

export interface DosProps {
Expand All @@ -52,6 +56,13 @@ export interface DosProps {
setImageRendering(rendering: ImageRendering): void;
setRenderBackend(backend: RenderBackend): void;
setRenderAspect(aspect: RenderAspect): void;
setNoNetworking(noNetworking: boolean): void;
setNoCloud(noCloud: boolean): void;
setPaused(pause: boolean): void;
setScaleControls(scaleControls: number): void;
setMouseSensitivity(mouseSensitivity: number): void;

stop(): Promise<void>;
}

export type DosFn = (element: HTMLDivElement, options: Partial<DosOptions>) => DosProps;
Expand Down
6 changes: 4 additions & 2 deletions src/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export function SideBar(props: {}) {
const editor = useSelector((state: State) => state.ui.editor);
const backend = useSelector((state: State) => state.dos.backend);
const kiosk = useSelector((state: State) => state.ui.kiosk);
const networking = !useSelector((state: State) => state.ui.noNetworking);
const cloud = !useSelector((state: State) => state.ui.noCloud);

if (kiosk) {
return null;
Expand All @@ -26,7 +28,7 @@ export function SideBar(props: {}) {
{window === "run" && backend === "dosboxX" && <QuickSaveButton />}
{window === "run" && pointer.mobile && <SoftKeyboardButton />}
{window === "run" && <ImageRenderingButton />}
{window === "run" && <NetworkButton />}
{window === "run" && networking && <NetworkButton />}
{editor && window === "prerun" && <DosboxConfButton />}
{editor && window === "prerun" && backend === "dosboxX" && <FatDrivesButton />}
{editor && window === "run" && <FsButton />}
Expand All @@ -35,6 +37,6 @@ export function SideBar(props: {}) {
{window === "run" && <CyclesButton />}
{window === "run" && <HddLed />}
{(window === "prerun" || window === "run") && <SettingsButton />}
{window !== "run" && <AccountButton />}
{window !== "run" && cloud && <AccountButton />}
</div>;
};
15 changes: 15 additions & 0 deletions src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type Frame = "none" | "account" | "settings" |
"stats" | "fat-drives" | "quick-save" | "image-rendering";

const initialState: {
hidden: boolean,
modal: "none" | "login",
frame: Frame,
frameXs: boolean,
Expand All @@ -33,7 +34,10 @@ const initialState: {
autoStart: boolean,
kiosk: boolean,
documentHidden: boolean,
noNetworking: boolean,
noCloud: boolean,
} = {
hidden: false,
modal: "none",
frame: "none",
frameXs: false,
Expand All @@ -52,6 +56,8 @@ const initialState: {
autoStart: false,
kiosk: false,
documentHidden: document.hidden ?? false,
noNetworking: false,
noCloud: false,
};

export type UiState = typeof initialState;
Expand Down Expand Up @@ -164,6 +170,15 @@ export const uiSlice = createSlice({
documentHidden: (s, a: { payload: boolean }) => {
s.documentHidden = a.payload;
},
noNetworking: (state, a: { payload: boolean }) => {
state.noNetworking = a.payload;
},
noCloud: (state, a: { payload: boolean }) => {
state.noCloud = a.payload;
},
hidden: (state, a: { payload: boolean }) => {
state.hidden = a.payload;
},
},
extraReducers: (builder) => {
builder
Expand Down
9 changes: 7 additions & 2 deletions src/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import { useT } from "./i18n";
let currentWideScreen = uiSlice.getInitialState().wideScreen;
export function Ui() {
const rootRef = useRef<HTMLDivElement>(null);
const hidden = useSelector((state: State) => state.ui.hidden);
const theme = useSelector((state: State) => state.ui.theme);
const dispatch = useDispatch();

useEffect(() => {
if (rootRef === null || rootRef.current === null) {
if (hidden || rootRef === null || rootRef.current === null) {
return;
}

Expand All @@ -37,7 +38,11 @@ export function Ui() {
resizeObserver.disconnect();
window.removeEventListener("resize", onResize);
};
}, [rootRef, dispatch]);
}, [hidden, rootRef, dispatch]);

if (hidden) {
return null;
}

return <div
ref={rootRef}
Expand Down
5 changes: 3 additions & 2 deletions src/window/prerun-window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function PreRunWindow() {
const emuVersion = useSelector((state: State) => state.dos.emuVersion);
const dispatch = useDispatch();
const kiosk = useSelector((state: State) => state.ui.kiosk);
const noCloud = useSelector((state: State) => state.ui.noCloud);
const t = useT();

function login() {
Expand All @@ -28,7 +29,7 @@ export function PreRunWindow() {
return <div class="pre-run-window">
<Play class="mb-8" />

{!kiosk && (account === null) &&
{!noCloud && !kiosk && (account === null) &&
<div class="flex flex-row mb-4 -mt-4 items-center">
<div class="btn btn-accent" onClick={login}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
Expand All @@ -49,7 +50,7 @@ export function PreRunWindow() {
</div>
</div>
}
{!kiosk && account &&
{!noCloud && !kiosk && account &&
<div class="flex flex-row mb-4 -mt-4 items-center">
<div class="btn btn-ghost" onClick={login}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
Expand Down

0 comments on commit d6d1f53

Please sign in to comment.