Added speech/music/sfx volume sliders to setup menu and .cfg file

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2096 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2005-12-21 08:05:09 +00:00
parent c3942d5395
commit 1659928b5d
7 changed files with 164 additions and 5 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.5:
- Added slider controls for volume to setup menu - Michael
- Added --shield and --scaler hq to setup menu - Michael
- Fixed lockup when skipping past VUX beast analysis data in Starbase
(bug #790; should take care of all spliced comm edge cases) - Alex
+1 -1
View File
@@ -131,7 +131,7 @@ LINK32=link.exe
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /D "USE_PLATFORM_ACCEL" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FD /c
# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "." /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /I "..\regex" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "HAVE_OPENAL" /D "HAVE_ZIP" /D "ZLIB_DLL" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
+92 -1
View File
@@ -264,6 +264,77 @@ Widget_DrawLabel (WIDGET *_self, int x, int y)
(void) x;
}
void
Widget_DrawSlider(WIDGET *_self, int x, int y)
{
WIDGET_SLIDER *self = (WIDGET_SLIDER *)_self;
COLOR oldtext;
COLOR inactive, default_color, selected;
FONT oldfont = SetContextFont (StarConFont);
FRAME oldFontEffect = SetContextFontEffect (NULL);
TEXT t;
RECT r;
int tick = (SCREEN_WIDTH - x) / 8;
default_color = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F);
selected = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x00), 0x0E);
inactive = BUILD_COLOR (MAKE_RGB15 (0x18, 0x18, 0x1F), 0x07);
t.baseline.x = x;
t.baseline.y = y;
t.align = ALIGN_LEFT;
t.valign = VALIGN_BOTTOM;
t.CharCount = ~0;
t.pStr = self->category;
if (widget_focus == _self)
{
Widget_DrawToolTips (3, self->tooltip);
oldtext = SetContextForeGroundColor (selected);
}
else
{
oldtext = SetContextForeGroundColor (default_color);
}
font_DrawText (&t);
r.corner.x = t.baseline.x + 3 * tick;
r.corner.y = t.baseline.y - 4;
r.extent.height = 2;
r.extent.width = 3 * tick;
DrawFilledRectangle (&r);
r.extent.width = 3;
r.extent.height = 8;
r.corner.y = t.baseline.y - 7;
r.corner.x = t.baseline.x + 3 * tick + (3 * tick * (self->value - self->min) /
(self->max - self->min)) - 1;
DrawFilledRectangle (&r);
(*self->draw_value)(self, t.baseline.x + 7 * tick, t.baseline.y);
SetContextFontEffect (oldFontEffect);
SetContextFont (oldfont);
SetContextForeGroundColor (oldtext);
}
void
Widget_Slider_DrawValue (WIDGET_SLIDER *self, int x, int y)
{
TEXT t;
char buffer[16];
sprintf (buffer, "%d", self->value);
t.baseline.x = x;
t.baseline.y = y;
t.align = ALIGN_CENTER;
t.valign = VALIGN_BOTTOM;
t.CharCount = ~0;
t.pStr = buffer;
font_DrawText (&t);
}
int
Widget_HeightChoice (WIDGET *_self)
{
@@ -299,7 +370,7 @@ Widget_WidthFullScreen (WIDGET *_self)
}
int
Widget_ReceiveFocusButton (WIDGET *_self, int event)
Widget_ReceiveFocusSimple (WIDGET *_self, int event)
{
widget_focus = _self;
(void)event;
@@ -389,6 +460,26 @@ Widget_HandleEventChoice (WIDGET *_self, int event)
}
}
int
Widget_HandleEventSlider (WIDGET *_self, int event)
{
WIDGET_SLIDER *self = (WIDGET_SLIDER *)_self;
switch (event)
{
case WIDGET_EVENT_LEFT:
self->value -= self->step;
if (self->value < self->min)
self->value = self->min;
return TRUE;
case WIDGET_EVENT_RIGHT:
self->value += self->step;
if (self->value > self->max)
self->value = self->max;
return TRUE;
default:
return FALSE;
}
}
int
Widget_HandleEventMenuScreen (WIDGET *_self, int event)
+26 -2
View File
@@ -96,6 +96,20 @@ typedef struct _widget_label {
const char **lines;
} WIDGET_LABEL;
typedef struct _widget_slider {
struct _widget *parent;
int (*handleEvent)(struct _widget *self, int event);
int (*receiveFocus)(struct _widget *self, int event);
void (*draw)(struct _widget *self, int x, int y);
int (*height)(struct _widget *self);
int (*width)(struct _widget *self);
void (*draw_value)(struct _widget_slider *self, int x, int y);
int min, max, step;
int value;
const char *category;
const char *tooltip[3];
} WIDGET_SLIDER;
void DrawShadowedBox (PRECT r, COLOR bg, COLOR dark, COLOR medium);
int Widget_Event (int event);
@@ -104,11 +118,13 @@ int Widget_Event (int event);
int Widget_ReceiveFocusMenuScreen (WIDGET *_self, int event);
int Widget_ReceiveFocusChoice (WIDGET *_self, int event);
int Widget_ReceiveFocusButton (WIDGET *_self, int event);
int Widget_ReceiveFocusSimple (WIDGET *_self, int event);
int Widget_ReceiveFocusSlider (WIDGET *_self, int event);
int Widget_ReceiveFocusRefuseFocus (WIDGET *_self, int event);
int Widget_HandleEventMenuScreen (WIDGET *_self, int event);
int Widget_HandleEventChoice (WIDGET *_self, int event);
int Widget_HandleEventSlider (WIDGET *_self, int event);
int Widget_HandleEventIgnoreAll (WIDGET *_self, int event);
int Widget_HeightChoice (WIDGET *_self);
@@ -122,11 +138,14 @@ void Widget_DrawMenuScreen (WIDGET *_self, int x, int y);
void Widget_DrawChoice (WIDGET *_self, int x, int y);
void Widget_DrawButton (WIDGET *_self, int x, int y);
void Widget_DrawLabel (WIDGET *_self, int x, int y);
void Widget_DrawSlider (WIDGET *_self, int x, int y);
void Widget_Slider_DrawValue (WIDGET_SLIDER *self, int x, int y);
/* "Constructor" macros */
#define BUTTON_INIT(handler, name, ttip1, ttip2, ttip3) { \
NULL, handler, Widget_ReceiveFocusButton, Widget_DrawButton, \
NULL, handler, Widget_ReceiveFocusSimple, Widget_DrawButton, \
Widget_HeightOneLine, Widget_WidthFullScreen, \
(name), { (ttip1), (ttip2), (ttip3) } }
@@ -143,4 +162,9 @@ void Widget_DrawLabel (WIDGET *_self, int x, int y);
Widget_DrawMenuScreen, Widget_HeightFullScreen, \
Widget_WidthFullScreen
#define SLIDER_PREFACE NULL, Widget_HandleEventSlider, \
Widget_ReceiveFocusSimple, Widget_DrawSlider, \
Widget_HeightOneLine, Widget_WidthFullScreen, \
Widget_Slider_DrawValue
#endif /* _WIDGETS_H */
+28 -1
View File
@@ -329,6 +329,12 @@ static WIDGET_CHOICE cmdline_opts[] = {
{ CHOICE_PREFACE, "Sound Quality", 3, 3, aquality_opts, 0, 0 },
{ CHOICE_PREFACE, "Slave Shields", 2, 2, shield_opts, 0, 0 } };
static WIDGET_SLIDER sliders_opts[] = {
{ SLIDER_PREFACE, 0, 100, 5, 75, "Music Volume", { "Sets the music volume.", "", "" } },
{ SLIDER_PREFACE, 0, 100, 5, 75, "SFX Volume", { "Sets the sound effects volume.", "", "" } },
{ SLIDER_PREFACE, 0, 100, 5, 75, "Speech Volume", { "Sets the speech volume.", "", "" } },
};
static WIDGET_BUTTON quit_button = BUTTON_INIT (quit_main_menu,
"Quit Setup Menu",
"Return to the main menu.", "", "");
@@ -386,6 +392,9 @@ static WIDGET *graphics_widgets[] = {
(WIDGET *)(&prev_button) };
static WIDGET *audio_widgets[] = {
(WIDGET *)(&sliders_opts[0]),
(WIDGET *)(&sliders_opts[1]),
(WIDGET *)(&sliders_opts[2]),
(WIDGET *)(&cmdline_opts[15]),
(WIDGET *)(&cmdline_opts[10]),
(WIDGET *)(&prev_button) };
@@ -437,7 +446,7 @@ static WIDGET_MENU_SCREEN audio_menu = {
"Ur-Quan Masters Setup",
"Audio Options",
{ {0, 0}, NULL },
3, audio_widgets,
6, audio_widgets,
0 };
static WIDGET_MENU_SCREEN engine_menu = {
@@ -610,6 +619,10 @@ SetDefaults (void)
cmdline_opts[16].selected = opts.adriver;
cmdline_opts[17].selected = opts.aquality;
cmdline_opts[18].selected = opts.shield;
sliders_opts[0].value = opts.musicvol;
sliders_opts[1].value = opts.sfxvol;
sliders_opts[2].value = opts.speechvol;
}
static void
@@ -636,6 +649,9 @@ PropagateResults (void)
opts.aquality = cmdline_opts[17].selected;
opts.shield = cmdline_opts[18].selected;
opts.musicvol = sliders_opts[0].value;
opts.sfxvol = sliders_opts[1].value;
opts.speechvol = sliders_opts[2].value;
SetGlobalOptions (&opts);
}
@@ -888,6 +904,10 @@ GetGlobalOptions (GLOBALOPTS *opts)
opts->res = OPTVAL_CUSTOM;
break;
}
opts->musicvol = (((int)(musicVolumeScale * 100.0f) + 2) / 5) * 5;
opts->sfxvol = (((int)(sfxVolumeScale * 100.0f) + 2) / 5) * 5;
opts->speechvol = (((int)(speechVolumeScale * 100.0f) + 2) / 5) * 5;
}
void
@@ -1056,5 +1076,12 @@ SetGlobalOptions (GLOBALOPTS *opts)
break;
}
res_PutInteger ("config.musicvol", opts->musicvol);
res_PutInteger ("config.sfxvol", opts->sfxvol);
res_PutInteger ("config.speechvol", opts->speechvol);
musicVolumeScale = opts->musicvol / 100.0f;
sfxVolumeScale = opts->sfxvol / 100.0f;
speechVolumeScale = opts->speechvol / 100.0f;
res_SaveFilename (configDir, "uqm.cfg", "config.");
}
+1
View File
@@ -78,6 +78,7 @@ typedef struct globalopts_struct {
OPT_DEPTH depth;
OPT_ENABLABLE fullscreen, subtitles, scanlines, fps, stereo;
OPT_CONSOLETYPE music, menu, text, cscan, scroll, intro, meleezoom, shield;
int speechvol, musicvol, sfxvol;
} GLOBALOPTS;
void SetupMenu (void);
+15
View File
@@ -308,6 +308,21 @@ main (int argc, char *argv[])
{
options.whichShield = res_GetBoolean ("config.pulseshield") ? OPT_3DO : OPT_PC;
}
if (res_HasKey ("config.musicvol"))
{
int err = parseVolume(res_GetString ("config.musicvol"),
&options.musicVolumeScale, "music volume");
}
if (res_HasKey ("config.sfxvol"))
{
int err = parseVolume(res_GetString ("config.sfxvol"),
&options.sfxVolumeScale, "SFX volume");
}
if (res_HasKey ("config.speechvol"))
{
int err = parseVolume(res_GetString ("config.speechvol"),
&options.speechVolumeScale, "speech volume");
}
optionsResult = parseOptions(argc, argv, &options);
if (optionsResult != 0)