Moved and added a bunch of stuff
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package game.ui.console;
|
||||
|
||||
import engine.enums.CVarFlag;
|
||||
import game.ui.text.TextFormats;
|
||||
import assets.Fonts;
|
||||
import openfl.Lib;
|
||||
@@ -11,11 +10,12 @@ import openfl.display.Sprite;
|
||||
import openfl.Assets;
|
||||
import openfl.text.TextFormat;
|
||||
import openfl.text.TextFieldType;
|
||||
import engine.typedefs.CVar;
|
||||
import engine.ConVar;
|
||||
import engine.typedefs.CCmd;
|
||||
import engine.enums.console.CVarFlag;
|
||||
import engine.typedefs.console.CVar;
|
||||
import engine.typedefs.console.CCmd;
|
||||
import game.ui.console.elements.ConsoleInput;
|
||||
|
||||
import engine.ui.UIPane;
|
||||
|
||||
|
||||
class Console extends Sprite{
|
||||
@@ -161,16 +161,22 @@ class Console extends Sprite{
|
||||
}
|
||||
public function execCommands(commands:Array<Array<String>>){
|
||||
for(command in commands){
|
||||
// Store command name, value and args
|
||||
var cName:String = command[0];
|
||||
var cValue:String = command[1];
|
||||
var cArgs:Array<String> = command.slice(1);
|
||||
//Check if convar with that name actually exists
|
||||
if(ConVar.isCVar(cName)){
|
||||
//Get reference to convar object
|
||||
var cv:CVar = ConVar.getCVar(command[0]);
|
||||
//Check number of params
|
||||
if(command.length == 1){
|
||||
//No params after the cmd, print help string
|
||||
devMsg(cv.name+" - "+cv.helpString);
|
||||
devMsg(cv.name+" = "+cv.value);
|
||||
}
|
||||
else{
|
||||
//Check for convar type and set value accordingly
|
||||
switch(cv.type){
|
||||
case CInt:
|
||||
ConVar.setCVar(cName,Std.parseInt(cValue));
|
||||
@@ -196,9 +202,11 @@ class Console extends Sprite{
|
||||
}
|
||||
|
||||
}
|
||||
//convar is actually a command, run it.
|
||||
else if(ConVar.isCmd(cName)){
|
||||
ConVar.runCmd(cName,cArgs);
|
||||
}
|
||||
//convar doesn't exist
|
||||
else{
|
||||
devMsg("unkown command: "+command[0]);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package game.ui.console;
|
||||
|
||||
import engine.HProfiler;
|
||||
import engine.ui.UIPane;
|
||||
import engine.ui.UIElement;
|
||||
import openfl.text.TextField;
|
||||
import openfl.display3D.textures.Texture;
|
||||
import openfl.display.Sprite;
|
||||
@@ -29,7 +31,7 @@ class ConsolePane extends Sprite{
|
||||
testPane.addChild(titlebarPane);
|
||||
testPane.addChild(inputPane);
|
||||
testPane.addChild(outputPane);
|
||||
|
||||
|
||||
|
||||
|
||||
var textField:TextField = new TextField();
|
||||
@@ -39,10 +41,20 @@ class ConsolePane extends Sprite{
|
||||
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);
|
||||
var inputButtonPane:UIPane = new UIPane("submit button", {height: 32, width: 32});
|
||||
inputButtonPane.align = END;
|
||||
|
||||
var inputFieldPane:UIPane = new UIPane("input field", {height: 32, width: 3});
|
||||
inputFieldPane.align = START;
|
||||
inputFieldPane.dimensions.expandBehavior = STRETCH;
|
||||
|
||||
inputPane.addChild(inputButtonPane);
|
||||
inputPane.addChild(inputFieldPane);
|
||||
//inputFieldPane.addChild(testInputElement);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user