2022-08-22 13:14:04 +00:00
|
|
|
import "@fontsource/material-icons";
|
2022-06-27 00:17:22 +00:00
|
|
|
import App from "App.vue";
|
|
|
|
import projInfo from "data/projInfo.json";
|
|
|
|
import "game/notifications";
|
2023-05-17 04:38:31 +00:00
|
|
|
import state from "game/state";
|
2022-06-27 00:17:22 +00:00
|
|
|
import { load } from "util/save";
|
2022-06-26 20:22:22 +00:00
|
|
|
import { useRegisterSW } from "virtual:pwa-register/vue";
|
2022-06-27 00:17:22 +00:00
|
|
|
import type { App as VueApp } from "vue";
|
|
|
|
import { createApp, nextTick } from "vue";
|
2022-06-26 20:22:22 +00:00
|
|
|
import { useToast } from "vue-toastification";
|
2022-01-14 04:25:47 +00:00
|
|
|
|
|
|
|
declare global {
|
2022-07-10 03:09:25 +00:00
|
|
|
/**
|
2022-07-10 05:43:52 +00:00
|
|
|
* Augment the window object so the vue app and project info can be accessed from the console.
|
2022-07-10 03:09:25 +00:00
|
|
|
*/
|
2022-01-14 04:25:47 +00:00
|
|
|
interface Window {
|
|
|
|
vue: VueApp;
|
2022-03-03 02:12:56 +00:00
|
|
|
projInfo: typeof projInfo;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
2022-07-10 03:02:44 +00:00
|
|
|
|
2022-07-10 05:43:52 +00:00
|
|
|
/** Fix for typedoc treating import functions as taking AssertOptions instead of GlobOptions. */
|
2022-07-10 03:02:44 +00:00
|
|
|
interface AssertOptions {
|
|
|
|
as: string;
|
|
|
|
}
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-17 04:30:54 +00:00
|
|
|
|
2023-05-17 04:38:31 +00:00
|
|
|
const error = console.error;
|
|
|
|
console.error = function (...args) {
|
|
|
|
if (import.meta.env.DEV) {
|
|
|
|
state.errors.push(new Error(args[0], { cause: args[1] }));
|
|
|
|
}
|
|
|
|
error(...args);
|
|
|
|
};
|
|
|
|
|
2023-05-18 01:05:37 +00:00
|
|
|
window.onerror = function (event, source, lineno, colno, err) {
|
|
|
|
state.errors.push(err instanceof Error ? err : new Error(JSON.stringify(err)));
|
|
|
|
error(err);
|
2023-05-17 04:38:31 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
window.onunhandledrejection = function (event) {
|
|
|
|
state.errors.push(
|
|
|
|
event.reason instanceof Error ? event.reason : new Error(JSON.stringify(event.reason))
|
|
|
|
);
|
2023-05-18 01:05:37 +00:00
|
|
|
error(event.reason);
|
2023-05-17 04:38:31 +00:00
|
|
|
};
|
|
|
|
|
2022-07-10 03:09:25 +00:00
|
|
|
document.title = projInfo.title;
|
|
|
|
window.projInfo = projInfo;
|
|
|
|
if (projInfo.id === "") {
|
2023-05-17 04:38:31 +00:00
|
|
|
console.error(
|
|
|
|
"Project ID is empty!",
|
|
|
|
"Please select a unique ID for this project in /src/data/projInfo.json"
|
2023-03-24 01:22:03 +00:00
|
|
|
);
|
2022-07-10 03:09:25 +00:00
|
|
|
}
|
|
|
|
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-17 04:30:54 +00:00
|
|
|
requestAnimationFrame(async () => {
|
2022-02-27 19:49:34 +00:00
|
|
|
console.log(
|
2022-02-27 20:24:48 +00:00
|
|
|
"%cMade in Profectus%c\nLearn more at www.moddingtree.com",
|
2022-02-27 19:49:34 +00:00
|
|
|
"font-weight: bold; font-size: 24px; color: #A3BE8C; background: #2E3440; padding: 4px 8px; border-radius: 8px;",
|
|
|
|
"padding: 4px;"
|
|
|
|
);
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-17 04:30:54 +00:00
|
|
|
await load();
|
2022-12-06 04:53:46 +00:00
|
|
|
const { globalBus } = await import("./game/events");
|
|
|
|
const { startGameLoop } = await import("./game/gameLoop");
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-17 04:30:54 +00:00
|
|
|
|
|
|
|
// Create Vue
|
2022-03-04 03:41:59 +00:00
|
|
|
const vue = (window.vue = createApp(App));
|
2023-05-17 04:38:31 +00:00
|
|
|
vue.config.errorHandler = function (err, instance, info) {
|
|
|
|
console.error(err, info, instance);
|
|
|
|
};
|
2022-01-14 04:25:47 +00:00
|
|
|
globalBus.emit("setupVue", vue);
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-17 04:30:54 +00:00
|
|
|
vue.mount("#app");
|
|
|
|
|
2022-06-26 20:22:22 +00:00
|
|
|
// Setup PWA update prompt
|
|
|
|
nextTick(() => {
|
|
|
|
const toast = useToast();
|
|
|
|
const { updateServiceWorker } = useRegisterSW({
|
|
|
|
onNeedRefresh() {
|
2022-12-10 06:47:11 +00:00
|
|
|
toast.info("New content available, click here to update.", {
|
2022-06-26 20:22:22 +00:00
|
|
|
timeout: false,
|
|
|
|
closeOnClick: false,
|
|
|
|
draggable: false,
|
|
|
|
icon: {
|
|
|
|
iconClass: "material-icons",
|
|
|
|
iconChildren: "refresh",
|
|
|
|
iconTag: "i"
|
|
|
|
},
|
|
|
|
rtl: false,
|
|
|
|
onClick() {
|
|
|
|
updateServiceWorker();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onOfflineReady() {
|
|
|
|
toast.info("App ready to work offline");
|
|
|
|
},
|
|
|
|
onRegisterError: console.warn,
|
|
|
|
onRegistered(r) {
|
|
|
|
if (r) {
|
2022-12-09 01:31:36 +00:00
|
|
|
// https://stackoverflow.com/questions/65500916/typeerror-failed-to-execute-update-on-serviceworkerregistration-illegal-in
|
|
|
|
setInterval(() => r.update(), 60 * 60 * 1000);
|
2022-06-26 20:22:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-01-14 04:25:47 +00:00
|
|
|
startGameLoop();
|
First pass at typescript support
Oh man did this end up requiring a *ton* of other work as well.
There's still a few typing issues I still can't quite work out,
and others I'd like to improve when I have time. In fact, this version
doesn't even really work, it has a stack overflow error caused by
a tooltip for some reason have a tree inside it, which in turn has
another tooltip, etc. There's also 17 errors that I *really* feel like
shouldn't be there, but they are, and 113 warnings - mostly using !
to assert that things are non-null. Lots of work left to do, to sum up.
The reason I'm committing this now is because I really need to get to
work on my game jam, and since it won't use a tree or really many of
TMT-X's features, I can get away with using a broken engine :)
2021-08-17 04:30:54 +00:00
|
|
|
});
|