예제 #1
0
void CMapLayers::OnMapLoad()
{
	if(Layers())
		LoadEnvPoints(Layers(), m_lEnvPoints);

	// easter time, place eggs
	if(m_pClient->IsEaster())
	{
		CMapItemLayerTilemap* pGameLayer = Layers()->GameLayer();
		if(m_pEggTiles)
			mem_free(m_pEggTiles);

		m_EggLayerWidth = pGameLayer->m_Width;
		m_EggLayerHeight = pGameLayer->m_Height;
		m_pEggTiles = (CTile*)mem_alloc(sizeof(CTile) * m_EggLayerWidth * m_EggLayerHeight,1);
		mem_zero(m_pEggTiles, sizeof(CTile) * m_EggLayerWidth * m_EggLayerHeight);
		CTile* aGameLayerTiles = (CTile*)Layers()->Map()->GetData(pGameLayer->m_Data);

		// first pass: baskets
		static const int s_aBasketIDs[] = {
			38,
			86
		};

		static const int s_BasketCount = sizeof(s_aBasketIDs)/sizeof(s_aBasketIDs[0]);
		PlaceEggDoodads(m_EggLayerWidth, m_EggLayerHeight, m_pEggTiles, aGameLayerTiles, 3, 2, s_aBasketIDs, s_BasketCount, 250);

		// second pass: double eggs
		static const int s_aDoubleEggIDs[] = {
			9,
			25,
			41,
			57,
			73,
			89
		};

		static const int s_DoubleEggCount = sizeof(s_aDoubleEggIDs)/sizeof(s_aDoubleEggIDs[0]);
		PlaceEggDoodads(m_EggLayerWidth, m_EggLayerHeight, m_pEggTiles, aGameLayerTiles, 2, 1, s_aDoubleEggIDs, s_DoubleEggCount, 100);

		// third pass: eggs
		static const int s_aEggIDs[] = {
			1, 2, 3, 4, 5,
			17, 18, 19, 20,
			33, 34, 35, 36,
			49, 50,     52,
			65, 66,
				82,
				98
		};

		static const int s_EggCount = sizeof(s_aEggIDs)/sizeof(s_aEggIDs[0]);
		PlaceEggDoodads(m_EggLayerWidth, m_EggLayerHeight, m_pEggTiles, aGameLayerTiles, 1, 1, s_aEggIDs, s_EggCount, 30);
	}
}
예제 #2
0
void CGameClient::OnConnected()
{
	m_Layers.Init(Kernel());
	m_Collision.Init(Layers());
    for (int i = 0; i < m_Layers.NumLayers(); i++)
    {
        CMapItemLayer *pLayer = m_Layers.GetLayer(i);
        if (pLayer->m_Type == LAYERTYPE_TILES && m_Layers.GetLayer(i + 1)->m_Type == LAYERTYPE_LUA)
        {
            dbg_msg("Init", "LuaMap");
            dbg_msg("Code", static_cast<const char *>(m_Layers.Map()->GetData(((CMapItemLayerLua *)m_Layers.GetLayer(i + 1))->m_Data)));
            m_LuaMap.m_lLuaMapFiles.add(new CLuaMapFile(static_cast<CTile *>(m_Layers.Map()->GetData(((CMapItemLayerTilemap *)m_Layers.GetLayer(i))->m_Data)), static_cast<const char *>(m_Layers.Map()->GetData(((CMapItemLayerLua *)m_Layers.GetLayer(i + 1))->m_Data)), ((CMapItemLayerTilemap *)m_Layers.GetLayer(i))->m_Width, ((CMapItemLayerTilemap *)m_Layers.GetLayer(i))->m_Height));
        }
    }

    //TODO:add config
	//RenderTools()->RenderTilemapGenerateSkip(Layers());
	thread_create(RenderTilemapGenerateSkipThread, this);

	for(int i = 0; i < m_All.m_Num; i++)
	{
		m_All.m_paComponents[i]->OnMapLoad();
		m_All.m_paComponents[i]->OnReset();
	}

	CServerInfo CurrentServerInfo;
	Client()->GetServerInfo(&CurrentServerInfo);

	m_ServerMode = SERVERMODE_PURE;
	m_LastSendInfo = 0;

	// send the inital info
	SendInfo(true);
}
예제 #3
0
Performance_Array::Performance_Array (int max_records) : 
	Dir_Array (max_records), Lookup_Size (0, 10)
{
	Layers (1);
	Congested_Ratio (0.0);

	Data_Size (sizeof (Performance_Data));
}
예제 #4
0
void CGameClient::OnConnected()
{
	m_Layers.Init(Kernel());
	m_Collision.Init(Layers());

	RenderTools()->RenderTilemapGenerateSkip(Layers());

	for(int i = 0; i < m_All.m_Num; i++)
	{
		m_All.m_paComponents[i]->OnMapLoad();
		m_All.m_paComponents[i]->OnReset();
	}

	m_ServerMode = SERVERMODE_PURE;

	// send the inital info
	SendStartInfo();
}
예제 #5
0
void CGameClient::OnConnected()
{
	m_StateSolo = false;
	m_Layers.Init(Kernel());
	m_Collision.Init(Layers());

	RenderTools()->RenderTilemapGenerateSkip(Layers());

	for(int i = 0; i < m_All.m_Num; i++)
	{
		m_All.m_paComponents[i]->OnMapLoad();
		m_All.m_paComponents[i]->OnReset();
	}

	CServerInfo CurrentServerInfo;
	Client()->GetServerInfo(&CurrentServerInfo);

	m_ServerMode = SERVERMODE_PURE;
	m_LastSendInfo = 0;

	// send the inital info
	SendInfo(true);
}
예제 #6
0
파일: hud.cpp 프로젝트: BotoX/teeworlds
void CHud::RenderCursor()
{
	if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK)
		return;

	vec2 Pos = *m_pClient->m_pCamera->GetCenter();
	RenderTools()->MapScreenToGroup(Pos.x, Pos.y, Layers()->GameGroup(), m_pClient->m_pCamera->GetZoom());
	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
	Graphics()->QuadsBegin();

	// render cursor
	RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteCursor);
	float CursorSize = 64;
	RenderTools()->DrawSprite(m_pClient->m_pControls->m_TargetPos.x, m_pClient->m_pControls->m_TargetPos.y, CursorSize);
	Graphics()->QuadsEnd();
}
예제 #7
0
파일: flow.cpp 프로젝트: wthnonck/tdtw
void CFlow::Init()
{
	if(m_pCells)
	{
		mem_free(m_pCells);
		m_pCells = 0;
	}
	
	CMapItemLayerTilemap *pTilemap = Layers()->GameLayer();
	m_Width = pTilemap->m_Width*32/m_Spacing;
	m_Height = pTilemap->m_Height*32/m_Spacing;

	// allocate and clear	
	m_pCells = (CCell *)mem_alloc(sizeof(CCell)*m_Width*m_Height, 1);
	for(int y = 0; y < m_Height; y++)
		for(int x = 0; x < m_Width; x++)
			m_pCells[y*m_Width+x].m_Vel = vec2(0.0f, 0.0f);
}
예제 #8
0
int test_texture1DArray_query()
{
	int Error(0);

	gli::texture1DArray::size_type Layers(2);
	gli::texture1DArray::size_type Levels(2);

	gli::texture1DArray Texture(gli::FORMAT_RGBA8_UINT, gli::texture1DArray::dim_type(2), Layers, Levels);

	gli::texture1DArray::size_type Size = Texture.size();

	Error += Size == sizeof(glm::u8vec4) * 3 * Layers ? 0 : 1;
	Error += Texture.format() == gli::FORMAT_RGBA8_UINT ? 0 : 1;
	Error += Texture.layers() == Layers ? 0 : 1;
	Error += Texture.levels() == Levels ? 0 : 1;
	Error += !Texture.empty() ? 0 : 1;
	Error += Texture.dimensions() == static_cast<gli::dim1_t>(2) ? 0 : 1;

	return Error;
}
예제 #9
0
	int test()
	{
		int Error(0);

		gli::texture2DArray::size_type Layers(2);
		gli::texture2DArray::size_type Levels(2);

		gli::texture2DArray Texture(gli::FORMAT_RGBA8_UINT_PACK8, gli::texture2DArray::texelcoord_type(2), Layers, Levels);

		gli::texture2DArray::size_type Size = Texture.size();

		Error += Size == sizeof(glm::u8vec4) * 5 * Layers ? 0 : 1;
		Error += Texture.format() == gli::FORMAT_RGBA8_UINT_PACK8 ? 0 : 1;
		Error += Texture.layers() == Layers ? 0 : 1;
		Error += Texture.levels() == Levels ? 0 : 1;
		Error += !Texture.empty() ? 0 : 1;
		Error += Texture.dimensions().x == 2 ? 0 : 1;
		Error += Texture.dimensions().y == 2 ? 0 : 1;

		return Error;
	}
예제 #10
0
int test_texture1DArray_query()
{
	int Error(0);

	gli::texture1DArray::size_type Layers(2);
	gli::texture1DArray::size_type Levels(2);

	gli::texture1DArray Texture(
		Layers, 
		Levels,
		gli::RGBA8U,
		gli::texture1DArray::dimensions_type(2));

	gli::texture1DArray::size_type Size = Texture.size();

	Error += Size == sizeof(glm::u8vec4) * 3 * Layers ? 0 : 1;
	Error += Texture.format() == gli::RGBA8U ? 0 : 1;
	Error += Texture.layers() == Layers ? 0 : 1;
	Error += Texture.levels() == Levels ? 0 : 1;
	Error += !Texture.empty() ? 0 : 1;
	Error += Texture.dimensions() == 2 ? 0 : 1;

	return Error;
}
예제 #11
0
void CMapLayers::OnMapLoad()
{
	if(Layers())
		LoadEnvPoints(Layers(), m_lEnvPoints);
}
예제 #12
0
void CMapImages::OnMapLoad()
{
	LoadMapImages(Kernel()->RequestInterface<IMap>(), Layers(), MAP_TYPE_GAME);
}
예제 #13
0
void CMapLayers::OnRender()
{
	if((Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK && !m_pMenuMap))
		return;

	CLayers *pLayers = 0;
	if(Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK)
		pLayers = Layers();
	else if(m_pMenuMap->IsLoaded())
		pLayers = m_pMenuLayers;

	if(!pLayers)
		return;

	CUIRect Screen;
	Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);

	vec2 Center = m_pClient->m_pCamera->m_Center;

	bool PassedGameLayer = false;

	for(int g = 0; g < pLayers->NumGroups(); g++)
	{
		CMapItemGroup *pGroup = pLayers->GetGroup(g);

		if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)
		{
			// set clipping
			float Points[4];
			RenderTools()->MapScreenToGroup(Center.x, Center.y, pLayers->GameGroup(), m_pClient->m_pCamera->m_Zoom);
			Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
			float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);
			float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);
			float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);
			float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);

			Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),
				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));
		}

		RenderTools()->MapScreenToGroup(Center.x, Center.y, pGroup, m_pClient->m_pCamera->m_Zoom);

		for(int l = 0; l < pGroup->m_NumLayers; l++)
		{
			CMapItemLayer *pLayer = pLayers->GetLayer(pGroup->m_StartLayer+l);
			bool Render = false;
			bool IsGameLayer = false;

			if(pLayer == (CMapItemLayer*)pLayers->GameLayer())
			{
				IsGameLayer = true;
				PassedGameLayer = 1;
			}

			// skip rendering if detail layers if not wanted
			if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))
				continue;

			if(m_Type == -1)
				Render = true;
			else if(m_Type == 0)
			{
				if(PassedGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))
					return;
				Render = true;
			}
			else
			{
				if(PassedGameLayer && !IsGameLayer)
					Render = true;
			}

			if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && Input()->KeyPress(KEY_KP_0))
			{
				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
				CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTMap->m_Data);
				CServerInfo CurrentServerInfo;
				Client()->GetServerInfo(&CurrentServerInfo);
				char aFilename[256];
				str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);
				IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
				if(File)
				{
					for(int y = 0; y < pTMap->m_Height; y++)
					{
						for(int x = 0; x < pTMap->m_Width; x++)
							io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));
						io_write_newline(File);
					}
					io_close(File);
				}
			}

			if(Render && !IsGameLayer)
			{
				if(pLayer->m_Type == LAYERTYPE_TILES)
				{
					CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
					if(pTMap->m_Image == -1)
						Graphics()->TextureClear();
					else
						Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));

					CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTMap->m_Data);
					Graphics()->BlendNone();
					vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f);
					RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
													EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
					Graphics()->BlendNormal();
					RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
													EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
				}
				else if(pLayer->m_Type == LAYERTYPE_QUADS)
				{
					CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
					if(pQLayer->m_Image == -1)
						Graphics()->TextureClear();
					else
						Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image));

					CQuad *pQuads = (CQuad *)pLayers->Map()->GetDataSwapped(pQLayer->m_Data);

					//Graphics()->BlendNone();
					//RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this);
					Graphics()->BlendNormal();
					RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this);
				}
			}
			else if(IsGameLayer)
			{
				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
				CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTMap->m_Data);

				Graphics()->TextureSet(g_pData->m_aImages[IMAGE_BLOCKS].m_Id);
				for(int i = 0; i < pLayers->GameLayer()->m_Width * pLayers->GameLayer()->m_Height; i++)
				{
					int Index = pTiles[i].m_Index;
					int Sprite = -1;

					if(!(Index&CCollision::COLFLAG_APPEAR))
					{
						if(Index == (CCollision::COLFLAG_BLUE | CCollision::COLFLAG_RED) && m_pClient->m_Techlevel[0] < 2 && m_pClient->m_Techlevel[1] < 2)
							Sprite = SPRITE_BLOCK_WHITE_2;
						else if(Index == (CCollision::COLFLAG_BLUE | CCollision::COLFLAG_RED | CCollision::COLFLAG_TL3) && m_pClient->m_Techlevel[0] < 3 && m_pClient->m_Techlevel[1] < 3)
							Sprite = SPRITE_BLOCK_WHITE_3;
						else if(Index == CCollision::COLFLAG_RED && m_pClient->m_Techlevel[0] < 2)
							Sprite = SPRITE_BLOCK_RED_2;
						else if(Index == (CCollision::COLFLAG_RED | CCollision::COLFLAG_TL3) && m_pClient->m_Techlevel[0] < 3)
							Sprite = SPRITE_BLOCK_RED_3;
						else if(Index == CCollision::COLFLAG_BLUE && m_pClient->m_Techlevel[1] < 2)
							Sprite = SPRITE_BLOCK_BLUE_2;
						else if(Index == (CCollision::COLFLAG_BLUE | CCollision::COLFLAG_TL3) && m_pClient->m_Techlevel[1] < 3)
							Sprite = SPRITE_BLOCK_BLUE_3;
					}
					else
					{
						Index ^= CCollision::COLFLAG_APPEAR;
						if(Index == (CCollision::COLFLAG_BLUE | CCollision::COLFLAG_RED) && (m_pClient->m_Techlevel[0] >= 2 || m_pClient->m_Techlevel[1] >= 2))
							Sprite = SPRITE_BLOCK_WHITE_2_APP;
						else if(Index == (CCollision::COLFLAG_BLUE | CCollision::COLFLAG_RED | CCollision::COLFLAG_TL3) && (m_pClient->m_Techlevel[0] == 3 || m_pClient->m_Techlevel[1] == 3))
							Sprite = SPRITE_BLOCK_WHITE_3_APP;
						else if(Index == CCollision::COLFLAG_RED && m_pClient->m_Techlevel[0] >= 2)
							Sprite = SPRITE_BLOCK_RED_2_APP;
						else if(Index == (CCollision::COLFLAG_RED | CCollision::COLFLAG_TL3) && m_pClient->m_Techlevel[0] == 3)
							Sprite = SPRITE_BLOCK_RED_3_APP;
						else if(Index == CCollision::COLFLAG_BLUE && m_pClient->m_Techlevel[1] >= 2)
							Sprite = SPRITE_BLOCK_BLUE_2_APP;
						else if(Index == (CCollision::COLFLAG_BLUE | CCollision::COLFLAG_TL3) && m_pClient->m_Techlevel[1] == 3)
							Sprite = SPRITE_BLOCK_BLUE_3_APP;
					}

					if(Sprite != -1)
					{
						Graphics()->QuadsBegin();
						RenderTools()->SelectSprite(Sprite);
						Graphics()->QuadsSetRotation(0);
						IGraphics::CQuadItem QuadItem(i % pLayers->GameLayer()->m_Width * 32 + 16, i / pLayers->GameLayer()->m_Width * 32 + 16, 33, 33);
						Graphics()->QuadsDraw(&QuadItem, 1);
						Graphics()->QuadsEnd();
					}
				}
			}
		}
		if(!g_Config.m_GfxNoclip)
			Graphics()->ClipDisable();
	}

	if(!g_Config.m_GfxNoclip)
		Graphics()->ClipDisable();

	// reset the screen like it was before
	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
}
예제 #14
0
파일: hud.cpp 프로젝트: H-M-H/MineTee
// MineTee
void CHud::RenderInventoryHud()
{
	int LocalID = m_pClient->m_Snap.m_LocalClientID;
    if (m_pClient->m_pChat->IsActive() || !m_pClient->m_Snap.m_aCharacters[LocalID].m_Active)
        return;

    //draw outbox
    const float outboxSize = 250.0f;
    CUIRect Outbox = { (m_Width/2-outboxSize/2)+2.5f, m_Height-33.0f, outboxSize-10.0f, 30.0f };
    //Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.6f);
    //RenderTools()->DrawRoundRectExt(m_Width/2-outboxSize/2, m_Height-30.f, outboxSize, 50.0f, 5.0f, CUI::CORNER_ALL);

    // Item Name
    int SelectedItem = m_pClient->m_Inventory.m_Items[m_pClient->m_Inventory.m_Selected]-NUM_WEAPONS;
    CBlockManager::CBlockInfo *pInfoBlock = m_pClient->m_BlockManager.GetBlockInfo(SelectedItem);
    if (SelectedItem >= 0 && pInfoBlock)
	{
		float TWidth = TextRender()->TextWidth(0, 4.0f, pInfoBlock->m_aName, -1);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 0.85f);
		TextRender()->Text(0x0, (m_Width/2-TWidth/2), Outbox.y - 8.0f, 4.0f, pInfoBlock->m_aName, -1);
    }

    Graphics()->TextureSet(-1);
    Graphics()->QuadsBegin();

    //draw outbox
    CNetObj_Character LocalNetChar = m_pClient->m_Snap.m_aCharacters[LocalID].m_Cur;
    if (LocalNetChar.m_PlayerFlags&PLAYERFLAG_BGPAINT)
        Graphics()->SetColor(1.0f, 0.5f, 0.25f, 0.6f);
    else if (LocalNetChar.m_PlayerFlags&PLAYERFLAG_FGPAINT)
        Graphics()->SetColor(0.25f, 0.5f, 1.0f, 0.6f);
    else
        Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.6f);
    RenderTools()->DrawRoundRectExt(Outbox.x, Outbox.y, Outbox.w, Outbox.h, 5.0f, CUI::CORNER_ALL);

    //draw cells
    const float cellSize = (outboxSize-9.0f-35.0f)/9.0f;
    Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.6f);
    for (int i=0; i<9; i++)
    {
        if (i != m_pClient->m_Inventory.m_Selected)
            Graphics()->SetColor(0.5f, 0.5f, 0.5f, 0.8f);
        else
            Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.8f);

        RenderTools()->DrawRoundRectExt((m_Width/2-outboxSize/2)+5.0f+3.0f+(i*cellSize)+(3.0f*i), m_Height-30.0f, cellSize, 14.0f, 0.0f, 0);

        if (i != m_pClient->m_Inventory.m_Selected)
            Graphics()->SetColor(0.5f, 0.5f, 0.5f, 0.4f);
        else
            Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.4f);

        RenderTools()->DrawRoundRectExt((m_Width/2-outboxSize/2)+5.0f+3.0f+(i*cellSize)+(3.0f*i), m_Height-(30.0f-14.0f), cellSize, 10.0f, 0.0f, 0);
    }

    Graphics()->QuadsEnd();

    //draw items
    if (Layers()->MineTeeLayer())
    {
		char buff[4];
		Graphics()->TextureSet(m_pClient->m_pMapimages->Get(Layers()->MineTeeLayer()->m_Image));
		for (int i=0; i<9; i++)
		{
			int item = m_pClient->m_Inventory.m_Items[i];
			int ammo = m_pClient->m_Inventory.m_Ammo[i];
			if (item == NUM_WEAPONS+CBlockManager::MAX_BLOCKS)
				continue;

			float x = (m_Width/2-outboxSize/2)+5.0f+3.0f+(i*cellSize)+(3.0f*i);
			float y = m_Height-30.f;

			if (item >= NUM_WEAPONS)
			{
				Graphics()->TextureSet(m_pClient->m_pMapimages->Get(Layers()->MineTeeLayer()->m_Image));
				RenderTools()->RenderTile((item-NUM_WEAPONS)%CBlockManager::MAX_BLOCKS, vec2(x+7.5f, y+3.5f), 8.0f);
			}
			else
			{
				Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
				Graphics()->QuadsBegin();
					RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[item%NUM_WEAPONS].m_pSpriteBody);
					Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
					IGraphics::CQuadItem QuadItem(x,y,24,16);
					Graphics()->QuadsDrawTL(&QuadItem, 1);
				Graphics()->QuadsEnd();
			}

			str_format(buff, sizeof(buff), "%i", ammo);
			float TWidth = TextRender()->TextWidth(0, 8.0f, buff, -1);
			TextRender()->TextColor(1.0f, 1.0f, 1.0f, 0.85f);
			TextRender()->Text(0x0, (x+cellSize/2-TWidth/2), (y+14.0f)+5.0f-6.0f, 8.0f, buff, -1);
			TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
		}
    }
}
예제 #15
0
파일: nameplates.cpp 프로젝트: Laxa/ddnet
void CNamePlates::RenderNameplate(
	const CNetObj_Character *pPrevChar,
	const CNetObj_Character *pPlayerChar,
	const CNetObj_PlayerInfo *pPlayerInfo
	)
{
	float IntraTick = Client()->IntraGameTick();
	int ClientID = pPlayerInfo->m_ClientID;

	vec2 Position;
	if((!m_pClient->AntiPingPlayers() && !pPlayerInfo->m_Local) || m_pClient->m_Snap.m_SpecInfo.m_Active)
	{
		Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), IntraTick);
	}
	else if(!m_pClient->AntiPingPlayers() && pPlayerInfo->m_Local)
	{
		Position = vec2(m_pClient->m_LocalCharacterPos.x, m_pClient->m_LocalCharacterPos.y);
	}
	else
	{
		Position = m_pPlayers->m_CurPredictedPos[ClientID];
	}

	bool OtherTeam;

	if(m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Team == TEAM_SPECTATORS && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)
		OtherTeam = false;
	else if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW)
		OtherTeam = m_pClient->m_Teams.Team(pPlayerInfo->m_ClientID) != m_pClient->m_Teams.Team(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID);
	else
		OtherTeam = m_pClient->m_Teams.Team(pPlayerInfo->m_ClientID) != m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientID);

	float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
	float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f;
	// render name plate
	if(!pPlayerInfo->m_Local || g_Config.m_ClNameplatesOwn)
	{
		float a = 1;
		if(g_Config.m_ClNameplatesAlways == 0)
			a = clamp(1-powf(distance(m_pClient->m_pControls->m_TargetPos[g_Config.m_ClDummy], Position)/200.0f,16.0f), 0.0f, 1.0f);

		const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName;
		if(str_comp(pName, m_aNamePlates[ClientID].m_aName) != 0 || FontSize != m_aNamePlates[ClientID].m_NameTextFontSize)
		{
			mem_copy(m_aNamePlates[ClientID].m_aName, pName, sizeof(m_aNamePlates[ClientID].m_aName));
			m_aNamePlates[ClientID].m_NameTextFontSize = FontSize;

			m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(0, FontSize, pName, -1);

			if(m_aNamePlates[ClientID].m_NameTextContainerIndex != -1)
				TextRender()->DeleteTextContainer(m_aNamePlates[ClientID].m_NameTextContainerIndex);

			CTextCursor Cursor;
			TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER);
			Cursor.m_LineWidth = -1;

			// create nameplates at standard zoom
			float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
			Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
			MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup());
			m_aNamePlates[ClientID].m_NameTextContainerIndex = TextRender()->CreateTextContainer(&Cursor, pName);
			Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
		}

		if(g_Config.m_ClNameplatesClan)
		{
			const char *pClan = m_pClient->m_aClients[ClientID].m_aClan;
			if(str_comp(pClan, m_aNamePlates[ClientID].m_aClanName) != 0 || FontSizeClan != m_aNamePlates[ClientID].m_ClanNameTextFontSize)
			{
				mem_copy(m_aNamePlates[ClientID].m_aClanName, pClan, sizeof(m_aNamePlates[ClientID].m_aClanName));
				m_aNamePlates[ClientID].m_ClanNameTextFontSize = FontSizeClan;

				m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(0, FontSizeClan, pClan, -1);

				if(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex != -1)
					TextRender()->DeleteTextContainer(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex);

				CTextCursor Cursor;
				TextRender()->SetCursor(&Cursor, 0, 0, FontSizeClan, TEXTFLAG_RENDER);
				Cursor.m_LineWidth = -1;

				// create nameplates at standard zoom
				float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
				Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
				MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup());
				m_aNamePlates[ClientID].m_ClanNameTextContainerIndex = TextRender()->CreateTextContainer(&Cursor, pClan);
				Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
			}
		}

		float tw = m_aNamePlates[ClientID].m_NameTextWidth;
		vec3 rgb = vec3(1.0f, 1.0f, 1.0f);
		if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Teams.Team(ClientID))
			rgb = HslToRgb(vec3(m_pClient->m_Teams.Team(ClientID) / 64.0f, 1.0f, 0.75f));

		STextRenderColor TColor;
		STextRenderColor TOutlineColor;

		if(OtherTeam)
		{
			TOutlineColor.Set(0.0f, 0.0f, 0.0f, 0.2f);
			TColor.Set(rgb.r, rgb.g, rgb.b, g_Config.m_ClShowOthersAlpha / 100.0f);
		}
		else
		{
			TOutlineColor.Set(0.0f, 0.0f, 0.0f, 0.5f*a);
			TColor.Set(rgb.r, rgb.g, rgb.b, a);
		}
		if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS)
		{
			if(m_pClient->m_aClients[ClientID].m_Team == TEAM_RED)
				TColor.Set(1.0f, 0.5f, 0.5f, a);
			else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE)
				TColor.Set(0.7f, 0.7f, 1.0f, a);
		}

		if(m_aNamePlates[ClientID].m_NameTextContainerIndex != -1)
			TextRender()->RenderTextContainer(m_aNamePlates[ClientID].m_NameTextContainerIndex, &TColor, &TOutlineColor, Position.x - tw / 2.0f, Position.y - FontSize - 38.0f);

		if(g_Config.m_ClNameplatesClan)
		{
			if(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex != -1)
				TextRender()->RenderTextContainer(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex, &TColor, &TOutlineColor, Position.x - m_aNamePlates[ClientID].m_ClanNameTextWidth / 2.0f, Position.y - FontSize - FontSizeClan - 38.0f);
		}

		if(g_Config.m_Debug) // render client id when in debug as well
		{
			char aBuf[128];
			str_format(aBuf, sizeof(aBuf),"%d", pPlayerInfo->m_ClientID);
			float Offset = g_Config.m_ClNameplatesClan ? (FontSize * 2 + FontSizeClan) : (FontSize * 2);
			float tw_id = TextRender()->TextWidth(0, FontSize, aBuf, -1);
			TextRender()->Text(0, Position.x-tw_id/2.0f, Position.y-Offset-38.0f, 28.0f, aBuf, -1);
		}

		TextRender()->TextColor(1,1,1,1);
		TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
	}
}
예제 #16
0
void CMapLayers::OnRender()
{
	if((Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK && !m_pMenuMap))
		return;

	CLayers *pLayers = 0;
	if(Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK)
		pLayers = Layers();
	else if(m_pMenuMap->IsLoaded())
		pLayers = m_pMenuLayers;

	if(!pLayers)
		return;

	CUIRect Screen;
	Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);

	vec2 Center = m_pClient->m_pCamera->m_Center;
	//float center_x = gameclient.camera->center.x;
	//float center_y = gameclient.camera->center.y;

	bool PassedGameLayer = false;

	for(int g = 0; g < pLayers->NumGroups(); g++)
	{
		CMapItemGroup *pGroup = pLayers->GetGroup(g);

		if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)
		{
			// set clipping
			float Points[4];
			MapScreenToGroup(Center.x, Center.y, pLayers->GameGroup());
			Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
			float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);
			float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);
			float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);
			float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);

			Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),
				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));
		}

		MapScreenToGroup(Center.x, Center.y, pGroup);

		for(int l = 0; l < pGroup->m_NumLayers; l++)
		{
			CMapItemLayer *pLayer = pLayers->GetLayer(pGroup->m_StartLayer+l);
			bool Render = false;
			bool IsGameLayer = false;

			if(pLayer == (CMapItemLayer*)pLayers->GameLayer())
			{
				IsGameLayer = true;
				PassedGameLayer = 1;
			}

			// skip rendering if detail layers if not wanted
			if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))
				continue;

			if(m_Type == -1)
				Render = true;
			else if(m_Type == 0)
			{
				if(PassedGameLayer && (Client()->State() == IClient::STATE_ONLINE || Client()->State() == IClient::STATE_DEMOPLAYBACK))
					return;
				Render = true;
			}
			else
			{
				if(PassedGameLayer && !IsGameLayer)
					Render = true;
			}

			if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))
			{
				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
				CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTMap->m_Data);
				CServerInfo CurrentServerInfo;
				Client()->GetServerInfo(&CurrentServerInfo);
				char aFilename[256];
				str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);
				IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
				if(File)
				{
					for(int y = 0; y < pTMap->m_Height; y++)
					{
						for(int x = 0; x < pTMap->m_Width; x++)
							io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));
						io_write_newline(File);
					}
					io_close(File);
				}
			}

			if(Render && !IsGameLayer)
			{
				//layershot_begin();

				if(pLayer->m_Type == LAYERTYPE_TILES)
				{
					CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
					if(pTMap->m_Image == -1)
						Graphics()->TextureClear();
					else
						Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));

					CTile *pTiles = (CTile *)pLayers->Map()->GetData(pTMap->m_Data);
					Graphics()->BlendNone();
					vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f);
					RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
													EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
					Graphics()->BlendNormal();
					RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
													EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
				}
				else if(pLayer->m_Type == LAYERTYPE_QUADS)
				{
					CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
					if(pQLayer->m_Image == -1)
						Graphics()->TextureClear();
					else
						Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image));

					CQuad *pQuads = (CQuad *)pLayers->Map()->GetDataSwapped(pQLayer->m_Data);

					Graphics()->BlendNone();
					RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this);
					Graphics()->BlendNormal();
					RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this);
				}

				//layershot_end();
			}
		}
		if(!g_Config.m_GfxNoclip)
			Graphics()->ClipDisable();
	}

	if(!g_Config.m_GfxNoclip)
		Graphics()->ClipDisable();

	// reset the screen like it was before
	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
}
예제 #17
0
파일: maplayers.cpp 프로젝트: def-/HClient
void CMapLayers::OnRender()
{
	if (Client()->State() != IClient::STATE_OFFLINE && Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)
		return;
    else if (Client()->State() == IClient::STATE_OFFLINE && !Client()->BackgroundLoaded())
        return;

	CUIRect Screen;
	Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);

	vec2 Center = m_pClient->m_pCamera->m_Center;
	//float center_x = gameclient.camera->center.x;
	//float center_y = gameclient.camera->center.y;

    CMapItemLayerTilemap *pGTMap = m_pLayers->GameLayer();
    CTile *pGameTiles = (CTile *)m_pLayers->Map()->GetData(pGTMap->m_Data);

	bool PassedGameLayer = false;
	for(int g = 0; g < m_pLayers->NumGroups(); g++)
	{
		CMapItemGroup *pGroup = m_pLayers->GetGroup(g);
		if (!pGroup)
            continue;

		if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)
		{
			// set clipping
			float Points[4];
			MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup());
			Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
			float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);
			float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);
			float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);
			float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);

			Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),
				(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));
		}

		MapScreenToGroup(Center.x, Center.y, pGroup, g==0);

		for(int l = 0; l < pGroup->m_NumLayers; l++)
		{
			CMapItemLayer *pLayer = m_pLayers->GetLayer(pGroup->m_StartLayer+l);
			bool Render = false;
			bool IsGameLayer = false;

			if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer())
			{
				IsGameLayer = true;
				PassedGameLayer = 1;
			}

			// skip rendering if detail layers if not wanted
			if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer)
				continue;

			if(m_Type == -1)
				Render = true;
			else if(m_Type == 0)
			{
				if(PassedGameLayer)
					return;
				Render = true;
			}
			else
			{
				if(PassedGameLayer && !IsGameLayer)
					Render = true;
			}

			if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))
			{
				CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
				CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);
				CServerInfo CurrentServerInfo;
				Client()->GetServerInfo(&CurrentServerInfo);
				char aFilename[256];
				str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);
				IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorageTW::TYPE_SAVE);
				if(File)
				{
					#if defined(CONF_FAMILY_WINDOWS)
						static const char Newline[] = "\r\n";
					#else
						static const char Newline[] = "\n";
					#endif
					for(int y = 0; y < pTMap->m_Height; y++)
					{
						for(int x = 0; x < pTMap->m_Width; x++)
							io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));
						io_write(File, Newline, sizeof(Newline)-1);
					}
					io_close(File);
				}
			}

			if(Render && !IsGameLayer)
			{
				//layershot_begin();

				if(pLayer->m_Type == LAYERTYPE_TILES)
				{
					CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
					if(pTMap->m_Image == -1)
						Graphics()->TextureSet(-1);
					else
						Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));

					CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);
					Graphics()->BlendNone();
					vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f);

                    CServerInfo Info;
                    Client()->GetServerInfo(&Info);
                    int MineTeeLayer = 0;

                    if (str_find_nocase(Info.m_aGameType, "minetee") || str_find_nocase(Info.m_aGameType, "ctf-break"))
                    {
                        if (pTMap == m_pLayers->MineTeeLayer())
                            MineTeeLayer = 1;
                        else if (pTMap == m_pLayers->MineTeeBGLayer())
                            MineTeeLayer = 2;
                        else if (pTMap == m_pLayers->MineTeeFGLayer())
                            MineTeeLayer = 3;
                    }

					if (m_pLayers->GameLayer() && g_Config.m_ddrShowHiddenWays && str_find_nocase(Info.m_aGameType, "race"))
					{
                        Graphics()->BlendNormal();
                        RenderTools()->RenderTilemap(pGameTiles, pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT,
                                                     EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset, MineTeeLayer, false, m_pClient->m_pEffects);
					}
                    else
                    {
                        Graphics()->BlendNone();
                        RenderTools()->RenderTilemap(0x0, pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
                                                        EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset, MineTeeLayer, false, m_pClient->m_pEffects);
                        Graphics()->BlendNormal();
                        RenderTools()->RenderTilemap(0x0, pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
                                                        EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset, MineTeeLayer, false, m_pClient->m_pEffects);
                    }

                    if (MineTeeLayer == 1)
                        RenderTools()->RenderTilemap(0x0, pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
                                                        EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset, MineTeeLayer, true, 0x0);
				}
				else if(pLayer->m_Type == LAYERTYPE_QUADS)
				{
					CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
					if(pQLayer->m_Image == -1)
						Graphics()->TextureSet(-1);
					else
						Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image));

					CQuad *pQuads = (CQuad *)m_pLayers->Map()->GetDataSwapped(pQLayer->m_Data);

					Graphics()->BlendNone();
					RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this);
					Graphics()->BlendNormal();
					RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this);
				}

				//layershot_end();
			}
		}
		if(!g_Config.m_GfxNoclip)
			Graphics()->ClipDisable();
	}

    //H-Client
    //NIGHT-DAY
    CServerInfo Info;
    Client()->GetServerInfo(&Info);
    if (str_find_nocase(Info.m_aGameType,"minetee") && m_pLayers->TileLights() && m_pLayers->MineTeeLayer() && !Graphics()->Tumbtail())
    {
        CTile *pMTLTiles = 0x0;
        CTile *pMTTiles = 0x0;
        static int s_LightLevel = 0;

        if (300 < 0)
            s_LightLevel = 0;
        else
        {
            int Time = -1;
            if (m_pClient->m_Snap.m_pGameInfoObj)
                Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)Client()->GameTickSpeed();
            m_MineTeeIsDay = (static_cast<int>(Time/300)%2)?false:true;

            float tt = Time;
            int itt = tt/300;
            tt/=300;

            if (tt-itt < 0.02)
                s_LightLevel=(m_MineTeeIsDay)?0:3;
            else if (tt-itt < 0.025)
                s_LightLevel=(m_MineTeeIsDay)?1:2;
            else if (tt-itt < 0.035)
                s_LightLevel=(m_MineTeeIsDay)?2:1;
            else if (tt-itt < 0.045)
                s_LightLevel=(m_MineTeeIsDay)?3:0;
            else
                s_LightLevel=(m_MineTeeIsDay)?4:0;
        }



        if (s_LightLevel >= 0)
        {
            CMapItemLayerTilemap *pMTMap = m_pLayers->MineTeeLayer();
            if (pMTMap)
                pMTTiles = (CTile *)m_pLayers->Map()->GetData(pMTMap->m_Data);

            if (pMTTiles)
                RenderTools()->UpdateLights(Collision(), pMTTiles, m_pLayers->TileLights(), Layers()->Lights()->m_Width, Layers()->Lights()->m_Height, s_LightLevel);
        }
    }

	if(!g_Config.m_GfxNoclip)
		Graphics()->ClipDisable();

	// reset the screen like it was before
	Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
}
예제 #18
0
파일: maplayers.cpp 프로젝트: def-/HClient
void CMapLayers::OnInit()
{
    m_MineTeeIsDay = false;
	m_pLayers = Layers();
	m_EnvStart = time_get();
}
예제 #19
0
파일: hud.cpp 프로젝트: H-M-H/MineTee
void CHud::RenderCursor()
{
    //H-Client: IF Change
	if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK)
		return;

	MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup());
	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
	Graphics()->QuadsBegin();

	// render cursor
	if (m_pClient->m_Snap.m_pLocalCharacter->m_Weapon >= NUM_WEAPONS) // MineTee
        RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[WEAPON_HAMMER].m_pSpriteCursor);
	else
        RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteCursor);
	float CursorSize = 64;
	RenderTools()->DrawSprite(m_pClient->m_pControls->m_TargetPos.x, m_pClient->m_pControls->m_TargetPos.y, CursorSize);
	Graphics()->QuadsEnd();
}
예제 #20
0
void CMapLayers::OnInit()
{
	m_pLayers = Layers();
}
예제 #21
0
파일: hud.cpp 프로젝트: wthnonck/tdtw
void CHud::RenderCursor()
{
	if(!m_pClient->m_Snap.m_pLocalCharacter)
		return;
		
	MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup());
	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
	Graphics()->QuadsBegin();

	// render cursor
	RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[m_pClient->m_Snap.m_pLocalCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteCursor);
	float CursorSize = 64;
	RenderTools()->DrawSprite(m_pClient->m_pControls->m_TargetPos.x, m_pClient->m_pControls->m_TargetPos.y, CursorSize);
	Graphics()->QuadsEnd();
}