hook PrototypeClass(%objectName) on up to inspector

fix dialog close, fix dynamic variable gui element alignment
This commit is contained in:
AzaezelX 2023-11-24 15:44:54 -06:00
parent 81b721c755
commit c10808873d
3 changed files with 18 additions and 7 deletions

View file

@ -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
{

View file

@ -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) {}

View file

@ -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";
};