From f71885f89e8e91732a61922b68d6556f527361b3 Mon Sep 17 00:00:00 2001 From: Dakedres Date: Mon, 22 Apr 2024 13:56:41 -0600 Subject: [PATCH] More cleanup lol --- src/hidden_Instance.js | 152 ----------------------------------------- 1 file changed, 152 deletions(-) delete mode 100755 src/hidden_Instance.js diff --git a/src/hidden_Instance.js b/src/hidden_Instance.js deleted file mode 100755 index 7e9ce4f..0000000 --- a/src/hidden_Instance.js +++ /dev/null @@ -1,152 +0,0 @@ -const Console = require('./Console') -const ModPackage = require('./ModPackage') -const handleIframe = require('./util/handleIframe'), - gzip = require('./util/gzip'), - promisify = require('./util/promisify') - -const openAsync = promisify($file.open), - { Buffer } = le._apps.abnt - -class Instance { - constructor(app, modPath) { - let self = this, - bundleDir = app.bundle.for('/import/') - - this.consoleWindow - this.window - this.mod - this.closed = false - this.app = app - this.assets = new Map() - this.import = new Proxy(this.assets, { - get(target, prop) { - console.log(`LOADING "${prop}"`) - - if( !target.has(prop) && bundleDir.access(prop) ) { - target.set(prop, bundleDir.openSync(prop, 'URL') ) - } - - return target.get(prop) - } - }) - this.arguments = [] - this.console = new Console() - - console.log('INSTANCE:', this) - - // Post init - - this.package = this.loadPackage(modPath) - .then(mod => { - this.mod = mod - console.log('woo window,', this.window) - - return mod - }) - - this.package.catch(console.error) - - this.openMain() - } - - async loadPackage(path) { - const buffer = await openAsync(path, 'ArrayBuffer').then(ab => Buffer.from(ab)), - mod = await ModPackage.unpack(buffer) - - return mod - } - - openMain() { - // We'll need to shove it in a fragment to force it to load while hidden - const iframe = document.createElement('iframe'), - self = this - - const options = { - title: 'Xash3D', - // url: "data:text/plain,", - // icon: app.icon, - // Windows93 adds to these to compensate for title height and such, - // but we want it to match the canvas resolution. - // We want 647 x 508 on the window element - width: 640 + 7 - 9, - height: 480 + 28 - 30, - menu: [ - { - name: 'Game', - items: [ - { - name: 'Open console', - action: function() { - self.openConsole() - } - } - ] - } - ], - onready() { - console.log('this:', this) - this.el.body.appendChild(iframe) - }, - onclose() { - self.consoleWindow?.close() - self.closed = true - - app.cleanInstances() - } - } - - iframe.style.display = 'none' - iframe.src = this.app.bundle.openSync('./main.html', 'URL') - - iframe.onload = () => { - iframe.contentWindow.instance = self - iframe.contentWindow.onmessage = event => { - console.log(event) - - if(event.data == 'loadingDone') - self.window = $window(options) - iframe.style.display = 'initial' - } - - handleIframe(iframe, '/import/') - console.log('loadd') - } - - document.body.append(iframe) - console.log(iframe) - } - - openConsole() { - const self = this - - if(this.consoleWindow) - // Put focus on the window instead - this.focusConsole() - - const options = { - title: 'Xash Console', - bodyClass: 'ui_terminal xash3d_terminal', - onready() { - self.console.attachTo(self.consoleWindow) - self.focusConsole() - }, - onclose() { - self.console.unattach() - } - } - - this.consoleWindow = $window(options) - } - - focusConsole() { - this.consoleWindow.el.header.click() - } - - kill() { - this.window?.close() - this.consoleWindow?.close() - delete this.assets // pls my memory - } -} - -module.exports = Instance \ No newline at end of file