Torque3D Documentation / _generateds / consoleTypes.cpp

consoleTypes.cpp

Engine/source/console/consoleTypes.cpp

More...

Public Variables

ConsoleGetType (TypeRealString)

Public Functions

bool
ConsoleGetType(TypeBool )
Vector< bool >
ConsoleGetType(TypeBoolVector )
ConsoleGetType(TypeCaseString )
ConsoleGetType(TypeColorI )
ConsoleGetType(TypeF32 )
ConsoleGetType(TypeF32Vector )
ConsoleGetType(TypeFilename )
ConsoleGetType(TypeImageFilename )
ConsoleGetType(TypePrefabFilename )
ConsoleGetType(TypeS32 )
ConsoleGetType(TypeS32Vector )
ConsoleGetType(TypeS8 )
ConsoleGetType(TypeShapeFilename )
ConsoleGetType(TypeSimObjectName )
ConsoleGetType(TypeSimObjectPtr )
const char *
ConsoleGetType(TypeString )
ConsoleGetType(TypeStringFilename )
ConsolePrepType(filename , TypeFilename , const char * )
ConsolePrepType(filename , TypeImageFilename , String )
ConsolePrepType(filename , TypePrefabFilename , String )
ConsolePrepType(filename , TypeShapeFilename , const char * )
ConsolePrepType(filename , TypeStringFilename , String )
ConsoleProcessData(TypeFilename )
ConsoleProcessData(TypeImageFilename )
ConsoleProcessData(TypePrefabFilename )
ConsoleProcessData(TypeShapeFilename )
ConsoleProcessData(TypeStringFilename )
ConsoleSetType(TypeBool )
ConsoleSetType(TypeBoolVector )
ConsoleSetType(TypeColorF )
ConsoleSetType(TypeColorI )
ConsoleSetType(TypeCommand )
ConsoleSetType(TypeCubemapName )
ConsoleSetType(TypeF32 )
ConsoleSetType(TypeF32Vector )
ConsoleSetType(TypeFlag )
ConsoleSetType(TypeMaterialName )
ConsoleSetType(TypeName )
ConsoleSetType(TypeParticleParameterString )
ConsoleSetType(TypePID )
ConsoleSetType(TypeRealString )
ConsoleSetType(TypeRectUV )
ConsoleSetType(TypeS32 )
ConsoleSetType(TypeS32Vector )
ConsoleSetType(TypeS8 )
ConsoleSetType(TypeSimPersistId )
ConsoleSetType(TypeString )
ConsoleSetType(TypeTerrainMaterialIndex )
ConsoleSetType(TypeTerrainMaterialName )
ConsoleSetType(TypeUUID )
ConsoleType(bool , TypeBool , bool , "" )
ConsoleType(boolList , TypeBoolVector , Vector< bool > , "" )
ConsoleType(caseString , TypeCaseString , const char * , "" )
ConsoleType(char , TypeS8 , S8 , "" )
ConsoleType(ColorI , TypeColorI , ColorI , "" )
ConsoleType(flag , TypeFlag , S32 , "" )
ConsoleType(float , TypeF32 , F32 , "" )
ConsoleType(floatList , TypeF32Vector , Vector< F32 > , "" )
ConsoleType(int , TypeS32 , S32 , "" )
ConsoleType(int , TypeTerrainMaterialIndex , S32 , "" )
ConsoleType(intList , TypeS32Vector , Vector< S32 > , "" )
ConsoleType(LinearColorF , TypeColorF , LinearColorF , "" )
ConsoleType(pid , TypePID , SimPersistID * , "" )
ConsoleType(RectF , TypeRectUV , RectF , "" )
ConsoleType(SimObject , TypeSimObjectName , SimObject * , "" )
ConsoleType(SimObject , TypeSimObjectPtr , SimObject * , "" )
ConsoleType(SimPersistId , TypeSimPersistId , SimPersistID * , "" )
ConsoleType(string , TypeCommand , String , "" )
ConsoleType(string , TypeCubemapName , String , "" )
ConsoleType(string , TypeMaterialName , String , "" )
ConsoleType(string , TypeName , const char * , "" )
ConsoleType(string , TypeParticleParameterString , const char * , "" )
ConsoleType(string , TypeRealString , String , "" )
ConsoleType(string , TypeString , const char * , "" )
ConsoleType(string , TypeTerrainMaterialName , const char * , "" )
ConsoleType(uuid , TypeUUID , Torque::UUID , "" )

Detailed Description

Public Variables

String ConsoleGetType (TypeRealString)

Public Functions

ConsoleGetType(TypeBool )

ConsoleGetType(TypeBoolVector )

ConsoleGetType(TypeCaseString )

ConsoleGetType(TypeColorF )

ConsoleGetType(TypeColorI )

ConsoleGetType(TypeF32 )

ConsoleGetType(TypeF32Vector )

ConsoleGetType(TypeFilename )

ConsoleGetType(TypeImageFilename )

ConsoleGetType(TypePID )

ConsoleGetType(TypePrefabFilename )

ConsoleGetType(TypeS32 )

ConsoleGetType(TypeS32Vector )

ConsoleGetType(TypeS8 )

ConsoleGetType(TypeShapeFilename )

ConsoleGetType(TypeSimObjectName )

ConsoleGetType(TypeSimObjectPtr )

ConsoleGetType(TypeString )

ConsoleGetType(TypeStringFilename )

ConsoleGetType(TypeUUID )

ConsolePrepType(filename , TypeFilename , const char * )

ConsolePrepType(filename , TypeImageFilename , String )

ConsolePrepType(filename , TypePrefabFilename , String )

