Title Screen [SOLVED]

Started by Jleger91, Wed 09/04/2025 16:27:17

Previous topic - Next topic

Jleger91

I have a room for title screen; the NEW GAME option leads to the next room which is good  :=

The LOAD GAME option only has
Code: ags
gRestoreGame.Visible = true;
which brings up an empty load game menu despite there being saved games. However if I press ESC and the LOAD GAME option then the saved games come up. How do I get saved games to come up from my title screen when I select LOAD GAME?  :confused:

Also, I can still access inventory from title screen. How do I temporarily disable inventory? In other words - disable the use of the ESC key?  :confused:

Jleger91

#1
Got it!! Used this code:
Code: ags
lstRestoreGamesList.FillSaveGameList();
gRestoreGame.Visible = true;
Now the save game appears in the load dialog. Next I need to disable the ESC key

I got that to work too!! In GlobalScript.asc where it says "if (keycode == eKeyEscape)", I put:
Code: ags
if (keycode == eKeyEscape && passedTitleScreen == true)
When I want to enable the ESC key, I set passedTitleScreen to true


Crimson Wizard

If you have a separate room for the title screen, then you may instead test for the current room. The current room is the one where "player" character is:

Code: ags
if (keycode == eKeyEscape && player.Room != NUMBER_OF_TITLE_SCREEN_ROOM)

Khris

Please always mention which game template you've used, that makes questions like this easier to answer.

My guess is you're using the Sierra template, and clicking one of the two load game buttons on the GUIs will ultimately call this function:
Code: ags
function show_restore_game_dialog()
{
  lstRestoreGamesList.FillSaveGameList();
  open_gui(gRestoreGame);
}

Your room hotspot/object should also call this function. Calling a custom global function from a room script requires importing it; this can be achieved by adding this line to the Global Script's header:

Code: ags
import function show_restore_game_dialog();

Now you can use this line in your room script:
Code: ags
  show_restore_game_dialog();

To disable a key in a specific room, you can also intercept the key press event. Add this to the room script:

Code: ags
function on_key_press(eKeyCode keycode, int mod)
{
  // disable global Escape handling
  if (keycode == eKeyEscape)
  {
    ClaimEvent(); // stop AGS from calling any global on_key_press functions
  }
}

--

It might not be obvious why doing all of this is preferable, so I'll briefly explain:

Should you ever have to adjust the code that prepares and displays the load game GUI, you can still do it in a single place and won't have to worry about remembering all the various places in your scripts where you might have put a bunch of identical lines.

Disabling the key is done completely locally, and the global script remains untouched. This is always preferable for room-specific code, because again, any future changes will not affect any other rooms or global behavior unintentionally.

SMF spam blocked by CleanTalk