Beispiel #1
0
	bool dto_complex::parse( const rapidjson::Value& json )
	{
		if( json.IsObject() && json.HasMember( key() ) && json[key()].IsObject() )
		{
			for( auto& child : get_children() )
			{
				child->set_client( client() );
				if( !child->parse( json[key()] ) && !optional() )
				{
					return false;
				}
			}
			
			return true;
		}
		else if( json.IsObject() )
		{
			for( auto& child : get_children() )
			{
				child->set_client( client() );
				if( !child->parse( json ) && !optional()  )
				{
					return false;
				}
			}
			
			return true;
		}

		set_present( false );
		return optional();
	}
Beispiel #2
0
void GUI:: set_visible(bool visible) // shown or hidden
{ 
	this->visible = visible;
	for(int i = 0; i < get_children().size(); i++)
	{
		GUI * child = get_children()[i];
		child->set_visible (visible); // set child visibility to the same as parent
	}
}
Beispiel #3
0
View *View::get_child(size_t index)
{
    // size_t is always >= 0
    if (index < get_children()->get_count())
    {
        return (*get_children())[index];
    }

    // went outside bounds return  NULL
    return 0;
}
Beispiel #4
0
void UIWidget::mouse_down_func()
{
   if (disabled) return;

   // call this function on the children first
   for (auto &child : ElementID::recast_collection<UIWidget>(get_children()))
      child->mouse_down_func();

   // now do the execution of the function
   if (mouse_over)
   {
      mouse_down_on_over = true;
      on_mouse_down();
      focused = true;
      on_focus();
   }
   else
   {
      if (focused)
      {
         focused = false;
         on_blur();
      }
   }
}
Beispiel #5
0
// virtual
void Transform::DrawGlobalLights(X3DDrawContext* pDC)
{
	D3DXMATRIX transform = GetTransform();
	pDC->m_renderContext->PushModelView(transform * pDC->m_renderContext->modelViewMatrix());

	DrawGlobalLightsChildren(pDC, getChildrenField());

	pDC->m_renderContext->PopMatrix();

#if 0
	pDC->m_pGraphics3D->PushMatrix();

// P' = T * C * R * SR * S * -SR * -C * P

		pDC->m_pGraphics3D->TranslateTransform(m_T->m_value);
		pDC->m_pGraphics3D->TranslateTransform(m_C->m_value);
		pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_R->m_value.m_angle), m_R->m_value.m_axis);
		pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_SR->m_value.m_angle), m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->ScaleTransform(m_S->m_value);
		pDC->m_pGraphics3D->RotateTransform(gmDegrees(m_SR->m_value.m_angle), -m_SR->m_value.m_axis);
		pDC->m_pGraphics3D->TranslateTransform(-m_C->m_value);

	DrawGlobalLightsChildren(pDC, get_children());

	pDC->m_pGraphics3D->PopMatrix();
#endif
}
Beispiel #6
0
/* Prints the parse tree in JSON format. Note that the cl_obj
is NULL for the root node and the first can be found in its children. */
void prt_tree(cleri_grammar_t * grammar, const char * str)
{
    cleri_parse_t * pr = cleri_parse(grammar, str);
    if (pr == NULL)
        abort();

    printf("Test string '%s': %s\n", str, pr->is_valid ? "true" : "false");
    cleri_node_t * tree = pr->tree;

    /* Creates a dynamic buffer that will store the string to be parsed.
    If error occurs, NULL is returned and redirected to goto. */
    buffer_t * buf = buffer_create();
    if (buf == NULL)
        goto prt_tree;

    /* Check if the tree node (root node) has children and if true
    get_children() will be called. */
    if (cleri_node_has_children(tree))
    {
        cleri_children_t * child = tree->children;
        int rc = get_children(child, pr->str, buf);

        /* Prints the end result collected in buf->buf in JSON format including
        space, tabs and newlines */
        if (!rc)
        {
            prt_JSON(buf->buf);
        }
    }
    buffer_destroy(buf);

prt_tree:
    cleri_parse_free(pr);
}
Beispiel #7
0
void Object::render(GLint tick,GLuint render_flag,GLuint current_program,Comparator comp, DrawingMode drawing_mode) {
  for(auto buffer : buffers) {
    buffer.second->pre_draw_function();
  }
  for(auto uniform_container : uniform_containers) {
    uniform_container->pre_draw_function();
  }

  update_ubos_phase2();

  if(shape!=0 && !skip_rendering(render_flag,comp)) {
    glUseProgram(get_program_ident(current_program));
    UniformList::set_current_program_ident(get_program_ident(current_program));
    for(auto drawer : drawers) {
      drawer->pre_draw_function(this);
    }
    shape->draw(drawing_mode);
    glUseProgram(0);
    for(auto drawer : drawers) {
      drawer->post_draw_function(this);
    }
  }
  for(auto child : get_children()) {
    child->render(tick,render_flag,current_program,comp,drawing_mode);
  }
  for(auto buffer : buffers) {
      buffer.second->post_draw_function();
  }
  for(auto uniform_container : uniform_containers) {
    uniform_container->post_draw_function();
  }
  post_render_function(tick);
}
int rem_dir( uint32_t id )
{
	printf("Called rem_dir( id: %d )\n", id );	
	int i, children;
	struct FS_Directory* dir_list;

	children = get_num_children( id );

	// If there are no more children, delete directory
	if ( children == 0 )
	{
		printf("No children in id: %d\n", id );		
		rem_dir_leaf( id );
		return id;
	}

	// Call function recursively over all the child dirs
	dir_list = get_children( id );
	for ( i = 0; i < children; i++ ) 
		rem_dir( dir_list[i].id );
	free( dir_list );

	// Upon return, all children are deleted, now delete this
	printf("Returned for id: %d, and removing this\n", id );
	rem_dir_leaf( id );

// TODO handle errors
	
}
/********************************************************
 *	print_dir
 *
 * Takes the a directory's ID and prints the child
 * directories and files within.
 ********************************************************/
