diff --git a/index.html b/index.html index 580a62a..2f9ed7a 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,6 @@ - diff --git a/links/main.css b/links/main.css index 734d467..7585c59 100644 --- a/links/main.css +++ b/links/main.css @@ -16,6 +16,7 @@ canvas:hover { cursor: none;} #terminal input { display: block; position:absolute; bottom:0px; width:100vw; padding:0px 5px; font-size:10px; line-height: 20px; background:none; z-index:900; color:white;} #terminal hint { background:#000; position:absolute; bottom:0px; line-height: 20px; padding:0px 5px; width:100vw; color:#777; font-size:10px; white-space: pre;} #terminal hint b { font-family: "input_mono_regular"; color:#999; } +#terminal hint i { font-style: italic; color:#fff; } #terminal logs { display: block;position: absolute;bottom:20px;width:100vw;color:white} #terminal logs log { display: block; font-size:10px; line-height:25px; padding:0px 5px; color:#666;} #terminal logs log .rune { color:white; } diff --git a/scripts/core/ronin.js b/scripts/core/ronin.js index 3c76dc9..99dfa5b 100644 --- a/scripts/core/ronin.js +++ b/scripts/core/ronin.js @@ -12,7 +12,6 @@ function Ronin() this.eye = new Eye("*"); this.render = new Render("%"); this.vector = new Vector("+"); - this.help = new Help("?"); this.typo = new Typographe("&"); this.cursor = new Cursor("."); this.terminal = new Terminal(">"); @@ -26,7 +25,6 @@ function Ronin() this.modules[this.eye.rune] = this.eye; this.modules[this.typo.rune] = this.typo; this.modules[this.vector.rune] = this.vector; - this.modules[this.help.rune] = this.help; this.modules[this.terminal.rune] = this.terminal; this.modules[this.cursor.rune] = this.cursor; diff --git a/scripts/modules/brush.js b/scripts/modules/brush.js index 800e2ca..f1a9aa7 100644 --- a/scripts/modules/brush.js +++ b/scripts/modules/brush.js @@ -73,16 +73,6 @@ function Brush(rune) this.pointers.push(pointer); } - - this.widget_cursor = function() - { - if(keyboard.shift_held == true){ - return "Eraser "+this.size; - } - else{ - return " Brush "+ronin.brush.pointers.length+"x "+this.size; - } - } // Eraser @@ -106,6 +96,16 @@ function Brush(rune) } // Cursor + + this.mouse_mode = function() + { + if(keyboard.shift_held == true){ + return "Eraser "+this.size; + } + else{ + return " Brush "+ronin.brush.pointers.length+"x "+this.size; + } + } this.is_drawing = false; @@ -125,7 +125,7 @@ function Brush(rune) } - this.mouse_move = function(position) + this.mouse_move = function(position,rect) { if(this.is_drawing === false){ return; } @@ -139,7 +139,7 @@ function Brush(rune) } } - this.mouse_up = function(position) + this.mouse_up = function(position,rect) { this.is_drawing = false; this.position_prev = null; diff --git a/scripts/modules/cursor.js b/scripts/modules/cursor.js index eafd9c6..5deb15e 100644 --- a/scripts/modules/cursor.js +++ b/scripts/modules/cursor.js @@ -121,13 +121,17 @@ function Cursor(rune) } this.position = position; + if(this.mode.constructor.name != Cursor.name){ + this.mode.mouse_from = position; this.mode.mouse_down(position); } } this.mouse_move = function(position) { + if(this.mode.mouse_from == null){ return; } + if(this.magnetism){ position = this.magnetic_position(position); } @@ -135,8 +139,12 @@ function Cursor(rune) this.position = position; + var rect = new Rect(); + rect.width = this.position.x - this.mode.mouse_from.x; + rect.height = this.position.y - this.mode.mouse_from.y; + if(this.mode.constructor.name != Cursor.name){ - this.mode.mouse_move(position); + this.mode.mouse_move(position,rect); } } @@ -148,9 +156,16 @@ function Cursor(rune) } this.position = position; + + var rect = new Rect(); + rect.width = this.position.x - this.mode.mouse_from.x; + rect.height = this.position.y - this.mode.mouse_from.y; + if(this.mode.constructor.name != Cursor.name){ - this.mode.mouse_up(position); + this.mode.mouse_up(position,rect); } ronin.terminal.input_element.focus(); + + this.mode.mouse_from = null; } } \ No newline at end of file diff --git a/scripts/modules/default.js b/scripts/modules/default.js index d99e504..9cdfb88 100644 --- a/scripts/modules/default.js +++ b/scripts/modules/default.js @@ -4,7 +4,7 @@ function Default(rune) // Cursor - this.widget_cursor = function() + this.mouse_mode = function() { return "Drag"; } diff --git a/scripts/modules/eye.js b/scripts/modules/eye.js index dd2c61f..52a917b 100644 --- a/scripts/modules/eye.js +++ b/scripts/modules/eye.js @@ -12,11 +12,6 @@ function Eye(rune) { } - this.widget_cursor = function() - { - return "Eye"; - } - // TODO: If a rect is given, return the average color this.color_picker = function(position,rect = null) { @@ -26,39 +21,27 @@ function Eye(rune) ronin.terminal.update_hint(); } - // Cursor - - this.live_draw_from = null; + // Mouse + + this.mouse_mode = function() + { + return "Eye"; + } this.mouse_down = function(position) { - this.click = true; - this.live_draw_from = position; ronin.overlay.draw(position); this.color_picker(position); } - this.mouse_move = function(position) + this.mouse_move = function(position,rect) { - if(!this.click){ return; } - - var rect = new Rect(); - rect.width = position.x - this.live_draw_from.x; - rect.height = position.y - this.live_draw_from.y; - - ronin.overlay.draw(this.live_draw_from,rect); - + ronin.overlay.draw(this.mouse_from,rect); this.color_picker(position,rect); } - this.mouse_up = function(position) + this.mouse_up = function(position,rect) { - this.click = null; - - var rect = new Rect(); - rect.width = position.x - this.live_draw_from.x; - rect.height = position.y - this.live_draw_from.y; - this.color_picker(position,rect); } } \ No newline at end of file diff --git a/scripts/modules/help.js b/scripts/modules/help.js deleted file mode 100644 index b81f289..0000000 --- a/scripts/modules/help.js +++ /dev/null @@ -1,56 +0,0 @@ -function Help(rune) -{ - Module.call(this,rune); - - this.view = document.createElement("div"); - - this.active = function(cmd) - { - s = "hello"; - - lines = []; - - // Modules - // TODO: Have the modules return their own help string - lines.push("Modules: "); - Object.keys(ronin.modules).forEach(function (key) { - html = ""; - var parameters = ""; - html += ""+key+" "+ronin.modules[key].constructor.name+" "; - for (i = 0; i < ronin.modules[key].parameters.length; i++) { - html += ""+ronin.modules[key].parameters[i].name+" "; - } - lines.push(html); - }); - - // Filters - lines.push("Filters: "); - for(var filter in ronin.modules["%"].collection){ - html = filter+" "; - for (i = 0; i < ronin.modules["%"].collection[filter].parameters.length; i++) { - html += ""+ronin.modules["%"].collection[filter].parameters[i].name+" "; - } - lines.push(html); - } - - // Controls - lines.push("Controls: "); - lines.push("ctrl Draw Overlays\n"); - lines.push("alt Drag Surface\n"); - lines.push("shift Erase\n"); - lines.push("shift+ctrl Eyedrop\n"); - lines.push("shift+alt Move Layer\n"); - - // Units - lines.push("Units: "); - var units = [new Value(), new Position(), new Rect(), new Color(), new Angle(), new Variable(), new Bang()] - for(key in units){ - lines.push(units[key].render()); - } - - // Print - for(line in lines){ - ronin.terminal.log(new Log(this,lines[line])); - } - } -} \ No newline at end of file diff --git a/scripts/modules/module.js b/scripts/modules/module.js index 383a779..d0cff0b 100644 --- a/scripts/modules/module.js +++ b/scripts/modules/module.js @@ -54,6 +54,8 @@ function Module(rune) h += variable+"="+ronin.module.variables[variable]+" "; } + h += ronin.module.mouse_mode() ? ""+ronin.module.mouse_mode()+"" : ""; + return this.pad(content)+h; } @@ -70,24 +72,30 @@ function Module(rune) { return ""; } - - this.widget_cursor = function() + + // Mouse + + this.mouse_mode = function() { - return "Missing"; + return null; } + + this.mouse_from = null; this.mouse_down = function(position) { } - this.mouse_move = function(position) + this.mouse_move = function(position,rect) { } - this.mouse_up = function(position) + this.mouse_up = function(position,rect) { } + // Keyboard + this.key_escape = function() { } diff --git a/scripts/modules/surface.js b/scripts/modules/surface.js index c72bbf8..512ccdd 100644 --- a/scripts/modules/surface.js +++ b/scripts/modules/surface.js @@ -112,11 +112,6 @@ function Surface(rune) return this.rune+" "+this.size.render(); } - - this.widget_cursor = function() - { - return "Crop"; - } // Widget @@ -130,7 +125,7 @@ function Surface(rune) } s += ""; - s += ""+ronin.cursor.mode.widget_cursor()+""; + s += ""+ronin.cursor.mode.mouse_mode()+""; var keys = Object.keys(ronin.surface.layers); var loc = keys.indexOf(this.active_layer.name); @@ -173,36 +168,30 @@ function Surface(rune) } // Cursor - - this.live_draw_from = null; + this.mouse_mode = function() + { + return "crop"; + } + this.mouse_down = function(position) { ronin.overlay.clear(); ronin.overlay.draw_pointer(position); - this.live_draw_from = position; - ronin.terminal.input_element.value = "| "+this.live_draw_from.render(); + ronin.terminal.input_element.value = "| "+this.mouse_from.render(); } - this.mouse_move = function(position) - { - if(this.live_draw_from === null){ return; } - + this.mouse_move = function(position,rect) + { ronin.overlay.clear(); - - var rect = new Rect(); - 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); - ronin.terminal.input_element.value = "@ "+this.live_draw_from.render()+" "+rect.render(); + + ronin.overlay.draw_rect(this.mouse_from,rect); + ronin.terminal.input_element.value = "@ "+this.mouse_from.render()+" "+rect.render(); ronin.terminal.update_hint(); } - this.mouse_up = function(position) + this.mouse_up = function(position,rect) { - this.live_draw_from = null; - ronin.terminal.input_element.focus(); } } \ No newline at end of file diff --git a/scripts/modules/surface.layer.js b/scripts/modules/surface.layer.js index 4384d16..a8f0476 100644 --- a/scripts/modules/surface.layer.js +++ b/scripts/modules/surface.layer.js @@ -46,11 +46,6 @@ function Layer(name,manager = null) // - this.widget_cursor = function() - { - return "Move"; - } - this.widget = function() { var e_name = this.name; @@ -62,6 +57,11 @@ function Layer(name,manager = null) return ""+e_name+""; } + this.mouse_mode = function() + { + return "Move"; + } + this.move_from = null; this.mouse_down = function(position) diff --git a/scripts/modules/typographe.js b/scripts/modules/typographe.js index d990412..fd86948 100644 --- a/scripts/modules/typographe.js +++ b/scripts/modules/typographe.js @@ -43,7 +43,7 @@ function Typographe(rune) this.click = null; - this.widget_cursor = function() + this.mouse_mode = function() { return "Typographe"; } diff --git a/scripts/modules/vector.js b/scripts/modules/vector.js index 5e9465e..0c14aa9 100644 --- a/scripts/modules/vector.js +++ b/scripts/modules/vector.js @@ -72,7 +72,7 @@ function Vector(rune) this.click = null; - this.widget_cursor = function() + this.mouse_mode = function() { if(keyboard.shift_held == true && keyboard.alt_held == true){ return "Vector(Origin)";