Add a cursor to the editor
This commit is contained in:
parent
09d220b2a3
commit
d700561c0f
@ -617,6 +617,7 @@ export class Level extends LevelInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tile.type.on_power) {
|
else if (tile.type.on_power) {
|
||||||
|
// FIXME this isn't quite right since there's seemingly a 1-frame delay
|
||||||
add_to_edge_map(circuit.tiles, tile, DIRECTIONS[edge].bit);
|
add_to_edge_map(circuit.tiles, tile, DIRECTIONS[edge].bit);
|
||||||
wired_outputs.add(tile);
|
wired_outputs.add(tile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2097,6 +2097,10 @@ export class Editor extends PrimaryView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
// Add more bits to SVG overlay
|
||||||
|
this.svg_cursor = mk_svg('rect.overlay-cursor', {x: 0, y: 0, width: 1, height: 1});
|
||||||
|
this.svg_overlay.append(this.svg_cursor);
|
||||||
|
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
window.addEventListener('keydown', ev => {
|
window.addEventListener('keydown', ev => {
|
||||||
if (! this.active)
|
if (! this.active)
|
||||||
@ -2161,6 +2165,17 @@ export class Editor extends PrimaryView {
|
|||||||
window.addEventListener('mousemove', ev => {
|
window.addEventListener('mousemove', ev => {
|
||||||
if (! this.active)
|
if (! this.active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let [x, y] = this.renderer.cell_coords_from_event(ev);
|
||||||
|
if (this.is_in_bounds(x, y)) {
|
||||||
|
this.svg_cursor.classList.add('--visible');
|
||||||
|
this.svg_cursor.setAttribute('x', x);
|
||||||
|
this.svg_cursor.setAttribute('y', y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.svg_cursor.classList.remove('--visible');
|
||||||
|
}
|
||||||
|
|
||||||
if (! this.mouse_op)
|
if (! this.mouse_op)
|
||||||
return;
|
return;
|
||||||
if ((ev.buttons & this.mouse_op.button_mask) === 0) {
|
if ((ev.buttons & this.mouse_op.button_mask) === 0) {
|
||||||
|
|||||||
14
style.css
14
style.css
@ -1413,6 +1413,14 @@ body.--debug #player-debug {
|
|||||||
stroke-width: 0.0625;
|
stroke-width: 0.0625;
|
||||||
fill: none;
|
fill: none;
|
||||||
}
|
}
|
||||||
|
#editor .level-editor-overlay rect.overlay-cursor {
|
||||||
|
display: none;
|
||||||
|
stroke: hsla(225, 100%, 60%, 0.5);
|
||||||
|
fill: hsla(225, 100%, 75%, 0.25);
|
||||||
|
}
|
||||||
|
#editor .level-editor-overlay rect.overlay-cursor.--visible {
|
||||||
|
display: initial;
|
||||||
|
}
|
||||||
#editor .level-editor-overlay rect.overlay-cxn {
|
#editor .level-editor-overlay rect.overlay-cxn {
|
||||||
stroke: red;
|
stroke: red;
|
||||||
}
|
}
|
||||||
@ -1523,7 +1531,11 @@ body.--debug #player-debug {
|
|||||||
#editor .palette {
|
#editor .palette {
|
||||||
isolation: isolate;
|
isolation: isolate;
|
||||||
grid-area: palette;
|
grid-area: palette;
|
||||||
padding-right: 0.25em; /* in case of scrollbar */
|
width: calc(32px * 8 + 4px * 9);
|
||||||
|
padding-right: 1em; /* make room for scrollbar so we don't get a horizontal one */
|
||||||
|
/* TODO when there IS a scrollbar, the h2s are slightly narrower. think this is an
|
||||||
|
* unexpected consequence of using min-content, which i guess does not take the
|
||||||
|
* possibility of a scrollbar into account */
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
#editor .palette h2 {
|
#editor .palette h2 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user