App rename + macOS Build Fixes

loading-screen
Noah 2021-05-02 12:06:34 -07:00
parent f5d814283c
commit 9b80d38c3e
8 changed files with 40 additions and 36 deletions

View File

@ -43,6 +43,9 @@ The bootstrap script will take care of the rest:
It should work on Fedora-likes, Debian-likes and macOS all the same.
It even runs on the Pine64 Pinephone (ARM64) with Mobian!
MacOS is expected to have [homebrew](https://brew.sh) installed.
MP3 support issues? [See here](https://github.com/veandco/go-sdl2/issues/299#issuecomment-611681191).
**To do:** the most important repositories, like the game itself, are
also mirrored on GitHub. Other supporting repos need mirroring too, or
otherwise, full source tarballs (the result of bootstrap.py) will be

View File

@ -72,13 +72,13 @@ def install_deps():
# Fedora-like.
if shell("rpm -q {}".format(' '.join(dep_fedora))) != 0:
must_shell("sudo dnf install {}".format(' '.join(dep_fedora)))
elif shell("which brew") == 0:
# MacOS, as Catalina has an apt command now??
must_shell("brew install {}".format(' '.join(dep_macos)))
elif shell("which apt") == 0:
# Debian-like.
if shell("dpkg-query -l {}".format(' '.join(dep_debian))) != 0:
must_shell("sudo apt update && sudo apt install {}".format(' '.join(dep_debian)))
elif shell("which brew") == 0:
# MacOS
must_shell("brew install {}".format(' '.join(dep_macos)))
else:
print("Warning: didn't detect your package manager to install SDL2 and other dependencies")

View File

@ -8,3 +8,7 @@ import "syscall/js"
func OpenURL(url string) {
js.Global().Get("window").Call("open", url)
}
func OpenLocalURL(url string) {
OpenURL(url)
}

View File

@ -5,7 +5,7 @@
VERSION=`grep -e 'Version =' ../../pkg/branding/branding.go | head -n 1 | cut -d '"' -f 2`
INSTALL_ROOT="/opt/sketchy-maze"
APP_NAME="Project Doodle.app"
APP_NAME="Sketchy Maze.app"
APP_FOLDER="../../etc/macos/$APP_NAME"
APP_CONTENTS="$APP_NAME/Contents"
@ -29,4 +29,4 @@ mkdir -p "$APP_CONTENTS/Resources"
# Copy binaries to /MacOS
cp doodle doodad "$APP_CONTENTS/MacOS/"
cp *.* "$APP_CONTENTS/Resources/"
cp -r *.* rtp guidebook "$APP_CONTENTS/Resources/"

View File

@ -27,7 +27,10 @@
}
if (!global.fs && global.require) {
global.fs = require("fs");
const fs = require("fs");
if (Object.keys(fs) !== 0) {
global.fs = fs;
}
}
const enosys = () => {
@ -172,37 +175,19 @@
const storeValue = (addr, v) => {
const nanHead = 0x7FF80000;
if (typeof v === "number") {
if (typeof v === "number" && v !== 0) {
if (isNaN(v)) {
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 0, true);
return;
}
if (v === 0) {
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 1, true);
return;
}
this.mem.setFloat64(addr, v, true);
return;
}
switch (v) {
case undefined:
this.mem.setFloat64(addr, 0, true);
return;
case null:
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 2, true);
return;
case true:
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 3, true);
return;
case false:
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 4, true);
return;
if (v === undefined) {
this.mem.setFloat64(addr, 0, true);
return;
}
let id = this._ids.get(v);
@ -216,8 +201,13 @@
this._ids.set(v, id);
}
this._goRefCounts[id]++;
let typeFlag = 1;
let typeFlag = 0;
switch (typeof v) {
case "object":
if (v !== null) {
typeFlag = 1;
}
break;
case "string":
typeFlag = 2;
break;
@ -440,14 +430,14 @@
// func valueInstanceOf(v ref, t ref) bool
"syscall/js.valueInstanceOf": (sp) => {
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16));
this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);
},
// func copyBytesToGo(dst []byte, src ref) (int, bool)
"syscall/js.copyBytesToGo": (sp) => {
const dst = loadSlice(sp + 8);
const src = loadValue(sp + 32);
if (!(src instanceof Uint8Array)) {
if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
this.mem.setUint8(sp + 48, 0);
return;
}
@ -461,7 +451,7 @@
"syscall/js.copyBytesToJS": (sp) => {
const dst = loadValue(sp + 8);
const src = loadSlice(sp + 16);
if (!(dst instanceof Uint8Array)) {
if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
this.mem.setUint8(sp + 48, 0);
return;
}
@ -490,10 +480,17 @@
global,
this,
];
this._goRefCounts = []; // number of references that Go has to a JS value, indexed by reference id
this._ids = new Map(); // mapping from JS values to reference ids
this._idPool = []; // unused ids that have been garbage collected
this.exited = false; // whether the Go program has exited
this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
this._ids = new Map([ // mapping from JS values to reference ids
[0, 1],
[null, 2],
[true, 3],
[false, 4],
[global, 5],
[this, 6],
]);
this._idPool = []; // unused ids that have been garbage collected
this.exited = false; // whether the Go program has exited
// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
let offset = 4096;