Resource.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #pragma once
  2. #include <Bild.h>
  3. #include <Schrift.h>
  4. #include <UIInitialization.h>
  5. using namespace Framework;
  6. class ColorMode : public virtual ReferenceCounter
  7. {
  8. public:
  9. ColorMode();
  10. virtual Bild *colorImage( Bild *zImg, int color );
  11. };
  12. class AlphaColorMode : public ColorMode
  13. {
  14. private:
  15. unsigned char alpha;
  16. public:
  17. AlphaColorMode( unsigned char alpha );
  18. Bild *colorImage( Bild *zImg, int color ) override;
  19. };
  20. class MaskColorMode : public ColorMode
  21. {
  22. private:
  23. int colorToReplace;
  24. public:
  25. MaskColorMode( int colorToReplace );
  26. Bild *colorImage( Bild *zImg, int color ) override;
  27. };
  28. enum ResourceId
  29. {
  30. R_BARIERE,
  31. R_BASE,
  32. R_PFEIL_GESCHOSS,
  33. R_PFEIL,
  34. R_LEBEN,
  35. R_SCHILD,
  36. R_SCHUH,
  37. R_GEIST,
  38. R_ROLLE,
  39. R_ROLLE_OBEN,
  40. R_ROLLE_LINKS,
  41. R_ROLLE_RECHTS,
  42. R_ROLLE_UNTEN,
  43. R_STURM,
  44. R_STURM_OBEN,
  45. R_STURM_LINKS,
  46. R_STURM_RECHTS,
  47. R_STURM_UNTEN,
  48. R_DRACHENAUGE,
  49. R_DRACHENAUGE_GESCHOSS,
  50. R_FEUERBALL,
  51. R_FEUERBALL_GESCHOSS,
  52. R_FEUERBALL_TREFFER,
  53. R_ENTERHAKEN_SEIL,
  54. R_ENTERHAKEN_SPITZE,
  55. R_ENTERHAKEN_ITEM,
  56. R_MINE,
  57. R_MINE_GESCHOSS,
  58. R_RWEISHEIT,
  59. R_RBOSHEIT,
  60. R_RLEBEN,
  61. R_RTEMPO,
  62. R_RSTRENGTH,
  63. R_SCHALTER,
  64. R_SCHIENE,
  65. R_SPIELER_STIRBT,
  66. R_SPIELER,
  67. R_SPIELER_RECHTS,
  68. R_SPIELER_LINKS,
  69. R_BRAND,
  70. R_EXPLOSION,
  71. R_HEILUNG,
  72. R_SCHADEN,
  73. R_TUNNEL,
  74. R_UMLENKUNG,
  75. R_RWEISHEIT_EFFECT,
  76. R_RBOSHEIT_EFFECT,
  77. R_RLEBEN_EFFECT,
  78. R_RTEMPO_EFFECT,
  79. R_RSTRENGTH_EFFECT,
  80. R_KUGEL_GESCHOSS,
  81. R_KUGEL,
  82. R_GUI_SPIELER,
  83. R_GUI_ERF_RAND,
  84. R_GUI_ERF,
  85. R_GUI_INVENTAR_AUSWAHL,
  86. R_GUI_INVENTAR_HINTERGRUND,
  87. R_GUI_INVENTAR_HINTERGRUND_BENUTZT,
  88. R_GUI_LEBEN_RAND,
  89. R_GUI_LEVEL_RAND
  90. };
  91. class ResourceRegistry;
  92. class Resource : public virtual ReferenceCounter
  93. {
  94. private:
  95. ResourceId id;
  96. int color;
  97. RCArray< Bild > images;
  98. public:
  99. Resource( ResourceId id, int color );
  100. virtual Resource *createColoredResource( int color, ColorMode *mode ) const;
  101. Iterator< Bild * > getImages() const;
  102. ResourceId getId() const;
  103. int getColor() const;
  104. Bild *zImage( int id ) const;
  105. Bild *getImage( int id ) const;
  106. int getImageCount() const;
  107. friend ResourceRegistry;
  108. };
  109. class ResourceRegistry : public virtual ReferenceCounter
  110. {
  111. private:
  112. RCArray< Resource > resources;
  113. Text spielPfad;
  114. Text mapPfad;
  115. UIInit uiFactory;
  116. public:
  117. ResourceRegistry( Text spielPfad, Text mapPfad );
  118. ~ResourceRegistry();
  119. void setUIFactory( UIInit &uiFactory );
  120. UIInit &getUIFactory();
  121. Resource *getResource( ResourceId id, int color, ColorMode *mode = 0, Text path = "" );
  122. Resource *zResource( ResourceId id, int color, ColorMode *mode = 0, Text path = "" );
  123. };