about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-21 17:39:09 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-21 17:39:09 +0000
commit45a047ce478e31297eba35e2e3121b25cabeae12 (patch)
tree0cf3794fca8ec176b8b64604ac7f7104977c0e2a
parentfaa13fe70371834c3e7e234875d32bb95d278c54 (diff)
downloadzcatch-45a047ce478e31297eba35e2e3121b25cabeae12.tar.gz
zcatch-45a047ce478e31297eba35e2e3121b25cabeae12.zip
fixed bug in text rendering. added option for detail layers
-rw-r--r--data/maps/ctf1.mapbin4401 -> 4401 bytes
-rw-r--r--data/maps/ctf2.mapbin10566 -> 10566 bytes
-rw-r--r--data/maps/dm1.mapbin4399 -> 4399 bytes
-rw-r--r--data/maps/dm2.mapbin7580 -> 7580 bytes
-rw-r--r--src/engine/client/ec_gfx.c3
-rw-r--r--src/game/client/gc_render.cpp4
-rw-r--r--src/game/editor/ed_editor.cpp34
-rw-r--r--src/game/editor/ed_editor.hpp5
-rw-r--r--src/game/editor/ed_io.cpp25
-rw-r--r--src/game/editor/ed_popups.cpp8
-rw-r--r--src/game/g_mapitems.h2
11 files changed, 67 insertions, 14 deletions
diff --git a/data/maps/ctf1.map b/data/maps/ctf1.map
index 8a780e5c..5e00a4e7 100644
--- a/data/maps/ctf1.map
+++ b/data/maps/ctf1.map
Binary files differdiff --git a/data/maps/ctf2.map b/data/maps/ctf2.map
index 5cbd404b..57af2d61 100644
--- a/data/maps/ctf2.map
+++ b/data/maps/ctf2.map
Binary files differdiff --git a/data/maps/dm1.map b/data/maps/dm1.map
index 9c00f947..292d85a2 100644
--- a/data/maps/dm1.map
+++ b/data/maps/dm1.map
Binary files differdiff --git a/data/maps/dm2.map b/data/maps/dm2.map
index 062e5797..47131481 100644
--- a/data/maps/dm2.map
+++ b/data/maps/dm2.map
Binary files differdiff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index 2de9ca23..e3a4453b 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -1036,7 +1036,7 @@ void gfx_text_ex(TEXT_CURSOR *cursor, const char *text, int length)
 			
 			to_render -= this_batch;
 
-			while(this_batch > 0)
+			while(this_batch-- > 0)
 			{
 				float tex_x0, tex_y0, tex_x1, tex_y1;
 				float width, height;
@@ -1062,7 +1062,6 @@ void gfx_text_ex(TEXT_CURSOR *cursor, const char *text, int length)
 				advance = x_advance + font_kerning(font, *current, *(current+1));
 				draw_x += advance*size;
 				current++;
-				this_batch--;
 			}
 		}
 
diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp
index c81aa46d..ccb60810 100644
--- a/src/game/client/gc_render.cpp
+++ b/src/game/client/gc_render.cpp
@@ -298,6 +298,10 @@ void render_layers(float center_x, float center_y, int pass)
 			bool render = false;
 			bool is_game_layer = false;
 			
+			// skip rendering if detail layers if not wanted
+			if(layer->flags&LAYERFLAG_DETAIL && !config.gfx_high_detail)
+				continue;
+			
 			if(layer == (MAPITEM_LAYER*)layers_game_layer())
 			{
 				is_game_layer = true;
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp
index ed1bec8a..f1e2e258 100644
--- a/src/game/editor/ed_editor.cpp
+++ b/src/game/editor/ed_editor.cpp
@@ -78,7 +78,10 @@ void LAYERGROUP::render()
 	for(int i = 0; i < layers.len(); i++)
 	{
 		if(layers[i]->visible && layers[i] != editor.map.game_layer)
-			layers[i]->render();
+		{
+			if(editor.show_detail || !(layers[i]->flags&LAYERFLAG_DETAIL))
+				layers[i]->render();
+		}
 	}
 }
 
