about summary refs log tree commit diff
path: root/src/game/client/components
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-27 16:23:15 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-08-27 16:23:15 +0000
commit68c52dd5efca7ed66b083b70439337b8f1205c15 (patch)
tree2690d39776899a8bdea18801cb6074c35d0a941e /src/game/client/components
parentdc67b341387f539f11f8964c299ce479e36cc142 (diff)
downloadzcatch-68c52dd5efca7ed66b083b70439337b8f1205c15.tar.gz
zcatch-68c52dd5efca7ed66b083b70439337b8f1205c15.zip
repaired the local console
Diffstat (limited to 'src/game/client/components')
-rw-r--r--src/game/client/components/console.cpp66
-rw-r--r--src/game/client/components/console.hpp8
-rw-r--r--src/game/client/components/hud.cpp11
3 files changed, 75 insertions, 10 deletions
diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp
index 6437b718..a67a1138 100644
--- a/src/game/client/components/console.cpp
+++ b/src/game/client/components/console.cpp
@@ -162,7 +162,6 @@ static float console_scale_func(float t)
 
 void CONSOLE::on_render()
 {
-
     RECT screen = *ui_screen();
 	float console_max_height = screen.h*3/5.0f;
 	float console_height;
@@ -294,7 +293,70 @@ void CONSOLE::on_message(int msgtype, void *rawmsg)
 
 bool CONSOLE::on_input(INPUT_EVENT e)
 {
-	return false;
+	if(console_state == CONSOLE_CLOSED)
+		return false;
+	if(e.key >= KEY_F1 && e.key <= KEY_F25)
+		return false;
+
+	if(e.key == KEY_ESC && (e.flags&INPFLAG_PRESS))
+		toggle(console_type);
+	else
+		current_console()->on_input(e);
+		
+	return true;
+}
+
+void CONSOLE::toggle(int type)
+{
+	if(console_type != type && (console_state == CONSOLE_OPEN || console_state == CONSOLE_OPENING))
+	{
+		// don't toggle console, just switch what console to use
+	}
+	else
+	{	
+		if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_OPEN)
+		{
+			state_change_end = time_now()+state_change_duration;
+		}
+		else
+		{
+			float progress = state_change_end-time_now();
+			float reversed_progress = state_change_duration-progress;
+
+			state_change_end = time_now()+reversed_progress;
+		}
+
+		if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_CLOSING)
+			console_state = CONSOLE_OPENING;
+		else
+			console_state = CONSOLE_CLOSING;
+	}
+
+	console_type = type;
+}
+
+void CONSOLE::con_toggle_local_console(void *result, void *user_data)
+{
+	((CONSOLE *)user_data)->toggle(0);
+}
+
+void CONSOLE::con_toggle_remote_console(void *result, void *user_data)
+{
+	((CONSOLE *)user_data)->toggle(1);
+}
+
+void CONSOLE::client_console_print_callback(const char *str, void *user_data)
+{
+	((CONSOLE *)user_data)->local_console.print_line(str);
+}
+
+void CONSOLE::on_init()
+{
+	//
+	console_register_print_callback(client_console_print_callback, this);
+	
+	MACRO_REGISTER_COMMAND("toggle_local_console", "", con_toggle_local_console, this);
+	MACRO_REGISTER_COMMAND("toggle_remote_console", "", con_toggle_remote_console, this);
 }
 
 
diff --git a/src/game/client/components/console.hpp b/src/game/client/components/console.hpp
index 988e4ea3..8c6a9c72 100644
--- a/src/game/client/components/console.hpp
+++ b/src/game/client/components/console.hpp
@@ -43,10 +43,18 @@ class CONSOLE : public COMPONENT
 	int console_state;
 	float state_change_end;
 	float state_change_duration;
+
+
+	void toggle(int type);
+
+	static void client_console_print_callback(const char *str, void *user_data);
+	static void con_toggle_local_console(void *result, void *user_data);
+	static void con_toggle_remote_console(void *result, void *user_data);
 	
 public:
 	CONSOLE();
 
+	virtual void on_init();
 	virtual void on_reset();
 	virtual void on_render();
 	virtual void on_message(int msgtype, void *rawmsg);
diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp
index 0e8d371c..a73ed955 100644
--- a/src/game/client/components/hud.cpp
+++ b/src/game/client/components/hud.cpp
@@ -196,14 +196,9 @@ void HUD::render_cursor()
 	gfx_quads_begin();
 
 	// render cursor
-	// TODO: repair me
-	//if (!menu_active)
-	{
-		dbg_msg("", "%f %f", gameclient.controls->target_pos.x, gameclient.controls->target_pos.y);
-		select_sprite(data->weapons.id[gameclient.snap.local_character->weapon%NUM_WEAPONS].sprite_cursor);
-		float cursorsize = 64;
-		draw_sprite(gameclient.controls->target_pos.x, gameclient.controls->target_pos.y, cursorsize);
-	}
+	select_sprite(data->weapons.id[gameclient.snap.local_character->weapon%NUM_WEAPONS].sprite_cursor);
+	float cursorsize = 64;
+	draw_sprite(gameclient.controls->target_pos.x, gameclient.controls->target_pos.y, cursorsize);
 	gfx_quads_end();
 }