Hi there,
Even moar dumb questions are coming.
I made the Main Menu in the game and it almost 100 % works, expect ... saving and load the game.
When I click "Uložit" ("to save" in czech language), nothing happens... no response
[imgzoom]https://i.imgur.com/wg7ZOW3.png[/imgzoom]
I totally don't understand how coding works :D So I literally stolen the script from the Sierra template, but it works there, so why it doesn't for me?
The Save button does this:
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
int gameSlotToSaveInto = find_save_slot(txtNewSaveName.Text);
if (gameSlotToSaveInto < 0)
{
Display("No more free save slots!");
return;
}
SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
//gSaveGame.Visible = false;
}
Also here is everything in my code to save related - you can check if I miss something here:
//stuff
function show_save_game_dialog()
{
gSaveGame.Visible = true;
// Get the list of save games
lstSaveGamesList.FillSaveGameList();
if (lstSaveGamesList.ItemCount > 0)
{
// If there is at least one, set the default text
// to be the first game's name
txtNewSaveName.Text = lstSaveGamesList.Items[0];
}
else
{
// No save games yet, default empty text.
txtNewSaveName.Text = "";
}
mouse.UseModeGraphic(eModePointer);
gInventory1.Visible = false;
}
function show_restore_game_dialog()
{
gRestoreGame.Visible = true;
lstRestoreGamesList.FillSaveGameList();
mouse.UseModeGraphic(eModePointer);
gInventory1.Visible = false;
}
function close_save_game_dialog()
{
gSaveGame.Visible = false;
mouse.UseDefaultGraphic();
gInventory1.Visible = true;
}
function close_restore_game_dialog()
{
gRestoreGame.Visible = false;
mouse.UseDefaultGraphic();
gInventory1.Visible = true;
}
//save
function btnCancelSave_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = false;
}
int find_save_slot(String name)
{
bool slots[] = new bool[999];
int i = 0;
while (i < lstSaveGamesList.ItemCount)
{
if (lstSaveGamesList.Items[i] == name)
{
// found existing save with matching name
return lstSaveGamesList.SaveGameSlots[i];
}
// remember which slots are already taken
slots[lstSaveGamesList.SaveGameSlots[i]] = true;
i++;
}
// Find first free save slot, starting with slot 1
i = 1;
while (i < 999)
{
if (!slots[i])
return i;
i++;
}
// no free slots found
return -1;
}
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
int gameSlotToSaveInto = find_save_slot(txtNewSaveName.Text);
if (gameSlotToSaveInto < 0)
{
Display("No more free save slots!");
return;
}
SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
//gSaveGame.Visible = false;
}
function btnCancelRestore_OnClick(GUIControl *control, MouseButton button)
{
gRestoreGame.Visible = false;
}
function btnRestoreGame_OnClick(GUIControl *control, MouseButton button)
{
if (lstRestoreGamesList.SelectedIndex >= 0)
{
RestoreGameSlot(lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex]);
}
gRestoreGame.Visible = false;
}
function lstSaveGamesList_OnSelectionCh(GUIControl *control)
{
txtNewSaveName.Text = lstSaveGamesList.Items[lstSaveGamesList.SelectedIndex];
}
function txtNewSaveName_OnActivate(GUIControl *control)
{
// Pressing return in the text box simulates clicking the Save button
btnSaveGame_OnClick(control, eMouseLeft);
}
function btnDeleteSave_OnClick(GUIControl *control, MouseButton button)
{
if (lstSaveGamesList.SelectedIndex >= 0)
{
DeleteSaveSlot(lstSaveGamesList.SaveGameSlots[lstSaveGamesList.SelectedIndex]);
lstSaveGamesList.FillSaveGameList();
}
}
function bQuit_OnClick(GUIControl *control, MouseButton button)
{
QuitGame(0);
}
//function bPlay_OnClick(GUIControl *control, MouseButton button)
//{
//gExitGame.Visible = false;
//gIconbar.Visible = true;
//mouse.UseDefaultGraphic();
//}
function lstSaveGamesList_OnSelectionChanged(GUIControl *control)
{
txtNewSaveName.Text = lstSaveGamesList.Items[lstSaveGamesList.SelectedIndex];
}
function lstRestoreGamesList_OnSelectionChanged(GUIControl *control)
{
}
function bLoad_OnClick(GUIControl *control, MouseButton button)
{
gRestoreGame.Visible = true;
}
function sldAudio_OnChange(GUIControl *control)
{
System.Volume = sldAudio.Value;
}
function sldSpeed_OnChange(GUIControl *control)
{
SetGameSpeed(sldSpeed.Value);
}
function btnResume_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = false;
mouse.UseDefaultGraphic();
}
function bSettings_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = true;
}
function btnOk_OnClick(GUIControl *control, MouseButton button)
{
gOvladani.Visible = false;
}
function bControls_OnClick(GUIControl *control, MouseButton button)
{
gOvladani.Visible = true;
}
function bNovaHra2_OnClick(GUIControl *control, MouseButton button)
{
gRestartYN.Visible = true;
}
function bSave2_OnClick(GUIControl *control, MouseButton button)
{
gSaveGame.Visible = true;
}
function bLoad2_OnClick(GUIControl *control, MouseButton button)
{
gRestoreGame.Visible = true;
}
function bSettings2_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = true;
}
function bControls2_OnClick(GUIControl *control, MouseButton button)
{
gOvladani.Visible = true;
}
function bEND2_OnClick(GUIControl *control, MouseButton button)
{
gExitDialogue.Visible = true;
Thanks for all advice!
The very first step is to make sure that the function is actually called. Just add
Display("save button clicked");
as the first line to that function.
When you say "the save button does this", do you mean you did enter btnSaveGame_OnClick into the button's on click event? Or did you just copy that function (which will have no effect)?
Quote from: Khris on Sat 06/07/2019 14:35:36
The very first step is to make sure that the function is actually called. Just add
Display("save button clicked");
as the first line to that function.
When you say "the save button does this", do you mean you did enter btnSaveGame_OnClick into the button's on click event? Or did you just copy that function (which will have no effect)?
Seems to be working
[imgzoom]https://i.imgur.com/J6ce9vV.png[/imgzoom]
Well I copypasted it, but also I assigned it to the button in GUI option :)
Doesn't work tho :)
Guy, I actually managed to figure it out.
Wait, I didn't, but I have found this old module:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=38928.msg512373#msg512373 (https://www.adventuregamestudio.co.uk/forums/index.php?topic=38928.msg512373#msg512373)
And copypasted it into my game... and now it works :D
Thanks
It's strange tho - it shows screenshots for save
[imgzoom]https://i.imgur.com/qrPhKTA.png[/imgzoom]
but not for load
[imgzoom]https://i.imgur.com/c8QAaBY.png[/imgzoom]
The buttons are the same :/