Exemplo n.º 1
0
/**
 * Display an entry on the item menu
 */
void get_item_display(menu_type *menu, int oid, bool cursor, int row, int col,
		      int width)
{
    struct object_menu_data *choice = menu_priv(menu);
    size_t max_len = Term->wid - 1;

    const object_type *o_ptr = choice[oid].object;

    int ex_width = 0;

    /* Do we even have a menu? */
    if (!show_list) return;

    /* Width of extra fields */
    if (olist_mode & OLIST_WEIGHT)
	ex_width += 9;
    if (olist_mode & OLIST_PRICE)
	ex_width += 9;
    if (olist_mode & OLIST_FAIL)
	ex_width += 10;

    /* Get max length */
    get_max_len(&max_len);

    /* Print it */
    show_obj(oid, max_len, items[oid].label, o_ptr, cursor, olist_mode);
}
Exemplo n.º 2
0
void
scan_heap(char* label, mem_t start, mem_t finish, mem_t top, 
	Heap_t** legalHeaps, Bitmap_t** legalStarts,
	int show, ShowType_t replicaType, Bitmap_t* startMap)
{
	mem_t cur = start, next;
	if(startMap)
		ClearBitmap(startMap);
	if(show){
		printf("--------------\n");
		printf("BEGIN %s HEAP CHECK at GC %d: %lx <= %lx < %lx\n",
			label,NumGC,(long)start,(long)finish,(long)top);
		printf("--------------\n");
	}
	while(cur < finish){
		ptr_t obj = NULL;
		next = show_obj(cur,&obj,show,replicaType,
			legalHeaps,legalStarts);
		assert(obj != NULL);
		assert(next > cur);
		if(startMap){
			int pos = obj - start;
			SetBitmapRange(startMap,pos,1);
		}
		cur = next;
	}
	if(show){
		printf("--------------\n");
		printf("END %s HEAP CHECK at GC %d: %lx <= %lx < %lx\n",
			label,NumGC,(long)start,(long)finish,(long)top);
		printf("--------------\n");
	}
}
Exemplo n.º 3
0
Arquivo: main.cpp Projeto: CCJY/coliru
int main()
{
    child c(5);
    show_obj( &c );
    return EXIT_SUCCESS;
}
Exemplo n.º 4
0
static void user_menu_handler(void *data, Evas *e, Evas_Object *obj, void *event){
	Evas_Event_Key_Down *ev = (Evas_Event_Key_Down*) event;

//	if (strcmp (ev->keyname, "f") == 0)
//		ecore_evas_fullscreen_set (core.ee_core, !ecore_evas_fullscreen_get (core.ee_core));
//	else


	if (strcmp (ev->keyname, "Start") == 0){
		if(!is_download && !is_downloading && get_download_status()!=IS_DOWNLOADING)
			ecore_main_loop_quit();
	}else if (strcmp (ev->keyname, "Circle") == 0){
		if(is_main_menu);
		else if(is_asking_exit_to_xmb){
			is_asking_exit_to_xmb = false;
			is_abort = false;
			hide_edj(&download_ask);
		}else if(is_download){
			is_download = false;
			hide_obj(down);
			hide_edj(&download_perc);
			hide_edj(&download);
		}else if(is_downloading){
			is_abort = true;
	//		ecore_file_download_abort_all();
		}else if(!is_downloading && get_download_status()!=IS_DOWNLOADING){
			for(int i=0;i<Apps[category].n_elem && category !=5;i++)
				hide_obj(Applications[category].Image[i].obj);
			is_main_menu = true;
			is_drawn = category = x = y = 0;
			show_edj(&menu[0]);
			show_edj(&menu[1]);
			show_edj(&menu[2]);
			show_edj(&bar);
			app=0;
			override_text(&bar, "app_type_text", "");
			override_text(&bar, "app_version_text", "");
		}else{
			is_downloading = false;
			is_download = false;
			evas_object_resize(down, 1, Bar_Y_Val);
		}
	}else if (strcmp (ev->keyname, "Left") == 0 && !is_download) 
		x--;
	else if (strcmp (ev->keyname, "Right") == 0 && !is_download)
		x++;
	else if (strcmp (ev->keyname, "Up") == 0 && !is_download){
		if(!y)
			app-=6;
		y=!y;
	}else if (strcmp (ev->keyname, "Down") == 0 && !is_download){
		if(y)
			app+=6;
		y=!y;
	}else if (strcmp (ev->keyname, "Cross") == 0 && !is_download){
		if(is_main_menu){
			category = y*3+x;
			app = x = y = 0;
			is_drawn = 2;
			hide_edj(&menu[2]); //main menu
			if(category==5)
				hide_edj(&menu[1]); // sub menu
		}else if(is_asking_exit_to_xmb){
			is_asking_exit_to_xmb = false;
			ecore_main_loop_quit();
		}else if(app+(y*3+x) < Apps[category].n_elem){
			override_text(&download, "d_name_text", Apps[category].name[app+(y*3+x)].c_str());
			override_text(&download_perc, "d_perc_text", " ");
/*
		// uncomment this only if you have in the xml the file size (you need to edit also application.h and .cpp
			char dst[100];
			if(Apps[category].file_size[app+(y*3+x)]>1000000000)
				sprintf(dst,"%.2f Gb",1.*Apps[category].file_size[app+(y*3+x)]/1000000000);
			else if(Apps[category].file_size[app+(y*3+x)]>1000000)
				sprintf(dst,"%.2f Mb",1.*Apps[category].file_size[app+(y*3+x)]/1000000);
			else if(Apps[category].file_size[app+(y*3+x)]>1000)
				sprintf(dst,"%.2f Kb",1.*Apps[category].file_size[app+(y*3+x)]/1000);
			else
				sprintf(dst,"%d Bytes",1.*Apps[category].file_size[app+(y*3+x)]);
			override_text(&download_perc, "d_perc_text", dst);

*/
			show_edj(&download);
			show_edj(&download_perc);
			show_obj(down);
			is_download = true;
		}
		is_main_menu = false;
	}else if (strcmp (ev->keyname, "Cross") == 0 && is_download && !is_downloading){
		override_text(&download, "d_name_text", Apps[category].name[app+(y*3+x)].c_str());
		int ret = 7;
		show_obj(down);
		show_edj(&download);
		show_edj(&download_perc);
		download_status = 0;
		char dst[100];
		sprintf(dst,"%s/%s",CACHE_PATH,Apps[category].pkg_file[app+(y*3+x)].c_str());
		if(file_exist(dst))
			file_delete(dst);
		download_file(Apps[category].link[app+(y*3+x)].c_str(), dst, download_func_curl, download_is_finished);
//		ecore_file_download(Apps[category].link[app+(y*3+x)].c_str(), dst, download_is_finished, download_func, NULL, NULL);
	 	
	}
	
	if(x<0)
		x = 2;
	else if(x>2)
		x = 0;
	if(app<0)
		app=0;

	if(category != 5){
		if(is_main_menu)
			override_text(&bar, "menu_text", Categories_Names[y*3+x].c_str());
		else{
			if(app > Apps[category].n_elem-1)
				app -=6;
			override_text(&bar, "menu_text", (app+(y*3+x) < Apps[category].n_elem) ? (Apps[category].name[app+(y*3+x)].c_str()) : "" );
			override_text(&bar, "app_version_text", (app+(y*3+x) < Apps[category].n_elem) ? (Apps[category].version[app+(y*3+x)].c_str()) : "" );
			char page[20];
			sprintf(page,"%d/%d",app+(y*3+x)+1,Apps[category].n_elem);
			override_text(&menu[1], "page_of", page);
			switch(Apps[category].type_file[app+(y*3+x)]){
			 		case PSC_PACKAGE:
						override_text(&bar, "app_type_text", "Package");
			 			break;
			 		case PSC_THEME:
						override_text(&bar, "app_type_text", "Theme");
			 			break;
			 		case PSC_IMAGE:
						override_text(&bar, "app_type_text", "Image");
			 			break;
			 		case PSC_VIDEO:
						override_text(&bar, "app_type_text", "Video");
			 			break;
			 		case PSC_NO_TYPE:
						override_text(&bar, "app_type_text", " ");
			 			break;
			 		default:
						override_text(&bar, "app_type_text", " ");
			 			break;
			}
			for(int i=0;i<Apps[category].n_elem;i++)
				hide_obj(Applications[category].Image[i].obj);
			for(int i=0;i<6 && i+app < Apps[category].n_elem;i++)
				show_obj(Applications[category].Image[app+i].obj);
		}
		move_edj(&bar, Cursor_X[x], Cursor_Y[y]);
	}else{
		hide_edj(&bar);
	}
}
Exemplo n.º 5
0
/**
 * Display an entry on the item menu
 */
