about summary refs log tree commit diff
path: root/src/game/client/components/countryflags.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/client/components/countryflags.cpp')
-rw-r--r--src/game/client/components/countryflags.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/src/game/client/components/countryflags.cpp b/src/game/client/components/countryflags.cpp
index c2af9a59..e62f4e51 100644
--- a/src/game/client/components/countryflags.cpp
+++ b/src/game/client/components/countryflags.cpp
@@ -6,6 +6,7 @@
 #include <engine/console.h>
 #include <engine/graphics.h>
 #include <engine/storage.h>
+#include <engine/textrender.h>
 #include <engine/shared/config.h>
 #include <engine/shared/linereader.h>
 
@@ -57,22 +58,30 @@ void CCountryFlags::LoadCountryflagsIndexfile()
 
 		// load the graphic file
 		char aBuf[128];
-		str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin);
 		CImageInfo Info;
-		if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL))
+		if(g_Config.m_ClLoadCountryFlags)
 		{
-			char aMsg[128];
-			str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf);
-			Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aMsg);
-			continue;
+			str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin);
+			if(!Graphics()->LoadPNG(&Info, aBuf, IStorage::TYPE_ALL))
+			{
+				char aMsg[128];
+				str_format(aMsg, sizeof(aMsg), "failed to load '%s'", aBuf);
+				Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aMsg);
+				continue;
+			}
 		}
 
 		// add entry
 		CCountryFlag CountryFlag;
 		CountryFlag.m_CountryCode = CountryCode;
 		str_copy(CountryFlag.m_aCountryCodeString, aOrigin, sizeof(CountryFlag.m_aCountryCodeString));
-		CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
-		mem_free(Info.m_pData);
+		if(g_Config.m_ClLoadCountryFlags)
+		{
+			CountryFlag.m_Texture = Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0);
+			mem_free(Info.m_pData);
+		}
+		else
+			CountryFlag.m_Texture = -1;
 		if(g_Config.m_Debug)
 		{
 			str_format(aBuf, sizeof(aBuf), "loaded country flag '%s'", aOrigin);
@@ -117,3 +126,24 @@ const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(int Index) const
 {
 	return &m_aCountryFlags[max(0, Index%m_aCountryFlags.size())];
 }
+
+void CCountryFlags::Render(int CountryCode, const vec4 *pColor, float x, float y, float w, float h)
+{
+	const CCountryFlag *pFlag = GetByCountryCode(CountryCode);
+	if(pFlag->m_Texture != -1)
+	{
+		Graphics()->TextureSet(pFlag->m_Texture);
+		Graphics()->QuadsBegin();
+		Graphics()->SetColor(pColor->r, pColor->g, pColor->b, pColor->a);
+		IGraphics::CQuadItem QuadItem(x, y, w, h);
+		Graphics()->QuadsDrawTL(&QuadItem, 1);
+		Graphics()->QuadsEnd();
+	}
+	else
+	{
+		CTextCursor Cursor;
+		TextRender()->SetCursor(&Cursor, x, y, 10.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
+		Cursor.m_LineWidth = w;
+		TextRender()->TextEx(&Cursor, pFlag->m_aCountryCodeString, -1);
+	}
+}