127 lines
2.3 KiB
JavaScript
127 lines
2.3 KiB
JavaScript
|
|
/*
|
||
|
|
|
||
|
|
Copyright (c) 2020, 2023, The Unified Company.
|
||
|
|
|
||
|
|
This code is part of Unify.
|
||
|
|
|
||
|
|
This program is free software; you can redistribute it and/or modify
|
||
|
|
it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE,
|
||
|
|
as published by the Free Software Foundation.
|
||
|
|
See the GNU AFFERO GENERAL PUBLIC LICENSE, for more details.
|
||
|
|
|
||
|
|
https://unifyjs.org
|
||
|
|
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
import applicationManager from './applicationManager.js';
|
||
|
|
|
||
|
|
import timer from './timer.js';
|
||
|
|
|
||
|
|
import tools from '../unify/tools.js';
|
||
|
|
|
||
|
|
import vector2 from '../unify/math/vector2.js';
|
||
|
|
|
||
|
|
document.states = new Array();
|
||
|
|
|
||
|
|
|
||
|
|
window.addEventListener('popstate', function( event ) {
|
||
|
|
|
||
|
|
console.log( "popstate tiggered", event, event.state.id );
|
||
|
|
|
||
|
|
var stateMachine = document.stateMachine;
|
||
|
|
|
||
|
|
console.log( stateMachine );
|
||
|
|
|
||
|
|
var state = stateMachine.getState( event.state.id );
|
||
|
|
|
||
|
|
console.log( "stateMachine.getState", state, state.id );
|
||
|
|
|
||
|
|
state.triggerEvents();
|
||
|
|
|
||
|
|
//var table = state.table;
|
||
|
|
|
||
|
|
//table.id = state.id;
|
||
|
|
|
||
|
|
//table.sync( false, true, false );
|
||
|
|
|
||
|
|
|
||
|
|
}, false);
|
||
|
|
|
||
|
|
|
||
|
|
// Set globals
|
||
|
|
document.globalZIndex = 2000;
|
||
|
|
|
||
|
|
document.animationID = 0;
|
||
|
|
|
||
|
|
document.keyframeID = 0;
|
||
|
|
|
||
|
|
document.timer = new timer();
|
||
|
|
|
||
|
|
|
||
|
|
if( !document.extendMap ) {
|
||
|
|
|
||
|
|
document.extendMap = new Array();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
function main() {
|
||
|
|
|
||
|
|
document.timer.lap("start");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//createGlobalMouseEventListener() {
|
||
|
|
|
||
|
|
document.mouse = new vector2(0,0);
|
||
|
|
|
||
|
|
document.mouseVelocity = new vector2(0,0);
|
||
|
|
|
||
|
|
var lastMouseUpdate = Date.now();
|
||
|
|
|
||
|
|
var previousMouse = new vector2(0,0);
|
||
|
|
|
||
|
|
document.body.addEventListener('mousemove', function( bodyEvent ) {
|
||
|
|
|
||
|
|
if( document.mouse ) {
|
||
|
|
|
||
|
|
previousMouse = document.mouse;
|
||
|
|
|
||
|
|
document.mouse = new vector2( bodyEvent.clientX, bodyEvent.clientY );
|
||
|
|
|
||
|
|
var delta = Date.now() - lastMouseUpdate;
|
||
|
|
|
||
|
|
var differenceX = document.mouse.x - previousMouse.x;
|
||
|
|
|
||
|
|
var differenceY = document.mouse.y - previousMouse.y;
|
||
|
|
|
||
|
|
|
||
|
|
document.mouseVelocity = new vector2( differenceX / delta, differenceY / delta );
|
||
|
|
|
||
|
|
|
||
|
|
lastMouseUpdate = Date.now();
|
||
|
|
|
||
|
|
} else {
|
||
|
|
|
||
|
|
document.mouse = new vector2( bodyEvent.screenX, bodyEvent.screenY );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
//}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
var applications = new applicationManager();
|
||
|
|
|
||
|
|
applications.start();
|
||
|
|
|
||
|
|
document.launcher = applications;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
document.onload = main();
|
||
|
|
|