Skip to content

Commit

Permalink
Implement kiosk mode
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Jun 20, 2024
1 parent e40372c commit 3e99ee0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
// url: "https://cdn.dos.zone/original/2X/7/744842062905f72648a4d492ccc2526d039b3702.jsdos", // sim-city
// dosboxConf: diabloConf,
// loginUrl: "http://localhost:8080/subscription.html",
autoStart: true,
// autoStart: true,
// kiosk: true,
pathPrefix: "/emulators/",
server: params.get("server"),
room: params.get("room"),
Expand Down
16 changes: 15 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ export const Dos: DosFn = (element: HTMLDivElement,
browserSetFullScreen(fullScreen, store);
}

function setAutoStart(autoStart: boolean) {
store.dispatch(uiSlice.actions.autoStart(autoStart));
}

function setKiosk(kiosk: boolean) {
store.dispatch(uiSlice.actions.kiosk(kiosk));
}

if (options.theme) {
setTheme(options.theme);
}
Expand Down Expand Up @@ -160,7 +168,11 @@ export const Dos: DosFn = (element: HTMLDivElement,
}

if (options.autoStart !== undefined) {
store.dispatch(uiSlice.actions.autoStart(options.autoStart));
setAutoStart(options.autoStart);
}

if (options.kiosk !== undefined) {
setKiosk(options.kiosk);
}

render(
Expand All @@ -182,6 +194,8 @@ export const Dos: DosFn = (element: HTMLDivElement,
setFrame,
setBackground,
setFullScreen,
setAutoStart,
setKiosk,
};
};

Expand Down
3 changes: 3 additions & 0 deletions src/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface DosOptions {
},
loginUrl: string,
autoStart: boolean,
kiosk: boolean,
}

export interface DosProps {
Expand All @@ -40,6 +41,8 @@ export interface DosProps {
setFrame(frame: "network"): void;
setBackground(background: string | null): void;
setFullScreen(fullScreen: boolean): void;
setAutoStart(autoStart: boolean): void;
setKiosk(kiosk: boolean): void;
}

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

if (kiosk) {
return null;
}

return <div class="sidebar">
{window === "run" && backend === "dosbox" && <CloudSaveButton />}
Expand Down
5 changes: 5 additions & 0 deletions src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const initialState: {
updateWsWarning: boolean,
cloudSaves: boolean,
autoStart: boolean,
kiosk: boolean,
} = {
modal: "none",
frame: "none",
Expand All @@ -48,6 +49,7 @@ const initialState: {
updateWsWarning: false,
cloudSaves: true,
autoStart: false,
kiosk: false,
};

export type UiState = typeof initialState;
Expand Down Expand Up @@ -154,6 +156,9 @@ export const uiSlice = createSlice({
autoStart: (state, a: { payload: boolean }) => {
state.autoStart = a.payload;
},
kiosk: (state, a: { payload: boolean }) => {
state.kiosk = a.payload;
},
},
extraReducers: (builder) => {
builder
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 @@ -14,6 +14,7 @@ export function PreRunWindow() {
const account = useSelector((state: State) => state.auth.account);
const emuVersion = useSelector((state: State) => state.dos.emuVersion);
const dispatch = useDispatch();
const kiosk = useSelector((state: State) => state.ui.kiosk);
const t = useT();

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

{(account === null) &&
{!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 @@ -48,7 +49,7 @@ export function PreRunWindow() {
</div>
</div>
}
{account &&
{!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
3 changes: 2 additions & 1 deletion src/window/window.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function Window(props: {}) {
const frameXs = useSelector((state: State) => state.ui.frameXs);
const window = useSelector((state: State) => state.ui.window);
const background = useSelector((state: State) => state.ui.background);
const kiosk = useSelector((state: State) => state.ui.kiosk);

let windowComponent = <Loading />;
switch (window) {
Expand All @@ -36,7 +37,7 @@ export function Window(props: {}) {
<div class="background-image"
style={{ backgroundImage: (background ? "url(" + background + ")" : undefined ) }} />
<div class="relative flex flex-row h-full w-full items-start justify-start overflow-auto">
<div class={(frameOpened ? (frameXs ? "w-24" : "w-96") : "w-12") + " flex-shrink-0"}></div>
{ !kiosk && <div class={(frameOpened ? (frameXs ? "w-24" : "w-96") : "w-12") + " flex-shrink-0"}></div> }
{windowComponent}
</div>
</div>;
Expand Down

0 comments on commit 3e99ee0

Please sign in to comment.