about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/engine/interface.h2
-rw-r--r--src/game/client/game_client.cpp110
-rw-r--r--src/game/client/menu.cpp119
3 files changed, 119 insertions, 112 deletions
diff --git a/src/engine/interface.h b/src/engine/interface.h
index f7a95c61..7fa1fedb 100644
--- a/src/engine/interface.h
+++ b/src/engine/interface.h
@@ -709,7 +709,7 @@ void modmenu_shutdown();
     Function: modmenu_render
         Called every frame to let the menu render it self.
 */
-int modmenu_render();
+int modmenu_render(bool ingame);
 
 
 
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp
index 0fd1b1e2..4eddebbd 100644
--- a/src/game/client/game_client.cpp
+++ b/src/game/client/game_client.cpp
@@ -17,11 +17,8 @@ data_container *data = 0x0;
 
 static int charids[16] = {2,10,0,4,12,6,9,1,3,15,13,11,7,5,8,14};
 
-static int gametype = GAMETYPE_DM;
+int gametype = GAMETYPE_DM;
 static int skinseed = 0;
-static int menu_team = 0;
-static int menu_quit = 0;
-static int menu_resume = 0;
 
 static int music_menu = -1;
 static int music_menu_id = -1;
@@ -1155,83 +1152,6 @@ void render_sun(float x, float y)
 	gfx_quads_end();	
 }
 
-void ingamemenu_render()
-{
-	if (!local_player)
-		return;
-	gfx_mapscreen(0, 0, 800, 600); // TODO: fix me
-	// Ingame menu - quit and change team (if tdm)
-	float mx,my;
-	int rx, ry;
-    inp_mouse_relative(&rx, &ry);
-    static vec2 menu_mouse_pos(0,0);
-    menu_mouse_pos.x += rx;
-    menu_mouse_pos.y += ry;
-    if(menu_mouse_pos.x < 0) mouse_pos.x = 0;
-    if(menu_mouse_pos.y < 0) mouse_pos.y = 0;
-    if(menu_mouse_pos.x > gfx_screenwidth()) menu_mouse_pos.x = gfx_screenwidth();
-    if(menu_mouse_pos.y > gfx_screenheight()) menu_mouse_pos.y = gfx_screenheight();
-        
-    // update the ui
-    mx = (menu_mouse_pos.x/(float)gfx_screenwidth())*800.0f;
-    my = (menu_mouse_pos.y/(float)gfx_screenheight())*600.0f;
-        
-    int buttons = 0;
-    if(inp_key_pressed(input::mouse_1)) buttons |= 1;
-    if(inp_key_pressed(input::mouse_2)) buttons |= 2;
-    if(inp_key_pressed(input::mouse_3)) buttons |= 4;
-        
-    ui_update(mx,my,mx*3.0f,my*3.0f,buttons);
-
-	char buf[128];
-	if (gametype == GAMETYPE_TDM)
-	{
-		// Switch team
-		ui_do_label(100,100,"Switch Team",40);
-		sprintf(buf,"Team: %s",local_player->team ? "A" : "B");
-		if (ui_do_button(&menu_team, buf, 0, 30, 150, 170, 48, draw_teewars_button))
-		{
-			msg_pack_start(MSG_SWITCHTEAM, MSGFLAG_VITAL);
-			msg_pack_end();
-			client_send_msg();
-			menu_active = false;
-		}
-	}
-
-	const int column1_x = 275;
-	const int row1_y = 200;
-	const int row2_y = row1_y + 60;
-	const int row3_y = row2_y + 60;
-
-	gfx_blend_normal();
-	
-	gfx_texture_set(-1);
-	gfx_quads_begin();
-	gfx_quads_setcolor(0,0,0,0.5f);
-	draw_round_rect(170, 120, 460, 300, 30.0f);
-	gfx_quads_end();
-	
-	ui_do_image(data->images[IMAGE_BANNER].id, 214, 150, 384, 96);
-
-	if (ui_do_button(&menu_resume, "Resume Game", 0, column1_x, row2_y, 250, 48, draw_teewars_button))
-	{
-		menu_active = 0;
-	}
-
-	if (ui_do_button(&menu_quit, "Disconnect", 0, column1_x, row3_y, 250, 48, draw_teewars_button))
-	{
-		menu_active = 0;
-		client_disconnect();
-	}
-	
-	gfx_texture_set(data->images[IMAGE_CURSOR].id);
-	gfx_quads_begin();
-	gfx_quads_setcolor(1,1,1,1);
-	gfx_quads_drawTL(mx,my,24,24);
-	gfx_quads_end();
-	
-}
-
 void render_game()
 {	
 	animstate idlestate;
@@ -1301,8 +1221,11 @@ void render_game()
 		}
 	}
 	
