//---------- 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::single_player_menu ----------// // void Game::single_player_menu() { enum { SINGLE_PLAYER_OPTION_COUNT = 5 }; #ifndef DISABLE_SINGLE_PLAYER_NEW_GAME static OptionInfo single_player_option_array[SINGLE_PLAYER_OPTION_COUNT] = { { 5+SWORD1_X, 10+SWORD1_Y, 282+SWORD1_X, 62+SWORD1_Y }, { 5+SWORD1_X, 67+SWORD1_Y, 282+SWORD1_X, 112+SWORD1_Y }, { 5+SWORD1_X, 120+SWORD1_Y, 282+SWORD1_X, 175+SWORD1_Y }, { 5+SWORD1_X, 182+SWORD1_Y, 282+SWORD1_X, 223+SWORD1_Y }, {40+SWORD1_X, 238+SWORD1_Y, 254+SWORD1_X, 280+SWORD1_Y }, }; static char single_player_option_flag[SINGLE_PLAYER_OPTION_COUNT] = { 1, 1, 1, 1, 1, // 1 = in use, 0 = darken, -1 = invisible }; #else static OptionInfo single_player_option_array[SINGLE_PLAYER_OPTION_COUNT] = { { 2+SWORD1_X, 10+SWORD1_Y, 286+SWORD1_X, 65+SWORD1_Y }, { 2+SWORD1_X, 67+SWORD1_Y, 286+SWORD1_X, 109+SWORD1_Y }, { 2+SWORD1_X, 112+SWORD1_Y, 286+SWORD1_X, 171+SWORD1_Y }, { 2+SWORD1_X, 112+SWORD1_Y, 286+SWORD1_X, 171+SWORD1_Y }, // not used {38+SWORD1_X, 174+SWORD1_Y, 256+SWORD1_X, 216+SWORD1_Y }, }; static char single_player_option_flag[SINGLE_PLAYER_OPTION_COUNT] = { 1, 1, 1, -1, 1, // 1 = in use, 0 = darken, -1 = invisible }; #endif game_mode = GAME_SINGLE_PLAYER; //------ display the single player menu options ------// // image_interface.put_large( &vga_back, 247, 242, "M_SINGLE" ); // vga_util.blt_buf(247, 242, 545, 567); // sys.blt_virtual_buf(); // blt the virtual front buffer to the screen int refreshFlag = 1, i; mouse_cursor.set_icon(CURSOR_NORMAL); char *menuBitmap = NULL; char *brightBitmap = NULL; char *darkBitmap = NULL; int pointingOption = -1; //---------- detect buttons -----------// while(1) { sys.yield(); mouse.get_event(); if( refreshFlag ) { image_interface.put_to_buf( &vga_back, "M_MAIN" ); vga_util.blt_buf(0,0,VGA_WIDTH-1, VGA_HEIGHT-1); if(!menuBitmap) { int resSize; File *resFile; #ifndef DISABLE_SINGLE_PLAYER_NEW_GAME resFile = image_interface.get_file("SWRD-2", resSize); #else resFile = image_interface.get_file("SWRD-4", resSize); #endif menuBitmap = mem_add(resSize); resFile->file_read(menuBitmap, resSize); } if(!brightBitmap) { int resSize; File *resFile; #ifndef DISABLE_SINGLE_PLAYER_NEW_GAME resFile = image_interface.get_file("SWRD-2B", resSize); #else resFile = image_interface.get_file("SWRD-4B", resSize); #endif brightBitmap = mem_add(resSize); resFile->file_read(brightBitmap, resSize); } if(!darkBitmap) { int resSize; File *resFile; #ifndef DISABLE_SINGLE_PLAYER_NEW_GAME resFile = image_interface.get_file("SWRD-2C", resSize); #else resFile = image_interface.get_file("SWRD-2C", resSize); // no SWRD-4C #endif darkBitmap = mem_add(resSize); resFile->file_read(darkBitmap, resSize); } for( i = 0; i < SINGLE_PLAYER_OPTION_COUNT; ++i ) { if( single_player_option_flag[i] >= 0) { mouse.hide_area(single_player_option_array[i].x1, single_player_option_array[i].y1, single_player_option_array[i].x2, single_player_option_array[i].y2); vga_front.put_bitmap_area(SWORD1_X, SWORD1_Y, single_player_option_flag[i] ? menuBitmap : darkBitmap, single_player_option_array[i].x1 - SWORD1_X, single_player_option_array[i].y1 - SWORD1_Y, single_player_option_array[i].x2 - SWORD1_X, single_player_option_array[i].y2 - SWORD1_Y); mouse.show_area(); } } pointingOption = -1; refreshFlag=0; } // ###### begin Gilbert 18/9 ########// if( config.music_flag ) { if( !music.is_playing(1) ) music.play(1, sys.cdrom_drive ? MUSIC_CD_THEN_WAV : 0 ); } else music.stop(); // ###### end Gilbert 18/9 ########// // display main menu int newPointingOption = -1; for(i = 0; i < SINGLE_PLAYER_OPTION_COUNT; ++i) { if( single_player_option_flag[i] > 0 && mouse.in_area(single_player_option_array[i].x1, single_player_option_array[i].y1, single_player_option_array[i].x2, single_player_option_array[i].y2) ) { newPointingOption = i; break; } } if( pointingOption != newPointingOption) { err_when( !menuBitmap ); err_when( !brightBitmap ); err_when( !darkBitmap ); // put un-highlighted option back i = pointingOption; if( i >= 0 && i < SINGLE_PLAYER_OPTION_COUNT ) { mouse.hide_area(single_player_option_array[i].x1, single_player_option_array[i].y1, single_player_option_array[i].x2, single_player_option_array[i].y2); vga_front.put_bitmap_area(SWORD1_X, SWORD1_Y, menuBitmap, single_player_option_array[i].x1 - SWORD1_X, single_player_option_array[i].y1 - SWORD1_Y, single_player_option_array[i].x2 - SWORD1_X, single_player_option_array[i].y2 - SWORD1_Y); mouse.show_area(); } // put new hightlighted option i = newPointingOption; if( i >= 0 && i < SINGLE_PLAYER_OPTION_COUNT ) { mouse.hide_area(single_player_option_array[i].x1,single_player_option_array[i].y1, single_player_option_array[i].x2,single_player_option_array[i].y2); vga_front.put_bitmap_area(SWORD1_X, SWORD1_Y, brightBitmap, single_player_option_array[i].x1 -SWORD1_X,single_player_option_array[i].y1 -SWORD1_Y, single_player_option_array[i].x2 -SWORD1_X,single_player_option_array[i].y2 -SWORD1_Y); mouse.show_area(); } pointingOption = newPointingOption; } sys.blt_virtual_buf(); // blt the virtual front buffer to the screen OptionInfo* optionInfo = single_player_option_array; for( int i=0 ; i<SINGLE_PLAYER_OPTION_COUNT ; i++, optionInfo++ ) { if( single_player_option_flag[i] > 0 && mouse.single_click( optionInfo->x1, optionInfo->y1, optionInfo->x2, optionInfo->y2 ) ) { // free some resource if( menuBitmap ) { mem_del(menuBitmap); menuBitmap = NULL; } if( brightBitmap ) { mem_del(brightBitmap); brightBitmap = NULL; } if( darkBitmap ) { mem_del(darkBitmap); darkBitmap = NULL; } refreshFlag = 1; switch(i+1) { case 1: tutor.select_run_tutor(0); // select and run tutorial, 0-called from the main menu, not from in-game break; case 2: #ifndef DEMO single_player_game(0); #else select_run_scenario(); #endif break; case 3: game_file_array.init("*.SAV"); if( game_file_array.menu(2) == 1) { battle.run_loaded(); deinit(); } { 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; case 4: select_run_scenario(); break; } return; } } } if( menuBitmap ) mem_del(menuBitmap); if( brightBitmap ) mem_del(brightBitmap); if( darkBitmap ) mem_del(darkBitmap); }
//---------- 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 }