TextureContainer * TextureContainer::Load(const res::path & name, TCFlags flags) {
	
	// Check first to see if the texture is already loaded
	TextureContainer * newTexture = Find(name);
	if(newTexture) {
		// TODO don't we need to check the texture's systemflags?
		return newTexture;
	}
	
	// Allocate and add the texture to the linked list of textures;
	newTexture = new TextureContainer(name, flags);
	if(!newTexture) {
		return NULL;
	}
	
	newTexture->systemflags = flags;
	
	if(GLOBAL_EERIETEXTUREFLAG_LOADSCENE_RELEASE == -1) {
		newTexture->systemflags &= ~Level;
	}
	
	// Create a bitmap and load the texture file into it,
	if(!newTexture->LoadFile(name)) {
		delete newTexture;
		return NULL;
	}
	
	MakeUserFlag(newTexture);
	
	return newTexture;
}
Example #2
0
void EERIE_MESH_TWEAK_Skin(EERIE_3DOBJ * obj, char * s1, char * s2)
{
	if (obj == NULL) return;

	if (s1 == NULL) return;

	if (s2 == NULL) return;

	char skintochange[512];
	char skinname[512];

	sprintf(skintochange, "Graph\\Obj3D\\Textures\\%s.bmp", s1);
	MakeUpcase(skintochange);
	TextureContainer * tex = D3DTextr_CreateTextureFromFile(skintochange);

	if (obj->originaltextures == NULL)
	{
		obj->originaltextures = (char *)malloc(256 * obj->nbmaps); 
		memset(obj->originaltextures, 0, 256 * obj->nbmaps);

		for (long i = 0; i < obj->nbmaps; i++)
		{
			if (obj->texturecontainer[i])
				strcpy(obj->originaltextures + 256 * i, obj->texturecontainer[i]->m_texName);
		}
	}

	if ((tex != NULL) && (obj->originaltextures != NULL))
	{
		for (long i = 0; i < obj->nbmaps; i++)
		{
			if ((strstr(obj->originaltextures + 256 * i, skintochange)))
			{
				strcpy(skintochange, obj->texturecontainer[i]->m_texName);
				break;
			}
		}

		tex->Restore(GDevice);
		TextureContainer * tex2 = FindTexture(skintochange);

		if (tex2)
			for (long i = 0; i < obj->nbmaps; i++)
			{
				if (obj->texturecontainer[i] == tex2)  obj->texturecontainer[i] = tex;
			}
	}
}
Example #3
0
static bool SelectSpellTargetCursorRender() {
	
	if(   !SPECIAL_DRAGINTER_RENDER
	   && LOOKING_FOR_SPELL_TARGET
	) {
		ArxDuration elapsed = arxtime.now() - LOOKING_FOR_SPELL_TARGET_TIME;
		if(elapsed > ArxDurationMs(7000)) {
			ARX_SOUND_PlaySFX(SND_MAGIC_FIZZLE, &player.pos);
			ARX_SPELLS_CancelSpellTarget();
		}
		
		TextureContainer * surf;
		
		if(FlyingOverIO
			&& (((LOOKING_FOR_SPELL_TARGET & 1) && (FlyingOverIO->ioflags & IO_NPC))
			||  ((LOOKING_FOR_SPELL_TARGET & 2) && (FlyingOverIO->ioflags & IO_ITEM)))
		){
			surf = cursorTargetOn;
			
			if(eeMouseUp1()) {
				ARX_SPELLS_LaunchSpellTarget(FlyingOverIO);
			}
		} else {
			surf = cursorTargetOff;
			
			if(GInput->actionPressed(CONTROLS_CUST_MAGICMODE)) {
				ARX_SOUND_PlaySFX(SND_MAGIC_FIZZLE, &player.pos);
				ARX_SPELLS_CancelSpellTarget();
			}
		}
		
		Vec2f pos = Vec2f(DANAEMouse);
		
		if(TRUE_PLAYER_MOUSELOOK_ON) {
			pos = MemoMouse;
		}
		
		Vec2f texSize = Vec2f(surf->size());
		pos += -texSize * 0.5f;
		
		EERIEDrawBitmap(Rectf(pos, texSize.x, texSize.y), 0.f, surf, Color::white);
		
		return true;
	}
	return false;
}
Example #4
0
void MemorizedRunesHud::draw() {
	
	if(!(CurrSpellSymbol || player.SpellToMemorize.bSpell)) {
		return;
	}
	
	Vec2f pos = m_rect.topLeft();
	
	for(int i = 0; i < 6; i++) {
		bool bHalo = false;
		if(SpellSymbol[i] != RUNE_NONE) {
			if(SpellSymbol[i] == player.SpellToMemorize.iSpellSymbols[i]) {
				bHalo = true;
			} else {
				player.SpellToMemorize.iSpellSymbols[i] = SpellSymbol[i];
				for(int j = i + 1; j < 6; j++) {
					player.SpellToMemorize.iSpellSymbols[j] = RUNE_NONE;
				}
			}
		}
		if(player.SpellToMemorize.iSpellSymbols[i] != RUNE_NONE) {
			
			Vec2f size = Vec2f(32.f, 32.f) * m_scale;
			Rectf rect = Rectf(pos, size.x, size.y);
			
			TextureContainer * tc = gui::necklace.pTexTab[player.SpellToMemorize.iSpellSymbols[i]];
			
			if(bHalo) {
				ARX_INTERFACE_HALO_Render(Color3f(0.2f, 0.4f, 0.8f), HALO_ACTIVE, tc->getHalo(), pos, Vec2f(m_scale));
			}
			
			EERIEDrawBitmap(rect, 0, tc, Color::white);
			
			if(!player.hasRune(player.SpellToMemorize.iSpellSymbols[i])) {
				UseRenderState state(render2D().blend(BlendInvDstColor, BlendOne).alphaCutout());
				EERIEDrawBitmap(rect, 0, cursorMovable, Color3f::gray(.8f).to<u8>());
			}
			
			pos.x += 32 * m_scale;
		}
	}
	if(g_gameTime.now() - player.SpellToMemorize.lTimeCreation > GameDurationMs(30000)) {
		player.SpellToMemorize.bSpell = false;
	}
}
void Block::Draw(long posX, long posY, App &app, TextureContainer &tC, unsigned short metadata)
{
	sf::Sprite *&&tempSprite = &(tC.getTextures(getTextureName())[getTextureId(app, metadata)]);
	if (tempSprite != nullptr)
	{
		tempSprite->setPosition(posX, posY);
		app.draw(*tempSprite);
	}
}
Example #6
0
void QuickSaveIconGui::draw() {
	
	if(m_remainingTime == 0) {
		return;
	}
	
	UseRenderState state(render2D().blend(BlendSrcColor, BlendOne).alphaCutout());
	
	// Flash the icon twice, starting at about 0.7 opacity
	float step = 1.f - (m_remainingTime / m_duration);
	float alpha = std::min(1.f, 0.6f * (std::sin(step * (7.f / 2.f * glm::pi<float>())) + 1.f));
	
	TextureContainer * tex = TextureContainer::LoadUI("graph/interface/icons/menu_main_save");
	arx_assert(tex);
	
	Vec2f size = Vec2f(tex->size());
	EERIEDrawBitmap(Rectf(Vec2f(0, 0), size.x, size.y), 0.f, tex, Color::gray(alpha));
	
}
Example #7
0
void Creature::Draw(sf::RenderWindow &app, TextureContainer &tc)
{
	sf::Sprite *sprite = &(tc.getTextures(spriteName)[spriteIndex]);
	if (sprite != NULL)
	{
		sprite->SetPosition(sf::Vector2f(x, y));
		sprite->SetRotation(angle);
		app.Draw(*sprite);
	}
	else
	{
		std::cout << "'" << getTextureName() << "' not found!" << std::endl;
	}
}
void Inventory::Draw(int xPos, int yPos, App& app, TextureContainer& tC)
{
	int x = xPos;
	int y = yPos;
	int slot = 0;
	sf::Sprite slotSprite = tC.getTextures("slot.png")[0];
	for(int xSlot = 0; xSlot < xSize; xSlot++)
	{
		for(int ySlot = 0; ySlot < ySize; ySlot++)
		{
			slotSprite.setPosition(x + (xSlot * 32), y + (ySlot * 32));
			app.draw(slotSprite);
			slot++;
		}
	}
}
void TextureInstance::bind_texture(const TextureContainer& textures)
{
    if (m_texture == 0)
    {
        m_texture = textures.get_by_name(impl->m_texture_name.c_str());

        // We need to resolve the alpha mode as soon as a texture is bound to this instance.
        // We cannot do it in on_frame_begin() because the texture instance might be needed
        // before it gets called. For instance, updating the trace context implies updating
        // the intersection filters, and those need to be able to sample texture instances.
        if (m_effective_alpha_mode == TextureAlphaModeDetect)
        {
            m_effective_alpha_mode = detect_alpha_mode(*m_texture);

            RENDERER_LOG_DEBUG(
                "texture instance \"%s\" was detected to use the \"%s\" alpha mode.",
                get_name(),
                m_effective_alpha_mode == TextureAlphaModeAlphaChannel ? "alpha_channel" : "luminance");
        }
    }
}
Example #10
0
void InputBinder::bind_texture_instance_to_input(
    const TextureContainer&         textures,
    const TextureInstanceContainer& texture_instances,
    const UniqueID                  assembly_uid,
    const char*                     entity_type,
    const char*                     entity_name,
    const char*                     param_value,
    InputArray::iterator&           input)
{
    const TextureInstance* texture_instance = texture_instances.get_by_name(param_value);
    assert(texture_instance);

    const size_t texture_index = texture_instance->get_texture_index();
    assert(texture_index != ~0);

    Texture* texture = textures.get_by_index(texture_index);
    assert(texture);

    try
    {
        input.bind(
            new TextureSource(
                assembly_uid,
                *texture_instance,
                texture->properties()));
    }
    catch (const exception& e)
    {
        RENDERER_LOG_ERROR(
            "while defining %s \"%s\", while binding \"%s\" to parameter \"%s\": %s.",
            entity_type,
            entity_name,
            param_value,
            input.name(),
            e.what());
        ++m_error_count;
    }
}
Example #11
0
void EERIE_MESH_TWEAK_Do(INTERACTIVE_OBJ * io, long tw, char * _path)
{
	if (!ALLOW_MESH_TWEAKING) return;

	char file2[256];
	char filet[256];
	char path[256];
	File_Standardize(_path, path);

	strcpy(filet, "GAME\\");
	strcat(filet, path);

	SetExt(filet, ".FTL");
	File_Standardize(filet, file2);

	if ((!PAK_FileExist(file2)) && (!PAK_FileExist(path))) return;

	if (tw == TWEAK_ERROR) return;

	if (io == NULL) return;

	if (io->obj == NULL) return;

	EERIE_MESH_ReleaseTransPolys(io->obj);

	if ((path == NULL) && (tw == TWEAK_REMOVE))
	{
		if (io->tweaky)
		{
			ReleaseEERIE3DObj(io->obj);
			io->obj = io->tweaky;
			EERIE_Object_Precompute_Fast_Access(io->obj);
			io->tweaky = NULL;
		}

		return;
	}

	EERIE_3DOBJ * tobj = NULL;
	EERIE_3DOBJ * result = NULL;
	EERIE_3DOBJ * result2 = NULL;

	if ((PAK_FileExist(file2)) || (PAK_FileExist(path)))
	{
		
		const char DIR_TEXTURES[] = "Graph\\Obj3D\\Textures\\";
		
		if (io->ioflags & IO_NPC)
			tobj = TheoToEerie_Fast(DIR_TEXTURES, path, TTE_NPC);
		else
			tobj = TheoToEerie_Fast(DIR_TEXTURES, path, 0);

		if (!tobj) return;

		switch (tw)
		{
			case TWEAK_ALL:

				if (io->tweaky == NULL) io->tweaky = io->obj;
				else ReleaseEERIE3DObj(io->obj);

				long i;
				TextureContainer * tc;
				tc = NULL;

				for (i = 0; i < tobj->nbfaces; i++)
				{
					if ((tobj->facelist[i].texid >= 0)
					        &&	(tobj->texturecontainer[tobj->facelist[i].texid]))
					{
						tc = tobj->texturecontainer[tobj->facelist[i].texid];

						if (!tc->m_pddsSurface)
							tc->Restore(GDevice);
					}
				}

				io->obj = tobj;
				return;
				break;
			case TWEAK_UPPER:
				result2 = CreateIntermediaryMesh(io->obj, tobj, TWEAK_HEAD);
				result = CreateIntermediaryMesh(result2, tobj, TWEAK_TORSO);
				ReleaseEERIE3DObj(result2);
				break;
			case TWEAK_LOWER:
				result2 = CreateIntermediaryMesh(io->obj, tobj, TWEAK_TORSO);
				result = CreateIntermediaryMesh(result2, tobj, TWEAK_LEGS);
				ReleaseEERIE3DObj(result2);
				break;
			case TWEAK_UP_LO:
				result = CreateIntermediaryMesh(tobj, io->obj, TWEAK_TORSO);
				break;
			default:
				result = CreateIntermediaryMesh(io->obj, tobj, tw);
				break;
		}

		if (result == NULL)
		{
			ReleaseEERIE3DObj(tobj);
			return;
		}

		result->pdata = NULL;
		result->cdata = NULL;

		if (io->tweaky == NULL) io->tweaky = io->obj;
		else if (io->tweaky != io->obj)
			ReleaseEERIE3DObj(io->obj);

		io->obj = result;
		EERIE_Object_Precompute_Fast_Access(io->obj);
	}

	EERIE_CreateCedricData(io->obj);

	if (io)
	{
		io->lastanimtime = 0;
		io->nb_lastanimvertex = 0;
	}

	ReleaseEERIE3DObj(tobj);
}
void SecondaryInventoryHud::draw() {
	const INVENTORY_DATA * inventory = TSecondaryInventory;
	
	if(!inventory)
		return;
	
	bool _bSteal = (player.Interface & INTER_STEAL) != 0;
	
	arx_assert(m_defaultBackground);
	ingame_inventory = m_defaultBackground;
	if(inventory->io && !inventory->io->inventory_skin.empty()) {
		
		res::path file = "graph/interface/inventory" / inventory->io->inventory_skin;
		TextureContainer * tc = TextureContainer::LoadUI(file);
		if(tc)
			ingame_inventory = tc;
	}
	
	Rectf rect = Rectf(Vec2f(m_fadePosition * m_scale, 0.f), m_size.x * m_scale, m_size.y * m_scale);
	EERIEDrawBitmap(rect, 0.001f, ingame_inventory, Color::white);
	
	for(long y = 0; y < inventory->m_size.y; y++) {
		for(long x = 0; x < inventory->m_size.x; x++) {
			Entity *io = inventory->slot[x][y].io;
			if(!io)
				continue;
			
			bool bItemSteal = false;
			TextureContainer *tc = io->m_icon;
			TextureContainer *tc2 = NULL;
			
			if(NeedHalo(io))
				tc2 = io->m_icon->getHalo();
			
			if(_bSteal) {
				if(!ARX_PLAYER_CanStealItem(io)) {
					bItemSteal = true;
					tc = m_canNotSteal;
					tc2 = NULL;
				}
			}
			
			if(tc && (inventory->slot[x][y].show || bItemSteal)) {
				UpdateGoldObject(io);
				
				Vec2f p = Vec2f(
				(m_fadePosition * m_scale) + (float)x*(32 * m_scale) + (2 * m_scale),
				(float)y*(32 * m_scale) + (13 * m_scale)
				);
				
				Vec2f size = Vec2f(tc->size());
				
				Color color = (io->poisonous && io->poisonous_count!=0) ? Color::green : Color::white;
				
				Rectf rect(p, size.x * m_scale, size.y * m_scale);
				// TODO use alpha blending so this will be anti-aliased even w/o alpha to coverage
				EERIEDrawBitmap(rect, 0.001f, tc, color);
				
				Color overlayColor = Color::black;
				
				if(!bItemSteal && (io==FlyingOverIO))
					overlayColor = Color::white;
				else if(!bItemSteal && (io->ioflags & IO_CAN_COMBINE)) {
					overlayColor = Color3f::gray(glm::abs(glm::cos(glm::radians(fDecPulse)))).to<u8>();
				}
				
				if(overlayColor != Color::black) {
					GRenderer->SetBlendFunc(BlendSrcAlpha, BlendOne);
					GRenderer->SetRenderState(Renderer::AlphaBlending, true);
					
					EERIEDrawBitmap(rect, 0.001f, tc, overlayColor);
					
					GRenderer->SetRenderState(Renderer::AlphaBlending, false);
				}
				
				if(tc2) {
					ARX_INTERFACE_HALO_Draw(io, tc, tc2, p, Vec2f(m_scale));
				}
				
				if((io->ioflags & IO_ITEM) && io->_itemdata->count != 1)
					ARX_INTERFACE_DrawNumber(p, io->_itemdata->count, 3, Color::white, m_scale);
			}
		}
	}
	
	
	if(!(player.Interface & INTER_COMBATMODE) && (player.Interface & INTER_MINIBACK)) {
		if(TSecondaryInventory) {
			
			Entity *temp = TSecondaryInventory->io;
			if(temp && !(temp->ioflags & IO_SHOP) && !(temp == ioSteal)) {
				m_pickAllButton.draw();
			}
			m_closeButton.draw();
		}
	}
}