-	input::clear_char(); // TODO: bypasses the engine interface
-	input::clear_key(); // TODO: bypasses the engine interface
+	if (!menu_active)
+	{
+		input::clear_char(); // TODO: bypasses the engine interface
+		input::clear_key(); // TODO: bypasses the engine interface
+	}
 	
 	// fetch new input
 	if(!menu_active)
@@ -1638,12 +1561,6 @@ void render_game()
 		}
 	}
 	
-	if (menu_active)
-	{
-		ingamemenu_render();
-		return;
-	}
-
 	// render goals
 	if(gameobj)
 	{
@@ -1675,6 +1592,15 @@ void render_game()
 			gfx_pretty_text(200-w/2, 2, 16, text);
 		}
 	}
+
+	if (menu_active)
+	{
+		if (modmenu_render(true))
+			menu_active = false;
+			
+		//ingamemenu_render();
+		return;
+	}
 	
 	// render score board
 	if(inp_key_pressed(baselib::input::tab) || // user requested
@@ -1909,15 +1835,15 @@ void modc_render()
 			music_menu_id = snd_play(music_menu, SND_LOOP);
 		
 		//netaddr4 server_address;
-		if(modmenu_render() == -1)
+		if(modmenu_render(false) == -1)
 			client_quit();
-
 	}
 }
 
 
 void menu_do_disconnected();
 void menu_do_connecting();
+void menu_do_connected();
 
 void modc_statechange(int state, int old)
 {
@@ -1925,6 +1851,8 @@ void modc_statechange(int state, int old)
 	 	menu_do_disconnected();
 	if(state == CLIENTSTATE_CONNECTING)
 		menu_do_connecting();
+	if (state == CLIENTSTATE_ONLINE)
+		menu_do_connected();
 }
 
 void modc_message(int msg)
diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp
index b39b8c3a..e0b171b1 100644
--- a/src/game/client/menu.cpp
+++ b/src/game/client/menu.cpp
@@ -970,8 +970,21 @@ static int settings_sound_render()
 	return 0;
 }
 
-static int settings_render()
+extern void draw_round_rect(float x, float y, float w, float h, float r);
+
+static int settings_render(bool ingame)
 {
+	if (ingame)
+	{
+		gfx_blend_normal();
+		
+		gfx_texture_set(-1);
+		gfx_quads_begin();
+		gfx_quads_setcolor(0,0,0,0.5f);
+		draw_round_rect(10, 120, 780, 460, 30.0f);
+		gfx_quads_end();
+	}
+
 	static int general_button, controls_button, video_button, sound_button;
 
 	if (ui_do_button(&general_button, "General", 0, 30, 200, 170, 48, draw_teewars_button))
@@ -1017,6 +1030,61 @@ static int settings_render()
 	return 0;
 }
 
+extern int gametype;
+static int ingame_main_render()
+{
+	static int menu_resume, menu_active, menu_quit, menu_settings;
+	char buf[128];
+	/*if (gametype == GAMETYPE_TDM)
+	{
+		// Switch team
+		ui_do_label(100,100,"Switch Team",40);
+		sprintf(buf,"Team: %s",local_player->team ? "A" : "B");
+		if (ui_do_button(&menu_team, buf, 0, 30, 150, 170, 48, draw_teewars_button))
+		{
+			msg_pack_start(MSG_SWITCHTEAM, MSGFLAG_VITAL);
+			msg_pack_end();
+			client_send_msg();
+			menu_active = false;
+		}
+	}*/
+
+	const int column1_x = 275;
+	const int row1_y = 200;
+	const int row2_y = row1_y + 60;
+	const int row3_y = row2_y + 60;
+	const int row4_y = row3_y + 60;
+
+	gfx_blend_normal();
+	
+	gfx_texture_set(-1);
+	gfx_quads_begin();
+	gfx_quads_setcolor(0,0,0,0.5f);
+	draw_round_rect(170, 120, 460, 360, 30.0f);
+	gfx_quads_end();
+	
+	ui_do_image(data->images[IMAGE_BANNER].id, 214, 150, 384, 96);
+
+	if (ui_do_button(&menu_resume, "Resume Game", 0, column1_x, row2_y, 250, 48, draw_teewars_button))
+	{
+		return 1;
+	}
+
+	if (ui_do_button(&menu_quit, "Disconnect", 0, column1_x, row4_y, 250, 48, draw_teewars_button))
+	{
+		client_disconnect();
+		return 1;
+	}
+
+	if (ui_do_button(&menu_settings, "Settings", 0, column1_x, row3_y, 250, 48, draw_teewars_button))
+	{
+		config_copy = config;
+		screen = SCREEN_SETTINGS_GENERAL;
+	}
+
+	return 0;
+}
+
 extern double extra_kerning[256*256];
 
 static int kerning_render()
