// Displays the save panel
function Save_show()
{
// No slot is selected by default
SELECTED_SLOT = 0;
// Freeze the game
freeze_mode = 1;
// Display it
set(mainmenu_save_pan,SHOW);
// Close other menu panels
reset(mainmenu_load_pan,SHOW);
reset(mainmenu_quit_pan,SHOW);
reset(mainmenu_options_pan,SHOW);
reset(mainmenu_options_txt1,SHOW);
reset(mainmenu_options_txt2,SHOW);
reset(mainmenu_options_txt3,SHOW);
reset(mainmenu_options_txt4,SHOW);
reset(mainmenu_options_txt5,SHOW);
reset(mainmenu_options_digit1,SHOW);
reset(mainmenu_options_digit2,SHOW);
reset(mainmenu_options_digit3,SHOW);
reset(mainmenu_options_digit4,SHOW);
reset(mainmenu_credits_pan,SHOW);
reset(mainmenu_credits_txt,SHOW);
reset(mainmenu_newgame_pan,SHOW);
reset(mainmenu_pan,SHOW);
}
// Displays the load panel
function Load_show()
{
// No slot is selected by default
SELECTED_SLOT = 0;
// Freeze the game
freeze_mode = 1;
// Display it
set(mainmenu_load_pan,SHOW);
// Close other menu panels
reset(mainmenu_save_pan,SHOW);
reset(mainmenu_quit_pan,SHOW);
reset(mainmenu_options_pan,SHOW);
reset(mainmenu_options_txt1,SHOW);
reset(mainmenu_options_txt2,SHOW);
reset(mainmenu_options_txt3,SHOW);
reset(mainmenu_options_txt4,SHOW);
reset(mainmenu_options_txt5,SHOW);
reset(mainmenu_options_digit1,SHOW);
reset(mainmenu_options_digit2,SHOW);
reset(mainmenu_options_digit3,SHOW);
reset(mainmenu_options_digit4,SHOW);
reset(mainmenu_credits_pan,SHOW);
reset(mainmenu_credits_txt,SHOW);
reset(mainmenu_newgame_pan,SHOW);
reset(mainmenu_pan,SHOW);
}
// Select a save/load slot
function SELECT_SLOT(but,pan)
{
// There are 2 other buttons defined first
but -= 2;
// Select slot
SELECTED_SLOT = but;
}
/////////////////////////////////////////////////////
// Puts the save/load slot bmap handles into an array
// Also loads the bmaps already at the slots
function init_slots()
{
// Set bmap handles
SAVESLOT_BMAPS[0] = handle(saveloadslot_1);
SAVESLOT_BMAPS[1] = handle(saveloadslot_2);
SAVESLOT_BMAPS[2] = handle(saveloadslot_3);
SAVESLOT_BMAPS[3] = handle(saveloadslot_4);
SAVESLOT_BMAPS[4] = handle(saveloadslot_5);
SAVESLOT_BMAPS[5] = handle(saveloadslot_6);
// Bmaps initialized
SAVESLOT_BMAPS_INIT = true;
// Load bmaps
game_load(savedPicturesFile,0);
}
// Saves the game
function GameSave(slot,pan)
{
// Get the saving slot
slot = SELECTED_SLOT - 1;
// Load the handles, if not done yet
if(!SAVESLOT_BMAPS_INIT) {init_slots();}
// Hide visible panels
reset(mainmenu_save_pan,SHOW);
reset(saveload_selected_pan,SHOW);
// Take the screenshot
bmap_for_screen(ptr_for_handle(SAVESLOT_BMAPS[slot]),1,0);
wait(3);
// Save the screen shot, return if it fails
if(!game_save(savedPicturesFile,0,SV_INFO + SV_BMAPS)) {return;}
wait(1);
// And now save the game
if(game_save(saveSlot_name,slot,SV_ALL - SV_INFO))
{
// Play a "beep" sound, if successfull
snd_play(beep_snd,75,10);
}
// Show main game menu
set(mainmenu_pan,SHOW);
}
/////////////////////////////////////////////////////
// Load a game
function GameLoad(slot,pan)
{
// Get the loading slot
slot = SELECTED_SLOT - 1;
// Load the handles, if not done yet
if(!SAVESLOT_BMAPS_INIT) {init_slots();}
// Load the game
if(game_load(saveSlot_name,slot))
{
// Play a "beep" sound, if successfull
snd_play(beep_snd,75,10);
reset(defeat_pan,SHOW);
reset(victory_pan,SHOW);
media_stop(0);
if (map == 1) media_loop("X-COM UFO Defense PSX - 02 - Geoscape2.mp3",NULL,MUSICVOLUME_i);
if (map == 2) media_loop("X-COM UFO Defense PSX - 01 - Geoscape1.mp3",NULL,MUSICVOLUME_i);
}
wait(1);
// Hide the main menu
reset(mainmenu_pan,SHOW);
reset(defeat_pan,SHOW);
freeze_mode = 0;
}