Added ClassiCube

This commit is contained in:
Dustin Brett
2022-11-19 14:28:41 -08:00
parent 678e438ffb
commit e1f607d3a4
21 changed files with 107943 additions and 0 deletions

1
.gitignore vendored
View File

@@ -21,6 +21,7 @@ public/Users/Public/**
!public/Users/Public/Start Menu/Emulators
!public/Users/Public/Start Menu/Emulators/*.url
!public/Users/Public/Start Menu/Games
!public/Users/Public/Start Menu/Games/ClassiCube.url
!public/Users/Public/Start Menu/Games/Space Cadet.url
!public/Users/Public/Videos
!public/Users/Public/Videos/Make an OS with ReactJS & Next.js

View File

@@ -0,0 +1,13 @@
import styled from "styled-components";
const StyledClassiCube = styled.div`
height: ${({ theme }) => `calc(100% - ${theme.sizes.titleBar.height}px)`};
width: 100%;
canvas {
height: 100%;
width: 100%;
}
`;
export default StyledClassiCube;

View File

@@ -0,0 +1,16 @@
import AppContainer from "components/apps/AppContainer";
import StyledClassiCube from "components/apps/ClassiCube/StyledClassiCube";
import useClassiCube from "components/apps/ClassiCube/useClassiCube";
import type { ComponentProcessProps } from "components/system/Apps/RenderComponent";
const ClassiCube: FC<ComponentProcessProps> = ({ id }) => (
<AppContainer
StyledComponent={StyledClassiCube}
id={id}
useHook={useClassiCube}
>
<canvas />
</AppContainer>
);
export default ClassiCube;

View File

@@ -0,0 +1,61 @@
import { useProcesses } from "contexts/process";
import { useCallback, useEffect } from "react";
import { TRANSITIONS_IN_MILLISECONDS } from "utils/constants";
import { loadFiles } from "utils/functions";
declare global {
interface Window {
CCModule: {
arguments: string[];
canvas: HTMLCanvasElement;
postRun: (() => void)[];
print: () => void;
setStatus: () => void;
};
}
}
const useClassiCube = (
id: string,
_url: string,
containerRef: React.MutableRefObject<HTMLDivElement | null>,
setLoading: React.Dispatch<React.SetStateAction<boolean>>
): void => {
const { processes: { [id]: process } = {} } = useProcesses();
const { libs } = process || {};
const getCanvas = useCallback(
() =>
(containerRef.current as HTMLElement)?.querySelector(
"canvas"
) as HTMLCanvasElement,
[containerRef]
);
useEffect(() => {
if (window.CCModule) return;
setTimeout(() => {
const canvas = getCanvas();
window.CCModule = {
arguments: ["Singleplayer"],
canvas,
postRun: [
() => setLoading(false),
() => {
const { width, height } = canvas.getBoundingClientRect() || {};
canvas.width = width;
canvas.height = height;
},
],
print: console.info,
setStatus: console.info,
};
loadFiles(libs);
}, TRANSITIONS_IN_MILLISECONDS.WINDOW);
}, [getCanvas, libs, setLoading]);
};
export default useClassiCube;

View File

@@ -30,6 +30,7 @@ const KEYVAL_STORE_NAME = "keyval";
const KEYVAL_DB = `${KEYVAL_STORE_NAME}-store`;
const KNOWN_IDB_DBS = [
"/classicube",
"/data/saves",
"ejs-bios",
"ejs-roms",

View File

@@ -32,6 +32,18 @@ const directory: Processes = {
icon: "/System/Icons/chromium.webp",
title: "Browser",
},
ClassiCube: {
Component: dynamic(() => import("components/apps/ClassiCube")),
allowResizing: false,
backgroundColor: "#201E20",
defaultSize: {
height: 420,
width: 700,
},
icon: "/System/Icons/classicube.webp",
libs: ["/Program Files/ClassiCube/ClassiCube.js"],
title: "ClassiCube",
},
DXBall: {
Component: dynamic(() => import("components/apps/DX-Ball")),
backgroundColor: "#000",

View File

@@ -73,6 +73,7 @@ This project is greatly augmented by code from the open source community. Thank
- [jspaint](https://github.com/1j01/jspaint)
- [Print.js](https://github.com/crabbly/print.js)
- [Kiwi IRC](https://github.com/kiwiirc/kiwiirc)
- [ClassiCube](https://github.com/UnknownShadow200/ClassiCube)
## Services

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,3 @@
[InternetShortcut]
BaseURL=ClassiCube
Comment=Minecraft Classic 0.30