Font list
This commit is contained in:
@@ -218,8 +218,16 @@ class Importer {
|
||||
}
|
||||
}
|
||||
|
||||
public static var fontList = ["default.ttf"];
|
||||
public static var fontMap = new Map<String, kha.Font>();
|
||||
|
||||
public static function importFont(path:String) {
|
||||
iron.data.Data.getFont(path, function(font:kha.Font) {
|
||||
var ar = path.split("/");
|
||||
ar = ar[ar.length - 1].split("\\");
|
||||
var name = ar[ar.length - 1];
|
||||
fontList.push(name);
|
||||
fontMap.set(name, font);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ class UITrait extends iron.Trait {
|
||||
|
||||
public var textToolImage:kha.Image = null;
|
||||
public var textToolText = "Text";
|
||||
public var textToolHandle = new Zui.Handle({position: 0});
|
||||
|
||||
var _onBrush:Array<Int->Void> = [];
|
||||
|
||||
@@ -546,7 +547,7 @@ class UITrait extends iron.Trait {
|
||||
brushLocked = false;
|
||||
brushCanUnlock = false;
|
||||
}
|
||||
if (kb.released("f") && brushLocked) {
|
||||
if (kb.released("f")) {
|
||||
mouse.unlock();
|
||||
brushCanUnlock = true;
|
||||
}
|
||||
@@ -1222,11 +1223,11 @@ class UITrait extends iron.Trait {
|
||||
}
|
||||
}
|
||||
if (brushType == 6) { // Text
|
||||
var font = ui.combo(Id.handle({position: 0}), ["default.ttf"], "Font");
|
||||
ui.combo(textToolHandle, Importer.fontList, "Font");
|
||||
var h = Id.handle();
|
||||
h.text = textToolText;
|
||||
textToolText = ui.textInput(h, "");
|
||||
if (h.changed) {
|
||||
if (h.changed || textToolHandle.changed) {
|
||||
ui.g.end();
|
||||
RenderUtil.makeTextPreview();
|
||||
RenderUtil.makeDecalPreview();
|
||||
@@ -2186,4 +2187,10 @@ class UITrait extends iron.Trait {
|
||||
ui.end();
|
||||
g.begin(false);
|
||||
}
|
||||
|
||||
public function getTextToolFont():kha.Font {
|
||||
var fontName = Importer.fontList[textToolHandle.position];
|
||||
if (fontName == 'default.ttf') return UITrait.inst.ui.ops.font;
|
||||
return Importer.fontMap.get(fontName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,12 @@ class RenderUtil {
|
||||
iron.Scene.active.camera.transform.setMatrix(m);
|
||||
var savedFov = iron.Scene.active.camera.data.raw.fov;
|
||||
iron.Scene.active.camera.data.raw.fov = 0.92;
|
||||
// var light = iron.Scene.active.lights[0];
|
||||
// light.data.raw.cast_shadow = false;
|
||||
var light = iron.Scene.active.lights[0];
|
||||
var savedLight = light.data.raw.strength;
|
||||
light.data.raw.strength = 1000;
|
||||
var probe = iron.Scene.active.world.probe;
|
||||
var savedProbe = probe.raw.strength;
|
||||
probe.raw.strength = 2;
|
||||
iron.Scene.active.world.envmap = UITrait.inst.previewEnvmap;
|
||||
|
||||
// No jitter
|
||||
@@ -119,8 +123,8 @@ class RenderUtil {
|
||||
iron.Scene.active.camera.data.raw.fov = savedFov;
|
||||
iron.Scene.active.camera.buildProjection();
|
||||
iron.Scene.active.camera.buildMatrix();
|
||||
// var light = iron.Scene.active.lights[0];
|
||||
// light.data.raw.cast_shadow = true;
|
||||
light.data.raw.strength = savedLight;
|
||||
probe.raw.strength = savedProbe;
|
||||
iron.Scene.active.world.envmap = UITrait.inst.showEnvmap ? UITrait.inst.savedEnvmap : UITrait.inst.emptyEnvmap;
|
||||
UINodes.inst.parseMeshMaterial();
|
||||
}
|
||||
@@ -132,7 +136,7 @@ class RenderUtil {
|
||||
}
|
||||
var g2 = UITrait.inst.textToolImage.g2;
|
||||
g2.begin(true, 0xff000000);
|
||||
g2.font = UITrait.inst.ui.ops.font;
|
||||
g2.font = UITrait.inst.getTextToolFont();
|
||||
g2.fontSize = 200;
|
||||
g2.color = 0xffffffff;
|
||||
g2.drawString(UITrait.inst.textToolText, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user