Fixed issues with new cursor modes.

This commit is contained in:
Devine Lu Linvega 2016-12-19 15:01:07 -07:00
parent df8d94d3d5
commit cdbd9e9c0b
6 changed files with 23 additions and 41 deletions

View File

@ -5,10 +5,10 @@ function Cursor()
this.update = function(event) this.update = function(event)
{ {
// if(event.ctrlKey === true){ this.set_mode(new Mode_Guide()); } if(event.ctrlKey === true){ this.set_mode(new Mode_Guide()); }
// else if(event.altKey === true){ this.set_mode(new Mode_Drag()); } else if(event.altKey === true){ this.set_mode(new Mode_Drag()); }
// else if(event.shiftKey === true){ this.set_mode(new Mode_Paint()); } else if(event.shiftKey === true){ this.set_mode(new Mode_Paint()); }
// else{ this.set_mode(new Mode_Paint()); } else{ this.set_mode(new Mode_Paint()); }
} }
this.set_mode = function(mode) this.set_mode = function(mode)

View File

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

View File

@ -23,8 +23,4 @@ var starting_canvas = new Rect();
starting_canvas.width = window.innerWidth - 200; starting_canvas.width = window.innerWidth - 200;
starting_canvas.height = window.innerHeight - 200; starting_canvas.height = window.innerHeight - 200;
commander.query("@ "+starting_canvas.render());
ronin.canvas.resize(starting_canvas);
ronin.overlay.resize(starting_canvas);
commander.query("@ 200x200");

View File

@ -2,24 +2,6 @@ function Keyboard()
{ {
this.is_locked = false; this.is_locked = false;
this.cmd = function()
{
var val = commander.element_input.value;
if(val.indexOf(";") > 0){
var cmds = val.split(";");
var vals = [];
for (i = 0; i < cmds.length; i++) {
val = cmds[i].replace(/^\s+|\s+$/g, '');
vals.push(val.split(" "));
}
return vals;
}
else{
return [val.split(" ")];
}
}
this.lock = function() this.lock = function()
{ {
this.is_locked = true; this.is_locked = true;

View File

@ -6,22 +6,24 @@ function Mode_Drag()
this.drag_from = null; this.drag_from = null;
this.mouse_down = function(event) this.mouse_down = function(position)
{ {
this.drag_from = new Position(event.clientX,event.clientY); this.drag_from = position;
} }
this.mouse_move = function(event) this.mouse_move = function(position)
{ {
if(this.drag_from == null){ return; } console.log(position);
return;
if(this.drag_from === null){ return; }
var offset_x = this.drag_from.x - event.clientX; var offset_x = this.drag_from.x - position.x;
var offset_y = this.drag_from.y - event.clientY; var offset_y = this.drag_from.y - position.y;
ronin.surface.style.left = ronin.surface.style.left ? parseInt(ronin.surface.style.left) - offset_x : offset_x; ronin.surface.style.left = ronin.surface.style.left ? parseInt(ronin.surface.style.left) - offset_x : offset_x;
ronin.surface.style.top = ronin.surface.style.top ? parseInt(ronin.surface.style.top) - offset_y : offset_y; ronin.surface.style.top = ronin.surface.style.top ? parseInt(ronin.surface.style.top) - offset_y : offset_y;
this.drag_from = new Position(event.clientX,event.clientY); this.drag_from = new Position(position.x,position.y);
} }
this.mouse_up = function(event) this.mouse_up = function(event)

View File

@ -6,31 +6,31 @@ function Mode_Guide()
this.live_draw_from = null; this.live_draw_from = null;
this.mouse_down = function(event) this.mouse_down = function(position)
{ {
ronin.overlay.clear(); ronin.overlay.clear();
ronin.overlay.draw_pointer(ronin.position_in_canvas(event)); ronin.overlay.draw_pointer(position);
this.live_draw_from = ronin.position_in_canvas(event); this.live_draw_from = position;
commander.show(); commander.show();
commander.element_input.focus(); commander.element_input.focus();
commander.element_input.value = "| "+this.live_draw_from.render(); commander.element_input.value = "| "+this.live_draw_from.render();
} }
this.mouse_move = function(event) this.mouse_move = function(position)
{ {
if(this.live_draw_from == null){ return; } if(this.live_draw_from == null){ return; }
ronin.overlay.clear(); ronin.overlay.clear();
var rect = new Rect(); var rect = new Rect();
rect.width = ronin.position_in_canvas(event).x - this.live_draw_from.x; rect.width = position.x - this.live_draw_from.x;
rect.height = ronin.position_in_canvas(event).y - this.live_draw_from.y; rect.height = position.y - this.live_draw_from.y;
ronin.overlay.draw_rect(this.live_draw_from,rect); ronin.overlay.draw_rect(this.live_draw_from,rect);
commander.element_input.value = "| "+this.live_draw_from.render()+" "+rect.render(); commander.element_input.value = "| "+this.live_draw_from.render()+" "+rect.render();
} }
this.mouse_up = function(event) this.mouse_up = function(position)
{ {
this.live_draw_from = null; this.live_draw_from = null;
commander.element_input.focus(); commander.element_input.focus();