2
0
Эх сурвалжийг харах

wipwork for adding a gui driven class callback method prototyper with command and variable reporting

AzaezelX 1 жил өмнө
parent
commit
81b721c755

+ 3 - 0
Templates/BaseGame/game/data/Prototyping/Prototyping.tscript

@@ -37,6 +37,9 @@ function Prototyping::onDestroyGameServer(%this)
 //This is called when the client is initially set up by the game application
 function Prototyping::initClient(%this)
 {
+   //class method prototyping
+   %this.queueExec("./UI/classPrototyping");
+   %this.queueExec("./UI/classPrototyping.gui");
 }
 
 //This is called when a client connects to a server

+ 5 - 0
Templates/BaseGame/game/data/Prototyping/UI/classPrototyping.asset.taml

@@ -0,0 +1,5 @@
+<GUIAsset
+    AssetName="classPrototyping"
+    ScriptFile="@assetFile=classPrototyping.tscript"
+    GUIFile="@assetFile=classPrototyping.gui"
+    VersionId="1"/>

+ 122 - 0
Templates/BaseGame/game/data/Prototyping/UI/classPrototyping.gui

@@ -0,0 +1,122 @@
+//--- OBJECT WRITE BEGIN ---
+$guiContent = new GuiControl(classPrototyping) {
+   extent = "1024 768";
+   profile = "GuiDefaultProfile";
+   tooltipProfile = "GuiToolTipProfile";
+   isContainer = "1";
+   canSaveDynamicFields = "1";
+      originalAssetName = "classPrototyping";
+
+   new GuiWindowCtrl() {
+      text = "Class Prototyping";
+      position = "216 124";
+      extent = "592 519";
+      horizSizing = "center";
+      vertSizing = "center";
+      profile = "ToolsGuiWindowProfile";
+      tooltipProfile = "GuiToolTipProfile";
+
+      new GuiScrollCtrl() {
+         lockVertScroll = "1";
+         position = "14 30";
+         extent = "564 33";
+         profile = "ToolsGuiScrollProfile";
+         tooltipProfile = "GuiToolTipProfile";
+
+         new GuiDynamicCtrlArrayControl(ClassInheritanceListCtrl) {
+            colCount = "1";
+            colSize = "80";
+            rowCount = "1";
+            rowSize = "18";
+            autoCellSize = "1";
+            fillRowFirst = "0";
+            dynamicSize = "1";
+            position = "1 1";
+            extent = "400 18";
+            profile = "GuiDefaultProfile";
+            tooltipProfile = "GuiToolTipProfile";
+         };
+      };
+      new GuiTextCtrl() {
+         text = "Callbacks";
+         position = "24 66";
+         extent = "54 14";
+         profile = "ToolsGuiTextProfile";
+         tooltipProfile = "GuiToolTipProfile";
+      };
+      new GuiScrollCtrl() {
+         position = "19 80";
+         extent = "552 326";
+         profile = "ToolsGuiScrollProfile";
+         tooltipProfile = "GuiToolTipProfile";
+
+         new GuiDynamicCtrlArrayControl(ClassMethodListCtrl) {
+            colCount = "1";
+            colSize = "8000";
+            rowCount = "1";
+            rowSize = "18";
+            dynamicSize = "1";
+            extent = "552 326";
+            profile = "GuiDefaultProfile";
+            tooltipProfile = "GuiToolTipProfile";
+         };
+      };
+      new GuiBitmapButtonCtrl() {
+         BitmapAsset = "ToolsModule:iconOpen_image";
+         bitmapMode = "Centered";
+         position = "348 467";
+         extent = "22 22";
+         horizSizing = "left";
+         profile = "ToolsGuiButtonProfile";
+         command = "SelectAssetPath.showDialog(AssetBrowser.dirHandler.currentAddress, \"setAssetTargetUpdatePath\");\nSelectAssetPathWindow.selectWindow();";
+         tooltipProfile = "GuiToolTipProfile";
+         tooltip = "New Module";
+      };
+      new GuiTextEditCtrl() {
+         text = "data/ExampleModule";
+         position = "143 470";
+         extent = "201 20";
+         horizSizing = "width";
+         profile = "ToolsGuiTextEditProfile";
+         active = "0";
+         tooltipProfile = "GuiToolTipProfile";
+         internalName = "targetPath";
+      };
+      new GuiTextCtrl() {
+         text = "Target Path:";
+         position = "20 470";
+         extent = "116 17";
+         profile = "ToolsGuiTextProfile";
+         tooltipProfile = "GuiToolTipProfile";
+      };
+      new GuiButtonCtrl() {
+         text = "Save";
+         position = "431 465";
+         profile = "ToolsGuiButtonProfile";
+         command = "classPrototyping.writeResults();";
+         tooltipProfile = "GuiToolTipProfile";
+      };
+      new GuiCheckBoxCtrl(ReportCommands) {
+         text = "Report Commands";
+         position = "16 420";
+         extent = "125 30";
+         profile = "ToolsGuiCheckBoxProfile";
+         tooltipProfile = "GuiToolTipProfile";
+      };
+      new GuiCheckBoxCtrl(ReportVariables) {
+         text = "Report Stock Variables";
+         position = "152 420";
+         extent = "125 30";
+         profile = "ToolsGuiCheckBoxProfile";
+         tooltipProfile = "GuiToolTipProfile";
+      };
+      new GuiCheckBoxCtrl(ReportDynamicVariables) {
+         text = "Report Dynamic Variables";
+         position = "250 420";
+         extent = "125 30";
+         profile = "ToolsGuiCheckBoxProfile";
+         tooltipProfile = "GuiToolTipProfile";
+      };
+   };
+};
+//--- OBJECT WRITE END ---

