Skip to content

Commit

Permalink
Fixed entity previews
Browse files Browse the repository at this point in the history
  • Loading branch information
deepnight committed Sep 21, 2023
1 parent 11427e3 commit 6bf4d66
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/assets/css/app.min.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app/assets/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ div.entityRef {
height: auto;
overflow: hidden;
object-fit: cover;
outline-offset: -2px;
outline-offset: -1px;

canvas {
width: 100%;
Expand All @@ -1492,7 +1492,8 @@ div.entityRef {
}

&.hasBg {
padding: 2px;
padding: 1px;
box-sizing: border-box;
}
img {
width: 100%;
Expand Down Expand Up @@ -6299,7 +6300,6 @@ canvas#webgl {
.entityPreview {
margin: 0;
zoom: 2;
padding: 0;
}
}
&.col-2 .subList ul li .entityPreview {
Expand Down
24 changes: 13 additions & 11 deletions src/electron.renderer/misc/JsTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,21 @@ class JsTools {
jWrapper.css("width", sizePx+"px");
jWrapper.css("height", sizePx+"px");

var tileRect = ed.uiTileRect!=null && ed.uiTileRect.w>0 ? ed.uiTileRect
: ed.renderMode==Tile && ed.tileRect!=null ? ed.tileRect
: null;

if( tileRect!=null ) {
if( ed.uiTileRect!=null && ed.uiTileRect.w>0 ) {
// Alt custom UI tile
var td = project.defs.getTilesetDef(ed.uiTileRect.tilesetUid);
var jImg = td.createTileHtmlImageFromRect(ed.uiTileRect);
jWrapper.append(jImg);
}
else if( ed.renderMode==Tile && ed.tileRect!=null ) {
// Tile
var td = project.defs.getTilesetDef(tileRect.tilesetUid);
var jImg = td.createTileHtmlImageFromRect(tileRect);
var td = project.defs.getTilesetDef(ed.tileRect.tilesetUid);
var jImg = td.createTileHtmlImageFromRect(ed.tileRect);
jWrapper.append(jImg);
jImg.css("opacity", ed.tileOpacity);
if( ed.lineOpacity>0 ) {
jWrapper.addClass("hasBg");
jWrapper.css("outline", "2px solid "+new dn.Col(ed.color).toCssRgba(ed.lineOpacity));
jWrapper.css("outline", "1px solid "+new dn.Col(ed.color).toCssRgba(ed.lineOpacity));
}
if( ed.fillOpacity>0 ) {
jWrapper.addClass("hasBg");
Expand All @@ -294,11 +296,11 @@ class JsTools {

var cnv = Std.downcast( jCanvas.get(0), js.html.CanvasElement );
var ctx = cnv.getContext2d();
var pad = M.round( sizePx*0.1 );
var pad = M.round( sizePx*0.1*superScale );

ctx.fillStyle = new dn.Col(ed.color).toCssRgba(ed.fillOpacity);
ctx.strokeStyle = new dn.Col(ed.color).toCssRgba(ed.lineOpacity);
ctx.lineWidth = 2;
ctx.lineWidth = 2/superScale;

switch ed.renderMode {
case Rectangle:
Expand All @@ -316,7 +318,7 @@ class JsTools {
ctx.stroke();

case Cross:
ctx.lineWidth = 4;
ctx.lineWidth = 3;
ctx.moveTo(0,0);
ctx.lineTo(wid, hei);
ctx.moveTo(0,hei);
Expand Down

0 comments on commit 6bf4d66

Please sign in to comment.