From 6189890e34a8b8ff7ec93bb2676b310f2d83f942 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Thu, 12 Sep 2024 00:28:57 -0700 Subject: [PATCH 1/2] Add functionality to load code from a query param --- src/app/components/editor/editor.component.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/components/editor/editor.component.ts b/src/app/components/editor/editor.component.ts index 18db93f..fef7691 100644 --- a/src/app/components/editor/editor.component.ts +++ b/src/app/components/editor/editor.component.ts @@ -1,4 +1,5 @@ import { Component, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; import { EditorView } from 'codemirror'; import { bracketMatching, @@ -63,7 +64,7 @@ export class EditorComponent { @ViewChild('editor') private editor!: CodeEditor; - constructor(private executor: ExecutorService) { + constructor(private executor: ExecutorService, private route: ActivatedRoute) { const noDotted = EditorView.theme({ '&.cm-editor.cm-focused': { outline: 'none', @@ -82,6 +83,23 @@ export class EditorComponent { flexGrow: 1, }, }); + + // Check for URL parameter and decode if present + this.route.queryParams.subscribe(params => { + const encodedContent = params['code']; + if (encodedContent) { + const decodedContent = atob(encodedContent); + this.content = `/world/New() + main() + ..() + eval("") + shutdown() + +/proc/main() + ${decodedContent}` + } + }); + const darkMode = EditorView.theme({}, { dark: true }); const runCodeEffect = StateEffect.define(); @@ -156,5 +174,6 @@ export class EditorComponent { [controlPanel], [runCodeField], ]; + } } From 11653af874b87411916ffc7cb4955996a2491ae1 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Thu, 12 Sep 2024 00:39:49 -0700 Subject: [PATCH 2/2] Load the first downloaded version by default --- src/vm/byond.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vm/byond.service.ts b/src/vm/byond.service.ts index 88b67ee..2f02259 100644 --- a/src/vm/byond.service.ts +++ b/src/vm/byond.service.ts @@ -131,6 +131,10 @@ export class ByondService { void this.lock.run(async () => { for await (const version of (await this.getByondFolder()).keys()) { this._versions.set(version, VersionStatus.Fetched); + // If this is the first version in the list, load it + if (this._activeVersion == null) { + await this.load(version, true); + } } }); void this.lock.run(() =>