about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorJakob Fries <jakob.fries@gmail.com>2007-08-15 10:07:44 +0000
committerJakob Fries <jakob.fries@gmail.com>2007-08-15 10:07:44 +0000
commit67710661741e1ba569073513b7e741fc88c756f3 (patch)
tree22c0b7d5c0a67b1ae27aa246ee31a735c6762a26 /src/game/client
parent15d262ea1d6d7d03cbe3934ecf3c7c5f6ab1b5fd (diff)
downloadzcatch-67710661741e1ba569073513b7e741fc88c756f3.tar.gz
zcatch-67710661741e1ba569073513b7e741fc88c756f3.zip
improved emoticon selector
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/game_client.cpp43
-rw-r--r--src/game/client/menu.cpp2
2 files changed, 17 insertions, 28 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index 00004a98..a04ccf34 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -1324,16 +1324,12 @@ void render_sun(float x, float y)
 	gfx_quads_end();	
 }
 
-const int emoticon_selector_input_num = 20;
 static bool emoticon_selector_inactive_override = false;
-static int emoticon_selector_input_count = 0;
-static int emoticon_selector_input_iter = 0;
-static vec2 emoticon_selector_inputs[emoticon_selector_input_num];
+static vec2 emoticon_selector_mouse;
 
 void emoticon_selector_reset()
 {
-	emoticon_selector_input_count = 0;
-	emoticon_selector_input_iter = 0;
+	emoticon_selector_mouse = vec2(0, 0);
 }
 
 int emoticon_selector_render()
@@ -1341,28 +1337,15 @@ int emoticon_selector_render()
 	int x, y;
 	inp_mouse_relative(&x, &y);
 
-	if (x || y)
-	{
-		emoticon_selector_inputs[emoticon_selector_input_iter++ % emoticon_selector_input_num] = vec2(x, y);
-		
-		emoticon_selector_input_count++;
-		if (emoticon_selector_input_count > emoticon_selector_input_num)
-			emoticon_selector_input_count = emoticon_selector_input_num;
-	}
-
-	float selected_angle = 0;
-
-	if (emoticon_selector_input_count > emoticon_selector_input_num/2)
-	{
-		vec2 sum;
+	emoticon_selector_mouse.x += x;
+	emoticon_selector_mouse.y += y;
 
-		for (int i = 0; i < emoticon_selector_input_count; i++)
-			sum += emoticon_selector_inputs[i];
+	if (length(emoticon_selector_mouse) > 60)
+		emoticon_selector_mouse = normalize(emoticon_selector_mouse) * 60;
 
-		selected_angle = get_angle(normalize(sum));
-		if (selected_angle < 0)
-			selected_angle += 2*pi;
-	}
+	float selected_angle = get_angle(emoticon_selector_mouse);
+	if (selected_angle > pi)
+		selected_angle -= 2*pi;
 
 	static bool mouse_down = false;
 	int emoticon_selected = -1;
@@ -1388,6 +1371,8 @@ int emoticon_selector_render()
 	for (int i = 0; i < 12; i++)
 	{
 		float angle = 2*pi*i/12.0;
+		if (angle > pi)
+			angle -= 2*pi;
 		float diff = fabs(selected_angle-angle);
 
 		bool selected = diff < pi/12;
@@ -1405,6 +1390,12 @@ int emoticon_selector_render()
 
 	gfx_quads_end();
 
+    gfx_texture_set(data->images[IMAGE_CURSOR].id);
+    gfx_quads_begin();
+    gfx_quads_setcolor(1,1,1,1);
+    gfx_quads_drawTL(emoticon_selector_mouse.x+200,emoticon_selector_mouse.y+150,12,12);
+    gfx_quads_end();
+
 	return emoticon_selected;
 }
 
diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp
index b2a4fbb8..9c881488 100644
--- a/src/game/client/menu.cpp
+++ b/src/game/client/menu.cpp
@@ -1429,8 +1429,6 @@ int modmenu_render(bool ingame)
     //int r = menu_render(server_address, str, max_len);
 	int r = menu_render(ingame);
 
-    // render butt ugly mouse cursor
-    // TODO: render nice cursor
     gfx_texture_set(data->images[IMAGE_CURSOR].id);
     gfx_quads_begin();
     gfx_quads_setcolor(1,1,1,1);