2022-05-18 16:00:05 +00:00
|
|
|
#include <base/system.h>
|
|
|
|
|
2020-09-26 07:37:35 +00:00
|
|
|
#include <engine/shared/config.h>
|
|
|
|
#include <engine/storage.h>
|
|
|
|
#include <engine/textrender.h>
|
|
|
|
#include <game/client/gameclient.h>
|
2022-05-29 16:33:38 +00:00
|
|
|
#include <game/localization.h>
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
|
2022-05-18 16:00:05 +00:00
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
using namespace std::chrono_literals;
|
|
|
|
|
2022-04-02 11:37:59 +00:00
|
|
|
typedef std::function<void()> TMenuAssetScanLoadedFunc;
|
|
|
|
|
|
|
|
struct SMenuAssetScanUser
|
|
|
|
{
|
|
|
|
void *m_pUser;
|
|
|
|
TMenuAssetScanLoadedFunc m_LoadedFunc;
|
|
|
|
};
|
|
|
|
|
2022-03-15 15:52:41 +00:00
|
|
|
// IDs of the tabs in the Assets menu
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ASSETS_TAB_ENTITIES = 0,
|
|
|
|
ASSETS_TAB_GAME = 1,
|
|
|
|
ASSETS_TAB_EMOTICONS = 2,
|
|
|
|
ASSETS_TAB_PARTICLES = 3,
|
2022-06-14 17:28:51 +00:00
|
|
|
ASSETS_TAB_HUD = 4,
|
2022-06-26 22:38:49 +00:00
|
|
|
ASSETS_TAB_EXTRAS = 5,
|
|
|
|
NUMBER_OF_ASSETS_TABS = 6,
|
2022-03-15 15:52:41 +00:00
|
|
|
};
|
|
|
|
|
2020-09-26 07:37:35 +00:00
|
|
|
void CMenus::LoadEntities(SCustomEntities *pEntitiesItem, void *pUser)
|
|
|
|
{
|
2022-04-02 11:37:59 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2021-09-13 08:06:34 +00:00
|
|
|
char aBuff[IO_MAX_PATH_LENGTH];
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
if(str_comp(pEntitiesItem->m_aName, "default") == 0)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < MAP_IMAGE_MOD_TYPE_COUNT; ++i)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
str_format(aBuff, sizeof(aBuff), "editor/entities_clear/%s.png", gs_apModEntitiesNames[i]);
|
2020-09-26 07:37:35 +00:00
|
|
|
CImageInfo ImgInfo;
|
|
|
|
if(pThis->Graphics()->LoadPNG(&ImgInfo, aBuff, IStorage::TYPE_ALL))
|
|
|
|
{
|
|
|
|
pEntitiesItem->m_aImages[i].m_Texture = pThis->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0);
|
2020-11-25 12:05:53 +00:00
|
|
|
pThis->Graphics()->FreePNG(&ImgInfo);
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2012-08-12 12:02:50 +00:00
|
|
|
if(!pEntitiesItem->m_RenderTexture.IsValid())
|
2020-09-26 07:37:35 +00:00
|
|
|
pEntitiesItem->m_RenderTexture = pEntitiesItem->m_aImages[i].m_Texture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int i = 0; i < MAP_IMAGE_MOD_TYPE_COUNT; ++i)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
str_format(aBuff, sizeof(aBuff), "assets/entities/%s/%s.png", pEntitiesItem->m_aName, gs_apModEntitiesNames[i]);
|
2020-09-26 07:37:35 +00:00
|
|
|
CImageInfo ImgInfo;
|
|
|
|
if(pThis->Graphics()->LoadPNG(&ImgInfo, aBuff, IStorage::TYPE_ALL))
|
|
|
|
{
|
|
|
|
pEntitiesItem->m_aImages[i].m_Texture = pThis->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0);
|
2020-11-25 12:05:53 +00:00
|
|
|
pThis->Graphics()->FreePNG(&ImgInfo);
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2012-08-12 12:02:50 +00:00
|
|
|
if(!pEntitiesItem->m_RenderTexture.IsValid())
|
2020-09-26 07:37:35 +00:00
|
|
|
pEntitiesItem->m_RenderTexture = pEntitiesItem->m_aImages[i].m_Texture;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str_format(aBuff, sizeof(aBuff), "assets/entities/%s.png", pEntitiesItem->m_aName);
|
|
|
|
if(pThis->Graphics()->LoadPNG(&ImgInfo, aBuff, IStorage::TYPE_ALL))
|
|
|
|
{
|
|
|
|
pEntitiesItem->m_aImages[i].m_Texture = pThis->Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0);
|
2020-11-25 12:05:53 +00:00
|
|
|
pThis->Graphics()->FreePNG(&ImgInfo);
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2012-08-12 12:02:50 +00:00
|
|
|
if(!pEntitiesItem->m_RenderTexture.IsValid())
|
2020-09-26 07:37:35 +00:00
|
|
|
pEntitiesItem->m_RenderTexture = pEntitiesItem->m_aImages[i].m_Texture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenus::EntitiesScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|
|
|
{
|
2022-04-02 11:37:59 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
2020-09-26 07:37:35 +00:00
|
|
|
if(IsDir)
|
|
|
|
{
|
|
|
|
if(pName[0] == '.')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// default is reserved
|
|
|
|
if(str_comp(pName, "default") == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SCustomEntities EntitiesItem;
|
|
|
|
str_copy(EntitiesItem.m_aName, pName, sizeof(EntitiesItem.m_aName));
|
|
|
|
CMenus::LoadEntities(&EntitiesItem, pUser);
|
2022-06-11 19:38:18 +00:00
|
|
|
pThis->m_vEntitiesList.push_back(EntitiesItem);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(str_endswith(pName, ".png"))
|
|
|
|
{
|
2021-09-13 08:06:34 +00:00
|
|
|
char aName[IO_MAX_PATH_LENGTH];
|
2020-09-26 07:37:35 +00:00
|
|
|
str_truncate(aName, sizeof(aName), pName, str_length(pName) - 4);
|
|
|
|
// default is reserved
|
|
|
|
if(str_comp(aName, "default") == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SCustomEntities EntitiesItem;
|
|
|
|
str_copy(EntitiesItem.m_aName, aName, sizeof(EntitiesItem.m_aName));
|
|
|
|
CMenus::LoadEntities(&EntitiesItem, pUser);
|
2022-06-11 19:38:18 +00:00
|
|
|
pThis->m_vEntitiesList.push_back(EntitiesItem);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-02 11:37:59 +00:00
|
|
|
pRealUser->m_LoadedFunc();
|
|
|
|
|
2020-09-26 07:37:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TName>
|
|
|
|
static void LoadAsset(TName *pAssetItem, const char *pAssetName, IGraphics *pGraphics, void *pUser)
|
|
|
|
{
|
2021-09-13 08:06:34 +00:00
|
|
|
char aBuff[IO_MAX_PATH_LENGTH];
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
if(str_comp(pAssetItem->m_aName, "default") == 0)
|
|
|
|
{
|
|
|
|
str_format(aBuff, sizeof(aBuff), "%s.png", pAssetName);
|
|
|
|
CImageInfo ImgInfo;
|
|
|
|
if(pGraphics->LoadPNG(&ImgInfo, aBuff, IStorage::TYPE_ALL))
|
|
|
|
{
|
|
|
|
pAssetItem->m_RenderTexture = pGraphics->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0);
|
2020-11-25 12:05:53 +00:00
|
|
|
pGraphics->FreePNG(&ImgInfo);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str_format(aBuff, sizeof(aBuff), "assets/%s/%s.png", pAssetName, pAssetItem->m_aName);
|
|
|
|
CImageInfo ImgInfo;
|
|
|
|
if(pGraphics->LoadPNG(&ImgInfo, aBuff, IStorage::TYPE_ALL))
|
|
|
|
{
|
|
|
|
pAssetItem->m_RenderTexture = pGraphics->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0);
|
2020-11-25 12:05:53 +00:00
|
|
|
pGraphics->FreePNG(&ImgInfo);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str_format(aBuff, sizeof(aBuff), "assets/%s/%s/%s.png", pAssetName, pAssetItem->m_aName, pAssetName);
|
|
|
|
if(pGraphics->LoadPNG(&ImgInfo, aBuff, IStorage::TYPE_ALL))
|
|
|
|
{
|
|
|
|
pAssetItem->m_RenderTexture = pGraphics->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, ImgInfo.m_pData, ImgInfo.m_Format, 0);
|
2020-11-25 12:05:53 +00:00
|
|
|
pGraphics->FreePNG(&ImgInfo);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TName>
|
2022-06-15 17:34:41 +00:00
|
|
|
static int AssetScan(const char *pName, int IsDir, int DirType, std::vector<TName> &vAssetList, const char *pAssetName, IGraphics *pGraphics, void *pUser)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-04-02 11:37:59 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
2020-09-26 07:37:35 +00:00
|
|
|
if(IsDir)
|
|
|
|
{
|
|
|
|
if(pName[0] == '.')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
// default is reserved
|
|
|
|
if(str_comp(pName, "default") == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
TName AssetItem;
|
|
|
|
str_copy(AssetItem.m_aName, pName, sizeof(AssetItem.m_aName));
|
|
|
|
LoadAsset(&AssetItem, pAssetName, pGraphics, pUser);
|
2022-06-15 17:34:41 +00:00
|
|
|
vAssetList.push_back(AssetItem);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(str_endswith(pName, ".png"))
|
|
|
|
{
|
2021-09-13 08:06:34 +00:00
|
|
|
char aName[IO_MAX_PATH_LENGTH];
|
2020-09-26 07:37:35 +00:00
|
|
|
str_truncate(aName, sizeof(aName), pName, str_length(pName) - 4);
|
|
|
|
// default is reserved
|
|
|
|
if(str_comp(aName, "default") == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
TName AssetItem;
|
|
|
|
str_copy(AssetItem.m_aName, aName, sizeof(AssetItem.m_aName));
|
|
|
|
LoadAsset(&AssetItem, pAssetName, pGraphics, pUser);
|
2022-06-15 17:34:41 +00:00
|
|
|
vAssetList.push_back(AssetItem);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-02 11:37:59 +00:00
|
|
|
pRealUser->m_LoadedFunc();
|
|
|
|
|
2020-09-26 07:37:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CMenus::GameScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|
|
|
{
|
2022-04-02 11:37:59 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
|
|
|
IGraphics *pGraphics = pThis->Graphics();
|
2022-06-11 19:38:18 +00:00
|
|
|
return AssetScan(pName, IsDir, DirType, pThis->m_vGameList, "game", pGraphics, pUser);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CMenus::EmoticonsScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|
|
|
{
|
2022-04-02 11:37:59 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
|
|
|
IGraphics *pGraphics = pThis->Graphics();
|
2022-06-11 19:38:18 +00:00
|
|
|
return AssetScan(pName, IsDir, DirType, pThis->m_vEmoticonList, "emoticons", pGraphics, pUser);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int CMenus::ParticlesScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|
|
|
{
|
2022-04-02 11:37:59 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
|
|
|
IGraphics *pGraphics = pThis->Graphics();
|
2022-06-11 19:38:18 +00:00
|
|
|
return AssetScan(pName, IsDir, DirType, pThis->m_vParticlesList, "particles", pGraphics, pUser);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 15:52:41 +00:00
|
|
|
int CMenus::HudScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|
|
|
{
|
2022-05-20 15:35:22 +00:00
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
|
|
|
IGraphics *pGraphics = pThis->Graphics();
|
2022-06-11 19:38:18 +00:00
|
|
|
return AssetScan(pName, IsDir, DirType, pThis->m_vHudList, "hud", pGraphics, pUser);
|
2022-03-15 15:52:41 +00:00
|
|
|
}
|
|
|
|
|
2022-06-14 17:30:01 +00:00
|
|
|
int CMenus::ExtrasScan(const char *pName, int IsDir, int DirType, void *pUser)
|
|
|
|
{
|
|
|
|
auto *pRealUser = (SMenuAssetScanUser *)pUser;
|
|
|
|
auto *pThis = (CMenus *)pRealUser->m_pUser;
|
|
|
|
IGraphics *pGraphics = pThis->Graphics();
|
|
|
|
return AssetScan(pName, IsDir, DirType, pThis->m_vExtrasList, "extras", pGraphics, pUser);
|
|
|
|
}
|
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
static std::vector<const CMenus::SCustomEntities *> gs_vpSearchEntitiesList;
|
|
|
|
static std::vector<const CMenus::SCustomGame *> gs_vpSearchGamesList;
|
|
|
|
static std::vector<const CMenus::SCustomEmoticon *> gs_vpSearchEmoticonsList;
|
|
|
|
static std::vector<const CMenus::SCustomParticle *> gs_vpSearchParticlesList;
|
|
|
|
static std::vector<const CMenus::SCustomHud *> gs_vpSearchHudList;
|
|
|
|
static std::vector<const CMenus::SCustomExtras *> gs_vpSearchExtrasList;
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
static bool gs_aInitCustomList[NUMBER_OF_ASSETS_TABS] = {
|
2020-09-26 07:37:35 +00:00
|
|
|
true,
|
|
|
|
};
|
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
static size_t gs_aCustomListSize[NUMBER_OF_ASSETS_TABS] = {
|
2020-09-26 07:37:35 +00:00
|
|
|
0,
|
|
|
|
};
|
|
|
|
|
2022-06-26 22:38:49 +00:00
|
|
|
static char s_aFilterString[NUMBER_OF_ASSETS_TABS][50];
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-03-15 15:52:41 +00:00
|
|
|
static int s_CurCustomTab = ASSETS_TAB_ENTITIES;
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-05-23 18:18:32 +00:00
|
|
|
static const CMenus::SCustomItem *GetCustomItem(int CurTab, size_t Index)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-03-15 15:52:41 +00:00
|
|
|
if(CurTab == ASSETS_TAB_ENTITIES)
|
2022-06-30 22:36:32 +00:00
|
|
|
return gs_vpSearchEntitiesList[Index];
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_GAME)
|
2022-06-30 22:36:32 +00:00
|
|
|
return gs_vpSearchGamesList[Index];
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_EMOTICONS)
|
2022-06-30 22:36:32 +00:00
|
|
|
return gs_vpSearchEmoticonsList[Index];
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_PARTICLES)
|
2022-06-30 22:36:32 +00:00
|
|
|
return gs_vpSearchParticlesList[Index];
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_HUD)
|
2022-06-30 22:36:32 +00:00
|
|
|
return gs_vpSearchHudList[Index];
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_EXTRAS)
|
2022-06-30 22:36:32 +00:00
|
|
|
return gs_vpSearchExtrasList[Index];
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TName>
|
2022-06-15 17:34:41 +00:00
|
|
|
void ClearAssetList(std::vector<TName> &vList, IGraphics *pGraphics)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-15 17:34:41 +00:00
|
|
|
for(size_t i = 0; i < vList.size(); ++i)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-15 17:34:41 +00:00
|
|
|
if(vList[i].m_RenderTexture.IsValid())
|
|
|
|
pGraphics->UnloadTexture(&(vList[i].m_RenderTexture));
|
|
|
|
vList[i].m_RenderTexture = IGraphics::CTextureHandle();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-06-15 17:34:41 +00:00
|
|
|
vList.clear();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenus::ClearCustomItems(int CurTab)
|
|
|
|
{
|
2022-03-15 15:52:41 +00:00
|
|
|
if(CurTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
for(auto &Entity : m_vEntitiesList)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-05-23 18:18:32 +00:00
|
|
|
for(auto &Image : Entity.m_aImages)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2012-08-12 12:02:50 +00:00
|
|
|
if(Image.m_Texture.IsValid())
|
2016-07-02 08:33:37 +00:00
|
|
|
Graphics()->UnloadTexture(&Image.m_Texture);
|
2020-10-26 14:14:07 +00:00
|
|
|
Image.m_Texture = IGraphics::CTextureHandle();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-11 19:38:18 +00:00
|
|
|
m_vEntitiesList.clear();
|
2021-04-11 12:34:08 +00:00
|
|
|
|
|
|
|
// reload current entities
|
2021-07-12 09:43:56 +00:00
|
|
|
m_pClient->m_MapImages.ChangeEntitiesPath(g_Config.m_ClAssetsEntites);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
ClearAssetList(m_vGameList, Graphics());
|
2021-04-11 12:34:08 +00:00
|
|
|
|
|
|
|
// reload current game skin
|
|
|
|
GameClient()->LoadGameSkin(g_Config.m_ClAssetGame);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
ClearAssetList(m_vEmoticonList, Graphics());
|
2021-04-11 12:34:08 +00:00
|
|
|
|
|
|
|
// reload current emoticons skin
|
|
|
|
GameClient()->LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
ClearAssetList(m_vParticlesList, Graphics());
|
2021-04-11 12:34:08 +00:00
|
|
|
|
|
|
|
// reload current particles skin
|
|
|
|
GameClient()->LoadParticlesSkin(g_Config.m_ClAssetParticles);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_HUD)
|
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
ClearAssetList(m_vHudList, Graphics());
|
2022-03-15 15:52:41 +00:00
|
|
|
|
|
|
|
// reload current hud skin
|
|
|
|
GameClient()->LoadHudSkin(g_Config.m_ClAssetHud);
|
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(CurTab == ASSETS_TAB_EXTRAS)
|
|
|
|
{
|
|
|
|
ClearAssetList(m_vExtrasList, Graphics());
|
|
|
|
|
|
|
|
// reload current DDNet particles skin
|
|
|
|
GameClient()->LoadExtrasSkin(g_Config.m_ClAssetExtras);
|
|
|
|
}
|
2022-06-30 22:36:32 +00:00
|
|
|
gs_aInitCustomList[CurTab] = true;
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TName, typename TCaller>
|
2022-06-15 17:34:41 +00:00
|
|
|
void InitAssetList(std::vector<TName> &vAssetList, const char *pAssetPath, const char *pAssetName, FS_LISTDIR_CALLBACK pfnCallback, IGraphics *pGraphics, IStorage *pStorage, TCaller Caller)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-15 17:34:41 +00:00
|
|
|
if(vAssetList.empty())
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
TName AssetItem;
|
|
|
|
str_copy(AssetItem.m_aName, "default", sizeof(AssetItem.m_aName));
|
|
|
|
LoadAsset(&AssetItem, pAssetName, pGraphics, Caller);
|
2022-06-15 17:34:41 +00:00
|
|
|
vAssetList.push_back(AssetItem);
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
// load assets
|
|
|
|
pStorage->ListDirectory(IStorage::TYPE_ALL, pAssetPath, pfnCallback, Caller);
|
2022-06-15 17:34:41 +00:00
|
|
|
std::sort(vAssetList.begin(), vAssetList.end());
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-06-30 22:36:32 +00:00
|
|
|
if(vAssetList.size() != gs_aCustomListSize[s_CurCustomTab])
|
|
|
|
gs_aInitCustomList[s_CurCustomTab] = true;
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TName>
|
2022-06-15 17:34:41 +00:00
|
|
|
int InitSearchList(std::vector<const TName *> &vpSearchList, std::vector<TName> &vAssetList)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-15 17:34:41 +00:00
|
|
|
vpSearchList.clear();
|
|
|
|
int ListSize = vAssetList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
for(int i = 0; i < ListSize; ++i)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
const TName *pAsset = &vAssetList[i];
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
// filter quick search
|
2022-06-30 22:36:32 +00:00
|
|
|
if(s_aFilterString[s_CurCustomTab][0] != '\0' && !str_utf8_find_nocase(pAsset->m_aName, s_aFilterString[s_CurCustomTab]))
|
2020-09-26 07:37:35 +00:00
|
|
|
continue;
|
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
vpSearchList.push_back(pAsset);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-06-15 17:34:41 +00:00
|
|
|
return vAssetList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenus::RenderSettingsCustom(CUIRect MainView)
|
|
|
|
{
|
2022-06-26 22:38:49 +00:00
|
|
|
CUIRect TabBar, CustomList, QuickSearch, QuickSearchClearButton, DirectoryButton, Page1Tab, Page2Tab, Page3Tab, Page4Tab, Page5Tab, Page6Tab, ReloadButton;
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-06-26 22:38:49 +00:00
|
|
|
MainView.HSplitTop(20, &TabBar, &MainView);
|
|
|
|
float TabsW = TabBar.w;
|
|
|
|
TabBar.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page1Tab, &Page2Tab);
|
|
|
|
Page2Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page2Tab, &Page3Tab);
|
|
|
|
Page3Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page3Tab, &Page4Tab);
|
|
|
|
Page4Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page4Tab, &Page5Tab);
|
|
|
|
Page5Tab.VSplitLeft(TabsW / NUMBER_OF_ASSETS_TABS, &Page5Tab, &Page6Tab);
|
2022-03-15 15:52:41 +00:00
|
|
|
|
2022-06-26 22:38:49 +00:00
|
|
|
static int s_aPageTabs[NUMBER_OF_ASSETS_TABS] = {};
|
2022-03-15 15:52:41 +00:00
|
|
|
|
2022-06-26 22:38:49 +00:00
|
|
|
if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_ENTITIES], Localize("Entities"), s_CurCustomTab == ASSETS_TAB_ENTITIES, &Page1Tab, 5, NULL, NULL, NULL, NULL, 4))
|
2022-03-15 15:52:41 +00:00
|
|
|
s_CurCustomTab = ASSETS_TAB_ENTITIES;
|
2022-06-26 22:38:49 +00:00
|
|
|
if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_GAME], Localize("Game"), s_CurCustomTab == ASSETS_TAB_GAME, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4))
|
2022-03-15 15:52:41 +00:00
|
|
|
s_CurCustomTab = ASSETS_TAB_GAME;
|
2022-06-26 22:38:49 +00:00
|
|
|
if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_EMOTICONS], Localize("Emoticons"), s_CurCustomTab == ASSETS_TAB_EMOTICONS, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4))
|
2022-03-15 15:52:41 +00:00
|
|
|
s_CurCustomTab = ASSETS_TAB_EMOTICONS;
|
2022-06-26 22:38:49 +00:00
|
|
|
if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_PARTICLES], Localize("Particles"), s_CurCustomTab == ASSETS_TAB_PARTICLES, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4))
|
2022-03-15 15:52:41 +00:00
|
|
|
s_CurCustomTab = ASSETS_TAB_PARTICLES;
|
2022-06-26 22:38:49 +00:00
|
|
|
if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_HUD], Localize("HUD"), s_CurCustomTab == ASSETS_TAB_HUD, &Page5Tab, 0, NULL, NULL, NULL, NULL, 4))
|
2022-03-15 15:52:41 +00:00
|
|
|
s_CurCustomTab = ASSETS_TAB_HUD;
|
2022-06-26 22:38:49 +00:00
|
|
|
if(DoButton_MenuTab((void *)&s_aPageTabs[ASSETS_TAB_EXTRAS], Localize("Extras"), s_CurCustomTab == ASSETS_TAB_EXTRAS, &Page6Tab, 10, NULL, NULL, NULL, NULL, 4))
|
2022-06-14 17:28:51 +00:00
|
|
|
s_CurCustomTab = ASSETS_TAB_EXTRAS;
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-06-13 16:07:29 +00:00
|
|
|
auto LoadStartTime = time_get_nanoseconds();
|
2022-04-02 11:37:59 +00:00
|
|
|
SMenuAssetScanUser User;
|
|
|
|
User.m_pUser = this;
|
|
|
|
User.m_LoadedFunc = [&]() {
|
2022-06-13 16:07:29 +00:00
|
|
|
if(time_get_nanoseconds() - LoadStartTime > 500ms)
|
2022-06-23 17:59:38 +00:00
|
|
|
RenderLoading(Localize("Loading assets"), "", 0, false);
|
2022-04-02 11:37:59 +00:00
|
|
|
};
|
2022-03-15 15:52:41 +00:00
|
|
|
if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
if(m_vEntitiesList.empty())
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
SCustomEntities EntitiesItem;
|
|
|
|
str_copy(EntitiesItem.m_aName, "default", sizeof(EntitiesItem.m_aName));
|
2022-04-02 11:37:59 +00:00
|
|
|
LoadEntities(&EntitiesItem, &User);
|
2022-06-11 19:38:18 +00:00
|
|
|
m_vEntitiesList.push_back(EntitiesItem);
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
// load entities
|
2022-04-02 11:37:59 +00:00
|
|
|
Storage()->ListDirectory(IStorage::TYPE_ALL, "assets/entities", EntitiesScan, &User);
|
2022-06-11 19:38:18 +00:00
|
|
|
std::sort(m_vEntitiesList.begin(), m_vEntitiesList.end());
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-06-30 22:36:32 +00:00
|
|
|
if(m_vEntitiesList.size() != gs_aCustomListSize[s_CurCustomTab])
|
|
|
|
gs_aInitCustomList[s_CurCustomTab] = true;
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
InitAssetList(m_vGameList, "assets/game", "game", GameScan, Graphics(), Storage(), &User);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
InitAssetList(m_vEmoticonList, "assets/emoticons", "emoticons", EmoticonsScan, Graphics(), Storage(), &User);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
InitAssetList(m_vParticlesList, "assets/particles", "particles", ParticlesScan, Graphics(), Storage(), &User);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_HUD)
|
|
|
|
{
|
2022-06-11 19:38:18 +00:00
|
|
|
InitAssetList(m_vHudList, "assets/hud", "hud", HudScan, Graphics(), Storage(), &User);
|
2022-03-15 15:52:41 +00:00
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EXTRAS)
|
|
|
|
{
|
2022-06-14 17:30:01 +00:00
|
|
|
InitAssetList(m_vExtrasList, "assets/extras", "extras", ExtrasScan, Graphics(), Storage(), &User);
|
2022-06-14 17:28:51 +00:00
|
|
|
}
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
MainView.HSplitTop(10.0f, 0, &MainView);
|
|
|
|
|
|
|
|
// skin selector
|
|
|
|
MainView.HSplitTop(MainView.h - 10.0f - ms_ButtonHeight, &CustomList, &MainView);
|
|
|
|
static float s_ScrollValue = 0.0f;
|
2022-06-30 22:36:32 +00:00
|
|
|
if(gs_aInitCustomList[s_CurCustomTab])
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
int ListSize = 0;
|
2022-03-15 15:52:41 +00:00
|
|
|
if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
gs_vpSearchEntitiesList.clear();
|
2022-06-11 19:38:18 +00:00
|
|
|
ListSize = m_vEntitiesList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
for(int i = 0; i < ListSize; ++i)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
const SCustomEntities *pEntity = &m_vEntitiesList[i];
|
2020-09-26 07:37:35 +00:00
|
|
|
|
|
|
|
// filter quick search
|
2022-06-30 22:36:32 +00:00
|
|
|
if(s_aFilterString[s_CurCustomTab][0] != '\0' && !str_utf8_find_nocase(pEntity->m_aName, s_aFilterString[s_CurCustomTab]))
|
2020-09-26 07:37:35 +00:00
|
|
|
continue;
|
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
gs_vpSearchEntitiesList.push_back(pEntity);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
ListSize = InitSearchList(gs_vpSearchGamesList, m_vGameList);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
ListSize = InitSearchList(gs_vpSearchEmoticonsList, m_vEmoticonList);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
ListSize = InitSearchList(gs_vpSearchParticlesList, m_vParticlesList);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_HUD)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
ListSize = InitSearchList(gs_vpSearchHudList, m_vHudList);
|
2022-03-15 15:52:41 +00:00
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EXTRAS)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
ListSize = InitSearchList(gs_vpSearchExtrasList, m_vExtrasList);
|
2022-06-14 17:28:51 +00:00
|
|
|
}
|
2022-06-30 22:36:32 +00:00
|
|
|
gs_aInitCustomList[s_CurCustomTab] = false;
|
|
|
|
gs_aCustomListSize[s_CurCustomTab] = ListSize;
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int OldSelected = -1;
|
|
|
|
float Margin = 10;
|
|
|
|
float TextureWidth = 150;
|
|
|
|
float TextureHeight = 150;
|
|
|
|
|
2022-05-23 18:18:32 +00:00
|
|
|
size_t SearchListSize = 0;
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-03-15 15:52:41 +00:00
|
|
|
if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
SearchListSize = gs_vpSearchEntitiesList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
SearchListSize = gs_vpSearchGamesList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
TextureHeight = 75;
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
SearchListSize = gs_vpSearchEmoticonsList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
SearchListSize = gs_vpSearchParticlesList.size();
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_HUD)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
SearchListSize = gs_vpSearchHudList.size();
|
2022-03-15 15:52:41 +00:00
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EXTRAS)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
SearchListSize = gs_vpSearchExtrasList.size();
|
2022-06-14 17:28:51 +00:00
|
|
|
}
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
UiDoListboxStart(&gs_aInitCustomList[s_CurCustomTab], &CustomList, TextureHeight + 15.0f + 10.0f + Margin, "", "", SearchListSize, CustomList.w / (Margin + TextureWidth), OldSelected, s_ScrollValue, true);
|
2022-05-23 18:18:32 +00:00
|
|
|
for(size_t i = 0; i < SearchListSize; ++i)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
const SCustomItem *pItem = GetCustomItem(s_CurCustomTab, i);
|
|
|
|
if(pItem == NULL)
|
2020-09-26 07:37:35 +00:00
|
|
|
continue;
|
|
|
|
|
2022-03-15 15:52:41 +00:00
|
|
|
if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(str_comp(pItem->m_aName, g_Config.m_ClAssetsEntites) == 0)
|
2020-09-26 07:37:35 +00:00
|
|
|
OldSelected = i;
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(str_comp(pItem->m_aName, g_Config.m_ClAssetGame) == 0)
|
2020-09-26 07:37:35 +00:00
|
|
|
OldSelected = i;
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(str_comp(pItem->m_aName, g_Config.m_ClAssetEmoticons) == 0)
|
2020-09-26 07:37:35 +00:00
|
|
|
OldSelected = i;
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(str_comp(pItem->m_aName, g_Config.m_ClAssetParticles) == 0)
|
2020-09-26 07:37:35 +00:00
|
|
|
OldSelected = i;
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_HUD)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(str_comp(pItem->m_aName, g_Config.m_ClAssetHud) == 0)
|
2022-03-15 15:52:41 +00:00
|
|
|
OldSelected = i;
|
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EXTRAS)
|
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(str_comp(pItem->m_aName, g_Config.m_ClAssetExtras) == 0)
|
2022-06-14 17:28:51 +00:00
|
|
|
OldSelected = i;
|
|
|
|
}
|
2020-09-26 07:37:35 +00:00
|
|
|
|
2022-06-30 22:36:32 +00:00
|
|
|
CListboxItem Item = UiDoListboxNextItem(pItem, OldSelected >= 0 && (size_t)OldSelected == i);
|
2020-09-26 07:37:35 +00:00
|
|
|
CUIRect ItemRect = Item.m_Rect;
|
|
|
|
ItemRect.Margin(Margin / 2, &ItemRect);
|
|
|
|
if(Item.m_Visible)
|
|
|
|
{
|
|
|
|
CUIRect TextureRect;
|
|
|
|
ItemRect.HSplitTop(15, &ItemRect, &TextureRect);
|
|
|
|
TextureRect.HSplitTop(10, NULL, &TextureRect);
|
2022-06-30 22:36:32 +00:00
|
|
|
UI()->DoLabel(&ItemRect, pItem->m_aName, ItemRect.h - 2, TEXTALIGN_CENTER);
|
|
|
|
if(pItem->m_RenderTexture.IsValid())
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
Graphics()->WrapClamp();
|
2022-06-30 22:36:32 +00:00
|
|
|
Graphics()->TextureSet(pItem->m_RenderTexture);
|
2020-09-26 07:37:35 +00:00
|
|
|
Graphics()->QuadsBegin();
|
|
|
|
Graphics()->SetColor(1, 1, 1, 1);
|
|
|
|
IGraphics::CQuadItem QuadItem(TextureRect.x + (TextureRect.w - TextureWidth) / 2, TextureRect.y + (TextureRect.h - TextureHeight) / 2, TextureWidth, TextureHeight);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
|
|
|
Graphics()->QuadsEnd();
|
|
|
|
Graphics()->WrapNormal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);
|
|
|
|
if(OldSelected != NewSelected)
|
|
|
|
{
|
|
|
|
if(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName[0] != '\0')
|
|
|
|
{
|
2022-03-15 15:52:41 +00:00
|
|
|
if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
str_copy(g_Config.m_ClAssetsEntites, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetsEntites));
|
2021-07-12 09:43:56 +00:00
|
|
|
m_pClient->m_MapImages.ChangeEntitiesPath(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
str_copy(g_Config.m_ClAssetGame, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetGame));
|
|
|
|
GameClient()->LoadGameSkin(g_Config.m_ClAssetGame);
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
str_copy(g_Config.m_ClAssetEmoticons, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetEmoticons));
|
|
|
|
GameClient()->LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons);
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
|
|
|
str_copy(g_Config.m_ClAssetParticles, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetParticles));
|
|
|
|
GameClient()->LoadParticlesSkin(g_Config.m_ClAssetParticles);
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_HUD)
|
|
|
|
{
|
2022-03-30 09:12:48 +00:00
|
|
|
str_copy(g_Config.m_ClAssetHud, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetHud));
|
2022-03-15 15:52:41 +00:00
|
|
|
GameClient()->LoadHudSkin(g_Config.m_ClAssetHud);
|
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EXTRAS)
|
|
|
|
{
|
|
|
|
str_copy(g_Config.m_ClAssetExtras, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetExtras));
|
|
|
|
GameClient()->LoadExtrasSkin(g_Config.m_ClAssetExtras);
|
|
|
|
}
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// render quick search
|
|
|
|
{
|
|
|
|
MainView.HSplitBottom(ms_ButtonHeight, &MainView, &QuickSearch);
|
2020-10-06 14:00:18 +00:00
|
|
|
QuickSearch.VSplitLeft(240.0f, &QuickSearch, &DirectoryButton);
|
2020-09-26 07:37:35 +00:00
|
|
|
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
|
2022-03-19 17:50:33 +00:00
|
|
|
const char *pSearchLabel = "\xEF\x80\x82";
|
2020-09-26 07:37:35 +00:00
|
|
|
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
2020-10-06 10:25:10 +00:00
|
|
|
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
2022-03-11 16:34:48 +00:00
|
|
|
|
|
|
|
SLabelProperties Props;
|
|
|
|
Props.m_AlignVertically = 0;
|
2022-06-12 08:34:09 +00:00
|
|
|
UI()->DoLabel(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
|
2020-09-26 07:37:35 +00:00
|
|
|
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
|
|
|
|
TextRender()->SetRenderFlags(0);
|
|
|
|
TextRender()->SetCurFont(NULL);
|
|
|
|
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
|
|
|
|
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
|
|
|
|
QuickSearch.VSplitLeft(QuickSearch.w - 15.0f, &QuickSearch, &QuickSearchClearButton);
|
|
|
|
static int s_ClearButton = 0;
|
2021-12-03 19:15:44 +00:00
|
|
|
static float s_Offset = 0.0f;
|
2022-03-13 18:09:33 +00:00
|
|
|
SUIExEditBoxProperties EditProps;
|
2021-12-18 11:23:20 +00:00
|
|
|
if(Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed())
|
2022-03-13 18:09:33 +00:00
|
|
|
{
|
2020-09-26 07:37:35 +00:00
|
|
|
UI()->SetActiveItem(&s_aFilterString[s_CurCustomTab]);
|
2022-03-13 18:09:33 +00:00
|
|
|
EditProps.m_SelectText = true;
|
|
|
|
}
|
|
|
|
EditProps.m_pEmptyText = Localize("Search");
|
|
|
|
if(UIEx()->DoClearableEditBox(&s_aFilterString[s_CurCustomTab], &s_ClearButton, &QuickSearch, s_aFilterString[s_CurCustomTab], sizeof(s_aFilterString[0]), 14.0f, &s_Offset, false, CUI::CORNER_ALL, EditProps))
|
2022-06-30 22:36:32 +00:00
|
|
|
gs_aInitCustomList[s_CurCustomTab] = true;
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 14:00:18 +00:00
|
|
|
DirectoryButton.HSplitTop(5.0f, 0, &DirectoryButton);
|
|
|
|
DirectoryButton.VSplitRight(175.0f, 0, &DirectoryButton);
|
|
|
|
DirectoryButton.VSplitRight(25.0f, &DirectoryButton, &ReloadButton);
|
|
|
|
DirectoryButton.VSplitRight(10.0f, &DirectoryButton, 0);
|
2021-05-17 07:11:36 +00:00
|
|
|
static int s_AssetsDirID = 0;
|
|
|
|
if(DoButton_Menu(&s_AssetsDirID, Localize("Assets directory"), 0, &DirectoryButton))
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2021-09-13 08:06:34 +00:00
|
|
|
char aBuf[IO_MAX_PATH_LENGTH];
|
|
|
|
char aBufFull[IO_MAX_PATH_LENGTH + 7];
|
2022-03-15 15:52:41 +00:00
|
|
|
if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
|
2020-09-26 07:37:35 +00:00
|
|
|
str_copy(aBufFull, "assets/entities", sizeof(aBufFull));
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_GAME)
|
2020-09-26 07:37:35 +00:00
|
|
|
str_copy(aBufFull, "assets/game", sizeof(aBufFull));
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
|
2020-09-26 07:37:35 +00:00
|
|
|
str_copy(aBufFull, "assets/emoticons", sizeof(aBufFull));
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
|
2020-09-26 07:37:35 +00:00
|
|
|
str_copy(aBufFull, "assets/particles", sizeof(aBufFull));
|
2022-03-15 15:52:41 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_HUD)
|
|
|
|
str_copy(aBufFull, "assets/hud", sizeof(aBufFull));
|
2022-06-14 17:28:51 +00:00
|
|
|
else if(s_CurCustomTab == ASSETS_TAB_EXTRAS)
|
|
|
|
str_copy(aBufFull, "assets/extras", sizeof(aBufFull));
|
2020-09-26 07:37:35 +00:00
|
|
|
Storage()->GetCompletePath(IStorage::TYPE_SAVE, aBufFull, aBuf, sizeof(aBuf));
|
|
|
|
Storage()->CreateFolder("assets", IStorage::TYPE_SAVE);
|
|
|
|
Storage()->CreateFolder(aBufFull, IStorage::TYPE_SAVE);
|
2021-12-19 00:13:08 +00:00
|
|
|
if(!open_file(aBuf))
|
2020-09-26 07:37:35 +00:00
|
|
|
{
|
2021-12-19 00:13:08 +00:00
|
|
|
dbg_msg("menus", "couldn't open file");
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-06 14:00:18 +00:00
|
|
|
|
|
|
|
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
2020-10-06 10:25:10 +00:00
|
|
|
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
2021-05-17 07:11:36 +00:00
|
|
|
static int s_AssetsReloadBtnID = 0;
|
2022-03-19 17:50:33 +00:00
|
|
|
if(DoButton_Menu(&s_AssetsReloadBtnID, "\xEF\x80\x9E", 0, &ReloadButton, NULL, 15, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0))
|
2020-10-06 14:00:18 +00:00
|
|
|
{
|
|
|
|
ClearCustomItems(s_CurCustomTab);
|
|
|
|
}
|
|
|
|
TextRender()->SetRenderFlags(0);
|
|
|
|
TextRender()->SetCurFont(NULL);
|
2020-09-26 07:37:35 +00:00
|
|
|
}
|
2021-04-11 12:34:08 +00:00
|
|
|
|
|
|
|
void CMenus::ConchainAssetsEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
|
|
|
{
|
|
|
|
CMenus *pThis = (CMenus *)pUserData;
|
|
|
|
if(pResult->NumArguments() == 1)
|
|
|
|
{
|
|
|
|
const char *pArg = pResult->GetString(0);
|
|
|
|
if(str_comp(pArg, g_Config.m_ClAssetsEntites) != 0)
|
|
|
|
{
|
2021-07-12 09:43:56 +00:00
|
|
|
pThis->m_pClient->m_MapImages.ChangeEntitiesPath(pArg);
|
2021-04-11 12:34:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pfnCallback(pResult, pCallbackUserData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenus::ConchainAssetGame(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
|
|
|
{
|
|
|
|
CMenus *pThis = (CMenus *)pUserData;
|
|
|
|
if(pResult->NumArguments() == 1)
|
|
|
|
{
|
|
|
|
const char *pArg = pResult->GetString(0);
|
|
|
|
if(str_comp(pArg, g_Config.m_ClAssetGame) != 0)
|
|
|
|
{
|
|
|
|
pThis->GameClient()->LoadGameSkin(pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pfnCallback(pResult, pCallbackUserData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenus::ConchainAssetParticles(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
|
|
|
{
|
|
|
|
CMenus *pThis = (CMenus *)pUserData;
|
|
|
|
if(pResult->NumArguments() == 1)
|
|
|
|
{
|
|
|
|
const char *pArg = pResult->GetString(0);
|
|
|
|
if(str_comp(pArg, g_Config.m_ClAssetParticles) != 0)
|
|
|
|
{
|
|
|
|
pThis->GameClient()->LoadParticlesSkin(pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pfnCallback(pResult, pCallbackUserData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenus::ConchainAssetEmoticons(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
|
|
|
{
|
|
|
|
CMenus *pThis = (CMenus *)pUserData;
|
|
|
|
if(pResult->NumArguments() == 1)
|
|
|
|
{
|
|
|
|
const char *pArg = pResult->GetString(0);
|
|
|
|
if(str_comp(pArg, g_Config.m_ClAssetEmoticons) != 0)
|
|
|
|
{
|
|
|
|
pThis->GameClient()->LoadEmoticonsSkin(pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pfnCallback(pResult, pCallbackUserData);
|
|
|
|
}
|
2022-03-15 15:52:41 +00:00
|
|
|
|
|
|
|
void CMenus::ConchainAssetHud(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
|
|
|
{
|
|
|
|
CMenus *pThis = (CMenus *)pUserData;
|
|
|
|
if(pResult->NumArguments() == 1)
|
|
|
|
{
|
|
|
|
const char *pArg = pResult->GetString(0);
|
|
|
|
if(str_comp(pArg, g_Config.m_ClAssetHud) != 0)
|
|
|
|
{
|
|
|
|
pThis->GameClient()->LoadHudSkin(pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pfnCallback(pResult, pCallbackUserData);
|
|
|
|
}
|
2022-06-14 17:28:51 +00:00
|
|
|
|
|
|
|
void CMenus::ConchainAssetExtras(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
|
|
|
{
|
|
|
|
CMenus *pThis = (CMenus *)pUserData;
|
|
|
|
if(pResult->NumArguments() == 1)
|
|
|
|
{
|
|
|
|
const char *pArg = pResult->GetString(0);
|
|
|
|
if(str_comp(pArg, g_Config.m_ClAssetExtras) != 0)
|
|
|
|
{
|
|
|
|
pThis->GameClient()->LoadExtrasSkin(pArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pfnCallback(pResult, pCallbackUserData);
|
|
|
|
}
|