afxGuiText.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  2. // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  3. // Copyright (C) 2015 Faust Logic, Inc.
  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 "afx/arcaneFX.h"
  25. #include "core/stream/bitStream.h"
  26. #include "afx/ce/afxGuiText.h"
  27. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  28. // afxGuiTextData
  29. IMPLEMENT_CO_DATABLOCK_V1(afxGuiTextData);
  30. ConsoleDocClass( afxGuiTextData,
  31. "@brief A datablock that specifies a Gui Text effect.\n\n"
  32. "A Gui Text effect, with the help of an existing afxGuiTextHud, can be used to display 2D text effects on the Gui Canvas. "
  33. "Essentially, using Gui Text effects with an afxGuiTextHud is like using the stock GuiShapeNameHud, but with the ability "
  34. "to make additional text elements come and go as effects constrained to the projection of 3D positions onto the 2D screen."
  35. "\n\n"
  36. "@ingroup afxEffects\n"
  37. "@ingroup AFX\n"
  38. "@ingroup Datablocks\n"
  39. );
  40. afxGuiTextData::afxGuiTextData()
  41. {
  42. text_str = ST_NULLSTRING;
  43. text_clr.set(1,1,1,1);
  44. }
  45. afxGuiTextData::afxGuiTextData(const afxGuiTextData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  46. {
  47. text_str = other.text_str;
  48. text_clr = other.text_clr;
  49. }
  50. #define myOffset(field) Offset(field, afxGuiTextData)
  51. void afxGuiTextData::initPersistFields()
  52. {
  53. addField("text", TypeString, myOffset(text_str),
  54. "The literal text to display on the afxGuiTextHud. The center of the text will be "
  55. "placed at the projection of the 3D constraint position into 2D screen space.\n"
  56. "If the text field is set to the special string, '#shapeName', the shape name of the "
  57. "primary position constraint object will be used. (This is only meaningful if the "
  58. "constraint source is a ShapeBase-derived object.)");
  59. addField("color", TypeColorF, myOffset(text_clr),
  60. "A color value for the text label.");
  61. Parent::initPersistFields();
  62. }
  63. bool afxGuiTextData::onAdd()
  64. {
  65. if (Parent::onAdd() == false)
  66. return false;
  67. return true;
  68. }
  69. void afxGuiTextData::packData(BitStream* stream)
  70. {
  71. Parent::packData(stream);
  72. stream->writeString(text_str);
  73. stream->write(text_clr);
  74. }
  75. void afxGuiTextData::unpackData(BitStream* stream)
  76. {
  77. Parent::unpackData(stream);
  78. text_str = stream->readSTString();
  79. stream->read(&text_clr);
  80. }
  81. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//