Beispiel #1
0
void build_output( char *buffer, int width, off64_t bytes_written,
                   off64_t total_size)
{
	int bar_size = width - END_OF_LINE_EMPTY;
	display_item_t item [ITEM_COUNT];

	if( transfer_has_known_size( total_size)) {
		bar_size = build_item( &item[0], bytes_written, total_size, 0,
		                       bar_size, write_percent);
	} else {
		item[0].should_display=0;
	}

	bar_size = build_item( &item[1], bytes_written, total_size, 1,
			       bar_size, write_bytes_written);
	bar_size = build_item( &item[2], bytes_written, total_size, 2,
			       bar_size, write_avr_rate);

	bar_size = hide_items_for_minimum_bar_size( item, bar_size, 20);

	if( transfer_has_known_size( total_size)) {
		write_percentage_progress_bar(buffer, bar_size, bytes_written,
		                              total_size);
	} else {
		write_activity_progress_bar( buffer, bar_size, bytes_written);
	}

	write_items( buffer, item);
}
Beispiel #2
0
static BOOL build_branch_menu(struct git_data *data,
			      const struct menu_item *item,
			      void *platform)
{
	void *submenu;

	int status;
	char *wd = wd_from_path(data->name, NULL);

	struct strbuf output;
	struct strbuf **lines, **it;
	strbuf_init(&output, 0);

	status = exec_program(wd, &output, NULL, WAITMODE,
		"git", "branch", NULL);
	free(wd);
	if (status)
		return FALSE;

	submenu = start_submenu(data, item, platform);

	lines = strbuf_split(&output, '\n');
	for (it = lines; *it; it++) {
		struct menu_item item = {
			MENU_ITEM_CLEANUP, 0,
			NULL, NULL,
			NULL, menu_branch
		};

		strbuf_rtrim(*it);
		item.string = strdup((*it)->buf + 2);
		item.helptext = strdup((*it)->buf + 2);
		item.flags = '*' == (*it)->buf[0] ?
			MI_CHECKED | MI_DISABLED : 0;
		if (build_item(data, &item, submenu))
			append_active_menu(&item);
		else
			/*
			 * if the platform failed to create an item
			 * there is no point to try other items
			 */
			break;
	}

	end_submenu(platform, submenu);

	/* technically, there is nothing to track for the menu engine */
	return FALSE;
}
Beispiel #3
0
void build_drop(int x,int y,int in)
{
	int nr;

	if (x<0 || x>=MAPX || y<0 || y>=MAPY) return;

	if (in&0x40000000) {
		map[x+y*MAPX].flags^=in&0xfffffff;
		return;
	}
	if (in&0x20000000) {
		nr=in&0xfffffff;
		if (nr==1003) { // hack for jungle ground
			nr+=RANDOM(4);
			if (nr>1003) nr++;
		}
		if (nr==542) { // hack for street ground
			nr+=RANDOM(9);
		}
		if (nr==551) { // hack for grass ground
			nr+=RANDOM(4);
		}
		if (nr==133) { // hack for parkett ground
			nr+=RANDOM(9);
		}
		if (nr==142) { // hack for parkett ground
			nr+=RANDOM(4);
		}
		if (nr==170) { // hack for stone ground
			nr+=RANDOM(6);
		}
		if (nr==704) {
			static int tab[4]={704,659,660,688};
			nr=tab[RANDOM(4)];
		}
		if (nr==950) {
			nr+=RANDOM(9);
		}
		if (nr==959) {
			nr+=(x%3)*3+(y%3);
		}
		if (nr==16670) nr+=RANDOM(4);
		if (nr==16933) {
			static int tab[4]={16933,16957,16958,16959};
			nr=tab[RANDOM(4)];
		}

		map[x+y*MAPX].sprite=nr;
		return;
	}

	nr=build_item(in,x,y);
	if (!nr) return;

	if (it[nr].active) {
		if (it[nr].light[1])
			do_add_light(x,y,it[nr].light[1]);
	} else {
		if (it[nr].light[0])
			do_add_light(x,y,it[nr].light[0]);
	}
}