afxSpellButton.h 3.7 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. #ifndef _AFX_SPELL_BUTTON_H_
  25. #define _AFX_SPELL_BUTTON_H_
  26. #include "gui/buttons/guiButtonCtrl.h"
  27. ///-------------------------------------
  28. /// Bitmap Button Contrl
  29. /// Set 'bitmap' comsole field to base name of bitmaps to use. This control will
  30. /// append '_n' for normal
  31. /// append '_h' for hilighted
  32. /// append '_d' for depressed
  33. ///
  34. /// if bitmap cannot be found it will use the default bitmap to render.
  35. ///
  36. /// if the extent is set to (0,0) in the gui editor and appy hit, this control will
  37. /// set it's extent to be exactly the size of the normal bitmap (if present)
  38. ///
  39. class afxSpellBook;
  40. class afxMagicSpellData;
  41. class afxRPGMagicSpellData;
  42. class afxSpellButton : public GuiButtonCtrl
  43. {
  44. private:
  45. typedef GuiButtonCtrl Parent;
  46. enum { NUM_COOLDOWN_FRAMES = 36 };
  47. protected:
  48. static StringTableEntry sUnknownSpellBitmap;
  49. static StringTableEntry sSpellCooldownBitmaps;
  50. StringTableEntry mBitmapName;
  51. GFXTexHandle mTextureNormal;
  52. GFXTexHandle mTextureHilight;
  53. GFXTexHandle mTextureDepressed;
  54. GFXTexHandle mTextureInactive;
  55. afxSpellBook* spellbook;
  56. Point2I book_slot;
  57. GFXTexHandle cooldown_txrs[NUM_COOLDOWN_FRAMES];
  58. void update_bitmap();
  59. void renderButton(GFXTexHandle &texture, Point2I &offset, const RectI& updateRect);
  60. public:
  61. /*C*/ afxSpellButton();
  62. /*D*/ ~afxSpellButton();
  63. void setBitmap(const char *name, bool placholder=false);
  64. void setSpellBook(afxSpellBook*, U8 page);
  65. void setPage(U8 page);
  66. const char* formatDesc(char* buffer, int len) const;
  67. afxMagicSpellData* getSpellDataBlock() const;
  68. afxRPGMagicSpellData* getSpellRPGDataBlock() const;
  69. virtual bool onAdd();
  70. virtual bool onWake();
  71. virtual void onSleep();
  72. virtual void inspectPostApply();
  73. virtual void onMouseEnter(const GuiEvent &event);
  74. virtual void onMouseLeave(const GuiEvent &event);
  75. virtual void onRender(Point2I offset, const RectI &updateRect);
  76. virtual void onDeleteNotify(SimObject*);
  77. static void initPersistFields();
  78. DECLARE_CONOBJECT(afxSpellButton);
  79. DECLARE_CATEGORY("AFX");
  80. };
  81. //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  82. #endif //_GUI_BITMAP_BUTTON_CTRL_H