afxGuiController.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/afxGuiController.h"
  27. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  28. // afxGuiControllerData
  29. IMPLEMENT_CO_DATABLOCK_V1(afxGuiControllerData);
  30. ConsoleDocClass( afxGuiControllerData,
  31. "@brief A datablock that specifies a Gui Controller effect.\n\n"
  32. "A Gui Controller enables effect manipulation of pre-existing gui controls. With a Gui Controller effect, a regular gui control "
  33. "is located by name, made visible during the lifetime of the effect, and potentially repositioned by projecting 3D constraint "
  34. "positions into 2D screen space. In addition, when used with a progress-bar control, (GuiProgressCtrl, afxSpellCastBar, "
  35. "afxStatusBar), the progress-bar will continuously reflect the elapsed progress of the effect over its lifetime."
  36. "\n\n"
  37. "@ingroup afxEffects\n"
  38. "@ingroup AFX\n"
  39. "@ingroup Datablocks\n"
  40. );
  41. afxGuiControllerData::afxGuiControllerData()
  42. {
  43. control_name = ST_NULLSTRING;
  44. preserve_pos = false;
  45. ctrl_client_only = false;
  46. }
  47. afxGuiControllerData::afxGuiControllerData(const afxGuiControllerData& other, bool temp_clone) : GameBaseData(other, temp_clone)
  48. {
  49. control_name = other.control_name;
  50. preserve_pos = other.preserve_pos;
  51. ctrl_client_only = other.ctrl_client_only;
  52. }
  53. #define myOffset(field) Offset(field, afxGuiControllerData)
  54. void afxGuiControllerData::initPersistFields()
  55. {
  56. addField("controlName", TypeString, myOffset(control_name),
  57. "Specifies the name of an existing gui-control.");
  58. addField("preservePosition", TypeBool, myOffset(preserve_pos),
  59. "When true, the gui-control will retain its initial position, otherwise the "
  60. "gui-control position will be continuously updated using a projection of the "
  61. "3D constraint position into 2D screen coordinates.");
  62. addField("controllingClientOnly", TypeBool, myOffset(ctrl_client_only),
  63. "If true, the effect will only be applied to a gui-control on the client that "
  64. "matches the controlling-client of the primary position constraint object.");
  65. Parent::initPersistFields();
  66. }
  67. bool afxGuiControllerData::onAdd()
  68. {
  69. if (Parent::onAdd() == false)
  70. return false;
  71. return true;
  72. }
  73. void afxGuiControllerData::packData(BitStream* stream)
  74. {
  75. Parent::packData(stream);
  76. stream->writeString(control_name);
  77. stream->writeFlag(preserve_pos);
  78. stream->writeFlag(ctrl_client_only);
  79. }
  80. void afxGuiControllerData::unpackData(BitStream* stream)
  81. {
  82. Parent::unpackData(stream);
  83. control_name = stream->readSTString();
  84. preserve_pos = stream->readFlag();
  85. ctrl_client_only = stream->readFlag();
  86. }
  87. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//