(SOLVED) help with text in save/load gui

Started by BlueAngel, Sat 11/06/2011 11:48:09

Previous topic - Next topic

BlueAngel

I trying to make a save/load gui in a blank game but I can’t get the save name to appear on the list.
I tried the wiki version and I tried copy the default one but I can’t get it to work. I tried searching here but the most versions are for older versions of AGS.
My version is 3.2.1.
This is my code


Code: ags

function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
    int totalSaves = lstSaveGames.ItemCount;//number of saves on list
  String saveName = txtSaveName.Text; //holds value of txtSaveName textbox
  //Check for a save name.If none tell them to enter one, else go on
  if(saveName=="")
  {
    Display("Please enter a name for your save.");
    return;
  }
  //if there is no saved games yet, just save it
  if(lstSaveGames.SelectedIndex ==-1)
  {
    gSaveGame.Visible=false;
    SaveGameSlot(totalSaves+1,  saveName);
  }
  else
  {
    int checkSave=0; //runs through the list and checks for double entries
    while (checkSave!=totalSaves)
    {
      if(saveName == lstSaveGames.Items[checkSave]) //one matches, so overwrite it.
      {
        //if so overwite the selscted game
        gSaveGame.Visible=false;
        SaveGameSlot(savegameindex[checkSave],saveName);
        return;
      }
      checkSave++;
    }
    //if we've made it here, there is no match so just save it to a new slot.
    if(totalSaves <20)
    {
      gSaveGame.Visible=false;
      SaveGameSlot(totalSaves+1,saveName);
    }
    else
    {
      Display("The maximum number of saved games has been reached; overwrite or delete some old ones.");
    }
}
}


Hope someone can help or I guess I have to start over i a default game.  :-[

barefoot

#1
Hi

After making your gui and putting in buttons for save and load:

Maybe you are looking to put in more than is generally required and I may be off course here but i use this with a new GUI with buttons coded:

Code: ags

show_save_game_dialog();


This brings up the Save box..

Its the same for the Load box:

Code: ags
show_restore_game_dialog();


As I said, maybe I'm off course in what you actually want to achieve. Possibly the bit about double entrys? Apart from that do you really need to override AGS Load / Save scripts?

barefoot



I May Not Be Perfect but I Have A Big Heart ..

BlueAngel

I have a save button on my main gui that brings up the save gui.
That is working, however it is coded:
Code: ags

function btn_save_OnClick(GUIControl *control, MouseButton button)
{
  gSaveGame.Visible=true;
  mouse.UseModeGraphic(eModeWait);
}


Do you think change it to "show dialog" would help with the text box?

barefoot

#3
It depends if your new GUI is visible all the time or if you make it visible at certain times..

Why would it have eModeWait? (baffling)


My code for this is:

Code: ags
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
  int gameSlotToSaveInto = lstSaveGamesList.ItemCount + 1;
  int i = 0;
  while (i < lstSaveGamesList.ItemCount)
  {
    if (lstSaveGamesList.Items[i] == txtNewSaveName.Text)
    {
      gameSlotToSaveInto = lstSaveGamesList.SaveGameSlots[i];
    }
    i++;
  }
  SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
  close_save_game_dialog();
}


Mmm.. perhaps elaborate a bit more..

I May Not Be Perfect but I Have A Big Heart ..

BlueAngel

I started with the same as you but that didnt work for me. Hmm maybe I have to start over.

barefoot

#5
Just create a new GUI with Buttons for save and Load (customise at will or just customise original )..

and script to new GUI buttons

Code: ags

show_save_game_dialog();


Code: ags

show_restore_game_dialog();


Code: ags

QuitGame(1);    // 0 or 1


Apart from that... it works for me...


I May Not Be Perfect but I Have A Big Heart ..

BlueAngel

Thanks for trying to help me. Its not really what I have problem with but I going to start again and try to find where I went wrong.
My problem is that the saves dont show in the text box.

barefoot

#7
Check that text colour is NOT the same as the GUI colour.

Perhaps make sure its text label has"Bring to front" so its above Gui

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris


BlueAngel

#9
Thanks barefoot, not a bad idea but not this time  :)
Thanks Khris, its working now.

barefoot

Glad you got there in the end.. and thanks Khris   :=
I May Not Be Perfect but I Have A Big Heart ..

monkey0506

I just want to point out that what you said about using "Bring to front" to make sure the label is above the GUI doesn't make any sense at all seeing as controls are always drawn on top of their owning GUI. The "Bring to front"/"send to back" options/functions apply to the ordering of the controls themselves.

SMF spam blocked by CleanTalk