Removed modes, merged with modules.

This commit is contained in:
Devine Lu Linvega
2016-12-19 16:24:39 -07:00
parent 6b7704c14a
commit 8d4e5a0d4a
17 changed files with 136 additions and 163 deletions

View File

@@ -2,6 +2,7 @@ function Commander(element,element_input)
{
this.element = element;
this.element_input = element_input;
this.hint = new Hint();
this.storage = [];
this.storage_index = 0;
this.always_show = false;
@@ -44,6 +45,7 @@ function Commander(element,element_input)
ronin.modules[key].passive(cmd);
ronin.module = ronin.modules[key];
}
this.hint.update(ronin.module,cmd);
}
//

View File

@@ -1,22 +1,22 @@
function Cursor()
{
this.mode = new Mode_Paint();
this.mode = null;
this.position = new Position();
this.update = function(event)
{
if(event.ctrlKey === true){ this.set_mode(new Mode_Guide()); }
else if(event.altKey === true){ this.set_mode(new Mode_Drag()); }
else if(event.shiftKey === true){ this.set_mode(new Mode_Paint()); }
else{ this.set_mode(new Mode_Paint()); }
if(event.ctrlKey === true){ this.set_mode(ronin.overlay); }
else if(event.altKey === true){ this.set_mode(ronin.canvas); }
else if(event.shiftKey === true){ this.set_mode(ronin.brush); }
else{ this.set_mode(ronin.brush); }
}
this.set_mode = function(mode)
{
if(this.mode.name == mode.name){ return; }
// if(this.mode.constructor.name == mode.constructor.name){ return; }
this.mode = mode;
document.body.setAttribute("class",this.mode.name);
ronin.widget.update();
document.body.setAttribute("class",this.mode.constructor.name);
// ronin.widget.update();
}
this.mouse_down = function(position)

View File

@@ -4,12 +4,10 @@ function Hint(element)
this.element = element;
this.update = function()
this.update = function(module,cmd)
{
return; // TODO
if(ronin.module){
this.element.innerHTML = this.message(ronin.module,commander.cmd);
if(module){
this.element.innerHTML = this.message(module,cmd);
this.element.style.display = "block";
}
else{

View File

@@ -1,11 +1,12 @@
var ronin = new Ronin();
ronin.canvas.element = document.getElementById('workspace');
ronin.overlay.element = document.getElementById('overlay');
ronin.hint.element = document.getElementById('commander_hint');
ronin.surface = document.getElementById('surface');
ronin.widget.element = document.getElementById('widget');
ronin.cursor.mode = ronin.brush;
var commander = new Commander(document.getElementById("commander"),document.getElementById("commander_input"));
commander.hint.element = document.getElementById('commander_hint');
// Cursor
document.addEventListener('mousedown', function(e){ ronin.cursor.mouse_down(ronin.position_in_canvas(e));}, false);

View File

@@ -34,9 +34,8 @@ function Keyboard()
// Passive
commander.passive(commander.element_input.value);
ronin.hint.update();
ronin.cursor.set_mode(new Mode_Paint());
ronin.cursor.set_mode(ronin.brush);
ronin.widget.update();
};

View File

@@ -2,7 +2,6 @@ function Ronin()
{
this.modules = {};
this.hint = new Hint();
this.widget = new Widget();
this.surface = null;
@@ -34,7 +33,9 @@ function Ronin()
this.position_in_canvas = function(e)
{
return new Position(e.clientX - parseFloat(ronin.surface.style.left) - parseFloat(ronin.canvas.element.style.left),e.clientY- parseFloat(ronin.surface.style.top) - parseFloat(ronin.canvas.element.style.top));
var x = e.clientX - parseFloat(ronin.surface.style.left) - parseFloat(ronin.canvas.element.style.left);
var y = e.clientY- parseFloat(ronin.surface.style.top) - parseFloat(ronin.canvas.element.style.top);
return new Position(x+","+y);
}
this.position_in_window = function(p)

View File

@@ -10,7 +10,7 @@ function Widget()
s += ronin.modules[key].widget();
}
s += "<span class='cursor'>"+ronin.cursor.mode.widget()+"</span>";
// s += "<span class='cursor'>"+ronin.cursor.mode.widget()+"</span>";
this.element.innerHTML = s;
}