diff --git a/sources/scripts/core/cursor.js b/sources/scripts/core/cursor.js index d10df1d..cba5951 100644 --- a/sources/scripts/core/cursor.js +++ b/sources/scripts/core/cursor.js @@ -168,6 +168,12 @@ function Cursor(rune) ronin.commander.update(); } + this.select_layer = function(layer) + { + this.target = layer; + ronin.commander.update(); + } + function make_offset(a,b) { return {x:a.x-b.x,y:a.y-b.y}; diff --git a/sources/scripts/core/keyboard.js b/sources/scripts/core/keyboard.js index a41f9df..eb3c1be 100644 --- a/sources/scripts/core/keyboard.js +++ b/sources/scripts/core/keyboard.js @@ -82,16 +82,6 @@ function Keyboard() ronin.io.methods.save.run(); } - if(e.key == "x"){ - e.preventDefault(); - ronin.cursor.swap_colors(); - } - - if(e.key == "z"){ - e.preventDefault(); - ronin.cursor.swap_layer(); - } - ronin.hint.update(e); } } \ No newline at end of file diff --git a/sources/scripts/core/layer.js b/sources/scripts/core/layer.js index 64b965e..97ecf45 100644 --- a/sources/scripts/core/layer.js +++ b/sources/scripts/core/layer.js @@ -12,9 +12,6 @@ function Layer(name) this.update = function(zoom = {scale:1,offset:{x:0,y:0}}) { - console.log(`Updated ${this.name}`); - // this.el.style.width = (ronin.frame.width)+"px"; - // this.el.style.height = (ronin.frame.height)+"px"; } this.context = function() diff --git a/sources/scripts/modules/frame.js b/sources/scripts/modules/frame.js index 01bb816..c98b60b 100644 --- a/sources/scripts/modules/frame.js +++ b/sources/scripts/modules/frame.js @@ -55,6 +55,11 @@ function Frame() ronin.frame.el.style.height = `${ronin.frame.height * ronin.frame.zoom.scale}px`; ronin.frame.zoom.offset.x = ronin.frame.zoom.scale == 1 ? 0 : ((-ronin.cursor.pos.x * ronin.frame.zoom.scale) + (ronin.frame.width/2)); ronin.frame.zoom.offset.y = ronin.frame.zoom.scale == 1 ? 0 : ((-ronin.cursor.pos.y * ronin.frame.zoom.scale) + (ronin.frame.height/2)); + + // Normalize + if(ronin.frame.zoom.offset.x > 0){ ronin.frame.zoom.offset.x = 0; } + if(ronin.frame.zoom.offset.y > 0){ ronin.frame.zoom.offset.y = 0; } + ronin.frame.el.style.top = `${ronin.frame.zoom.offset.y}px`; ronin.frame.el.style.left = `${ronin.frame.zoom.offset.x}px`; }); diff --git a/sources/scripts/ronin.js b/sources/scripts/ronin.js index 2170a06..769c783 100644 --- a/sources/scripts/ronin.js +++ b/sources/scripts/ronin.js @@ -76,10 +76,15 @@ function Ronin() this.controller.add("default","File","Open",() => { ronin.open(); },"CmdOrCtrl+O"); this.controller.add("default","File","Save",() => { ronin.save(); },"CmdOrCtrl+S"); + this.controller.add("default","Layers","Above Layer",() => { ronin.cursor.select_layer(ronin.layers.above); },"c"); + this.controller.add("default","Layers","Below Layer",() => { ronin.cursor.select_layer(ronin.layers.below); },"z"); + this.controller.add("default","Layers","Toggle Layer",() => { ronin.cursor.swap_layer(); },"x"); + this.controller.add("default","Brush","Inc Size",() => { ronin.brush.mod_size(1); },"]"); this.controller.add("default","Brush","Dec Size",() => { ronin.brush.mod_size(-1); },"["); + this.controller.add("default","Brush","Toggle Color",() => { ronin.cursor.swap_colors(); },"x"); - this.controller.add("default","View","Reset Zoom",() => { ronin.frame.methods.zoom.run(1); },"1"); + this.controller.add("default","View","Zoom Reset",() => { ronin.frame.methods.zoom.run(1); },"1"); this.controller.add("default","View","Zoom 2x",() => { ronin.frame.methods.zoom.run(2); },"2"); this.controller.add("default","View","Zoom 4x",() => { ronin.frame.methods.zoom.run(4); },"3");