ConsolePrepType(filename , TypeShapeFilename , const char * )

ConsolePrepType(filename , TypeStringFilename , String )

ConsoleProcessData(TypeFilename )

ConsoleProcessData(TypeImageFilename )

ConsoleProcessData(TypePrefabFilename )

ConsoleProcessData(TypeShapeFilename )

ConsoleProcessData(TypeStringFilename )

ConsoleSetType(TypeBool )

ConsoleSetType(TypeBoolVector )

ConsoleSetType(TypeColorF )

ConsoleSetType(TypeColorI )

ConsoleSetType(TypeCommand )

ConsoleSetType(TypeCubemapName )

ConsoleSetType(TypeF32 )

ConsoleSetType(TypeF32Vector )

ConsoleSetType(TypeFlag )

ConsoleSetType(TypeMaterialName )

ConsoleSetType(TypeName )

ConsoleSetType(TypeParticleParameterString )

ConsoleSetType(TypePID )

ConsoleSetType(TypeRealString )

ConsoleSetType(TypeRectUV )

ConsoleSetType(TypeS32 )

ConsoleSetType(TypeS32Vector )

ConsoleSetType(TypeS8 )

ConsoleSetType(TypeSimPersistId )

ConsoleSetType(TypeString )

ConsoleSetType(TypeTerrainMaterialIndex )

ConsoleSetType(TypeTerrainMaterialName )

ConsoleSetType(TypeUUID )

ConsoleType(bool , TypeBool , bool , "" )

ConsoleType(boolList , TypeBoolVector , Vector< bool > , "" )

ConsoleType(caseString , TypeCaseString , const char * , "" )

ConsoleType(char , TypeS8 , S8 , "" )

ConsoleType(ColorI , TypeColorI , ColorI , "" )

ConsoleType(flag , TypeFlag , S32 , "" )

ConsoleType(float , TypeF32 , F32 , "" )

ConsoleType(floatList , TypeF32Vector , Vector< F32 > , "" )

ConsoleType(int , TypeS32 , S32 , "" )

ConsoleType(int , TypeTerrainMaterialIndex , S32 , "" )

ConsoleType(intList , TypeS32Vector , Vector< S32 > , "" )

ConsoleType(LinearColorF , TypeColorF , LinearColorF , "" )

ConsoleType(pid , TypePID , SimPersistID * , "" )

ConsoleType(RectF , TypeRectUV , RectF , "" )

ConsoleType(SimObject , TypeSimObjectName , SimObject * , "" )

ConsoleType(SimObject , TypeSimObjectPtr , SimObject * , "" )

ConsoleType(SimPersistId , TypeSimPersistId , SimPersistID * , "" )

ConsoleType(string , TypeCommand , String , "" )

ConsoleType(string , TypeCubemapName , String , "" )

ConsoleType(string , TypeMaterialName , String , "" )

ConsoleType(string , TypeName , const char * , "" )

ConsoleType(string , TypeParticleParameterString , const char * , "" )

ConsoleType(string , TypeRealString , String , "" )

ConsoleType(string , TypeString , const char * , "" )

ConsoleType(string , TypeTerrainMaterialName , const char * , "" )

