mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Merge remote-tracking branch 'upstream/development' into imageAsset_refactor_rev3
This commit is contained in:
commit
e1c01cd49a
152 changed files with 7312 additions and 4132 deletions
|
|
@ -178,3 +178,17 @@ void CppAsset::onAssetRefresh(void)
|
|||
|
||||
mHeaderPath = getOwned() ? expandAssetFilePath(mHeaderFile) : mHeaderPath;
|
||||
}
|
||||
|
||||
DefineEngineMethod(CppAsset, getCodePath, const char*, (), ,
|
||||
"Gets the code file filepath of this asset.\n"
|
||||
"@return File path of the code file.")
|
||||
{
|
||||
return object->getCppFilePath();
|
||||
}
|
||||
|
||||
DefineEngineMethod(CppAsset, getHeaderPath, const char*, (), ,
|
||||
"Gets the header file filepath of this asset.\n"
|
||||
"@return File path of the header file.")
|
||||
{
|
||||
return object->getHeaderFilePath();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public:
|
|||
void setHeaderFile(const char* pHeaderFile);
|
||||
inline StringTableEntry getHeaderFile(void) const { return mHeaderFile; };
|
||||
|
||||
inline StringTableEntry getCppFilePath(void) const { return mCodePath; };
|
||||
inline StringTableEntry getHeaderFilePath(void) const { return mHeaderPath; };
|
||||
|
||||
protected:
|
||||
void initializeAsset(void) override;
|
||||
void onAssetRefresh(void) override;
|
||||
|
|
@ -73,9 +76,6 @@ protected:
|
|||
static bool setCppFile(void *obj, const char *index, const char *data) { static_cast<CppAsset*>(obj)->setCppFile(data); return false; }
|
||||
static const char* getCppFile(void* obj, const char* data) { return static_cast<CppAsset*>(obj)->getCppFile(); }
|
||||
|
||||
inline StringTableEntry getCppFilePath(void) const { return mCodePath; };
|
||||
inline StringTableEntry getHeaderFilePath(void) const { return mHeaderPath; };
|
||||
|
||||
static bool setHeaderFile(void *obj, const char *index, const char *data) { static_cast<CppAsset*>(obj)->setHeaderFile(data); return false; }
|
||||
static const char* getHeaderFile(void* obj, const char* data) { return static_cast<CppAsset*>(obj)->getHeaderFile(); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ ConsoleSetType(TypeLevelAssetId)
|
|||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
|
||||
LevelAsset::LevelAsset() : AssetBase()
|
||||
{
|
||||
mLevelName = StringTable->EmptyString();
|
||||
mLevelFile = StringTable->EmptyString();
|
||||
|
|
@ -117,7 +117,6 @@ LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
|
|||
mNavmeshPath = StringTable->EmptyString();
|
||||
|
||||
mGameModesNames = StringTable->EmptyString();
|
||||
mMainLevelAsset = StringTable->EmptyString();
|
||||
|
||||
mEditorFile = StringTable->EmptyString();
|
||||
mBakedSceneFile = StringTable->EmptyString();
|
||||
|
|
@ -158,7 +157,6 @@ void LevelAsset::initPersistFields()
|
|||
addProtectedField("BakedSceneFile", TypeAssetLooseFilePath, Offset(mBakedSceneFile, LevelAsset),
|
||||
&setBakedSceneFile, &getBakedSceneFile, "Path to the level file with the objects generated as part of the baking process");
|
||||
|
||||
addField("isSubScene", TypeBool, Offset(mIsSubLevel, LevelAsset), "Is this a sublevel to another Scene");
|
||||
addField("gameModesNames", TypeString, Offset(mGameModesNames, LevelAsset), "Name of the Game Mode to be used with this level");
|
||||
}
|
||||
|
||||
|
|
@ -481,15 +479,8 @@ GuiControl* GuiInspectorTypeLevelAssetPtr::constructEditControl()
|
|||
// Create "Open in Editor" button
|
||||
mEditButton = new GuiBitmapButtonCtrl();
|
||||
|
||||
String setSubSceneValue = "$createLevelAssetIsSubScene = \"\";";
|
||||
if(dynamic_cast<SubScene*>(mInspector->getInspectObject()) != NULL)
|
||||
{
|
||||
setSubSceneValue = "$createLevelAssetIsSubScene = true;";
|
||||
}
|
||||
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "$createAndAssignField = %s; %s AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule, \"createAndAssignLevelAsset\");",
|
||||
getIdString(),
|
||||
setSubSceneValue.c_str());
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "$createAndAssignField = %s; AssetBrowser.setupCreateNewAsset(\"LevelAsset\", AssetBrowser.selectedModule, \"createAndAssignLevelAsset\");",
|
||||
getIdString());
|
||||
mEditButton->setField("Command", szBuffer);
|
||||
|
||||
char bitmapName[512] = "ToolsModule:iconAdd_image";
|
||||
|
|
|
|||
|
|
@ -66,9 +66,6 @@ class LevelAsset : public AssetBase
|
|||
StringTableEntry mEditorFile;
|
||||
StringTableEntry mBakedSceneFile;
|
||||
|
||||
bool mIsSubLevel;
|
||||
StringTableEntry mMainLevelAsset;
|
||||
|
||||
StringTableEntry mGameModesNames;
|
||||
|
||||
Vector<AssetBase*> mAssetDependencies;
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ public: \
|
|||
|
||||
#pragma region Arrayed Asset Macros
|
||||
|
||||
#define DECLARE_SHAPEASSET_ARRAY(className,name,max) public: \
|
||||
#define DECLARE_SHAPEASSET_ARRAY(className,name,max,changeFunc) public: \
|
||||
static const U32 sm##name##Count = max;\
|
||||
Resource<TSShape>m##name[max];\
|
||||
StringTableEntry m##name##Name[max]; \
|
||||
|
|
@ -384,6 +384,10 @@ public: \
|
|||
\
|
||||
bool _set##name(StringTableEntry _in, const U32& index)\
|
||||
{\
|
||||
if (m##name##Asset[index].notNull())\
|
||||
{\
|
||||
m##name##Asset[index]->getChangedSignal().remove(this, &className::changeFunc);\
|
||||
}\
|
||||
if(m##name##AssetId[index] != _in || m##name##Name[index] != _in)\
|
||||
{\
|
||||
if(index >= sm##name##Count || index < 0)\
|
||||
|
|
@ -430,6 +434,8 @@ public: \
|
|||
if (get##name(index) != StringTable->EmptyString() && m##name##Asset[index].notNull())\
|
||||
{\
|
||||
m##name[index] = m##name##Asset[index]->getShapeResource();\
|
||||
\
|
||||
m##name##Asset[index]->getChangedSignal().notify(this, &className::changeFunc);\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
|
|
|
|||
166
Engine/source/T3D/assets/SubSceneAsset.cpp
Normal file
166
Engine/source/T3D/assets/SubSceneAsset.cpp
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
#include "SubSceneAsset.h"
|
||||
|
||||
#include "T3D/SubScene.h"
|
||||
IMPLEMENT_CONOBJECT(SubSceneAsset);
|
||||
|
||||
|
||||
ConsoleType(SubSceneAssetPtr, TypeSubSceneAssetPtr, const char*, "")
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleGetType(TypeSubSceneAssetPtr)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
return *((const char**)(dptr));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleSetType(TypeSubSceneAssetPtr)
|
||||
{
|
||||
// Was a single argument specified?
|
||||
if (argc == 1)
|
||||
{
|
||||
// Yes, so fetch field value.
|
||||
*((const char**)dptr) = StringTable->insert(argv[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Warn.
|
||||
Con::warnf("(TypeSubSceneAssetPtr) - Cannot set multiple args to a single asset.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
ConsoleType(assetIdString, TypeSubSceneAssetId, const char*, "")
|
||||
|
||||
ConsoleGetType(TypeSubSceneAssetId)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
return *((const char**)(dptr));
|
||||
}
|
||||
|
||||
ConsoleSetType(TypeSubSceneAssetId)
|
||||
{
|
||||
// Was a single argument specified?
|
||||
if (argc == 1)
|
||||
{
|
||||
*((const char**)dptr) = StringTable->insert(argv[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Warn.
|
||||
Con::warnf("(TypeSubSceneAssetId) - Cannot set multiple args to a single asset.");
|
||||
}
|
||||
|
||||
SubSceneAsset::SubSceneAsset() : LevelAsset()
|
||||
{
|
||||
}
|
||||
|
||||
SubSceneAsset::~SubSceneAsset()
|
||||
{
|
||||
}
|
||||
|
||||
void SubSceneAsset::initPersistFields()
|
||||
{
|
||||
docsURL;
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GuiInspectorTypeAssetId
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiInspectorTypeSubSceneAssetPtr);
|
||||
|
||||
ConsoleDocClass(GuiInspectorTypeSubSceneAssetPtr,
|
||||
"@brief Inspector field type for Shapes\n\n"
|
||||
"Editor use only.\n\n"
|
||||
"@internal"
|
||||
);
|
||||
|
||||
void GuiInspectorTypeSubSceneAssetPtr::consoleInit()
|
||||
{
|
||||
Parent::consoleInit();
|
||||
|
||||
ConsoleBaseType::getType(TypeSubSceneAssetPtr)->setInspectorFieldType("GuiInspectorTypeSubSceneAssetPtr");
|
||||
}
|
||||
|
||||
GuiControl* GuiInspectorTypeSubSceneAssetPtr::constructEditControl()
|
||||
{
|
||||
// Create base filename edit controls
|
||||
GuiControl* retCtrl = Parent::constructEditControl();
|
||||
if (retCtrl == NULL)
|
||||
return retCtrl;
|
||||
|
||||
// Change filespec
|
||||
char szBuffer[512];
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"SubSceneAsset\", \"AssetBrowser.changeAsset\", %s, \"\");",
|
||||
getIdString());
|
||||
mBrowseButton->setField("Command", szBuffer);
|
||||
|
||||
setDataField(StringTable->insert("targetObject"), NULL, mInspector->getInspectObject()->getIdString());
|
||||
|
||||
// Create "Open in Editor" button
|
||||
mEditButton = new GuiBitmapButtonCtrl();
|
||||
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "$createAndAssignField = %s; AssetBrowser.setupCreateNewAsset(\"SubSceneAsset\", AssetBrowser.selectedModule);",
|
||||
getIdString());
|
||||
mEditButton->setField("Command", szBuffer);
|
||||
|
||||
char bitmapName[512] = "ToolsModule:iconAdd_image";
|
||||
mEditButton->setBitmap(StringTable->insert(bitmapName));
|
||||
|
||||
mEditButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||
mEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||
mEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||
mEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Test play this sound");
|
||||
|
||||
mEditButton->registerObject();
|
||||
addObject(mEditButton);
|
||||
|
||||
return retCtrl;
|
||||
}
|
||||
|
||||
bool GuiInspectorTypeSubSceneAssetPtr::updateRects()
|
||||
{
|
||||
S32 dividerPos, dividerMargin;
|
||||
mInspector->getDivider(dividerPos, dividerMargin);
|
||||
Point2I fieldExtent = getExtent();
|
||||
Point2I fieldPos = getPosition();
|
||||
|
||||
mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
|
||||
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
|
||||
|
||||
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||
if (mBrowseButton != NULL)
|
||||
{
|
||||
mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
|
||||
resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
|
||||
}
|
||||
|
||||
if (mEditButton != NULL)
|
||||
{
|
||||
RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
|
||||
resized |= mEditButton->resize(shapeEdRect.point, shapeEdRect.extent);
|
||||
}
|
||||
|
||||
return resized;
|
||||
}
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiInspectorTypeSubSceneAssetId);
|
||||
|
||||
ConsoleDocClass(GuiInspectorTypeSubSceneAssetId,
|
||||
"@brief Inspector field type for SubScene\n\n"
|
||||
"Editor use only.\n\n"
|
||||
"@internal"
|
||||
);
|
||||
|
||||
void GuiInspectorTypeSubSceneAssetId::consoleInit()
|
||||
{
|
||||
Parent::consoleInit();
|
||||
|
||||
ConsoleBaseType::getType(TypeSubSceneAssetId)->setInspectorFieldType("GuiInspectorTypeSubSceneAssetId");
|
||||
}
|
||||
113
Engine/source/T3D/assets/SubSceneAsset.h
Normal file
113
Engine/source/T3D/assets/SubSceneAsset.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#pragma once
|
||||
#ifndef SUBSCENE_ASSET_H
|
||||
#define SUBSCENE_ASSET_H
|
||||
|
||||
#ifndef LEVEL_ASSET_H
|
||||
#include "LevelAsset.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_DEFINITION_H_
|
||||
#include "assets/assetDefinition.h"
|
||||
#endif
|
||||
|
||||
#ifndef _GUI_INSPECTOR_TYPES_H_
|
||||
#include "gui/editor/guiInspectorTypes.h"
|
||||
#endif
|
||||
|
||||
class SubSceneAsset : public LevelAsset
|
||||
{
|
||||
typedef LevelAsset Parent;
|
||||
|
||||
public:
|
||||
SubSceneAsset();
|
||||
virtual ~SubSceneAsset();
|
||||
|
||||
/// Engine.
|
||||
static void initPersistFields();
|
||||
|
||||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(SubSceneAsset);
|
||||
};
|
||||
|
||||
#ifdef TORQUE_TOOLS
|
||||
class GuiInspectorTypeSubSceneAssetPtr : public GuiInspectorTypeFileName
|
||||
{
|
||||
typedef GuiInspectorTypeFileName Parent;
|
||||
public:
|
||||
|
||||
GuiBitmapButtonCtrl* mEditButton;
|
||||
|
||||
DECLARE_CONOBJECT(GuiInspectorTypeSubSceneAssetPtr);
|
||||
static void consoleInit();
|
||||
|
||||
GuiControl* constructEditControl() override;
|
||||
bool updateRects() override;
|
||||
};
|
||||
|
||||
class GuiInspectorTypeSubSceneAssetId : public GuiInspectorTypeSubSceneAssetPtr
|
||||
{
|
||||
typedef GuiInspectorTypeSubSceneAssetPtr Parent;
|
||||
public:
|
||||
|
||||
DECLARE_CONOBJECT(GuiInspectorTypeSubSceneAssetId);
|
||||
static void consoleInit();
|
||||
};
|
||||
#endif
|
||||
|
||||
DefineConsoleType(TypeSubSceneAssetPtr, SubSceneAsset)
|
||||
DefineConsoleType(TypeSubSceneAssetId, String)
|
||||
|
||||
#pragma region Singular Asset Macros
|
||||
|
||||
//Singular assets
|
||||
/// <Summary>
|
||||
/// Declares an SubScene asset
|
||||
/// This establishes the assetId, asset and legacy filepath fields, along with supplemental getter and setter functions
|
||||
/// </Summary>
|
||||
#define DECLARE_SUBSCENEASSET(className, name, changeFunc) public: \
|
||||
StringTableEntry m##name##AssetId;\
|
||||
AssetPtr<SubSceneAsset> m##name##Asset;\
|
||||
public: \
|
||||
const AssetPtr<SubSceneAsset> & get##name##Asset() const { return m##name##Asset; }\
|
||||
void set##name##Asset(const AssetPtr<SubSceneAsset> &_in) { m##name##Asset = _in;}\
|
||||
\
|
||||
bool _set##name(StringTableEntry _in)\
|
||||
{\
|
||||
if(m##name##AssetId != _in)\
|
||||
{\
|
||||
if (m##name##Asset.notNull())\
|
||||
{\
|
||||
m##name##Asset->getChangedSignal().remove(this, &className::changeFunc);\
|
||||
}\
|
||||
if (_in == NULL || _in == StringTable->EmptyString())\
|
||||
{\
|
||||
m##name##AssetId = StringTable->EmptyString();\
|
||||
m##name##Asset = NULL;\
|
||||
return true;\
|
||||
}\
|
||||
if (AssetDatabase.isDeclaredAsset(_in))\
|
||||
{\
|
||||
m##name##AssetId = _in;\
|
||||
m##name##Asset = _in;\
|
||||
return true;\
|
||||
}\
|
||||
}\
|
||||
\
|
||||
if(get##name() == StringTable->EmptyString())\
|
||||
return true;\
|
||||
\
|
||||
return false;\
|
||||
}\
|
||||
\
|
||||
const StringTableEntry get##name() const\
|
||||
{\
|
||||
return m##name##AssetId;\
|
||||
}\
|
||||
bool name##Valid() {return (get##name() != StringTable->EmptyString() && m##name##Asset->getStatus() == AssetBase::Ok); }
|
||||
|
||||
#define INITPERSISTFIELD_SUBSCENEASSET(name, consoleClass, docs) \
|
||||
addProtectedField(assetText(name, Asset), TypeSubSceneAssetId, Offset(m##name##AssetId, consoleClass), _set##name##Data, &defaultProtectedGetFn, assetDoc(name, asset docs.));
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#endif // SUBSCENE_ASSET_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue