Page 1 of 2

Simple widget to control sound level

Posted: 09 Jan 2012, 14:20
by Jools
I made this simple widget that acts as an on-screen display to control the sound level. Sorry if there already existed one.

It works just like with the television remote: you press alt-numpad+ to increase sound and alt-numpad- to decrease it. It fades away after 3 seconds to let you concentrate on more important things.

Screenie:

Image

Download it here:

http://springfiles.com/spring/lua-scripts/volume-osd

Re: Simple widget to control sound level

Posted: 09 Jan 2012, 23:24
by Forboding Angel
Well, chili has it built in via epicmenu, but this is quite nice still

Re: Simple widget to control sound level

Posted: 09 Jan 2012, 23:52
by smoth
neat! keep up the good work jools

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 15:32
by Jools
Yeah, I know there were other widgets to do that. I used one called snd_volume by trepan to achieve the same thing. But I didn't want to access a menu or to enable/disable a widget just for such a simple thing.

You don't do that when watching TV either.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 18:57
by knorke
does what it says and seems to work. :-)
Finally a way to controll volume without console commands or clicking around in chili menus.

Though what I don't like is when widgets include files such as sounds, images and after a while your sounds\ and images\ folders are cluttered with generic named files like "pop.wav" etc.

Should adjust to rescaling the window.

Never fades away when game is paused because you use frames for dt.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 19:29
by jamerlan
NICE!!!

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 20:12
by Jools
Yeah, I know. I made it really quickly, and those would be my first improvements.

Adjusting to resolution is easy to fix. But how to get the current real world time? This command?

Code: Select all

Spring.GetTimer
It's undocumented.

I could put that sound in a sub folder with widget name, but I use that sound also in other widgets.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 20:24
by knorke
try widget:Update (dt)
I could put that sound in a sub folder with widget name, but I use that sound also in other widgets.
even worse, when I want to delete the volume widget, remove pop.wav and accidently break other widgets...

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 21:19
by CarRepairer
There is no clicking around in chili menus. The volume and music sliders are always present. Don't be a liar.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 21:39
by knorke
chili menu is controlled by clicking around on things.
jools widget works by mashing keyboard buttons.
dont misunderstand everything.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 21:41
by zwzsg
Jools wrote:

Code: Select all

Spring.GetTimer
It's undocumented.
You use Spring.GetTimer()
It returns you a special object that is the time of when it was run

You use it again, you get the time of another moment.

You then use Spring.DiffTimers to get the number of seconds between the two timers.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 21:57
by very_bad_soldier
Cool stuff Jools, keep it up!

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 22:04
by Pxtl
Alt-numpad?

Seriously, it should be +/-. As for the "set gamespeed" thing? *that* crap can live in the damned menus hidden away from casual usage.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 23:29
by Jools
Yeah, well I use the + and - on numpad to set game speed. I started using those buttons, because the other + and - changes place depending on if you have a swiss or german or scandinavian keyboard. It's a mess.

Isn't it enough if user can customise that key within the widget? They are right in the beginning as variables.

Re: Simple widget to control sound level

Posted: 10 Jan 2012, 23:34
by Jools
knorke wrote: even worse, when I want to delete the volume widget, remove pop.wav and accidently break other widgets...
Oops. The sound is not really vital, I guess it should have a presence-check before it is being played.

Re: Simple widget to control sound level

Posted: 11 Jan 2012, 03:18
by CarRepairer
knorke wrote:chili menu is controlled by clicking around on things.
jools widget works by mashing keyboard buttons.
dont misunderstand everything.
You both used the word menu. I was setting the record straight.

Re: Simple widget to control sound level

Posted: 11 Jan 2012, 08:01
by Jools
I tried chili (menu) and it also works well. You press esc and then cotnrol the volume with mouse. That also works.

If you install this widget then you have one additional way of controlling the sound :)

Re: Simple widget to control sound level

Posted: 11 Jan 2012, 08:50
by Google_Frog
Unless the volume control in chili can be bound to a hotkey. I'm not sure if it can be but now I've said it Car cannot resist adding the functionality.

Re: Simple widget to control sound level

Posted: 08 Feb 2012, 19:43
by Jools
Updated to version 1.1. Changes:

– Fade speed not dependant on game speed
– resizes to window size
– added lots of options, look in the file to set them (such as colour, display times and size, keys)

Instructions:

The currently working (default) keys are:

– Alt and Numpad+ to increase sound level.
– Alt and Numpad– to decrease sound level.

and additionally in version 1.1:

– Alt and + to increase sound level.
– Alt and – to decrease sound level.

Also you can move the widget by entering tweak mode (press Ctrl - F11)

http://springfiles.com/spring/lua-scripts/volume-osd

Bugs:

The plus key doesn't work on my keyboard. It's either because of the fact that the widget also requires the alt key to be pressed, and when pressing alt it also changes the function on the + key, or because my keyboard is scandinavian.

Anyway, the keys are configurable within the widget: there are two keys labelled as plus- and minuskeys. Set them to what you like (or set them to be same key to disable the secondary key).

Keysymbols can be found in uikeys.txt in spring folder. Would there be an easier way to have the settings configurable? Do people like to mess in their widget files?

Re: Simple widget to control sound level

Posted: 08 Feb 2012, 19:57
by Jools
It looks like this with red colour:

Image