diff --git a/data/editor/entities_clear.png b/data/editor/entities_clear.png deleted file mode 100644 index 904c8dae1..000000000 Binary files a/data/editor/entities_clear.png and /dev/null differ diff --git a/data/editor/entities_clear/ddnet.png b/data/editor/entities_clear/ddnet.png new file mode 100644 index 000000000..911a2ad7e Binary files /dev/null and b/data/editor/entities_clear/ddnet.png differ diff --git a/data/editor/entities_clear/ddrace.png b/data/editor/entities_clear/ddrace.png new file mode 100644 index 000000000..206c68191 Binary files /dev/null and b/data/editor/entities_clear/ddrace.png differ diff --git a/data/editor/entities_clear/fng.png b/data/editor/entities_clear/fng.png new file mode 100644 index 000000000..27317932a Binary files /dev/null and b/data/editor/entities_clear/fng.png differ diff --git a/data/editor/entities_clear/race.png b/data/editor/entities_clear/race.png new file mode 100644 index 000000000..830ee10f9 Binary files /dev/null and b/data/editor/entities_clear/race.png differ diff --git a/data/editor/entities_clear/vanilla.png b/data/editor/entities_clear/vanilla.png new file mode 100644 index 000000000..c34c9f008 Binary files /dev/null and b/data/editor/entities_clear/vanilla.png differ diff --git a/src/engine/serverbrowser.h b/src/engine/serverbrowser.h index 612fa68fd..d0ffa3b44 100644 --- a/src/engine/serverbrowser.h +++ b/src/engine/serverbrowser.h @@ -51,9 +51,14 @@ public: CClient m_aClients[MAX_CLIENTS]; }; +bool IsVanilla(const CServerInfo *pInfo); +bool IsCatch(const CServerInfo *pInfo); +bool IsInsta(const CServerInfo *pInfo); +bool IsFNG(const CServerInfo *pInfo); bool IsRace(const CServerInfo *pInfo); bool IsDDRace(const CServerInfo *pInfo); bool IsDDNet(const CServerInfo *pInfo); + bool Is64Player(const CServerInfo *pInfo); bool IsPlus(const CServerInfo *pInfo); diff --git a/src/engine/shared/serverbrowser.cpp b/src/engine/shared/serverbrowser.cpp index 45bc4418d..6be1b80b5 100644 --- a/src/engine/shared/serverbrowser.cpp +++ b/src/engine/shared/serverbrowser.cpp @@ -1,6 +1,32 @@ #include #include +// gametypes + +bool IsVanilla(const CServerInfo *pInfo) +{ + return !str_comp(pInfo->m_aGameType, "DM") + || !str_comp(pInfo->m_aGameType, "TDM") + || !str_comp(pInfo->m_aGameType, "CTF"); +} + +bool IsCatch(const CServerInfo *pInfo) +{ + return str_find_nocase(pInfo->m_aGameType, "catch"); +} + +bool IsInsta(const CServerInfo *pInfo) +{ + return str_find_nocase(pInfo->m_aGameType, "idm") + || str_find_nocase(pInfo->m_aGameType, "itdm") + || str_find_nocase(pInfo->m_aGameType, "ictf"); +} + +bool IsFNG(const CServerInfo *pInfo) +{ + return str_find_nocase(pInfo->m_aGameType, "fng"); +} + bool IsRace(const CServerInfo *pInfo) { return str_find_nocase(pInfo->m_aGameType, "race") @@ -19,6 +45,8 @@ bool IsDDNet(const CServerInfo *pInfo) || str_find_nocase(pInfo->m_aGameType, "ddnet"); } +// other + bool Is64Player(const CServerInfo *pInfo) { return str_find(pInfo->m_aGameType, "64") diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index c6d41e650..1afc7f682 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -88,11 +89,26 @@ void CMapImages::LoadBackground(class IMap *pMap) int CMapImages::GetEntities() { - if(m_EntitiesTextures == -1) + CServerInfo Info; + Client()->GetServerInfo(&Info); + + if(m_EntitiesTextures == -1 || str_comp(m_aEntitiesGameType, Info.m_aGameType)) { - m_EntitiesTextures = Graphics()->LoadTexture("editor/entities_clear.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); - if(m_EntitiesTextures == -1) - m_EntitiesTextures = Graphics()->LoadTexture("editor/entities.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); + char file[64] = "vanilla"; + if(IsDDNet(&Info)) + str_copy(file, "ddnet", sizeof(file)); + else if(IsDDRace(&Info)) + str_copy(file, "ddrace", sizeof(file)); + else if(IsRace(&Info)) + str_copy(file, "race", sizeof(file)); + else if(IsFNG(&Info)) + str_copy(file, "fng", sizeof(file)); + + char path[64]; + str_format(path, sizeof(path), "editor/entities_clear/%s.png", file); + m_EntitiesTextures = Graphics()->LoadTexture(path, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); + + str_copy(m_aEntitiesGameType, Info.m_aGameType, sizeof(m_aEntitiesGameType)); } return m_EntitiesTextures; } diff --git a/src/game/client/components/mapimages.h b/src/game/client/components/mapimages.h index 089d912a4..0c24e5c56 100644 --- a/src/game/client/components/mapimages.h +++ b/src/game/client/components/mapimages.h @@ -10,6 +10,8 @@ class CMapImages : public CComponent int m_aTextures[64]; int m_Count; + + char m_aEntitiesGameType[16]; public: CMapImages(); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index bc4b101a7..2fa7c97ea 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -432,24 +432,20 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) { vec3 hsl = vec3(1.0f, 1.0f, 1.0f); - if (!str_comp(pItem->m_aGameType, "DM") - || !str_comp(pItem->m_aGameType, "TDM") - || !str_comp(pItem->m_aGameType, "CTF")) - hsl = vec3(0.33f, 1.0f, 0.75f); // Vanilla - else if (str_find_nocase(pItem->m_aGameType, "catch")) - hsl = vec3(0.17f, 1.0f, 0.75f); // Catch - else if (str_find_nocase(pItem->m_aGameType, "idm") - || str_find_nocase(pItem->m_aGameType, "itdm") - || str_find_nocase(pItem->m_aGameType, "ictf")) - hsl = vec3(0.00f, 1.0f, 0.75f); // Instagib - else if (str_find_nocase(pItem->m_aGameType, "fng")) - hsl = vec3(0.83f, 1.0f, 0.75f); // FNG + if (IsVanilla(pItem)) + hsl = vec3(0.33f, 1.0f, 0.75f); + else if (IsCatch(pItem)) + hsl = vec3(0.17f, 1.0f, 0.75f); + else if (IsInsta(pItem)) + hsl = vec3(0.00f, 1.0f, 0.75f); + else if (IsFNG(pItem)) + hsl = vec3(0.83f, 1.0f, 0.75f); else if (IsDDNet(pItem)) - hsl = vec3(0.58f, 1.0f, 0.75f); // DDNet + hsl = vec3(0.58f, 1.0f, 0.75f); else if (IsDDRace(pItem)) - hsl = vec3(0.75f, 1.0f, 0.75f); // DDRace + hsl = vec3(0.75f, 1.0f, 0.75f); else if (IsRace(pItem)) - hsl = vec3(0.46f, 1.0f, 0.75f); // Race + hsl = vec3(0.46f, 1.0f, 0.75f); vec3 rgb = HslToRgb(hsl); TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);