CCreatureHandler.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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::vector<CCreature> creatures;
  46. std::map<std::string,int> nameToID;
  47. void loadCreatures();
  48. void loadAnimationInfo();
  49. void loadUnitAnimInfo(CCreature & unit, std::string & src, int & i);
  50. void loadUnitAnimations();
  51. };
  52. class CCreatureAnimation
  53. {
  54. private:
  55. int totalEntries, DEFType, totalBlocks, fullWidth, fullHeight;
  56. unsigned char fbuffer[800];
  57. bool allowRepaint;
  58. int length;
  59. BMPPalette palette[256];
  60. unsigned int * RWEntries;
  61. int * RLEntries;
  62. struct SEntry
  63. {
  64. std::string name;
  65. int offset;
  66. int group;
  67. } ;
  68. std::vector<SEntry> SEntries ;
  69. char id[2];
  70. std::string defName, curDir;
  71. int readNormalNr (int pos, int bytCon, unsigned char * str=NULL, bool cyclic=false);
  72. ////////////
  73. unsigned char * FDef; //animation raw data
  74. unsigned int curFrame; //number of currently displayed frame
  75. unsigned int frames; //number of frames
  76. int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
  77. public:
  78. CCreatureAnimation(std::string name); //c-tor
  79. //~CCreatureAnimation(); //d-tor //not necessery ATM
  80. void setType(int type); //sets type of animation and cleares framecount
  81. int getType() const; //returns type of animation
  82. int nextFrame(SDL_Surface * dest, int x, int y); //0 - success, any other - error //print next
  83. };
  84. #endif //CCREATUREHANDLER_H