about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-03 20:03:01 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-09-03 20:03:01 +0000
commit53da3f0d40ff9eb171b3d8eaaeed148e9ddd2f8b (patch)
treed9014120bd015f7e3fcc4f2cf997321ba0494b70 /src/game/client
parent37f3fa6c6efe231d5a172dbee6a50d63bf42b910 (diff)
downloadzcatch-53da3f0d40ff9eb171b3d8eaaeed148e9ddd2f8b.tar.gz
zcatch-53da3f0d40ff9eb171b3d8eaaeed148e9ddd2f8b.zip
added favorites. no saving of them yet however
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/components/menus.cpp32
-rw-r--r--src/game/client/components/menus_browser.cpp36
-rw-r--r--src/game/client/components/players.cpp18
3 files changed, 56 insertions, 30 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 70fdc767..de2e5711 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -104,21 +104,7 @@ void MENUS::ui_draw_browse_icon(int what, const RECT *r)
 {
 	gfx_texture_set(data->images[IMAGE_BROWSEICONS].id);
 	gfx_quads_begin();
-	select_sprite(SPRITE_BROWSE_PROGRESS1); // default
-	if(what == -1)
-	{
-	}
-	else if(what <= 100)
-	{
-		if(what < 66)
-			select_sprite(SPRITE_BROWSE_PROGRESS2);
-		else
-			select_sprite(SPRITE_BROWSE_PROGRESS3);
-	}
-	else if(what&0x100)
-	{
-		select_sprite(SPRITE_BROWSE_LOCK);
-	}
+	select_sprite(what);
 	gfx_quads_drawTL(r->x,r->y,r->w,r->h);
 	gfx_quads_end();
 }
@@ -509,7 +495,7 @@ int MENUS::render_menubar(RECT r)
 		static int internet_button=0;
 		if (ui_do_button(&internet_button, "Internet", active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, 0))
 		{
-			client_serverbrowse_refresh(0);
+			client_serverbrowse_refresh(BROWSETYPE_INTERNET);
 			new_page = PAGE_INTERNET;
 		}
 
@@ -518,17 +504,17 @@ int MENUS::render_menubar(RECT r)
 		static int lan_button=0;
 		if (ui_do_button(&lan_button, "LAN", active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, 0))
 		{
-			client_serverbrowse_refresh(1);
+			client_serverbrowse_refresh(BROWSETYPE_LAN);
 			new_page = PAGE_LAN;
 		}
 
-		if(0) // this one is not done yet
+		ui_vsplit_l(&box, 4.0f, 0, &box);
+		ui_vsplit_l(&box, 120.0f, &button, &box);
+		static int favorites_button=0;
+		if (ui_do_button(&favorites_button, "Favorites", active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, 0))
 		{
-			ui_vsplit_l(&box, 4.0f, 0, &box);
-			ui_vsplit_l(&box, 120.0f, &button, &box);
-			static int favorites_button=0;
-			if (ui_do_button(&favorites_button, "Favorites", active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, 0))
-				new_page  = PAGE_FAVORITES;
+			client_serverbrowse_refresh(BROWSETYPE_FAVORITES);
+			new_page  = PAGE_FAVORITES;
 		}
 	}
 	else
diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp
index be0e1904..0d1effb8 100644
--- a/src/game/client/components/menus_browser.cpp
+++ b/src/game/client/components/menus_browser.cpp
@@ -68,7 +68,8 @@ void MENUS::render_serverbrowser(RECT main_view)
 		FIXED=1,
 		SPACER=2,
 		
-		COL_FLAGS=0,
+		COL_FLAG_LOCK=0,
+		COL_FLAG_FAV,
 		COL_NAME,
 		COL_GAMETYPE,
 		COL_MAP,
