Ejemplo n.º 1
0
Matrix32 Node2D::get_relative_transform(const Node *p_parent) const {

	if (p_parent==this)
		return Matrix32();

	Node2D *parent_2d = get_parent()->cast_to<Node2D>();
	ERR_FAIL_COND_V(!parent_2d,Matrix32());
	if (p_parent==parent_2d)
		return get_transform();
	else
		return parent_2d->get_relative_transform(p_parent) * get_transform();
}
Ejemplo n.º 2
0
String CollisionShape::get_configuration_warning() const {

	if (!get_parent()->cast_to<CollisionObject>()) {
		return TTR("CollisionShape only serves to provide a collision shape to a CollisionObject derived node. Please only use it as a child of Area, StaticBody, RigidBody, KinematicBody, etc. to give them a shape.");
	}

	if (!shape.is_valid()) {
		return TTR("A shape must be provided for CollisionShape to function. Please create a shape resource for it!");
	}

	return String();
}
Ejemplo n.º 3
0
void CollisionPolygon2D::_update_parent() {

	if (!can_update_body)
		return;
	Node *parent = get_parent();
	if (!parent)
		return;
	CollisionObject2D *co = parent->cast_to<CollisionObject2D>();
	if (!co)
		return;
	co->_update_shapes_from_children();
}
Ejemplo n.º 4
0
/* 上一节点 */
static rbtree_node_st *rb_prev(const rbtree_node_st *node)
{
    rbtree_node_st *parent;

    if (node->left)
        return get_last(node->left);

    while ((parent = get_parent(node)) && parent->left == node)
        node = parent;

    return parent;
}
Ejemplo n.º 5
0
String CollisionPolygon2D::get_configuration_warning() const {

	if (!get_parent()->cast_to<CollisionObject2D>()) {
		return TTR("CollisionPolygon2D only serves to provide a collision shape to a CollisionObject2D derived node. Please only use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
	}

	if (polygon.empty()) {
		return TTR("An empty CollisionPolygon2D has no effect on collision.");
	}

	return String();
}
Ejemplo n.º 6
0
void CollisionPolygon2D::set_trigger(bool p_trigger) {

	trigger=p_trigger;
	_update_parent();
	if (!can_update_body && is_inside_tree() && shape_from>=0 && shape_to>=0) {
		CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
		for(int i=shape_from;i<=shape_to;i++) {
			co->set_shape_as_trigger(i,p_trigger);
		}

	}
}
Ejemplo n.º 7
0
 ///
 /// Initializes a new instance of the class by computing the set of
 /// nodes in the path to the root. The specified node is included in the
 /// result, but the root node is not. For example, computing a tree path
 /// for node 'D' for the tree, "((B:2,(C:4,D:5)n1:3)n2:1)A;" results in
 /// the container (D, n1, n2).
 ///
 explicit basic_tree_path(
         const node_type & node) ///< The node to measure.
     : _map ()
 {
     //
     // Loop toward the root node, starting at the specified node, but
     // do not include the root node in the result; in each iteration,
     // accumulate the nodes traversed.
     //
     for (auto n = &node; !n->is_root(); n = n->get_parent())
         _map[n->get_id()] = n;
 }
Ejemplo n.º 8
0
String ARVRCamera::get_configuration_warning() const {
	if (!is_visible() || !is_inside_tree())
		return String();

	// must be child node of ARVROrigin!
	ARVROrigin *origin = get_parent()->cast_to<ARVROrigin>();
	if (origin == NULL) {
		return TTR("ARVRCamera must have an ARVROrigin node as its parent");
	};

	return String();
};
Ejemplo n.º 9
0
void CollisionShape::set_trigger(bool p_trigger) {

	trigger = p_trigger;
	if (updating_body) {
		_update_body();
	} else if (can_update_body && update_shape_index >= 0 && is_inside_tree()) {
		CollisionObject *co = get_parent()->cast_to<CollisionObject>();
		if (co) {
			co->set_shape_as_trigger(update_shape_index, p_trigger);
		}
	}
}
Ejemplo n.º 10
0
void Viewport::_parent_visibility_changed() {

	Node *parent = get_parent();

	if (parent && parent->cast_to<Control>()) {

		Control *c = parent->cast_to<Control>();
		VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,c->is_visible());
	}


}
Ejemplo n.º 11
0
void VisibilityEnabler2D::_notification(int p_what){

	if (p_what==NOTIFICATION_ENTER_TREE) {

		if (get_tree()->is_editor_hint())
			return;


		Node *from = this;
		//find where current scene starts
		while(from->get_parent() && from->get_filename()==String())
			from=from->get_parent();

		_find_nodes(from);

		if (enabler[ENABLER_PARENT_FIXED_PROCESS] && get_parent())
			get_parent()->set_fixed_process(false);
		if (enabler[ENABLER_PARENT_PROCESS] && get_parent())
			get_parent()->set_process(false);


	}

	if (p_what==NOTIFICATION_EXIT_TREE) {

		if (get_tree()->is_editor_hint())
			return;


		for (Map<Node*,Variant>::Element *E=nodes.front();E;E=E->next()) {

			if (!visible)
				_change_node_state(E->key(),true);
			E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed");
		}

		nodes.clear();

	}
}
Ejemplo n.º 12
0
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {

	if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {

		if (!get_parent() || !is_visible_in_tree() || is_disabled())
			return;

		bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));

		if (popup->activate_item_by_event(p_event, global_only))
			accept_event();
	}
}
Ejemplo n.º 13
0
Gobby::TaskExportHtml::TaskExportHtml(FileCommands& file_commands,
                                      TextSessionView& view):
	Task(file_commands),
	m_file_dialog(get_file_chooser(), get_parent(),
		Glib::ustring::compose(
			_("Choose a location to export document \"%1\" to"),
			view.get_title()),
		Gtk::FILE_CHOOSER_ACTION_SAVE),
	m_view(&view), m_running(false)
{
	get_folder().signal_document_removed().connect(
		sigc::mem_fun(*this, &TaskExportHtml::on_document_removed));
}
Ejemplo n.º 14
0
void MenuButton::_unhandled_key_input(InputEvent p_event) {


	if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYSTICK_BUTTON)) {

		if (!get_parent() || !is_visible() || is_disabled())
			return;


		if (popup->activate_item_by_event(p_event))
			accept_event();
	}
}
Ejemplo n.º 15
0
Transform2D Node2D::get_relative_transform_to_parent(const Node *p_parent) const {

	if (p_parent == this)
		return Transform2D();

	Node2D *parent_2d = Object::cast_to<Node2D>(get_parent());

	ERR_FAIL_COND_V(!parent_2d, Transform2D());
	if (p_parent == parent_2d)
		return get_transform();
	else
		return parent_2d->get_relative_transform_to_parent(p_parent) * get_transform();
}
Ejemplo n.º 16
0
void cell::set_comment(const xlnt::comment &c)
{
    if (c.d_ != d_->comment_.get())
    {
        throw xlnt::attribute_error();
    }

    if (!has_comment())
    {
        get_parent().increment_comments();
    }

    *get_comment().d_ = *c.d_;
}
Ejemplo n.º 17
0
void BoneAttachment::_check_unbind() {

	if (bound) {

		if (Skeleton *sk = Object::cast_to<Skeleton>(get_parent())) {

			int idx = sk->find_bone(bone_name);
			if (idx != -1) {
				sk->unbind_child_node_from_bone(idx, this);
			}
		}
		bound = false;
	}
}
Ejemplo n.º 18
0
 /// for debug only
 const char *visualize(const node_type *id0) const
 {
     static char buf[256];
     sprintf(buf, "%d skip: %d pt: %d ptId: %d lnk0: %d tag0: %d lnk1: %d tag1: %d\n",
         this - id0,
         get_skip(),
         get_parent() - id0,
         get_parent_id(),
         get_xlink(0) - id0,
         get_xtag(0),
         get_xlink(1) - id0,
         get_xtag(1));
     return buf;
 }
