Torque3D Documentation / _generateds / afxEA_ConsoleMessage.cpp

afxEA_ConsoleMessage.cpp

Engine/source/afx/ea/afxEA_ConsoleMessage.cpp

More...

Classes:

Detailed Description

  1
  2
  3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  5// Copyright (C) 2015 Faust Logic, Inc.
  6//
  7// Permission is hereby granted, free of charge, to any person obtaining a copy
  8// of this software and associated documentation files (the "Software"), to
  9// deal in the Software without restriction, including without limitation the
 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 11// sell copies of the Software, and to permit persons to whom the Software is
 12// furnished to do so, subject to the following conditions:
 13//
 14// The above copyright notice and this permission notice shall be included in
 15// all copies or substantial portions of the Software.
 16//
 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 23// IN THE SOFTWARE.
 24//
 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 26
 27#include <typeinfo>
 28#include "afx/arcaneFX.h"
 29#include "afx/afxEffectDefs.h"
 30#include "afx/afxEffectWrapper.h"
 31#include "afx/afxChoreographer.h"
 32#include "afx/ce/afxConsoleMessage.h"
 33
 34//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 35// afxEA_ConsoleMessage 
 36
 37class afxEA_ConsoleMessage : public afxEffectWrapper
 38{
 39  typedef afxEffectWrapper Parent;
 40  
 41  afxConsoleMessageData*  message_data;
 42  bool              displayed;
 43  
 44  void              do_runtime_substitutions();
 45
 46public:
 47  /*C*/             afxEA_ConsoleMessage();
 48
 49  virtual bool      isDone() { return displayed; }
 50
 51  virtual void      ea_set_datablock(SimDataBlock*);
 52  virtual bool      ea_start();
 53  virtual bool      ea_update(F32 dt);
 54};
 55
 56//~~~~~~~~~~~~~~~~~~~~//
 57
 58afxEA_ConsoleMessage::afxEA_ConsoleMessage()
 59{
 60  message_data = 0;
 61  displayed = false;
 62}
 63
 64void afxEA_ConsoleMessage::ea_set_datablock(SimDataBlock* db)
 65{
 66  message_data = dynamic_cast<afxConsoleMessageData*>(db);
 67}
 68
 69bool afxEA_ConsoleMessage::ea_start()
 70{
 71  if (!message_data)
 72  {
 73    Con::errorf("afxEA_ConsoleMessage::ea_start() -- missing or incompatible datablock.");
 74    return false;
 75  }
 76
 77  do_runtime_substitutions();
 78
 79  return true;
 80}
 81
 82bool afxEA_ConsoleMessage::ea_update(F32 dt)
 83{
 84  if (!displayed)
 85  {
 86    if (message_data->message_str != ST_NULLSTRING)
 87      Con::printf("ConsoleMessage: \"%s\"", message_data->message_str);
 88    displayed = true;
 89  }
 90
 91  return true;
 92}
 93
 94void afxEA_ConsoleMessage::do_runtime_substitutions()
 95{
 96  // only clone the datablock if there are substitutions
 97  if (message_data->getSubstitutionCount() > 0)
 98  {
 99    // clone the datablock and perform substitutions
100    afxConsoleMessageData* orig_db = message_data;
101    message_data = new afxConsoleMessageData(*orig_db, true);
102    orig_db->performSubstitutions(message_data, mChoreographer, mGroup_index);
103  }
104}
105
106//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
107
108class afxEA_ConsoleMessageDesc : public afxEffectAdapterDesc, public afxEffectDefs 
109{
110  static afxEA_ConsoleMessageDesc desc;
111
112public:
113  virtual bool  testEffectType(const SimDataBlock*) const;
114  virtual bool  requiresStop(const afxEffectWrapperData*, const afxEffectTimingData&) const { return false; }
115  virtual bool  runsOnServer(const afxEffectWrapperData*) const { return true; }
116  virtual bool  runsOnClient(const afxEffectWrapperData*) const { return true; }
117  virtual bool  isPositional(const afxEffectWrapperData*) const { return false; }
118
119  virtual afxEffectWrapper* create() const { return new afxEA_ConsoleMessage; }
120};
121
122afxEA_ConsoleMessageDesc afxEA_ConsoleMessageDesc::desc;
123
124bool afxEA_ConsoleMessageDesc::testEffectType(const SimDataBlock* db) const
125{
126  return (typeid(afxConsoleMessageData) == typeid(*db));
127}
128
129//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
130