@@ -79,8 +80,9 @@ void MENUS::render_serverbrowser(RECT main_view)
 	};
 	
 	static column cols[] = {
-		{-1,			-1,						" ",		-1, 10.0f, 0, {0}, {0}},
-		{COL_FLAGS,		-1,						" ",		-1, 20.0f, 0, {0}, {0}},
+		{-1,			-1,						" ",		-1, 2.0f, 0, {0}, {0}},
+		{COL_FLAG_LOCK,	-1,						" ",		-1, 14.0f, 0, {0}, {0}},
+		{COL_FLAG_FAV,	-1,						" ",		-1, 14.0f, 0, {0}, {0}},
 		{COL_NAME,		BROWSESORT_NAME,		"Name",		0, 300.0f, 0, {0}, {0}},
 		{COL_GAMETYPE,	BROWSESORT_GAMETYPE,	"Type",		1, 50.0f, 0, {0}, {0}},
 		{COL_MAP,		BROWSESORT_MAP,			"Map", 		1, 100.0f, 0, {0}, {0}},
@@ -239,15 +241,21 @@ void MENUS::render_serverbrowser(RECT main_view)
 
 			//s = ui_do_button(item, "L", l, &button, ui_draw_browse_icon, 0);
 			
-			if(id == COL_FLAGS)
+			if(id == COL_FLAG_LOCK)
 			{
 				if(item->flags&1)
-					ui_draw_browse_icon(0x100, &button);
+					ui_draw_browse_icon(SPRITE_BROWSE_LOCK, &button);
+			}	
+			else if(id == COL_FLAG_FAV)
+			{
+				if(item->favorite)
+					ui_draw_browse_icon(SPRITE_BROWSE_HEART, &button);
 			}
 			else if(id == COL_NAME)
 			{
 				TEXT_CURSOR cursor;
-				gfx_text_set_cursor(&cursor, button.x, button.y, 12.0f, TEXTFLAG_RENDER);
+				gfx_text_set_cursor(&cursor, button.x, button.y, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
+				cursor.line_width = button.w;
 				
 				if(config.b_filter_string[0] && (item->quicksearch_hit&BROWSEQUICK_SERVERNAME))
 				{
@@ -350,6 +358,21 @@ void MENUS::render_serverbrowser(RECT main_view)
 		RECT left_column;
 		RECT right_column;
 
+		// 
+		{
+			RECT button;
+			ui_hsplit_b(&server_details, 20.0f, &server_details, &button);
+			static int add_fav_button = 0;
+			if (ui_do_button(&add_fav_button, "Favorite", selected_server->favorite, &button, ui_draw_checkbox, 0))
+			{
+				if(selected_server->favorite)
+					client_serverbrowse_removefavorite(selected_server->netaddr);
+				else
+					client_serverbrowse_addfavorite(selected_server->netaddr);
+			}
+		}
+		//ui_do_label(&row, temp, font_size, -1);		
+
 		ui_vsplit_l(&server_details, 5.0f, 0x0, &server_details);
 		ui_vsplit_l(&server_details, 80.0f, &left_column, &right_column);
 
@@ -377,6 +400,7 @@ void MENUS::render_serverbrowser(RECT main_view)
 		str_format(temp, sizeof(temp), "%d", selected_server->latency);
 		ui_hsplit_t(&right_column, 15.0f, &row, &right_column);
 		ui_do_label(&row, temp, font_size, -1);
+
 	}
 	
 	// server scoreboard
diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp
index f2d81323..68cf032b 100644
--- a/src/game/client/components/players.cpp
+++ b/src/game/client/components/players.cpp
@@ -58,6 +58,22 @@ void PLAYERS::render_hand(TEE_RENDER_INFO *info, vec2 center_pos, vec2 dir, floa
 	gfx_quads_end();
 }
 
+inline float normalize_angular(float f)
+{
+	return fmod(f, pi*2);
+}
+
+inline float mix_angular(float src, float dst, float amount)
+{
+	src = normalize_angular(src);
+	dst = normalize_angular(dst);
+	float d0 = dst-src;
+	float d1 = dst-(src+pi*2);
+	if(fabs(d0) < fabs(d1))
+		return src+d0*amount;
+	return src+d1*amount;
+}
+
 void PLAYERS::render_player(
 	const NETOBJ_CHARACTER *prev_char,
 	const NETOBJ_CHARACTER *player_char,
@@ -112,7 +128,7 @@ void PLAYERS::render_player(
 	if(player.attacktick != prev.attacktick)
 		mixspeed = 0.1f;
 	
-	float angle = mix(gameclient.clients[info.cid].angle, player.angle/256.0f, mixspeed);
+	float angle = mix_angular(gameclient.clients[info.cid].angle, player.angle/256.0f, mixspeed);
 	gameclient.clients[info.cid].angle = angle;
 	vec2 direction = get_direction((int)(angle*256.0f));