diff --git a/hGameTest/project.xml b/hGameTest/project.xml
index 17e79d3b..e52a3878 100644
--- a/hGameTest/project.xml
+++ b/hGameTest/project.xml
@@ -15,6 +15,10 @@
+
+
+
+
@@ -24,6 +28,6 @@
-
+
+
\ No newline at end of file
diff --git a/hGameTest/src/engine/ConVars_Engine.hx b/hGameTest/src/engine/ConVars_Engine.hx
new file mode 100644
index 00000000..2c623779
--- /dev/null
+++ b/hGameTest/src/engine/ConVars_Engine.hx
@@ -0,0 +1,36 @@
+package engine;
+
+import game.video.Mode;
+import haxe.macro.Expr.Field;
+import engine.typedefs.console.CVar;
+import engine.typedefs.console.CCmd;
+import engine.enums.console.CVarType;
+import engine.enums.console.CVarFlag;
+import engine.macros.CCmdDecorator;
+import game.ui.console.Console;
+
+@:keep
+// @:build(engine.macros.CCmdDecorator.build()) // No longer needed because we added the build macro to the project.xml
+class ConVars_Engine {
+
+ @:command("list")
+ public static function listCommands(args:Array) {
+ var CVarMap:Map = ConVar.getCVarMap();
+ var keys:Array = ConVar.getCVarNames();
+ for(key in keys){
+ if(CVarMap[key] != null){
+ Console.devMsg(key+" "+ CVarMap[key].value);
+ }
+ else{
+ Console.devMsg(key);
+ }
+ }
+ }
+
+ @:command("test")
+ public static function testCommand() {
+ // Command implementation
+ trace("Test Output");
+ }
+
+}
\ No newline at end of file
diff --git a/hGameTest/src/engine/macros/CCmdDecorator.hx b/hGameTest/src/engine/macros/CCmdDecorator.hx
new file mode 100644
index 00000000..a54d4a75
--- /dev/null
+++ b/hGameTest/src/engine/macros/CCmdDecorator.hx
@@ -0,0 +1,46 @@
+package engine.macros;
+
+import haxe.macro.Expr;
+import haxe.macro.Context;
+
+class CCmdDecorator {
+ public static macro function build():Array {
+ var fields = Context.getBuildFields();
+ var pos = Context.currentPos();
+
+ for (field in fields) {
+ var meta = field.meta != null ? Lambda.find(field.meta, function(m) return m.name == ":command") : null;
+ if (meta != null) {
+ trace(meta);
+ switch field.kind {
+ case FFun(f):
+ var name = meta.params.length > 0
+ ? switch(meta.params[0].expr) {
+ case EConst(CString(s)): s;
+ case _: field.name;
+ }
+ : field.name;
+
+ // Create a static initializer field
+ var initField = {
+ name: "__init__" + name,
+ access: [AStatic, APrivate],
+ kind: FVar(null, macro {
+ engine.ConVar.registerCCmd($v{name}, function(args:Array) {
+ ${f.expr};
+ });
+ }),
+ pos: pos,
+ doc: null,
+ meta: []
+ };
+
+ // Add the initializer field
+ fields.push(initField);
+ case _:
+ }
+ }
+ }
+ return fields;
+ }
+}
\ No newline at end of file
diff --git a/hGameTest/src/game/video/Mode.hx b/hGameTest/src/game/video/Mode.hx
index 5b1d2bf5..bebf6b94 100644
--- a/hGameTest/src/game/video/Mode.hx
+++ b/hGameTest/src/game/video/Mode.hx
@@ -15,9 +15,10 @@ class Mode
public static function setVideoMode(width:Int, height:Int, fs:Int = null){
getWindow().resize(width,height);
}
- public static var cvMatSetVideoMode:CCmd = ConVar.registerCCmd("mat_setvideomode",(args:Array)->{
- setVideoMode(Std.parseInt(args[0]), Std.parseInt(args[1]), Std.parseInt(args[2]));
- });
+ @:command("mat_setvideomode")
+ public static function cCmdMatSetVideoMode(args:Array){
+ Mode.setVideoMode(Std.parseInt(args[0]), Std.parseInt(args[1]), Std.parseInt(args[2]));
+ }
public static function switchFsMode(toState:Int = 0){
if(toState == 0){
if(Lib.current.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){