Solved: intro blocks modal title screen GUI

Started by Cerno, Sun 14/04/2013 02:24:57

Previous topic - Next topic

Cerno

Hello.

A question about modal GUIs

I just added a title screen to my game. A simple GUI with two buttons, one of which will simply switch the GUI off, effectively starting the game.
Since the game starts with a scripted sequence, I have chosen the "pause game when shown" option for the GUI.
Now the problem is that apparently the blocking actions in the intro script cause the mouse pointer to be disabled. I know that this is standard behavior for a blocking action.

What I don't understand is why apparently the modal GUI does not stop the game, which causes the intro script to start, which in turn disables the mouse.
If I comment the intro script out so that the game gives control to the player right after the GUI closes, everything works as it should.

Some code to illustrate what I do:

Code: AGS

  //GlobalScript.asc in game_start()
  gTitleScreen.Visible = true; //modal dialog screen on, should pause everything until START button is clicked.

  //GlobalScript.asc, handling the start button press
  function NewGameButton_OnClick(GUIControl *control, MouseButton button)
  {
    FadeOut(5);
    gTitleScreen.Visible = false;
    Wait(30);
    FadeIn(1);
  }

  //in the starting room's room_AfterFadeIn
  Wait(100);
  oDoorOpen.Visible = true;
  Wait(30);
  player.x = 580;
  player.y = 430;
  cOther.Animate(0, 5, eOnce, eNoBlock, eForwards);
  Wait(20);
  player.Walk(450, 470, eBlock);
  player.FaceCharacter(cOther);


And so on.

What am I missing? Does the modal GUI not block the blocking actions after all?
123  Currently working on: Sibun - Shadow of the Septemplicon

Andail

QuoteNOTE: When the game is paused, game cycles will continue to run but no animations or movement will be performed, and timers will not count down. Apart from that, your scripts will continue to run as normal.

I'm no expert when it comes to GUI modality, but the room will likely finish fading in, and the Wait commands will probably run as normal.
Why not let the game start in an empty room, with the title screen GUI visible, place the character out of sight and just teleport him to the "real" starting room? I think having the intro screen pop up in the global game_start is not the ideal solution.
But I can't provide more technical expertise right now.

Cerno

#2
That did the trick, thanks a lot.

I added an empty room in which the game starts (hiding the character out of sight is not necessary since the title screen fills the whole screen and overlays everything, also the character).
Pressing the start button then triggers the room change upon which the intro sequence runs.

This has the added benefit that I now have a multi-purpose empty room to send any characters I want to vanish without having to take care about them popping up somewhere they should not be.

The implementation is straightforward:
Code: AGS

//new empty room
  function room_Load()
  {
    gTitleScreen.Visible = true;
  }

  //GlobalScript.asc, handling the start button press
  function NewGameButton_OnClick(GUIControl *control, MouseButton button)
  {
    FadeOut(5);
    gTitleScreen.Visible = false;
    player.ChangeRoom(4);
  }

  //the old starting room's room_AfterFadeIn implemented like above
123  Currently working on: Sibun - Shadow of the Septemplicon

Slasher

#3
You appeared to be trying to over complicate things.

It's the sort of trap many fall into (myself included.)  (laugh)

If it's sorted then that's great  8-)

Edit: in answer to your below message:
QuoteIt did not work.




Cerno

Actually I think my original solution was less complicated, but unfortunately it didn't work  :P
123  Currently working on: Sibun - Shadow of the Septemplicon

Khris

1) You could have started the intro after the "new game" button click.

Something like this in room_RepExec
Code: ags
  if (gMenu.Visible == false && GameDoOnceOnly("roll intro")) intro();


2) You can send characters to room -1 to remove them from the game.

Cerno

Sweet, that's prettier indeed. It will also make my custom fade in more robust (see http://www.adventuregamestudio.co.uk/forums/index.php?topic=48015.new;topicseen#new)

The current implementation works, so this change is not urgent but I'll definitely check your way out, thanks.
123  Currently working on: Sibun - Shadow of the Septemplicon

Cerno

Khris, I implemented your suggestion after the other one somehow caused my Inventory to not show up anymore (for whatever reason, logically it should not do that I think).
Anyway, it works now, gives me better control over the initial fade in and I save an additional room. ;)
123  Currently working on: Sibun - Shadow of the Septemplicon

SMF spam blocked by CleanTalk