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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user