changed a bunch of fucking shit
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package game.ui;
|
||||
|
||||
|
||||
typedef CVar = {
|
||||
var name:String;
|
||||
var type:CVarType;
|
||||
var value:Dynamic;
|
||||
@:optional var callback:Void -> Void;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
package game.ui;
|
||||
|
||||
enum CVarType {
|
||||
CInt;
|
||||
CFloat;
|
||||
CString;
|
||||
CBool;
|
||||
CCmd;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package game.ui;
|
||||
|
||||
import game.ui.CVar;
|
||||
import game.ui.CVarType;
|
||||
|
||||
|
||||
class ConVar{
|
||||
static var CVarMap:Map<String, CVar> = [];
|
||||
public static inline function registerCVar(_name:String, _type:CVarType, _value, _callback:Void->Void,_callOnSet:Bool=false)
|
||||
{
|
||||
if(CVarMap[_name]!=null){
|
||||
|
||||
return;
|
||||
}
|
||||
CVarMap[_name] = {
|
||||
name : _name,
|
||||
type : _type,
|
||||
value : _value,
|
||||
callback : _callback == null ? ()->{} : _callback
|
||||
}
|
||||
}
|
||||
public static inline function setCVar(_name:String, _value:Dynamic)
|
||||
{
|
||||
if(CVarMap[_name] != null){
|
||||
CVarMap[_name] = _value;
|
||||
}
|
||||
else{
|
||||
Console.consoleIndex.devMsg("trying to set null convar '"+_name+"'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package game.ui;
|
||||
|
||||
import openfl.events.Event;
|
||||
import openfl.text.TextFieldAutoSize;
|
||||
import openfl.text.TextField;
|
||||
import openfl.display.Sprite;
|
||||
import openfl.Assets;
|
||||
import openfl.text.TextFormat;
|
||||
import openfl.text.TextFieldType;
|
||||
|
||||
class Console extends Sprite{
|
||||
|
||||
public var textFormat:TextFormat;
|
||||
public var cOut:TextField;
|
||||
public var cIn:TextField;
|
||||
public static var consoleIndex:Console;
|
||||
public function new(){
|
||||
super();
|
||||
|
||||
consoleIndex = this;
|
||||
|
||||
graphics.beginFill(0x111111);
|
||||
graphics.drawRect(0,0,800,600);
|
||||
|
||||
textFormat = new TextFormat(Assets.getFont("fonts/Terminus.ttf").fontName, 24, 0x00ff00);
|
||||
|
||||
|
||||
|
||||
cIn = new TextField();
|
||||
cIn.type = TextFieldType.INPUT;
|
||||
cIn.text = "b";
|
||||
cIn.multiline = false;
|
||||
//cIn.autoSize = TextFieldAutoSize.LEFT;
|
||||
cIn.width = 800-24;
|
||||
cIn.height = 32;
|
||||
|
||||
cIn.background = true;
|
||||
cIn.backgroundColor = 0x000000;
|
||||
cIn.selectable = true;
|
||||
cIn.setTextFormat(textFormat);
|
||||
cIn.y = 600-cIn.height-12;
|
||||
cIn.x = 12;
|
||||
|
||||
cOut = new TextField();
|
||||
cOut.text = "hConsole Initialized\n";
|
||||
cOut.setTextFormat(textFormat);
|
||||
//cOut.autoSize = TextFieldAutoSize.LEFT;
|
||||
cOut.multiline = true;
|
||||
cOut.background = true;
|
||||
cOut.backgroundColor = 0x000000;
|
||||
cOut.width = 800 - 24;
|
||||
cOut.height = 600 - cIn.height - 38;
|
||||
cOut.y = 12;
|
||||
cOut.x = 12;
|
||||
|
||||
|
||||
cOut.addEventListener(Event.CHANGE, onOutputTextChange);
|
||||
//cOut.addEventListener()
|
||||
this.addChild(cOut);
|
||||
this.addChild(cIn);
|
||||
}
|
||||
public function parseCmd(cmd:String){
|
||||
var parts:Array<String> = cmd.split(" ");
|
||||
}
|
||||
public function submitInput(){
|
||||
parseCmd(cIn.text);
|
||||
cOut.appendText(">"+cIn.text+"\n");
|
||||
cIn.text = "";
|
||||
cOut.scrollV = cOut.maxScrollV;
|
||||
}
|
||||
public function onOutputTextChange(e:Event){
|
||||
cOut.scrollV = cOut.maxScrollV;
|
||||
}
|
||||
public function devMsg(msg:String):Void
|
||||
{
|
||||
cOut.appendText(msg+"\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user