ConsoleType(uuid , TypeUUID , Torque::UUID , "" )

   1
   2//-----------------------------------------------------------------------------
   3// Copyright (c) 2012 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#include "console/console.h"
  25#include "console/consoleTypes.h"
  26#include "console/simPersistID.h"
  27#include "core/stringTable.h"
  28#include "core/util/str.h"
  29#include "core/util/uuid.h"
  30#include "core/color.h"
  31#include "console/simBase.h"
  32#include "math/mRect.h"
  33#include "core/strings/stringUnit.h"
  34
  35//-----------------------------------------------------------------------------
  36// TypeString
  37//-----------------------------------------------------------------------------
  38ConsoleType( string, TypeString, const char*, "" )
  39ImplementConsoleTypeCasters( TypeString, const char* );
  40
  41ConsoleGetType( TypeString )
  42{
  43   return *((const char **)(dptr));
  44}
  45
  46ConsoleSetType( TypeString )
  47{
  48   if(argc == 1)
  49      *((const char **) dptr) = StringTable->insert(argv[0]);
  50   else
  51      Con::printf("(TypeString) Cannot set multiple args to a single string.");
  52}
  53
  54//-----------------------------------------------------------------------------
  55// TypeCaseString
  56//-----------------------------------------------------------------------------
  57ConsoleType(caseString, TypeCaseString, const char*, "")
  58
  59ConsoleSetType( TypeCaseString )
  60{
  61   if(argc == 1)
  62      *((const char **) dptr) = StringTable->insert(argv[0], true);
  63   else
  64      Con::printf("(TypeCaseString) Cannot set multiple args to a single string.");
  65}
  66
  67ConsoleGetType( TypeCaseString )
  68{
  69   return *((const char **)(dptr));
  70}
  71
  72//-----------------------------------------------------------------------------
  73// TypeRealString
  74//-----------------------------------------------------------------------------
  75ConsoleType(string, TypeRealString, String, "")
  76ImplementConsoleTypeCasters( TypeRealString, String )
  77
  78ConsoleGetType( TypeRealString )
  79{
  80   const String *theString = static_cast<const String*>(dptr);
  81
  82   return theString->c_str();
  83}
  84
  85ConsoleSetType( TypeRealString )
  86{
  87   String *theString = static_cast<String*>(dptr);
  88
  89   if(argc == 1)
  90      *theString = argv[0];
  91   else
  92      Con::printf("(TypeRealString) Cannot set multiple args to a single string.");
  93}
  94
  95//-----------------------------------------------------------------------------
  96// TypeCommand
  97//-----------------------------------------------------------------------------
  98ConsoleType(string, TypeCommand, String, "")
  99
 100ConsoleGetType( TypeCommand )
 101{
 102   const String *theString = static_cast<const String*>(dptr);
 103
 104   return theString->c_str();
 105}
 106
 107ConsoleSetType( TypeCommand )
 108{
 109   String *theString = static_cast<String*>(dptr);
 110
 111   if(argc == 1)
 112      *theString = argv[0];
 113   else
 114      Con::printf("(TypeCommand) Cannot set multiple args to a single command.");
 115}
 116
 117//-----------------------------------------------------------------------------
 118// TypeFileName
 119//-----------------------------------------------------------------------------
 120ConsolePrepType( filename, TypeFilename, const char * )
 121
 122ConsoleSetType( TypeFilename )
 123{
 124   if(argc == 1)
 125   {
 126      char buffer[1024];
 127      if(argv[0][0] == '$')
 128      {
 129         dStrncpy(buffer, argv[0], sizeof(buffer) - 1);
 130         buffer[sizeof(buffer)-1] = 0;
 131      }
 132      else if (! Con::expandScriptFilename(buffer, 1024, argv[0]))
 133      {
 134         Con::warnf("(TypeFilename) illegal filename detected: %s", argv[0]);
 135         return;
 136      }
 137
 138      *((const char **) dptr) = StringTable->insert(buffer);
 139   }
 140   else
 141      Con::printf("(TypeFilename) Cannot set multiple args to a single filename.");
 142}
 143
 144ConsoleGetType( TypeFilename )
 145{
 146   return *((const char **)(dptr));
 147}
 148
 149ConsoleProcessData( TypeFilename )
 150{
 151   if( Con::expandScriptFilename( buffer, bufferSz, data ) )
 152      return buffer;
 153   else
 154   {
 155      Con::warnf("(TypeFilename) illegal filename detected: %s", data);
 156      return data;
 157   }
 158}
 159
 160//-----------------------------------------------------------------------------
 161// TypeStringFilename
 162//-----------------------------------------------------------------------------
 163ConsolePrepType( filename, TypeStringFilename, String )
 164
 165ConsoleSetType( TypeStringFilename )
 166{
 167   if(argc == 1)
 168   {
 169      char buffer[1024];
 170      if(argv[0][0] == '$')
 171      {
 172         dStrncpy(buffer, argv[0], sizeof(buffer) - 1);
 173         buffer[sizeof(buffer)-1] = 0;
 174      }
 175      else if (! Con::expandScriptFilename(buffer, 1024, argv[0]))
 176      {
 177         Con::warnf("(TypeStringFilename) illegal filename detected: %s", argv[0]);
 178         return;
 179      }
 180
 181      *((String*)dptr) = String(buffer);
 182   }
 183   else
 184      Con::printf("(TypeStringFilename) Cannot set multiple args to a single filename.");
 185}
 186
 187ConsoleGetType( TypeStringFilename )
 188{
 189   return *((String*)dptr);
 190}
 191
 192ConsoleProcessData( TypeStringFilename )
 193{
 194   if( Con::expandScriptFilename( buffer, bufferSz, data ) )
 195   {
 196      return buffer;
 197   }
 198   else
 199   {
 200      Con::warnf("(TypeFilename) illegal filename detected: %s", data);
 201      return data;
 202   }
 203}
 204
 205//-----------------------------------------------------------------------------
 206// TypePrefabFilename
 207//-----------------------------------------------------------------------------
 208ConsolePrepType( filename, TypePrefabFilename, String )
 209
 210ConsoleSetType( TypePrefabFilename )
 211{
 212   Con::setData(TypeStringFilename, dptr, 0, argc, argv, tbl, flag);
 213}
 214
 215ConsoleGetType( TypePrefabFilename )
 216{
 217   return *((String*)dptr);
 218}
 219
 220ConsoleProcessData( TypePrefabFilename )
 221{
 222   if( Con::expandScriptFilename( buffer, bufferSz, data ) )
 223   {
 224      return buffer;
 225   }
 226   else
 227   {
 228      Con::warnf("(TypePrefabFilename) illegal filename detected: %s", data);
 229      return data;
 230   }
 231}
 232
 233//-----------------------------------------------------------------------------
 234// TypeImageFilename
 235//-----------------------------------------------------------------------------
 236ConsolePrepType( filename, TypeImageFilename, String )
 237
 238ConsoleSetType( TypeImageFilename )
 239{
 240   Con::setData(TypeStringFilename, dptr, 0, argc, argv, tbl, flag);
 241}
 242
 243ConsoleGetType( TypeImageFilename )
 244{
 245   return *((String*)dptr);
 246}
 247
 248ConsoleProcessData( TypeImageFilename )
 249{
 250   if( Con::expandScriptFilename( buffer, bufferSz, data ) )
 251      return buffer;
 252   else
 253   {
 254      Con::warnf("(TypeImageFilename) illegal filename detected: %s", data);
 255      return data;
 256   }
 257}
 258
 259//-----------------------------------------------------------------------------
 260// TypeShapeFilename
 261//-----------------------------------------------------------------------------
 262ConsolePrepType( filename, TypeShapeFilename, const char* )
 263
 264ConsoleSetType( TypeShapeFilename )
 265{
 266   Con::setData(TypeFilename, dptr, 0, argc, argv, tbl, flag);
 267}
 268
 269ConsoleGetType( TypeShapeFilename )
 270{
 271   return *((const char **)(dptr));
 272}
 273
 274ConsoleProcessData( TypeShapeFilename )
 275{
 276   if( Con::expandScriptFilename( buffer, bufferSz, data ) )
 277      return buffer;
 278   else
 279   {
 280      Con::warnf("(TypeShapeFilename) illegal filename detected: %s", data);
 281      return data;
 282   }
 283}
 284
 285//-----------------------------------------------------------------------------
 286// TypeS8
 287//-----------------------------------------------------------------------------
 288ConsoleType(char, TypeS8, S8, "")
 289ImplementConsoleTypeCasters( TypeS8, S8 )
 290
 291ConsoleGetType( TypeS8 )
 292{
 293   static const U32 bufSize = 256;
 294   char* returnBuffer = Con::getReturnBuffer(bufSize);
 295   dSprintf(returnBuffer, bufSize, "%d", *((U8 *) dptr) );
 296   return returnBuffer;
 297}
 298
 299ConsoleSetType( TypeS8 )
 300{
 301   if(argc == 1)
 302      *((U8 *) dptr) = dAtoi(argv[0]);
 303   else
 304      Con::printf("(TypeU8) Cannot set multiple args to a single S8.");
 305}
 306
 307//-----------------------------------------------------------------------------
 308// TypeS32
 309//-----------------------------------------------------------------------------
 310ConsoleType(int, TypeS32, S32, "")
 311ImplementConsoleTypeCasters(TypeS32, S32)
 312
 313ConsoleGetType( TypeS32 )
 314{
 315   static const U32 bufSize = 512;
 316   char* returnBuffer = Con::getReturnBuffer(bufSize);
 317   dSprintf(returnBuffer, bufSize, "%d", *((S32 *) dptr) );
 318   return returnBuffer;
 319}
 320
 321ConsoleSetType( TypeS32 )
 322{
 323   if(argc == 1)
 324      *((S32 *) dptr) = dAtoi(argv[0]);
 325   else
 326      Con::printf("(TypeS32) Cannot set multiple args to a single S32.");
 327}
 328
 329
 330//-----------------------------------------------------------------------------
 331// TypeS32Vector
 332//-----------------------------------------------------------------------------
 333ConsoleType(intList, TypeS32Vector, Vector<S32>, "")
 334ImplementConsoleTypeCasters( TypeS32Vector, Vector< S32 > )
 335
 336ConsoleGetType( TypeS32Vector )
 337{
 338   Vector<S32> *vec = (Vector<S32> *)dptr;
 339   S32 buffSize = ( vec->size() * 15 ) + 16 ;
 340   char* returnBuffer = Con::getReturnBuffer( buffSize );
 341   S32 maxReturn = buffSize;
 342   returnBuffer[0] = '\0';
 343   S32 returnLeng = 0;
 344   for (Vector<S32>::iterator itr = vec->begin(); itr != vec->end(); itr++)
 345   {
 346      // concatenate the next value onto the return string
 347      dSprintf(returnBuffer + returnLeng, maxReturn - returnLeng, "%d ", *itr);
 348      // update the length of the return string (so far)
 349      returnLeng = dStrlen(returnBuffer);
 350   }
 351   // trim off that last extra space
 352   if (returnLeng > 0 && returnBuffer[returnLeng - 1] == ' ')
 353      returnBuffer[returnLeng - 1] = '\0';
 354   return returnBuffer;
 355}
 356
 357ConsoleSetType( TypeS32Vector )
 358{
 359   Vector<S32> *vec = (Vector<S32> *)dptr;
 360   // we assume the vector should be cleared first (not just appending)
 361   vec->clear();
 362   if(argc == 1)
 363   {
 364      const char *values = argv[0];
 365      const char *endValues = values + dStrlen(values);
 366      S32 value;
 367      // advance through the string, pulling off S32's and advancing the pointer
 368      while (values < endValues && dSscanf(values, "%d", &value) != 0)
 369      {
 370         vec->push_back(value);
 371         const char *nextValues = dStrchr(values, ' ');
 372         if (nextValues != 0 && nextValues < endValues)
 373            values = nextValues + 1;
 374         else
 375            break;
 376      }
 377   }
 378   else if (argc > 1)
 379   {
 380      for (S32 i = 0; i < argc; i++)
 381         vec->push_back(dAtoi(argv[i]));
 382   }
 383   else
 384      Con::printf("Vector<S32> must be set as { a, b, c, ... } or \"a b c ...\"");
 385}
 386
 387//-----------------------------------------------------------------------------
 388// TypeF32
 389//-----------------------------------------------------------------------------
 390ConsoleType(float, TypeF32, F32, "")
 391ImplementConsoleTypeCasters(TypeF32, F32)
 392
 393ConsoleGetType( TypeF32 )
 394{
 395   static const U32 bufSize = 256;
 396   char* returnBuffer = Con::getReturnBuffer(bufSize);
 397   dSprintf(returnBuffer, bufSize, "%g", *((F32 *) dptr) );
 398   return returnBuffer;
 399}
 400ConsoleSetType( TypeF32 )
 401{
 402   if(argc == 1)
 403      *((F32 *) dptr) = dAtof(argv[0]);
 404   else
 405      Con::printf("(TypeF32) Cannot set multiple args to a single F32.");
 406}
 407
 408//-----------------------------------------------------------------------------
 409// TypeF32Vector
 410//-----------------------------------------------------------------------------
 411ConsoleType(floatList, TypeF32Vector, Vector<F32>, "")
 412ImplementConsoleTypeCasters( TypeF32Vector, Vector< F32 > )
 413
 414ConsoleGetType( TypeF32Vector )
 415{
 416   Vector<F32> *vec = (Vector<F32> *)dptr;
 417   S32 buffSize = ( vec->size() * 15 ) + 16 ;
 418   char* returnBuffer = Con::getReturnBuffer( buffSize );
 419   S32 maxReturn = buffSize;
 420   returnBuffer[0] = '\0';
 421   S32 returnLeng = 0;
 422   for (Vector<F32>::iterator itr = vec->begin(); itr != vec->end(); itr++)
 423   {
 424      // concatenate the next value onto the return string
 425      dSprintf(returnBuffer + returnLeng, maxReturn - returnLeng, "%g ", *itr);
 426      // update the length of the return string (so far)
 427      returnLeng = dStrlen(returnBuffer);
 428   }
 429   // trim off that last extra space
 430   if (returnLeng > 0 && returnBuffer[returnLeng - 1] == ' ')
 431      returnBuffer[returnLeng - 1] = '\0';
 432   return returnBuffer;
 433}
 434
 435ConsoleSetType( TypeF32Vector )
 436{
 437   Vector<F32> *vec = (Vector<F32> *)dptr;
 438   // we assume the vector should be cleared first (not just appending)
 439   vec->clear();
 440   if(argc == 1)
 441   {
 442      const char *values = argv[0];
 443      const char *endValues = values + dStrlen(values);
 444      F32 value;
 445      // advance through the string, pulling off F32's and advancing the pointer
 446      while (values < endValues && dSscanf(values, "%g", &value) != 0)
 447      {
 448         vec->push_back(value);
 449         const char *nextValues = dStrchr(values, ' ');
 450         if (nextValues != 0 && nextValues < endValues)
 451            values = nextValues + 1;
 452         else
 453            break;
 454      }
 455   }
 456   else if (argc > 1)
 457   {
 458      for (S32 i = 0; i < argc; i++)
 459         vec->push_back(dAtof(argv[i]));
 460   }
 461   else
 462      Con::printf("Vector<F32> must be set as { a, b, c, ... } or \"a b c ...\"");
 463}
 464
 465//-----------------------------------------------------------------------------
 466// TypeBool
 467//-----------------------------------------------------------------------------
 468ConsoleType(bool, TypeBool, bool, "")
 469ImplementConsoleTypeCasters( TypeBool, bool )
 470
 471ConsoleGetType( TypeBool )
 472{
 473   return *((bool *) dptr) ? "1" : "0";
 474}
 475
 476ConsoleSetType( TypeBool )
 477{
 478   if(argc == 1)
 479      *((bool *) dptr) = dAtob(argv[0]);
 480   else
 481      Con::printf("(TypeBool) Cannot set multiple args to a single bool.");
 482}
 483
 484
 485//-----------------------------------------------------------------------------
 486// TypeBoolVector
 487//-----------------------------------------------------------------------------
 488ConsoleType(boolList, TypeBoolVector, Vector<bool>, "")
 489ImplementConsoleTypeCasters( TypeBoolVector, Vector< bool > )
 490
 491ConsoleGetType( TypeBoolVector )
 492{
 493   Vector<bool> *vec = (Vector<bool>*)dptr;
 494   static const U32 bufSize = 1024;
 495   char* returnBuffer = Con::getReturnBuffer(bufSize);
 496   S32 maxReturn = bufSize;
 497   returnBuffer[0] = '\0';
 498   S32 returnLeng = 0;
 499   for (Vector<bool>::iterator itr = vec->begin(); itr < vec->end(); itr++)
 500   {
 501      // concatenate the next value onto the return string
 502      dSprintf(returnBuffer + returnLeng, maxReturn - returnLeng, "%d ", (*itr == true ? 1 : 0));
 503      returnLeng = dStrlen(returnBuffer);
 504   }
 505   // trim off that last extra space
 506   if (returnLeng > 0 && returnBuffer[returnLeng - 1] == ' ')
 507      returnBuffer[returnLeng - 1] = '\0';
 508   return(returnBuffer);
 509}
 510
 511ConsoleSetType( TypeBoolVector )
 512{
 513   Vector<bool> *vec = (Vector<bool>*)dptr;
 514   // we assume the vector should be cleared first (not just appending)
 515   vec->clear();
 516   if (argc == 1)
 517   {
 518      const char *values = argv[0];
 519      const char *endValues = values + dStrlen(values);
 520      S32 value;
 521      // advance through the string, pulling off bool's and advancing the pointer
 522      while (values < endValues && dSscanf(values, "%d", &value) != 0)
 523      {
 524         vec->push_back(value == 0 ? false : true);
 525         const char *nextValues = dStrchr(values, ' ');
 526         if (nextValues != 0 && nextValues < endValues)
 527            values = nextValues + 1;
 528         else
 529            break;
 530      }
 531   }
 532   else if (argc > 1)
 533   {
 534      for (S32 i = 0; i < argc; i++)
 535         vec->push_back(dAtob(argv[i]));
 536   }
 537   else
 538      Con::printf("Vector<bool> must be set as { a, b, c, ... } or \"a b c ...\"");
 539}
 540
 541
 542//-----------------------------------------------------------------------------
 543// TypeFlag
 544//-----------------------------------------------------------------------------
 545ConsoleType(flag, TypeFlag, S32, "")
 546
 547ConsoleGetType( TypeFlag )
 548{
 549   BitSet32 tempFlags = *(BitSet32 *)dptr;
 550   if (tempFlags.test(flag)) return "true";
 551   else return "false";
 552}
 553
 554ConsoleSetType( TypeFlag )
 555{
 556   bool value = true;
 557   if (argc != 1)
 558   {
 559      Con::printf("flag must be true or false");
 560   }
 561   else
 562   {
 563      value = dAtob(argv[0]);
 564   }
 565   ((BitSet32 *)dptr)->set(flag, value);
 566}
 567
 568//-----------------------------------------------------------------------------
 569// TypeColorF
 570//-----------------------------------------------------------------------------
 571ConsoleType(LinearColorF, TypeColorF, LinearColorF, "")
 572ImplementConsoleTypeCasters( TypeColorF, LinearColorF )
 573
 574ConsoleGetType( TypeColorF )
 575{
 576   // Fetch color.
 577   const LinearColorF* color = (LinearColorF*)dptr;
 578
 579   // Fetch stock color name.
 580   StringTableEntry colorName = StockColor::name( *color );
 581
 582   // Write as color name if was found.
 583   if ( colorName != StringTable->EmptyString() ) 
 584      return colorName;
 585
 586   // Format as color components.
 587   static const U32 bufSize = 256;
 588   char* returnBuffer = Con::getReturnBuffer(bufSize);
 589   dSprintf(returnBuffer, bufSize, "%g %g %g %g", color->red, color->green, color->blue, color->alpha);
 590   return(returnBuffer);
 591}
 592
 593ConsoleSetType( TypeColorF )
 594{
 595   LinearColorF *tmpColor = (LinearColorF *) dptr;
 596   if(argc == 1)
 597   {
 598      // Is only a single argument passed?
 599      if ( StringUnit::getUnitCount( argv[0], " " ) == 1 )
 600      {
 601         // Is this a stock color name?
 602         if ( !StockColor::isColor(argv[0]) )
 603         {
 604            // No, so warn.
 605            Con::warnf( "TypeColorF() - Invalid single argument of '%s' could not be interpreted as a stock color name.  Using default.", argv[0] );
 606         }
 607
 608         // Set stock color (if it's invalid we'll get the default.
 609         tmpColor->set( argv[0] );
 610
 611         return;
 612      }
 613
 614      tmpColor->set(0, 0, 0, 1);
 615      F32 r,g,b,a;
 616      S32 args = dSscanf(argv[0], "%g %g %g %g", &r, &g, &b, &a);
 617      tmpColor->red = r;
 618      tmpColor->green = g;
 619      tmpColor->blue = b;
 620      if (args == 4)
 621         tmpColor->alpha = a;
 622   }
 623   else if(argc == 3)
 624   {
 625      tmpColor->red    = dAtof(argv[0]);
 626      tmpColor->green  = dAtof(argv[1]);
 627      tmpColor->blue   = dAtof(argv[2]);
 628      tmpColor->alpha  = 1.f;
 629   }
 630   else if(argc == 4)
 631   {
 632      tmpColor->red    = dAtof(argv[0]);
 633      tmpColor->green  = dAtof(argv[1]);
 634      tmpColor->blue   = dAtof(argv[2]);
 635      tmpColor->alpha  = dAtof(argv[3]);
 636   }
 637   else
 638      Con::printf("Color must be set as { r, g, b [,a] }, { r g b [b] } or { stockColorName }");
 639}
 640
 641//-----------------------------------------------------------------------------
 642// TypeColorI
 643//-----------------------------------------------------------------------------
 644ConsoleType(ColorI, TypeColorI, ColorI, "")
 645ImplementConsoleTypeCasters( TypeColorI, ColorI )
 646
 647ConsoleGetType( TypeColorI )
 648{
 649   // Fetch color.
 650   ColorI* color = (ColorI*)dptr;
 651
 652   // Fetch stock color name.
 653   StringTableEntry colorName = StockColor::name( *color );
 654
 655   // Write as color name if was found.
 656   if ( colorName != StringTable->EmptyString() ) 
 657      return colorName;
 658
 659   // Format as color components.
 660   static const U32 bufSize = 256;
 661   char* returnBuffer = Con::getReturnBuffer(bufSize);
 662   dSprintf(returnBuffer, bufSize, "%d %d %d %d", color->red, color->green, color->blue, color->alpha);
 663   return returnBuffer;
 664}
 665
 666ConsoleSetType( TypeColorI )
 667{
 668   ColorI *tmpColor = (ColorI *) dptr;
 669   if(argc == 1)
 670   {
 671      // Is only a single argument passed?
 672      if ( StringUnit::getUnitCount( argv[0], " " ) == 1 )
 673      {
 674         // Is this a stock color name?
 675         if ( !StockColor::isColor(argv[0]) )
 676         {
 677            // No, so warn.
 678            Con::warnf( "TypeColorF() - Invalid single argument of '%s' could not be interpreted as a stock color name.  Using default.", argv[0] );
 679         }
 680
 681         // Set stock color (if it's invalid we'll get the default.
 682         tmpColor->set( argv[0] );
 683
 684         return;
 685      }
 686
 687      tmpColor->set(0, 0, 0, 255);
 688      S32 r,g,b,a;
 689      S32 args = dSscanf(argv[0], "%d %d %d %d", &r, &g, &b, &a);
 690      tmpColor->red = r;
 691      tmpColor->green = g;
 692      tmpColor->blue = b;
 693      if (args == 4)
 694         tmpColor->alpha = a;
 695   }
 696   else if(argc == 3)
 697   {
 698      tmpColor->red    = dAtoi(argv[0]);
 699      tmpColor->green  = dAtoi(argv[1]);
 700      tmpColor->blue   = dAtoi(argv[2]);
 701      tmpColor->alpha  = 255;
 702   }
 703   else if(argc == 4)
 704   {
 705      tmpColor->red    = dAtoi(argv[0]);
 706      tmpColor->green  = dAtoi(argv[1]);
 707      tmpColor->blue   = dAtoi(argv[2]);
 708      tmpColor->alpha  = dAtoi(argv[3]);
 709   }
 710   else
 711      Con::printf("Color must be set as { r, g, b [,a] }, { r g b [b] }  or { stockColorName }");
 712}
 713
 714//-----------------------------------------------------------------------------
 715// TypeSimObjectPtr
 716//-----------------------------------------------------------------------------
 717ConsoleType(SimObject, TypeSimObjectPtr, SimObject*, "")
 718
 719ConsoleSetType(TypeSimObjectPtr)
 720{
 721   if (argc == 1)
 722   {
 723      SimObject **obj = (SimObject **)dptr;
 724      *obj = Sim::findObject(argv[0]);
 725   }
 726   else
 727      Con::printf("(TypeSimObjectPtr) Cannot set multiple args to a single S32.");
 728}
 729
 730ConsoleGetType(TypeSimObjectPtr)
 731{
 732   SimObject **obj = (SimObject**)dptr;
 733   static const U32 bufSize = 128;
 734   char* returnBuffer = Con::getReturnBuffer(bufSize);
 735   dSprintf(returnBuffer, bufSize, "%s", *obj ? (*obj)->getName() ? (*obj)->getName() : (*obj)->getIdString() : "");
 736   return returnBuffer;
 737}
 738
 739//-----------------------------------------------------------------------------
 740// TypeSimObjectName
 741//-----------------------------------------------------------------------------
 742ConsoleType(SimObject, TypeSimObjectName, SimObject*, "")
 743
 744ConsoleSetType( TypeSimObjectName )
 745{
 746   if(argc == 1)
 747   {
 748      SimObject **obj = (SimObject **)dptr;
 749      *obj = Sim::findObject(argv[0]);
 750   }
 751   else
 752      Con::printf("(TypeSimObjectName) Cannot set multiple args to a single S32.");
 753}
 754
 755ConsoleGetType( TypeSimObjectName )
 756{
 757   SimObject **obj = (SimObject**)dptr;
 758   static const U32 bufSize = 128;
 759   char* returnBuffer = Con::getReturnBuffer(bufSize);
 760   dSprintf(returnBuffer, bufSize, "%s", *obj && (*obj)->getName() ? (*obj)->getName() : "");
 761   return returnBuffer;
 762}
 763
 764//-----------------------------------------------------------------------------
 765// TypeName
 766//-----------------------------------------------------------------------------
 767ConsoleType(string, TypeName, const char*, "")
 768
 769ConsoleGetType( TypeName )
 770{
 771   return *((const char **)(dptr));
 772}
 773
 774ConsoleSetType( TypeName )
 775{   
 776   Con::warnf( "ConsoleSetType( TypeName ) should not be called. A ProtectedSetMethod does this work!" );
 777}
 778
 779//------------------------------------------------------------------------------
 780// TypeParticleParameterString
 781//------------------------------------------------------------------------------
 782ConsoleType(string, TypeParticleParameterString, const char*, "")
 783
 784ConsoleGetType( TypeParticleParameterString )
 785{
 786   return *((const char **)(dptr));
 787}
 788
 789ConsoleSetType( TypeParticleParameterString )
 790{
 791   if(argc == 1)
 792      *((const char **) dptr) = StringTable->insert(argv[0]);
 793   else
 794      Con::printf("(TypeParticleParameterString) Cannot set multiple args to a single string.");
 795}
 796
 797//-----------------------------------------------------------------------------
 798// TypeMaterialName
 799//-----------------------------------------------------------------------------
 800
 801ConsoleType(string, TypeMaterialName, String, "")
 802
 803ConsoleGetType( TypeMaterialName )
 804{
 805   const String *theString = static_cast<const String*>(dptr);
 806   return theString->c_str();
 807}
 808
 809ConsoleSetType( TypeMaterialName )
 810{
 811   String *theString = static_cast<String*>(dptr);
 812
 813   if(argc == 1)
 814      *theString = argv[0];
 815   else
 816      Con::printf("(TypeMaterialName) Cannot set multiple args to a single string.");
 817}
 818
 819//-----------------------------------------------------------------------------
 820// TypeTerrainMaterialIndex
 821//-----------------------------------------------------------------------------
 822
 823ConsoleType(int, TypeTerrainMaterialIndex, S32, "")
 824
 825ConsoleGetType( TypeTerrainMaterialIndex )
 826{
 827   static const U32 bufSize = 256;
 828   char* returnBuffer = Con::getReturnBuffer(bufSize);
 829   dSprintf(returnBuffer, bufSize, "%d", *((S32 *) dptr) );
 830   return returnBuffer;
 831}
 832
 833ConsoleSetType( TypeTerrainMaterialIndex )
 834{
 835   if(argc == 1)
 836      *((S32 *) dptr) = dAtoi(argv[0]);
 837   else
 838      Con::printf("(TypeTerrainMaterialIndex) Cannot set multiple args to a single S32.");
 839}
 840
 841//-----------------------------------------------------------------------------
 842// TypeTerrainMaterialName
 843//-----------------------------------------------------------------------------
 844
 845ConsoleType(string, TypeTerrainMaterialName, const char*, "")
 846
 847ConsoleGetType( TypeTerrainMaterialName )
 848{
 849   return *((const char **)(dptr));
 850}
 851
 852ConsoleSetType( TypeTerrainMaterialName )
 853{
 854   if(argc == 1)
 855      *((const char **) dptr) = StringTable->insert(argv[0]);
 856   else
 857      Con::printf("(TypeTerrainMaterialName) Cannot set multiple args to a single string.");
 858}
 859
 860//-----------------------------------------------------------------------------
 861// TypeCubemapName
 862//-----------------------------------------------------------------------------
 863
 864ConsoleType(string, TypeCubemapName, String, "")
 865
 866ConsoleGetType( TypeCubemapName )
 867{
 868   const String *theString = static_cast<const String*>(dptr);
 869   return theString->c_str();
 870}
 871
 872ConsoleSetType( TypeCubemapName )
 873{
 874   String *theString = static_cast<String*>(dptr);
 875
 876   if(argc == 1)
 877      *theString = argv[0];
 878   else
 879      Con::printf("(TypeCubemapName) Cannot set multiple args to a single string.");
 880}
 881
 882//-----------------------------------------------------------------------------
 883// TypeRectUV
 884//-----------------------------------------------------------------------------
 885ConsoleType(RectF, TypeRectUV, RectF, "")
 886
 887ConsoleGetType( TypeRectUV )
 888{
 889   RectF *rect = (RectF *) dptr;
 890   static const U32 bufSize = 256;
 891   char* returnBuffer = Con::getReturnBuffer(bufSize);
 892   dSprintf(returnBuffer, bufSize, "%g %g %g %g", rect->point.x, rect->point.y,
 893            rect->extent.x, rect->extent.y);
 894   return returnBuffer;
 895}
 896
 897ConsoleSetType( TypeRectUV )
 898{
 899   if(argc == 1)
 900      dSscanf(argv[0], "%g %g %g %g", &((RectF *) dptr)->point.x, &((RectF *) dptr)->point.y,
 901              &((RectF *) dptr)->extent.x, &((RectF *) dptr)->extent.y);
 902   else if(argc == 4)
 903      *((RectF *) dptr) = RectF(dAtof(argv[0]), dAtof(argv[1]), dAtof(argv[2]), dAtof(argv[3]));
 904   else
 905      Con::printf("RectUV must be set as { x, y, w, h } or \"x y w h\"");
 906}
 907
 908//-----------------------------------------------------------------------------
 909// TypeUUID
 910//-----------------------------------------------------------------------------
 911ConsoleType(uuid, TypeUUID, Torque::UUID, "")
 912ImplementConsoleTypeCasters( TypeUUID, Torque::UUID )
 913
 914ConsoleGetType( TypeUUID )
 915{
 916   Torque::UUID* uuid = ( Torque::UUID* ) dptr;
 917   return Con::getReturnBuffer( uuid->toString() );
 918}
 919
 920ConsoleSetType( TypeUUID )
 921{
 922   if( argc == 1 )
 923   {
 924      Torque::UUID* uuid = ( Torque::UUID* ) dptr;
 925      if( !uuid->fromString( argv[ 0 ] ) )
 926         Con::errorf( "Error parsing UUID: '%s'", argv[ 0 ] );
 927   }
 928   else
 929      Con::printf( "(TypeUUID) Cannot set multiple args to a single uuid." );
 930}
 931
 932//-----------------------------------------------------------------------------
 933// TypePID
 934//-----------------------------------------------------------------------------
 935ConsoleType(pid, TypePID, SimPersistID*, "")
 936ImplementConsoleTypeCasters( TypePID, SimPersistID* )
 937
 938ConsoleGetType( TypePID )
 939{
 940   SimPersistID* pid = *( ( SimPersistID** ) dptr );
 941   if( !pid )
 942      return "";
 943      
 944   return Con::getReturnBuffer( pid->getUUID().toString() );
 945}
 946
 947ConsoleSetType( TypePID )
 948{
 949   if( argc == 1 )
 950   {
 951      SimPersistID** pid = ( SimPersistID** ) dptr;
 952      
 953      if( !argv[ 0 ][ 0 ] )
 954         *pid = NULL;
 955      else
 956      {
 957         Torque::UUID uuid;
 958         if( !uuid.fromString( argv[ 0 ] ) )
 959         {
 960            Con::errorf( "Error parsing UUID in PID: '%s'", argv[ 0 ] );
 961            *pid = NULL;
 962         }
 963         else
 964            *pid = SimPersistID::findOrCreate( uuid );
 965      }
 966   }
 967   else
 968      Con::printf( "(TypePID) Cannot set multiple args to a single pid." );
 969}
 970
 971//-----------------------------------------------------------------------------
 972// TypeSimPersistId
 973//-----------------------------------------------------------------------------
 974ConsoleType(SimPersistId, TypeSimPersistId, SimPersistID*, "")
 975
 976ConsoleGetType( TypeSimPersistId )
 977{
 978   SimPersistID* pid = *( ( SimPersistID** ) dptr );
 979   if( !pid )
 980      return "";
 981      
 982   return Con::getReturnBuffer( pid->getUUID().toString() );
 983}
 984
 985ConsoleSetType( TypeSimPersistId )
 986{
 987   if( argc == 1 )
 988   {
 989      SimPersistID** pid = ( SimPersistID** ) dptr;
 990      
 991      if( !argv[ 0 ][ 0 ] )
 992         *pid = NULL;
 993      else
 994      {
 995         Torque::UUID uuid;
 996         if( !uuid.fromString( argv[ 0 ] ) )
 997         {
 998            Con::errorf( "Error parsing UUID in PID: '%s'", argv[ 0 ] );
 999            *pid = NULL;
1000         }
1001         else
1002            *pid = SimPersistID::find( uuid );
1003      }
1004   }
1005   else
1006      Con::printf( "(TypeSimPersistId) Cannot set multiple args to a single SimPersistId." );
1007}
1008