1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

Enchance chunk hightlighting and add keyboard control

This commit is contained in:
Starbeamrainbowlabs 2017-06-22 21:00:59 +01:00
parent 0bbe117f3d
commit 5e59d7098a
5 changed files with 14 additions and 13 deletions

View file

@ -116,6 +116,9 @@ class BoardWindow extends EventEmitter
this.keyboard.on("keyup-down", (function(event) {
this.interface.updateBrushWidth(this.interface.currentBrushWidth - 2, true);
}).bind(this));
this.keyboard.on("keyup-c", (function(event) {
this.chunkCache.showRenderedChunks = !this.chunkCache.showRenderedChunks;
}).bind(this));
// --~~~--

View file

@ -13,7 +13,7 @@ class ChunkCache
this.cache = new Map();
// Whether to highlight rendered chunks. Useful for debugging purposes.
this.showRenderedChunks = true;
this.showRenderedChunks = false;
this.boardWindow.rippleLink.on("ChunkUpdate", this.handleChunkUpdate.bind(this));
}
@ -66,17 +66,15 @@ class ChunkCache
cx / chunkSize, cy / chunkSize
);
// todo Render the purple box slightly different if we don't
// actually have a chunk form the server to render
if(this.showRenderedChunks) {
context.beginPath();
context.fillStyle = "hsla(270.5, 79.6%, 55.9%, 0.5)";
context.fillRect(cx, cy, chunkSize, chunkSize);
}
let chunk = this.cache.get(cChunk.toString());
if(typeof chunk != "undefined")
chunk.render(canvas, context);
if(this.showRenderedChunks) {
context.beginPath();
context.fillStyle = `hsla(270.5, 79.6%, 55.9%, ${typeof chunk != "undefined" ? 0.3 : 0.1})`;
context.fillRect(cx, cy, chunkSize, chunkSize);
}
}
}

View file

@ -45,7 +45,7 @@
<aside id="debuginfo">
<label>Viewport:</label> <output id="debug-viewport" class="debug-value">?</output>
<small><em><kbd>g</kbd>: toggle grid, <kbd>c</kbd>: toggle chunk higlighting</small>
</aside>
<canvas id="canvas-main"></canvas>

View file

@ -51,7 +51,7 @@
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View file

@ -2,5 +2,5 @@
<packages>
<package id="IotWeb" version="0.8.6" targetFramework="net452" />
<package id="MimeSharp" version="1.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
</packages>