From cdbd9e9c0bc4e112b3a982204ceab9b89b799ee2 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 19 Dec 2016 15:01:07 -0700 Subject: [PATCH] Fixed issues with new cursor modes. --- scripts/core/cursor.js | 8 ++++---- scripts/core/hint.js | 2 ++ scripts/core/init.js | 6 +----- scripts/core/keyboard.js | 18 ------------------ scripts/modes/mode.drag.js | 16 +++++++++------- scripts/modes/mode.guide.js | 14 +++++++------- 6 files changed, 23 insertions(+), 41 deletions(-) diff --git a/scripts/core/cursor.js b/scripts/core/cursor.js index 7a259ab..36621ec 100644 --- a/scripts/core/cursor.js +++ b/scripts/core/cursor.js @@ -5,10 +5,10 @@ function Cursor() 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(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()); } } this.set_mode = function(mode) diff --git a/scripts/core/hint.js b/scripts/core/hint.js index 7bf5e7a..6fb1d02 100644 --- a/scripts/core/hint.js +++ b/scripts/core/hint.js @@ -6,6 +6,8 @@ function Hint(element) this.update = function() { + return; // TODO + if(ronin.module){ this.element.innerHTML = this.message(ronin.module,commander.cmd); this.element.style.display = "block"; diff --git a/scripts/core/init.js b/scripts/core/init.js index e0ddfde..74b7242 100644 --- a/scripts/core/init.js +++ b/scripts/core/init.js @@ -23,8 +23,4 @@ var starting_canvas = new Rect(); starting_canvas.width = window.innerWidth - 200; starting_canvas.height = window.innerHeight - 200; - -ronin.canvas.resize(starting_canvas); -ronin.overlay.resize(starting_canvas); - -commander.query("@ 200x200"); \ No newline at end of file +commander.query("@ "+starting_canvas.render()); \ No newline at end of file diff --git a/scripts/core/keyboard.js b/scripts/core/keyboard.js index 6fe439c..d8e8572 100644 --- a/scripts/core/keyboard.js +++ b/scripts/core/keyboard.js @@ -2,24 +2,6 @@ function Keyboard() { 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.is_locked = true; diff --git a/scripts/modes/mode.drag.js b/scripts/modes/mode.drag.js index 67e826a..1ad5b1b 100644 --- a/scripts/modes/mode.drag.js +++ b/scripts/modes/mode.drag.js @@ -6,22 +6,24 @@ function Mode_Drag() 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_y = this.drag_from.y - event.clientY; + var offset_x = this.drag_from.x - position.x; + 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.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) diff --git a/scripts/modes/mode.guide.js b/scripts/modes/mode.guide.js index 0b5a183..8d6bd01 100644 --- a/scripts/modes/mode.guide.js +++ b/scripts/modes/mode.guide.js @@ -6,31 +6,31 @@ function Mode_Guide() this.live_draw_from = null; - this.mouse_down = function(event) + this.mouse_down = function(position) { ronin.overlay.clear(); - ronin.overlay.draw_pointer(ronin.position_in_canvas(event)); - this.live_draw_from = ronin.position_in_canvas(event); + ronin.overlay.draw_pointer(position); + this.live_draw_from = position; commander.show(); commander.element_input.focus(); 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; } ronin.overlay.clear(); var rect = new Rect(); - rect.width = ronin.position_in_canvas(event).x - this.live_draw_from.x; - rect.height = ronin.position_in_canvas(event).y - this.live_draw_from.y; + rect.width = position.x - this.live_draw_from.x; + rect.height = position.y - this.live_draw_from.y; ronin.overlay.draw_rect(this.live_draw_from,rect); 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; commander.element_input.focus();