OR_AI.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 : OR_AI.CPP
  21. //Description : Report for displaying AI actions
  22. #include <OVGA.h>
  23. #include <ODATE.h>
  24. #include <OFONT.h>
  25. #include <OVBROWIF.h>
  26. #include <OBUTTON.h>
  27. #include <OFIRMRES.h>
  28. #include <ONATION.h>
  29. #include <OINFO.h>
  30. //------------- Define coordinations -----------//
  31. enum { ACTION_BROWSE_X1 = ZOOM_X1+6,
  32. ACTION_BROWSE_Y1 = ZOOM_Y1+6,
  33. ACTION_BROWSE_X2 = ZOOM_X2-6,
  34. ACTION_BROWSE_Y2 = ACTION_BROWSE_Y1+200
  35. };
  36. enum { ATTACK_BROWSE_X1 = ZOOM_X1+6,
  37. ATTACK_BROWSE_Y1 = ACTION_BROWSE_Y2+6,
  38. ATTACK_BROWSE_X2 = ZOOM_X2-6,
  39. ATTACK_BROWSE_Y2 = ATTACK_BROWSE_Y1+160
  40. };
  41. enum { OTHER_INFO_X1 = ZOOM_X1+6,
  42. OTHER_INFO_Y1 = ATTACK_BROWSE_Y2+6,
  43. OTHER_INFO_X2 = ZOOM_X2-6,
  44. OTHER_INFO_Y2 = ZOOM_Y2-6,
  45. };
  46. //----------- Define action mode string --------//
  47. static char* action_mode_str_array[] =
  48. {
  49. "Build firm",
  50. "Assign overseer",
  51. "Assign constructor",
  52. "Assign worker",
  53. "Assign spy",
  54. "Scout",
  55. "Settle to another town",
  56. "Process diplomatic message",
  57. "Defend",
  58. "Sea Travel 1",
  59. "Sea Travel 2",
  60. "Sea Travel 3",
  61. };
  62. //----------- Define static variables ----------//
  63. static VBrowseIF browse_action, browse_attack;
  64. static int total_population, total_peasant;
  65. static Nation* cur_nation_ptr;
  66. //----------- Define static functions ----------//
  67. static void put_action_rec(int recNo, int x, int y, int refreshFlag);
  68. static void put_attack_rec(int recNo, int x, int y, int refreshFlag);
  69. static void disp_other_info();
  70. //--------- Begin of function Info::disp_ai_action ---------//
  71. //
  72. void Info::disp_ai_action(int refreshFlag)
  73. {
  74. cur_nation_ptr = nation_array[info.viewing_nation_recno];
  75. if( cur_nation_ptr->nation_type != NATION_AI )
  76. return;
  77. //------ display the queued action list -------//
  78. int x=ACTION_BROWSE_X1+9;
  79. int y=ACTION_BROWSE_Y1+4;
  80. vga_back.d3_panel_up(ACTION_BROWSE_X1, ACTION_BROWSE_Y1, ACTION_BROWSE_X2, ACTION_BROWSE_Y1+18 );
  81. font_san.put( x , y, "Action Mode" );
  82. font_san.put( x+120, y, "Action Para" );
  83. font_san.put( x+220, y, "Add Date" );
  84. font_san.put( x+320, y, "Instance" );
  85. font_san.put( x+390, y, "Processing" );
  86. font_san.put( x+470, y, "Processed" );
  87. browse_action.init( ACTION_BROWSE_X1, ACTION_BROWSE_Y1+20, ACTION_BROWSE_X2, ACTION_BROWSE_Y2,
  88. 0, 22, cur_nation_ptr->action_count(), put_action_rec, 1 );
  89. browse_action.open(browse_ai_action_recno ); // if refreshFlag is INFO_UPDATE, keep the original top_rec_no of the browser
  90. //------ display the queued action list -------//
  91. x=ATTACK_BROWSE_X1+9;
  92. y=ATTACK_BROWSE_Y1+4;
  93. vga_back.d3_panel_up(ATTACK_BROWSE_X1, ATTACK_BROWSE_Y1, ATTACK_BROWSE_X2, ATTACK_BROWSE_Y1+18 );
  94. font_san.put( x , y, "Firm recno" );
  95. font_san.put( x+120, y, "Combat level" );
  96. font_san.put( x+220, y, "Distance" );
  97. font_san.put( x+320, y, "Patrol Date" );
  98. browse_attack.init( ATTACK_BROWSE_X1, ATTACK_BROWSE_Y1+20, ATTACK_BROWSE_X2, ATTACK_BROWSE_Y2,
  99. 0, 22, cur_nation_ptr->attack_camp_count, put_attack_rec, 1 );
  100. browse_attack.open(browse_ai_attack_recno); // if refreshFlag is INFO_UPDATE, keep the original top_rec_no of the browser
  101. //-------------------------------//
  102. disp_other_info();
  103. }
  104. //----------- End of function Info::disp_ai_action -----------//
  105. //--------- Begin of function Info::detect_ai_action ---------//
  106. //
  107. void Info::detect_ai_action()
  108. {
  109. if( browse_action.detect() )
  110. browse_ai_action_recno = browse_action.recno();
  111. if( browse_attack.detect() )
  112. browse_ai_attack_recno = browse_attack.recno();
  113. }
  114. //----------- End of function Info::detect_ai_action -----------//
  115. //-------- Begin of static function put_action_rec --------//
  116. //
  117. static void put_action_rec(int recNo, int x, int y, int refreshFlag)
  118. {
  119. ActionNode* actionNode = cur_nation_ptr->get_action(recNo);
  120. //---------- display info ----------//
  121. x+=3;
  122. y+=3;
  123. font_san.put( x, y, action_mode_str_array[actionNode->action_mode-1] );
  124. if( actionNode->action_mode >= ACTION_AI_BUILD_FIRM &&
  125. actionNode->action_mode <= ACTION_AI_ASSIGN_WORKER )
  126. {
  127. font_san.put( x+120, y, firm_res[actionNode->action_para]->name, 0, x+216 );
  128. }
  129. font_san.put( x+220, y, date.date_str(actionNode->add_date, 1) ); // short month string
  130. font_san.put( x+340, y, actionNode->instance_count );
  131. font_san.put( x+410, y, actionNode->processing_instance_count );
  132. font_san.put( x+490, y, actionNode->processed_instance_count );
  133. /*
  134. font_san.put( x+220, y, actionNode->action_x_loc ); // short month string
  135. font_san.put( x+340, y, actionNode->action_y_loc );
  136. font_san.put( x+410, y, actionNode->ref_x_loc );
  137. font_san.put( x+490, y, actionNode->ref_y_loc );
  138. */
  139. }
  140. //----------- End of static function put_action_rec -----------//
  141. //-------- Begin of static function put_attack_rec --------//
  142. //
  143. static void put_attack_rec(int recNo, int x, int y, int refreshFlag)
  144. {
  145. AttackCamp* attackCamp = cur_nation_ptr->attack_camp_array+recNo-1;
  146. //---------- display info ----------//
  147. x+=3;
  148. y+=3;
  149. font_san.put( x , y, attackCamp->firm_recno );
  150. font_san.put( x+120, y, attackCamp->combat_level );
  151. font_san.put( x+220, y, attackCamp->distance );
  152. font_san.put( x+340, y, date.date_str(attackCamp->patrol_date) );
  153. }
  154. //----------- End of static function put_attack_rec -----------//
  155. //--------- Begin of static function disp_other_info ---------//
  156. //
  157. static void disp_other_info()
  158. {
  159. //---------- display total income ----------//
  160. vga_back.d3_panel_up(OTHER_INFO_X1, OTHER_INFO_Y1, OTHER_INFO_X2, OTHER_INFO_Y2 );
  161. int x=OTHER_INFO_X1+9;
  162. int y=OTHER_INFO_Y1+6;
  163. int x2=x+300;
  164. font_san.put_field( x, y , "ai_capture_enemy_town_recno", x2, cur_nation_ptr->ai_capture_enemy_town_recno, 1 );
  165. font_san.put_field( x, y+=16, "ai_capture_enemy_town_plan_date", x2, date.date_str(cur_nation_ptr->ai_capture_enemy_town_plan_date) );
  166. font_san.put_field( x, y+=16, "ai_capture_enemy_town_start_attack_date", x2, date.date_str(cur_nation_ptr->ai_capture_enemy_town_start_attack_date) );
  167. font_san.put_field( x, y+=16, "ai_attack_target_nation_recno", x2, cur_nation_ptr->ai_attack_target_nation_recno, 1 );
  168. font_san.put_field( x, y+=16, "ai_attack_target_x_loc", x2, cur_nation_ptr->ai_attack_target_x_loc, 1 );
  169. font_san.put_field( x, y+=16, "ai_attack_target_y_loc", x2, cur_nation_ptr->ai_attack_target_y_loc, 1 );
  170. }
  171. //----------- End of static function disp_other_info -----------//