Ejemplo n.º 19
0
void precolateUp(genre_heap* heap, int childIndex) {
	int parentIndex = get_parent(heap, childIndex);
	if (heap->genre[parentIndex].genre_count < heap->genre[childIndex].genre_count && parentIndex >= 0) {
		genre temp = heap->genre[parentIndex];
		heap->genre[parentIndex] = heap->genre[childIndex];
		heap->genre[childIndex] = temp;

		precolateUp(heap, parentIndex);


	}
	

}
Ejemplo n.º 20
0
// --------------------------------------------------------
// draw this window
// --------------------------------------------------------
// re-size the button to fit the child windows.
void t_button::update_size()
{
	if (!is_open())
		return;

	// get our own screen rect, and force the origin of the rect to match.
	t_screen_rect rect = compute_size();

	update_transparency();
	
	// remap rectangle to parent's client coordinates, and change size.
	rect = get_parent()->to_client( rect );
	move( rect, false );
}
Ejemplo n.º 21
0
static int get_sha1_1(const char *name, int len, unsigned char *sha1)
{
	int parent, ret;
	const char *cp;

	/* foo^[0-9] or foo^ (== foo^1); we do not do more than 9 parents. */
	if (len > 2 && name[len-2] == '^' &&
	    name[len-1] >= '0' && name[len-1] <= '9') {
		parent = name[len-1] - '0';
		len -= 2;
	}
	else if (len > 1 && name[len-1] == '^') {
		parent = 1;
		len--;
	} else
		parent = -1;

	if (parent >= 0)
		return get_parent(name, len, sha1, parent);

	/* "name~3" is "name^^^",
	 * "name~12" is "name^^^^^^^^^^^^", and
	 * "name~" and "name~0" are name -- not "name^0"!
	 */
	parent = 0;
	for (cp = name + len - 1; name <= cp; cp--) {
		int ch = *cp;
		if ('0' <= ch && ch <= '9')
			continue;
		if (ch != '~')
			parent = -1;
		break;
	}
	if (!parent && *cp == '~') {
		int len1 = cp - name;
		cp++;
		while (cp < name + len)
			parent = parent * 10 + *cp++ - '0';
		return get_nth_ancestor(name, len1, sha1, parent);
	}

	ret = peel_onion(name, len, sha1);
	if (!ret)
		return 0;

	ret = get_sha1_basic(name, len, sha1);
	if (!ret)
		return 0;
	return get_short_sha1(name, len, sha1, 0);
}
Ejemplo n.º 22
0
static int mhdriver_create_folder(mailsession * session, const char * mb)
{
  int r;
  struct mailmh_folder * parent;
  const char * name;
  
  r = get_parent(session, mb, &parent, &name);
  if (r != MAIL_NO_ERROR)
    return r;

  r = mailmh_folder_add_subfolder(parent, name);
  
  return mhdriver_mh_error_to_mail_error(r);
}
Ejemplo n.º 23
0
void BoneAttachment::_get_property_list( List<PropertyInfo>* p_list ) const{

	Skeleton *parent=NULL;
	if(get_parent())
		parent=get_parent()->cast_to<Skeleton>();

	if (parent) {

		String names;
		for(int i=0;i<parent->get_bone_count();i++) {
			if(i>0)
				names+=",";
			names+=parent->get_bone_name(i);
		}

		p_list->push_back(PropertyInfo(Variant::STRING,"bone_name",PROPERTY_HINT_ENUM,names));
	} else {

		p_list->push_back(PropertyInfo(Variant::STRING,"bone_name"));

	}

}
Ejemplo n.º 24
0
bool marathon_group::remove(const std::string& id)
{
	if(id == get_id())
	{
		throw sinsp_exception("Invalid access - group can not remove itself.");
	}

	if(ptr_t group = get_parent(id))
	{
		return group->remove_group(id);
	}

	return false;
}
Ejemplo n.º 25
0
/**
 * Get previous item in the tree, following natural order.
 */
