//---------- Begin of function Game::scenario_editor_menu ----------// // void Game::scenario_editor_menu() { mouse_cursor.set_icon(CURSOR_NORMAL); { VgaFrontLock vgaLock; while(1) { if (!process_messages()) return; VgaFrontReLock vgaReLock; // -------- display ----------// vga.disp_image_file("M_main"); // ------ display button ------// font_thin_black.center_put_paragraph( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, text_game_menu.str_new_game(), 0 ); font_thin_black.center_put_paragraph( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, text_game_menu.str_load_game(), 0 ); font_thin_black.center_put_paragraph( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, text_game_menu.str_cancel(), 0 ); vga.flip(); sys.yield(); mouse.get_event(); if( config.music_flag ) { if( !music.is_playing(3) ) music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else { music.stop(); } // --------- detect -------// // detect new if( mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) ) { game_file_array.init( DIR_SCENARIO, "*.scn" ); // necessary to set the path and extension single_player_game(0); break; } // detect load game else if( mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) ) { err_when( MAX_SCENARIO_PATH <= 1 ); game_file_array.init( DIR_SCENARIO, "*.scn" ); // necessary to set the path and extension // ##### begin Gilbert 20/1 #######// // if( game_file_array.menu(2) == 1) if( game_file_array.menu(3) == 1) // ##### begin Gilbert 20/1 #######// { battle.run_loaded(); // ###### begin Gilbert 22/3 ######// deinit_all(); // ###### end Gilbert 22/3 ######// } { char signalExitFlagBackup = sys.signal_exit_flag; sys.signal_exit_flag = 2; game.deinit(); // game.deinit() is needed if game_file_array.menu fails sys.signal_exit_flag = signalExitFlagBackup; } break; } // cancel else if( mouse.single_click(BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) ) { break; } } // end while } // end scope of vgaLock }
void Game::main_menu() { char optionFlag[5] = { 1, 1, 1, 1, 1, }; // ----- disable some option -------// // test sys.game_version, skip single player and scenario editor optionFlag[0] = optionFlag[2] = (sys.game_version == VERSION_MULTIPLAYER_ONLY) ? 0 : 1; int emptyProfileTesting = 1; mouse_cursor.set_icon(CURSOR_NORMAL); vga_buffer.bar(0,0,VGA_WIDTH-1,VGA_HEIGHT-1,V_BLACK); { VgaFrontLock vgaLock; while(1) { if (!process_messages()) return; VgaFrontReLock vgaReLock; // -------- check auto load game request ------// // -------- display ----------// game_mode = GAME_PREGAME; vga.disp_image_file("M_main"); // ------ display button -------// if( player_profile.is_registered() ) { if( optionFlag[0] > 0 ) // single player font_thin_black.center_put_paragraph( BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2, text_game_menu.str_single_player(), 0); if( optionFlag[1] > 0 ) // multi player font_thin_black.center_put_paragraph( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, text_game_menu.str_multi_player(), 0); if( optionFlag[2] > 0 ) // scenario editor font_thin_black.center_put_paragraph( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2, text_game_menu.str_scenario_editor(), 0); } if( optionFlag[3] > 0 ) font_thin_black.center_put_paragraph( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, text_game_menu.str_hall_of_fame(), 0); if( optionFlag[4] > 0 ) font_thin_black.center_put_paragraph( BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2, text_game_menu.str_credits(), 0); font_thin_black.center_put_paragraph( BUTTON6_X1, BUTTON6_Y1, BUTTON6_X2, BUTTON6_Y2, text_game_menu.str_player_register(), 0); font_thin_black.center_put_paragraph( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, text_game_menu.str_quit(), 0); font_thin_black.center_put_paragraph( BUTTONA_X1, BUTTONA_Y1, BUTTONA_X2, BUTTONA_Y2, text_game_menu.str_web_site(), 0); disp_version(); String resStr; if( !DisplayModeInfo::get_display_info(config.display_mode_id) ) config.display_mode_id = 0; resStr = DisplayModeInfo::get_display_info(config.display_mode_id)->screen_width; resStr += "X"; resStr += DisplayModeInfo::get_display_info(config.display_mode_id)->screen_height; font_thin_black.center_put( BUTTON9_X1, BUTTON9_Y1, BUTTON9_X2, BUTTON9_Y2, resStr ); disp_version(); vga.flip(); sys.yield(); mouse.get_event(); if( config.music_flag ) { if( !music.is_playing(3) ) music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else { music.stop(); } sys.signal_exit_flag = 0; // -------- auto load game on request --------// if( auto_load_file_name ) { int rc = game_file.load_game(NULL, auto_load_file_name); // auto_load_file_name has the full path, no need to give path clear_load_game_in_main_menu(); if( rc > 0 ) { battle.run_loaded(); deinit_all(); } { char signalExitFlagBackup = sys.signal_exit_flag; sys.signal_exit_flag = 2; game.deinit(); // game.deinit() is needed if game_file_array.menu fails sys.signal_exit_flag = signalExitFlagBackup; } continue; } // ---------- detect new user ---------// if( emptyProfileTesting ) // do this testing only once { emptyProfileTesting = 0; if( PlayerProfile::load_count_profiles( NULL, 1) == 0 ) // maxLoad=1 for fast testing { box.msg( text_game_menu.str_first_welcome() ); // run_main_menu_option(0); don't call run_main_menu_option, we can't get it detect new profile if( player_profile.register_menu() == 1 // return 1 = new profile created && player_profile.is_registered() // check is_registered for safety && box.ask(text_game_menu.str_first_training()) ) // ask continue training { // ##### patch begin Gilbert 4/10 #####// game_file_array.init( player_profile.save_game_path(NULL), "*.sav" ); // necessary to set the path and extension // ##### patch end Gilbert 4/10 #####// tutor.building_size = 2; // default small building size tutor.run( 2, 0 ); // 2 - is the first fryhtan training tutorial id, 0 - not inGameCall } } if( sys.signal_exit_flag == 1 ) break; else continue; } // -------- detect --------// if( player_profile.is_registered() && optionFlag[0] > 0 && mouse.single_click(BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2) ) { run_main_menu_option(1); // single player } else if( player_profile.is_registered() && optionFlag[1] > 0 && mouse.single_click(BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) ) { run_main_menu_option(2); // multi player } else if( player_profile.is_registered() && optionFlag[2] > 0 && mouse.single_click(BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2) ) { run_main_menu_option(3); // scenario editor } else if( optionFlag[3] > 0 && mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) ) { run_main_menu_option(4); // hall of fame } else if( optionFlag[4] > 0 && mouse.single_click( BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2) ) { run_main_menu_option(5); // credits } else if( mouse.single_click(BUTTON6_X1, BUTTON6_Y1, BUTTON6_X2, BUTTON6_Y2) ) { run_main_menu_option(0); // profile } else if( mouse.single_click( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) ) { // quit break; } else if( mouse.single_click( BUTTON9_X1, BUTTON9_Y1, BUTTON9_X2, BUTTON9_Y2) ) { if( DisplayModeInfo::get_display_info(config.display_mode_id+1) ) ++config.display_mode_id; else config.display_mode_id = 0; } else if( mouse.single_click( BUTTONA_X1, BUTTONA_Y1, BUTTONA_X2, BUTTONA_Y2) ) { run_main_menu_option(6); // home page } // ----- check signal exit flag -------// if( sys.signal_exit_flag == 1 ) break; } // end while } // end the scope of vgaLock }
//---------- Begin of function Game::single_player_menu ----------// // void Game::single_player_menu() { char optionFlag[5] = { 1, 1, 1, 1, 1, }; mouse_cursor.set_icon(CURSOR_NORMAL); optionFlag[4] = select_run_scenario(1) > 0; // 1 - count number of scenario { VgaFrontLock vgaLock; while(1) { if (!process_messages()) return; VgaFrontReLock vgaReLock; // -------- display ----------// vga.disp_image_file("M_main"); // ------ display button ------// if( optionFlag[0] ) font_thin_black.center_put_paragraph( BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2, text_game_menu.str_training(), 0 ); if( optionFlag[1] ) font_thin_black.center_put_paragraph( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, text_game_menu.str_new_campaign(), 0 ); if( optionFlag[2] ) font_thin_black.center_put_paragraph( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2, text_game_menu.str_new_single_game(), 0 ); if( optionFlag[3] ) font_thin_black.center_put_paragraph( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, text_game_menu.str_load_game(), 0 ); if( optionFlag[4] ) font_thin_black.center_put_paragraph( BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2, text_game_menu.str_load_scenario(), 0 ); font_thin_black.center_put_paragraph( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, text_game_menu.str_cancel(), 0 ); vga.flip(); sys.yield(); mouse.get_event(); if( config.music_flag ) { if( !music.is_playing(3) ) music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else { music.stop(); } // --------- detect -------// // detect training if( optionFlag[0] && mouse.single_click(BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.sav" ); // necessary to set the path and extension tutor.select_run_tutor(0); break; } // detect new campaign else if( optionFlag[1] && mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.sav" ); // necessary to set the path and extension run_campaign(); break; } // detect new single game else if( optionFlag[2] && mouse.single_click( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.sav" ); // necessary to set the path and extension single_player_game(0); break; } // detect load game else if( optionFlag[3] && mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.sav" ); // necessary to set the path and extension // ##### begin Gilbert 20/1 #######// // if( game_file_array.menu(2) == 1) if( game_file_array.menu(3) == 1) // ##### begin Gilbert 20/1 #######// { battle.run_loaded(); deinit_all(); } { char signalExitFlagBackup = sys.signal_exit_flag; sys.signal_exit_flag = 2; game.deinit(); // game.deinit() is needed if game_file_array.menu fails sys.signal_exit_flag = signalExitFlagBackup; } break; } // run scenario else if( optionFlag[4] && mouse.single_click(BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.sav" ); // necessary to set the path and extension select_run_scenario(); break; } // cancel else if( mouse.single_click(BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) ) { break; } } // end while } // end scope of vgaLock }
//-------- Begin of function Game::run_campaign --------// // void Game::run_campaign() { err_when( cur_campaign ); Config saveConfig = config; // save the original config as the campaign will overwrite it. int rc = select_campaign_menu(); //---- while we save the original config, we need to overwrite it with new settings the player has just chosen ---// saveConfig.race_id = config.race_id; saveConfig.player_nation_color = config.player_nation_color; strcpy( saveConfig.player_name, config.player_name ); saveConfig.campaign_difficulty = config.campaign_difficulty; saveConfig.building_size = config.building_size; saveConfig.fog_of_war = config.fog_of_war; saveConfig.random_event_frequency = config.random_event_frequency; //---- create debuggin log if in testing mode -----// #ifdef DEBUG if( misc.is_file_exist("CTEST.SYS") ) { game.debug_log = new LongLog('0'); game.debug_log->printf( "\n\r---------------------------\n\r" ); } //---------------------------------------// char total_stage_run_count_array[MAX_STAGE]; char total_event_run_count_array[MAX_EVENT]; int maxStage, maxEvent; memset( total_stage_run_count_array, 0, sizeof(total_stage_run_count_array) ); memset( total_event_run_count_array, 0, sizeof(total_event_run_count_array) ); #endif //---------------------------------------// while( rc > 0 ) { init_campaign(rc); cur_campaign->init_new_campaign(); game.main_loop_all(); int autoTestFlag = cur_campaign->auto_test_flag; //----- write debug log ---------// #ifdef DEBUG if( game.debug_log ) { game.debug_log->printf( "\n\r---------------------------\n\r" ); //--- write the execution counters ----// int i; for( i=0 ; i<cur_campaign->max_stage ; i++ ) { game.debug_log->printf( "Stage %d: %d\n\r", i+1, cur_campaign->stage_run_count_array[i] ); // stage run counters total_stage_run_count_array[i] += cur_campaign->stage_run_count_array[i]; } game.debug_log->printf( "\n\r" ); for( i=0 ; i<cur_campaign->max_event ; i++ ) { game.debug_log->printf( "Event %d: %d\n\r", i+1, cur_campaign->event_run_count_array[i] ); // event run counters total_event_run_count_array[i] += cur_campaign->event_run_count_array[i]; } maxStage = cur_campaign->max_stage; maxEvent = cur_campaign->max_event; game.debug_log->printf( "\n\r---------------------------\n\r" ); } #endif //-------------------------------------// deinit_all(); if( autoTestFlag ) rc = 1; else rc = 0; } config = saveConfig; #ifdef DEBUG if( game.debug_log ) { //-- write the total of the counters from all games previously run --// game.debug_log->printf( "TOTAL\n\r" ); int i; for( i=0 ; i<maxStage ; i++ ) game.debug_log->printf( "Stage %d: %d\n\r", i+1, total_stage_run_count_array[i] ); // stage run counters game.debug_log->printf( "\n\r" ); for( i=0 ; i<maxEvent ; i++ ) game.debug_log->printf( "Event %d: %d\n\r", i+1, total_event_run_count_array[i] ); // event run counters game.debug_log->printf( "\n\r---------------------------\n\r" ); //------ delete the log class ------// delete game.debug_log; game.debug_log = NULL; } #endif }
//---------- Begin of function Game::scenario_editor_menu ----------// // void Game::scenario_editor_menu() { int refreshFlag = SPOPTION_ALL; mouse_cursor.set_icon(CURSOR_NORMAL); { VgaFrontLock vgaLock; while(1) { #if 0 // FIXME MSG msg; if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage( &msg, NULL, 0, 0)) { sys.signal_exit_flag = 1; // BUGHERE : vga_front is unlocked return; } TranslateMessage(&msg); DispatchMessage(&msg); continue; } else if( sys.paused_flag || !sys.active_flag ) { WaitMessage(); continue; } #endif if( sys.need_redraw_flag ) { refreshFlag = SPOPTION_ALL; sys.need_redraw_flag = 0; } VgaFrontReLock vgaReLock; // -------- display ----------// if( refreshFlag ) { if( refreshFlag & SPOPTION_PAGE ) { vga.use_back(); vga_util.disp_image_file("M_MAIN"); // ------ display button ------// font_thin_black.center_put_paragraph( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, text_game_menu.str_new_game(), 0 ); font_thin_black.center_put_paragraph( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, text_game_menu.str_load_game(), 0 ); font_thin_black.center_put_paragraph( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, text_game_menu.str_cancel(), 0 ); vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 ); vga.use_front(); } refreshFlag = 0; } sys.blt_virtual_buf(); // blt the virtual front buffer to the screen sys.yield(); mouse.get_event(); if( config.music_flag ) { if( !music.is_playing(3) ) music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else { music.stop(); } // --------- detect -------// // detect new if( mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) ) { game_file_array.init( DIR_SCENARIO, "*.SCN" ); // necessary to set the path and extension single_player_game(0); break; } // detect load game else if( mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) ) { err_when( MAX_SCENARIO_PATH <= 1 ); game_file_array.init( DIR_SCENARIO, "*.SCN" ); // necessary to set the path and extension // ##### begin Gilbert 20/1 #######// // if( game_file_array.menu(2) == 1) if( game_file_array.menu(3) == 1) // ##### begin Gilbert 20/1 #######// { battle.run_loaded(); // ###### begin Gilbert 22/3 ######// deinit_all(); // ###### end Gilbert 22/3 ######// } { char signalExitFlagBackup = sys.signal_exit_flag; sys.signal_exit_flag = 2; game.deinit(); // game.deinit() is needed if game_file_array.menu fails sys.signal_exit_flag = signalExitFlagBackup; } break; } // cancel else if( mouse.single_click(BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) ) { break; } } // end while } // end scope of vgaLock }
//---------- Begin of function Game::single_player_menu ----------// // void Game::single_player_menu() { int refreshFlag = SPOPTION_ALL; #ifdef DEMO char optionFlag[5] = { 1, 0, 0, 1, 1, }; #else char optionFlag[5] = { 1, 1, 1, 1, 1, }; #endif mouse_cursor.set_icon(CURSOR_NORMAL); #ifdef DISABLE_SINGLE_PLAYER_NEW_GAME optionFlag[1] = 0; // disable new campaign optionFlag[2] = 0; // disable new single game #endif optionFlag[4] = select_run_scenario(1) > 0; // 1 - count number of scenario { VgaFrontLock vgaLock; while(1) { #if 0 // FIXME MSG msg; if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage( &msg, NULL, 0, 0)) { sys.signal_exit_flag = 1; // BUGHERE : vga_front is unlocked return; } TranslateMessage(&msg); DispatchMessage(&msg); continue; } else if( sys.paused_flag || !sys.active_flag ) { WaitMessage(); continue; } #endif if( sys.need_redraw_flag ) { refreshFlag = SPOPTION_ALL; sys.need_redraw_flag = 0; } VgaFrontReLock vgaReLock; // -------- display ----------// if( refreshFlag ) { if( refreshFlag & SPOPTION_PAGE ) { vga.use_back(); vga_util.disp_image_file("M_MAIN"); // ------ display button ------// if( optionFlag[0] ) font_thin_black.center_put_paragraph( BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2, text_game_menu.str_training(), 0 ); if( optionFlag[1] ) font_thin_black.center_put_paragraph( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, text_game_menu.str_new_campaign(), 0 ); if( optionFlag[2] ) font_thin_black.center_put_paragraph( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2, text_game_menu.str_new_single_game(), 0 ); if( optionFlag[3] ) font_thin_black.center_put_paragraph( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, text_game_menu.str_load_game(), 0 ); if( optionFlag[4] ) font_thin_black.center_put_paragraph( BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2, text_game_menu.str_load_scenario(), 0 ); font_thin_black.center_put_paragraph( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, text_game_menu.str_cancel(), 0 ); vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 ); vga.use_front(); } refreshFlag = 0; } sys.blt_virtual_buf(); // blt the virtual front buffer to the screen sys.yield(); mouse.get_event(); if( config.music_flag ) { if( !music.is_playing(3) ) music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else { music.stop(); } // --------- detect -------// // detect training if( optionFlag[0] && mouse.single_click(BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" ); // necessary to set the path and extension tutor.select_run_tutor(0); break; } // detect new campaign else if( optionFlag[1] && mouse.single_click( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" ); // necessary to set the path and extension run_campaign(); break; } // detect new single game else if( optionFlag[2] && mouse.single_click( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" ); // necessary to set the path and extension single_player_game(0); break; } // detect load game else if( optionFlag[3] && mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" ); // necessary to set the path and extension // ##### begin Gilbert 20/1 #######// // if( game_file_array.menu(2) == 1) if( game_file_array.menu(3) == 1) // ##### begin Gilbert 20/1 #######// { battle.run_loaded(); deinit_all(); } { char signalExitFlagBackup = sys.signal_exit_flag; sys.signal_exit_flag = 2; game.deinit(); // game.deinit() is needed if game_file_array.menu fails sys.signal_exit_flag = signalExitFlagBackup; } break; } // run scenario else if( optionFlag[4] && mouse.single_click(BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2) ) { game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" ); // necessary to set the path and extension select_run_scenario(); break; } // cancel else if( mouse.single_click(BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) ) { break; } } // end while } // end scope of vgaLock }
void Game::main_menu() { int refreshFlag = MMOPTION_ALL; char optionFlag[5] = { 1, 1, 1, 1, 1, }; // ----- disable some option -------// // test sys.game_version, skip single player and scenario editor optionFlag[0] = optionFlag[2] = #if(defined(DISABLE_SINGLE_PLAYER)) 0; #elif(defined(DEBUG)) 1; #elif(defined(BETA)) 1; #else (sys.game_version == VERSION_MULTIPLAYER_ONLY) ? 0 : 1; #endif #ifdef DISABLE_MULTI_PLAYER // disable multiplayer game, Game::multi_player_menu is disabled optionFlag[1] = 0; #endif #ifdef DISABLE_SCENARIO_EDITOR optionFlag[2] = 0; #endif int emptyProfileTesting = 1; mouse_cursor.set_icon(CURSOR_NORMAL); vga_front.bar(0,0,VGA_WIDTH-1,VGA_HEIGHT-1,V_BLACK); unsigned long lastRedrawTime = misc.get_time(); { VgaFrontLock vgaLock; while(1) { #if 0 // FIXME MSG msg; if (PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage( &msg, NULL, 0, 0)) { sys.signal_exit_flag = 1; // BUGHERE : vga_front is unlocked return; } TranslateMessage(&msg); DispatchMessage(&msg); continue; } else if( sys.paused_flag || !sys.active_flag ) { WaitMessage(); continue; } #endif if( sys.need_redraw_flag || misc.get_time() - lastRedrawTime > 8000 ) { refreshFlag = MMOPTION_ALL; sys.need_redraw_flag = 0; lastRedrawTime = misc.get_time(); // redraw every 8 sec. Such that if background erased at the beginning, redraw } VgaFrontReLock vgaReLock; // -------- check auto load game request ------// if( auto_load_file_name ) { refreshFlag = 0; } // -------- display ----------// game_mode = GAME_PREGAME; if( refreshFlag ) { if( refreshFlag & MMOPTION_PAGE ) { vga.use_back(); vga_util.disp_image_file("M_MAIN"); // // ------ display copyright message --------// // font_zoom.right_put( 755, 62, "(c) Copyright 1999 by Enlight Software and Trevor Chan" ); // ------ display button -------// if( player_profile.is_registered() ) { if( optionFlag[0] > 0 ) // single player font_thin_black.center_put_paragraph( BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2, text_game_menu.str_single_player(), 0); if( optionFlag[1] > 0 ) // multi player font_thin_black.center_put_paragraph( BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2, text_game_menu.str_multi_player(), 0); if( optionFlag[2] > 0 ) // scenario editor font_thin_black.center_put_paragraph( BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2, text_game_menu.str_scenario_editor(), 0); } if( optionFlag[3] > 0 ) font_thin_black.center_put_paragraph( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2, text_game_menu.str_hall_of_fame(), 0); if( optionFlag[4] > 0 ) font_thin_black.center_put_paragraph( BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2, text_game_menu.str_credits(), 0); font_thin_black.center_put_paragraph( BUTTON6_X1, BUTTON6_Y1, BUTTON6_X2, BUTTON6_Y2, text_game_menu.str_player_register(), 0); font_thin_black.center_put_paragraph( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2, text_game_menu.str_quit(), 0); font_thin_black.center_put_paragraph( BUTTONA_X1, BUTTONA_Y1, BUTTONA_X2, BUTTONA_Y2, text_game_menu.str_web_site(), 0); vga_util.blt_buf( 0, 0, VGA_WIDTH-1, VGA_HEIGHT-1, 0 ); vga.use_front(); disp_version(); } if( refreshFlag & MMOPTION_RESOLUTION ) { String resStr; if( !DisplayModeInfo::get_display_info(config.display_mode_id) ) config.display_mode_id = MODE_ID_DEFAULT; resStr = DisplayModeInfo::get_display_info(config.display_mode_id)->screen_width; resStr += "X"; resStr += DisplayModeInfo::get_display_info(config.display_mode_id)->screen_height; vga_util.blt_buf( BUTTON9_X1, BUTTON9_Y1, BUTTON9_X2, BUTTON9_Y2, 0); font_thin_black.center_put( BUTTON9_X1, BUTTON9_Y1, BUTTON9_X2, BUTTON9_Y2, resStr ); disp_version(); } refreshFlag = 0; } sys.blt_virtual_buf(); // blt the virtual front buffer to the screen sys.yield(); mouse.get_event(); if( config.music_flag ) { if( !music.is_playing(3) ) music.play(3, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else { music.stop(); } sys.signal_exit_flag = 0; // -------- auto load game on request --------// if( auto_load_file_name ) { int rc = game_file.load_game(NULL, auto_load_file_name); // auto_load_file_name has the full path, no need to give path clear_load_game_in_main_menu(); if( rc > 0 ) { battle.run_loaded(); deinit_all(); } { char signalExitFlagBackup = sys.signal_exit_flag; sys.signal_exit_flag = 2; game.deinit(); // game.deinit() is needed if game_file_array.menu fails sys.signal_exit_flag = signalExitFlagBackup; } refreshFlag = MMOPTION_ALL; continue; } // ---------- detect new user ---------// if( emptyProfileTesting ) // do this testing only once { emptyProfileTesting = 0; if( PlayerProfile::load_count_profiles( NULL, 1) == 0 ) // maxLoad=1 for fast testing { box.msg( text_game_menu.str_first_welcome() ); // run_main_menu_option(0); don't call run_main_menu_option, we can't get it detect new profile if( player_profile.register_menu() == 1 // return 1 = new profile created && player_profile.is_registered() // check is_registered for safety && box.ask(text_game_menu.str_first_training()) ) // ask continue training { // ##### patch begin Gilbert 4/10 #####// game_file_array.init( player_profile.save_game_path(NULL), "*.SAV" ); // necessary to set the path and extension // ##### patch end Gilbert 4/10 #####// tutor.building_size = 2; // default small building size tutor.run( 2, 0 ); // 2 - is the first fryhtan training tutorial id, 0 - not inGameCall } } if( sys.signal_exit_flag == 1 ) break; else continue; } // -------- detect --------// if( player_profile.is_registered() && optionFlag[0] > 0 && mouse.single_click(BUTTON1_X1, BUTTON1_Y1, BUTTON1_X2, BUTTON1_Y2) ) { run_main_menu_option(1); // single player refreshFlag = MMOPTION_ALL; } else if( player_profile.is_registered() && optionFlag[1] > 0 && mouse.single_click(BUTTON2_X1, BUTTON2_Y1, BUTTON2_X2, BUTTON2_Y2) ) { run_main_menu_option(2); // multi player refreshFlag = MMOPTION_ALL; } else if( player_profile.is_registered() && optionFlag[2] > 0 && mouse.single_click(BUTTON3_X1, BUTTON3_Y1, BUTTON3_X2, BUTTON3_Y2) ) { run_main_menu_option(3); // scenario editor refreshFlag = MMOPTION_ALL; } else if( optionFlag[3] > 0 && mouse.single_click( BUTTON4_X1, BUTTON4_Y1, BUTTON4_X2, BUTTON4_Y2) ) { run_main_menu_option(4); // hall of fame refreshFlag = MMOPTION_ALL; } else if( optionFlag[4] > 0 && mouse.single_click( BUTTON5_X1, BUTTON5_Y1, BUTTON5_X2, BUTTON5_Y2) ) { run_main_menu_option(5); // credits refreshFlag = MMOPTION_ALL; } else if( mouse.single_click(BUTTON6_X1, BUTTON6_Y1, BUTTON6_X2, BUTTON6_Y2) ) { run_main_menu_option(0); // profile refreshFlag = MMOPTION_ALL; } else if( mouse.single_click( BUTTON8_X1, BUTTON8_Y1, BUTTON8_X2, BUTTON8_Y2) ) { // quit break; } else if( mouse.single_click( BUTTON9_X1, BUTTON9_Y1, BUTTON9_X2, BUTTON9_Y2) ) { if( DisplayModeInfo::get_display_info(config.display_mode_id+1) ) ++config.display_mode_id; else config.display_mode_id = 0; refreshFlag |= MMOPTION_RESOLUTION; } else if( mouse.single_click( BUTTONA_X1, BUTTONA_Y1, BUTTONA_X2, BUTTONA_Y2) ) { run_main_menu_option(6); // home page refreshFlag = MMOPTION_ALL; } // ----- check signal exit flag -------// if( sys.signal_exit_flag == 1 ) break; } // end while } // end the scope of vgaLock // #ifdef DEMO // demo_disp_ad_page(); // #else // //---- display game end advertising page ----// // vga_util.disp_image_file("MAINMENU"); // mouse.wait_press(60); // vga_util.finish_disp_image_file(); // #endif }
static void sigint_handler(int sig) { deinit_all(); exit(EXIT_SUCCESS); }