about summary refs log tree commit diff
path: root/src/game/editor
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 /src/game/editor
parentfaa13fe70371834c3e7e234875d32bb95d278c54 (diff)
downloadzcatch-45a047ce478e31297eba35e2e3121b25cabeae12.tar.gz
zcatch-45a047ce478e31297eba35e2e3121b25cabeae12.zip
fixed bug in text rendering. added option for detail layers
Diffstat (limited to 'src/game/editor')
-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
4 files changed, 60 insertions, 12 deletions
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);
 }