void get_item_display(struct menu *menu, int oid, bool cursor, int row,
					  int col, int width)
{
	/* Print it */
	show_obj(oid, row - oid, col, cursor, olist_mode);
}
Exemplo n.º 6
0
/**
 * Display a list of objects.  Each object may be prefixed with a label.
 * Used by show_inven(), show_equip(), and show_floor().  Mode flags are
 * documented in object.h
 */
static void show_obj_list(olist_detail_t mode)
{
	int i, row = 0, col = 0;
	char tmp_val[80];

	bool in_term = (mode & OLIST_WINDOW) ? true : false;
	bool terse = false;

	/* Initialize */
	max_len = 0;
	ex_width = 0;
	ex_offset = 0;

	if (in_term) max_len = 40;
	if (in_term && Term->wid < 40) mode &= ~(OLIST_WEIGHT);

	if (Term->wid < 50) terse = true;

	/* Set the names and get the max length */
	set_obj_names(terse);

	/* Take the quiver message into consideration */
	if (mode & OLIST_QUIVER && player->upkeep->quiver[0] != NULL)
		max_len = MAX(max_len, 24);

	/* Width of extra fields */
	if (mode & OLIST_WEIGHT) ex_width += 9;
	if (mode & OLIST_PRICE) ex_width += 9;
	if (mode & OLIST_FAIL) ex_width += 10;

	/* Determine beginning row and column */
	if (in_term) {
		/* Term window */
		row = 0;
		col = 0;
	} else {
		/* Main window */
		row = 1;
		col = Term->wid - 1 - max_len - ex_width;

		if (col < 3) col = 0;
	}

	/* Column offset of the first extra field */
	ex_offset = MIN(max_len, (size_t)(Term->wid - 1 - ex_width - col));

	/* Output the list */
	for (i = 0; i < num_obj; i++)
		show_obj(i, row, col, false, mode);

	/* For the inventory: print the quiver count */
	if (mode & OLIST_QUIVER) {
		int count, j;
		int quiver_slots = (player->upkeep->quiver_cnt + z_info->quiver_slot_size - 1) / z_info->quiver_slot_size;

		/* Quiver may take multiple lines */
		for (j = 0; j < quiver_slots; j++, i++) {
			const char *fmt = "in Quiver: %d missile%s";
			char letter = I2A(in_term ? i - 1 : i);

			/* Number of missiles in this "slot" */
			if (j == quiver_slots - 1)
				count = player->upkeep->quiver_cnt - (z_info->quiver_slot_size * (quiver_slots - 1));
			else
				count = z_info->quiver_slot_size;

			/* Clear the line */
			prt("", row + i, MAX(col - 2, 0));

			/* Print the (disabled) label */
			strnfmt(tmp_val, sizeof(tmp_val), "%c) ", letter);
			c_put_str(COLOUR_SLATE, tmp_val, row + i, col);

			/* Print the count */
			strnfmt(tmp_val, sizeof(tmp_val), fmt, count,
					count == 1 ? "" : "s");
			c_put_str(COLOUR_L_UMBER, tmp_val, row + i, col + 3);
		}
	}

	/* Clear term windows */
	if (in_term) {
		for (; i < Term->hgt; i++)
			prt("", row + i, MAX(col - 2, 0));
	} else if (i > 0 && row + i < 24) {
		/* Print a drop shadow for the main window if necessary */
		prt("", row + i, MAX(col - 2, 0));
	}
}
Exemplo n.º 7
0
/*
 * Display a list of objects.  Each object may be prefixed with a label.
 * Used by show_inven(), show_equip(), and show_floor().  Mode flags are
 * documented in object.h
 */
static void show_obj_list(int num_obj, u32b display, olist_detail_t mode)
{
    int i, row = 0, col = 0, sp = 0;
    size_t max_len = Term->wid - 1;
    int ex_width = 0;

    object_type *o_ptr;
    char tmp_val[80];

    bool in_term;

    in_term = (mode & OLIST_WINDOW) ? TRUE : FALSE;

    get_max_len(&max_len);

    /* Check for window size restrictions */
    if (in_term)
    {
	/* Scan windows */
	for (i = 0; i < ANGBAND_TERM_MAX; i++) {
	    /* Unused */
	    if (!angband_term[i])
		continue;
	
	    /* Count windows displaying inven */
	    if (op_ptr->window_flag[i] & display)
		max_len = MIN(max_len, angband_term[i]->wid);
	}
    }	

    /* Width of extra fields */
    if (mode & OLIST_WEIGHT)
	ex_width += 9;
    if (mode & OLIST_PRICE)
	ex_width += 9;
    if (mode & OLIST_FAIL)
	ex_width += 10;

    /* Determine beginning row and column */
    if (in_term) {
	/* Term window */
	row = 0;
	col = 0;
    } else {
	/* Main window */
	row = 1;
	col = Term->wid - 1 - max_len - ex_width;
	col = MIN(col, 20);

	if (col < 3)
	    col = 0;
    }

    /* Output the list */
    for (i = 0; i < num_obj; i++) 
    {
	o_ptr = items[i].object;

	/* Display each line */
	show_obj(i + sp, max_len, items[i].label, o_ptr, FALSE, mode);
	if ((i == (INVEN_FEET - INVEN_WIELD)) && need_spacer)
	{
	    sp = 1;
	    prt("", i + sp + 1, MAX(col - 2, 0));
	}
    }

    /* For the inventory: print the quiver count */
    if (mode & OLIST_QUIVER)
    {
	int count, j;

	/* Adjust for subwindow */
	int skip = (in_term) ? 1 : 0;

	/* Quiver may take multiple lines */
	for(j = 0; j < p_ptr->quiver_slots; j++, i++)
	{
	    /* Number of missiles in this "slot" */
	    if (j == p_ptr->quiver_slots - 1 && p_ptr->quiver_remainder > 0)
		count = p_ptr->quiver_remainder;
	    else
		count = 99;

	    /* Clear the line */
	    prt("", row + i + skip, MAX(col - 2, 0));

	    /* Print the (disabled) label */
	    strnfmt(tmp_val, sizeof(tmp_val), "%c) ", index_to_label(i));
	    c_put_str(TERM_SLATE, tmp_val, row + i + skip, col);

	    /* Print the count */
	    strnfmt(tmp_val, sizeof(tmp_val), "in Quiver: %d missile%s", count,
		    count == 1 ? "" : "s");
	    c_put_str(TERM_L_UMBER, tmp_val, row + i + skip, col + 3);
	}
    }

    /* Clear term windows */
    if (in_term) {
	for (; i < Term->hgt; i++) {
	    prt("", row + i + offset + sp, MAX(col - 2, 0));
	}
    }

    /* Print a drop shadow for the main window if necessary */
    else if (i > 0 && row + i < 24) {
	prt("", row + i + sp, MAX(col - 2, 0));
    }
}