SkinBitmapElement.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include <api/skin/skinitem.h>
  3. #include "ParamList.h"
  4. #include <tataki/region/region.h>
  5. class ElementRegionServer : public RegionServerI
  6. {
  7. public:
  8. ElementRegionServer(api_region *r)
  9. : reg(r->getOSHandle())
  10. {}
  11. virtual api_region *getRegion()
  12. {
  13. return &reg;
  14. }
  15. private:
  16. RegionI reg;
  17. };
  18. struct SkinBitmapElement : public SkinItemI
  19. {
  20. public:
  21. SkinBitmapElement(const wchar_t *_id, const wchar_t *_filename, const wchar_t *_rootpath,
  22. int _x, int _y, int _w, int _h,
  23. ifc_xmlreaderparams *pars = NULL, int script_id = -1, int secondarycounter = 0, const wchar_t *colorgrp = NULL);
  24. virtual ~SkinBitmapElement();
  25. const wchar_t *getId() { return id; }
  26. const wchar_t *getFilename() { return filename; }
  27. int getX() { return x; }
  28. int getY() { return y; }
  29. int getW() { return w; }
  30. int getH() { return h; }
  31. int getSecCount() { return seccount; }
  32. const wchar_t *getColorGroup() { return colorgroup; }
  33. ElementRegionServer *getRegionServer() { return region; }
  34. void setRegionServer(ElementRegionServer *s) { region = s; }
  35. virtual const wchar_t *getXmlRootPath() { return rootpath; }
  36. virtual const wchar_t *getName() { return L"bitmap"; }
  37. virtual ifc_xmlreaderparams *getParams() { return &params; }
  38. virtual int getSkinPartId() { return scriptid; }
  39. virtual SkinItem *getAncestor();
  40. private:
  41. StringW id;
  42. StringW filename;
  43. StringW rootpath;
  44. int x;
  45. int y;
  46. int w;
  47. int h;
  48. int scriptid;
  49. int seccount;
  50. ParamList params;
  51. StringW colorgroup;
  52. ElementRegionServer *region;
  53. };
  54. class SortSkinBitmapElement
  55. {
  56. public:
  57. static int compareItem(SkinBitmapElement *p1, SkinBitmapElement *p2)
  58. {
  59. int r = WCSICMP(p1->getId(), p2->getId());
  60. if (!r)
  61. {
  62. if (p1->getSkinPartId() < p2->getSkinPartId()) return -1;
  63. if (p1->getSkinPartId() > p2->getSkinPartId()) return 1;
  64. if (p1->getSecCount() < p2->getSecCount()) return -1;
  65. if (p1->getSecCount() > p2->getSecCount()) return 1;
  66. return 0;
  67. }
  68. return r;
  69. }
  70. static int compareAttrib(const wchar_t *attrib, SkinBitmapElement *item)
  71. {
  72. return WCSICMP(attrib, item->getId());
  73. }
  74. };