OGAMSING.cpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  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 : OGAMSING.CPP
  21. //Description : Single player game interface
  22. #include <OVGA.h>
  23. #include <OSYS.h>
  24. #include <OMOUSE.h>
  25. #include <OFONT.h>
  26. #include <OIMGRES.h>
  27. #include <ORACERES.h>
  28. #include <OINFO.h>
  29. #include <OBUTT3D.h>
  30. #include <OGET.h>
  31. #include <OBATTLE.h>
  32. #include <OGFILE.h>
  33. #include <OGAME.h>
  34. #include <OCONFIG.h>
  35. #include <OMUSIC.h>
  36. #include <OBUTTCUS.h>
  37. #include <OCOLTBL.h>
  38. #include <OGETA.h>
  39. //---------- Define option modes --------//
  40. enum { OPTION_BASIC,
  41. OPTION_ADVANCED,
  42. OPTION_ADVANCE2,
  43. OPTION_GOAL,
  44. };
  45. static char option_mode;
  46. //--------- Define constant ----------//
  47. enum { BASIC_OPTION_X_SPACE = 78,
  48. BASIC_OPTION_HEIGHT = 32 };
  49. enum { COLOR_OPTION_X_SPACE = 35,
  50. COLOR_OPTION_HEIGHT = 32 };
  51. enum { ADVANCED_OPTION_X_SPACE = 89,
  52. ADVANCED_OPTION_Y_SPACE = 34,
  53. ADVANCED_OPTION_HEIGHT = 32 };
  54. static char race_table[MAX_RACE] = // race translation table
  55. #if(MAX_RACE == 10)
  56. {
  57. RACE_CHINESE, RACE_EGYPTIAN, RACE_GREEK, RACE_JAPANESE, RACE_MAYA,
  58. RACE_INDIAN, RACE_NORMAN, RACE_PERSIAN, RACE_VIKING, RACE_ZULU
  59. };
  60. #else
  61. {
  62. RACE_CHINESE, RACE_GREEK, RACE_JAPANESE, RACE_MAYA,
  63. RACE_PERSIAN, RACE_NORMAN, RACE_VIKING
  64. };
  65. #endif
  66. static char reverse_race_table[MAX_RACE] = // race translation table
  67. #if(MAX_RACE == 10)
  68. {
  69. 6, 4, 2, 8, 7, 0, 3, 1, 5, 9
  70. };
  71. #else
  72. {
  73. 5, 3, 1, 6, 4, 0, 2
  74. };
  75. #endif
  76. //------- Declare static functions -------//
  77. static int select_option();
  78. //-------- Begin of function Game::single_player_game --------//
  79. //
  80. // <int> noAI - if there should be no AI in the game.
  81. //
  82. void Game::single_player_game(int noAI)
  83. {
  84. if( !select_option() )
  85. return;
  86. // ------ attempt to save the config -------//
  87. config.save("CONFIG.DAT");
  88. //------ start single player game ----------//
  89. init();
  90. battle.run(0); // 0-not multiplayer game
  91. deinit();
  92. }
  93. //--------- End of function Game::single_player_game ---------//
  94. // define bit flag for refreshFlag
  95. static void disp_virtual_button(ButtonCustom *, int);
  96. static void disp_virtual_tick(ButtonCustom *, int);
  97. #define SGOPTION_PAGE 0x40000000
  98. #define SGOPTION_RACE 0x00000001
  99. #define SGOPTION_COLOR 0x00000002
  100. #define SGOPTION_AI_NATION 0x00000004
  101. #define SGOPTION_DIFFICULTY 0x00000008
  102. #define SGOPTION_TERRAIN 0x00000010
  103. #define SGOPTION_LAND_MASS 0x00000020
  104. #define SGOPTION_NAME_FIELD 0x00000040
  105. #define SGOPTION_MAP_ID 0x00000080
  106. #define SGOPTION_EXPLORED 0x00000100
  107. #define SGOPTION_FOG 0x00000200
  108. #define SGOPTION_TREASURE 0x00000400
  109. #define SGOPTION_AI_TREASURE 0x00000800
  110. #define SGOPTION_AI_AGGRESSIVE 0x00001000
  111. #define SGOPTION_FRYHTANS 0x00002000
  112. #define SGOPTION_RANDOM_STARTUP 0x00004000
  113. #define SGOPTION_RAW 0x00010000
  114. #define SGOPTION_NEAR_RAW 0x00020000
  115. #define SGOPTION_START_TOWN 0x00040000
  116. #define SGOPTION_TOWN_STRENGTH 0x00080000
  117. #define SGOPTION_TOWN_EMERGE 0x00100000
  118. #define SGOPTION_KINGDOM_EMERGE 0x00200000
  119. #define SGOPTION_RANDOM_EVENT 0x00400000
  120. #define SGOPTION_CLEAR_ENEMY 0x01000000
  121. #define SGOPTION_CLEAR_MONSTER 0x02000000
  122. #define SGOPTION_ENOUGH_PEOPLE 0x04000000
  123. #define SGOPTION_ENOUGH_INCOME 0x08000000
  124. #define SGOPTION_ENOUGH_SCORE 0x10000000
  125. #define SGOPTION_TIME_LIMIT 0x20000000
  126. #define SGOPTION_ALL 0x7fffffff
  127. static int select_option()
  128. {
  129. const int offsetY = 124;
  130. char optionMode = OPTION_BASIC;
  131. char menuTitleBitmap[] = "TOP-NSPG";
  132. Config tempConfig = config;
  133. // last multi-player game may set ai_nation_count to zero
  134. if( tempConfig.ai_nation_count < 1 )
  135. tempConfig.ai_nation_count = MAX_NATION-1;
  136. // some setting may be modified in the last game
  137. if( tempConfig.difficulty_level != OPTION_CUSTOM )
  138. tempConfig.change_difficulty(tempConfig.difficulty_level);
  139. int i;
  140. long refreshFlag = SGOPTION_ALL;
  141. int retFlag = 0;
  142. // --------- initialize race button group ---------- //
  143. ButtonCustomGroup raceGroup(MAX_RACE);
  144. for( i = 0; i < MAX_RACE; ++i )
  145. {
  146. #if(MAX_RACE == 10)
  147. raceGroup[i].create(222+(i%5)*BASIC_OPTION_X_SPACE, offsetY+81+(i/5)*BASIC_OPTION_HEIGHT,
  148. 222+(i%5+1)*BASIC_OPTION_X_SPACE-1, offsetY+81+(i/5+1)*BASIC_OPTION_HEIGHT-1,
  149. disp_virtual_button, ButtonCustomPara(&raceGroup, race_table[i]), 0, 0);
  150. #define Y_SHIFT_FLAG 1
  151. #else
  152. raceGroup[i].create(118+i*BASIC_OPTION_X_SPACE, offsetY+103,
  153. 118+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+103+BASIC_OPTION_HEIGHT-1,
  154. disp_virtual_button, ButtonCustomPara(&raceGroup, race_table[i]), 0, 0);
  155. #define Y_SHIFT_FLAG 0
  156. #endif
  157. }
  158. // --------- initialize color button group ---------- //
  159. ButtonCustomGroup colorGroup(MAX_COLOR_SCHEME);
  160. for( i = 0; i < MAX_COLOR_SCHEME; ++i )
  161. {
  162. #if(Y_SHIFT_FLAG)
  163. #define Y_SHIFT 14
  164. #else
  165. #define Y_SHIFT 0
  166. #endif
  167. colorGroup[i].create(195+i*COLOR_OPTION_X_SPACE, offsetY+149+Y_SHIFT,
  168. 195+(i+1)*COLOR_OPTION_X_SPACE-1, offsetY+149+Y_SHIFT+COLOR_OPTION_HEIGHT-1,
  169. disp_virtual_button, ButtonCustomPara(&colorGroup, i+1), 0, 0);
  170. #undef Y_SHIFT
  171. }
  172. // ---------- initialize ai_nation_count buttons --------//
  173. ButtonCustom aiNationInc, aiNationDec;
  174. {
  175. #if(Y_SHIFT_FLAG)
  176. #define Y_SHIFT 14
  177. #else
  178. #define Y_SHIFT 0
  179. #endif
  180. aiNationInc.create(595, offsetY+149+Y_SHIFT,
  181. 595+COLOR_OPTION_X_SPACE-1, offsetY+149+Y_SHIFT+COLOR_OPTION_HEIGHT-1,
  182. disp_virtual_button, ButtonCustomPara(NULL, +1) );
  183. aiNationDec.create(630, offsetY+149+Y_SHIFT,
  184. 630+COLOR_OPTION_X_SPACE-1, offsetY+149+Y_SHIFT+COLOR_OPTION_HEIGHT-1,
  185. disp_virtual_button, ButtonCustomPara(NULL, -1) );
  186. #undef Y_SHIFT
  187. }
  188. // ---------- initialize difficulty_level button group -------//
  189. ButtonCustomGroup diffGroup(6);
  190. for( i = 0; i < 6; ++i )
  191. {
  192. #if(Y_SHIFT_FLAG)
  193. #define Y_SHIFT 17
  194. #else
  195. #define Y_SHIFT 0
  196. #endif
  197. diffGroup[i].create( 205+i*BASIC_OPTION_X_SPACE, offsetY+194+Y_SHIFT,
  198. 205+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+194+Y_SHIFT+BASIC_OPTION_HEIGHT-1,
  199. disp_virtual_button, ButtonCustomPara(&diffGroup, i), 0, 0);
  200. #undef Y_SHIFT
  201. }
  202. // --------- initialize terrain_set button group -------//
  203. ButtonCustomGroup terrainGroup(3);
  204. for( i = 0; i < 3; ++i )
  205. {
  206. #if(Y_SHIFT_FLAG)
  207. #define Y_SHIFT 17
  208. #else
  209. #define Y_SHIFT 0
  210. #endif
  211. #ifdef AMPLUS
  212. terrainGroup[i].create(168+i*BASIC_OPTION_X_SPACE, offsetY+258+Y_SHIFT,
  213. 168+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+258+Y_SHIFT+BASIC_OPTION_HEIGHT-1,
  214. disp_virtual_button, ButtonCustomPara(&terrainGroup, i+1), 0, 0);
  215. #else
  216. // BUGHERE : terrain_set 2 is disable, exchange the position of button 1 and 2
  217. int k = i;
  218. switch(i)
  219. {
  220. case 1: k = 2; break;
  221. case 2: k = 1; break;
  222. }
  223. terrainGroup[i].create(205+k*BASIC_OPTION_X_SPACE, offsetY+258+Y_SHIFT,
  224. 205+(k+1)*BASIC_OPTION_X_SPACE-1, offsetY+258+Y_SHIFT+BASIC_OPTION_HEIGHT-1,
  225. disp_virtual_button, ButtonCustomPara(&terrainGroup, i+1), 0, 0);
  226. if( i == 1 )
  227. terrainGroup[i].enable_flag = 0;
  228. #endif
  229. #undef Y_SHIFT
  230. }
  231. // --------- initialize land_mass button group -------//
  232. ButtonCustomGroup landGroup(3);
  233. for( i = 0; i < 3; ++i )
  234. {
  235. #if(Y_SHIFT_FLAG)
  236. #define Y_SHIFT 17
  237. #else
  238. #define Y_SHIFT 0
  239. #endif
  240. landGroup[i].create(439+i*BASIC_OPTION_X_SPACE, offsetY+258+Y_SHIFT,
  241. 439+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+258+Y_SHIFT+BASIC_OPTION_HEIGHT-1,
  242. disp_virtual_button, ButtonCustomPara(&landGroup, i+1), 0, 0);
  243. #undef Y_SHIFT
  244. }
  245. GetA playerNameField;
  246. // ####### begin Gilbert 3/11 #######//
  247. // playerNameField.init( 318, offsetY+327, 690, tempConfig.player_name,
  248. // tempConfig.PLAYER_NAME_LEN, &font_san, 0, 1);
  249. playerNameField.init( 318, offsetY+322, 690, tempConfig.player_name,
  250. tempConfig.PLAYER_NAME_LEN, &font_bard, 0, 1);
  251. // ####### end Gilbert 3/11 #######//
  252. // --------- initialize info.random_seed field ----------//
  253. const int mapIdSize = 11; // enough to hold a dword in decimal
  254. char mapIdStr[mapIdSize+1];
  255. info.init_random_seed(0);
  256. ltoa( info.random_seed , mapIdStr, 10);
  257. GetA mapIdField;
  258. #if(defined(SPANISH))
  259. #define MAPID_X1 586
  260. #elif(defined(FRENCH))
  261. #define MAPID_X1 572
  262. #else
  263. #define MAPID_X1 564
  264. #endif
  265. mapIdField.init( MAPID_X1, offsetY+112, 700, mapIdStr, mapIdSize, &font_san, 0, 1);
  266. #undef MAPID_X1
  267. // --------- initialize explore_whole_map button group -------//
  268. ButtonCustomGroup exploreGroup(2);
  269. for( i = 0; i < 2; ++i )
  270. {
  271. exploreGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+103,
  272. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+103+BASIC_OPTION_HEIGHT-1,
  273. disp_virtual_button, ButtonCustomPara(&exploreGroup, 1-i), 0, 0);
  274. }
  275. // --------- initialize fog_of_war button group -------//
  276. ButtonCustomGroup fogGroup(2);
  277. for( i = 0; i < 2; ++i )
  278. {
  279. fogGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+135,
  280. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+135+BASIC_OPTION_HEIGHT-1,
  281. disp_virtual_button, ButtonCustomPara(&fogGroup, 1-i), 0, 0);
  282. }
  283. // --------- initialize start_up_cash/start_up_food button group -------//
  284. ButtonCustomGroup treasureGroup(4);
  285. for( i = 0; i < 4; ++i )
  286. {
  287. treasureGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+167,
  288. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+167+BASIC_OPTION_HEIGHT-1,
  289. disp_virtual_button, ButtonCustomPara(&treasureGroup, i+1), 0, 0);
  290. }
  291. // --------- initialize ai_start_up_cash/food button group -------//
  292. ButtonCustomGroup aiTreasureGroup(4);
  293. for( i = 0; i < 4; ++i )
  294. {
  295. aiTreasureGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+199,
  296. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+199+BASIC_OPTION_HEIGHT-1,
  297. disp_virtual_button, ButtonCustomPara(&aiTreasureGroup, i+1), 0, 0);
  298. }
  299. // --------- initialize ai_aggressiveness -------//
  300. ButtonCustomGroup aiAggressiveGroup(4);
  301. for( i = 0; i < 4; ++i )
  302. {
  303. aiAggressiveGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+231,
  304. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+231+BASIC_OPTION_HEIGHT-1,
  305. disp_virtual_button, ButtonCustomPara(&aiAggressiveGroup, i+1), 0, 0);
  306. }
  307. // --------- initialize monster_type -------//
  308. ButtonCustomGroup monsterGroup(3);
  309. for( i = 0; i < 3; ++i )
  310. {
  311. monsterGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+263,
  312. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+263+BASIC_OPTION_HEIGHT-1,
  313. disp_virtual_button, ButtonCustomPara(&monsterGroup, i), 0, 0);
  314. }
  315. // --------- initialize random startup button group -------//
  316. ButtonCustomGroup randomStartUpGroup(2);
  317. for( i = 0; i < 2; ++i )
  318. {
  319. randomStartUpGroup[i].create(335+i*BASIC_OPTION_X_SPACE, offsetY+295,
  320. 335+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+295+BASIC_OPTION_HEIGHT-1,
  321. disp_virtual_button, ButtonCustomPara(&randomStartUpGroup, 1-i), 0, 0);
  322. }
  323. // -------- initialize start_up_raw_site buttons --------- //
  324. ButtonCustom rawSiteInc, rawSiteDec;
  325. rawSiteInc.create( 368, offsetY+100,
  326. 368+COLOR_OPTION_X_SPACE-1, offsetY+100+COLOR_OPTION_HEIGHT-1,
  327. disp_virtual_button, ButtonCustomPara(NULL,0));
  328. rawSiteDec.create( 403, offsetY+100,
  329. 403+COLOR_OPTION_X_SPACE-1, offsetY+100+COLOR_OPTION_HEIGHT-1,
  330. disp_virtual_button, ButtonCustomPara(NULL,0));
  331. // --------- initialize start_up_has_mine_nearby button group --------//
  332. ButtonCustomGroup nearRawGroup(2);
  333. for( i = 0; i < 2; ++i )
  334. {
  335. nearRawGroup[i].create(332+i*BASIC_OPTION_X_SPACE, offsetY+132,
  336. 332+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+132+BASIC_OPTION_HEIGHT-1,
  337. disp_virtual_button, ButtonCustomPara(&nearRawGroup, 1-i), 0, 0);
  338. }
  339. // --------- initialize start_up_independent_town button group --------//
  340. static short startTownArray[3] = { 7, 15, 30 };
  341. ButtonCustomGroup townStartGroup(3);
  342. for( i = 0; i < 3; ++i )
  343. {
  344. townStartGroup[i].create(332+i*BASIC_OPTION_X_SPACE, offsetY+164,
  345. 332+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+164+BASIC_OPTION_HEIGHT-1,
  346. disp_virtual_button, ButtonCustomPara(&townStartGroup, startTownArray[i]), 0, 0);
  347. }
  348. // --------- initialize independent_town_resistance button group --------//
  349. ButtonCustomGroup townResistGroup(3);
  350. for( i = 0; i < 3; ++i )
  351. {
  352. townResistGroup[i].create(332+i*BASIC_OPTION_X_SPACE, offsetY+196,
  353. 332+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+196+BASIC_OPTION_HEIGHT-1,
  354. disp_virtual_button, ButtonCustomPara(&townResistGroup, i+1), 0, 0);
  355. }
  356. // --------- initialize new_independent_town_emerge button group --------//
  357. ButtonCustomGroup townEmergeGroup(2);
  358. for( i = 0; i < 2; ++i )
  359. {
  360. townEmergeGroup[i].create(332+i*BASIC_OPTION_X_SPACE, offsetY+228,
  361. 332+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+228+BASIC_OPTION_HEIGHT-1,
  362. disp_virtual_button, ButtonCustomPara(&townEmergeGroup, 1-i), 0, 0);
  363. }
  364. // --------- initialize new_nation_emerge button group --------//
  365. ButtonCustomGroup nationEmergeGroup(2);
  366. for( i = 0; i < 2; ++i )
  367. {
  368. nationEmergeGroup[i].create(332+i*BASIC_OPTION_X_SPACE, offsetY+260,
  369. 332+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+260+BASIC_OPTION_HEIGHT-1,
  370. disp_virtual_button, ButtonCustomPara(&nationEmergeGroup, 1-i), 0, 0);
  371. }
  372. // --------- initialize random_event_frequency button group --------//
  373. ButtonCustomGroup randomEventGroup(4);
  374. for( i = 0; i < 4; ++i )
  375. {
  376. randomEventGroup[i].create(332+i*BASIC_OPTION_X_SPACE, offsetY+292,
  377. 332+(i+1)*BASIC_OPTION_X_SPACE-1, offsetY+292+BASIC_OPTION_HEIGHT-1,
  378. disp_virtual_button, ButtonCustomPara(&randomEventGroup, i), 0, 0);
  379. }
  380. // ---------- initialize goal buttons ----------//
  381. ButtonCustom clearEnemyButton, clearMonsterButton, enoughPeopleButton, enoughIncomeButton, enoughScoreButton, timeLimitButton;
  382. ButtonCustom peopleInc, peopleDec, incomeInc, incomeDec, scoreInc, scoreDec, yearInc, yearDec;
  383. clearEnemyButton.create( 214, offsetY+145, 214+19, offsetY+145+19,
  384. disp_virtual_tick, ButtonCustomPara(NULL, 0), 0, 1);
  385. clearEnemyButton.enable_flag = 0;;
  386. clearMonsterButton.create( 214, offsetY+178, 214+19, offsetY+178+19,
  387. disp_virtual_tick, ButtonCustomPara(NULL, 0), 0,
  388. tempConfig.goal_destroy_monster);
  389. enoughPeopleButton.create( 214, offsetY+211, 214+19, offsetY+211+19,
  390. disp_virtual_tick, ButtonCustomPara(NULL, 0), 0,
  391. tempConfig.goal_population_flag);
  392. enoughIncomeButton.create( 214, offsetY+244, 214+19, offsetY+244+19, // -9
  393. disp_virtual_tick, ButtonCustomPara(NULL, 0), 0,
  394. tempConfig.goal_economic_score_flag);
  395. enoughScoreButton.create( 214, offsetY+277, 214+19, offsetY+277+19,
  396. disp_virtual_tick, ButtonCustomPara(NULL, 0), 0,
  397. tempConfig.goal_total_score_flag);
  398. timeLimitButton.create( 214, offsetY+309, 214+19, offsetY+309+19, // +23
  399. disp_virtual_tick, ButtonCustomPara(NULL, 0), 0,
  400. tempConfig.goal_year_limit_flag);
  401. peopleInc.create( 529, offsetY+206,
  402. 529+COLOR_OPTION_X_SPACE-1, offsetY+206+COLOR_OPTION_HEIGHT-1,
  403. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  404. peopleDec.create( 564, offsetY+206,
  405. 564+COLOR_OPTION_X_SPACE-1, offsetY+206+COLOR_OPTION_HEIGHT-1,
  406. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  407. incomeInc.create( 529, offsetY+238,
  408. 529+COLOR_OPTION_X_SPACE-1, offsetY+238+COLOR_OPTION_HEIGHT-1,
  409. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  410. incomeDec.create( 564, offsetY+238,
  411. 564+COLOR_OPTION_X_SPACE-1, offsetY+238+COLOR_OPTION_HEIGHT-1,
  412. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  413. scoreInc.create( 529, offsetY+270,
  414. 529+COLOR_OPTION_X_SPACE-1, offsetY+270+COLOR_OPTION_HEIGHT-1,
  415. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  416. scoreDec.create( 564, offsetY+270,
  417. 564+COLOR_OPTION_X_SPACE-1, offsetY+270+COLOR_OPTION_HEIGHT-1,
  418. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  419. yearInc.create( 529, offsetY+302,
  420. 529+COLOR_OPTION_X_SPACE-1, offsetY+302+COLOR_OPTION_HEIGHT-1,
  421. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  422. yearDec.create( 564, offsetY+302,
  423. 564+COLOR_OPTION_X_SPACE-1, offsetY+302+COLOR_OPTION_HEIGHT-1,
  424. disp_virtual_button, ButtonCustomPara(NULL, 0) );
  425. Button3D startButton, returnButton;
  426. // startButton.create(250, 553, "BB-START", "BB-START", 1, 0);
  427. // returnButton.create(440, 553, "BB-RETURN", "BB-RETURN", 1, 0);
  428. startButton.create(194, 538, "START-U", "START-D", 1, 0);
  429. returnButton.create(440, 538, "CANCEL-U", "CANCEL-D", 1, 0);
  430. vga_front.unlock_buf();
  431. while(1)
  432. {
  433. MSG msg;
  434. if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE))
  435. {
  436. if (!GetMessage( &msg, NULL, 0, 0))
  437. {
  438. sys.signal_exit_flag = 1;
  439. // BUGHERE : vga_front is unlocked
  440. return 0;
  441. }
  442. TranslateMessage(&msg);
  443. DispatchMessage(&msg);
  444. continue;
  445. }
  446. else if( sys.paused_flag || !sys.active_flag )
  447. {
  448. WaitMessage();
  449. continue;
  450. }
  451. if( sys.need_redraw_flag )
  452. {
  453. refreshFlag = SGOPTION_ALL;
  454. sys.need_redraw_flag = 0;
  455. }
  456. vga_front.lock_buf();
  457. sys.yield();
  458. mouse.get_event();
  459. // -------- display ----------//
  460. if( refreshFlag )
  461. {
  462. // ------- display basic option ---------//
  463. if( optionMode == OPTION_BASIC )
  464. {
  465. if( refreshFlag & SGOPTION_PAGE )
  466. {
  467. image_menu.put_to_buf( &vga_back, "SPG-BSC");
  468. #if(MAX_RACE == 10)
  469. // protection : image_menu.put_to_buf( &vga_back, "SPG-BSC");
  470. // ensure the user has the release version (I_MENU.RES)
  471. // image_menu2.put_to_buf( &vga_back, "SPG-BSC") get the real one
  472. image_menu2.put_to_buf( &vga_back, "SPG-BSC");
  473. #endif
  474. image_menu.put_back( 234, 15, menuTitleBitmap);
  475. vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1,0);
  476. }
  477. if( refreshFlag & SGOPTION_RACE )
  478. raceGroup.paint( reverse_race_table[tempConfig.race_id-1] );
  479. if( refreshFlag & SGOPTION_COLOR )
  480. colorGroup.paint( tempConfig.player_nation_color-1 );
  481. if( refreshFlag & SGOPTION_AI_NATION )
  482. {
  483. #if(Y_SHIFT_FLAG)
  484. #define Y_SHIFT 14
  485. #else
  486. #define Y_SHIFT 0
  487. #endif
  488. font_san.center_put(564, offsetY+154+Y_SHIFT, 564+25, offsetY+154+Y_SHIFT+21,
  489. m.format(tempConfig.ai_nation_count), 1);
  490. aiNationInc.paint();
  491. aiNationDec.paint();
  492. #undef Y_SHIFT
  493. }
  494. if( refreshFlag & SGOPTION_DIFFICULTY )
  495. diffGroup.paint(tempConfig.difficulty_level);
  496. if( refreshFlag & SGOPTION_TERRAIN )
  497. terrainGroup.paint(tempConfig.terrain_set-1);
  498. if( refreshFlag & SGOPTION_LAND_MASS )
  499. landGroup.paint(tempConfig.land_mass-1);
  500. if( refreshFlag & SGOPTION_NAME_FIELD )
  501. playerNameField.paint();
  502. }
  503. // ------- display advanced option ---------//
  504. if( optionMode == OPTION_ADVANCED )
  505. {
  506. if( refreshFlag & SGOPTION_PAGE )
  507. {
  508. image_menu.put_to_buf( &vga_back, "SPG-O1");
  509. image_menu.put_back( 234, 15, menuTitleBitmap);
  510. vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1,0);
  511. }
  512. if( refreshFlag & SGOPTION_MAP_ID )
  513. mapIdField.paint();
  514. if( refreshFlag & SGOPTION_EXPLORED )
  515. exploreGroup.paint(1-tempConfig.explore_whole_map);
  516. if( refreshFlag & SGOPTION_FOG )
  517. fogGroup.paint(1-tempConfig.fog_of_war);
  518. if( refreshFlag & SGOPTION_TREASURE )
  519. treasureGroup.paint( tempConfig.start_up_cash-1 );
  520. if( refreshFlag & SGOPTION_AI_TREASURE )
  521. aiTreasureGroup.paint( tempConfig.ai_start_up_cash-1 );
  522. if( refreshFlag & SGOPTION_AI_AGGRESSIVE )
  523. aiAggressiveGroup.paint(tempConfig.ai_aggressiveness-1);
  524. if( refreshFlag & SGOPTION_FRYHTANS )
  525. monsterGroup.paint(tempConfig.monster_type);
  526. if( refreshFlag & SGOPTION_RANDOM_STARTUP )
  527. randomStartUpGroup.paint(1-tempConfig.random_start_up);
  528. }
  529. // ------- display advanced option ---------//
  530. if( optionMode == OPTION_ADVANCE2 )
  531. {
  532. if( refreshFlag & SGOPTION_PAGE )
  533. {
  534. image_menu.put_to_buf( &vga_back, "SPG-O2");
  535. image_menu.put_back( 234, 15, menuTitleBitmap);
  536. vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1,0);
  537. }
  538. if( refreshFlag & SGOPTION_RAW )
  539. {
  540. font_san.center_put(337, offsetY+105, 337+25, offsetY+105+21,
  541. m.format(tempConfig.start_up_raw_site), 1);
  542. rawSiteInc.paint();
  543. rawSiteDec.paint();
  544. }
  545. if( refreshFlag & SGOPTION_NEAR_RAW )
  546. nearRawGroup.paint(1-tempConfig.start_up_has_mine_nearby);
  547. if( refreshFlag & SGOPTION_START_TOWN )
  548. townStartGroup.paint(
  549. tempConfig.start_up_independent_town >= 30 ? 2 :
  550. tempConfig.start_up_independent_town <= 7 ? 0 :
  551. 1
  552. );
  553. if( refreshFlag & SGOPTION_TOWN_STRENGTH )
  554. townResistGroup.paint(tempConfig.independent_town_resistance-1);
  555. if( refreshFlag & SGOPTION_TOWN_EMERGE )
  556. townEmergeGroup.paint(1-tempConfig.new_independent_town_emerge);
  557. if( refreshFlag & SGOPTION_KINGDOM_EMERGE )
  558. nationEmergeGroup.paint(1-tempConfig.new_nation_emerge);
  559. if( refreshFlag & SGOPTION_RANDOM_EVENT )
  560. randomEventGroup.paint(tempConfig.random_event_frequency);
  561. }
  562. // ------- display goal option ---------//
  563. if( optionMode == OPTION_GOAL )
  564. {
  565. if( refreshFlag & SGOPTION_PAGE )
  566. {
  567. image_menu.put_to_buf( &vga_back, "SPG-GOAL");
  568. image_menu.put_back( 234, 15, menuTitleBitmap);
  569. vga.blt_buf(0,0,VGA_WIDTH-1,VGA_HEIGHT-1,0);
  570. }
  571. if( refreshFlag & SGOPTION_CLEAR_ENEMY )
  572. clearEnemyButton.paint();
  573. if( refreshFlag & SGOPTION_CLEAR_MONSTER )
  574. clearMonsterButton.paint(tempConfig.goal_destroy_monster);
  575. if( refreshFlag & SGOPTION_ENOUGH_PEOPLE )
  576. {
  577. enoughPeopleButton.paint(tempConfig.goal_population_flag);
  578. font_san.center_put( 456, offsetY+211, 456+67, offsetY+211+21,
  579. m.format(tempConfig.goal_population) ,1);
  580. peopleInc.paint();
  581. peopleDec.paint();
  582. }
  583. if( refreshFlag & SGOPTION_ENOUGH_INCOME )
  584. {
  585. enoughIncomeButton.paint(tempConfig.goal_economic_score_flag);
  586. font_san.center_put( 456, offsetY+243, 456+67, offsetY+243+21,
  587. m.format(tempConfig.goal_economic_score), 1);
  588. incomeInc.paint();
  589. incomeDec.paint();
  590. }
  591. if( refreshFlag & SGOPTION_ENOUGH_SCORE )
  592. {
  593. enoughScoreButton.paint(tempConfig.goal_total_score_flag);
  594. font_san.center_put( 456, offsetY+275, 456+67, offsetY+275+21,
  595. m.format(tempConfig.goal_total_score), 1);
  596. scoreInc.paint();
  597. scoreDec.paint();
  598. }
  599. if( refreshFlag & SGOPTION_TIME_LIMIT )
  600. {
  601. timeLimitButton.paint(tempConfig.goal_year_limit_flag);
  602. font_san.center_put( 456, offsetY+307, 456+33, offsetY+307+21,
  603. m.format(tempConfig.goal_year_limit), 1);
  604. yearInc.paint();
  605. yearDec.paint();
  606. }
  607. }
  608. // ------- display difficulty -------//
  609. if( refreshFlag & SGOPTION_DIFFICULTY )
  610. {
  611. font_san.center_put( 718, offsetY+74, 780, offsetY+108,
  612. m.format(tempConfig.single_player_difficulty()), 1 );
  613. }
  614. // -------- repaint button -------//
  615. if( refreshFlag & SGOPTION_PAGE )
  616. {
  617. startButton.paint();
  618. returnButton.paint();
  619. }
  620. refreshFlag = 0;
  621. }
  622. sys.blt_virtual_buf();
  623. if( config.music_flag )
  624. {
  625. if( !music.is_playing(1) )
  626. music.play(1, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 );
  627. }
  628. else
  629. music.stop();
  630. // --------- detect basic option -------- //
  631. if( optionMode == OPTION_BASIC )
  632. {
  633. if( raceGroup.detect() >= 0)
  634. {
  635. tempConfig.race_id = raceGroup[raceGroup()].custom_para.value;
  636. //refreshFlag |= SGOPTION_RACE;
  637. }
  638. else if( colorGroup.detect() >= 0)
  639. {
  640. tempConfig.player_nation_color = colorGroup[colorGroup()].custom_para.value;
  641. //refreshFlag |= SGOPTION_COLOR;
  642. }
  643. else if( aiNationInc.detect() )
  644. {
  645. tempConfig.ai_nation_count++;
  646. if( tempConfig.ai_nation_count >= MAX_NATION )
  647. tempConfig.ai_nation_count = MAX_NATION-1;
  648. tempConfig.difficulty_level = OPTION_CUSTOM;
  649. refreshFlag |= SGOPTION_AI_NATION | SGOPTION_DIFFICULTY;
  650. }
  651. else if( aiNationDec.detect() )
  652. {
  653. tempConfig.ai_nation_count--;
  654. if( tempConfig.ai_nation_count <= 0 )
  655. tempConfig.ai_nation_count = 1;
  656. tempConfig.difficulty_level = OPTION_CUSTOM;
  657. refreshFlag |= SGOPTION_AI_NATION | SGOPTION_DIFFICULTY;
  658. }
  659. else if( diffGroup.detect() >= 0)
  660. {
  661. if( diffGroup[diffGroup()].custom_para.value != OPTION_CUSTOM )
  662. {
  663. tempConfig.change_difficulty(diffGroup[diffGroup()].custom_para.value);
  664. // all but SGOPTION_PAGE;
  665. refreshFlag |= SGOPTION_ALL & ~SGOPTION_PAGE;
  666. }
  667. }
  668. else if( terrainGroup.detect() >= 0)
  669. {
  670. tempConfig.terrain_set = terrainGroup[terrainGroup()].custom_para.value;
  671. static short latitudeArray[3] = { 45, 70, 20 };
  672. err_when( tempConfig.terrain_set <= 0 || tempConfig.terrain_set > 3 );
  673. tempConfig.latitude = latitudeArray[tempConfig.terrain_set-1];
  674. //refreshFlag |= SGOPTION_TERRAIN;
  675. }
  676. else if( landGroup.detect() >= 0)
  677. {
  678. tempConfig.land_mass = landGroup[landGroup()].custom_para.value;
  679. //refreshFlag |= SGOPTION_LAND_MASS;
  680. }
  681. else if( playerNameField.detect() )
  682. {
  683. refreshFlag |= SGOPTION_NAME_FIELD;
  684. }
  685. }
  686. // -------- detect advanced option ---------//
  687. if( optionMode == OPTION_ADVANCED )
  688. {
  689. if( mapIdField.detect() )
  690. {
  691. refreshFlag |= SGOPTION_MAP_ID;
  692. }
  693. else
  694. if( exploreGroup.detect() >= 0 )
  695. {
  696. tempConfig.explore_whole_map = exploreGroup[exploreGroup()].custom_para.value;
  697. tempConfig.difficulty_level = OPTION_CUSTOM;
  698. // refreshFlag |= SGOPTION_EXPLORED;
  699. refreshFlag |= SGOPTION_DIFFICULTY;
  700. }
  701. else if( fogGroup.detect() >= 0 )
  702. {
  703. tempConfig.fog_of_war = fogGroup[fogGroup()].custom_para.value;
  704. tempConfig.difficulty_level = OPTION_CUSTOM;
  705. // refreshFlag |= SGOPTION_FOG
  706. refreshFlag |= SGOPTION_DIFFICULTY;
  707. }
  708. else if( treasureGroup.detect() >= 0 )
  709. {
  710. tempConfig.start_up_cash = treasureGroup[treasureGroup()].custom_para.value;
  711. tempConfig.difficulty_level = OPTION_CUSTOM;
  712. // refreshFlag |= SGOPTION_TREASURE;
  713. refreshFlag |= SGOPTION_DIFFICULTY;
  714. }
  715. else if( aiTreasureGroup.detect() >= 0 )
  716. {
  717. tempConfig.ai_start_up_cash = aiTreasureGroup[aiTreasureGroup()].custom_para.value;
  718. tempConfig.difficulty_level = OPTION_CUSTOM;
  719. // refreshFlag |= SGOPTION_AI_TREASURE;
  720. refreshFlag |= SGOPTION_DIFFICULTY;
  721. }
  722. else if( aiAggressiveGroup.detect() >= 0 )
  723. {
  724. tempConfig.ai_aggressiveness =
  725. aiAggressiveGroup[aiAggressiveGroup()].custom_para.value;
  726. tempConfig.difficulty_level = OPTION_CUSTOM;
  727. // refreshFlag |= SGOPTION_AI_AGGRESSIVE;
  728. refreshFlag |= SGOPTION_DIFFICULTY;
  729. }
  730. else if( monsterGroup.detect() >= 0 )
  731. {
  732. tempConfig.monster_type = monsterGroup[monsterGroup()].custom_para.value;
  733. tempConfig.difficulty_level = OPTION_CUSTOM;
  734. // refreshFlag |= SGOPTION_FRYHTANS;
  735. refreshFlag |= SGOPTION_DIFFICULTY;
  736. }
  737. else if( randomStartUpGroup.detect() >= 0)
  738. {
  739. tempConfig.random_start_up = randomStartUpGroup[randomStartUpGroup()].custom_para.value;
  740. tempConfig.difficulty_level = OPTION_CUSTOM;
  741. // refreshFlag |= SGOPTION_RANDOM_STARTUP;
  742. refreshFlag |= SGOPTION_DIFFICULTY;
  743. }
  744. }
  745. // -------- detect advanced option ---------//
  746. if( optionMode == OPTION_ADVANCE2 )
  747. {
  748. if( rawSiteInc.detect() )
  749. {
  750. if( ++tempConfig.start_up_raw_site > 7 )
  751. tempConfig.start_up_raw_site = 7;
  752. tempConfig.difficulty_level = OPTION_CUSTOM;
  753. refreshFlag |= SGOPTION_RAW | SGOPTION_DIFFICULTY;
  754. }
  755. else if( rawSiteDec.detect() )
  756. {
  757. if( --tempConfig.start_up_raw_site < 1 )
  758. tempConfig.start_up_raw_site = 1;
  759. tempConfig.difficulty_level = OPTION_CUSTOM;
  760. refreshFlag |= SGOPTION_RAW | SGOPTION_DIFFICULTY;
  761. }
  762. else if( nearRawGroup.detect() >= 0)
  763. {
  764. tempConfig.start_up_has_mine_nearby = nearRawGroup[nearRawGroup()].custom_para.value;
  765. tempConfig.difficulty_level = OPTION_CUSTOM;
  766. // refreshFlag |= SGOPTION_NEAR_RAW;
  767. refreshFlag |= SGOPTION_DIFFICULTY;
  768. }
  769. else if( townStartGroup.detect() >= 0)
  770. {
  771. tempConfig.start_up_independent_town = townStartGroup[townStartGroup()].custom_para.value;
  772. tempConfig.difficulty_level = OPTION_CUSTOM;
  773. // resfreshFlag |= SGOPTION_START_TOWN;
  774. refreshFlag |= SGOPTION_DIFFICULTY;
  775. }
  776. else if( townResistGroup.detect() >= 0)
  777. {
  778. tempConfig.independent_town_resistance = townResistGroup[townResistGroup()].custom_para.value;
  779. tempConfig.difficulty_level = OPTION_CUSTOM;
  780. // resfreshFlag |= SGOPTION_TOWN_RESIST;
  781. refreshFlag |= SGOPTION_DIFFICULTY;
  782. }
  783. else if( townEmergeGroup.detect() >= 0)
  784. {
  785. tempConfig.new_independent_town_emerge = townEmergeGroup[townEmergeGroup()].custom_para.value;
  786. tempConfig.difficulty_level = OPTION_CUSTOM;
  787. // refreshFlag |= SGOPTION_TOWN_EMERGE;
  788. refreshFlag |= SGOPTION_DIFFICULTY;
  789. }
  790. else if( nationEmergeGroup.detect() >= 0)
  791. {
  792. tempConfig.new_nation_emerge = nationEmergeGroup[nationEmergeGroup()].custom_para.value;
  793. tempConfig.difficulty_level = OPTION_CUSTOM;
  794. // refreshFlag |= SGOPTION_NATION_EMERGE;
  795. refreshFlag |= SGOPTION_DIFFICULTY;
  796. }
  797. else if( randomEventGroup.detect() >= 0)
  798. {
  799. tempConfig.random_event_frequency = randomEventGroup[randomEventGroup()].custom_para.value;
  800. tempConfig.difficulty_level = OPTION_CUSTOM;
  801. // refreshFlag |= SGOPTION_RANDOM_EVENT;
  802. refreshFlag |= SGOPTION_DIFFICULTY;
  803. }
  804. }
  805. // -------- detect goal option ----------//
  806. if( optionMode == OPTION_GOAL )
  807. {
  808. if( clearEnemyButton.detect() )
  809. {
  810. }
  811. else if( clearMonsterButton.detect() )
  812. {
  813. tempConfig.goal_destroy_monster = clearMonsterButton.pushed_flag;
  814. }
  815. else if( enoughPeopleButton.detect() )
  816. {
  817. tempConfig.goal_population_flag = enoughPeopleButton.pushed_flag;
  818. }
  819. else if( enoughIncomeButton.detect() )
  820. {
  821. tempConfig.goal_economic_score_flag = enoughIncomeButton.pushed_flag;
  822. }
  823. else if( enoughScoreButton.detect() )
  824. {
  825. tempConfig.goal_total_score_flag = enoughScoreButton.pushed_flag;
  826. }
  827. else if( timeLimitButton.detect() )
  828. {
  829. tempConfig.goal_year_limit_flag = timeLimitButton.pushed_flag;
  830. }
  831. else if( peopleInc.detect() )
  832. {
  833. tempConfig.goal_population += 100;
  834. if( tempConfig.goal_population > 5000 )
  835. tempConfig.goal_population = 5000;
  836. refreshFlag |= SGOPTION_ENOUGH_PEOPLE;
  837. }
  838. else if( peopleDec.detect() )
  839. {
  840. tempConfig.goal_population -= 100;
  841. if( tempConfig.goal_population < 100 )
  842. tempConfig.goal_population = 100;
  843. refreshFlag |= SGOPTION_ENOUGH_PEOPLE;
  844. }
  845. else if( incomeInc.detect() )
  846. {
  847. tempConfig.goal_economic_score += 100;
  848. if( tempConfig.goal_economic_score > 5000 )
  849. {
  850. tempConfig.goal_economic_score = 5000;
  851. }
  852. refreshFlag |= SGOPTION_ENOUGH_INCOME;
  853. }
  854. else if( incomeDec.detect() )
  855. {
  856. tempConfig.goal_economic_score -= 100;
  857. if( tempConfig.goal_economic_score < 100 )
  858. {
  859. tempConfig.goal_economic_score = 100;
  860. }
  861. refreshFlag |= SGOPTION_ENOUGH_INCOME;
  862. }
  863. else if( scoreInc.detect() )
  864. {
  865. if( tempConfig.goal_total_score >= 2000 )
  866. tempConfig.goal_total_score += 500;
  867. else
  868. tempConfig.goal_total_score += 100;
  869. if( tempConfig.goal_total_score > 10000 )
  870. tempConfig.goal_total_score = 10000;
  871. refreshFlag |= SGOPTION_ENOUGH_SCORE;
  872. }
  873. else if( scoreDec.detect() )
  874. {
  875. if( tempConfig.goal_total_score > 2000 )
  876. tempConfig.goal_total_score -= 500;
  877. else
  878. tempConfig.goal_total_score -= 100;
  879. if( tempConfig.goal_total_score < 100 )
  880. tempConfig.goal_total_score = 100;
  881. refreshFlag |= SGOPTION_ENOUGH_SCORE;
  882. }
  883. else if( yearInc.detect() )
  884. {
  885. if( tempConfig.goal_year_limit >= 20 )
  886. tempConfig.goal_year_limit += 5;
  887. else
  888. tempConfig.goal_year_limit++;
  889. if( tempConfig.goal_year_limit > 100 )
  890. {
  891. tempConfig.goal_year_limit = 100;
  892. }
  893. refreshFlag |= SGOPTION_TIME_LIMIT;
  894. }
  895. else if( yearDec.detect() )
  896. {
  897. if( tempConfig.goal_year_limit > 20 )
  898. tempConfig.goal_year_limit -= 5;
  899. else
  900. tempConfig.goal_year_limit--;
  901. if( tempConfig.goal_year_limit < 1 )
  902. {
  903. tempConfig.goal_year_limit = 1;
  904. }
  905. refreshFlag |= SGOPTION_TIME_LIMIT;
  906. }
  907. }
  908. // --------- detect switch option button ------//
  909. if( mouse.single_click(96, offsetY+12, 218, offsetY+54) )
  910. {
  911. if( optionMode != OPTION_BASIC )
  912. {
  913. optionMode = OPTION_BASIC;
  914. refreshFlag = SGOPTION_ALL;
  915. }
  916. }
  917. else if( mouse.single_click(236, offsetY+12, 363, offsetY+54) )
  918. {
  919. if( optionMode != OPTION_ADVANCED )
  920. {
  921. optionMode = OPTION_ADVANCED;
  922. refreshFlag = SGOPTION_ALL;
  923. }
  924. }
  925. else if( mouse.single_click(380, offsetY+12, 506, offsetY+54) )
  926. {
  927. if( optionMode != OPTION_ADVANCE2 )
  928. {
  929. optionMode = OPTION_ADVANCE2;
  930. refreshFlag = SGOPTION_ALL;
  931. }
  932. }
  933. else if( mouse.single_click(523, offsetY+12, 649, offsetY+54) )
  934. {
  935. if( optionMode != OPTION_GOAL )
  936. {
  937. optionMode = OPTION_GOAL;
  938. refreshFlag = SGOPTION_ALL;
  939. }
  940. }
  941. // --------- detect input name --------//
  942. // --------- detect start button --------//
  943. if( startButton.detect() )
  944. {
  945. retFlag = 1;
  946. break; // break while(1)
  947. }
  948. else if( returnButton.detect() )
  949. {
  950. retFlag = 0;
  951. break; // break while(1)
  952. }
  953. vga_front.unlock_buf();
  954. }
  955. if( !vga_front.buf_locked )
  956. vga_front.lock_buf();
  957. if( retFlag )
  958. {
  959. info.init_random_seed( atol(mapIdStr) );
  960. tempConfig.difficulty_rating = tempConfig.single_player_difficulty();
  961. // BUGHERE : terrain_set 2 is not available
  962. #ifndef AMPLUS
  963. if( tempConfig.terrain_set == 2 )
  964. tempConfig.terrain_set = 1;
  965. #endif
  966. config = tempConfig;
  967. }
  968. return retFlag;
  969. }
  970. #ifdef Y_SHIFT
  971. #error
  972. #endif
  973. #undef Y_SHIFT_FLAG
  974. static void disp_virtual_button(ButtonCustom *button, int)
  975. {
  976. mouse.hide_area(button->x1, button->y1, button->x2, button->y2);
  977. if( !button->pushed_flag )
  978. {
  979. // copy from back buffer to front buffer
  980. IMGcopy(vga_front.buf_ptr(), vga_front.buf_pitch(),
  981. vga_back.buf_ptr(), vga_back.buf_pitch(),
  982. button->x1, button->y1, button->x2, button->y2 );
  983. }
  984. else
  985. {
  986. // copy from back buffer to front buffer, but the area is
  987. // darkened by 2 scale
  988. IMGcopyRemap(vga_front.buf_ptr(), vga_front.buf_pitch(),
  989. vga_back.buf_ptr(), vga_back.buf_pitch(),
  990. button->x1, button->y1, button->x2, button->y2,
  991. vga.vga_color_table->get_table(-2) );
  992. // draw black frame
  993. if( button->x2-button->x1+1 == BASIC_OPTION_X_SPACE &&
  994. button->y2-button->y1+1 == BASIC_OPTION_HEIGHT )
  995. {
  996. image_interface.put_front(button->x1, button->y1, "BAS_DOWN");
  997. }
  998. else if( button->x2-button->x1+1 == COLOR_OPTION_X_SPACE &&
  999. button->y2-button->y1+1 == COLOR_OPTION_HEIGHT )
  1000. {
  1001. image_interface.put_front(button->x1, button->y1, "COL_DOWN");
  1002. }
  1003. }
  1004. mouse.show_area();
  1005. }
  1006. static void disp_virtual_tick(ButtonCustom *button, int )
  1007. {
  1008. mouse.hide_area(button->x1, button->y1, button->x2, button->y2);
  1009. // copy from back buffer to front buffer
  1010. IMGcopy(vga_front.buf_ptr(), vga_front.buf_pitch(),
  1011. vga_back.buf_ptr(), vga_back.buf_pitch(),
  1012. button->x1, button->y1, button->x2, button->y2 );
  1013. if( button->pushed_flag )
  1014. image_menu.put_front( button->x1+3, button->y1+3, "NMPG-RCH" );
  1015. mouse.show_area();
  1016. }