OSITEDRW.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 : OSITE2.CPP
  21. //Description : Object Site Material - display info functions
  22. #include <OVGA.h>
  23. #include <OINFO.h>
  24. #include <OFONT.h>
  25. #include <OWORLD.h>
  26. #include <OIMGRES.h>
  27. #include <ORAWRES.h>
  28. #include <OGODRES.h>
  29. #include <ORACERES.h>
  30. #include <OSITE.h>
  31. //--------- Begin of function Site::disp_info ---------//
  32. //
  33. void Site::disp_info(int refreshFlag)
  34. {
  35. if( refreshFlag != INFO_REPAINT )
  36. return;
  37. //------- natural resource site ------//
  38. if( site_type == SITE_RAW )
  39. {
  40. font_san.d3_put( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+17, "Natural Resource" );
  41. vga.d3_panel_up( INFO_X1, INFO_Y1+20, INFO_X2, INFO_Y1+59, 1 );
  42. int x=INFO_X1+4, y=INFO_Y1+24;
  43. font_san.put_field( x, y , "Resource", x+70, raw_res[object_id]->name );
  44. font_san.put_field( x, y+16, "Reserve" , x+70, reserve_qty, 1 );
  45. }
  46. //--------- scroll of power --------//
  47. else if( site_type == SITE_SCROLL )
  48. {
  49. font_san.d3_put( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+17, "Scroll of Power" );
  50. vga.d3_panel_up( INFO_X1, INFO_Y1+20, INFO_X2, INFO_Y1+59, 1 );
  51. int x=INFO_X1+4, y=INFO_Y1+24;
  52. GodInfo* godInfo = god_res[object_id];
  53. font_san.put_field( x, y , "Nationalty", x+82, race_res[godInfo->race_id]->name );
  54. font_san.put_field( x, y+16, "Invoke" , x+82, unit_res[godInfo->unit_id]->name );
  55. }
  56. //----------- gold coins -----------//
  57. else if( site_type == SITE_GOLD_COIN )
  58. {
  59. font_san.d3_put( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+17, "Treasure" );
  60. vga.d3_panel_up( INFO_X1, INFO_Y1+20, INFO_X2, INFO_Y1+43, 1 );
  61. int x=INFO_X1+4, y=INFO_Y1+24;
  62. font_san.put_field( x, y, "Worth", x+60, object_id, 2 );
  63. }
  64. }
  65. //----------- End of function Site::disp_info -----------//
  66. //--------- Begin of function Site::detect_info ---------//
  67. //
  68. void Site::detect_info()
  69. {
  70. }
  71. //----------- End of function Site::detect_info -----------//
  72. //--------- Begin of function Site::draw ---------//
  73. //
  74. void Site::draw(int x, int y)
  75. {
  76. char* bmpPtr;
  77. switch( site_type )
  78. {
  79. case SITE_RAW:
  80. bmpPtr = raw_res.large_raw_icon(object_id);
  81. break;
  82. case SITE_SCROLL:
  83. {
  84. char iconName[]="SCROLL-0";
  85. iconName[7] = race_res[object_id]->code[0];
  86. bmpPtr = image_spict.get_ptr(iconName);
  87. break;
  88. }
  89. case SITE_GOLD_COIN:
  90. {
  91. // ##### begin Gilbert 30/8 ######//
  92. #define MAX_COINS_TYPE 8
  93. // ##### end Gilbert 30/8 ######//
  94. char iconName[]="COINS-0";
  95. iconName[6] = '1' + object_id % MAX_COINS_TYPE;
  96. bmpPtr = image_spict.get_ptr(iconName);
  97. break;
  98. }
  99. }
  100. vga_back.put_bitmap_trans( x, y, bmpPtr );
  101. }
  102. //----------- End of function Site::draw -----------//
  103. //------- Begin of function Site::draw_selected -----------//
  104. //
  105. // Draw a square around the raw material site on the map.
  106. //
  107. void Site::draw_selected()
  108. {
  109. Location* locPtr = world.get_loc(map_x_loc, map_y_loc);
  110. if( locPtr->is_firm() || locPtr->is_town() ) // do not draw the selection frame if there is a firm or town built on the top of the site
  111. return;
  112. //------ calculate frame coordinations ---------//
  113. int x1 = map_x_loc * ZOOM_LOC_WIDTH;
  114. int y1 = map_y_loc * ZOOM_LOC_HEIGHT;
  115. int x2 = x1 + ZOOM_LOC_WIDTH - 1;
  116. int y2 = y1 + ZOOM_LOC_HEIGHT - 1;
  117. x1 = x1 - World::view_top_x + ZOOM_X1;
  118. y1 = y1 - World::view_top_y + ZOOM_Y1;
  119. x2 = x2 - World::view_top_x + ZOOM_X1;
  120. y2 = y2 - World::view_top_y + ZOOM_Y1;
  121. //------------ draw the square frame now ------------//
  122. if( x1>=ZOOM_X1 && y1>=ZOOM_Y1 && x2<=ZOOM_X2 && y2<=ZOOM_Y2 )
  123. {
  124. vga_back.rect( x1, y1, x2, y2, 1, OWN_SELECT_FRAME_COLOR );
  125. }
  126. }
  127. //--------- End of function Site::draw_selected -----------//
  128. //--------- Begin of function SiteArray::draw_dot ---------//
  129. //
  130. // Draw 2x2 tiny squares on map window representing the
  131. // location of raw materials sites.
  132. //
  133. void SiteArray::draw_dot()
  134. {
  135. char* vgaBufPtr = vga_back.buf_ptr();
  136. char* writePtr;
  137. int i, mapX, mapY;
  138. Site* rawPtr;
  139. // ###### begin Gilbert 7/7 #######//
  140. int vgaBufPitch = vga_back.buf_pitch();
  141. // ###### end Gilbert 7/7 #######//
  142. for(i=1; i <=size() ; i++)
  143. {
  144. if( is_deleted(i) )
  145. continue;
  146. rawPtr = operator[](i);
  147. mapX = MAP_X1 + rawPtr->map_x_loc;
  148. mapY = MAP_Y1 + rawPtr->map_y_loc;
  149. if( mapX == MAP_WIDTH-1 )
  150. mapX = MAP_WIDTH-2;
  151. if( mapY == MAP_HEIGHT-1 )
  152. mapY = MAP_HEIGHT-2;
  153. // ###### begin Gilbert 2/9 #######//
  154. writePtr = vgaBufPtr + mapY*vgaBufPitch + mapX;
  155. if( writePtr[-vgaBufPitch-1] != UNEXPLORED_COLOR )
  156. writePtr[-vgaBufPitch-1] = (char) SITE_COLOR;
  157. if( writePtr[-vgaBufPitch] != UNEXPLORED_COLOR )
  158. writePtr[-vgaBufPitch] = (char) SITE_COLOR;
  159. if( writePtr[-vgaBufPitch+1] != UNEXPLORED_COLOR )
  160. writePtr[-vgaBufPitch+1] = (char) SITE_COLOR;
  161. if( writePtr[-1] != UNEXPLORED_COLOR )
  162. writePtr[-1] = (char) SITE_COLOR;
  163. if( writePtr[0] != UNEXPLORED_COLOR )
  164. writePtr[0] = (char) SITE_COLOR;
  165. if( writePtr[1] != UNEXPLORED_COLOR )
  166. writePtr[1] = (char) SITE_COLOR;
  167. if( writePtr[vgaBufPitch-1] != UNEXPLORED_COLOR )
  168. writePtr[vgaBufPitch-1] = (char) SITE_COLOR;
  169. if( writePtr[vgaBufPitch] != UNEXPLORED_COLOR )
  170. writePtr[vgaBufPitch] = (char) SITE_COLOR;
  171. if( writePtr[vgaBufPitch+1] != UNEXPLORED_COLOR )
  172. writePtr[vgaBufPitch+1] = (char) SITE_COLOR;
  173. // ###### end Gilbert 2/9 #######//
  174. }
  175. }
  176. //----------- End of function SiteArray::draw_dot -----------//