コード例 #1
0
ファイル: graph_edit.cpp プロジェクト: UgisBrekis/godot
void GraphEdit::_connections_layer_draw() {

	Color activity_color = get_color("activity");
	//draw connections
	List<List<Connection>::Element *> to_erase;
	for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {

		NodePath fromnp(E->get().from);

		Node *from = get_node(fromnp);
		if (!from) {
			to_erase.push_back(E);
			continue;
		}

		GraphNode *gfrom = Object::cast_to<GraphNode>(from);

		if (!gfrom) {
			to_erase.push_back(E);
			continue;
		}

		NodePath tonp(E->get().to);
		Node *to = get_node(tonp);
		if (!to) {
			to_erase.push_back(E);
			continue;
		}

		GraphNode *gto = Object::cast_to<GraphNode>(to);

		if (!gto) {
			to_erase.push_back(E);
			continue;
		}

		Vector2 frompos = gfrom->get_connection_output_position(E->get().from_port) + gfrom->get_offset() * zoom;
		Color color = gfrom->get_connection_output_color(E->get().from_port);
		Vector2 topos = gto->get_connection_input_position(E->get().to_port) + gto->get_offset() * zoom;
		Color tocolor = gto->get_connection_input_color(E->get().to_port);

		if (E->get().activity > 0) {
			color = color.linear_interpolate(activity_color, E->get().activity);
			tocolor = tocolor.linear_interpolate(activity_color, E->get().activity);
		}
		_draw_cos_line(connections_layer, frompos, topos, color, tocolor);
	}

	while (to_erase.size()) {
		connections.erase(to_erase.front()->get());
		to_erase.pop_front();
	}
}
コード例 #2
0
ファイル: graph_edit.cpp プロジェクト: Scrik/godot
void GraphEdit::_top_layer_draw() {

	_update_scroll();

	if (connecting) {

		Node *fromn = get_node(connecting_from);
		ERR_FAIL_COND(!fromn);
		GraphNode *from = fromn->cast_to<GraphNode>();
		ERR_FAIL_COND(!from);
		Vector2 pos;
		if (connecting_out)
			pos=from->get_connection_output_pos(connecting_index);
		else
			pos=from->get_connection_input_pos(connecting_index);
		pos+=from->get_pos();

		Vector2 topos;
		topos=connecting_to;

		Color col=connecting_color;

		if (connecting_target) {
			col.r+=0.4;
			col.g+=0.4;
			col.b+=0.4;
		}
		_draw_cos_line(pos,topos,col);
	}

	List<List<Connection>::Element* > to_erase;
	for(List<Connection>::Element *E=connections.front();E;E=E->next()) {

		NodePath fromnp(E->get().from);

		Node * from = get_node(fromnp);
		if (!from) {
			to_erase.push_back(E);
			continue;
		}

		GraphNode *gfrom = from->cast_to<GraphNode>();

		if (!gfrom) {
			to_erase.push_back(E);
			continue;
		}

		NodePath tonp(E->get().to);
		Node * to = get_node(tonp);
		if (!to) {
			to_erase.push_back(E);
			continue;
		}

		GraphNode *gto = to->cast_to<GraphNode>();

		if (!gto) {
			to_erase.push_back(E);
			continue;
		}

		Vector2 frompos=gfrom->get_connection_output_pos(E->get().from_port)+gfrom->get_pos();
		Color color = gfrom->get_connection_output_color(E->get().from_port);
		Vector2 topos=gto->get_connection_input_pos(E->get().to_port)+gto->get_pos();
		_draw_cos_line(frompos,topos,color);

	}

	while(to_erase.size()) {
		connections.erase(to_erase.front()->get());
		to_erase.pop_front();
	}
	if (box_selecting)
		top_layer->draw_rect(box_selecting_rect,Color(0.7,0.7,1.0,0.3));
}