コード例 #1
0
ファイル: read_csv.c プロジェクト: jdigittl/Smatter
void load_random_rows (frameT *frame, float pct)
{
	// This finds a series of empty bits in the bitmap and loads the
	// rows that correspond to the bytes in the full csv file. As rows
	// are loaded, bits are set in the bitmap to ensure that the same
	// row isn't loaded multiple times.

	int		i;
	long	rows_to_load;
	csvT	*csv = frame->csv;

	rows_to_load = csv->est_rows * pct / 100.0;
	if (!rows_to_load)  rows_to_load = 1;

	for (i=0; i<rows_to_load; i++)
	{
		unsigned long	bitmap_byte, st;
		char	bitmap_bit;
		off_t	start, end;

		bitmap_byte = (random() / (float) RAND_MAX) * csv->bitmap_size;
		st = bitmap_byte;
		while ((bitmap_byte < csv->bitmap_size) && (csv->bitmap_loaded[bitmap_byte] == 0xFF)) bitmap_byte++;
		// TODO: this is probably why we can load more rows than exist.. bitmap may be bigger than file or something
		if (bitmap_byte >= csv->bitmap_size)
		{
			bitmap_byte = 0;
			while ((bitmap_byte < st) && (csv->bitmap_loaded[bitmap_byte] == 0xFF)) bitmap_byte++;
			if (bitmap_byte >= st)
			{
				// We have already loaded the entire file
				update_all_stats (frame);
				return ;
			}
		}
		bitmap_bit = nlo[csv->bitmap_loaded[bitmap_byte]];
		
		start = (bitmap_byte*8 + bitmap_bit) * csv->bytes_per_bitmap_bit;
		end   = (bitmap_byte*8 + bitmap_bit + 1) * csv->bytes_per_bitmap_bit;
		while ((start < end) && (start < csv->size))
		{
			load_offset_row (frame, start, end);
			start = ftell (frame->csv->fp);
		}
		csv->bitmap_loaded[bitmap_byte] |= 1 << bitmap_bit;
	}	

	update_all_stats (frame);

	return; 
}
コード例 #2
0
ファイル: read_csv.c プロジェクト: jdigittl/Smatter
void	load_all_rows (frameT *frame)
{
	csvT	*csv = frame->csv;
	char	buf[CSV_BUF_SIZE];

	fseek (csv->fp, 0L, SEEK_SET);
	// Skip header
	fgets (buf, CSV_BUF_SIZE, csv->fp);

	while (ftell (csv->fp) < csv->size)
	{
		load_row (frame);
	}	

	update_all_stats (frame);
}
コード例 #3
0
ファイル: UIStatsinfo.cpp プロジェクト: Ordywee/JourneyClient
	UIStatsinfo::UIStatsinfo(const CharStats& st) :
		UIDragElement<PosSTATS>(Point<int16_t>(212, 20)), stats(st) {

		nl::node src = nl::nx::ui["UIWindow4.img"]["Stat"]["main"];
		nl::node detail = nl::nx::ui["UIWindow4.img"]["Stat"]["detail"];

		sprites.emplace_back(src["backgrnd"]);
		sprites.emplace_back(src["backgrnd2"]);
		sprites.emplace_back(src["backgrnd3"]);

		textures_detail.emplace_back(detail["backgrnd"]);
		textures_detail.emplace_back(detail["backgrnd2"]);
		textures_detail.emplace_back(detail["backgrnd3"]);

		abilities[RARE] = detail["abilityTitle"]["rare"]["0"];
		abilities[EPIC] = detail["abilityTitle"]["epic"]["0"];
		abilities[UNIQUE] = detail["abilityTitle"]["unique"]["0"];
		abilities[LEGENDARY] = detail["abilityTitle"]["legendary"]["0"];
		abilities[NONE] = detail["abilityTitle"]["normal"]["0"];

		buttons[BT_HP] = std::make_unique<MapleButton>(src["BtHpUp"]);
		buttons[BT_MP] = std::make_unique<MapleButton>(src["BtMpUp"]);
		buttons[BT_STR] = std::make_unique<MapleButton>(src["BtStrUp"]);
		buttons[BT_DEX] = std::make_unique<MapleButton>(src["BtDexUp"]);
		buttons[BT_LUK] = std::make_unique<MapleButton>(src["BtLukUp"]);
		buttons[BT_INT] = std::make_unique<MapleButton>(src["BtIntUp"]);

		buttons[BT_DETAILOPEN] = std::make_unique<MapleButton>(src["BtDetailOpen"]);
		buttons[BT_DETAILCLOSE] = std::make_unique<MapleButton>(src["BtDetailClose"]);
		buttons[BT_DETAILCLOSE]->set_active(false);

		update_ap();

		for (size_t i = 0; i < NUMLABELS; i++)
		{
			statlabels[i] = Text(Text::A11M, Text::LEFT, Text::LIGHTGREY);
		}
		statoffsets[NAME] = Point<int16_t>(73, 27);
		statoffsets[JOB] = Point<int16_t>(73, 45);
		statoffsets[GUILD] = Point<int16_t>(73, 63);
		statoffsets[FAME] = Point<int16_t>(73, 81);
		statoffsets[DAMAGE] = Point<int16_t>(73, 99);
		statoffsets[HP] = Point<int16_t>(73, 117);
		statoffsets[MP] = Point<int16_t>(73, 135);
		statoffsets[AP] = Point<int16_t>(70, 177);
		statoffsets[STR] = Point<int16_t>(73, 204);
		statoffsets[DEX] = Point<int16_t>(73, 222);
		statoffsets[INT] = Point<int16_t>(73, 240);
		statoffsets[LUK] = Point<int16_t>(73, 258);
		statoffsets[ATTACK] = Point<int16_t>(73, 37);
		statoffsets[CRIT] = Point<int16_t>(73, 55);
		statoffsets[MINCRIT] = Point<int16_t>(73, 73);
		statoffsets[MAXCRIT] = Point<int16_t>(168, 73);
		statoffsets[BDM] = Point<int16_t>(73, 91);
		statoffsets[IGNOREDEF] = Point<int16_t>(168, 91);
		statoffsets[RESIST] = Point<int16_t>(73, 109);
		statoffsets[STANCE] = Point<int16_t>(168, 109);
		statoffsets[WDEF] = Point<int16_t>(73, 127);
		statoffsets[MDEF] = Point<int16_t>(73, 145);
		statoffsets[ACCURACY] = Point<int16_t>(73, 163);
		statoffsets[AVOID] = Point<int16_t>(73, 199);
		statoffsets[SPEED] = Point<int16_t>(73, 235);
		statoffsets[JUMP] = Point<int16_t>(168, 235);
		statoffsets[HONOR] = Point<int16_t>(73, 353);

		update_all_stats();
		update_stat(Maplestat::JOB);
		update_stat(Maplestat::FAME);

		dimension = Point<int16_t>(212, 318);
		showdetail = false;
	}