示例#1
0
CTimeOfDayScheduler::TimeOfDayTimerId CTimeOfDayScheduler::AddTimer(float time, CTimeOfDayScheduler::TimeOfDayTimerCallback callback, void* pUserData)
{
    assert (callback != 0);
    if (callback == 0)
        return InvalidTimerId;
    SEntry entryForTime(0,time,0,0);
    TEntries::iterator iter = std::lower_bound(m_entries.begin(), m_entries.end(), entryForTime);
    m_entries.insert(iter, SEntry(m_nextId, time, callback, pUserData));
    return m_nextId++;
}
示例#2
0
void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
{
	SDL_Color palette[256];
	SDefEntry &de = * reinterpret_cast<SDefEntry *>(table);
	ui8 *p;

	defName = name;
	DEFType = read_le_u32(&de.DEFType);
	width = read_le_u32(&de.width);
	height = read_le_u32(&de.height);
	ui32 totalBlocks = read_le_u32(&de.totalBlocks);

	for (ui32 it=0;it<256;it++)
	{
		palette[it].r = de.palette[it].R;
		palette[it].g = de.palette[it].G;
		palette[it].b = de.palette[it].B;
		palette[it].unused = 255;
	}

	// The SDefEntryBlock starts just after the SDefEntry
	p = reinterpret_cast<ui8 *>(&de);
	p += sizeof(de);

	int totalEntries=0;
	for (ui32 z=0; z<totalBlocks; z++)
	{
		SDefEntryBlock &block = * reinterpret_cast<SDefEntryBlock *>(p);
		ui32 totalInBlock;

		totalInBlock = read_le_u32(&block.totalInBlock);

		for (ui32 j=SEntries.size(); j<totalEntries+totalInBlock; j++)
			SEntries.push_back(SEntry());

		p = block.data;
		for (ui32 j=0; j<totalInBlock; j++)
		{
			char Buffer[13];
			memcpy(Buffer, p, 12);
			Buffer[12] = 0;
			SEntries[totalEntries+j].name=Buffer;
			p += 13;
		}
		for (ui32 j=0; j<totalInBlock; j++)
		{
			SEntries[totalEntries+j].offset = read_le_u32(p);
			p += 4;
		}
		//totalEntries+=totalInBlock;
		for(ui32 hh=0; hh<totalInBlock; ++hh)
		{
			SEntries[totalEntries].group = z;
			++totalEntries;
		}
	}

	for(auto & elem : SEntries)
	{
		elem.name = elem.name.substr(0, elem.name.find('.')+4);
	}
	//RWEntries = new ui32[height];
	for(ui32 i=0; i < SEntries.size(); ++i)
	{
		Cimage nimg;
		nimg.bitmap = getSprite(i, table, palette);
		nimg.imName = SEntries[i].name;
		nimg.groupNumber = SEntries[i].group;
		ourImages.push_back(nimg);
	}
}
示例#3
0
void CMenu::AddEntry(const std::string &id, const std::string &name)
{
    m_MenuList.insert(std::lower_bound(m_MenuList.begin(), m_MenuList.end(), name), SEntry(id, name));
    m_LongestLine = std::max(m_LongestLine, MBWidth(name));
    RequestUpdate();
}
示例#4
0
void CDefHandler::openFromMemory(unsigned char *table, const std::string & name)
{
	BMPPalette palette[256];
	SDefEntry &de = * reinterpret_cast<SDefEntry *>(table);
	unsigned char *p;

	defName = name;
	DEFType = SDL_SwapLE32(de.DEFType);
	width = SDL_SwapLE32(de.width);
	height = SDL_SwapLE32(de.height);
	unsigned int totalBlocks = SDL_SwapLE32(de.totalBlocks);

	for (unsigned int it=0;it<256;it++)
	{
		palette[it].R = de.palette[it].R;
		palette[it].G = de.palette[it].G;
		palette[it].B = de.palette[it].B;
		palette[it].F = 0;
	}

	// The SDefEntryBlock starts just after the SDefEntry
	p = reinterpret_cast<unsigned char *>(&de);
	p += sizeof(de);

	int totalEntries=0;
	for (unsigned int z=0; z<totalBlocks; z++)
	{
		SDefEntryBlock &block = * reinterpret_cast<SDefEntryBlock *>(p);
		unsigned int totalInBlock;

		totalInBlock = read_le_u32(&block.totalInBlock);

		for (unsigned int j=SEntries.size(); j<totalEntries+totalInBlock; j++)
			SEntries.push_back(SEntry());

		p = block.data;
		for (unsigned int j=0; j<totalInBlock; j++)
		{
			char Buffer[13];
			memcpy(Buffer, p, 12);
			Buffer[12] = 0;
			SEntries[totalEntries+j].name=Buffer;
			p += 13;
		}
		for (unsigned int j=0; j<totalInBlock; j++)
		{ 
			SEntries[totalEntries+j].offset = read_le_u32(p);
			p += 4;
		}
		//totalEntries+=totalInBlock;
		for(unsigned int hh=0; hh<totalInBlock; ++hh)
		{
			SEntries[totalEntries].group = z;
			++totalEntries;
		}
	}

	for(unsigned int j=0; j<SEntries.size(); ++j)
	{
		SEntries[j].name = SEntries[j].name.substr(0, SEntries[j].name.find('.')+4);
	}
	//RWEntries = new unsigned int[height];
	for(unsigned int i=0; i < SEntries.size(); ++i)
	{
		Cimage nimg;
		nimg.bitmap = getSprite(i, table, palette);
		nimg.imName = SEntries[i].name;
		nimg.groupNumber = SEntries[i].group;
		ourImages.push_back(nimg);
	}
}