Commit 03b40af7 authored by Christian Winter's avatar Christian Winter

wip

parent d78bda06
......@@ -399,3 +399,40 @@ table#renderSettings {
font-size: 14pt;
font-family: 'Oswald', sans-serif;
}
.view{
margin: 0px;
padding: 0px;
position: absolute;
border: 1px solid grey;
}
#prefabEditor{
position: absolute;
left: 250px;
height: 50%;
}
#prefabList{
position: absolute;
left: 250px;
height: 50%;
}
\ No newline at end of file
......@@ -2,14 +2,22 @@
constructor() {
console.log("Application.constructor()");
this.currentState; // Drawing, EditingPrefab
this.currentFocus;
this.currentView;
this.views = [];
}
start() {
/*
this.createGUIFromScratch();
return;
// */
this.initializeClasses();
this.views = [];
let viewNum = 1;
for (let i = 0; i < viewNum; ++i)
for (let i = 0; i < viewNum; ++i)
this.views.push(new View());
this.currentView = this.views[this.views.length - 1];
......@@ -42,7 +50,6 @@
}
this.redrawAllViews();
}
initializeClasses() {
......@@ -104,11 +111,18 @@
// TODO magic
GUI.stats.style.right = 280;
GUI.stats.style.top = GUI.menubar.offsetHeight + 25;
this.redrawAllViews();
}
focus(focusable) {
this.currentFocus = focusable;
}
setView(view) {
if (view == null)
if (view == null) {
this.currentView = null;
return;
}
if (this.currentView)
this.currentView.deactivate();
......@@ -127,4 +141,45 @@
for (let view of this.views)
view.renderer.setQualitySetting(setting);
}
createGUIFromScratch() {
let body = document.body;
while (body.firstChild) {
body.removeChild(body.firstChild);
}
// left menu
let div = document.createElement('div');
div.setAttribute("class", "view");
div.style.left = 0;
div.style.width = 250;
div.style.height = window.innerHeight;
body.appendChild(div);
// right menu
div = document.createElement('div');
div.setAttribute("class", "view");
div.style.right = 0;
div.style.width = 250;
div.style.height = window.innerHeight;
body.appendChild(div);
// prefab editor
div = document.createElement('div');
div.setAttribute("class", "view");
div.style.left = 250;
div.style.width = 250;
div.style.height = window.innerHeight / 2;
body.appendChild(div);
// prefabs list
div = document.createElement('div');
div.setAttribute("class", "view");
div.style.top = window.innerHeight / 2;
div.style.left = 250;
div.style.width = 250;
div.style.height = window.innerHeight / 2;
body.appendChild(div);
}
}
\ No newline at end of file
......@@ -420,12 +420,14 @@
mouseEnter(e) {
//console.log(this._getMousePos(e));
Application.setView(this);
Application.focus(this);
}
mouseExit(e) {
//console.log(this._getMousePos(e));
Application.setView(null);
Application.focus(null);
}
_getMousePos(e) {
......
......@@ -32,20 +32,23 @@ class Input {
}
Logic.currentState.keyDown(e.keyCode);
Application.currentView.keyDown(e.keyCode);
if (Application.currentFocus)
Application.currentFocus.keyDown(e.keyCode);
// dont prevent default
if (Application.currentView && !(
e.keyCode == Key.F12
|| (e.keyCode == Key.L && Input.isKeyDown(Key.Control))
|| e.keyCode == Key.F6
|| e.keyCode == Key.F5
|| e.keyCode != Key.Tab
)) {
console.log("prevent")
e.preventDefault();
if (e.keyCode == Key.Enter) {
Application.currentView.canvas.focus();
}
if (e.keyCode != Key.F12
&& !(e.keyCode == Key.L && Input.isKeyDown(Key.Control))
&& e.keyCode != Key.F6
&& e.keyCode != Key.F5
&& e.keyCode == Key.Tab
)
e.preventDefault();
// prevent default for these keys
if (
e.keyCode == Key.D && this.isKeyDown(Key.Control)
|| e.keyCode == Key.Alt
......@@ -64,7 +67,8 @@ class Input {
switch (e.keyCode) {
default:
Logic.currentState.keyUp(e.keyCode);
Application.currentView.keyUp(e.keyCode);
if (Application.currentFocus)
Application.currentFocus.keyUp(e.keyCode);
break;
}
......@@ -78,7 +82,8 @@ class Input {
for (let keycode in Input.downKeys) {
if (Input.downKeys[keycode] == true) {
Logic.currentState.keyUp(+keycode);
Application.currentView.keyUp(+keycode);
if (Application.currentFocus)
Application.currentFocus.keyUp(+keycode);
}
}
Input.downKeys = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment