static t_litem *print_list_item(t_dir_item *item, int *total, char *params) { t_litem *line; int i; i = 0; line = NULL; t_litem_push(&line, get_rights(item->prop.st_mode)); t_litem_push(&line, t_litem_new(ft_itoa(item->prop.st_nlink))); if (getpwuid(item->prop.st_uid) != NULL) t_litem_push(&line, t_litem_new(ft_strdup(getpwuid(item->prop.st_uid)->pw_name))); else t_litem_push(&line, t_litem_new(ft_itoa((long)(item->prop.st_uid)))); if (getgrgid(item->prop.st_gid) != NULL) t_litem_push(&line, t_litem_new(ft_strdup(getgrgid(item->prop.st_gid)->gr_name))); else t_litem_push(&line, t_litem_new(ft_itoa((long)(item->prop.st_gid)))); if (S_ISCHR(item->prop.st_mode) || S_ISBLK(item->prop.st_mode)) t_litem_push(&line, t_litem_new(get_maj_min(item->prop.st_rdev))); else t_litem_push(&line, t_litem_new(ft_itoa((long)item->prop.st_size))); t_litem_push(&line, get_date(item)); t_litem_push(&line, t_litem_new(get_item_name(item, params))); *(total) += (int)(item->prop.st_blocks); return (line); }
virtual bool context_get_display( unsigned int index, metadb_handle_list_cref tracks, pfc::string_base& out, unsigned int& /*displayflags*/, const GUID& /*caller*/ ) { switch(index) { case Items::ReplaceWithBestVersion: { out = "Replace with best version of track"; if(tracks.get_count() > 1) { out.add_string("s"); } return true; } default: { // Nothing wants to customise the display of the item; let the regular name be displayed. get_item_name(index, out); return true; } } }
/** * \brief Draws the treasure. * \param dst_surface the surface where to draw * \param x the treasure x position on this surface * \param y the treasure y position on this surface */ void Treasure::draw(Surface& dst_surface, int x, int y) { if (sprite == NULL) { // create the sprite only if needed (many treasures are actually never drawn) sprite = new Sprite("entities/items"); sprite->set_current_animation(get_item_name()); sprite->set_current_direction(get_variant() - 1); } // draw the item sprite->draw(dst_surface, x, y); }
/** * \brief Draws the treasure. * \param dst_surface The surface where to draw. * \param x The treasure x position on this surface. * \param y The treasure y position on this surface. */ void Treasure::draw(const SurfacePtr& dst_surface, int x, int y) { if (sprite == nullptr) { // Create the sprite only if needed (many treasures are actually // never drawn). sprite = std::make_shared<Sprite>("entities/items"); sprite->set_current_animation(get_item_name()); sprite->set_current_direction(get_variant() - 1); } // Draw the item. sprite->draw(dst_surface, x, y); }
int get_burn_parts_from_img(HIMAGE hImg, ConfigPara_t* pcfgPara) { BurnParts_t* pburnPartsCfg = &pcfgPara->burnParts; int i = 0; int ret = 0; int burnNum = 0; const int totalItemNum = get_total_itemnr(hImg); for (i = 0; i < totalItemNum; i++) { const char* main_type = NULL; const char* sub_type = NULL; ret = get_item_name(hImg, i, &main_type, &sub_type); if (ret) { DWN_ERR("Exception:fail to get item name!\n"); return __LINE__; } if (!strcmp("PARTITION", main_type)) { char* partName = pburnPartsCfg->burnParts[burnNum]; if (!strcmp("bootloader", sub_type)) continue; if (!strcmp(AML_SYS_RECOVERY_PART, sub_type)) { if (OPTIMUS_WORK_MODE_SYS_RECOVERY == optimus_work_mode_get()) continue; } strcpy(partName, sub_type); pburnPartsCfg->bitsMap4BurnParts |= 1U<<burnNum; burnNum += 1; } } if (burnNum) { pburnPartsCfg->burn_num = burnNum; ret = check_cfg_burn_parts(pcfgPara); if (ret) { DWN_ERR("Fail in check burn parts\n"); return __LINE__; } print_burn_parts_para(pburnPartsCfg); } return OPT_DOWN_OK; }
void course_render_init() { free(treeLocsOrderedByZ); tree_t* treeLocs = get_tree_locs(); int numTrees = get_num_trees(); treeLocsOrderedByZ = (tree_t*)malloc(sizeof(tree_t)*numTrees); memcpy(treeLocsOrderedByZ,treeLocs,sizeof(tree_t)*numTrees); order_trees_by_z(treeLocsOrderedByZ,numTrees); first_tree_to_check=0; itemLocs = get_item_locs(); numItems = get_num_items(); int i; for (i=0;i<numItems;i++) { if (itemLocs[i].item_type == kStartType) { char* name = get_item_name(itemLocs[i].item_type); TRDebugLog("item name : %s, itemType = %d coord x = %f et coord y = %f\n",name, itemLocs[i].item_type,itemLocs[i].ray.pt.x,itemLocs[i].ray.pt.y); } } }
bool MeshLibrary::_get(const StringName& p_name,Variant &r_ret) const { String name=p_name; int idx = name.get_slice("/",1).to_int(); ERR_FAIL_COND_V(!item_map.has(idx),false); String what = name.get_slice("/",2); if(what=="name") r_ret= get_item_name(idx); else if(what=="mesh") r_ret= get_item_mesh(idx); else if(what=="shape") r_ret= get_item_shape(idx); else if(what=="preview") r_ret= get_item_preview(idx); else return false; return true; }
void MainMenu::build_menu_item(Fl_XmlNode *node) { if(!node) return; int type = str_to_type(node->get_attribute("Type")); if(type==ITEM_NONE) return; Fl_Widget *w=0; EItemGroup *g=0; EItem *i=0; switch(type) { case ITEM_EXEC: i = new EItem(this); i->callback((Fl_Callback*)cb_exec_item); set_exec(i, node->get_attribute("Exec")); i->image(run_pix); w = (Fl_Widget *)i; break; case ITEM_APPDIR: g = new EItemGroup(this, APP_GROUP); g->image(programs_pix); g->dir(get_item_dir(node)); break; case ITEM_SUBDIR: g = new EItemGroup(this, APP_GROUP); g->image(programs_pix); break; case ITEM_FILEBROWSER: g = new EItemGroup(this, BROWSER_GROUP); g->dir(get_item_dir(node)); g->image(find_pix); break; case ITEM_DIVIDER: w = (Fl_Widget *)new Fl_Menu_Divider(); break; } if(g) { g->begin(); w = (Fl_Widget*)g; } Fl_Image *im=0; if(node->has_attribute("Icon")) { im = find_image(node->get_attribute("Icon")); } else { Fl_String im_path(node->get_attribute("Exec")); im_path += ".png"; im = find_image(im_path); } if(im) w->image(im); Fl_String label = get_item_name(node); w->label(label); for(uint n=0; n<node->children(); n++) { Fl_XmlNode *np = node->child(n); if((np->is_element() || np->is_leaf()) && np->name()=="Item") build_menu_item(np); } if(w->is_group()) ((Fl_Group*)w)->end(); }
/* This should probably go to a gworld first, or something */ static void update_inventory_panel( boolean force_redraw) { short section_items[NUMBER_OF_ITEMS]; short section_counts[NUMBER_OF_ITEMS]; short section_count, loop; short item_type, current_row; if(INVENTORY_IS_DIRTY(current_player) || force_redraw) { screen_rectangle *destination= get_interface_rectangle(_inventory_rect); screen_rectangle text_rectangle; short total_inventory_line_count= count_inventory_lines(current_player_index); short max_lines= max_displayable_inventory_lines(); /* Recalculate and redraw.. */ item_type= GET_CURRENT_INVENTORY_SCREEN(current_player); /* Reset the row.. */ current_row= 0; if(item_type!=_network_statistics) { /* Get the types and names */ calculate_player_item_array(current_player_index, item_type, section_items, section_counts, §ion_count); } /* Draw the header. */ get_header_name(temporary, item_type); draw_inventory_header(temporary, current_row++); /* Draw the network time elapsed if timed game. */ if (item_type==_network_statistics && dynamic_world->game_information.game_time_remaining<60*60*TICKS_PER_SECOND) { long seconds= dynamic_world->game_information.game_time_remaining/TICKS_PER_SECOND; screen_rectangle destination; sprintf(temporary, "% 2d:%02d", seconds/60, seconds%60); calculate_inventory_rectangle_from_offset(&destination, current_row-1); destination.top -= 2; //<6/17/96 AMR> Sick hack destination.bottom -= 2; /* Now draw the text. */ destination.left+= TEXT_INSET; _draw_screen_text(temporary, &destination, _right_justified, _interface_font, _inventory_text_color); } /* Erase the panel.. */ text_rectangle= *destination; text_rectangle.top+= _get_font_line_height(_interface_font); _fill_rect(&text_rectangle, _inventory_background_color); if(item_type==_network_statistics) { struct player_ranking_data rankings[MAXIMUM_NUMBER_OF_PLAYERS]; calculate_player_rankings(rankings); /* Calculate the network statistics. */ for(loop= 0; loop<dynamic_world->player_count; ++loop) { screen_rectangle dest_rect; struct player_data *player= get_player_data(rankings[loop].player_index); short width; calculate_inventory_rectangle_from_offset(&dest_rect, current_row++); calculate_ranking_text(temporary, rankings[loop].ranking); /* Draw the player name.. */ width= _text_width(temporary, _interface_font); dest_rect.right-= width; dest_rect.left+= TEXT_INSET; _draw_screen_text(player->name, &dest_rect, _center_vertical, _interface_font, PLAYER_COLOR_BASE_INDEX+player->color); /* Now draw the ranking_text */ dest_rect.right+= width; dest_rect.left= dest_rect.right-width; _draw_screen_text(temporary, &dest_rect, _center_vertical, _interface_font, PLAYER_COLOR_BASE_INDEX+player->color); } } else { /* Draw the items. */ for(loop= 0; loop<section_count && current_row<max_lines; ++loop) { boolean valid_in_this_environment; /* Draw the item */ get_item_name(temporary, section_items[loop], (section_counts[loop]!=1)); valid_in_this_environment= item_valid_in_current_environment(section_items[loop]); draw_inventory_item(temporary, section_counts[loop], current_row++, FALSE, valid_in_this_environment); } } SET_INVENTORY_DIRTY_STATE(current_player, FALSE); } return; }
/* A change of weapon has occurred, change the weapon display panel */ static void update_weapon_panel( boolean force_redraw) { if(force_redraw || interface_state.weapon_is_dirty) { char weapon_name[90]; struct weapon_interface_data *definition; screen_rectangle *destination= get_interface_rectangle(_weapon_display_rect); screen_rectangle source; short desired_weapon= get_player_desired_weapon(current_player_index); /* Now we have to erase, because the panel won't do it for us.. */ _fill_rect(destination, _inventory_background_color); if(desired_weapon != NONE) { assert(desired_weapon>=0 && desired_weapon<MAXIMUM_WEAPON_INTERFACE_DEFINITIONS); definition= weapon_interface_definitions+desired_weapon; /* Check if it is a multi weapon - actually special cased for the magnum... */ if(definition->multi_weapon) { #define MAGNUM_DELTA_X 97 if(definition->item_id==_i_magnum) { /* Either way, draw the single */ _draw_screen_shape_at_x_y(definition->weapon_panel_shape, definition->standard_weapon_panel_left, definition->standard_weapon_panel_top); if(current_player->items[definition->item_id]>1) { _draw_screen_shape_at_x_y( BUILD_DESCRIPTOR(_collection_interface, _left_magnum), definition->standard_weapon_panel_left-MAGNUM_DELTA_X, definition->standard_weapon_panel_top); } else { /* Draw the empty one.. */ _draw_screen_shape_at_x_y( BUILD_DESCRIPTOR(_collection_interface, _left_magnum_unusable), definition->standard_weapon_panel_left-MAGNUM_DELTA_X, definition->standard_weapon_panel_top); } } else if(definition->item_id==_i_shotgun) { if(current_player->items[definition->item_id]>1) { _draw_screen_shape_at_x_y( BUILD_DESCRIPTOR(_collection_interface, _double_shotgun), definition->standard_weapon_panel_left, definition->standard_weapon_panel_top-12); } else { _draw_screen_shape_at_x_y(definition->weapon_panel_shape, definition->standard_weapon_panel_left, definition->standard_weapon_panel_top); } } } else { /* Slam it to the screen! */ if(definition->weapon_panel_shape != NONE) { _draw_screen_shape_at_x_y(definition->weapon_panel_shape, definition->standard_weapon_panel_left, definition->standard_weapon_panel_top); } } /* Get the weapon name.. */ if(desired_weapon != _weapon_ball) { #define strWEAPON_NAME_LIST 137 getcstr(weapon_name, strWEAPON_NAME_LIST, desired_weapon); } else { short item_index; /* Which ball do they actually have? */ for(item_index= BALL_ITEM_BASE; item_index<BALL_ITEM_BASE+MAXIMUM_NUMBER_OF_PLAYERS; ++item_index) { if(current_player->items[item_index]>0) break; } assert(item_index != BALL_ITEM_BASE+MAXIMUM_NUMBER_OF_PLAYERS); get_item_name(weapon_name, item_index, FALSE); } /* Draw the weapon name.. */ source= *destination; source.top= definition->weapon_name_start_y; source.bottom= definition->weapon_name_end_y; if(definition->weapon_name_start_x != NONE) { source.left= definition->weapon_name_start_x; } if(definition->weapon_name_end_x != NONE) { source.right= definition->weapon_name_end_x; } _draw_screen_text(weapon_name, &source, _center_horizontal|_center_vertical|_wrap_text, _weapon_name_font, _inventory_text_color); /* And make sure that the ammo knows it needs to update */ interface_state.ammo_is_dirty= TRUE; } interface_state.weapon_is_dirty= FALSE; } }
/** * \brief Returns whether this treasure is empty. * \return true if this treasure is empty */ bool Treasure::is_empty() const { return get_item_name().empty(); }
bool get_item_description( unsigned n, pfc::string_base & out ) { get_item_name( n, out ); return true; }
const chowstring & INI::get_item_name(unsigned int index) { return get_item_name(current_group, index); }
virtual bool context_get_display( unsigned int index, metadb_handle_list_cref tracks, pfc::string_base& out, unsigned int& displayflags, const GUID& /*caller*/ ) { switch(index) { case Items::GetArtistTopTracks: { const auto& mainArtist = getMainArtist(tracks); const t_size stringLength = mainArtist.length(); if(stringLength > 0) { // We have found a main artist; set the display of the item to be of the form: // "Artist's top tracks". out = mainArtist.c_str(); // Grammar alert! Artists ending with "s" get just a "'" rather than "'s". if(out[stringLength - 1] == 's') { out.add_string("' top tracks"); } else { out.add_string("'s top tracks"); } } else { // Failed to find a main artist; return the normal, non-custom name for the item. get_item_name(index, out); } return true; } case Items::GetSimilarTracks: { if(tracks.get_count() == 0) { displayflags = FLAG_DISABLED_GRAYED; get_item_name(index, out); } else { out = "Get tracks similar to "; out.add_string(getTitle(tracks.get_item(0)).c_str()); } return true; } default: { // Nothing wants to customise the display of the item; let the regular name be displayed. get_item_name(index, out); return true; } } }
void draw_trees() { tree_t *treeLocs; int numTrees; scalar_t treeRadius; scalar_t treeHeight; int i; GLuint texture_id = 0; vector_t normal; scalar_t fwd_clip_limit, bwd_clip_limit, fwd_tree_detail_limit; int tree_type = -1; char *tree_name = 0; scalar_t itemRadius; scalar_t itemHeight; int item_type = -1; char * item_name = 0; item_type_t *item_types; treeLocs = treeLocsOrderedByZ; numTrees = get_num_trees(); item_types = get_item_types(); fwd_clip_limit = getparam_forward_clip_distance(); bwd_clip_limit = getparam_backward_clip_distance(); fwd_tree_detail_limit = getparam_tree_detail_distance(); set_gl_options( TREES ); glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); set_material( white, black, 1.0 ); #ifdef __APPLE__ #undef glVertexPointer #undef glTexCoordPointer #undef glEnableClientState #undef glDisableClientState #undef glDrawArrays static const GLfloat verticesTree []= { -1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0, -1.0, 0.0, 1.0, 1.0, }; static const GLfloat texCoordsTree []= { 0.0, 0.0 , 1.0, 0.0 , 1.0, 1.0 , 0.0, 1.0 , 0.0, 0.0 , 1.0, 1.0 , 0.0, 0.0 , 1.0, 0.0 , 1.0, 1.0 , 0.0, 1.0 , 0.0, 0.0 , 1.0, 1.0 , }; glVertexPointer (3, GL_FLOAT , 0, verticesTree); glTexCoordPointer(2, GL_FLOAT, 0, texCoordsTree); glEnableClientState(GL_TEXTURE_COORD_ARRAY); #endif for (i = first_tree_to_check; i< numTrees; i++ ) { if ( clip_course ) { if ( eye_pt.z - treeLocs[i].ray.pt.z > fwd_clip_limit ) //printf("break : eye_pt.z - treeLocs[i].ray.pt.z = %f > fwd_clip_limit = %f\n",eye_pt.z - treeLocs[i].ray.pt.z,fwd_clip_limit); break; if ( treeLocs[i].ray.pt.z - eye_pt.z > bwd_clip_limit ){ first_tree_to_check = i; //printf("continue : treeLocs[i].ray.pt.z - eye_pt.z = %f > bwd_clip_limit = %f\n",treeLocs[i].ray.pt.z - eye_pt.z,bwd_clip_limit); continue; } //printf("condition 1 : eye_pt.z - treeLocs[i].ray.pt.z = %f > fwd_clip_limit = %f\n",eye_pt.z - treeLocs[i].ray.pt.z,fwd_clip_limit); // printf("condition 2 : treeLocs[i].ray.pt.z - eye_pt.z = %f > bwd_clip_limit = %f\n",treeLocs[i].ray.pt.z - eye_pt.z,bwd_clip_limit); } /* verify that the correct texture is bound */ if (treeLocs[i].tree_type != tree_type) { tree_type = treeLocs[i].tree_type; tree_name = get_tree_name(tree_type); if (!get_texture_binding( tree_name, &texture_id ) ) { texture_id = 0; } glBindTexture( GL_TEXTURE_2D, texture_id ); } glPushMatrix(); glTranslatef( treeLocs[i].ray.pt.x, treeLocs[i].ray.pt.y, treeLocs[i].ray.pt.z ); treeRadius = treeLocs[i].diam/2.; treeHeight = treeLocs[i].height; normal = subtract_points( eye_pt, treeLocs[i].ray.pt ); normalize_vector( &normal ); glNormal3f( normal.x, normal.y, normal.z ); #ifdef __APPLE__ glScalef(treeRadius, treeHeight, treeRadius); bool drawTwoPlanes = false; if ( !clip_course || eye_pt.z - treeLocs[i].ray.pt.z < fwd_tree_detail_limit ) drawTwoPlanes = true; glDrawArrays(GL_TRIANGLES, 0, 6 + drawTwoPlanes ? 6 : 0); #else glBegin( GL_QUADS ); glTexCoord2f( 0., 0. ); glVertex3f( -treeRadius, 0.0, 0.0 ); glTexCoord2f( 1., 0. ); glVertex3f( treeRadius, 0.0, 0.0 ); glTexCoord2f( 1., 1. ); glVertex3f( treeRadius, treeHeight, 0.0 ); glTexCoord2f( 0., 1. ); glVertex3f( -treeRadius, treeHeight, 0.0 ); if ( !clip_course || eye_pt.z - treeLocs[i].ray.pt.z < fwd_tree_detail_limit ) { glTexCoord2f( 0., 0. ); glVertex3f( 0.0, 0.0, -treeRadius ); glTexCoord2f( 1., 0. ); glVertex3f( 0.0, 0.0, treeRadius ); glTexCoord2f( 1., 1. ); glVertex3f( 0.0, treeHeight, treeRadius ); glTexCoord2f( 0., 1. ); glVertex3f( 0.0, treeHeight, -treeRadius ); } glEnd(); #endif glPopMatrix(); } #ifdef __APPLE__ static const GLfloat verticesItem []= { -1.0, 0.0, 1.0, 1.0, 0.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 0.0, 1.0, 1.0, 1.0, -1.0, }; static const GLfloat texCoordsItem []= { 0.0, 0.0 , 1.0, 0.0 , 1.0, 1.0 , 0.0, 1.0 , 0.0, 0.0 , 1.0, 1.0 , }; glVertexPointer (3, GL_FLOAT , 0, verticesItem); glTexCoordPointer(2, GL_FLOAT, 0, texCoordsItem); #endif texture_id = 0; for (i = 0; i< numItems; i++ ) { #ifdef __APPLE__ if (g_game.is_speed_only_mode || !g_game.practicing) { if ( itemLocs[i].collectable == 1) { /* In speed mode or in tutorial we don't want to draw fishes*/ continue; } } #endif if ( itemLocs[i].collectable == 0 || itemLocs[i].drawable == False) { /* already collected or not to be drawn*/ continue; } if ( clip_course ) { if ( eye_pt.z - itemLocs[i].ray.pt.z > fwd_clip_limit ) continue; if ( itemLocs[i].ray.pt.z - eye_pt.z > bwd_clip_limit ) continue; } /* load texture id if needed */ if (!itemLocs[i].sponsor_binded) { itemLocs[i].sponsor_binded = True; if(itemLocs[i].item_type == kFlagType) { int r = rand() % 2; item_name = r ? "flag_furlan" : "flag_zag"; /*un drapeau sur 2 portera le logo zag ou furlan, au hasard*/ } else { item_name = get_item_name(itemLocs[i].item_type); } if (!get_texture_binding( item_name, &itemLocs[i].tid ) ) { itemLocs[i].tid = 0; } } /* verify that the correct texture is bound */ if (itemLocs[i].tid != texture_id) { glBindTexture( GL_TEXTURE_2D, itemLocs[i].tid ); texture_id = itemLocs[i].tid; } glPushMatrix(); { glTranslatef( itemLocs[i].ray.pt.x, itemLocs[i].ray.pt.y, itemLocs[i].ray.pt.z ); itemRadius = itemLocs[i].diam/2.; itemHeight = itemLocs[i].height; if ( item_types[item_type].use_normal ) { normal = item_types[item_type].normal; } else { normal = subtract_points( eye_pt, itemLocs[i].ray.pt ); normalize_vector( &normal ); } if (normal.y == 1.0) { continue; } glNormal3f( normal.x, normal.y, normal.z ); normal.y = 0.0; normalize_vector( &normal ); #ifdef __APPLE__ glScalef(itemRadius*normal.z, itemHeight, itemRadius*normal.x); glDrawArrays(GL_TRIANGLES, 0, 6); #else glBegin( GL_QUADS ); { glTexCoord2f( 0., 0. ); glVertex3f( -itemRadius*normal.z, 0.0, itemRadius*normal.x ); glTexCoord2f( 1., 0. ); glVertex3f( itemRadius*normal.z, 0.0, -itemRadius*normal.x ); glTexCoord2f( 1., 1. ); glVertex3f( itemRadius*normal.z, itemHeight, -itemRadius*normal.x ); glTexCoord2f( 0., 1. ); glVertex3f( -itemRadius*normal.z, itemHeight, itemRadius*normal.x ); } glEnd(); #endif } glPopMatrix(); } #ifdef __APPLE__ glDisableClientState(GL_TEXTURE_COORD_ARRAY); #endif }
inline char const* get_name(Item const& item) { return get_item_name(item); }
/** * \brief Returns the equipment item corresponding to this treasure's content. * \return The equipment item. */ EquipmentItem& Treasure::get_item() const { return game->get_equipment().get_item(get_item_name()); }