void print_dir( uint32_t id )
{
	uint32_t i, num_children, num_files;
	struct FS_Directory *children;
	struct FS_File *dir_files;

	num_children = get_num_children( id );
	if ( num_children )
	{
		children = get_children( id );
		for ( i = 0; i < num_children; i++ )
			printf("%s\n", children[i].name );
		free( children );
	}
	

	num_files = get_num_files( id );
	if ( num_files )
	{
		dir_files = get_files( id );
		for ( i = 0; i < num_files; i++ )
			printf("%s\n", dir_files[i].name );
		free( dir_files );
	}
		
}
Beispiel #10
0
void Barrack::tick(const float dt) {
	DestructableObject::tick(dt);

	if (!_broken && _spawn.tick(dt)) {
		if (hp == max_hp) { //nothing happens
			int tr;
			Config->get("objects." + registered_name + ".targeting-range", tr, 500);

			v2<float> pos, vel;
			if (!get_nearest(ai::Targets->infantry, tr, pos, vel, false))
				return; //skip spawning
		}
		
		int max_c;
		Config->get("objects." + registered_name + ".maximum-children", max_c, 5);
		int n = get_children(std::string());
		if (n < max_c) {
			v2<float>dpos;
			dpos.y = size.y / 2 + 16; //fixme: use debiloids size here.
			
			Object * o = spawn(_object, _animation, dpos);
			o->copy_special_owners(this);
			play_now("spawn");
		}
	}
}
Beispiel #11
0
void UIWidget::draw_func()
{
   if (surface_area) surface_area->placement.start_transform();

   on_draw();

   std::vector<UIWidget *> elements = ElementID::recast_collection<UIWidget>(get_children());
   std::reverse(elements.begin(), elements.end());

   for (auto &child : elements) child->draw_func();

   // draws the focus rectangle if it's focused
   /*
   if (focused && gimmie_super_screen()->draw_focused_outline)
   {
      al_draw_rounded_rectangle(0, 0, surface_area->placement.size.x, surface_area->placement.size.y, 3, 3, color::color(color::black, 0.2), 5);
      al_draw_rounded_rectangle(0, 0, surface_area->placement.size.x, surface_area->placement.size.y, 3, 3, color::mix(gimmie_super_screen()->focused_outline_color, color::purple, 0.6+0.4*sin(Framework::time_now*3)), 1.5);
   }
   */

   if (surface_area) surface_area->placement.restore_transform();

   // draws the collision shape (for debugging)
   //surface_area->draw_bounding_area();
}
Beispiel #12
0
    /**
     * Search a Node with `data` (Add if not exists) and return it.
     *
     * @param data The data for search or add.
     * @return The Node.
     */
    Node* get_or_add_children(std::string data) {
        Node *node = get_children(data);

        if (node != NULL) {
            return node;
        }

        return add_children(data);
    }
