tUseSounds config variable added to enable/disable sounds; menu option added to GUI client to do this on a game-by-game basis. - vaccinewars - be a doctor and try to vaccinate the world
(HTM) git clone git://src.adamsgaard.dk/vaccinewars
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 254694f8f33ecf467a2b787e2e97eca6d995c506
(DIR) parent 6dc3d3791bec78ddd09166683de5148437cc2a23
(HTM) Author: Ben Webb <ben@salilab.org>
Date: Fri, 16 Aug 2002 18:14:42 +0000
UseSounds config variable added to enable/disable sounds; menu option added
tto GUI client to do this on a game-by-game basis.
Diffstat:
M src/curses_client/curses_client.c | 1 +
M src/dopewars.c | 5 ++++-
M src/dopewars.h | 2 +-
M src/gui_client/gtk_client.c | 22 +++++++++++++++++++++-
4 files changed, 27 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/src/curses_client/curses_client.c b/src/curses_client/curses_client.c
t@@ -2448,6 +2448,7 @@ void CursesLoop(struct CMDLINE *cmdline)
LogMessage, NULL);
SoundOpen(cmdline->plugin);
+ SoundEnable(UseSounds);
display_intro();
(DIR) diff --git a/src/dopewars.c b/src/dopewars.c
t@@ -68,7 +68,7 @@
#endif
int ClientSock, ListenSock;
-gboolean Network, Client, Server, WantAntique = FALSE;
+gboolean Network, Client, Server, WantAntique = FALSE, UseSounds = TRUE;
/*
* dopewars acting as standalone TCP server:
t@@ -397,6 +397,9 @@ struct GLOBALS Globals[] = {
N_("Name of the gun shop"), NULL, NULL, 0, "", NULL, NULL, FALSE, 0},
{NULL, NULL, NULL, &Names.RoughPubName, NULL, "RoughPubName",
N_("Name of the pub"), NULL, NULL, 0, "", NULL, NULL, FALSE, 0},
+ {NULL, &UseSounds, NULL, NULL, NULL, "UseSounds",
+ N_("TRUE if sounds should be enabled"),
+ NULL, NULL, 0, "", NULL, NULL, FALSE, 0},
{NULL, NULL, NULL, &Sounds.FightHit, NULL, "Sounds.FightHit",
N_("Sound file played for a gun \"hit\""), NULL, NULL, 0, "",
NULL, NULL, FALSE, 0},
(DIR) diff --git a/src/dopewars.h b/src/dopewars.h
t@@ -174,7 +174,7 @@ struct DATE {
extern gboolean WantAntique;
extern struct DATE StartDate;
extern int ClientSock, ListenSock;
-extern gboolean Network, Client, Server;
+extern gboolean Network, Client, Server, UseSounds;
extern unsigned Port;
extern gboolean Sanitized, ConfigVerbose, DrugValue;
extern int NumLocation, NumGun, NumCop, NumDrug, NumSubway, NumPlaying,
(DIR) diff --git a/src/gui_client/gtk_client.c b/src/gui_client/gtk_client.c
t@@ -97,6 +97,7 @@ static void QuitGame(GtkWidget *widget, gpointer data);
static void DestroyGtk(GtkWidget *widget, gpointer data);
static void NewGame(GtkWidget *widget, gpointer data);
static void AbandonGame(GtkWidget *widget, gpointer data);
+static void ToggleSound(GtkWidget *widget, gpointer data);
static void ListScores(GtkWidget *widget, gpointer data);
static void ListInventory(GtkWidget *widget, gpointer data);
static void EndGame(void);
t@@ -159,6 +160,7 @@ static GtkItemFactoryEntry menu_items[] = {
{N_("/Game/_New..."), "<control>N", NewGame, 0, NULL},
{N_("/Game/_Abandon..."), "<control>A", AbandonGame, 0, NULL},
{N_("/Game/_Options..."), "<control>O", OptDialog, 0, NULL},
+ {N_("/Game/Enable _sound"), NULL, ToggleSound, 0, "<CheckItem>"},
{N_("/Game/_Quit..."), "<control>Q", QuitGame, 0, NULL},
{N_("/_Talk"), NULL, NULL, 0, "<Branch>"},
{N_("/Talk/To _All..."), NULL, TalkToAll, 0, NULL},
t@@ -269,6 +271,20 @@ void AbandonGame(GtkWidget *widget, gpointer data)
}
}
+void ToggleSound(GtkWidget *widget, gpointer data)
+{
+ gboolean enable;
+
+ widget = gtk_item_factory_get_widget(ClientData.Menu,
+ "<main>/Game/Enable sound");
+ if (widget) {
+ enable = GTK_CHECK_MENU_ITEM(widget)->active;
+ SoundEnable(enable);
+ } else {
+ g_print("widget is NULL\n");
+ }
+}
+
void ListScores(GtkWidget *widget, gpointer data)
{
if (InGame) {
t@@ -2148,7 +2164,7 @@ gboolean GtkLoop(int *argc, char **argv[],
#endif
{
GtkWidget *window, *vbox, *vbox2, *hbox, *frame, *table, *menubar, *text,
- *vpaned, *button, *clist;
+ *vpaned, *button, *clist, *widget;
GtkAccelGroup *accel_group;
GtkItemFactory *item_factory;
gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
t@@ -2225,6 +2241,10 @@ gboolean GtkLoop(int *argc, char **argv[],
gtk_box_pack_start(GTK_BOX(vbox2), menubar, FALSE, FALSE, 0);
gtk_widget_show_all(menubar);
UpdateMenus();
+ SoundEnable(UseSounds);
+ widget = gtk_item_factory_get_widget(ClientData.Menu,
+ "<main>/Game/Enable sound");
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), UseSounds);
vbox = ClientData.vbox = gtk_vbox_new(FALSE, 5);
frame = gtk_frame_new(_("Stats"));