示例#1
0
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void* EffectTextureLoader::Load(const EFK_CHAR* path, Effekseer::TextureType textureType)
{
	auto key = astring((const achar*) path);
	auto cache = m_caches.find(key);
	if (cache != m_caches.end())
	{
		cache->second.Count++;
		return cache->second.Ptr;
	}

	auto staticFile = m_graphics->GetFile()->CreateStaticFile((const achar*) path);
	if (staticFile.get() == nullptr) return nullptr;

	int32_t imageWidth = 0;
	int32_t imageHeight = 0;
	std::vector<uint8_t> imageDst;
	if (!ImageHelper::LoadPNGImage(staticFile->GetData(), staticFile->GetSize(), IsReversed(), imageWidth, imageHeight, imageDst, m_graphics->GetLog()))
	{
		return nullptr;
	}

	void* img = InternalLoad(m_graphics, imageDst, imageWidth, imageHeight);

	Cache c;
	c.Ptr = img;
	c.Count = 1;
	c.Width = imageWidth;
	c.Height = imageHeight;
	m_caches[key] = c;
	dataToKey[img] = key;

	m_graphics->IncVRAM(ImageHelper::GetVRAMSize(TextureFormat::R8G8B8A8_UNORM, imageWidth, imageHeight));

	return img;
}
示例#2
0
// Adds a new option to the select control.
int WidgetDropDown::AddOption(const Rocket::Core::String& rml, const Rocket::Core::String& value, int before, bool select, bool selectable)
{
	// Instance a new element for the option.
	Core::Element* element = Core::Factory::InstanceElement(selection_element, "*", "option", Rocket::Core::XMLAttributes());

	// Force to block display and inject the RML. Register a click handler so we can be notified of selection.
	element->SetProperty("display", "block");
	element->SetProperty("clip", "auto");
	element->SetInnerRML(rml);
	element->AddEventListener("click", this);

	int option_index;
	if (before < 0 ||
		before >= (int) options.size())
	{
		if (IsReversed())
			selection_element->InsertBefore(element, selection_element->GetFirstChild());
		else
			selection_element->AppendChild(element);
		options.push_back(SelectOption(element, value, selectable));
		option_index = (int) options.size() - 1;
	}
	else
	{
		if (IsReversed())
		{
			if (before == 0)
				selection_element->AppendChild(element);
			else
				selection_element->InsertBefore(element, options[before-1].GetElement());
		}
		else
			selection_element->InsertBefore(element, selection_element->GetChild(before));
		options.insert(options.begin() + before, SelectOption(element, value, selectable));
		option_index = before;
	}

	element->RemoveReference();

	// Select the option if appropriate.
	if (select)
		SetSelection(option_index);

	box_layout_dirty = true;
	return option_index;
}
示例#3
0
float GameManager::GameSpeed() const {
	if (GState() & (GStateMainMenu|GStateGameOver)) return 0;
	
	return 1.0f + (ScorePipeXVelocityMultiplier * CurrentRoundScore()) * (IsReversed() ? -1.0f : 1.0f);
}