Audio Volume & Game Speed Slider

Started by Arjunaz78, Sun 05/02/2012 14:45:00

Previous topic - Next topic

Arjunaz78

I've create a room that actually a GUI room on my game start menu.
The menu including the 'setting' sub menu that represent,
the audio & game speed option (gSetting),
and for that 'setting' menu i set a custom gui that include
audio & game speed slider.

Unfortunately when i start the game on the very first room,
when i hit the tab that showing the default gPanel gui,
the audio & game speed slider on gPanel
not match the alternate audio & game speed custom gui
that i make at the game start menu.

In other word, the setting i make at the game start menu,
not save automatically,
because the audio & game speed slider
reset to max value (100) itself on gPanel (although i setup the slider
setup value on 50 at gui properties option)
at the first room when the game start.

below is the script that i use for custom
audio & game speed option menu

Code: ags
 
function SliderAV_OnChange(GUIControl *control)
{
 System.Volume = SliderAV.Value;
}

function SliderGS_OnChange(GUIControl *control)
{
 SetGameSpeed(sldSpeed.Value);
}

function ButtonCS_OnClick(GUIControl *control, MouseButton button)
{
 gSetting.Visible = false;
  ButtonNGM.Enabled = true;   // other menu on gui start menu
  ButtonLGM.Enabled = true;   // other menu on gui start menu
 ButtonEXT.Enabled = true;    // other menu on gui start menu
}


note:  SliderAV are the Audio slider option,
           SliderGS for Game Speed slider option,
           ButtonCS is a confirm setting button (OK button)
         

then below is the default Audio & Game Speed option on gPanel
(default setting on AGS Editor)

Code: ags


function sldAudio_OnChange(GUIControl *control)
{
  System.Volume = sldAudio.Value;
}

function sldSpeed_OnChange(GUIControl *control)
{
  SetGameSpeed(sldSpeed.Value);
}


That i miss something or i do a strange scripting?
besides i don't want to set a value on audio & game speed,
what i want is, the player can setup freely on audio & game speed
without a certain value at the game menu option & then the current setting
continues when the game start on first room,
without need to change/setting back the option.

p/s: sorry for my bad English.

THX.
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Khris

It's simply really.
Before showing the GUI, set the sliders to the actual values.

Just this should be enough:

Code: ags
  SliderAV.Value = System.Volume;
  sldSpeed.Value = GetGameSpeed();


Do this for both GUIs and everything should work fine.

Arjunaz78

THX mate..

Beside i've to put a couple of script at the 4 different GUIs and finally it's work perfectly although it's conflict with the default Audio Volume & Game Speed sliders on gPanel gui at the first, then i decide to delete it and replace that with the same custom Audio Volume & Game speed slider (SliderAV & SliderGS gui) graphic & script code.

Well it's very confusing but it's finally works nicely, one more thing..can i use a gamma slider setting/option, together with my custom gui too (gSetting) or it's automatically set on default by AGS editor?
..In the making of Silent Hill: The Hospital..

https://www.facebook.com/ArjunazGamesStudio

Ghost

#3
Quote from: Arjunaz78 on Wed 08/02/2012 05:14:11
can i use a gamma slider setting/option, together with my custom gui too (gSetting) or it's automatically set on default by AGS editor?

Gamma works only in fullscreen mode, in windowed mode the value is automatically set to 100. A standard way is to check in game_start if gamma CAN be set, and if not, make the slider invisible:

if (System.SupportsGammaControl)
  sldGamma.Visible = false;
else
  sldGamma.Value = System.Gamma;

Apart from that, such a slider would work like your volume sliders, with a possible minimum of 0 and a maximum of 200.

SMF spam blocked by CleanTalk