Implementing cursor managers
This commit is contained in:
parent
9d6db2a93c
commit
99f1929618
@ -1,6 +1,12 @@
|
||||
function Command(content)
|
||||
{
|
||||
this.content = content;
|
||||
|
||||
this.inject_position = function(injection)
|
||||
{
|
||||
console.log("> "+injection);
|
||||
console.log("- "+content);
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
|
@ -4,8 +4,11 @@ function Hint(element)
|
||||
|
||||
this.element = element;
|
||||
|
||||
this.update = function(module,cmd)
|
||||
this.update = function()
|
||||
{
|
||||
var module = ronin.module;
|
||||
var cmd = commander.cmd();
|
||||
|
||||
if(module){
|
||||
this.element.innerHTML = this.message(module,cmd);
|
||||
this.element.style.display = "block";
|
||||
|
@ -55,8 +55,20 @@ function Commander(element,element_input)
|
||||
if(ronin.modules[key]){
|
||||
ronin.modules[key].passive(cmd);
|
||||
ronin.module = ronin.modules[key];
|
||||
ronin.cursor.set_mode(ronin.module);
|
||||
}
|
||||
this.hint.update(ronin.module,cmd);
|
||||
else{
|
||||
ronin.cursor.set_mode(ronin.brush);
|
||||
}
|
||||
this.hint.update();
|
||||
}
|
||||
|
||||
this.cmd = function()
|
||||
{
|
||||
var content = this.element_input.value.trim();
|
||||
var key = content[0];
|
||||
var cmd = new Command(content.substring(1).split(" "));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
//
|
||||
@ -95,6 +107,5 @@ function Commander(element,element_input)
|
||||
{
|
||||
this.storage_index -= this.storage_index < 1 ? 0 : 1;
|
||||
this.element_input.value = this.storage[this.storage_index];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ function Cursor()
|
||||
else if(event.ctrlKey === true){ this.set_mode(ronin.overlay); }
|
||||
else if(event.altKey === true){ this.set_mode(ronin.surface); }
|
||||
else if(event.shiftKey === true){ this.set_mode(ronin.eraser); }
|
||||
else if(ronin.module){ this.set_mode(ronin.module); }
|
||||
else{ this.set_mode(ronin.brush); }
|
||||
}
|
||||
|
||||
@ -28,6 +29,7 @@ function Cursor()
|
||||
this.position = position;
|
||||
this.mode.mouse_down(position);
|
||||
ronin.widget.update();
|
||||
// console.log(this.mode);
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
@ -41,5 +43,6 @@ function Cursor()
|
||||
this.position = position;
|
||||
this.mode.mouse_up(position);
|
||||
ronin.widget.update();
|
||||
commander.element_input.focus();
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ ronin.install();
|
||||
// Canvas
|
||||
var starting_canvas = new Rect();
|
||||
starting_canvas.width = window.innerWidth - 200;
|
||||
starting_canvas.height = window.innerHeight - 400;
|
||||
starting_canvas.height = window.innerHeight - 200;
|
||||
|
||||
// Clamp
|
||||
|
||||
|
@ -26,7 +26,7 @@ function Keyboard()
|
||||
// Passive
|
||||
commander.passive(commander.element_input.value);
|
||||
|
||||
ronin.cursor.set_mode(ronin.brush);
|
||||
// ronin.cursor.set_mode(ronin.brush);
|
||||
ronin.widget.update();
|
||||
};
|
||||
|
||||
|
@ -46,4 +46,35 @@ function Typographe(rune)
|
||||
ctx.fillStyle = color.hex;
|
||||
ctx.fillText(text,position.x,position.y);
|
||||
}
|
||||
|
||||
// Mouse
|
||||
|
||||
this.click = null;
|
||||
|
||||
this.widget_cursor = function()
|
||||
{
|
||||
return "&";
|
||||
}
|
||||
|
||||
this.mouse_down = function(position)
|
||||
{
|
||||
this.click = true;
|
||||
ronin.overlay.draw(position);
|
||||
commander.element_input.value = "& "+position.render();
|
||||
commander.hint.update();
|
||||
}
|
||||
|
||||
this.mouse_move = function(position)
|
||||
{
|
||||
if(!this.click){ return; }
|
||||
ronin.overlay.draw(position);
|
||||
commander.element_input.value = "& "+position.render();
|
||||
}
|
||||
|
||||
this.mouse_up = function(position)
|
||||
{
|
||||
this.click = null;
|
||||
ronin.overlay.draw(position);
|
||||
commander.element_input.value = "& "+position.render();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user