@@ -220,14 +223,14 @@ static void draw_inc_button(const void *id, const char *text, int checked, const
 {
 	if(ui_hot_item == id) if(extra) editor.tooltip = (const char *)extra;
 	ui_draw_rect(r, get_button_color(id, checked), CORNER_R, 3.0f);
-	ui_do_label(r, ">", 10, 0, -1);
+	ui_do_label(r, text?text:">", 10, 0, -1);
 }
 
 static void draw_dec_button(const void *id, const char *text, int checked, const RECT *r, const void *extra)
 {
 	if(ui_hot_item == id) if(extra) editor.tooltip = (const char *)extra;
 	ui_draw_rect(r, get_button_color(id, checked), CORNER_L, 3.0f);
-	ui_do_label(r, "<", 10, 0, -1);
+	ui_do_label(r, text?text:"<", 10, 0, -1);
 }
 
 enum
@@ -362,6 +365,16 @@ static void do_toolbar(RECT toolbar)
 
 	// animate button
 	ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar);
+	static int hq_button = 0;
+	if(do_editor_button(&hq_button, "Detail", editor.show_detail, &button, draw_editor_button, 0, "[ctrl+h] Toggle High Detail") ||
+		(inp_key_down('H') && (inp_key_pressed(KEY_LCTRL) || inp_key_pressed(KEY_RCTRL))))
+	{
+		editor.show_detail = !editor.show_detail;
+	}
+
+	ui_vsplit_l(&toolbar, 5.0f, 0, &toolbar);
+	
+	ui_vsplit_l(&toolbar, 30.0f, &button, &toolbar);
 	static int animate_button = 0;
 	if(do_editor_button(&animate_button, "Anim", editor.animate, &button, draw_editor_button, 0, "[ctrl+m] Toggle animation") ||
 		(inp_key_down('M') && (inp_key_pressed(KEY_LCTRL) || inp_key_pressed(KEY_RCTRL))))
@@ -1193,6 +1206,21 @@ int EDITOR::do_properties(RECT *toolbox, PROPERTY *props, int *ids, int *new_val
 				change = i;
 			}
 		}
+		else if(props[i].type == PROPTYPE_BOOL)
+		{
+			RECT no, yes;
+			ui_vsplit_mid(&shifter, &no, &yes);
+			if(do_editor_button(&ids[i], "No", !props[i].value, &no, draw_dec_button, 0, ""))
+			{
+				*new_val = 0;
+				change = i;
+			}
+			if(do_editor_button(((char *)&ids[i])+1, "Yes", props[i].value, &yes, draw_inc_button, 0, ""))
+			{
+				*new_val = 1;
+				change = i;
+			}
+		}		
 		else if(props[i].type == PROPTYPE_INT_SCROLL)
 		{
 			int new_value = ui_do_value_selector(&ids[i], &shifter, "", props[i].value, props[i].min, props[i].max, 1.0f);
diff --git a/src/game/editor/ed_editor.hpp b/src/game/editor/ed_editor.hpp
index b2bc7f26..e2fda9ef 100644
--- a/src/game/editor/ed_editor.hpp
+++ b/src/game/editor/ed_editor.hpp
@@ -134,6 +134,7 @@ public:
 		type_name = "(invalid)";
 		visible = true;
 		readonly = false;
+		flags = 0;
 	}
 	
 	virtual ~LAYER()
@@ -159,6 +160,7 @@ public:
 	
 	const char *type_name;
 	int type;
+	int flags;
 
 	bool readonly;
 	bool visible;
