about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-11-04 21:36:03 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-11-04 21:36:03 +0000
commitb6a629cf8020e9fe76de251e07a0135dbd2f1f80 (patch)
treedd744a6ec4384beaae26006e3f674ee774855ea7 /src/engine
parentdaf89a01ff88c7771f0c252808de2b3eede23927 (diff)
downloadzcatch-b6a629cf8020e9fe76de251e07a0135dbd2f1f80.tar.gz
zcatch-b6a629cf8020e9fe76de251e07a0135dbd2f1f80.zip
new gui commit
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/snd.c14
-rw-r--r--src/engine/client/ui.c20
-rw-r--r--src/engine/client/ui.h14
-rw-r--r--src/engine/config_variables.h1
4 files changed, 29 insertions, 20 deletions
diff --git a/src/engine/client/snd.c b/src/engine/client/snd.c
index 725bc569..8e70deea 100644
--- a/src/engine/client/snd.c
+++ b/src/engine/client/snd.c
@@ -48,6 +48,7 @@ static VOICE voices[NUM_VOICES] = { {0} };
 static CHANNEL channels[NUM_CHANNELS] = { {255, 0} };
 
 static LOCK sound_lock = 0;
+static int sound_enabled = 0;
 
 static int center_x = 0;
 static int center_y = 0;
@@ -231,9 +232,12 @@ int snd_init()
 	PaStreamParameters params;
 	PaError err = Pa_Initialize();
 	
-	mixing_rate = config.snd_rate;
-
 	sound_lock = lock_create();
+	
+	if(!config.snd_enable)
+		return 0;
+	
+	mixing_rate = config.snd_rate;
 
 	params.device = Pa_GetDefaultOutputDevice();
 	if(params.device < 0)
@@ -243,7 +247,6 @@ int snd_init()
 	params.suggestedLatency = Pa_GetDeviceInfo(params.device)->defaultLowOutputLatency;
 	params.hostApiSpecificStreamInfo = 0x0;
 
-
 	err = Pa_OpenStream(
 			&stream,        /* passes back stream pointer */
 			0,              /* no input channels */
@@ -255,6 +258,7 @@ int snd_init()
 			0x0); /* pass our data through to callback */
 	err = Pa_StartStream(stream);
 
+	sound_enabled = 1;
 	return 0;
 }
 
@@ -338,6 +342,10 @@ int snd_load_wv(const char *filename)
 	/* don't waste memory on sound when we are stress testing */
 	if(config.stress)
 		return -1;
+		
+	/* no need to load sound when we are running with no sound */
+	if(!sound_enabled)
+		return 1;
 
 	file = fopen(filename, "rb"); /* TODO: use system.h stuff for this */
 	if(!file)
diff --git a/src/engine/client/ui.c b/src/engine/client/ui.c
index c2c79afa..4cd997a5 100644
--- a/src/engine/client/ui.c
+++ b/src/engine/client/ui.c
@@ -16,10 +16,10 @@ struct pretty_font
 
 extern struct pretty_font *current_font;
 
-static void *hot_item = 0;
-static void *active_item = 0;
-static void *last_active_item = 0;
-static void *becomming_hot_item = 0;
+static const void *hot_item = 0;
+static const void *active_item = 0;
+static const void *last_active_item = 0;
+static const void *becomming_hot_item = 0;
 static float mouse_x, mouse_y; /* in gui space */
 static float mouse_wx, mouse_wy; /* in world space */
 static unsigned mouse_buttons = 0;
@@ -30,12 +30,12 @@ float ui_mouse_world_x() { return mouse_wx; }
 float ui_mouse_world_y() { return mouse_wy; }
 int ui_mouse_button(int index) { return (mouse_buttons>>index)&1; }
 
-void ui_set_hot_item(void *id) { becomming_hot_item = id; }
-void ui_set_active_item(void *id) { active_item = id; if (id) last_active_item = id; }
+void ui_set_hot_item(const void *id) { becomming_hot_item = id; }
+void ui_set_active_item(const void *id) { active_item = id; if (id) last_active_item = id; }
 void ui_clear_last_active_item() { last_active_item = 0; }
-void *ui_hot_item() { return hot_item; }
-void *ui_active_item() { return active_item; }
-void *ui_last_active_item() { return last_active_item; }
+const void *ui_hot_item() { return hot_item; }
+const void *ui_active_item() { return active_item; }
+const void *ui_last_active_item() { return last_active_item; }
 
 int ui_update(float mx, float my, float mwx, float mwy, int buttons)
 {
@@ -80,7 +80,7 @@ void ui_do_label(float x, float y, const char *text, float size)
     gfx_pretty_text(x, y, size, text, -1);
 }
 
-int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra)
+int ui_do_button(const void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra)
 {
     /* logic */
     int r = 0;
diff --git a/src/engine/client/ui.h b/src/engine/client/ui.h
index 31757b3b..6b29a61c 100644
--- a/src/engine/client/ui.h
+++ b/src/engine/client/ui.h
@@ -13,20 +13,20 @@ float ui_mouse_world_x();
 float ui_mouse_world_y();
 int ui_mouse_button(int index);
 
-void ui_set_hot_item(void *id);
-void ui_set_active_item(void *id);
+void ui_set_hot_item(const void *id);
+void ui_set_active_item(const void *id);
 void ui_clear_last_active_item();
-void *ui_hot_item();
-void *ui_active_item();
-void *ui_last_active_item();
+const void *ui_hot_item();
+const void *ui_active_item();
+const void *ui_last_active_item();
 
 int ui_mouse_inside(float x, float y, float w, float h);
 
-typedef void (*draw_button_callback)(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra);
+typedef void (*draw_button_callback)(const void *id, const char *text, int checked, float x, float y, float w, float h, void *extra);
 
 void ui_do_image(int texture, float x, float y, float w, float h);
 void ui_do_label(float x, float y, const char *text, float size);
-int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra);
+int ui_do_button(const void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra);
 
 #ifdef __cplusplus
 }
diff --git a/src/engine/config_variables.h b/src/engine/config_variables.h
index f3820901..eb2837af 100644
--- a/src/engine/config_variables.h
+++ b/src/engine/config_variables.h
@@ -23,6 +23,7 @@ MACRO_CONFIG_INT(b_sort, 0, 0, 0)
 MACRO_CONFIG_INT(b_max_requests, 10, 0, 0)
 
 MACRO_CONFIG_INT(snd_rate, 48000, 0, 0)
+MACRO_CONFIG_INT(snd_enable, 1, 0, 1)
 
 MACRO_CONFIG_INT(gfx_screen_width, 800, 0, 0)
 MACRO_CONFIG_INT(gfx_screen_height, 600, 0, 0)