SkinElementAlias.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include <api/skin/skinitem.h>
  3. #include <api/xml/xmlparamsi.h>
  4. struct SkinElementAlias : public SkinItemI
  5. {
  6. public:
  7. SkinElementAlias(const wchar_t *_aliasname, const wchar_t *_idtarget, int _scriptid = -1, int _secondarycounter = 0)
  8. : aliasname(_aliasname), idtarget(_idtarget), scriptid(_scriptid), seccount(_secondarycounter) //, rootpath(path)
  9. {
  10. params = NULL;
  11. /*
  12. if (p != NULL) {
  13. params = new XmlReaderParamsI();
  14. for (int i=0;i<p->getNbItems();i++) {
  15. params->addItem(p->getItemName(i), p->getItemValue(i));
  16. }
  17. }
  18. */
  19. }
  20. virtual ~SkinElementAlias()
  21. {
  22. delete params;
  23. }
  24. const wchar_t *getAliasName() { return aliasname; }
  25. const wchar_t *getTargetId() { return idtarget; }
  26. int getSecCount() { return seccount; }
  27. virtual const wchar_t *getXmlRootPath() { return rootpath; }
  28. virtual const wchar_t *getName() { return L"elementalias"; }
  29. virtual ifc_xmlreaderparams *getParams() { return params; }
  30. virtual int getSkinPartId() { return scriptid; }
  31. virtual SkinItem *getAncestor();
  32. private:
  33. StringW aliasname;
  34. StringW idtarget;
  35. int scriptid;
  36. int seccount;
  37. XmlReaderParamsI *params;
  38. StringW rootpath;
  39. };
  40. class SortSkinElementAlias
  41. {
  42. public:
  43. static int compareItem(SkinElementAlias *p1, SkinElementAlias *p2)
  44. {
  45. int r = WCSICMP(p1->getAliasName(), p2->getAliasName());
  46. if (!r)
  47. {
  48. if (p1->getSkinPartId() < p2->getSkinPartId()) return -1;
  49. if (p1->getSkinPartId() > p2->getSkinPartId()) return 1;
  50. if (p1->getSecCount() < p2->getSecCount()) return -1;
  51. if (p1->getSecCount() > p2->getSecCount()) return 1;
  52. return 0;
  53. }
  54. return r;
  55. }
  56. static int compareAttrib(const wchar_t *attrib, SkinElementAlias *item)
  57. {
  58. return WCSICMP(attrib, item->getAliasName());
  59. }
  60. };