1
0

skinelem.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef _SKINELEM_H
  2. #define _SKINELEM_H
  3. #include <api/xml/xmlreader.h>
  4. #include <tataki/region/region.h>
  5. #include <api/skin/skinitem.h>
  6. #include <api/xml/xmlparamsi.h>
  7. typedef struct
  8. {
  9. const wchar_t *tagname;
  10. int id;
  11. int needclosetag;
  12. }
  13. xml_elementtag;
  14. class XmlElementTagComp
  15. {
  16. public:
  17. static int compareItem(void *p1, void *p2)
  18. {
  19. return WCSICMP(((xml_elementtag *)p1)->tagname, ((xml_elementtag *)p2)->tagname);
  20. }
  21. static int compareAttrib(const wchar_t *attrib, void *item)
  22. {
  23. return WCSICMP(attrib, ((xml_elementtag *)item)->tagname);
  24. }
  25. };
  26. enum {
  27. XML_ELEMENTTAG_UNKNOWN = 0,
  28. XML_ELEMENTTAG_ELEMENTS,
  29. XML_ELEMENTTAG_ELEMENTALIAS,
  30. XML_ELEMENTTAG_BITMAP,
  31. XML_ELEMENTTAG_COLOR,
  32. XML_ELEMENTTAG_BITMAPFONT,
  33. XML_ELEMENTTAG_TRUETYPEFONT,
  34. XML_ELEMENTTAG_CURSOR,
  35. };
  36. class ElementRegionServer;
  37. /*typedef enum {
  38. SKIN_BITMAP_ELEMENT,
  39. SKIN_FONT_ELEMENT,
  40. SKIN_CURSOR_ELEMENT,
  41. SKIN_COLOR_ELEMENT
  42. } SkinElementType;*/
  43. class SkinElementsXmlReader : public XmlReaderCallbackI
  44. {
  45. public:
  46. void xmlReaderOnStartElementCallback(const wchar_t *xmltag, skin_xmlreaderparams *params);
  47. void xmlReaderOnEndElementCallback(const wchar_t *xmltag);
  48. };
  49. class SkinElementsMgr
  50. {
  51. public:
  52. static void init();
  53. static void deinit();
  54. static void onBeforeLoadingSkinElements(const wchar_t *rootpath);
  55. static void onAfterLoadingSkinElements();
  56. static void onBeforeLoadingScriptElements(const wchar_t *name, int script_id);
  57. static void onAfterLoadingScriptElements();
  58. static void resetSkinElements();
  59. static void unloadScriptElements(int scriptid);
  60. static void xmlReaderOnStartElementCallback( const wchar_t *xmltag, skin_xmlreaderparams *params);
  61. static void _xmlReaderOnStartElementCallback( int tagid, const wchar_t *xmltag, skin_xmlreaderparams *params);
  62. static void xmlReaderOnEndElementCallback( const wchar_t *xmltag);
  63. static const wchar_t *getSkinRootpathFromIncludePath(const wchar_t *includepath, const wchar_t *def);
  64. static int elementEqual(const wchar_t *file1, const wchar_t *rootpath1,
  65. const wchar_t *file2, const wchar_t *rootpath2);
  66. private:
  67. static SkinElementsXmlReader xmlreader;
  68. static int inelements;
  69. static int elementScriptId;
  70. static int oldid, oldinel;
  71. static StringW rootpath;
  72. static StringW original_rootpath;
  73. static StringW t_rootpath;
  74. static StringW last_includepath;
  75. static PtrList<StringW> rootpathstack;
  76. static PtrListQuickSorted<xml_elementtag, XmlElementTagComp> quickxmltaglist;
  77. };
  78. #endif