+ 142 - 0
Templates/BaseGame/game/data/Prototyping/UI/classPrototyping.tscript

@@ -0,0 +1,142 @@
+function classPrototyping::onWake(%this)
+{
+    
+}
+
+function classPrototyping::onSleep(%this)
+{
+    
+}
+//PrototypeClass(MainMenuGui)
+//PrototypeClass(GuiChunkedBitmapCtrl)
+function PrototypeClass(%classInstance)
+{
+    Canvas.pushDialog(classPrototyping);
+    classPrototyping.fillClasslist(%classInstance);
+    classPrototyping.SetNamespaceUsed(%classInstance);
+}
+
+function classPrototyping::fillClasslist(%this, %classInstance)
+{
+    ClassInheritanceListCtrl.deleteAllObjects();
+    %this.inst = %classInstance;
+    %this.instanceName = %classInstance.getName();
+    
+    //get potentially scripted namespaces
+    %class = %classInstance.getClassName();    
+    %prepend = %classInstance.getName();
+    if (%classInstance.class !$= "")
+        %prepend = %prepend SPC %classInstance.class;        
+    if (%classInstance.superclass !$= "")
+        %prepend = %prepend SPC %classInstance.superclass;
+        
+    //append to hardcoded potential namespaces
+    %this.classlist = %prepend SPC getClassHierarchy(%class);
+    %this.classCount = getWordCount(%this.classlist);
+    for (%i=0; %i<%this.classCount; %i++)
+    {
+        %inheritanceOrder = %this.classCount-(%i+1);
+        %className = getWord(%this.classlist,%inheritanceOrder);
+        if (%i<%this.classCount-1)
+            %className = %className @"->";
+        %elemClass = new GuiRadioCtrl("ProtoClassSelect"@ %i) {
+               text = %className;
+               entry = strreplace(%className,"->","");
+               groupNum = "1";
+               extent = "80 18";
+               profile = "ToolsGuiRadioProfile";
+               tooltipProfile = "GuiToolTipProfile";
+               };
+        eval("function ProtoClassSelect"@ %i @"::onClick(%this){classPrototyping.SetNamespaceUsed(%this.entry);}");
+        ClassInheritanceListCtrl.addGuiControl(%elemClass);
+    }
+    %lastElem = "ProtoClassSelect"@ %this.classCount-1;
+    %lastElem.setStateOn(true);
+}
+
+function classPrototyping::SetNamespaceUsed(%this, %nameSpaceUsed)
+{
+    ClassMethodListCtrl.deleteAllObjects();
+    if (%nameSpaceUsed $= %this.instanceName)
+    {
+        %this.tempClass = %this.inst;
+        %this.fillMethodlist(%this.inst);
+        return;
+    }
+    eval("classPrototyping.tempClass = new "@ %nameSpaceUsed @"(){};");
+    %this.fillMethodlist(%this.tempClass);    
+}
+
+function classPrototyping::fillMethodlist(%this, %classInstance)
+{
+    ClassMethodListCtrl.deleteAllObjects();
+
+    %this.methodArray = %classInstance.getMethodSigs();
+    %this.methodCount = %this.methodArray.count();
+    
+    for (%i=0; %i<%this.methodCount; %i++)
+    {
+         %methodDef = getRecord(%this.methodArray.getValue(%i),0);
+         %methodName = strreplace(%methodDef,"::"," ");
+         %methodName = getWord(strreplace(%methodName,"("," "),2);
+         
+        %elemMethod = new GuiCheckBoxCtrl("ProtoMethodSelect"@ %i) {
+            text = %methodName;
+            position = "1 1";
+            profile = "ToolsGuiCheckBoxProfile";
+            tooltipProfile = "GuiToolTipProfile";
+         };
+        ClassMethodListCtrl.addGuiControl(%elemMethod);
+    }
+}
+
+function classPrototyping::writeResults(%this)
+{
+    %namespaceUsed = "";
+    for (%i=0; %i<%this.classCount; %i++)
+    {
+        %inheritanceOrder = %this.classCount-(%i+1);
+        %obj = "ProtoClassSelect"@ %i;
+        if (%obj.isStateOn())
+            %namespaceUsed = getWord(%this.classlist,%inheritanceOrder);
+    }
+    echo(%namespaceUsed);
+    for (%i=0; %i<%this.methodCount; %i++)
+    {
+        %obj = "ProtoMethodSelect"@ %i;
+        if (%obj.isStateOn())
+            echo(strreplace(%this.methodArray.getValue(%i),%this.instanceName,%namespaceUsed));
+    }
+    
+    if (ReportCommands.isStateOn())
+    {
+        %this.commandArray = %this.tempClass.getMethodSigs(true);
+        %this.commandCount = %this.commandArray.count();
+        echo("/* Available Commands:");
+        for (%i=0; %i< %this.commandCount; %i++)
+        {
+            echo(getRecord(%this.commandArray.getValue(%i),0));
+        }
+        echo("*/");
+    }
+    
+    if (ReportVariables.isStateOn())
+    {
+        echo("/* HardCoded Variables");
+        for (%i=0; %i< %this.tempClass.getFieldCount(); %i++)
+        {
+            echo(%this.tempClass.getField(%i));
+        }
+        echo("*/");
+    }
+    
+    if (ReportDynamicVariables.isStateOn())
+    {
+        echo("/* Dynamic Variables");
+        for (%i=0; %i< %this.tempClass.getDynamicFieldCount(); %i++)
+        {
+            echo(getword(%this.tempClass.getDynamicField(%i),0));
+        }
+        echo("*/");
+    }
+}