Improve scaling

This commit is contained in:
luboslenco
2019-05-23 11:11:23 +02:00
parent 8c6f9ce21e
commit 88801eb1b0
4 changed files with 13 additions and 4 deletions
+5 -2
View File
@@ -22,6 +22,8 @@ class App extends iron.Trait {
public static var uienabled = true;
public static var isDragging = false;
public static var dragAsset:TAsset = null;
public static var dragOffX = 0.0;
public static var dragOffY = 0.0;
public static var showFiles = false;
public static var showBox = false;
public static var foldersOnly = false;
@@ -310,9 +312,10 @@ class App extends iron.Trait {
var mouse = iron.system.Input.getMouse();
if (arm.App.dragAsset != null) {
var img = UITrait.inst.getImage(arm.App.dragAsset);
var ratio = 128 / img.width;
@:privateAccess var size = 50 * UITrait.inst.ui.SCALE;
var ratio = size / img.width;
var h = img.height * ratio;
g.drawScaledImage(img, mouse.x + iron.App.x(), mouse.y + iron.App.y(), 128, h);
g.drawScaledImage(img, mouse.x + iron.App.x() + arm.App.dragOffX, mouse.y + iron.App.y() + arm.App.dragOffY, size, h);
}
var usingMenu = false;
+2 -1
View File
@@ -312,7 +312,8 @@ class UINodes extends iron.Trait {
var id = nodes.nodesSelected[0].buttons[0].default_value;
if (id < UITrait.inst.assets.length) {
var img = UITrait.inst.getImage(UITrait.inst.assets[id]);
ui.g.drawScaledImage(img, ww - 64 - 20, wh - 64 - 40, 64, 64);
var size = 64 * ui.SCALE;
ui.g.drawScaledImage(img, ww - size - 20 * ui.SCALE, wh - size - 40 * ui.SCALE, size, size);
}
}
+6 -1
View File
@@ -2092,7 +2092,7 @@ class UITrait extends iron.Trait {
@:privateAccess ui.endElement();
continue;
}
var img = materials[i].imageIcon;
var img = ui.SCALE >= 2.0 ? materials[i].image : materials[i].imageIcon;
var imgFull = materials[i].image;
if (selectedMaterial == materials[i]) {
@@ -2219,7 +2219,12 @@ class UITrait extends iron.Trait {
}
var img = UITrait.inst.getImage(asset);
var uix = ui._x;
var uiy = ui._y;
if (ui.image(img) == State.Started) {
var mouse = iron.system.Input.getMouse();
arm.App.dragOffX = -(mouse.x - uix - ui._windowX + iron.App.x() - 3);
arm.App.dragOffY = -(mouse.y - uiy - ui._windowY + iron.App.y() + 1);
arm.App.dragAsset = asset;
selectedTexture = asset;
BIN
View File
Binary file not shown.