Skip to content

Commit

Permalink
v8.1.15: fix for #320, #321
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Jul 11, 2024
1 parent bc2df45 commit aa2adee
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
// props.setFullScreen(true);
}
},
// renderAspect: "1/1",
// renderBackend: "webgl",
// imageRendering: "smooth",
});
});

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.14",
"version": "8.1.15",
"description": "Full-featured DOS player with multiple emulator backends",
"type": "module",
"keywords": [
Expand Down
31 changes: 29 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import "./index.css";

import { Provider } from "react-redux";
import { Ui } from "./ui";
import { dosSlice } from "./store/dos";
import { dosSlice, RenderAspect } from "./store/dos";
import { initEmulators } from "./store/dos";
// eslint-disable-next-line
import { uiSlice } from "./store/ui";
import { i18nSlice } from "./i18n";
import { getCache } from "./host/lcache";
import { loadBundleFromConfg, loadBundleFromUrl } from "./load";

import { DosOptions, DosProps, DosFn } from "./public/types";
import { DosOptions, DosProps, DosFn, ImageRendering, RenderBackend } from "./public/types";
import { browserSetFullScreen } from "./host/fullscreen";
import { NonSerializableStore, Store, makeNonSerializableStore, makeStore, postJsDosEvent } from "./store";
import { authSlice } from "./store/auth";
Expand Down Expand Up @@ -122,6 +122,18 @@ export const Dos: DosFn = (element: HTMLDivElement,
store.dispatch(uiSlice.actions.kiosk(kiosk));
}

function setImageRendering(imageRendering: ImageRendering) {
store.dispatch(dosSlice.actions.imageRendering(imageRendering));
}

function setRenderBackend(backend: RenderBackend) {
store.dispatch(dosSlice.actions.renderBackend(backend));
}

function setRenderAspect(aspect: RenderAspect) {
store.dispatch(dosSlice.actions.renderAspect(aspect));
}

if (options.theme) {
setTheme(options.theme);
}
Expand Down Expand Up @@ -174,6 +186,18 @@ export const Dos: DosFn = (element: HTMLDivElement,
setKiosk(options.kiosk);
}

if (options.imageRendering !== undefined) {
setImageRendering(options.imageRendering);
}

if (options.renderBackend !== undefined) {
setRenderBackend(options.renderBackend);
}

if (options.renderAspect !== undefined) {
setRenderAspect(options.renderAspect);
}

render(
<Provider store={store}>
{<Ui /> as any}
Expand All @@ -195,6 +219,9 @@ export const Dos: DosFn = (element: HTMLDivElement,
setFullScreen,
setAutoStart,
setKiosk,
setImageRendering,
setRenderBackend,
setRenderAspect,
};
};

Expand Down
9 changes: 9 additions & 0 deletions src/public/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export type DosEvent = "emu-ready" | "ci-ready" | "bnd-play";
export type ImageRendering = "pixelated" | "smooth";
export type RenderBackend = "webgl" | "canvas";
export type RenderAspect = "AsIs" | "1/1" | "5/4" | "4/3" | "16/10" | "16/9" | "Fit";

export interface DosOptions {
url: string,
Expand Down Expand Up @@ -27,6 +30,9 @@ export interface DosOptions {
loginUrl: string,
autoStart: boolean,
kiosk: boolean,
imageRendering: ImageRendering,
renderBackend: RenderBackend,
renderAspect: RenderAspect,
}

export interface DosProps {
Expand All @@ -43,6 +49,9 @@ export interface DosProps {
setFullScreen(fullScreen: boolean): void;
setAutoStart(autoStart: boolean): void;
setKiosk(kiosk: boolean): void;
setImageRendering(rendering: ImageRendering): void;
setRenderBackend(backend: RenderBackend): void;
setRenderAspect(aspect: RenderAspect): void;
}

export type DosFn = (element: HTMLDivElement, options: Partial<DosOptions>) => DosProps;
Expand Down

0 comments on commit aa2adee

Please sign in to comment.