@@ -313,6 +315,7 @@ struct PROPERTY
 enum
 {
 	PROPTYPE_NULL=0,
+	PROPTYPE_BOOL,
 	PROPTYPE_INT_STEP,
 	PROPTYPE_INT_SCROLL,
 	PROPTYPE_COLOR,
@@ -345,6 +348,7 @@ public:
 		gui_active = true;
 		proof_borders = false;
 		
+		show_detail = true;
 		animate = false;
 		animate_start = 0;
 		animate_time = 0;
@@ -387,6 +391,7 @@ public:
 	float mouse_delta_wx;
 	float mouse_delta_wy;
 	
+	bool show_detail;
 	bool animate;
 	int64 animate_start;
 	float animate_time;
diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp
index 8c4c1e92..b805b0b5 100644
--- a/src/game/editor/ed_io.cpp
+++ b/src/game/editor/ed_io.cpp
@@ -252,7 +252,7 @@ int MAP::save(const char *filename)
 				MAPITEM_LAYER_TILEMAP item;
 				item.version = 2;
 				
-				item.layer.flags = 0;
+				item.layer.flags = layer->flags;
 				item.layer.type = layer->type;
 				
 				item.color.r = 255; // not in use right now
@@ -280,7 +280,7 @@ int MAP::save(const char *filename)
 				{
 					MAPITEM_LAYER_QUADS item;
 					item.version = 1;
-					item.layer.flags = 0;
+					item.layer.flags =  layer->flags;
 					item.layer.type = layer->type;
 					item.image = layer->image;
 					
@@ -440,6 +440,7 @@ int MAP::load(const char *filename)
 				
 				for(int l = 0; l < gitem->num_layers; l++)
 				{
+					LAYER *layer = 0;
 					MAPITEM_LAYER *layer_item = (MAPITEM_LAYER *)datafile_get_item(df, layers_start+gitem->start_layer+l, 0, 0);
 					if(!layer_item)
 						continue;
@@ -457,6 +458,8 @@ int MAP::load(const char *filename)
 						}
 						else
 							tiles = new LAYER_TILES(tilemap_item->width, tilemap_item->height);
+
+						layer = tiles;
 						
 						group->add_layer(tiles);
 						void *data = datafile_get_data(df, tilemap_item->data);
@@ -479,16 +482,20 @@ int MAP::load(const char *filename)
 					else if(layer_item->type == LAYERTYPE_QUADS)
 					{
 						MAPITEM_LAYER_QUADS *quads_item = (MAPITEM_LAYER_QUADS *)layer_item;
-						LAYER_QUADS *layer = new LAYER_QUADS;
-						layer->image = quads_item->image;
-						if(layer->image < -1 || layer->image >= images.len())
-							layer->image = -1;
+						LAYER_QUADS *quads = new LAYER_QUADS;
+						layer = quads;
+						quads->image = quads_item->image;
+						if(quads->image < -1 || quads->image >= images.len())
+							quads->image = -1;
 						void *data = datafile_get_data_swapped(df, quads_item->data);
-						group->add_layer(layer);
-						layer->quads.setsize(quads_item->num_quads);
-						mem_copy(layer->quads.getptr(), data, sizeof(QUAD)*quads_item->num_quads);
+						group->add_layer(quads);
+						quads->quads.setsize(quads_item->num_quads);
+						mem_copy(quads->quads.getptr(), data, sizeof(QUAD)*quads_item->num_quads);
 						datafile_unload_data(df, quads_item->data);
 					}
+					
+					if(layer)
+						layer->flags = layer_item->flags;
 				}
 			}
 		}
diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp
index a03e4e9e..81192521 100644
--- a/src/game/editor/ed_popups.cpp
+++ b/src/game/editor/ed_popups.cpp
@@ -178,12 +178,14 @@ int popup_layer(RECT view)
 	{
 		PROP_GROUP=0,
 		PROP_ORDER,
+		PROP_HQ,
 		NUM_PROPS,
 	};
 	
 	PROPERTY props[] = {
 		{"Group", editor.selected_group, PROPTYPE_INT_STEP, 0, editor.map.groups.len()-1},
 		{"Order", editor.selected_layer, PROPTYPE_INT_STEP, 0, current_group->layers.len()},
+		{"Detail", current_layer->flags&LAYERFLAG_DETAIL, PROPTYPE_BOOL, 0, 1},
 		{0},
 	};
 	
@@ -203,6 +205,12 @@ int popup_layer(RECT view)
 			editor.selected_layer = editor.map.groups[new_val]->layers.len()-1;
 		}
 	}
+	else if(prop == PROP_HQ)
+	{
+		current_layer->flags &= ~LAYERFLAG_DETAIL;
+		if(new_val)
+			current_layer->flags |= LAYERFLAG_DETAIL;
+	}
 		
 	return current_layer->render_properties(&view);
 }
diff --git a/src/game/g_mapitems.h b/src/game/g_mapitems.h
index d78cf66d..48ae492d 100644
--- a/src/game/g_mapitems.h
+++ b/src/game/g_mapitems.h
@@ -47,6 +47,8 @@ enum
 	TILEFLAG_VFLIP=1,
 	TILEFLAG_HFLIP=2,
 	
+	LAYERFLAG_DETAIL=1,
+	
 	ENTITY_OFFSET=255-16*4,
 };