1
0

skin.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef _SKIN_H
  2. #define _SKIN_H
  3. #include <api/skin/api_skin.h>
  4. #include <bfc/platform/platform.h>
  5. #include <api/wnd/basewnd.h>
  6. #include <bfc/ptrlist.h>
  7. #include <tataki/region/region.h>
  8. #include <tataki/bitmap/autobitmap.h>
  9. #include <bfc/string/bfcstring.h>
  10. #include <api/wndmgr/container.h>
  11. #include <api/xml/xmlreader.h>
  12. #include <bfc/string/StringW.h>
  13. class SkinBitmap;
  14. #include "SkinVersion.h"
  15. #define CB_SETSKINDEFERRED 0x5492
  16. class SkinTimer;
  17. class Skin
  18. {
  19. public:
  20. enum {
  21. CHKSKIN_UNKNOWN = -1,
  22. CHKSKIN_ISWA3 = 1,
  23. CHKSKIN_ISWA3OLD = 2,
  24. CHKSKIN_ISWA3FUTURE = 3,
  25. CHKSKIN_ISWA2 = 4,
  26. CHKSKIN_DISALLOWED = 5,
  27. };
  28. Skin();
  29. virtual ~Skin();
  30. static const wchar_t *getSkinName();
  31. static void setSkinName(const wchar_t *newskinname, const wchar_t *skinpath = NULL);
  32. static const wchar_t *getSkinPath();
  33. static const wchar_t *getDefaultSkinPath();
  34. static Skin *getCurSkin();
  35. void setBaseTexture(const wchar_t *b);
  36. //CUT static int registerCallback(SkinCallback *cb);
  37. //CUT static int deregisterCallback(SkinCallback *cb);
  38. static void renderBaseTexture(ifc_window *base, Skin *s, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha = 255);
  39. static void renderBaseTexture(ifc_window *s, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha = 255);
  40. static void invalidateBaseTexture(Skin *s);
  41. static void invalidateAllBaseTextures();
  42. static Skin *baseToSkin(ifc_window *b);
  43. static void registerBaseSkin(Skin *s, ifc_window *b);
  44. static Skin *unregisterBaseSkin(ifc_window *b);
  45. static void unloadAllBaseTextures();
  46. static void reloadAllBaseTextures();
  47. void _unloadBaseTexture();
  48. void _reloadBaseTexture();
  49. static wchar_t *enumLoadableSkins(int refresh = FALSE);
  50. static int checkSkin(const wchar_t *name);
  51. static void toggleSkin(const wchar_t *name, const wchar_t *skin_path = NULL, int deferred = 0);
  52. static void unloadSkin();
  53. static void parseSkinFilename(const wchar_t *filename, const wchar_t *incpath);
  54. static int isDefaultSkin;
  55. static void sendUnloadingCallback();
  56. static int sendAbortCallback(const wchar_t *skinname);
  57. static void sendResetCallback();
  58. static void sendReloadCallback();
  59. static void sendBeforeLoadingElementsCallback();
  60. static void sendGuiLoadedCallback();
  61. static void sendLoadedCallback();
  62. static int isSkinReady();
  63. static void setSkinReady(int i);
  64. static int isDynamicGroupReloadEnabled() { return enable_group_reload; }
  65. static void unloadSkinPart(int id);
  66. static int loadSkinPart(const wchar_t *xmlfile);
  67. static void main_notifySkinLoaded();
  68. static int isLoading() { return loading; }
  69. static int unloadResources();
  70. static int reloadResources();
  71. static bool isLoaded();
  72. private:
  73. void rescaleBaseTexture(int w, int h);
  74. void _renderBaseTexture(ifc_window *base, ifc_canvas *c, const RECT &r, ifc_window *dest, int alpha);
  75. void _invalidateBaseTexture(void);
  76. void validateBaseTextureRect(RECT *r);
  77. AutoSkinBitmap *base;
  78. BltCanvas *scaled;
  79. int scale_x, scale_y;
  80. bool forceinvalid;
  81. int m_x, m_y;
  82. int lastw, lasth, maxw, maxh;
  83. bool resizing;
  84. RegionI *validRgn;
  85. static int loading;
  86. static int enable_group_reload;
  87. static PtrList<Skin> skinList;
  88. static PtrList<ifc_window> baseList;
  89. static StringW skinName;
  90. static StringW skinPath;
  91. static StringW defSkinPath;
  92. static int highest_id;
  93. static int reloadingskin;
  94. static int skin_loaded;
  95. static SkinTimer *deferedskinset;
  96. };
  97. class SkinTimer : public TimerClientDI
  98. {
  99. public :
  100. SkinTimer() {}
  101. virtual ~SkinTimer() {}
  102. void setSkinDeferred(const wchar_t *skinname)
  103. {
  104. skin = skinname;
  105. timerclient_postDeferredCallback(CB_SETSKINDEFERRED, 0);
  106. }
  107. virtual int timerclient_onDeferredCallback(intptr_t p1, intptr_t p2)
  108. {
  109. if (p1 == CB_SETSKINDEFERRED)
  110. {
  111. Skin::toggleSkin(skin);
  112. skin.trunc(0);
  113. }
  114. else
  115. return TimerClientDI::timerclient_onDeferredCallback(p1, p2);
  116. return 1;
  117. }
  118. private:
  119. StringW skin;
  120. };
  121. extern Skin *tha;
  122. #endif