rbnode_t *
erbtree_prev(const rbnode_t *node)
{
	rbnode_t *parent;

	g_assert(node != NULL);

	if (node->left != NULL)
		return get_last(node->left);

	while (NULL != (parent = get_parent(node)) && parent->left == node)
		node = parent;
	return parent;
}
Ejemplo n.º 26
0
t_quest_log_window::t_quest_log_window( t_window* parent, t_adventure_frame *frame_ptr )
    : t_window( k_completely_transparent, parent )
{
    m_frame = frame_ptr;
    m_map = frame_ptr->get_map();
    m_bitmaps_ptr = k_quest_log_bitmaps.get();

    t_screen_rect rect;

    /*
    ** Create background bitmap.
    */
    t_bitmap_layer const*   layer;
    t_window*               background;
    t_window*               window_ptr;
    t_screen_point          origin(0,0);

    layer = m_bitmaps_ptr->find( "background" );
    background = new t_bitmap_layer_window( layer, origin, this );
    layer = m_bitmaps_ptr->find( "title_scroll" );
    window_ptr = new t_bitmap_layer_window( layer, origin, this );

    // Set position.
    t_screen_rect parent_rect;
    parent_rect = get_parent()->get_client_rect();
    rect = m_bitmaps_ptr->get_rect();
    rect += (parent_rect.size() - rect.size()) / 2;
    init( rect );

    // Add buttons.
    t_button* button_ptr;
    t_help_block const& shared_help_block = get_help_block( "shared" );

    rect = m_bitmaps_ptr->find( "close_button" )->get_rect();
    button_ptr = new t_button( g_ok_button.get(), rect.top_left(), this );
    button_ptr->set_click_handler( bound_handler( *this, &t_quest_log_window::close_clicked ));
    set_help( button_ptr, shared_help_block, "ok" );

    // Text windows.
    t_text_window*  text_window_ptr;

    rect = m_bitmaps_ptr->find( "title" )->get_rect();
    text_window_ptr  = new t_text_window( get_font( rect.height() ), rect, this, "", t_pixel_24(0,0,0) );
    text_window_ptr->set_text ( k_text_title );
    text_window_ptr->set_center_horizontal();

    gather_data();
    create_quests_windows();
    show_quests( 0 );
}
Ejemplo n.º 27
0
void BrainsComponent::follow_the_plan()
{
    if (not task_.current || task_.plan.empty()) {
        return; // nothing to do
    }

    // if plan is fulfilled
    auto wo            = AnimateObject::get_world();
    ai::Order::Ptr ord = task_.current;
    ai::Context ctx    = ord->ctx_; // copy
    ctx.actor_         = get_parent();
    if (wo->conditions_stand_true(ord->desired_, ctx)) {
        // we do not desire anymore that which came true
        wo->report_fulfilled(ord->id_, PlanResult::Success);
        task_.current = {};
        task_.plan.clear();
        return;
    }

    Q_ASSERT(not task_.plan.empty());
    auto& step = task_.plan.front();
//    qDebug() << "brains: follow plan" << *get_parent()
//             << " step=" << step.action_;

    switch (step.action_) {
    case ai::ActionType::None: // no action (this should not be in plan either)
        finish_plan_step();
        return;
    case ai::ActionType::Mine: {
            auto dst = step.arg_.get_pos();
            plan_step_mine(dst);
        } break;
    case ai::ActionType::CreateRamp: {
            auto dst = step.arg_.get_pos();
            plan_step_create_ramp(dst);
        } break;
    case ai::ActionType::Move: {
            auto dst = step.arg_.get_pos();
            if (plan_step_move(dst, MovePrecision::Adjacent)) return;
        } break;
    case ai::ActionType::MoveClose: {
            auto dst = step.arg_.get_pos();
            if (plan_step_move(dst, MovePrecision::AdjacentDepth)) return;
        } break;
    }

    if (task_.plan.empty()) {
        finish_plan(PlanResult::Done);
    }
}
Ejemplo n.º 28
0
 void Element::set_plane(const math::VectorPair3 &p)
 {
   if (Element *parent = get_parent())
     {
       const math::Transform<3> &t = _system->get_local_transform(*parent);
       _transform.set_translation(t.transform(p[0]));
       set_local_direction(t.transform_linear(p[1]));
     }
   else
     {
       set_local_plane(p);
     }
   // system_moved(); called in set_local_direction
 }
