api_palette.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. #include <api/skin/skinitem.h>
  4. #include <api/skin/skin.h>
  5. #include <tataki/region/region.h>
  6. class api_palette : public Dispatchable
  7. {
  8. protected:
  9. api_palette() {}
  10. ~api_palette() {}
  11. public:
  12. void StartTransaction(); // if you add a bunch of stuff at once, it's faster to call this at the beginning
  13. void EndTransaction(); // and this at the end.
  14. void Reset(); // clear everything
  15. const int *getSkinPartIteratorPtr(); // call this to get a pointer that's faster to check than calling getSkinPartIterator via Dispatchable
  16. int newSkinPart(); // call this before adding your elements, let's you easily remove just your stuff via UnloadElements
  17. int getSkinPartIterator(); // if this value changes, then something in the skin palette has changed
  18. void UnloadElements(int skinpart); // unload just your skin elements (get a skinpart value via newSkinPart)
  19. /* Aliases */
  20. void AddAlias(const wchar_t *id, const wchar_t *target);
  21. const wchar_t *getElementAlias(const wchar_t *alias);
  22. SkinItem *getAliasAncestor(SkinItem *item);
  23. /* Colors */
  24. void AddColor(const wchar_t *id, ARGB32 value, const wchar_t *colorgrp = NULL, const wchar_t *path = NULL, ifc_xmlreaderparams *p = NULL);
  25. int getNumColorElements();
  26. const wchar_t *enumColorElement(int n);
  27. ARGB32 *getColorElementRef(const wchar_t *type, const wchar_t **grp = NULL);
  28. SkinItem *getColorAncestor(SkinItem *item);
  29. ARGB32 getColorElement(const wchar_t *type, const wchar_t **grp = NULL);
  30. /* Cursors */
  31. void AddCursor(const wchar_t *id, const wchar_t *bitmapid, int x, int y, const wchar_t *path = NULL, ifc_xmlreaderparams *params = NULL);
  32. int getCursorElement(const wchar_t *id);
  33. OSCURSOR getCursor(const wchar_t *id);
  34. SkinItem *getCursorAncestor(SkinItem *item);
  35. const wchar_t *getSkinCursorBitmapId(const wchar_t *cursor);
  36. /* Bitmaps */
  37. void AddBitmap(const wchar_t *id, const wchar_t *filename, const wchar_t *path, int x, int y, int w, int h, ifc_xmlreaderparams *params = NULL, const wchar_t *colorgroup = NULL);
  38. int getBitmapElement(const wchar_t *type);
  39. SkinItem *getBitmapAncestor(SkinItem *item);
  40. int getNumBitmapElement();
  41. const wchar_t *getSkinBitmapFilename(const wchar_t *id, int *x, int *y, int *w, int *h, const wchar_t **rootpath, ifc_xmlreaderparams **params);
  42. const wchar_t *getGammaGroupFromId(const wchar_t *id);
  43. int getLayerFromId(const wchar_t *id);
  44. /* Region Server (part of Bitmaps) */
  45. RegionServer *requestSkinRegion(const wchar_t *id);
  46. void cacheSkinRegion(const wchar_t *id, api_region *r);
  47. enum
  48. {
  49. API_PALETTE_STARTTRANSACTION=0,
  50. API_PALETTE_ENDTRANSACTION=1,
  51. API_PALETTE_RESET=2,
  52. API_PALETTE_GETSKINPARTITERATORPTR=3,
  53. API_PALETTE_NEWSKINPART=4,
  54. API_PALETTE_GETSKINPARTITERATOR=5,
  55. API_PALETTE_UNLOADELEMENTS=6,
  56. API_PALETTE_ADDALIAS=7,
  57. API_PALETTE_GETELEMENTALIAS=8,
  58. API_PALETTE_GETALIASANCESTOR=9,
  59. API_PALETTE_ADDCOLOR=10,
  60. API_PALETTE_GETNUMCOLORELEMENTS=11,
  61. API_PALETTE_ENUMCOLORELEMENT=12,
  62. API_PALETTE_GETCOLORELEMENTREF=13,
  63. API_PALETTE_GETCOLORANCESTOR=14,
  64. API_PALETTE_GETCOLORELEMENT=15,
  65. API_PALETTE_ADDCURSOR=16,
  66. API_PALETTE_GETCURSORELEMENT=17,
  67. API_PALETTE_GETCURSOR=18,
  68. API_PALETTE_GETCURSORANCESTOR=19,
  69. API_PALETTE_GETSKINCURSORBITMAPID=20,
  70. API_PALETTE_ADDBITMAP=21,
  71. API_PALETTE_GETBITMAPELEMENT=22,
  72. API_PALETTE_GETBITMAPANCESTOR=23,
  73. API_PALETTE_GETNUMBITMAPELEMENT=24,
  74. API_PALETTE_GETSKINBITMAPFILENAME=25,
  75. API_PALETTE_GETGAMMAGROUPFROMID=26,
  76. API_PALETTE_GETLAYERFROMID=27,
  77. API_PALETTE_REQUESTSKINREGION=28,
  78. API_PALETTE_CACHESKINREGION=29,
  79. };
  80. };
  81. inline void api_palette::StartTransaction()
  82. {
  83. _voidcall(API_PALETTE_STARTTRANSACTION);
  84. }
  85. inline void api_palette::EndTransaction()
  86. {
  87. _voidcall(API_PALETTE_ENDTRANSACTION);
  88. }
  89. inline void api_palette::Reset()
  90. {
  91. _voidcall(API_PALETTE_RESET);
  92. }
  93. inline const int *api_palette::getSkinPartIteratorPtr()
  94. {
  95. return _call(API_PALETTE_GETSKINPARTITERATORPTR, (const int *)0);
  96. }
  97. inline int api_palette::newSkinPart()
  98. {
  99. return _call(API_PALETTE_NEWSKINPART, (int)0);
  100. }
  101. inline int api_palette::getSkinPartIterator()
  102. {
  103. return _call(API_PALETTE_GETSKINPARTITERATOR, (int)0);
  104. }
  105. inline void api_palette::UnloadElements(int skinpart)
  106. {
  107. _voidcall(API_PALETTE_UNLOADELEMENTS, skinpart);
  108. }
  109. inline void api_palette::AddAlias(const wchar_t *id, const wchar_t *target)
  110. {
  111. _voidcall(API_PALETTE_ADDALIAS, id, target);
  112. }
  113. inline const wchar_t *api_palette::getElementAlias(const wchar_t *alias)
  114. {
  115. return _call(API_PALETTE_GETELEMENTALIAS, (const wchar_t *)0, alias);
  116. }
  117. inline SkinItem *api_palette::getAliasAncestor(SkinItem *item)
  118. {
  119. return _call(API_PALETTE_GETALIASANCESTOR, (SkinItem *)0, item);
  120. }
  121. inline void api_palette::AddColor(const wchar_t *id, ARGB32 value, const wchar_t *colorgrp, const wchar_t *path, ifc_xmlreaderparams *p)
  122. {
  123. _voidcall(API_PALETTE_ADDCOLOR, id, value, colorgrp, path, p);
  124. }
  125. inline int api_palette::getNumColorElements()
  126. {
  127. return _call(API_PALETTE_GETNUMCOLORELEMENTS, (int)0);
  128. }
  129. inline const wchar_t *api_palette::enumColorElement(int n)
  130. {
  131. return _call(API_PALETTE_ENUMCOLORELEMENT, (const wchar_t *)0, n);
  132. }
  133. inline ARGB32 *api_palette::getColorElementRef(const wchar_t *type, const wchar_t **grp)
  134. {
  135. return _call(API_PALETTE_GETCOLORELEMENTREF, (ARGB32 *)0, type, grp);
  136. }
  137. inline SkinItem *api_palette::getColorAncestor(SkinItem *item)
  138. {
  139. return _call(API_PALETTE_GETCOLORANCESTOR, (SkinItem *)0, item);
  140. }
  141. inline ARGB32 api_palette::getColorElement(const wchar_t *type, const wchar_t **grp)
  142. {
  143. return _call(API_PALETTE_GETCOLORELEMENT, (ARGB32)RGB(255, 0, 255), type, grp);
  144. }
  145. inline void api_palette::AddCursor(const wchar_t *id, const wchar_t *bitmapid, int x, int y, const wchar_t *path, ifc_xmlreaderparams *params)
  146. {
  147. _voidcall(API_PALETTE_ADDCURSOR, id, bitmapid, x, y, path, params);
  148. }
  149. inline int api_palette::getCursorElement(const wchar_t *id)
  150. {
  151. return _call(API_PALETTE_GETCURSORELEMENT, (int)-1, id);
  152. }
  153. inline OSCURSOR api_palette::getCursor(const wchar_t *id)
  154. {
  155. return _call(API_PALETTE_GETCURSOR, INVALIDOSCURSORHANDLE, id);
  156. }
  157. inline SkinItem *api_palette::getCursorAncestor(SkinItem *item)
  158. {
  159. return _call(API_PALETTE_GETCURSORANCESTOR, (SkinItem *)0, item);
  160. }
  161. inline const wchar_t *api_palette::getSkinCursorBitmapId(const wchar_t *cursor)
  162. {
  163. return _call(API_PALETTE_GETSKINCURSORBITMAPID, (const wchar_t *)0, cursor);
  164. }
  165. inline void api_palette::AddBitmap(const wchar_t *id, const wchar_t *filename, const wchar_t *path, int x, int y, int w, int h, ifc_xmlreaderparams *params, const wchar_t *colorgroup)
  166. {
  167. _voidcall(API_PALETTE_ADDBITMAP, id, filename, path, x, y, w, h, params, colorgroup);
  168. }
  169. inline int api_palette::getBitmapElement(const wchar_t *type)
  170. {
  171. return _call(API_PALETTE_GETBITMAPELEMENT, (int)-1, type);
  172. }
  173. inline SkinItem *api_palette::getBitmapAncestor(SkinItem *item)
  174. {
  175. return _call(API_PALETTE_GETBITMAPANCESTOR, (SkinItem *)0, item);
  176. }
  177. inline int api_palette::getNumBitmapElement()
  178. {
  179. return _call(API_PALETTE_GETNUMBITMAPELEMENT, (int)0);
  180. }
  181. inline const wchar_t *api_palette::getSkinBitmapFilename(const wchar_t *id, int *x, int *y, int *w, int *h, const wchar_t **rootpath, ifc_xmlreaderparams **params)
  182. {
  183. return _call(API_PALETTE_GETSKINBITMAPFILENAME, (const wchar_t *)0,id,x,y,w,h,rootpath, params);
  184. }
  185. inline const wchar_t *api_palette::getGammaGroupFromId(const wchar_t *id)
  186. {
  187. return _call(API_PALETTE_GETGAMMAGROUPFROMID, (const wchar_t *)0, id);
  188. }
  189. inline int api_palette::getLayerFromId(const wchar_t *id)
  190. {
  191. return _call(API_PALETTE_GETLAYERFROMID, (int)-1, id);
  192. }
  193. inline RegionServer *api_palette::requestSkinRegion(const wchar_t *id)
  194. {
  195. return _call(API_PALETTE_REQUESTSKINREGION, (RegionServer *)0, id);
  196. }
  197. inline void api_palette::cacheSkinRegion(const wchar_t *id, api_region *r)
  198. {
  199. _voidcall(API_PALETTE_CACHESKINREGION, id, r);
  200. }
  201. // {DCA2E3C2-4C3E-4dd9-AB1A-1940F2CA31F7}
  202. static const GUID PaletteManagerGUID =
  203. { 0xdca2e3c2, 0x4c3e, 0x4dd9, { 0xab, 0x1a, 0x19, 0x40, 0xf2, 0xca, 0x31, 0xf7 } };