OWALLRES.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Seven Kingdoms: Ancient Adversaries
  3. *
  4. * Copyright 1997,1998 Enlight Software Ltd.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. //Filename : OWALLRES.H
  21. //Description : Header file of object WallRes
  22. //Ownership : Gilbert
  23. #ifndef __OWALLRES_H
  24. #define __OWALLRES_H
  25. #ifndef __ORESDB_H
  26. #include <ORESDB.h>
  27. #endif
  28. //------------ Define constant -------------//
  29. #define WALL_SPACE_LOC 5 // no. of space between the wall and the town border
  30. #define BUILD_WALL_COST 10
  31. #define DESTRUCT_WALL_COST 5
  32. //------------ Define struct WallRec ---------------//
  33. struct WallRec
  34. {
  35. enum { WALL_ID_LEN=2, OFFSET_LEN=4, LOC_OFF_LEN=2, FILE_NAME_LEN=8, BITMAP_PTR_LEN=4 };
  36. char wall_id[WALL_ID_LEN];
  37. char gate_flag;
  38. char trans_flag;
  39. char offset_x[OFFSET_LEN];
  40. char offset_y[OFFSET_LEN];
  41. char loc_off_x[LOC_OFF_LEN];
  42. char loc_off_y[LOC_OFF_LEN];
  43. char draw_wall[WALL_ID_LEN];
  44. char file_name[FILE_NAME_LEN];
  45. char bitmap_ptr[BITMAP_PTR_LEN];
  46. };
  47. //------------- Define struct WallInfo --------------//
  48. struct WallInfo
  49. {
  50. char wall_id;
  51. char flags; // b0 = gate_flag, b1 = trans_flag
  52. short offset_x; // pixels to the drawing pixel
  53. short offset_y;
  54. char loc_off_x; // location to the top left location
  55. char loc_off_y;
  56. char draw_wall_id;
  57. char dummy;
  58. char* bitmap_ptr;
  59. public:
  60. int is_gate() { return flags & 1; }
  61. int is_trans() { return flags & 2; }
  62. void set_gate() { flags |= 1;}
  63. void set_trans() { flags |= 2;}
  64. short bitmap_width() { return *(short *)bitmap_ptr; }
  65. short bitmap_height() { return *(((short *)bitmap_ptr)+1); }
  66. void draw(int xLoc, int yLoc, char *remapTbl = NULL);
  67. void draw_at(int absBaseX, int absBaseY, char *remapTbl = NULL);
  68. };
  69. //----------- Define class WallRes ---------------//
  70. class WallRes
  71. {
  72. public:
  73. WallInfo* wall_info_array;
  74. WallInfo** wall_index; // wallInfoPtr = wall_index[wall_id-1];
  75. short wall_count;
  76. char max_wall_id;
  77. char init_flag;
  78. ResourceDb res_bitmap;
  79. short selected_x_loc;
  80. short selected_y_loc;
  81. public:
  82. WallRes();
  83. void init();
  84. void deinit();
  85. void disp_info(int refreshFlag);
  86. void draw_selected();
  87. WallInfo* operator[](int WallId);
  88. private:
  89. void load_wall_info();
  90. };
  91. extern WallRes wall_res;
  92. //----------------------------------------------------//
  93. #endif