Beispiel #13
0
void UIWidget::key_char_func()
{
   if (disabled) return;

   for (auto &child : ElementID::recast_collection<UIWidget>(get_children()))
      child->key_char_func();

   on_key_char();
}
Beispiel #14
0
void PLodNode::update_cache() {
  if (geometry_changed_) {
    if (geometry_description_ != "") {
      if (!GeometryDatabase::instance()->contains(geometry_description_)) {
        GeometryDescription desc(geometry_description_);
        try {
          gua::LodLoader loader;
          loader.load_lod_pointcloud(desc.filepath(), desc.flags());
        } catch (std::exception& e) {
          Logger::LOG_WARNING
              << "PLodNode::update_cache(): Loading failed from "
              << desc.filepath() << " : " << e.what() << std::endl;
        }
      }
      geometry_ = std::dynamic_pointer_cast<LodResource>(
          GeometryDatabase::instance()->lookup(geometry_description_));

      if (!geometry_) {
        Logger::LOG_WARNING
            << "Failed to get LodResource for " << geometry_description_
            << ": The data base entry is of wrong type!" << std::endl;
      }
    }

    geometry_changed_ = false;
  }

  // modified version of Node::update_cache -> add local transformation
  if (self_dirty_) {
    math::mat4 old_world_trans(world_transform_);

    if (is_root()) {
      world_transform_ = transform_ * geometry_->local_transform();
    } else {
      world_transform_ = get_parent()->get_world_transform() * transform_ *
                         geometry_->local_transform();
    }

    update_bounding_box();

    if (world_transform_ != old_world_trans) {
      on_world_transform_changed.emit(world_transform_);
    }

    self_dirty_ = false; 
  }

  if (child_dirty_) {
    for (auto const& child : get_children()) {
      child->update_cache();
    }

    update_bounding_box();

    child_dirty_ = false;
  }
}
Beispiel #15
0
void UIWidget::joy_axis_func()
{
   if (disabled) return;

   for (auto &child : ElementID::recast_collection<UIWidget>(get_children()))
      child->joy_axis_func();

   on_joy_axis();
}
size_t pqrs_xml_compiler_get_preferences_number_node_tree_children_count(const pqrs_xml_compiler_preferences_number_node_tree* p) {
  auto node_tree = cast_to_preferences_number_node_tree(p);
  if (!node_tree) return 0;

  auto children = node_tree->get_children();
  if (!children) return 0;

  return children->size();
}
const pqrs_xml_compiler_preferences_number_node_tree* pqrs_xml_compiler_get_preferences_number_node_tree_child(const pqrs_xml_compiler_preferences_number_node_tree* p, size_t index) {
  auto node_tree = cast_to_preferences_number_node_tree(p);
  if (!node_tree) return nullptr;

  auto children = node_tree->get_children();
  if (!children) return nullptr;
  if (index >= children->size()) return nullptr;

  return reinterpret_cast<const pqrs_xml_compiler_preferences_number_node_tree*>(((*children)[index]).get());
}
Beispiel #18
0
void SpotLightNode::update_bounding_box() const {
    auto geometry_bbox(GeometryDatabase::instance()->lookup(
        "gua_light_cone_proxy")->get_bounding_box());

    bounding_box_ = transform(geometry_bbox, world_transform_);

    for (auto child : get_children()) {
        bounding_box_.expandBy(child->get_bounding_box());
    }
}
Beispiel #19
0
std::vector<unsigned int> View::getUnselectedChildrenIndexes()
{
    const std::vector<unsigned int> selectedIndexes = getSelectedChildrenIndexes();
    std::vector<unsigned int> unselectedIndexes;
    ranges::set_difference(ranges::view::iota(0, get_children().size()),
                           selectedIndexes,
                           ranges::back_inserter(unselectedIndexes));

    return unselectedIndexes;
}
Beispiel #20
0
void UIWidget::key_down_func()
{
   if (disabled) return;

   // call this function on the children first
   for (auto &child : ElementID::recast_collection<UIWidget>(get_children()))
      child->key_down_func();

   // then call on self
   on_key_down();
}
Beispiel #21
0
// Free entire tree
void free_tree(Node *root) {
    if(root != NULL) {
        int i;
        int num_children = get_num_children(root);
        Node **children = get_children(root);
        for(i = 0; i < num_children; i++) {
            free_tree(children[i]);
        }
        free_node(root);
    }
}
Beispiel #22
0
void Object::perform_action(GLint tick) {
  
  for(auto child : get_children()) {
    child->perform_action(tick);
  }
  action_phase_function();
  for(auto action : action_vector) {
    action->perform_action(this,tick);
  }
  //update_ubos_phase1();
}
Beispiel #23
0
void PLodNode::update_bounding_box() const {
  if (geometry_) {
    auto geometry_bbox(geometry_->get_bounding_box());
    bounding_box_ = transform(geometry_bbox, world_transform_);

    for (auto child : get_children()) {
      bounding_box_.expandBy(child->get_bounding_box());
    }
  } else {
    Node::update_bounding_box();
  }
}
Beispiel #24
0
void  load_trans_couples( FILE *fp )
{
	char *buf_ptr, buffer[BUFFER_SIZE] ;
	int parameter ;
	short done = FALSE ;
	Couple *cptr ;
	int cref ;
	short block ;
	char *chr_ptr ;		/* used for pointing to references		*/
	int children[MAX_CHILDREN+1] ;
	short i ;

	buffer[BUFFER_SIZE - 1] = '\0' ;
	while( fgets( buffer, BUFFER_SIZE - 1, fp ), !feof( fp ) && !done )
	{
		buf_ptr = buffer ;
		buffer[strlen( buffer ) - 1] = '\0' ;
		parameter = (*buf_ptr++<<16) + (*buf_ptr++<<8) + *buf_ptr++ ;
		switch( parameter )
		{
			case 'ref' :
				cref = atoi( buf_ptr ) ;
				cref += trans_coup_oset ;
				cptr = get_cdata_ptr( cref, &block ) ;
				break ;
			case 'end' :
				cptr->reference = cref ;
				if( cptr->male_reference )
					cptr->male_reference += trans_pers_oset ;
				if( cptr->female_reference )
					cptr->female_reference += trans_pers_oset ;
				if( chr_ptr = cptr->children )
				{
					get_children( cptr, children ) ;
					i = 0 ;
					while( children[i] )
						put_ref( children[i++] + trans_pers_oset, &chr_ptr ) ;
				}
				add_to_cidx( cref, cptr ) ;
				cblock_changed[block] = TRUE ;
				next_couple++ ;
				break ;
			case 'coe' :
				done = TRUE ;
				break ;
			default :
				load_cparam( parameter, cptr, buf_ptr, block ) ;
				break ;
		}
	}
	cidx_changed = TRUE ;
}
Beispiel #25
0
void Object::set_world(World * world) {
  if(world != 0) {
    world->register_object(this);
  }
  if(this->world != 0) {
    this->world->deregister_object(this);
  }
  this->world = world;

  for(auto child : get_children()) {
    child->set_world(world);
  }
}
Beispiel #26
0
void VolumeNode::update_bounding_box() const {
  if (data.get_volume() != "") {
    auto geometry_bbox(GeometryDatabase::instance()
                           ->lookup(data.get_volume())
                           ->get_bounding_box());
    bounding_box_ = transform(geometry_bbox, world_transform_);

    for (auto child : get_children()) {
      bounding_box_.expandBy(child->get_bounding_box());
    }
  } else {
    Node::update_bounding_box();
  }
}
Beispiel #27
0
void UIWidget::joy_down_func()
{
   if (disabled) return;

   for (auto &child : ElementID::recast_collection<UIWidget>(get_children()))
      child->joy_down_func();

   if (mouse_over && Framework::current_event->joystick.button == 0)
   {
      set_as_focused();
   }

   on_joy_down();
}
Beispiel #28
0
node_ptr node::from_xml(xml_node const& xml, fontset_map const& fontsets)
{
    auto list = std::make_shared<list_node>();
    for (auto const& node : xml)
    {
        if (node.name() == "Placement")
            continue;
        node_ptr n = registry::instance().from_xml(node,fontsets);
        if (n) list->push_back(n);
    }
    if (list->get_children().size() == 1)
    {
        return list->get_children()[0];
    }
    else if (list->get_children().size() > 1)
    {
        return list;
    }
    else
    {
        return nullptr;
    }
}
Beispiel #29
0
void UIWidget::primary_timer_func()
{
   if (disabled) return;

   on_timer();

   std::vector<UIWidget *> children = ElementID::recast_collection<UIWidget>(get_children());

   for (auto &child : children)
      child->primary_timer_func();

   // delete the widgets who request deletion
   for (auto &child : children)
      if (child->delete_me) delete child;
}
Beispiel #30
0
Datei: dary.c Projekt: tkng/dary
dary_status
dary_get_children(dary *da, int index, int **loc)
{
   int *children;

   children = malloc(sizeof(int) * (256 + 1));
   if(children == NULL) {
      return DARY_STATUS_NO_MEMORY;
   }

   get_children(da, index, children);

   *loc = children;

   return DARY_STATUS_SUCCESS;
}