@@ -1186,7 +1254,6 @@ static int kerning_render()
 	return 0;
 }
 
-extern void draw_round_rect(float x, float y, float w, float h, float r);
 
 static int render_popup(const char *caption, const char *text, const char *button_text)
 {
@@ -1254,31 +1321,43 @@ void menu_do_connecting()
 	screen = SCREEN_CONNECTING;
 }
 
-static int menu_render()
+void menu_do_connected()
 {
-	// background color
-	gfx_clear(0.65f,0.78f,0.9f);
-	//gfx_clear(89/255.f,122/255.f,0.0);
+	screen = SCREEN_MAIN;
+}
+
+static int menu_render(bool ingame)
+{
+	if (!ingame)
+	{
+		// background color
+		gfx_clear(0.65f,0.78f,0.9f);
+		//gfx_clear(89/255.f,122/255.f,0.0);
 
-	// GUI coordsys
-	gfx_mapscreen(0,0,800.0f,600.0f);
+		// GUI coordsys
+		gfx_mapscreen(0,0,800.0f,600.0f);
 
-	static int64 start = time_get();
+		static int64 start = time_get();
 
-	float t = double(time_get() - start) / double(time_freq());
-	gfx_mapscreen(0,0,1600.0f,1200.0f);
-	draw_background(t);
-	gfx_mapscreen(0,0,800.0f,600.0f);
+		float t = double(time_get() - start) / double(time_freq());
+		gfx_mapscreen(0,0,1600.0f,1200.0f);
+		draw_background(t);
+		gfx_mapscreen(0,0,800.0f,600.0f);
 
-	if (screen != SCREEN_KERNING)
+		if (screen != SCREEN_KERNING)
+		{
+			ui_do_image(data->images[IMAGE_BANNER].id, 200, 20, 512, 128);
+			ui_do_label(20.0f, 600.0f-40.0f, "Version: " TEEWARS_VERSION, 36);
+		}
+	}
+	else
 	{
-		ui_do_image(data->images[IMAGE_BANNER].id, 200, 20, 512, 128);
-		ui_do_label(20.0f, 600.0f-40.0f, "Version: " TEEWARS_VERSION, 36);
+		gfx_mapscreen(0, 0, 800, 600);
 	}
 
 	switch (screen)
 	{
-		case SCREEN_MAIN: return main_render();
+		case SCREEN_MAIN: return ingame ? ingame_main_render() : main_render();
 		case SCREEN_DISCONNECTED: return disconnected_render();
 		case SCREEN_CONNECTING: return connecting_render();
 		case SCREEN_SETTINGS_GENERAL:
@@ -1286,7 +1365,7 @@ static int menu_render()
 		case SCREEN_SETTINGS_VIDEO:
 		case SCREEN_SETTINGS_VIDEO_SELECT_MODE:
 		case SCREEN_SETTINGS_VIDEO_CUSTOM:
-		case SCREEN_SETTINGS_SOUND: return settings_render();
+		case SCREEN_SETTINGS_SOUND: return settings_render(ingame);
 		case SCREEN_KERNING: return kerning_render();
 		default: dbg_msg("menu", "invalid screen selected..."); return 0;
 	}
@@ -1305,7 +1384,7 @@ void modmenu_shutdown()
 {
 }
 
-int modmenu_render()
+int modmenu_render(bool ingame)
 {
 	static int mouse_x = 0;
 	static int mouse_y = 0;
@@ -1335,7 +1414,7 @@ int modmenu_render()
     }
 
     //int r = menu_render(server_address, str, max_len);
-	int r = menu_render();
+	int r = menu_render(ingame);
 
     // render butt ugly mouse cursor
     // TODO: render nice cursor