[SOLVED] GUI sounds coming through when MouseUp

Started by subspark, Mon 27/09/2010 12:42:56

Previous topic - Next topic

subspark

Hey guys, I have this annoying issue with button sounds and GUIS.

First off, I have a gMainMenu which comprises of a series of buttons that show up in room 2 (the menu screen).
Now I have this check for the speech.vox file like so:
Code: ags
if ((IsSpeechVoxAvailable() == 0) {
//show warning gui
}


I have set up the message so that you click the mouse down to hide it.

Now my big issue:
The problem is that if you click down to hide gMessage GUI where the gMainMenu lies behind, when you release again, the mouseUp sounds linked to the buttons on gMainMenu play.
I still want all the hilighting going on with these buttons when the mouse is still down after clicking away gMessage but I just want to avoid their mouseUp sounds in this one case.

In Repeatedly_Execute_Always in Global Script:
Code: ags
  if (gMessage.Visible == true) // If the message window is visible
  {
    if ((mouse.IsButtonDown(eMouseLeft) == true) || (IsKeyPressed(eKeyEscape) == true)) // If the player hits escape or left clicks mouse
    {
      if (lblMessage.Text == "The game's ~Speech Pack~ is MISSING! Subtitles have been ~enabled~.") // If the message is about a missing speech pack
      {
        dlgOption=2;
        lDialogOptions.Text="Subtitles Only";
        SubtitleSpeedLabel.TextColor=48429;
        bSubtitleSpeed.Enabled=true;
        lDialogOptions.Text="Subtitles Only";
        bSubtitleSpeed.NormalGraphic=865;
        SetVoiceMode(eSpeechTextOnly);
      }
      else // If the message is about something else
      {
      // do somthing different
      }
      // Disable The Message
      lblMessage.Text = "NULL";
      lblMessageShadow.Text = lblMessage.Text;
      // Re-Enable Menu Buttons
      if (IsLoadFrozen()) UnfreezeLoadGame();
      if (IsSaveFrozen()) UnfreezeSaveGame();
      if (IsMenuFrozen()) UnfreezeMainMenu();
      gMessage.Visible = false;               // close the message box and
      gDarken.Visible = false;
      lblMessage.Text = "NULL";
      lblMessageShadow.Text = "NULL";
      UnfreezeMainMenu();  // re-enable all buttons in  gMainMenu
    }
    // otherwise re-enable clicking in the main menu
    else {}
  }


Any help would be kindly appreciated. Also if you need any more code to try and figure out what some of the functions are doing, please let me know and I will supply it.

Cheers,
Sparky. ;D

Wonkyth

You could cheat, and stick in a function level bool to track whether the button has been clicked that frame, and check it before making the sound.
Assuming I understand the problem...
"But with a ninja on your face, you live longer!"

tzachs

I don't see in this code the segment that plays the mouseUp sound.
Did you link it in the designer somehow or is it in code?
If you linked it in the designer, then consider scripting it manually, then you will be able to control when to play the sound and when not to.

When it's in code, you can use a boolean to tell whether to play the sound. In the code you published, when showing the error message, put the boolean to false if the user pressed the mouse (and not used the escape key).
In the code that plays the sound, if the boolean is false then don't set the sound and set the boolean to true so that it will play the sound on the next time. It's a bit messy, but should work.

subspark


SMF spam blocked by CleanTalk