mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Merge branch 'ExpandedAssetsPR' of https://github.com/Areloch/Torque3D into development
This commit is contained in:
commit
ace58e2c28
73 changed files with 4468 additions and 1876 deletions
|
|
@ -124,7 +124,8 @@ void ComponentAsset::initPersistFields()
|
|||
addField("componentType", TypeString, Offset(mComponentType, ComponentAsset), "The category of the component for organizing in the editor.");
|
||||
addField("description", TypeString, Offset(mDescription, ComponentAsset), "Simple description of the component.");
|
||||
|
||||
addField("scriptFile", TypeString, Offset(mScriptFile, ComponentAsset), "A script file with additional scripted functionality for this component.");
|
||||
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, ComponentAsset),
|
||||
&setScriptFile, &getScriptFile, "A script file with additional scripted functionality for this component.");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -137,12 +138,35 @@ void ComponentAsset::copyTo(SimObject* object)
|
|||
|
||||
void ComponentAsset::initializeAsset()
|
||||
{
|
||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||
|
||||
if(Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void ComponentAsset::onAssetRefresh()
|
||||
{
|
||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentAsset::setScriptFile(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,9 +77,15 @@ public:
|
|||
|
||||
AssetDefinition* getAssetDefinition() { return mpAssetDefinition; }
|
||||
|
||||
void setScriptFile(const char* pScriptFile);
|
||||
inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<ComponentAsset*>(obj)->setScriptFile(data); return false; }
|
||||
static const char* getScriptFile(void* obj, const char* data) { return static_cast<ComponentAsset*>(obj)->getScriptFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeComponentAssetPtr, ComponentAsset)
|
||||
|
|
|
|||
167
Engine/source/T3D/assets/CppAsset.cpp
Normal file
167
Engine/source/T3D/assets/CppAsset.cpp
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2013 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CPP_ASSET_H
|
||||
#include "CppAsset.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_MANAGER_H_
|
||||
#include "assets/assetManager.h"
|
||||
#endif
|
||||
|
||||
#ifndef _CONSOLETYPES_H_
|
||||
#include "console/consoleTypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _TAML_
|
||||
#include "persistence/taml/taml.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_PTR_H_
|
||||
#include "assets/assetPtr.h"
|
||||
#endif
|
||||
|
||||
// Debug Profiling.
|
||||
#include "platform/profiler.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CONOBJECT(CppAsset);
|
||||
|
||||
ConsoleType(CppAssetPtr, TypeCppAssetPtr, CppAsset, ASSET_ID_FIELD_PREFIX)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleGetType(TypeCppAssetPtr)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
return (*((AssetPtr<CppAsset>*)dptr)).getAssetId();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleSetType(TypeCppAssetPtr)
|
||||
{
|
||||
// Was a single argument specified?
|
||||
if (argc == 1)
|
||||
{
|
||||
// Yes, so fetch field value.
|
||||
const char* pFieldValue = argv[0];
|
||||
|
||||
// Fetch asset pointer.
|
||||
AssetPtr<CppAsset>* pAssetPtr = dynamic_cast<AssetPtr<CppAsset>*>((AssetPtrBase*)(dptr));
|
||||
|
||||
// Is the asset pointer the correct type?
|
||||
if (pAssetPtr == NULL)
|
||||
{
|
||||
// No, so fail.
|
||||
//Con::warnf("(TypeCppAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set asset.
|
||||
pAssetPtr->setAssetId(pFieldValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Warn.
|
||||
Con::warnf("(TypeCppAssetPtr) - Cannot set multiple args to a single asset.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CppAsset::CppAsset() : AssetBase()
|
||||
{
|
||||
mCodeFile = StringTable->EmptyString();
|
||||
mHeaderFile = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CppAsset::~CppAsset()
|
||||
{
|
||||
// If the asset manager does not own the asset then we own the
|
||||
// asset definition so delete it.
|
||||
if (!getOwned())
|
||||
delete mpAssetDefinition;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CppAsset::initPersistFields()
|
||||
{
|
||||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addProtectedField("codeFile", TypeAssetLooseFilePath, Offset(mCodeFile, CppAsset),
|
||||
&setCppFile, &getCppFile, "Path to the cpp file.");
|
||||
|
||||
addProtectedField("headerFile", TypeAssetLooseFilePath, Offset(mHeaderFile, CppAsset),
|
||||
&setHeaderFile, &getHeaderFile, "Path to the h file.");
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void CppAsset::copyTo(SimObject* object)
|
||||
{
|
||||
// Call to parent.
|
||||
Parent::copyTo(object);
|
||||
}
|
||||
|
||||
void CppAsset::setCppFile(const char* pCppFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pCppFile != NULL, "Cannot use a NULL code file.");
|
||||
|
||||
// Fetch image file.
|
||||
pCppFile = StringTable->insert(pCppFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pCppFile == mCodeFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mCodeFile = getOwned() ? expandAssetFilePath(pCppFile) : StringTable->insert(pCppFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void CppAsset::setHeaderFile(const char* pHeaderFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pHeaderFile != NULL, "Cannot use a NULL header file.");
|
||||
|
||||
// Fetch image file.
|
||||
pHeaderFile = StringTable->insert(pHeaderFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pHeaderFile == mHeaderFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mHeaderFile = getOwned() ? expandAssetFilePath(pHeaderFile) : StringTable->insert(pHeaderFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
81
Engine/source/T3D/assets/CppAsset.h
Normal file
81
Engine/source/T3D/assets/CppAsset.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2013 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef CPP_ASSET_H
|
||||
#define CPP_ASSET_H
|
||||
#pragma once
|
||||
|
||||
#ifndef _ASSET_BASE_H_
|
||||
#include "assets/assetBase.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_DEFINITION_H_
|
||||
#include "assets/assetDefinition.h"
|
||||
#endif
|
||||
|
||||
#ifndef _STRINGUNIT_H_
|
||||
#include "string/stringUnit.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_FIELD_TYPES_H_
|
||||
#include "assets/assetFieldTypes.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CppAsset : public AssetBase
|
||||
{
|
||||
typedef AssetBase Parent;
|
||||
|
||||
StringTableEntry mCodeFile;
|
||||
StringTableEntry mHeaderFile;
|
||||
|
||||
public:
|
||||
CppAsset();
|
||||
virtual ~CppAsset();
|
||||
|
||||
/// Engine.
|
||||
static void initPersistFields();
|
||||
virtual void copyTo(SimObject* object);
|
||||
|
||||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(CppAsset);
|
||||
|
||||
void setCppFile(const char* pCppFile);
|
||||
inline StringTableEntry getCppFile(void) const { return mCodeFile; };
|
||||
|
||||
void setHeaderFile(const char* pHeaderFile);
|
||||
inline StringTableEntry getHeaderFile(void) const { return mHeaderFile; };
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void) {};
|
||||
virtual void onAssetRefresh(void) {};
|
||||
|
||||
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(); }
|
||||
|
||||
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(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeCppAssetPtr, CppAsset)
|
||||
|
||||
#endif // _ASSET_BASE_H_
|
||||
|
||||
|
|
@ -92,8 +92,8 @@ ConsoleSetType(TypeGUIAssetPtr)
|
|||
|
||||
GUIAsset::GUIAsset()
|
||||
{
|
||||
mScriptFilePath = StringTable->EmptyString();
|
||||
mGUIFilePath = StringTable->EmptyString();
|
||||
mScriptFile = StringTable->EmptyString();
|
||||
mGUIFile = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -113,8 +113,11 @@ void GUIAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("scriptFilePath", TypeString, Offset(mScriptFilePath, GUIAsset), "Path to the script file for the gui");
|
||||
addField("GUIFilePath", TypeString, Offset(mGUIFilePath, GUIAsset), "Path to the gui file");
|
||||
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, GUIAsset),
|
||||
&setScriptFile, &getScriptFile, "Path to the script file for the gui");
|
||||
|
||||
addProtectedField("GUIFile", TypeAssetLooseFilePath, Offset(mGUIFile, GUIAsset),
|
||||
&setScriptFile, &getScriptFile, "Path to the gui file");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -127,20 +130,66 @@ void GUIAsset::copyTo(SimObject* object)
|
|||
|
||||
void GUIAsset::initializeAsset()
|
||||
{
|
||||
if (Platform::isFile(mGUIFilePath))
|
||||
Con::executeFile(mGUIFilePath, false, false);
|
||||
mGUIFile = expandAssetFilePath(mGUIFile);
|
||||
|
||||
if (Platform::isFile(mScriptFilePath))
|
||||
Con::executeFile(mScriptFilePath, false, false);
|
||||
if (Platform::isFile(mGUIFile))
|
||||
Con::executeFile(mGUIFile, false, false);
|
||||
|
||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void GUIAsset::onAssetRefresh()
|
||||
{
|
||||
if (Platform::isFile(mGUIFilePath))
|
||||
Con::executeFile(mGUIFilePath, false, false);
|
||||
mGUIFile = expandAssetFilePath(mGUIFile);
|
||||
|
||||
if (Platform::isFile(mScriptFilePath))
|
||||
Con::executeFile(mScriptFilePath, false, false);
|
||||
if (Platform::isFile(mGUIFile))
|
||||
Con::executeFile(mGUIFile, false, false);
|
||||
|
||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void GUIAsset::setGUIFile(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL gui file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mGUIFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mGUIFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void GUIAsset::setScriptFile(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ class GUIAsset : public AssetBase
|
|||
{
|
||||
typedef AssetBase Parent;
|
||||
|
||||
StringTableEntry mScriptFilePath;
|
||||
StringTableEntry mGUIFilePath;
|
||||
StringTableEntry mScriptFile;
|
||||
StringTableEntry mGUIFile;
|
||||
|
||||
public:
|
||||
GUIAsset();
|
||||
|
|
@ -60,9 +60,19 @@ public:
|
|||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(GUIAsset);
|
||||
|
||||
void setGUIFile(const char* pScriptFile);
|
||||
inline StringTableEntry getGUIFile(void) const { return mGUIFile; };
|
||||
void setScriptFile(const char* pScriptFile);
|
||||
inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setGUIFile(void *obj, const char *index, const char *data) { static_cast<GUIAsset*>(obj)->setGUIFile(data); return false; }
|
||||
static const char* getGUIFile(void* obj, const char* data) { return static_cast<GUIAsset*>(obj)->getGUIFile(); }
|
||||
static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<GUIAsset*>(obj)->setScriptFile(data); return false; }
|
||||
static const char* getScriptFile(void* obj, const char* data) { return static_cast<GUIAsset*>(obj)->getScriptFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeGUIAssetPtr, GUIAsset)
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ ConsoleSetType(TypeGameObjectAssetPtr)
|
|||
|
||||
GameObjectAsset::GameObjectAsset()
|
||||
{
|
||||
mGameObjectName = StringTable->lookup("");
|
||||
mScriptFilePath = StringTable->lookup("");
|
||||
mTAMLFilePath = StringTable->lookup("");
|
||||
mGameObjectName = StringTable->EmptyString();
|
||||
mScriptFile = StringTable->EmptyString();
|
||||
mTAMLFile = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -115,8 +115,11 @@ void GameObjectAsset::initPersistFields()
|
|||
Parent::initPersistFields();
|
||||
|
||||
addField("gameObjectName", TypeString, Offset(mGameObjectName, GameObjectAsset), "Name of the game object. Defines the created object's class.");
|
||||
addField("scriptFilePath", TypeString, Offset(mScriptFilePath, GameObjectAsset), "Path to the script file for the GameObject's script code.");
|
||||
addField("TAMLFilePath", TypeString, Offset(mTAMLFilePath, GameObjectAsset), "Path to the taml file for the GameObject's heirarchy.");
|
||||
|
||||
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, GameObjectAsset),
|
||||
&setScriptFile, &getScriptFile, "Path to the script file for the GameObject's script code.");
|
||||
addProtectedField("TAMLFile", TypeAssetLooseFilePath, Offset(mTAMLFile, GameObjectAsset),
|
||||
&setTAMLFile, &getTAMLFile, "Path to the taml file for the GameObject's heirarchy.");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -129,14 +132,98 @@ void GameObjectAsset::copyTo(SimObject* object)
|
|||
|
||||
void GameObjectAsset::initializeAsset()
|
||||
{
|
||||
if (Platform::isFile(mScriptFilePath))
|
||||
Con::executeFile(mScriptFilePath, false, false);
|
||||
//Ensure we have an expanded filepath
|
||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void GameObjectAsset::onAssetRefresh()
|
||||
{
|
||||
if (Platform::isFile(mScriptFilePath))
|
||||
Con::executeFile(mScriptFilePath, false, false);
|
||||
//Ensure we have an expanded filepath
|
||||
mScriptFile = expandAssetFilePath(mScriptFile);
|
||||
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void GameObjectAsset::setScriptFile(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
|
||||
void GameObjectAsset::setTAMLFile(const char* pTAMLFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pTAMLFile != NULL, "Cannot use a NULL TAML file.");
|
||||
|
||||
// Fetch image file.
|
||||
pTAMLFile = StringTable->insert(pTAMLFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pTAMLFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mTAMLFile = getOwned() ? expandAssetFilePath(pTAMLFile) : StringTable->insert(pTAMLFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
|
||||
const char* GameObjectAsset::create()
|
||||
{
|
||||
if (!Platform::isFile(mTAMLFile))
|
||||
return "";
|
||||
|
||||
// Set the format mode.
|
||||
Taml taml;
|
||||
|
||||
// Yes, so set it.
|
||||
taml.setFormatMode(Taml::getFormatModeEnum("xml"));
|
||||
|
||||
// Turn-off auto-formatting.
|
||||
taml.setAutoFormat(false);
|
||||
|
||||
// Read object.
|
||||
SimObject* pSimObject = taml.read(mTAMLFile);
|
||||
|
||||
// Did we find the object?
|
||||
if (pSimObject == NULL)
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf("GameObjectAsset::create() - Could not read object from file '%s'.", mTAMLFile);
|
||||
return "";
|
||||
}
|
||||
|
||||
//Flag it so we know where it came from
|
||||
pSimObject->setDataField("GameObject", nullptr, getAssetId());
|
||||
|
||||
return pSimObject->getIdString();
|
||||
}
|
||||
|
||||
DefineEngineMethod(GameObjectAsset, createObject, const char*, (),,
|
||||
"Creates an instance of the given GameObject given the asset definition.\n"
|
||||
"@return The GameObject entity created from the asset.")
|
||||
{
|
||||
return object->create();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -160,35 +247,50 @@ void GuiInspectorTypeGameObjectAssetPtr::consoleInit()
|
|||
|
||||
GuiControl* GuiInspectorTypeGameObjectAssetPtr::constructEditControl()
|
||||
{
|
||||
// Create base filename edit controls
|
||||
GuiControl *retCtrl = Parent::constructEditControl();
|
||||
if (retCtrl == NULL)
|
||||
return retCtrl;
|
||||
// Create "Open in ShapeEditor" button
|
||||
mGameObjectEditButton = new GuiButtonCtrl();
|
||||
|
||||
// Change filespec
|
||||
char szBuffer[512];
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"GameObjectAsset\", \"AssetBrowser.changeAsset\", %d, %s);",
|
||||
mInspector->getComponentGroupTargetId(), mCaption);
|
||||
mBrowseButton->setField("Command", szBuffer);
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "%d.onClick(%s);", this->getId(), mCaption);
|
||||
mGameObjectEditButton->setField("Command", szBuffer);
|
||||
|
||||
// Create "Open in ShapeEditor" button
|
||||
mSMEdButton = new GuiBitmapButtonCtrl();
|
||||
mGameObjectEditButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||
mGameObjectEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||
mGameObjectEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "echo(\"Game Object Editor not implemented yet!\");", retCtrl->getId());
|
||||
mSMEdButton->setField("Command", szBuffer);
|
||||
const char* assetId = getData();
|
||||
|
||||
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
||||
mSMEdButton->setBitmap(bitmapName);
|
||||
if (assetId == "")
|
||||
{
|
||||
mGameObjectEditButton->setText("Create Game Object");
|
||||
|
||||
mSMEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||
mSMEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||
mSMEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||
mSMEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the State Machine Editor");
|
||||
mGameObjectEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Convert this object into a reusable Game Object asset.");
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObjectAsset* goAsset = AssetDatabase.acquireAsset< GameObjectAsset>(assetId);
|
||||
|
||||
mSMEdButton->registerObject();
|
||||
addObject(mSMEdButton);
|
||||
if (goAsset)
|
||||
{
|
||||
mGameObjectEditButton->setText("Edit Game Object");
|
||||
|
||||
return retCtrl;
|
||||
mGameObjectEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Edit this object instance or Game Object asset.");
|
||||
}
|
||||
else
|
||||
{
|
||||
mGameObjectEditButton->setText("Create Game Object");
|
||||
|
||||
mGameObjectEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Convert this object into a reusable Game Object asset.");
|
||||
}
|
||||
}
|
||||
|
||||
//mGameObjectEditButton->registerObject();
|
||||
_registerEditControl(mGameObjectEditButton);
|
||||
|
||||
addObject(mGameObjectEditButton);
|
||||
|
||||
return mGameObjectEditButton;
|
||||
}
|
||||
|
||||
bool GuiInspectorTypeGameObjectAssetPtr::updateRects()
|
||||
|
|
@ -199,20 +301,13 @@ bool GuiInspectorTypeGameObjectAssetPtr::updateRects()
|
|||
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);
|
||||
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin, fieldExtent.y);
|
||||
|
||||
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||
if (mBrowseButton != NULL)
|
||||
if (mGameObjectEditButton != NULL)
|
||||
{
|
||||
mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
|
||||
resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
|
||||
}
|
||||
|
||||
if (mSMEdButton != NULL)
|
||||
{
|
||||
RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
|
||||
resized |= mSMEdButton->resize(shapeEdRect.point, shapeEdRect.extent);
|
||||
resized |= mGameObjectEditButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||
}
|
||||
|
||||
return resized;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ class GameObjectAsset : public AssetBase
|
|||
typedef AssetBase Parent;
|
||||
|
||||
StringTableEntry mGameObjectName;
|
||||
StringTableEntry mScriptFilePath;
|
||||
StringTableEntry mTAMLFilePath;
|
||||
StringTableEntry mScriptFile;
|
||||
StringTableEntry mTAMLFile;
|
||||
|
||||
public:
|
||||
GameObjectAsset();
|
||||
|
|
@ -59,12 +59,24 @@ public:
|
|||
static void initPersistFields();
|
||||
virtual void copyTo(SimObject* object);
|
||||
|
||||
const char* create();
|
||||
|
||||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(GameObjectAsset);
|
||||
|
||||
void setScriptFile(const char* pScriptFile);
|
||||
inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
|
||||
void setTAMLFile(const char* pScriptFile);
|
||||
inline StringTableEntry getTAMLFile(void) const { return mTAMLFile; };
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<GameObjectAsset*>(obj)->setScriptFile(data); return false; }
|
||||
static const char* getScriptFile(void* obj, const char* data) { return static_cast<GameObjectAsset*>(obj)->getScriptFile(); }
|
||||
static bool setTAMLFile(void *obj, const char *index, const char *data) { static_cast<GameObjectAsset*>(obj)->setTAMLFile(data); return false; }
|
||||
static const char* getTAMLFile(void* obj, const char* data) { return static_cast<GameObjectAsset*>(obj)->getTAMLFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeGameObjectAssetPtr, GameObjectAsset)
|
||||
|
|
@ -73,12 +85,12 @@ DefineConsoleType(TypeGameObjectAssetPtr, GameObjectAsset)
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeAssetId GuiInspectorField Class
|
||||
//-----------------------------------------------------------------------------
|
||||
class GuiInspectorTypeGameObjectAssetPtr : public GuiInspectorTypeFileName
|
||||
class GuiInspectorTypeGameObjectAssetPtr : public GuiInspectorField
|
||||
{
|
||||
typedef GuiInspectorTypeFileName Parent;
|
||||
typedef GuiInspectorField Parent;
|
||||
public:
|
||||
|
||||
GuiBitmapButtonCtrl *mSMEdButton;
|
||||
GuiButtonCtrl *mGameObjectEditButton;
|
||||
|
||||
DECLARE_CONOBJECT(GuiInspectorTypeGameObjectAssetPtr);
|
||||
static void consoleInit();
|
||||
|
|
|
|||
|
|
@ -108,7 +108,9 @@ void ImageAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("imageFile", TypeString, Offset(mImageFileName, ImageAsset), "Path to the image file.");
|
||||
addProtectedField("imageFile", TypeAssetLooseFilePath, Offset(mImageFileName, ImageAsset),
|
||||
&setImageFileName, &getImageFileName, "Path to the image file.");
|
||||
|
||||
addField("useMips", TypeBool, Offset(mUseMips, ImageAsset), "Should the image use mips? (Currently unused).");
|
||||
addField("isHDRImage", TypeBool, Offset(mIsHDRImage, ImageAsset), "Is the image in an HDR format? (Currently unused)");
|
||||
}
|
||||
|
|
@ -153,4 +155,23 @@ void ImageAsset::initializeAsset()
|
|||
void ImageAsset::onAssetRefresh()
|
||||
{
|
||||
loadImage();
|
||||
}
|
||||
}
|
||||
|
||||
void ImageAsset::setImageFileName(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL image file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mImageFileName)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mImageFileName = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ public:
|
|||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(ImageAsset);
|
||||
|
||||
StringTableEntry getImageFileName() { return mImageFileName; }
|
||||
void setImageFileName(const char* pScriptFile);
|
||||
inline StringTableEntry getImageFileName(void) const { return mImageFileName; };
|
||||
|
||||
bool isValid() { return mIsValidImage; }
|
||||
|
||||
|
|
@ -76,6 +77,9 @@ protected:
|
|||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setImageFileName(void *obj, const char *index, const char *data) { static_cast<ImageAsset*>(obj)->setImageFileName(data); return false; }
|
||||
static const char* getImageFileName(void* obj, const char* data) { return static_cast<ImageAsset*>(obj)->getImageFileName(); }
|
||||
|
||||
void loadImage();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ ConsoleSetType(TypeLevelAssetPtr)
|
|||
|
||||
LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
|
||||
{
|
||||
mLevelName = StringTable->EmptyString();
|
||||
mLevelFile = StringTable->EmptyString();
|
||||
mPreviewImage = StringTable->EmptyString();
|
||||
|
||||
|
|
@ -115,8 +116,11 @@ void LevelAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("LevelFile", TypeString, Offset(mLevelFile, LevelAsset), "Path to the actual level file.");
|
||||
addField("PreviewImage", TypeString, Offset(mPreviewImage, LevelAsset), "Path to the image used for selection preview.");
|
||||
addProtectedField("LevelFile", TypeAssetLooseFilePath, Offset(mLevelFile, LevelAsset),
|
||||
&setLevelFile, &getLevelFile, "Path to the actual level file.");
|
||||
addField("LevelName", TypeString, Offset(mLevelName, LevelAsset), "Human-friendly name for the level.");
|
||||
addProtectedField("PreviewImage", TypeAssetLooseFilePath, Offset(mPreviewImage, LevelAsset),
|
||||
&setPreviewImageFile, &getPreviewImageFile, "Path to the image used for selection preview.");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -125,4 +129,54 @@ void LevelAsset::copyTo(SimObject* object)
|
|||
{
|
||||
// Call to parent.
|
||||
Parent::copyTo(object);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void LevelAsset::initializeAsset()
|
||||
{
|
||||
// Call parent.
|
||||
Parent::initializeAsset();
|
||||
|
||||
// Ensure the image-file is expanded.
|
||||
mPreviewImage = expandAssetFilePath(mPreviewImage);
|
||||
mLevelFile = expandAssetFilePath(mLevelFile);
|
||||
}
|
||||
|
||||
//
|
||||
void LevelAsset::setLevelFile(const char* pLevelFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pLevelFile != NULL, "Cannot use a NULL level file.");
|
||||
|
||||
// Fetch image file.
|
||||
pLevelFile = StringTable->insert(pLevelFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pLevelFile == mLevelFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mLevelFile = getOwned() ? expandAssetFilePath(pLevelFile) : StringTable->insert(pLevelFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void LevelAsset::setImageFile(const char* pImageFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pImageFile != NULL, "Cannot use a NULL image file.");
|
||||
|
||||
// Fetch image file.
|
||||
pImageFile = StringTable->insert(pImageFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pImageFile == mPreviewImage)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mPreviewImage = getOwned() ? expandAssetFilePath(pImageFile) : StringTable->insert(pImageFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class LevelAsset : public AssetBase
|
|||
{
|
||||
typedef AssetBase Parent;
|
||||
|
||||
StringTableEntry mLevelName;
|
||||
StringTableEntry mLevelFile;
|
||||
StringTableEntry mPreviewImage;
|
||||
|
||||
|
|
@ -61,8 +62,20 @@ public:
|
|||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(LevelAsset);
|
||||
|
||||
void setLevelFile(const char* pImageFile);
|
||||
inline StringTableEntry getLevelFile(void) const { return mLevelFile; };
|
||||
void setImageFile(const char* pImageFile);
|
||||
inline StringTableEntry getImageFile(void) const { return mPreviewImage; };
|
||||
|
||||
SimObjectId load();
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void) {}
|
||||
static bool setLevelFile(void *obj, const char *index, const char *data) { static_cast<LevelAsset*>(obj)->setLevelFile(data); return false; }
|
||||
static const char* getLevelFile(void* obj, const char* data) { return static_cast<LevelAsset*>(obj)->getLevelFile(); }
|
||||
static bool setPreviewImageFile(void *obj, const char *index, const char *data) { static_cast<LevelAsset*>(obj)->setImageFile(data); return false; }
|
||||
static const char* getPreviewImageFile(void* obj, const char* data) { return static_cast<LevelAsset*>(obj)->getImageFile(); }
|
||||
|
||||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void) {}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -98,10 +98,6 @@ MaterialAsset::MaterialAsset()
|
|||
|
||||
MaterialAsset::~MaterialAsset()
|
||||
{
|
||||
// If the asset manager does not own the asset then we own the
|
||||
// asset definition so delete it.
|
||||
if (!getOwned())
|
||||
delete mpAssetDefinition;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -112,7 +108,9 @@ void MaterialAsset::initPersistFields()
|
|||
Parent::initPersistFields();
|
||||
|
||||
//addField("shaderGraph", TypeRealString, Offset(mShaderGraphFile, MaterialAsset), "");
|
||||
addField("scriptFile", TypeRealString, Offset(mScriptFile, MaterialAsset), "Path to the file containing the material definition.");
|
||||
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, MaterialAsset),
|
||||
&setScriptFile, &getScriptFile, "Path to the file containing the material definition.");
|
||||
|
||||
addField("materialDefinitionName", TypeRealString, Offset(mMatDefinitionName, MaterialAsset), "Name of the material definition this asset is for.");
|
||||
}
|
||||
|
||||
|
|
@ -132,12 +130,12 @@ void MaterialAsset::onAssetRefresh()
|
|||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
|
||||
if (!mMatDefinitionName.isEmpty())
|
||||
if (mMatDefinitionName != StringTable->EmptyString())
|
||||
{
|
||||
Material* matDef;
|
||||
if (!Sim::findObject(mMatDefinitionName.c_str(), matDef))
|
||||
if (!Sim::findObject(mMatDefinitionName, matDef))
|
||||
{
|
||||
Con::errorf("MaterialAsset: Unable to find the Material %s", mMatDefinitionName.c_str());
|
||||
Con::errorf("MaterialAsset: Unable to find the Material %s", mMatDefinitionName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -145,6 +143,25 @@ void MaterialAsset::onAssetRefresh()
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialAsset::setScriptFile(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void MaterialAsset::compileShader()
|
||||
|
|
@ -184,34 +201,68 @@ void GuiInspectorTypeMaterialAssetPtr::consoleInit()
|
|||
GuiControl* GuiInspectorTypeMaterialAssetPtr::constructEditControl()
|
||||
{
|
||||
// Create base filename edit controls
|
||||
GuiControl *retCtrl = Parent::constructEditControl();
|
||||
if (retCtrl == NULL)
|
||||
return retCtrl;
|
||||
mUseHeightOverride = true;
|
||||
mHeightOverride = 100;
|
||||
|
||||
mMatEdContainer = new GuiControl();
|
||||
mMatEdContainer->registerObject();
|
||||
|
||||
addObject(mMatEdContainer);
|
||||
|
||||
// Create "Open in ShapeEditor" button
|
||||
mMatPreviewButton = new GuiBitmapButtonCtrl();
|
||||
|
||||
const char* matAssetId = getData();
|
||||
|
||||
MaterialAsset* matAsset = AssetDatabase.acquireAsset< MaterialAsset>(matAssetId);
|
||||
|
||||
Material* materialDef = nullptr;
|
||||
|
||||
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
||||
|
||||
if (!Sim::findObject(matAsset->getMaterialDefinitionName(), materialDef))
|
||||
{
|
||||
Con::errorf("GuiInspectorTypeMaterialAssetPtr::constructEditControl() - unable to find material in asset");
|
||||
}
|
||||
else
|
||||
{
|
||||
mMatPreviewButton->setBitmap(materialDef->mDiffuseMapFilename[0]);
|
||||
}
|
||||
|
||||
mMatPreviewButton->setPosition(0, 0);
|
||||
mMatPreviewButton->setExtent(100,100);
|
||||
|
||||
// Change filespec
|
||||
char szBuffer[512];
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"MaterialAsset\", \"AssetBrowser.changeAsset\", %d, %s);",
|
||||
mInspector->getComponentGroupTargetId(), mCaption);
|
||||
mBrowseButton->setField("Command", szBuffer);
|
||||
mMatPreviewButton->setField("Command", szBuffer);
|
||||
|
||||
// Create "Open in ShapeEditor" button
|
||||
mSMEdButton = new GuiBitmapButtonCtrl();
|
||||
mMatPreviewButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||
mMatPreviewButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||
mMatPreviewButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "echo(\"Game Object Editor not implemented yet!\");", retCtrl->getId());
|
||||
mSMEdButton->setField("Command", szBuffer);
|
||||
StringBuilder strbld;
|
||||
strbld.append(matAsset->getMaterialDefinitionName());
|
||||
strbld.append("\n");
|
||||
strbld.append("Open this file in the Material Editor");
|
||||
|
||||
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
||||
mSMEdButton->setBitmap(bitmapName);
|
||||
mMatPreviewButton->setDataField(StringTable->insert("tooltip"), NULL, strbld.data());
|
||||
|
||||
mSMEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||
mSMEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||
mSMEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||
mSMEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the Material Editor");
|
||||
_registerEditControl(mMatPreviewButton);
|
||||
//mMatPreviewButton->registerObject();
|
||||
mMatEdContainer->addObject(mMatPreviewButton);
|
||||
|
||||
mSMEdButton->registerObject();
|
||||
addObject(mSMEdButton);
|
||||
mMatAssetIdTxt = new GuiTextEditCtrl();
|
||||
mMatAssetIdTxt->registerObject();
|
||||
mMatAssetIdTxt->setActive(false);
|
||||
|
||||
return retCtrl;
|
||||
mMatAssetIdTxt->setText(matAssetId);
|
||||
|
||||
mMatAssetIdTxt->setBounds(100, 0, 150, 18);
|
||||
mMatEdContainer->addObject(mMatAssetIdTxt);
|
||||
|
||||
return mMatEdContainer;
|
||||
}
|
||||
|
||||
bool GuiInspectorTypeMaterialAssetPtr::updateRects()
|
||||
|
|
@ -225,17 +276,41 @@ bool GuiInspectorTypeMaterialAssetPtr::updateRects()
|
|||
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
|
||||
|
||||
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||
if (mBrowseButton != NULL)
|
||||
|
||||
if (mMatEdContainer != nullptr)
|
||||
{
|
||||
mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
|
||||
resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
|
||||
mMatPreviewButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||
}
|
||||
|
||||
if (mSMEdButton != NULL)
|
||||
if (mMatPreviewButton != nullptr)
|
||||
{
|
||||
RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
|
||||
resized |= mSMEdButton->resize(shapeEdRect.point, shapeEdRect.extent);
|
||||
mMatPreviewButton->resize(Point2I::Zero, Point2I(100, 100));
|
||||
}
|
||||
|
||||
if (mMatAssetIdTxt != nullptr)
|
||||
{
|
||||
mMatAssetIdTxt->resize(Point2I(100, 0), Point2I(mEditCtrlRect.extent.x - 100, 18));
|
||||
}
|
||||
|
||||
return resized;
|
||||
}
|
||||
}
|
||||
|
||||
void GuiInspectorTypeMaterialAssetPtr::setMaterialAsset(String assetId)
|
||||
{
|
||||
mTargetObject->setDataField(mCaption, "", assetId);
|
||||
|
||||
//force a refresh
|
||||
SimObject* obj = mInspector->getInspectObject();
|
||||
mInspector->inspectObject(obj);
|
||||
}
|
||||
|
||||
DefineEngineMethod(GuiInspectorTypeMaterialAssetPtr, setMaterialAsset, void, (String assetId), (""),
|
||||
"Gets a particular shape animation asset for this shape.\n"
|
||||
"@param animation asset index.\n"
|
||||
"@return Shape Animation Asset.\n")
|
||||
{
|
||||
if (assetId == String::EmptyString)
|
||||
return;
|
||||
|
||||
return object->setMaterialAsset(assetId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class MaterialAsset : public AssetBase
|
|||
|
||||
String mShaderGraphFile;
|
||||
String mScriptFile;
|
||||
String mMatDefinitionName;
|
||||
StringTableEntry mMatDefinitionName;
|
||||
|
||||
public:
|
||||
MaterialAsset();
|
||||
|
|
@ -67,15 +67,22 @@ public:
|
|||
static void initPersistFields();
|
||||
virtual void copyTo(SimObject* object);
|
||||
|
||||
virtual void initializeAsset();
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
void compileShader();
|
||||
|
||||
String getMaterialDefinitionName() { return mMatDefinitionName; }
|
||||
StringTableEntry getMaterialDefinitionName() { return mMatDefinitionName; }
|
||||
|
||||
void setScriptFile(const char* pScriptFile);
|
||||
inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
|
||||
|
||||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(MaterialAsset);
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset();
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<MaterialAsset*>(obj)->setScriptFile(data); return false; }
|
||||
static const char* getScriptFile(void* obj, const char* data) { return static_cast<MaterialAsset*>(obj)->getScriptFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeMaterialAssetPtr, MaterialAsset)
|
||||
|
|
@ -83,18 +90,21 @@ DefineConsoleType(TypeMaterialAssetPtr, MaterialAsset)
|
|||
//-----------------------------------------------------------------------------
|
||||
// TypeAssetId GuiInspectorField Class
|
||||
//-----------------------------------------------------------------------------
|
||||
class GuiInspectorTypeMaterialAssetPtr : public GuiInspectorTypeFileName
|
||||
class GuiInspectorTypeMaterialAssetPtr : public GuiInspectorField
|
||||
{
|
||||
typedef GuiInspectorTypeFileName Parent;
|
||||
typedef GuiInspectorField Parent;
|
||||
public:
|
||||
|
||||
GuiBitmapButtonCtrl *mSMEdButton;
|
||||
GuiControl* mMatEdContainer;
|
||||
GuiBitmapButtonCtrl *mMatPreviewButton;
|
||||
GuiTextEditCtrl *mMatAssetIdTxt;
|
||||
|
||||
DECLARE_CONOBJECT(GuiInspectorTypeMaterialAssetPtr);
|
||||
static void consoleInit();
|
||||
|
||||
virtual GuiControl* constructEditControl();
|
||||
virtual bool updateRects();
|
||||
void setMaterialAsset(String assetId);
|
||||
};
|
||||
|
||||
#endif // _ASSET_BASE_H_
|
||||
|
|
|
|||
|
|
@ -112,7 +112,8 @@ void PostEffectAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("scriptFile", TypeString, Offset(mScriptFile, PostEffectAsset), "Path to the script file.");
|
||||
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, PostEffectAsset),
|
||||
&setScriptFile, &getScriptFile, "Path to the script file.");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -125,5 +126,31 @@ void PostEffectAsset::copyTo(SimObject* object)
|
|||
|
||||
void PostEffectAsset::initializeAsset()
|
||||
{
|
||||
//mPostEffect = new PostEffect();
|
||||
}
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void PostEffectAsset::onAssetRefresh()
|
||||
{
|
||||
if (Platform::isFile(mScriptFile))
|
||||
Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
|
||||
void PostEffectAsset::setScriptFile(const char* pScriptFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,13 +56,18 @@ public:
|
|||
static void initPersistFields();
|
||||
virtual void copyTo(SimObject* object);
|
||||
|
||||
virtual void initializeAsset();
|
||||
void setScriptFile(const char* pScriptFile);
|
||||
inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
|
||||
|
||||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(PostEffectAsset);
|
||||
|
||||
protected:
|
||||
virtual void onAssetRefresh(void) {}
|
||||
virtual void initializeAsset();
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<PostEffectAsset*>(obj)->setScriptFile(data); return false; }
|
||||
static const char* getScriptFile(void* obj, const char* data) { return static_cast<PostEffectAsset*>(obj)->getScriptFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypePostEffectAssetPtr, PostEffectAsset)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ ConsoleSetType(TypeScriptAssetPtr)
|
|||
|
||||
ScriptAsset::ScriptAsset() : AssetBase(), mIsServerSide(true)
|
||||
{
|
||||
mScriptFilePath = StringTable->EmptyString();
|
||||
mScriptFile = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -111,9 +111,8 @@ void ScriptAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("scriptFilePath", TypeString, Offset(mScriptFilePath, ScriptAsset), "Path to the script file.");
|
||||
addField("isServerSide", TypeBool, Offset(mIsServerSide, ScriptAsset), "Is this script file to be run on the server side?");
|
||||
|
||||
addProtectedField("scriptFile", TypeAssetLooseFilePath, Offset(mScriptFile, ScriptAsset),
|
||||
&setScriptFile, &getScriptFile, "Path to the script file.");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -124,14 +123,41 @@ void ScriptAsset::copyTo(SimObject* object)
|
|||
Parent::copyTo(object);
|
||||
}
|
||||
|
||||
void ScriptAsset::initializeAsset()
|
||||
void ScriptAsset::setScriptFile(const char* pScriptFile)
|
||||
{
|
||||
if (Platform::isFile(mScriptFilePath))
|
||||
Con::executeFile(mScriptFilePath, false, false);
|
||||
// Sanity!
|
||||
AssertFatal(pScriptFile != NULL, "Cannot use a NULL script file.");
|
||||
|
||||
// Fetch image file.
|
||||
pScriptFile = StringTable->insert(pScriptFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pScriptFile == mScriptFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void ScriptAsset::onAssetRefresh()
|
||||
bool ScriptAsset::execScript()
|
||||
{
|
||||
if (Platform::isFile(mScriptFilePath))
|
||||
Con::executeFile(mScriptFilePath, false, false);
|
||||
}
|
||||
if (Platform::isFile(mScriptFile))
|
||||
{
|
||||
return Con::executeFile(mScriptFile, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Con::errorf("ScriptAsset:execScript() - Script asset must have a valid file to exec");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DefineEngineMethod(ScriptAsset, execScript, bool, (), ,
|
||||
"Executes the script file.\n"
|
||||
"@return The bool result of calling exec")
|
||||
{
|
||||
return object->execScript();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ScriptAsset : public AssetBase
|
|||
{
|
||||
typedef AssetBase Parent;
|
||||
|
||||
StringTableEntry mScriptFilePath;
|
||||
StringTableEntry mScriptFile;
|
||||
bool mIsServerSide;
|
||||
|
||||
public:
|
||||
|
|
@ -58,9 +58,17 @@ public:
|
|||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(ScriptAsset);
|
||||
|
||||
void setScriptFile(const char* pScriptFile);
|
||||
inline StringTableEntry getScriptFile(void) const { return mScriptFile; };
|
||||
|
||||
bool execScript();
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
virtual void initializeAsset(void) {}
|
||||
virtual void onAssetRefresh(void) {}
|
||||
|
||||
static bool setScriptFile(void *obj, const char *index, const char *data) { static_cast<ScriptAsset*>(obj)->setScriptFile(data); return false; }
|
||||
static const char* getScriptFile(void* obj, const char* data) { return static_cast<ScriptAsset*>(obj)->getScriptFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeScriptAssetPtr, ScriptAsset)
|
||||
|
|
|
|||
|
|
@ -105,10 +105,6 @@ ShapeAnimationAsset::ShapeAnimationAsset() :
|
|||
|
||||
ShapeAnimationAsset::~ShapeAnimationAsset()
|
||||
{
|
||||
// If the asset manager does not own the asset then we own the
|
||||
// asset definition so delete it.
|
||||
if (!getOwned())
|
||||
delete mpAssetDefinition;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -118,7 +114,9 @@ void ShapeAnimationAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("animationFile", TypeFilename, Offset(mFileName, ShapeAnimationAsset), "Path to the file name containing the animation");
|
||||
addProtectedField("animationFile", TypeAssetLooseFilePath, Offset(mFileName, ShapeAnimationAsset),
|
||||
&setAnimationFile, &getAnimationFile, "Path to the file name containing the animation");
|
||||
|
||||
addField("animationName", TypeString, Offset(mAnimationName, ShapeAnimationAsset), "Name of the animation");
|
||||
|
||||
addField("isEmbedded", TypeBool, Offset(mIsEmbedded, ShapeAnimationAsset), "If true, this animation asset just referrs to an embedded animation of a regular shape mesh. If false, it is a self-contained animation file");
|
||||
|
|
@ -172,4 +170,38 @@ void ShapeAnimationAsset::initializeAsset(void)
|
|||
void ShapeAnimationAsset::onAssetRefresh(void)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeAnimationAsset::setAnimationFile(const char* pAnimationFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pAnimationFile != NULL, "Cannot use a NULL animation file.");
|
||||
|
||||
// Fetch image file.
|
||||
pAnimationFile = StringTable->insert(pAnimationFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pAnimationFile == mFileName)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mFileName = getOwned() ? expandAssetFilePath(pAnimationFile) : StringTable->insert(pAnimationFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
S32 ShapeAnimationAsset::getAnimationCount()
|
||||
{
|
||||
if (mSourceShape == nullptr)
|
||||
return 0;
|
||||
|
||||
return mSourceShape->sequences.size();
|
||||
}
|
||||
|
||||
DefineEngineMethod(ShapeAnimationAsset, getAnimationCount, S32, (), ,
|
||||
"Gets the number of animations for this shape asset.\n"
|
||||
"@return Animation count.\n")
|
||||
{
|
||||
return object->getAnimationCount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ public:
|
|||
static void initPersistFields();
|
||||
virtual void copyTo(SimObject* object);
|
||||
|
||||
void setAnimationFile(const char* pScriptFile);
|
||||
inline StringTableEntry getAnimationFile(void) const { return mFileName; };
|
||||
|
||||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(ShapeAnimationAsset);
|
||||
|
||||
|
|
@ -85,6 +88,9 @@ protected:
|
|||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setAnimationFile(void *obj, const char *index, const char *data) { static_cast<ShapeAnimationAsset*>(obj)->setAnimationFile(data); return false; }
|
||||
static const char* getAnimationFile(void* obj, const char* data) { return static_cast<ShapeAnimationAsset*>(obj)->getAnimationFile(); }
|
||||
|
||||
public:
|
||||
StringTableEntry getAnimationFilename() { return mFileName; }
|
||||
StringTableEntry getAnimationName() { return mAnimationName; }
|
||||
|
|
@ -101,6 +107,8 @@ public:
|
|||
bool isBlend() { return mIsBlend; }
|
||||
|
||||
S32 getBlendFrame() { return mBlendFrame; }
|
||||
|
||||
S32 getAnimationCount();
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeShapeAnimationAssetPtr, ShapeAnimationAsset)
|
||||
|
|
|
|||
|
|
@ -92,10 +92,6 @@ ShapeAsset::ShapeAsset()
|
|||
|
||||
ShapeAsset::~ShapeAsset()
|
||||
{
|
||||
// If the asset manager does not own the asset then we own the
|
||||
// asset definition so delete it.
|
||||
if (!getOwned())
|
||||
delete mpAssetDefinition;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -105,7 +101,8 @@ void ShapeAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("fileName", TypeFilename, Offset(mFileName, ShapeAsset), "Path to the shape file we want to render");
|
||||
addProtectedField("fileName", TypeAssetLooseFilePath, Offset(mFileName, ShapeAsset),
|
||||
&setShapeFile, &getShapeFile, "Path to the shape file we want to render");
|
||||
}
|
||||
|
||||
void ShapeAsset::setDataField(StringTableEntry slotName, const char *array, const char *value)
|
||||
|
|
@ -127,7 +124,36 @@ void ShapeAsset::initializeAsset()
|
|||
// Call parent.
|
||||
Parent::initializeAsset();
|
||||
|
||||
if (dStrcmp(mFileName, "") == 0)
|
||||
if (mFileName == StringTable->EmptyString())
|
||||
return;
|
||||
|
||||
ResourceManager::get().getChangedSignal().notify(this, &ShapeAsset::_onResourceChanged);
|
||||
|
||||
loadShape();
|
||||
}
|
||||
|
||||
void ShapeAsset::setShapeFile(const char* pShapeFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pShapeFile != NULL, "Cannot use a NULL shape file.");
|
||||
|
||||
// Fetch image file.
|
||||
pShapeFile = StringTable->insert(pShapeFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pShapeFile == mFileName)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mFileName = getOwned() ? expandAssetFilePath(pShapeFile) : StringTable->insert(pShapeFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
void ShapeAsset::_onResourceChanged(const Torque::Path &path)
|
||||
{
|
||||
if (path != Torque::Path(mFileName) )
|
||||
return;
|
||||
|
||||
loadShape();
|
||||
|
|
@ -152,12 +178,12 @@ bool ShapeAsset::loadShape()
|
|||
|
||||
if (assetType == StringTable->insert("MaterialAsset"))
|
||||
{
|
||||
mMaterialAssetIds.push_back(assetDependenciesItr->value);
|
||||
mMaterialAssetIds.push_front(assetDependenciesItr->value);
|
||||
|
||||
//Force the asset to become initialized if it hasn't been already
|
||||
AssetPtr<MaterialAsset> matAsset = assetDependenciesItr->value;
|
||||
|
||||
mMaterialAssets.push_back(matAsset);
|
||||
mMaterialAssets.push_front(matAsset);
|
||||
}
|
||||
else if (assetType == StringTable->insert("ShapeAnimationAsset"))
|
||||
{
|
||||
|
|
@ -227,6 +253,8 @@ bool ShapeAsset::loadShape()
|
|||
}
|
||||
}
|
||||
|
||||
onShapeChanged.trigger(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,16 +95,40 @@ public:
|
|||
Resource<TSShape> getShapeResource() { return mShape; }
|
||||
|
||||
void SplitSequencePathAndName(String& srcPath, String& srcName);
|
||||
String getShapeFilename() { return mFileName; }
|
||||
StringTableEntry getShapeFilename() { return mFileName; }
|
||||
|
||||
U32 getShapeFilenameHash() { return _StringTable::hashString(mFileName); }
|
||||
|
||||
Vector<AssetPtr<MaterialAsset>> getMaterialAssets() { return mMaterialAssets; }
|
||||
|
||||
inline AssetPtr<MaterialAsset> getMaterialAsset(U32 matId)
|
||||
{
|
||||
if(matId >= mMaterialAssets.size())
|
||||
return nullptr;
|
||||
else
|
||||
return mMaterialAssets[matId];
|
||||
}
|
||||
|
||||
void clearMaterialAssets() { mMaterialAssets.clear(); }
|
||||
|
||||
void addMaterialAssets(AssetPtr<MaterialAsset> matPtr) { mMaterialAssets.push_back(matPtr); }
|
||||
|
||||
S32 getMaterialCount() { return mMaterialAssets.size(); }
|
||||
S32 getAnimationCount() { return mAnimationAssets.size(); }
|
||||
ShapeAnimationAsset* getAnimation(S32 index);
|
||||
|
||||
void _onResourceChanged(const Torque::Path &path);
|
||||
|
||||
Signal< void(ShapeAsset*) > onShapeChanged;
|
||||
|
||||
void setShapeFile(const char* pScriptFile);
|
||||
inline StringTableEntry getShapeFile(void) const { return mFileName; };
|
||||
|
||||
protected:
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setShapeFile(void *obj, const char *index, const char *data) { static_cast<ShapeAsset*>(obj)->setShapeFile(data); return false; }
|
||||
static const char* getShapeFile(void* obj, const char* data) { return static_cast<ShapeAsset*>(obj)->getShapeFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeShapeAssetPtr, S32)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ ConsoleSetType(TypeSoundAssetPtr)
|
|||
|
||||
SoundAsset::SoundAsset()
|
||||
{
|
||||
mSoundFilePath = StringTable->EmptyString();
|
||||
mSoundFile = StringTable->EmptyString();
|
||||
|
||||
mPitchAdjust = 0;
|
||||
mVolumeAdjust = 0;
|
||||
|
|
@ -117,7 +117,8 @@ void SoundAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("soundFilePath", TypeFilename, Offset(mSoundFilePath, SoundAsset), "Path to the sound file.");
|
||||
addProtectedField("soundFile", TypeAssetLooseFilePath, Offset(mSoundFile, SoundAsset),
|
||||
&setSoundFile, &getSoundFile, "Path to the sound file.");
|
||||
|
||||
addField("pitchAdjust", TypeF32, Offset(mPitchAdjust, SoundAsset), "Adjustment of the pitch value");
|
||||
addField("volumeAdjust", TypeF32, Offset(mVolumeAdjust, SoundAsset), "Adjustment to the volume.");
|
||||
|
|
@ -138,4 +139,23 @@ void SoundAsset::initializeAsset(void)
|
|||
void SoundAsset::onAssetRefresh(void)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SoundAsset::setSoundFile(const char* pSoundFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pSoundFile != NULL, "Cannot use a NULL shape file.");
|
||||
|
||||
// Fetch image file.
|
||||
pSoundFile = StringTable->insert(pSoundFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pSoundFile == mSoundFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mSoundFile = getOwned() ? expandAssetFilePath(pSoundFile) : StringTable->insert(pSoundFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class SoundAsset : public AssetBase
|
|||
typedef AssetBase Parent;
|
||||
|
||||
protected:
|
||||
StringTableEntry mSoundFilePath;
|
||||
StringTableEntry mSoundFile;
|
||||
F32 mPitchAdjust;
|
||||
F32 mVolumeAdjust;
|
||||
|
||||
|
|
@ -62,11 +62,15 @@ public:
|
|||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(SoundAsset);
|
||||
|
||||
StringTableEntry getSoundFilePath() { return mSoundFilePath; }
|
||||
void setSoundFile(const char* pScriptFile);
|
||||
inline StringTableEntry getSoundFile(void) const { return mSoundFile; };
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void);
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
static bool setSoundFile(void *obj, const char *index, const char *data) { static_cast<SoundAsset*>(obj)->setSoundFile(data); return false; }
|
||||
static const char* getSoundFile(void* obj, const char* data) { return static_cast<SoundAsset*>(obj)->getSoundFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeSoundAssetPtr, SoundAsset)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ ConsoleSetType(TypeStateMachineAssetPtr)
|
|||
|
||||
StateMachineAsset::StateMachineAsset()
|
||||
{
|
||||
mStateMachineFileName = StringTable->EmptyString();
|
||||
mStateMachineFile = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -112,7 +112,8 @@ void StateMachineAsset::initPersistFields()
|
|||
// Call parent.
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("stateMachineFile", TypeString, Offset(mStateMachineFileName, StateMachineAsset), "Path to the state machine file.");
|
||||
addProtectedField("stateMachineFile", TypeAssetLooseFilePath, Offset(mStateMachineFile, StateMachineAsset),
|
||||
&setStateMachineFile, &getStateMachineFile, "Path to the state machine file.");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -123,9 +124,29 @@ void StateMachineAsset::copyTo(SimObject* object)
|
|||
Parent::copyTo(object);
|
||||
}
|
||||
|
||||
void StateMachineAsset::setStateMachineFile(const char* pStateMachineFile)
|
||||
{
|
||||
// Sanity!
|
||||
AssertFatal(pStateMachineFile != NULL, "Cannot use a NULL state machine file.");
|
||||
|
||||
// Fetch image file.
|
||||
pStateMachineFile = StringTable->insert(pStateMachineFile);
|
||||
|
||||
// Ignore no change,
|
||||
if (pStateMachineFile == mStateMachineFile)
|
||||
return;
|
||||
|
||||
// Update.
|
||||
mStateMachineFile = getOwned() ? expandAssetFilePath(pStateMachineFile) : StringTable->insert(pStateMachineFile);
|
||||
|
||||
// Refresh the asset.
|
||||
refreshAsset();
|
||||
}
|
||||
|
||||
|
||||
DefineEngineMethod(StateMachineAsset, notifyAssetChanged, void, (),,"")
|
||||
{
|
||||
ResourceManager::get().getChangedSignal().trigger(object->getStateMachineFileName());
|
||||
ResourceManager::get().getChangedSignal().trigger(object->getStateMachineFile());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class StateMachineAsset : public AssetBase
|
|||
{
|
||||
typedef AssetBase Parent;
|
||||
|
||||
StringTableEntry mStateMachineFileName;
|
||||
StringTableEntry mStateMachineFile;
|
||||
|
||||
public:
|
||||
StateMachineAsset();
|
||||
|
|
@ -59,11 +59,15 @@ public:
|
|||
/// Declare Console Object.
|
||||
DECLARE_CONOBJECT(StateMachineAsset);
|
||||
|
||||
StringTableEntry getStateMachineFileName() { return mStateMachineFileName; }
|
||||
void setStateMachineFile(const char* pStateMachineFile);
|
||||
inline StringTableEntry getStateMachineFile(void) const { return mStateMachineFile; };
|
||||
|
||||
protected:
|
||||
virtual void initializeAsset(void) {}
|
||||
virtual void onAssetRefresh(void) {}
|
||||
|
||||
static bool setStateMachineFile(void *obj, const char *index, const char *data) { static_cast<StateMachineAsset*>(obj)->setStateMachineFile(data); return false; }
|
||||
static const char* getStateMachineFile(void* obj, const char* data) { return static_cast<StateMachineAsset*>(obj)->getStateMachineFile(); }
|
||||
};
|
||||
|
||||
DefineConsoleType(TypeStateMachineAssetPtr, StateMachineAsset)
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ Entity::Entity()
|
|||
|
||||
mGameObjectAssetId = StringTable->insert("");
|
||||
|
||||
mDirtyGameObject = false;
|
||||
}
|
||||
|
||||
Entity::~Entity()
|
||||
|
|
@ -156,8 +157,11 @@ void Entity::initPersistFields()
|
|||
endGroup("Misc");
|
||||
|
||||
addGroup("GameObject");
|
||||
addProtectedField("gameObjectName", TypeGameObjectAssetPtr, Offset(mGameObjectAsset, Entity), &_setGameObject, &defaultProtectedGetFn,
|
||||
addProtectedField("GameObject", TypeGameObjectAssetPtr, Offset(mGameObjectAsset, Entity), &_setGameObject, &defaultProtectedGetFn,
|
||||
"The asset Id used for the game object this entity is based on.");
|
||||
|
||||
addField("dirtyGameObject", TypeBool, Offset(mDirtyGameObject, Entity), "If this entity is a GameObject, it flags if this instance delinates from the template.",
|
||||
AbstractClassRep::FieldFlags::FIELD_HideInInspectors);
|
||||
endGroup("GameObject");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ private:
|
|||
StringTableEntry mGameObjectAssetId;
|
||||
AssetPtr<GameObjectAsset> mGameObjectAsset;
|
||||
|
||||
//Marked if this entity is a GameObject and deliniates from the parent GO asset
|
||||
bool mDirtyGameObject;
|
||||
|
||||
ContainerQueryInfo containerInfo;
|
||||
|
||||
bool mInitialized;
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ mAssetInitialized(false)
|
|||
{
|
||||
// Generate an asset definition.
|
||||
mpAssetDefinition = new AssetDefinition();
|
||||
|
||||
mInternalName = StringTable->EmptyString();
|
||||
mClassName = StringTable->EmptyString();
|
||||
mSuperClassName = StringTable->EmptyString();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue