Просмотр исходного кода

hook PrototypeClass(%objectName) on up to inspector
fix dialog close, fix dynamic variable gui element alignment

AzaezelX 1 год назад
Родитель
Сommit
c10808873d

+ 13 - 2
Engine/source/console/simObject.cpp

@@ -40,6 +40,7 @@
 #include "core/fileObject.h"
 #include "persistence/taml/tamlCustom.h"
 #include "gui/editor/guiInspector.h"
+#include "console/script.h"
 
 #include "sim/netObject.h"
 
@@ -90,7 +91,7 @@ SimObject::SimObject()
    mNameSpace    = NULL;
    mNotifyList   = NULL;
    mFlags.set( ModStaticFields | ModDynamicFields );
-
+   mPrototype = true;
    mProgenitorFile = StringTable->EmptyString();
 
    mFieldDictionary = NULL;
@@ -159,7 +160,8 @@ void SimObject::initPersistFields()
 
       addProtectedField("inheritFrom", TypeString, Offset(mInheritFrom, SimObject), &setInheritFrom, &defaultProtectedGetFn,
          "Optional Name of object to inherit from as a parent.");
-                  
+
+      addProtectedField("Prototype", TypeBool, Offset(mPrototype, SimObject), &_doPrototype, &defaultProtectedGetFn, "Prototype Methods", AbstractClassRep::FieldFlags::FIELD_ComponentInspectors);
    endGroup( "Ungrouped" );
 
    addGroup( "Object" );
@@ -212,6 +214,15 @@ void SimObject::initPersistFields()
 }
 
 //-----------------------------------------------------------------------------
+bool SimObject::_doPrototype(void* object, const char* index, const char* data)
+{
+   if (!Con::isFunction("PrototypeClass")) return false;
+   if (dAtoi(data) != 1) return false;
+   SimObject* obj = reinterpret_cast<SimObject*>(object);
+   String command = String("PrototypeClass(") + (obj->getName()? String(obj->getName()) : String::ToString(obj->getId())) + ");";
+   Con::evaluate(command.c_str());
+   return false;
+}
 
 String SimObject::describeSelf() const
 {

+ 2 - 2
Engine/source/console/simObject.h

@@ -300,7 +300,7 @@ class SimObject: public ConsoleObject, public TamlCallbacks
       SimObject*       nextIdObject;
 
       StringTableEntry mInheritFrom;
-
+      bool    mPrototype;
       /// SimGroup we're contained in, if any.
       SimGroup*   mGroup;
       
@@ -388,7 +388,7 @@ class SimObject: public ConsoleObject, public TamlCallbacks
    public:
       inline void setProgenitorFile(const char* pFile) { mProgenitorFile = StringTable->insert(pFile); }
       inline StringTableEntry getProgenitorFile(void) const { return mProgenitorFile; }
-
+      static bool _doPrototype(void* object, const char* index, const char* data);
    protected:
       /// Taml callbacks.
       virtual void onTamlPreWrite(void) {}

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

@@ -15,7 +15,7 @@ $guiContent = new GuiControl(classPrototyping) {
       vertSizing = "center";
       profile = "ToolsGuiWindowProfile";
       tooltipProfile = "GuiToolTipProfile";
-
+      closeCommand = "Canvas.popDialog(classPrototyping);";
       new GuiScrollCtrl() {
          lockVertScroll = "1";
          position = "14 30";
@@ -112,8 +112,8 @@ $guiContent = new GuiControl(classPrototyping) {
       };
       new GuiCheckBoxCtrl(ReportDynamicVariables) {
          text = "Report Dynamic Variables";
-         position = "250 420";
-         extent = "125 30";
+         position = "300 420";
+         extent = "150 30";
          profile = "ToolsGuiCheckBoxProfile";
          tooltipProfile = "GuiToolTipProfile";
       };