summaryrefslogtreecommitdiff
path: root/src/desktop/index.tsx
diff options
context:
space:
mode:
authordarkuss <darkussdelta@gmail.com>2026-08-22 01:58:37 +0200
committerdarkuss <darkussdelta@gmail.com>2026-08-22 01:58:37 +0200
commit8f32fd58cafe677c07d9ed9fff84f6e255156d37 (patch)
treea5de06ffb2c0a8b878c8a563ec8cee692efc98ac /src/desktop/index.tsx
parent5ac62cc1a4d9a5f50ea26d5bc1afb0fbf95da23c (diff)
holy shit i'm finally done
Diffstat (limited to 'src/desktop/index.tsx')
-rw-r--r--src/desktop/index.tsx123
1 files changed, 90 insertions, 33 deletions
diff --git a/src/desktop/index.tsx b/src/desktop/index.tsx
index 021d3a0..b47422d 100644
--- a/src/desktop/index.tsx
+++ b/src/desktop/index.tsx
@@ -1,43 +1,100 @@
+import "$/apps" // registers all of the apps;
import { useRef } from "preact/hooks"
-import { Edit } from "./apps/edit"
import { Window } from "./window"
-import { Music } from "./apps/music";
+import { FILE_REGISTRY } from "./files";
+import { Source } from "$/apps/source";
+import { App } from "$/apps";
+import { createModel, Signal, signal } from "@preact/signals";
+import { MutableValue } from "$/util";
+import { File } from "./file";
+import { StartMenu } from "./start";
+
+export type Task = {
+ app: App,
+ source: Signal<Source>,
+ window: {
+ minimized: Signal<boolean>,
+ maximized: Signal<boolean>
+ width?: string | number;
+ height?: string | number;
+ position?: {
+ x?: string | number;
+ y?: string | number;
+ },
+ z: Signal<number>;
+ }
+ title: Signal<string | undefined>,
+ id: number;
+ contentReady: Signal<boolean>,
+ sizingFinished: Signal<boolean>
+}
+
+const TaskManagerModel = createModel(() => {
+ const tasks: Signal<MutableValue<Task[]>> = signal(new MutableValue([]))
+
+ return {
+ tasks,
+ close(currentTask: Task) {
+ tasks.value = tasks.value.deriveNew(self => {
+ const idx = self.findIndex(task => {
+ return currentTask === task
+ })
+ self.splice(idx, 1);
+ return self
+ })
+ },
+ focusWindow(currentTask: Task) {
+ const t = tasks.value.value;
+ const currentTaskZ = currentTask.window.z.value;
+
+ for (const task of t) {
+ if (task === currentTask) {
+ task.window.z.value = t.length - 1
+ } else if (task.window.z.value > currentTaskZ) {
+ task.window.z.value = task.window.z.value - 1
+ }
+ }
+ },
+ add(task: Task) {
+ tasks.value = tasks.value.deriveNew(self => {
+ self.push(task)
+ return self
+ })
+ }
+ }
+})
+export const taskManager = new TaskManagerModel();
+
+let taskCounter = 0;
+export function getTaskId(): number {
+ return taskCounter++;
+}
export function Desktop() {
const ref = useRef(null);
+
return <div id="desktop" ref={ref}>
- <div class="icon_grid">
- <div></div>
- <div></div>
- <div></div>
- <div></div>
- <div></div>
+ <div class="icon_list">
+ { FILE_REGISTRY.map(file => <File file={file} />)}
</div>
- <Window title="README.txt" width="30vw" height={300} x={40} y={40} desktop={ref}>
- <Edit>
- Fine release by Sunnexo 2026&#10;
- &#10;
- Tracklist:&#10;
- 1. Internet Exploder&#10;
- 2. Netpunk (feat. Kasane Teto)&#10;
- 3. Free Download&#10;
- 4. I am not a Robot&#10;
- 5. Content&#10;
- 6. Keygen&#10;
- 7. Base64&#10;
- 8. Readme (feat. Kasane Teto)&#10;
- 9. Symlink&#10;
- 10. Memory&#10;
-
- An album about borrowing software forever.&#10;
-
- A clumsy robot forgets about their girlfriend's anniversary, scrambling to find something to do for the date, eventually concluding they should watch a movie. Of course the movie is in high demand, so the tickets have sold out. Ultimately they resort to piracy, and things spiral out of control... &#10;
- </Edit>
- </Window>
- <Window title="Stream Netpunk" desktop={ref}>
- <Music />
- </Window>
-
+ { taskManager.tasks.value.value.map(task => {
+ const App = task.app;
+ return <Window
+ key={task.id}
+ task={task}
+ desktop={ref}
+ onFocus={taskManager.focusWindow}
+ onClose={taskManager.close}
+ >
+ <App
+ title={task.title}
+ source={task.source}
+ contentReady={task.contentReady}
+ sizingFinished={task.sizingFinished}
+ />
+ </Window>
+ })}
+ <StartMenu />
<img id="netpunk" src="/assets/netpunk.png" />
</div>
}