Light font improvements
This commit is contained in:
parent
34ea6d45cf
commit
0e073689c4
483
assets/Textures/Fonts/myFont2Map.json
Normal file
483
assets/Textures/Fonts/myFont2Map.json
Normal file
@ -0,0 +1,483 @@
|
|||||||
|
{
|
||||||
|
"imageWidth": 3864,
|
||||||
|
"imageHeight": 60,
|
||||||
|
"glyphs":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"symbol": "A",
|
||||||
|
"startX": 1,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "B",
|
||||||
|
"startX": 43,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "C",
|
||||||
|
"startX": 85,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "D",
|
||||||
|
"startX": 127,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "E",
|
||||||
|
"startX": 169,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "F",
|
||||||
|
"startX": 211,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "G",
|
||||||
|
"startX": 253,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "H",
|
||||||
|
"startX": 295,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "I",
|
||||||
|
"startX": 337,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "J",
|
||||||
|
"startX": 379,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "K",
|
||||||
|
"startX": 421,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "L",
|
||||||
|
"startX": 463,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "M",
|
||||||
|
"startX": 505,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "N",
|
||||||
|
"startX": 547,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "O",
|
||||||
|
"startX": 589,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "P",
|
||||||
|
"startX": 631,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "Q",
|
||||||
|
"startX": 673,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "R",
|
||||||
|
"startX": 715,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "S",
|
||||||
|
"startX": 757,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "T",
|
||||||
|
"startX": 799,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "U",
|
||||||
|
"startX": 841,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "V",
|
||||||
|
"startX": 883,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "W",
|
||||||
|
"startX": 925,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "X",
|
||||||
|
"startX": 967,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "Y",
|
||||||
|
"startX": 1009,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "Z",
|
||||||
|
"startX": 1051,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "a",
|
||||||
|
"startX": 1093,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "b",
|
||||||
|
"startX": 1135,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "c",
|
||||||
|
"startX": 1177,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "d",
|
||||||
|
"startX": 1219,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "e",
|
||||||
|
"startX": 1261,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "f",
|
||||||
|
"startX": 1303,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "g",
|
||||||
|
"startX": 1345,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "h",
|
||||||
|
"startX": 1387,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "i",
|
||||||
|
"startX": 1429,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "j",
|
||||||
|
"startX": 1471,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "k",
|
||||||
|
"startX": 1513,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "l",
|
||||||
|
"startX": 1555,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "m",
|
||||||
|
"startX": 1597,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "n",
|
||||||
|
"startX": 1639,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "o",
|
||||||
|
"startX": 1681,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "p",
|
||||||
|
"startX": 1723,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "q",
|
||||||
|
"startX": 1765,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "r",
|
||||||
|
"startX": 1807,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "s",
|
||||||
|
"startX": 1849,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "t",
|
||||||
|
"startX": 1891,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "u",
|
||||||
|
"startX": 1933,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "v",
|
||||||
|
"startX": 1975,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "w",
|
||||||
|
"startX": 2017,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "x",
|
||||||
|
"startX": 2059,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "y",
|
||||||
|
"startX": 2101,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "z",
|
||||||
|
"startX": 2143,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "1",
|
||||||
|
"startX": 2185,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "2",
|
||||||
|
"startX": 2227,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "3",
|
||||||
|
"startX": 2269,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "4",
|
||||||
|
"startX": 2311,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "5",
|
||||||
|
"startX": 2353,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "6",
|
||||||
|
"startX": 2395,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "7",
|
||||||
|
"startX": 2437,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "8",
|
||||||
|
"startX": 2479,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "9",
|
||||||
|
"startX": 2521,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "0",
|
||||||
|
"startX": 2563,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": ".",
|
||||||
|
"startX": 2605,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "!",
|
||||||
|
"startX": 2647,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "?",
|
||||||
|
"startX": 2689,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "\"",
|
||||||
|
"startX": 2731,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": "'",
|
||||||
|
"startX": 2773,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"symbol": ",",
|
||||||
|
"startX": 2815,
|
||||||
|
"startY": 1,
|
||||||
|
"width": 40,
|
||||||
|
"height": 58
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
assets/Textures/Fonts/myfont2.png
Normal file
BIN
assets/Textures/Fonts/myfont2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@ -300,6 +300,7 @@ public class ControlHandler {
|
|||||||
|
|
||||||
case IN_GAME_MAIN_MENU:
|
case IN_GAME_MAIN_MENU:
|
||||||
runHandlers(menuNavigationControlList);
|
runHandlers(menuNavigationControlList);
|
||||||
|
runHandlers(typingControlList);
|
||||||
// pollMenuNavigationControls();
|
// pollMenuNavigationControls();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -370,7 +370,7 @@ public class Globals {
|
|||||||
//create default lights
|
//create default lights
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createBitmapDisplay(), AssetDataStrings.ASSET_STRING_BITMAP_FONT);
|
assetManager.registerModelToSpecificString(RenderUtils.createBitmapDisplay(), AssetDataStrings.ASSET_STRING_BITMAP_FONT);
|
||||||
assetManager.registerModelToSpecificString(RenderUtils.createBitmapCharacter(), AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
assetManager.registerModelToSpecificString(RenderUtils.createBitmapCharacter(), AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
||||||
RawFontMap fontMap = FileUtils.loadObjectFromAssetPath("Textures/Fonts/myFontMap.json", RawFontMap.class);
|
RawFontMap fontMap = FileUtils.loadObjectFromAssetPath("Textures/Fonts/myFont2Map.json", RawFontMap.class);
|
||||||
FontUtils.setFontDataMap(fontMap);
|
FontUtils.setFontDataMap(fontMap);
|
||||||
//particle billboard model
|
//particle billboard model
|
||||||
particleBillboardModel = assetManager.registerModel(RenderUtils.createParticleModel());
|
particleBillboardModel = assetManager.registerModel(RenderUtils.createParticleModel());
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import electrosphere.game.server.saves.SaveUtils;
|
|||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.main.Main;
|
import electrosphere.main.Main;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
import electrosphere.renderer.ui.ClickableElement;
|
import electrosphere.renderer.ui.ClickableElement;
|
||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
@ -537,21 +538,42 @@ public class MenuGenerators {
|
|||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
||||||
|
//text entry (port)
|
||||||
|
TextInput modelDebugInput = new TextInput(100,150, 40*5, 40);
|
||||||
|
scrollable.addChild(modelDebugInput);
|
||||||
|
modelDebugInput.setText("Model path goes here");
|
||||||
|
modelDebugInput.setOnFocus(new FocusEventCallback() {public boolean execute(FocusEvent event) {
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
modelDebugInput.setOnLoseFocus(new FocusEventCallback() {public boolean execute(FocusEvent event) {
|
||||||
|
return false;
|
||||||
|
}});
|
||||||
|
|
||||||
//label 2 (quit)
|
//label 2 (quit)
|
||||||
Button quitButton = new Button();
|
Button quitButton = new Button();
|
||||||
Label quitLabel = new Label(100,150,fontSize);
|
Label quitLabel = new Label(100,250,fontSize);
|
||||||
quitLabel.setText("debug or smthn");
|
quitLabel.setText("Print Model Debug Info");
|
||||||
quitButton.addChild(quitLabel);
|
quitButton.addChild(quitLabel);
|
||||||
scrollable.addChild(quitButton);
|
scrollable.addChild(quitButton);
|
||||||
quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||||
// Main.running = false;
|
// Main.running = false;
|
||||||
|
Model targetModel = null;
|
||||||
|
if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){
|
||||||
|
targetModel.describeHighLevel();
|
||||||
|
} else {
|
||||||
|
Globals.assetManager.addModelPathToQueue(modelDebugInput.getText());
|
||||||
|
Globals.assetManager.loadAssetsInQueue();
|
||||||
|
if((targetModel = Globals.assetManager.fetchModel(modelDebugInput.getText())) != null){
|
||||||
|
targetModel.describeHighLevel();
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}});
|
}});
|
||||||
|
|
||||||
for(int i = 0; i < 10; i++){
|
for(int i = 0; i < 9; i++){
|
||||||
Button someButton = new Button();
|
Button someButton = new Button();
|
||||||
Label someLabel = new Label(100,250 + i * 100,fontSize);
|
Label someLabel = new Label(100,350 + i * 100,fontSize);
|
||||||
someLabel.setText("aaaaaa" + i);
|
someLabel.setText("aaaaaa" + i);
|
||||||
someButton.addChild(someLabel);
|
someButton.addChild(someLabel);
|
||||||
scrollable.addChild(someButton);
|
scrollable.addChild(someButton);
|
||||||
|
|||||||
@ -797,9 +797,9 @@ public class RenderUtils {
|
|||||||
m.nodeID = AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME;
|
m.nodeID = AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME;
|
||||||
|
|
||||||
Material uiMat = new Material();
|
Material uiMat = new Material();
|
||||||
Globals.assetManager.addTexturePathtoQueue("/Textures/Fonts/myfont1-harsher.png");
|
Globals.assetManager.addTexturePathtoQueue("/Textures/Fonts/myfont2.png");
|
||||||
uiMat.set_diffuse("/Textures/Fonts/myfont1-harsher.png");
|
uiMat.set_diffuse("/Textures/Fonts/myfont2.png");
|
||||||
uiMat.set_specular("/Textures/Fonts/myfont1-harsher.png");
|
uiMat.set_specular("/Textures/Fonts/myfont2.png");
|
||||||
m.setMaterial(uiMat);
|
m.setMaterial(uiMat);
|
||||||
rVal.materials = new ArrayList<Material>();
|
rVal.materials = new ArrayList<Material>();
|
||||||
rVal.materials.add(uiMat);
|
rVal.materials.add(uiMat);
|
||||||
|
|||||||
@ -8,7 +8,9 @@ import electrosphere.renderer.framebuffer.Framebuffer;
|
|||||||
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
||||||
import electrosphere.renderer.texture.Texture;
|
import electrosphere.renderer.texture.Texture;
|
||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
|
import electrosphere.renderer.ui.FocusableElement;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
|
import electrosphere.renderer.ui.events.FocusEvent;
|
||||||
import electrosphere.renderer.ui.font.FontUtils;
|
import electrosphere.renderer.ui.font.FontUtils;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||||
@ -18,7 +20,7 @@ import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
|||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
*/
|
*/
|
||||||
public class TextInput implements DrawableElement {
|
public class TextInput implements DrawableElement, FocusableElement {
|
||||||
|
|
||||||
Framebuffer widgetBuffer;
|
Framebuffer widgetBuffer;
|
||||||
Material customMat = new Material();
|
Material customMat = new Material();
|
||||||
@ -35,6 +37,10 @@ public class TextInput implements DrawableElement {
|
|||||||
|
|
||||||
int linePaddingHorizonal = 2;
|
int linePaddingHorizonal = 2;
|
||||||
int linePaddingVertical = 5;
|
int linePaddingVertical = 5;
|
||||||
|
|
||||||
|
boolean focused = false;
|
||||||
|
FocusEventCallback onFocusCallback = null;
|
||||||
|
FocusEventCallback onLoseFocusCallback = null;
|
||||||
|
|
||||||
Vector3f color = new Vector3f(0,0,0);
|
Vector3f color = new Vector3f(0,0,0);
|
||||||
|
|
||||||
@ -82,7 +88,6 @@ public class TextInput implements DrawableElement {
|
|||||||
public void setWidth(int width) {
|
public void setWidth(int width) {
|
||||||
float ndcWidth = (float)width/(float)parentWidth;
|
float ndcWidth = (float)width/(float)parentWidth;
|
||||||
boxDimensions.x = ndcWidth;
|
boxDimensions.x = ndcWidth;
|
||||||
System.out.println(ndcWidth);
|
|
||||||
Framebuffer newBuffer = FramebufferUtils.generateTextureFramebuffer(width, height);
|
Framebuffer newBuffer = FramebufferUtils.generateTextureFramebuffer(width, height);
|
||||||
Framebuffer oldBuffer = widgetBuffer;
|
Framebuffer oldBuffer = widgetBuffer;
|
||||||
widgetBuffer = newBuffer;
|
widgetBuffer = newBuffer;
|
||||||
@ -217,7 +222,34 @@ public class TextInput implements DrawableElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean handleEvent(Event event){
|
public boolean handleEvent(Event event){
|
||||||
return true;
|
boolean propagate = true;
|
||||||
|
if(event instanceof FocusEvent){
|
||||||
|
this.focused = ((FocusEvent)event).isFocused();
|
||||||
|
if(this.focused && onFocusCallback != null){
|
||||||
|
propagate = onFocusCallback.execute((FocusEvent)event);
|
||||||
|
} else if(!this.focused && onLoseFocusCallback != null){
|
||||||
|
propagate = onLoseFocusCallback.execute((FocusEvent)event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return propagate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocused() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnFocus(FocusEventCallback callback) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
onFocusCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnLoseFocus(FocusEventCallback callback) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
onLoseFocusCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user