DMenu:Paint() and CSoundPatch:SetSoundLevel()

Hey guys,

First question, is there a way I can change the colour of the text in a DMenu’s items? Or if anyone could provide all the stuff in a DMenu that Paint() can be applied to, that would be even better.

Second question, why does CSoundPatch:SetSoundLevel() not work? I have a sound made by CreateSound() and when I change sound:SetSoundLevel() to like 50 or something, the volume doesn’t change at all. When it’s set to 0 though, the song just stops. Was it broken by garry or what?

Thanks for any help.

I think you have to restart the sound to change the volume!

No, restarting the sound does not change the volume. Niether does setting the volume before playing the sound.

You’re probably trying to increase the volume of the sound with SetSoundLevel, which from what I understand is not the purpose of the function. For most sounds in Gmod, the “volume” is just how far the sound reaches; i.e. a volume of 50 is heard by people farther away from the origin of the sound than with a volume of 20.

edit Look at this: http://developer.valvesoftware.com/wiki/Soundscripts#SoundLevel_Flags

Ah, that makes sense.

EDIT: Success!

The wiki lacks a page for CSoundPatch:ChangeVolume() so I didn’t even try to use it. However, it worked.

Actually I did try to use it before. I use a DNumberWang for people to change the volume of a sound. However, the Dnumwang goes from 1 - 100, and you must use a number between 0 and 1 on ChangeVolume. So I just divide the value of the dnumwang by 100 and there we go! Thanks guys. Looking at that link you posted entoros let me see that they were using numbers from 0 - 1 in their stuff.

But my other question still stands: What else can you apply Paint() to in a DMenu, besides the DMenu itself? Like can you do it to each of it’s items so their text color is changed?

Try painting over each DMenuOption.

How? Using blah = Menu:AddOption() returns a boolean, not the object.

Oh, really? I was hoping it did. And the wiki doesn’t provide any helpful menu:GetOptions().

Another thing you could try that I haven’t personally experimented with is the menu:PaintOver() function, and see if you could apply it to the options.

OR

Instead of using AddOption, you could try using the AddPanel function, and add either a DLabel or a DPanel with a paint override using draw.DrawText.