mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
- Hides the special-case direct filepath field for ShapeAsset persist fields macro - Shifts the handling of TSStatics so the shape instance will load materials on the server as well as the client. This opens gameplay options as well as allowing rebaking of meshes functionality more easily - Expands AssetBase's isValidAsset utility function to actually check validity instead of just returning true - Adds isValid utility function to AssetPtr - Added new field flag that makes the field not write out to file - Removed legacy iconBitmap field from GuiIconButtonCtrl because it was causing errors - Fixed group filtering check of guiInspector to ignore case - Removed unneeded isFile checks for common datablock script files in Prototyping module script - Removed test datablocks from Prototyping module - Removed unnecessary container control from AssetBrowser - Adjusted preview regen logic of AssetBrowser so it doesn't trip if you're simply resizing the window - Fixed issue where row-vs-column layout logic for AssetBrowser when resizing window was fiddly - Added handling for when Dragging and Dropping datablock from AssetBrowser to spawn, it'll prompt if it spawns the actual object, or a spawnsphere that spawns said object. In the event of an PlayerData will also prompt if it should spawn an AIPlayer - Added ability to take a TSStatic that uses a baked down mesh and are able to restore it to the cache prefab, or trigger and in-place rebake to refresh it if something has changed in the original contents via RMB menu on the scene tree - Added ability to explode prefab to RMB menu on scene tree - Added ability to convert selection to prefab or bake to mesh in RMB menu on scene tree - Tweaked sizing of the DatablockEditorCreatePrompt window to not have cut off elements and easier to see/work with - Added sanity check to datablock editor creation - Fixed preview display of material in Decal Editor - Made compositeTextureEditor use the cached preview of images - Fixed sizing/spacing of gui selection dropdown as well as resolution dropdown of GuiEditor - Fixes MaterialEditor to properly save the group collapse state when editing - Adds ability to in-flow edit and create datablocks in the NavMesh Editor for the testing panel, and makes the datablock dropdown searchable - Fixed issue where opening the ShapeEditor via the edit button on a ShapeAsset field would cause the action buttons on the top bar to not show - Fixed error in shape editor where when exiting it was erroneously checking for a clear value of -1 rather than 0 - Removed unneeded top tabbook and tab page for main editor panel - Fixed issue where reset button of TerrainBrush Softness Curve editor didn't actually reset - Resized Object Builder window to not cut off elements and have enough width to show more data - Added a TypeCommand field type to Object Builder and changed spawnscript field of SpawnSphere to use it rather than a simple text edit field - Allow SpawnSphere in ObjectBuilder to be passed in spawn class and spawn datablock default info - Injects button to controllable objects when Inspecting them to make it easy to toggle if you're in control of it or not -
185 lines
9.4 KiB
C++
185 lines
9.4 KiB
C++
//-----------------------------------------------------------------------------
|
|
// 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 _ASSET_BASE_H_
|
|
#define _ASSET_BASE_H_
|
|
|
|
#ifndef _ASSET_DEFINITION_H_
|
|
#include "assetDefinition.h"
|
|
#endif
|
|
|
|
#ifndef _STRINGUNIT_H_
|
|
#include "string/stringUnit.h"
|
|
#endif
|
|
|
|
#ifndef _ASSET_FIELD_TYPES_H_
|
|
#include "assets/assetFieldTypes.h"
|
|
#endif
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class AssetManager;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
extern StringTableEntry assetNameField;
|
|
extern StringTableEntry assetDescriptionField;
|
|
extern StringTableEntry assetCategoryField;
|
|
extern StringTableEntry assetInternalField;
|
|
extern StringTableEntry assetPrivateField;
|
|
extern StringTableEntry assetAutoUnloadField;
|
|
extern StringTableEntry assetTypeField;
|
|
|
|
//#define ASSET_BASE_ASSETNAME_FIELD "AssetName"
|
|
//#define ASSET_BASE_ASSETDESCRIPTION_FIELD "AssetDescription"
|
|
//#define ASSET_BASE_ASSETCATEGORY_FIELD "AssetCategory"
|
|
//#define ASSET_BASE_ASSETINTERNAL_FIELD "AssetInternal"
|
|
//#define ASSET_BASE_ASSETPRIVATE_FIELD "AssetPrivate"
|
|
//#define ASSET_BASE_AUTOUNLOAD_FIELD "AssetAutoUnload"
|
|
|
|
//-----------------------------------------------------------------------------
|
|
class AssetBase : public SimGroup
|
|
{
|
|
friend class AssetManager;
|
|
|
|
typedef SimGroup Parent;
|
|
|
|
protected:
|
|
AssetManager* mpOwningAssetManager;
|
|
bool mAssetInitialized;
|
|
AssetDefinition* mpAssetDefinition;
|
|
U32 mAcquireReferenceCount;
|
|
U32 mLoadedState;
|
|
|
|
public:
|
|
enum AssetErrCode
|
|
{
|
|
Failed,
|
|
Ok,
|
|
NotLoaded,
|
|
Reloading,
|
|
BadFileReference,
|
|
InvalidFormat,
|
|
DependencyNotFound,
|
|
FileTooLarge,
|
|
UsingFallback,
|
|
Extended
|
|
};
|
|
|
|
static const String mErrCodeStrings[AssetErrCode::Extended + 1];
|
|
static String getAssetErrstrn(U32 errCode)
|
|
{
|
|
if (errCode > AssetErrCode::Extended) return "undefined error";
|
|
return mErrCodeStrings[errCode];
|
|
};
|
|
U32 getStatus() { return mLoadedState; };
|
|
virtual U32 load() { return NotLoaded; };
|
|
AssetBase();
|
|
virtual ~AssetBase();
|
|
|
|
/// Engine.
|
|
static void initPersistFields();
|
|
void copyTo(SimObject* object) override;
|
|
|
|
/// Asset configuration.
|
|
inline void setAssetName(const char* pAssetName) { if (mpOwningAssetManager == NULL) mpAssetDefinition->mAssetName = StringTable->insert(pAssetName); }
|
|
inline StringTableEntry getAssetName(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetName : StringTable->EmptyString(); }
|
|
void setAssetDescription(const char* pAssetDescription);
|
|
inline StringTableEntry getAssetDescription(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetDescription : StringTable->EmptyString(); }
|
|
void setAssetCategory(const char* pAssetCategory);
|
|
inline StringTableEntry getAssetCategory(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetCategory : StringTable->EmptyString(); }
|
|
void setAssetAutoUnload(const bool autoUnload);
|
|
inline bool getAssetAutoUnload(void) const { return mpAssetDefinition->mAssetAutoUnload; }
|
|
void setAssetInternal(const bool assetInternal);
|
|
inline bool getAssetInternal(void) const { return mpAssetDefinition->mAssetInternal; }
|
|
inline bool getAssetPrivate(void) const { return mpAssetDefinition->mAssetPrivate; }
|
|
inline StringTableEntry getAssetType(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetType: StringTable->EmptyString(); }
|
|
|
|
inline S32 getAcquiredReferenceCount(void) const { return mAcquireReferenceCount; }
|
|
inline bool getOwned(void) const { return mpOwningAssetManager != NULL; }
|
|
|
|
// Asset Id is only available once registered with the asset manager.
|
|
inline StringTableEntry getAssetId(void) const { return mpAssetDefinition ? mpAssetDefinition->mAssetId : StringTable->EmptyString(); }
|
|
|
|
/// Expanding/Collapsing asset paths is only available once registered with the asset manager.
|
|
StringTableEntry expandAssetFilePath(const char* pAssetFilePath) const;
|
|
StringTableEntry collapseAssetFilePath(const char* pAssetFilePath) const;
|
|
|
|
virtual bool isAssetValid(void) const
|
|
{
|
|
return mpOwningAssetManager != nullptr && mAssetInitialized && (mLoadedState == AssetErrCode::Ok || mLoadedState == AssetErrCode::UsingFallback);
|
|
}
|
|
|
|
void refreshAsset(void);
|
|
|
|
S32 getAssetDependencyFieldCount(const char* pFieldName);
|
|
StringTableEntry getAssetDependencyField(const char* pFieldName, S32 index = 0);
|
|
void clearAssetDependencyFields(const char* pFieldName);
|
|
void addAssetDependencyField(const char* pFieldName, const char* pAssetId);
|
|
|
|
bool saveAsset();
|
|
|
|
/// Declare Console Object.
|
|
DECLARE_CONOBJECT(AssetBase);
|
|
|
|
protected:
|
|
virtual void initializeAsset(void) {}
|
|
virtual void onAssetRefresh(void) {}
|
|
virtual void unloadAsset(void) {}
|
|
|
|
protected:
|
|
static bool setAssetName(void *obj, const char *array, const char *data) { static_cast<AssetBase*>(obj)->setAssetName(data); return false; }
|
|
static const char* getAssetName(void* obj, const char* data) { return static_cast<AssetBase*>(obj)->getAssetName(); }
|
|
static bool writeAssetName(void* obj, StringTableEntry pFieldName) { return static_cast<AssetBase*>(obj)->getAssetName() != StringTable->EmptyString(); }
|
|
|
|
static bool setAssetDescription(void *obj, const char *array, const char *data) { static_cast<AssetBase*>(obj)->setAssetDescription(data); return false; }
|
|
static const char* getAssetDescription(void* obj, const char* data) { return static_cast<AssetBase*>(obj)->getAssetDescription(); }
|
|
static bool writeAssetDescription(void* obj, StringTableEntry pFieldName) { return static_cast<AssetBase*>(obj)->getAssetDescription() != StringTable->EmptyString(); }
|
|
|
|
static bool setAssetCategory(void *obj, const char *array, const char *data) { static_cast<AssetBase*>(obj)->setAssetCategory(data); return false; }
|
|
static const char* getAssetCategory(void* obj, const char* data) { return static_cast<AssetBase*>(obj)->getAssetCategory(); }
|
|
static bool writeAssetCategory(void* obj, StringTableEntry pFieldName) { return static_cast<AssetBase*>(obj)->getAssetCategory() != StringTable->EmptyString(); }
|
|
|
|
static bool setAssetAutoUnload(void *obj, const char *array, const char *data) { static_cast<AssetBase*>(obj)->setAssetAutoUnload(dAtob(data)); return false; }
|
|
static const char* getAssetAutoUnload(void* obj, const char* data) { return Con::getBoolArg(static_cast<AssetBase*>(obj)->getAssetAutoUnload()); }
|
|
static bool writeAssetAutoUnload(void* obj, StringTableEntry pFieldName) { return static_cast<AssetBase*>(obj)->getAssetAutoUnload() == false; }
|
|
|
|
static bool setAssetInternal(void *obj, const char *array, const char *data) { static_cast<AssetBase*>(obj)->setAssetInternal(dAtob(data)); return false; }
|
|
static const char* getAssetInternal(void* obj, const char* data) { return Con::getBoolArg(static_cast<AssetBase*>(obj)->getAssetInternal()); }
|
|
static bool writeAssetInternal(void* obj, StringTableEntry pFieldName) { return static_cast<AssetBase*>(obj)->getAssetInternal() == true; }
|
|
|
|
static const char* getAssetPrivate(void* obj, const char* data) { return Con::getBoolArg(static_cast<AssetBase*>(obj)->getAssetPrivate()); }
|
|
|
|
private:
|
|
void acquireAssetReference(void);
|
|
bool releaseAssetReference(void);
|
|
|
|
/// Set asset manager ownership.
|
|
void setOwned(AssetManager* pAssetManager, AssetDefinition* pAssetDefinition);
|
|
};
|
|
|
|
//helper macro for stitching string and non string values togeather sans quotes
|
|
#define assetText(x,suff) #x#suff
|
|
#define macroText(x) #x
|
|
#define assetDoc(x,suff) "@brief "#x" "#suff
|
|
#endif // _ASSET_BASE_H_
|
|
|