Author Topic: Reading volume values [SOLVED]  (Read 768 times)  Share 

Ultra Magnus

  • Welcome to you're "Doom!"
Reading volume values [SOLVED]
« on: 09 Feb 2009, 15:26 »
Hello people.
I couldn't find the answer to this anywhere, so...

How can I get the game to read and store the user-set volume levels for music and sound?
Here's what I've got now...

After tooling around with the sliders, the player clicks either btnResume to save their changes and resume playing, or btnNoChange to discard the changes they made and go back to the last saved set of values.

[code]function btnResume_OnClick(GUIControl *control, MouseButton button)
{
  lastMsldval=sldMusic.Value;
  lastMlevel=
  lastSsldval=sldSound.Value;
  lastSlevel=
  lastGsldval=sldGamma.Value;
  lastGlevel=System.Gamma;
}

function btnNoChange_OnClick(GUIControl *control, MouseButton button)
{
  sldMusic.Value=lastMsldval;
  SetMusicMasterVolume(lastMlevel);
  sldSound.Value=lastSsldval;
  SetSoundVolume(lastSlevel);
  sldGamma.Value=lastGsldval;
  System.Gamma=lastGlevel;
}[/code]

What can I fill btnResume's gaps with?

Thanks in advance.
J.
« Last Edit: 10 Feb 2009, 07:46 by Ultra Magnus »
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Pumaman

  • Creator of AGS
  • Administrator
  • Mittens TRAITOR
  • I sense danger.
    • Lifetime Achievement Award Winner
    •  
Re: Reading volume values
« Reply #1 on: 10 Feb 2009, 00:31 »
Why have you got two variables for each thing, like lastMsldval and lastMlevel? What is each one supposed to represent?

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Reading volume values
« Reply #2 on: 10 Feb 2009, 03:47 »
Yes, one variable per setting is enough (if it weren't possible to cancel, you'd need no additional vars; adding this possibility adds the need for one additional variable per setting.)
I believe Ultra Magnus thought he'd need two because one can't read e.g. the current MusicMasterVolume.

Ultra Magnus:
Say the music volume is 70 at the start of the game. lastMlevel, sldMusic.Value and the game's MusicMasterVolume are all set to 70.
Now the player opens the settings GUI, then slides the slider to 80. This changes the actual volume to 80, so both sldMusic.Value and MusicMasterVolume are 80 now.

Resume:
-Set lastMlevel to sldMusic.Value
-exit

Cancel:
-Set sldMusic.Value and MusicMasterVolume to lastMlevel

So the functions are supposed to look like this:

[code]function btnResume_OnClick(GUIControl *control, MouseButton button)
{
  lastMlevel=sldMusic.Value;
  lastSlevel=sldSound.Value;
  lastGlevel=sldGamma.Value;
}

function btnNoChange_OnClick(GUIControl *control, MouseButton button)
{
  sldMusic.Value=lastMlevel;
  SetMusicMasterVolume(lastMlevel);
  sldSound.Value=lastSlevel;
  SetSoundVolume(lastSlevel);
  sldGamma.Value=lastGlevel;
  System.Gamma=lastGlevel;
}[/code]
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Ultra Magnus

  • Welcome to you're "Doom!"
Re: Reading volume values
« Reply #3 on: 10 Feb 2009, 07:46 »
The level variables were for the actual levels and the sldvals were the sliders' values (positions).
I had them both because at first I tried just this...

[code]function btnNoChange_OnClick(GUIControl *control, MouseButton button)
{
  sldMusic.Value=lastMlevel;
  sldSound.Value=lastSlevel;
  sldGamma.Value=lastGlevel;
}[/code]

...assuming the sliders were kinda hard-wired to the levels, so they'd change together.
When clicking it made the sliders move, but the levels stayed the same, I thought I'd need to set them both separately.

I wouldn't have thought that it would be possible to read from a variable that was only just set within the same function, but Khris' suggestion works perfectly.

Thanks a lot.
« Last Edit: 10 Feb 2009, 07:48 by Ultra Magnus »
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.