Torque3D Documentation / _generateds / ParticleAsset.cpp

ParticleAsset.cpp

Engine/source/T3D/assets/ParticleAsset.cpp

More...

Public Functions

ConsoleDocClass(GuiInspectorTypeParticleAssetPtr , "@brief Inspector field type <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/class/structparticle/">Particle</a> Asset <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Objects\n\n</a>" "Editor use <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">only.\n\n</a>" "@internal" )
ConsoleSetType(TypeParticleAssetPtr )
ConsoleType(ParticleAssetPtr , TypeParticleAssetPtr , ParticleAsset , ASSET_ID_FIELD_PREFIX )

Detailed Description

Public Functions

ConsoleDocClass(GuiInspectorTypeParticleAssetPtr , "@brief Inspector field type <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/class/structparticle/">Particle</a> Asset <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Objects\n\n</a>" "Editor use <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">only.\n\n</a>" "@internal" )

ConsoleSetType(TypeParticleAssetPtr )

ConsoleType(ParticleAssetPtr , TypeParticleAssetPtr , ParticleAsset , ASSET_ID_FIELD_PREFIX )

IMPLEMENT_CONOBJECT(GuiInspectorTypeParticleAssetPtr )

IMPLEMENT_CONOBJECT(ParticleAsset )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2013 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef PARTICLE_ASSET_H
 25#include "ParticleAsset.h"
 26#endif
 27
 28#ifndef _ASSET_MANAGER_H_
 29#include "assets/assetManager.h"
 30#endif
 31
 32#ifndef _CONSOLETYPES_H_
 33#include "console/consoleTypes.h"
 34#endif
 35
 36#ifndef _TAML_
 37#include "persistence/taml/taml.h"
 38#endif
 39
 40#ifndef _ASSET_PTR_H_
 41#include "assets/assetPtr.h"
 42#endif
 43
 44// Debug Profiling.
 45#include "platform/profiler.h"
 46
 47//-----------------------------------------------------------------------------
 48
 49IMPLEMENT_CONOBJECT(ParticleAsset);
 50
 51ConsoleType(ParticleAssetPtr, TypeParticleAssetPtr, ParticleAsset, ASSET_ID_FIELD_PREFIX)
 52
 53//-----------------------------------------------------------------------------
 54
 55ConsoleGetType(TypeParticleAssetPtr)
 56{
 57   // Fetch asset Id.
 58   return (*((AssetPtr<ParticleAsset>*)dptr)).getAssetId();
 59}
 60
 61//-----------------------------------------------------------------------------
 62
 63ConsoleSetType(TypeParticleAssetPtr)
 64{
 65   // Was a single argument specified?
 66   if (argc == 1)
 67   {
 68      // Yes, so fetch field value.
 69      const char* pFieldValue = argv[0];
 70
 71      // Fetch asset pointer.
 72      AssetPtr<ParticleAsset>* pAssetPtr = dynamic_cast<AssetPtr<ParticleAsset>*>((AssetPtrBase*)(dptr));
 73
 74      // Is the asset pointer the correct type?
 75      if (pAssetPtr == NULL)
 76      {
 77         // No, so fail.
 78         //Con::warnf("(TypeParticleAssetPtr) - Failed to set asset Id '%d'.", pFieldValue);
 79         return;
 80      }
 81
 82      // Set asset.
 83      pAssetPtr->setAssetId(pFieldValue);
 84
 85      return;
 86   }
 87
 88   // Warn.
 89   Con::warnf("(TypeParticleAssetPtr) - Cannot set multiple args to a single asset.");
 90}
 91
 92//-----------------------------------------------------------------------------
 93
 94ParticleAsset::ParticleAsset()
 95{
 96   mScriptFilePath = StringTable->EmptyString();
 97   mDatablockFilePath = StringTable->EmptyString();
 98}
 99
100//-----------------------------------------------------------------------------
101
102ParticleAsset::~ParticleAsset()
103{
104}
105
106//-----------------------------------------------------------------------------
107
108void ParticleAsset::initPersistFields()
109{
110   // Call parent.
111   Parent::initPersistFields();
112
113   addField("scriptFilePath", TypeString, Offset(mScriptFilePath, ParticleAsset), "Path to the script file for the particle effect");
114   addField("DatablockFilePath", TypeString, Offset(mDatablockFilePath, ParticleAsset), "Path to the datablock file");
115}
116
117//------------------------------------------------------------------------------
118
119void ParticleAsset::copyTo(SimObject* object)
120{
121   // Call to parent.
122   Parent::copyTo(object);
123}
124
125
126//-----------------------------------------------------------------------------
127// GuiInspectorTypeAssetId
128//-----------------------------------------------------------------------------
129
130IMPLEMENT_CONOBJECT(GuiInspectorTypeParticleAssetPtr);
131
132ConsoleDocClass(GuiInspectorTypeParticleAssetPtr,
133   "@brief Inspector field type for Particle Asset Objects\n\n"
134   "Editor use only.\n\n"
135   "@internal"
136);
137
138void GuiInspectorTypeParticleAssetPtr::consoleInit()
139{
140   Parent::consoleInit();
141
142   ConsoleBaseType::getType(TypeParticleAssetPtr)->setInspectorFieldType("GuiInspectorTypeParticleAssetPtr");
143}
144
145GuiControl* GuiInspectorTypeParticleAssetPtr::constructEditControl()
146{
147   // Create base filename edit controls
148   GuiControl *retCtrl = Parent::constructEditControl();
149   if (retCtrl == NULL)
150      return retCtrl;
151
152   // Change filespec
153   char szBuffer[512];
154   dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"ParticleAsset\", \"AssetBrowser.changeAsset\", %d, %s);",
155      mInspector->getComponentGroupTargetId(), mCaption);
156   mBrowseButton->setField("Command", szBuffer);
157
158   // Create "Open in ShapeEditor" button
159   mSMEdButton = new GuiBitmapButtonCtrl();
160
161   dSprintf(szBuffer, sizeof(szBuffer), "echo(\"Game Object Editor not implemented yet!\");", retCtrl->getId());
162   mSMEdButton->setField("Command", szBuffer);
163
164   char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
165   mSMEdButton->setBitmap(bitmapName);
166
167   mSMEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
168   mSMEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
169   mSMEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
170   mSMEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the State Machine Editor");
171
172   mSMEdButton->registerObject();
173   addObject(mSMEdButton);
174
175   return retCtrl;
176}
177
178bool GuiInspectorTypeParticleAssetPtr::updateRects()
179{
180   S32 dividerPos, dividerMargin;
181   mInspector->getDivider(dividerPos, dividerMargin);
182   Point2I fieldExtent = getExtent();
183   Point2I fieldPos = getPosition();
184
185   mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
186   mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
187
188   bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
189   if (mBrowseButton != NULL)
190   {
191      mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
192      resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
193   }
194
195   if (mSMEdButton != NULL)
196   {
197      RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
198      resized |= mSMEdButton->resize(shapeEdRect.point, shapeEdRect.extent);
199   }
200
201   return resized;
202}
203