Ejemplo n.º 29
0
void t_score_dialog::initialize()
{
	// calculate the final scores
	calculate_scores( m_map, m_winner_team, m_scores );

	m_layout = g_layout.get();
	m_difficulty_icons = g_difficulty_icons.get();

	//////////////////////////////////////////////////////////////////
 	// find dimensions & center
	t_screen_point        origin(0,0);
	t_bitmap_layer const* layer = m_layout->find( "background" );
	t_screen_rect		  rect = layer->get_rect();

	set_bitmap( layer );
	rect += t_screen_point( (get_parent()->get_width() - rect.width()) / 2, 
		                           (get_parent()->get_height() - rect.height()) / 2 );
	move( rect );
	set_drop_shadow();

	//////////////////////////////////////////////////////////////////

	// add title
	t_text_window* window;
	layer = m_layout->find( "title" );
	rect = layer->get_rect();
	window = new t_text_window( get_font( rect.height() ), rect, this, 
		                         k_score_title, t_pixel_24(0,0,0) );
	window->set_center_horizontal();
	window->set_center_vertical();
	window->set_drop_shadow( true, t_pixel_24(200,200,200));

	create_text();
	create_icons();
	create_buttons();
}
Ejemplo n.º 30
0
/**
 * Get next item in the tree, following natural order.
 */
rbnode_t *
erbtree_next(const rbnode_t *node)
{
	rbnode_t *parent;

	g_assert(node != NULL);

	if (node->right != NULL)
		return get_first(node->right);

	while (NULL != (parent = get_parent(node)) && parent->right == node)
		node = parent;

	return parent;
}