afxGuiTextHud.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef _AFX_GUI_TEXT_HUD_H_
  25. #define _AFX_GUI_TEXT_HUD_H_
  26. #include "gui/core/guiControl.h"
  27. //----------------------------------------------------------------------------
  28. /// Displays name & damage above shape objects.
  29. ///
  30. /// This control displays the name and damage value of all named
  31. /// ShapeBase objects on the client. The name and damage of objects
  32. /// within the control's display area are overlayed above the object.
  33. ///
  34. /// This GUI control must be a child of a TSControl, and a server connection
  35. /// and control object must be present.
  36. ///
  37. /// This is a stand-alone control and relies only on the standard base GuiControl.
  38. class afxGuiTextHud : public GuiControl
  39. {
  40. typedef GuiControl Parent;
  41. struct HudTextSpec
  42. {
  43. Point3F pos;
  44. const char* text;
  45. LinearColorF text_clr;
  46. SceneObject* obj;
  47. };
  48. static Vector<HudTextSpec> text_items;
  49. // field data
  50. LinearColorF mFillColor;
  51. LinearColorF mFrameColor;
  52. LinearColorF mTextColor;
  53. F32 mVerticalOffset;
  54. F32 mDistanceFade;
  55. bool mShowFrame;
  56. bool mShowFill;
  57. bool mLabelAllShapes;
  58. bool mEnableControlObjectOcclusion;
  59. protected:
  60. void drawName( Point2I offset, const char *buf, F32 opacity, LinearColorF* color=0);
  61. public:
  62. afxGuiTextHud();
  63. // GuiControl
  64. virtual void onRender(Point2I offset, const RectI &updateRect);
  65. static void initPersistFields();
  66. static void addTextItem(const Point3F& pos, const char* text, LinearColorF& color, SceneObject* obj=0);
  67. static void reset();
  68. DECLARE_CONOBJECT( afxGuiTextHud );
  69. DECLARE_CATEGORY("AFX");
  70. };
  71. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  72. #endif //_AFX_GUI_TEXT_HUD_H_