Simple widget to control sound level

Simple widget to control sound level

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderators: Moderators, Moderators

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Simple widget to control sound level

Post 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
0 x

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14625
Joined: 17 Nov 2005, 02:43

Re: Simple widget to control sound level

Post by Forboding Angel »

Well, chili has it built in via epicmenu, but this is quite nice still
0 x

User avatar
smoth
Posts: 22300
Joined: 13 Jan 2005, 00:46

Re: Simple widget to control sound level

Post by smoth »

neat! keep up the good work jools
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
jamerlan
Balanced Annihilation Developer
Posts: 683
Joined: 20 Oct 2009, 13:04

Re: Simple widget to control sound level

Post by jamerlan »

NICE!!!
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Simple widget to control sound level

Post 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...
0 x

User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Simple widget to control sound level

Post by CarRepairer »

There is no clicking around in chili menus. The volume and music sliders are always present. Don't be a liar.
0 x

User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Simple widget to control sound level

Post by knorke »

chili menu is controlled by clicking around on things.
jools widget works by mashing keyboard buttons.
dont misunderstand everything.
0 x

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7019
Joined: 16 Nov 2004, 13:08

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
very_bad_soldier
Posts: 1371
Joined: 20 Feb 2007, 01:10

Re: Simple widget to control sound level

Post by very_bad_soldier »

Cool stuff Jools, keep it up!
0 x

User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post 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 :)
0 x

Google_Frog
Moderator
Posts: 2445
Joined: 12 Oct 2007, 09:24

Re: Simple widget to control sound level

Post 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.
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post 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?
Last edited by Jools on 08 Feb 2012, 20:03, edited 1 time in total.
0 x

User avatar
Jools
XTA Developer
Posts: 2806
Joined: 23 Feb 2009, 16:29

Re: Simple widget to control sound level

Post by Jools »

It looks like this with red colour:

Image
0 x

Post Reply

Return to “Lua Scripts”