various changes
This commit is contained in:
@@ -34,9 +34,14 @@ class Console extends Sprite{
|
||||
|
||||
consoleInstance = this;
|
||||
|
||||
|
||||
graphics.beginFill(0x555555);
|
||||
graphics.drawRect(0,0,800,600);
|
||||
|
||||
var consolePane:UIPane = new UIPane("yeeto",{width:800, height:600});
|
||||
|
||||
this.addChild(consolePane.sprite);
|
||||
consolePane.layout = VERTICAL;
|
||||
|
||||
//graphics.beginFill(0x555555);
|
||||
//graphics.drawRect(0,0,800,600);
|
||||
|
||||
cInput = new ConsoleInput();
|
||||
cIn = cInput.tf;
|
||||
@@ -51,6 +56,21 @@ class Console extends Sprite{
|
||||
},false,false,0,0,false);
|
||||
|
||||
cOut = new TextField();
|
||||
cAutoComp = new TextField();
|
||||
|
||||
drawFields(cOut, cAutoComp);
|
||||
|
||||
|
||||
cOut.addEventListener(Event.CHANGE, onOutputTextChange);
|
||||
cIn.addEventListener(Event.CHANGE, onInputTextChange);
|
||||
this.addChild(cOut);
|
||||
this.addChild(cInput);
|
||||
this.addChild(cAutoComp);
|
||||
ConVar.registerCCmd("echo", (args:Array<String>) -> { Console.devMsg(args.join(" ").split('"').join(""));});
|
||||
ConVar.registerCCmd("quit", (args:Array<String>) -> { Lib.application.window.close();});
|
||||
}
|
||||
public function drawFields(cOut:TextField, cAutoComp:TextField){
|
||||
|
||||
cOut.text = "hConsole Initialized\n";
|
||||
cOut.defaultTextFormat = TextFormats.getFormats().cOutputFmt;
|
||||
cOut.wordWrap = true;
|
||||
@@ -63,7 +83,6 @@ class Console extends Sprite{
|
||||
cOut.y = 12;
|
||||
cOut.x = 12;
|
||||
|
||||
cAutoComp = new TextField();
|
||||
cAutoComp.text = "";
|
||||
cAutoComp.defaultTextFormat = TextFormats.getFormats().cInputFmt;
|
||||
cAutoComp.wordWrap = false;
|
||||
@@ -78,19 +97,9 @@ class Console extends Sprite{
|
||||
cAutoComp.visible = false;
|
||||
cAutoComp.x = 0;
|
||||
cAutoComp.y = 600;
|
||||
|
||||
|
||||
|
||||
cOut.addEventListener(Event.CHANGE, onOutputTextChange);
|
||||
cIn.addEventListener(Event.CHANGE, onInputTextChange);
|
||||
//cOut.addEventListener()
|
||||
this.addChild(cOut);
|
||||
this.addChild(cInput);
|
||||
this.addChild(cAutoComp);
|
||||
//ConVar.registerCVar("echo", CVarType.CCmd, null, devMsg())
|
||||
ConVar.registerCCmd("echo", (args:Array<String>) -> { Console.devMsg(args.join(" ").split('"').join(""));});
|
||||
ConVar.registerCCmd("quit", (args:Array<String>) -> { Lib.application.window.close();});
|
||||
}
|
||||
|
||||
|
||||
public function parseCmd(cmd:String, bNoHist:Bool = false){
|
||||
if(!bNoHist)
|
||||
history.push(cmd);
|
||||
@@ -196,9 +205,9 @@ class Console extends Sprite{
|
||||
}
|
||||
}
|
||||
public function submitInput(){
|
||||
cOut.appendText(">"+cIn.text+"\n");
|
||||
parseCmd(cIn.text);
|
||||
cIn.text = "";
|
||||
cOut.appendText(">"+cInput.getText()+"\n");
|
||||
parseCmd(cInput.getText());
|
||||
cInput.setText("");
|
||||
cAutoComp.visible = false;
|
||||
cOut.scrollV = cOut.maxScrollV;
|
||||
histSelect = -1;
|
||||
@@ -207,7 +216,7 @@ class Console extends Sprite{
|
||||
cOut.scrollV = cOut.maxScrollV;
|
||||
}
|
||||
public function onInputTextChange(e:Event){
|
||||
if(cIn.text != ""){
|
||||
if(cInput.getText() != ""){
|
||||
cAutoComp.text = "";
|
||||
for(string in (autocompleteList = getCompList())){
|
||||
cAutoComp.text += string+"\n";
|
||||
@@ -245,7 +254,7 @@ class Console extends Sprite{
|
||||
public static function getCompList():Array<String>
|
||||
{
|
||||
// Split words
|
||||
var inp:Array<String> = consoleInstance.cIn.text.split(" ");
|
||||
var inp:Array<String> = consoleInstance.cInput.getText().split(" ");
|
||||
var inpStripped:Array<String> = [
|
||||
for(word in inp){
|
||||
if(word != "" && word != " "){
|
||||
@@ -292,9 +301,9 @@ class Console extends Sprite{
|
||||
public static function histPrev():Void
|
||||
{
|
||||
// Only complete if input field is empty or scrolling through hist
|
||||
if(consoleInstance.cIn.text == "" || histSelect != -1){
|
||||
if(consoleInstance.cInput.getText() == "" || histSelect != -1){
|
||||
// Store current input in tmpInput
|
||||
if(histSelect == -1) tmpInput = consoleInstance.cIn.text;
|
||||
if(histSelect == -1) tmpInput = consoleInstance.cInput.getText();
|
||||
// Only go through history if history is not empty
|
||||
if(history.length != 0){
|
||||
// Check if currently selecting a history entry
|
||||
@@ -308,11 +317,11 @@ class Console extends Sprite{
|
||||
}
|
||||
if(histSelect != -1){
|
||||
// Put correct history entry in the input field
|
||||
consoleInstance.cIn.text = history[histSelect];
|
||||
consoleInstance.cInput.setText(history[histSelect]);
|
||||
}
|
||||
else{
|
||||
// Restore tmp input
|
||||
consoleInstance.cIn.text = tmpInput;
|
||||
consoleInstance.cInput.setText(tmpInput);
|
||||
}
|
||||
}
|
||||
// History is empty
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package game.ui.console;
|
||||
|
||||
import engine.HProfiler;
|
||||
import openfl.text.TextField;
|
||||
import openfl.display3D.textures.Texture;
|
||||
import openfl.display.Sprite;
|
||||
|
||||
class ConsolePane extends Sprite{
|
||||
public function new(){
|
||||
super();
|
||||
var testPane:UIPane = new UIPane("test",{height:800,width:600});
|
||||
testPane.layout = VERTICAL;
|
||||
|
||||
var titlebarPane:UIPane = new UIPane("titlebar", {height:32, width: 600});
|
||||
titlebarPane.align = START;
|
||||
titlebarPane.layout = HORIZONTAL;
|
||||
|
||||
var inputPane:UIPane = new UIPane("inputbar", {height:32, width: 600});
|
||||
inputPane.align = END;
|
||||
inputPane.layout = HORIZONTAL;
|
||||
|
||||
var outputPane:UIPane = new UIPane("output pane", {height: 32, width: 600});
|
||||
outputPane.align = START;
|
||||
outputPane.dimensions.expandBehavior = STRETCH;
|
||||
HProfiler.startProfiling("ui_resize");
|
||||
testPane.width = 1000;
|
||||
HProfiler.stopProfiling("ui_resize");
|
||||
|
||||
testPane.addChild(titlebarPane);
|
||||
testPane.addChild(inputPane);
|
||||
testPane.addChild(outputPane);
|
||||
|
||||
|
||||
|
||||
var textField:TextField = new TextField();
|
||||
textField.background = true;
|
||||
textField.backgroundColor = 0x00ff00;
|
||||
|
||||
var testInputElement:UIElement = new UIElement("inputelem", {height: 32, width: 300},textField);
|
||||
testInputElement.dimensions.expandBehavior = STRETCH;
|
||||
testInputElement.padding = {x: 8, y: 8};
|
||||
var inputFieldPane:UIPane = new UIPane("input field", {height: 32, width: 3});
|
||||
var inputButtonPane:UIPane = new UIPane("submit button", {height: 32, width: 32});
|
||||
|
||||
inputPane.addChild(testInputElement);
|
||||
|
||||
|
||||
|
||||
addChild(testPane.sprite);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user