about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-12 07:20:26 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-12 07:20:26 +0000
commit5bcba4498e2934d44ae3b15d047be5eff5e7afb1 (patch)
tree209a8f2e7265dadba0b593223cdb8f3014a71c71
parent39c01e7f11bda0e9efc3e0a17c40b60d72b1afc3 (diff)
downloadzcatch-5bcba4498e2934d44ae3b15d047be5eff5e7afb1.tar.gz
zcatch-5bcba4498e2934d44ae3b15d047be5eff5e7afb1.zip
fixed timeout
-rw-r--r--src/game/client/components/menus.cpp78
-rw-r--r--src/game/client/components/menus.hpp2
-rw-r--r--src/game/client/gameclient.cpp9
3 files changed, 63 insertions, 26 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 2f853e28..f9034403 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -89,6 +89,8 @@ MENUS::MENUS()
 	need_restart = false;
 	menu_active = true;
 	num_inputevents = 0;
+	
+	last_input = time_get();
 }
 
 vec4 MENUS::button_color_mul(const void *id)
@@ -940,6 +942,8 @@ void MENUS::on_reset()
 
 bool MENUS::on_mousemove(float x, float y)
 {
+	last_input = time_get();
+	
 	if(!menu_active)
 		return false;
 		
@@ -955,6 +959,8 @@ bool MENUS::on_mousemove(float x, float y)
 
 bool MENUS::on_input(INPUT_EVENT e)
 {
+	last_input = time_get();
+	
 	if(e.flags&INPFLAG_PRESS && e.key == KEY_ESC)
 	{
 		menu_active	= !menu_active;
@@ -1039,31 +1045,55 @@ void MENUS::on_render()
 	ui_update(mx,my,mx*3.0f,my*3.0f,buttons);
     
     // render
-	render();
-	/*render_background();
-
-
-    {RECT screen = *ui_screen();
-	gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);}*/
+    if(time_get()-last_input > time_freq()*30)
+    {
+    	// screen saver :)
+		render_background();
+		
+		if(data->images[IMAGE_BANNER].id != 0)
+		{
+			float sw = 300*gfx_screenaspect();
+			float sh = 300;
+			gfx_mapscreen(0, 0, sw, sh);
 	
-	// render cursor
-    gfx_texture_set(data->images[IMAGE_CURSOR].id);
-    gfx_quads_begin();
-    gfx_setcolor(1,1,1,1);
-    gfx_quads_drawTL(mx,my,24,24);
-    gfx_quads_end();
-
-	// render debug information
-	if(config.debug)
+			gfx_texture_set(data->images[IMAGE_BANNER].id);
+			gfx_quads_begin();
+			gfx_setcolor(0,0,0,1.0f);
+			//gfx_quads_setrotation(-pi/4+0.15f);
+			gfx_quads_drawTL(sw-200-20, 10, 200, 200/4);
+			gfx_setcolor(1,1,1,1.0f);
+			gfx_quads_drawTL(sw-200-20-2, 10-2, 200, 200/4);
+			gfx_quads_end();
+			
+//void gfx_text(void *font, float x, float y, float size, const char *text, int max_width);
+			
+			if((time_get()/(time_freq()/3))&1)
+				gfx_text(NULL, sw-150, 200/4, 10.0f, "INSERT COIN", -1);
+		}		
+	}
+	else
 	{
-		RECT screen = *ui_screen();
-		gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
-
-		char buf[512];
-		str_format(buf, sizeof(buf), "%p %p %p", ui_hot_item(), ui_active_item(), ui_last_active_item());
-		TEXT_CURSOR cursor;
-		gfx_text_set_cursor(&cursor, 10, 10, 10, TEXTFLAG_RENDER);
-		gfx_text_ex(&cursor, buf, -1);
+		render();
+
+		// render cursor
+		gfx_texture_set(data->images[IMAGE_CURSOR].id);
+		gfx_quads_begin();
+		gfx_setcolor(1,1,1,1);
+		gfx_quads_drawTL(mx,my,24,24);
+		gfx_quads_end();
+
+		// render debug information
+		if(config.debug)
+		{
+			RECT screen = *ui_screen();
+			gfx_mapscreen(screen.x, screen.y, screen.w, screen.h);
+
+			char buf[512];
+			str_format(buf, sizeof(buf), "%p %p %p", ui_hot_item(), ui_active_item(), ui_last_active_item());
+			TEXT_CURSOR cursor;
+			gfx_text_set_cursor(&cursor, 10, 10, 10, TEXTFLAG_RENDER);
+			gfx_text_ex(&cursor, buf, -1);
+		}
 	}
 
 	num_inputevents = 0;
@@ -1171,6 +1201,8 @@ static TEE tees[NUM_TEES];
 
 void MENUS::render_background()
 {
+	gfx_clear(1,1,1);
+	
 	static int load = 1;
 	if(load)
 	{
diff --git a/src/game/client/components/menus.hpp b/src/game/client/components/menus.hpp
index a4f6ec99..6390ec52 100644
--- a/src/game/client/components/menus.hpp
+++ b/src/game/client/components/menus.hpp
@@ -60,6 +60,8 @@ class MENUS : public COMPONENT
 	int active_page;
 	bool menu_active;
 	vec2 mouse_pos;
+	
+	int64 last_input;
 
 	// TODO: this is a bit ugly but.. well.. yeah	
 	enum { MAX_INPUTEVENTS = 32 };
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 9c13c107..fe9b0476 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -216,10 +216,13 @@ void GAMECLIENT::dispatch_input()
 	// handle mouse movement
 	int x=0, y=0;
 	inp_mouse_relative(&x, &y);
-	for(int h = 0; h < input.num; h++)
+	if(x || y)
 	{
-		if(input.components[h]->on_mousemove(x, y))
-			break;
+		for(int h = 0; h < input.num; h++)
+		{
+			if(input.components[h]->on_mousemove(x, y))
+				break;
+		}
 	}
 	
 	// handle key presses