CCreatureHandler.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #ifndef CCREATUREHANDLER_H
  2. #define CCREATUREHANDLER_H
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. #include "CDefHandler.h"
  7. class CDefHandler;
  8. struct SDL_Surface;
  9. //#include "CDefHandler.h"
  10. class CCreature
  11. {
  12. public:
  13. std::string namePl, nameSing, nameRef; //name in singular and plural form; and reference name
  14. int wood, mercury, ore, sulfur, crystal, gems, gold, fightValue, AIValue, growth, hordeGrowth, hitPoints, speed, attack, defence, shots, spells;
  15. int low1, low2, high1, high2; //TODO - co to w ogóle jest???
  16. std::string abilityText; //description of abilities
  17. std::string abilityRefs; //references to abilities, in textformat
  18. int idNumber;
  19. ///animation info
  20. float timeBetweenFidgets, walkAnimationTime, attackAnimationTime, flightAnimationDistance;
  21. int upperRightMissleOffsetX, rightMissleOffsetX, lowerRightMissleOffsetX, upperRightMissleOffsetY, rightMissleOffsetY, lowerRightMissleOffsetY;
  22. float missleFrameAngles[12];
  23. int troopCountLocationOffset, attackClimaxFrame;
  24. ///end of anim info
  25. //for some types of towns
  26. bool isDefinite; //if the creature type is wotn dependent, it should be true
  27. int indefLevel; //only if indefinite
  28. bool indefUpgraded; //onlu if inddefinite
  29. //end
  30. CDefHandler * battleAnimation;
  31. //TODO - zdolnoœci - na typie wyliczeniowym czy czymœ
  32. };
  33. class CCreatureSet //seven combined creatures
  34. {
  35. public:
  36. std::map<int,std::pair<CCreature*,int> > slots;
  37. //CCreature * slot1, * slot2, * slot3, * slot4, * slot5, * slot6, * slot7; //types of creatures on each slot
  38. //unsigned int s1, s2, s3, s4, s5, s6, s7; //amounts of units in slots
  39. bool formation; //false - wide, true - tight
  40. };
  41. class CCreatureHandler
  42. {
  43. public:
  44. std::map<int,SDL_Surface*> smallImgs; //creature ID -> small 32x32 img of creature; //ID=-2 is for blank (black) img; -1 for the border
  45. std::map<int,SDL_Surface*> bigImgs; //creature ID -> big 58x64 img of creature; //ID=-2 is for blank (black) img; -1 for the border
  46. std::vector<CCreature> creatures;
  47. std::map<std::string,int> nameToID;
  48. void loadCreatures();
  49. void loadAnimationInfo();
  50. void loadUnitAnimInfo(CCreature & unit, std::string & src, int & i);
  51. void loadUnitAnimations();
  52. };
  53. class CCreatureAnimation
  54. {
  55. private:
  56. int totalEntries, DEFType, totalBlocks, fullWidth, fullHeight;
  57. unsigned char fbuffer[800];
  58. bool allowRepaint;
  59. int length;
  60. BMPPalette palette[256];
  61. unsigned int * RWEntries;
  62. int * RLEntries;
  63. struct SEntry
  64. {
  65. std::string name;
  66. int offset;
  67. int group;
  68. } ;
  69. std::vector<SEntry> SEntries ;
  70. char id[2];
  71. std::string defName, curDir;
  72. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL, bool cyclic=false);
  73. ////////////
  74. unsigned char * FDef; //animation raw data
  75. unsigned int curFrame; //number of currently displayed frame
  76. unsigned int frames; //number of frames
  77. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  78. public:
  79. CCreatureAnimation(std::string name); //c-tor
  80. //~CCreatureAnimation(); //d-tor //not necessery ATM
  81. void setType(int type); //sets type of animation and cleares framecount
  82. int getType() const; //returns type of animation
  83. int nextFrame(SDL_Surface * dest, int x, int y); //0 - success, any other - error //print next
  84. };
  85. #endif //CCREATUREHANDLER_H