Add HUD Sprites, LoadHudSkin() and HUD Assets Tab

This commit is contained in:
c0d3d3v 2022-03-15 16:52:41 +01:00
parent f60ae47be1
commit 755c260401
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
9 changed files with 270 additions and 49 deletions

View file

@ -1188,6 +1188,7 @@ set(EXPECTED_DATA
gui_cursor.png gui_cursor.png
gui_icons.png gui_icons.png
gui_logo.png gui_logo.png
hud.png
languages/arabic.txt languages/arabic.txt
languages/belarusian.txt languages/belarusian.txt
languages/bosnian.txt languages/bosnian.txt

BIN
data/hud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View file

@ -238,6 +238,7 @@ image_arrow = Image("arrow", "arrow.png")
image_demobuttons2 = Image("demobuttons2", "demo_buttons2.png") image_demobuttons2 = Image("demobuttons2", "demo_buttons2.png")
image_audio_source = Image("audio_source", "editor/audio_source.png") image_audio_source = Image("audio_source", "editor/audio_source.png")
image_strongweak = Image("strongweak", "strong_weak.png") image_strongweak = Image("strongweak", "strong_weak.png")
image_hud = Image("hud", "hud.png")
container.images.Add(image_null) container.images.Add(image_null)
container.images.Add(image_game) container.images.Add(image_game)
@ -256,6 +257,7 @@ container.images.Add(image_arrow)
container.images.Add(image_demobuttons2) container.images.Add(image_demobuttons2)
container.images.Add(image_audio_source) container.images.Add(image_audio_source)
container.images.Add(image_strongweak) container.images.Add(image_strongweak)
container.images.Add(image_hud)
container.pickups.Add(Pickup("health")) container.pickups.Add(Pickup("health"))
container.pickups.Add(Pickup("armor")) container.pickups.Add(Pickup("armor"))
@ -274,6 +276,7 @@ set_guiicons = SpriteSet("guiicons", image_guiicons, 12, 2)
set_demobuttons2 = SpriteSet("demobuttons2", image_demobuttons2, 4, 1) set_demobuttons2 = SpriteSet("demobuttons2", image_demobuttons2, 4, 1)
set_audio_source = SpriteSet("audio_source", image_audio_source, 1, 1) set_audio_source = SpriteSet("audio_source", image_audio_source, 1, 1)
set_strongweak = SpriteSet("strongweak", image_strongweak, 2, 1) set_strongweak = SpriteSet("strongweak", image_strongweak, 2, 1)
set_hud = SpriteSet("hud", image_hud, 14, 6)
container.spritesets.Add(set_particles) container.spritesets.Add(set_particles)
container.spritesets.Add(set_game) container.spritesets.Add(set_game)
@ -287,6 +290,7 @@ container.spritesets.Add(set_guiicons)
container.spritesets.Add(set_demobuttons2) container.spritesets.Add(set_demobuttons2)
container.spritesets.Add(set_audio_source) container.spritesets.Add(set_audio_source)
container.spritesets.Add(set_strongweak) container.spritesets.Add(set_strongweak)
container.spritesets.Add(set_hud)
container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1)) container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1))
container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1)) container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1))
@ -426,6 +430,28 @@ container.sprites.Add(Sprite("audio_source", set_audio_source, 0,0,1,1))
container.sprites.Add(Sprite("hook_strong", set_strongweak, 0,0,1,1)) container.sprites.Add(Sprite("hook_strong", set_strongweak, 0,0,1,1))
container.sprites.Add(Sprite("hook_weak", set_strongweak, 1,0,1,1)) container.sprites.Add(Sprite("hook_weak", set_strongweak, 1,0,1,1))
container.sprites.Add(Sprite("hud_airjump", set_hud, 0,0,2,2))
container.sprites.Add(Sprite("hud_airjump_empty", set_hud, 2,0,2,2))
container.sprites.Add(Sprite("hud_solo", set_hud, 4,0,2,2))
container.sprites.Add(Sprite("hud_no_collision", set_hud, 6,0,2,2))
container.sprites.Add(Sprite("hud_endless_jump", set_hud, 8,0,2,2))
container.sprites.Add(Sprite("hud_endless_hook", set_hud, 10,0,2,2))
container.sprites.Add(Sprite("hud_jetpack", set_hud, 12,0,2,2))
container.sprites.Add(Sprite("hud_freeze_bar_full_left", set_game, 0,2,1,2))
container.sprites.Add(Sprite("hud_freeze_bar_full", set_game, 1,2,1,2))
container.sprites.Add(Sprite("hud_freeze_bar_empty", set_game, 2,2,1,2))
container.sprites.Add(Sprite("hud_freeze_bar_empty_right", set_game, 3,2,1,2))
container.sprites.Add(Sprite("hud_no_hook_hit", set_game, 4,2,2,2))
container.sprites.Add(Sprite("hud_no_hammer_hit", set_game, 6,2,2,2))
container.sprites.Add(Sprite("hud_no_shotgun_hit", set_game, 8,2,2,2))
container.sprites.Add(Sprite("hud_no_grenade_hit", set_game, 10,2,2,2))
container.sprites.Add(Sprite("hud_no_laser_hit", set_game, 12,2,2,2))
container.sprites.Add(Sprite("hud_teleport_grenade", set_game, 4,4,2,2))
container.sprites.Add(Sprite("hud_teleport_gun", set_game, 6,4,2,2))
container.sprites.Add(Sprite("hud_teleport_laser", set_game, 8,4,2,2))
container.sprites.Add(Sprite("hud_dummy_hammer", set_game, 10,4,2,2))
container.sprites.Add(Sprite("hud_dummy_copy", set_game, 12,4,2,2))
anim = Animation("base") anim = Animation("base")
anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0)) anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0))
anim.back_foot.frames.Add(AnimKeyframe(0, 0, 10, 0)) anim.back_foot.frames.Add(AnimKeyframe(0, 0, 10, 0))

View file

@ -41,6 +41,7 @@ MACRO_CONFIG_STR(ClAssetsEntites, cl_assets_entities, 50, "default", CFGFLAG_SAV
MACRO_CONFIG_STR(ClAssetGame, cl_asset_game, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for game") MACRO_CONFIG_STR(ClAssetGame, cl_asset_game, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for game")
MACRO_CONFIG_STR(ClAssetEmoticons, cl_asset_emoticons, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for emoticons") MACRO_CONFIG_STR(ClAssetEmoticons, cl_asset_emoticons, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for emoticons")
MACRO_CONFIG_STR(ClAssetParticles, cl_asset_particles, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for particles") MACRO_CONFIG_STR(ClAssetParticles, cl_asset_particles, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for particles")
MACRO_CONFIG_STR(ClAssetHud, cl_asset_hud, 50, "default", CFGFLAG_SAVE | CFGFLAG_CLIENT, "The asset for HUD")
MACRO_CONFIG_STR(BrFilterString, br_filter_string, 25, "Novice", CFGFLAG_SAVE | CFGFLAG_CLIENT, "Server browser filtering string") MACRO_CONFIG_STR(BrFilterString, br_filter_string, 25, "Novice", CFGFLAG_SAVE | CFGFLAG_CLIENT, "Server browser filtering string")
MACRO_CONFIG_STR(BrExcludeString, br_exclude_string, 25, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "Server browser exclusion string") MACRO_CONFIG_STR(BrExcludeString, br_exclude_string, 25, "", CFGFLAG_SAVE | CFGFLAG_CLIENT, "Server browser exclusion string")

View file

@ -1039,6 +1039,7 @@ void CMenus::OnInit()
Console()->Chain("cl_asset_game", ConchainAssetGame, this); Console()->Chain("cl_asset_game", ConchainAssetGame, this);
Console()->Chain("cl_asset_emoticons", ConchainAssetEmoticons, this); Console()->Chain("cl_asset_emoticons", ConchainAssetEmoticons, this);
Console()->Chain("cl_asset_particles", ConchainAssetParticles, this); Console()->Chain("cl_asset_particles", ConchainAssetParticles, this);
Console()->Chain("cl_asset_hud", ConchainAssetHud, this);
m_TextureBlob = Graphics()->LoadTexture("blob.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); m_TextureBlob = Graphics()->LoadTexture("blob.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);

View file

@ -246,11 +246,16 @@ public:
{ {
}; };
struct SCustomHud : public SCustomItem
{
};
protected: protected:
sorted_array<SCustomEntities> m_EntitiesList; sorted_array<SCustomEntities> m_EntitiesList;
sorted_array<SCustomGame> m_GameList; sorted_array<SCustomGame> m_GameList;
sorted_array<SCustomEmoticon> m_EmoticonList; sorted_array<SCustomEmoticon> m_EmoticonList;
sorted_array<SCustomParticle> m_ParticlesList; sorted_array<SCustomParticle> m_ParticlesList;
sorted_array<SCustomHud> m_HudList;
bool m_IsInit = false; bool m_IsInit = false;
@ -260,11 +265,13 @@ protected:
static int GameScan(const char *pName, int IsDir, int DirType, void *pUser); static int GameScan(const char *pName, int IsDir, int DirType, void *pUser);
static int EmoticonsScan(const char *pName, int IsDir, int DirType, void *pUser); static int EmoticonsScan(const char *pName, int IsDir, int DirType, void *pUser);
static int ParticlesScan(const char *pName, int IsDir, int DirType, void *pUser); static int ParticlesScan(const char *pName, int IsDir, int DirType, void *pUser);
static int HudScan(const char *pName, int IsDir, int DirType, void *pUser);
static void ConchainAssetsEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainAssetsEntities(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainAssetGame(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainAssetGame(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainAssetParticles(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainAssetParticles(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainAssetEmoticons(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainAssetEmoticons(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
static void ConchainAssetHud(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
void ClearCustomItems(int CurTab); void ClearCustomItems(int CurTab);

View file

@ -15,6 +15,16 @@ struct SMenuAssetScanUser
TMenuAssetScanLoadedFunc m_LoadedFunc; TMenuAssetScanLoadedFunc m_LoadedFunc;
}; };
// 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,
ASSETS_TAB_HUD = 4
};
void CMenus::LoadEntities(SCustomEntities *pEntitiesItem, void *pUser) void CMenus::LoadEntities(SCustomEntities *pEntitiesItem, void *pUser)
{ {
auto *pRealUser = (SMenuAssetScanUser *)pUser; auto *pRealUser = (SMenuAssetScanUser *)pUser;
@ -208,33 +218,44 @@ int CMenus::ParticlesScan(const char *pName, int IsDir, int DirType, void *pUser
return AssetScan(pName, IsDir, DirType, pThis->m_ParticlesList, "particles", pGraphics, pUser); return AssetScan(pName, IsDir, DirType, pThis->m_ParticlesList, "particles", pGraphics, pUser);
} }
int CMenus::HudScan(const char *pName, int IsDir, int DirType, void *pUser)
{
CMenus *pMenus = (CMenus *)pUser;
IGraphics *pGraphics = pMenus->Graphics();
return AssetScan(pName, IsDir, DirType, pMenus->m_HudList, "hud", pGraphics, pUser);
}
static sorted_array<const CMenus::SCustomEntities *> s_SearchEntitiesList; static sorted_array<const CMenus::SCustomEntities *> s_SearchEntitiesList;
static sorted_array<const CMenus::SCustomGame *> s_SearchGamesList; static sorted_array<const CMenus::SCustomGame *> s_SearchGamesList;
static sorted_array<const CMenus::SCustomEmoticon *> s_SearchEmoticonsList; static sorted_array<const CMenus::SCustomEmoticon *> s_SearchEmoticonsList;
static sorted_array<const CMenus::SCustomParticle *> s_SearchParticlesList; static sorted_array<const CMenus::SCustomParticle *> s_SearchParticlesList;
static sorted_array<const CMenus::SCustomHud *> s_SearchHudList;
static bool s_InitCustomList[4] = { static const int NumberOfAssetsTabs = 5;
static bool s_InitCustomList[NumberOfAssetsTabs] = {
true, true,
}; };
static int s_CustomListSize[4] = { static int s_CustomListSize[NumberOfAssetsTabs] = {
0, 0,
}; };
static char s_aFilterString[4][50]; static char s_aFilterString[NumberOfAssetsTabs][50];
static int s_CurCustomTab = 0; static int s_CurCustomTab = ASSETS_TAB_ENTITIES;
static const CMenus::SCustomItem *GetCustomItem(int CurTab, int Index) static const CMenus::SCustomItem *GetCustomItem(int CurTab, int Index)
{ {
if(CurTab == 0) if(CurTab == ASSETS_TAB_ENTITIES)
return s_SearchEntitiesList[Index]; return s_SearchEntitiesList[Index];
else if(CurTab == 1) else if(CurTab == ASSETS_TAB_GAME)
return s_SearchGamesList[Index]; return s_SearchGamesList[Index];
else if(CurTab == 2) else if(CurTab == ASSETS_TAB_EMOTICONS)
return s_SearchEmoticonsList[Index]; return s_SearchEmoticonsList[Index];
else if(CurTab == 3) else if(CurTab == ASSETS_TAB_PARTICLES)
return s_SearchParticlesList[Index]; return s_SearchParticlesList[Index];
else if(CurTab == ASSETS_TAB_HUD)
return s_SearchHudList[Index];
return NULL; return NULL;
} }
@ -253,7 +274,7 @@ void ClearAssetList(sorted_array<TName> &List, IGraphics *pGraphics)
void CMenus::ClearCustomItems(int CurTab) void CMenus::ClearCustomItems(int CurTab)
{ {
if(CurTab == 0) if(CurTab == ASSETS_TAB_ENTITIES)
{ {
for(int i = 0; i < m_EntitiesList.size(); ++i) for(int i = 0; i < m_EntitiesList.size(); ++i)
{ {
@ -269,27 +290,34 @@ void CMenus::ClearCustomItems(int CurTab)
// reload current entities // reload current entities
m_pClient->m_MapImages.ChangeEntitiesPath(g_Config.m_ClAssetsEntites); m_pClient->m_MapImages.ChangeEntitiesPath(g_Config.m_ClAssetsEntites);
} }
else if(CurTab == 1) else if(CurTab == ASSETS_TAB_GAME)
{ {
ClearAssetList(m_GameList, Graphics()); ClearAssetList(m_GameList, Graphics());
// reload current game skin // reload current game skin
GameClient()->LoadGameSkin(g_Config.m_ClAssetGame); GameClient()->LoadGameSkin(g_Config.m_ClAssetGame);
} }
else if(CurTab == 2) else if(CurTab == ASSETS_TAB_EMOTICONS)
{ {
ClearAssetList(m_EmoticonList, Graphics()); ClearAssetList(m_EmoticonList, Graphics());
// reload current emoticons skin // reload current emoticons skin
GameClient()->LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons); GameClient()->LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons);
} }
else if(CurTab == 3) else if(CurTab == ASSETS_TAB_PARTICLES)
{ {
ClearAssetList(m_ParticlesList, Graphics()); ClearAssetList(m_ParticlesList, Graphics());
// reload current particles skin // reload current particles skin
GameClient()->LoadParticlesSkin(g_Config.m_ClAssetParticles); GameClient()->LoadParticlesSkin(g_Config.m_ClAssetParticles);
} }
else if(CurTab == ASSETS_TAB_HUD)
{
ClearAssetList(m_HudList, Graphics());
// reload current hud skin
GameClient()->LoadHudSkin(g_Config.m_ClAssetHud);
}
s_InitCustomList[CurTab] = true; s_InitCustomList[CurTab] = true;
} }
@ -330,24 +358,27 @@ int InitSearchList(sorted_array<const TName *> &SearchList, sorted_array<TName>
void CMenus::RenderSettingsCustom(CUIRect MainView) void CMenus::RenderSettingsCustom(CUIRect MainView)
{ {
CUIRect Label, CustomList, QuickSearch, QuickSearchClearButton, DirectoryButton, Page1Tab, Page2Tab, Page3Tab, Page4Tab, ReloadButton; CUIRect Label, CustomList, QuickSearch, QuickSearchClearButton, DirectoryButton, Page1Tab, Page2Tab, Page3Tab, Page4Tab, Page5Tab, ReloadButton;
MainView.HSplitTop(20, &Label, &MainView); MainView.HSplitTop(20, &Label, &MainView);
float TabsW = Label.w; float TabsW = Label.w;
Label.VSplitLeft(TabsW / 4, &Page1Tab, &Page2Tab); Label.VSplitLeft(TabsW / NumberOfAssetsTabs, &Page1Tab, &Page2Tab);
Page2Tab.VSplitLeft(TabsW / 4, &Page2Tab, &Page3Tab); Page2Tab.VSplitLeft(TabsW / NumberOfAssetsTabs, &Page2Tab, &Page3Tab);
Page3Tab.VSplitLeft(TabsW / 4, &Page3Tab, &Page4Tab); Page3Tab.VSplitLeft(TabsW / NumberOfAssetsTabs, &Page3Tab, &Page4Tab);
Page4Tab.VSplitLeft(TabsW / NumberOfAssetsTabs, &Page4Tab, &Page5Tab);
static int s_aPageTabs[4] = {}; static int s_aPageTabs[NumberOfAssetsTabs] = {};
if(DoButton_MenuTab((void *)&s_aPageTabs[0], Localize("Entities"), s_CurCustomTab == 0, &Page1Tab, 5, NULL, NULL, NULL, NULL, 4)) if(DoButton_MenuTab((void *)&s_aPageTabs[0], Localize("Entities"), s_CurCustomTab == ASSETS_TAB_ENTITIES, &Page1Tab, 5, NULL, NULL, NULL, NULL, 4))
s_CurCustomTab = 0; s_CurCustomTab = ASSETS_TAB_ENTITIES;
if(DoButton_MenuTab((void *)&s_aPageTabs[1], Localize("Game"), s_CurCustomTab == 1, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4)) if(DoButton_MenuTab((void *)&s_aPageTabs[1], Localize("Game"), s_CurCustomTab == ASSETS_TAB_GAME, &Page2Tab, 0, NULL, NULL, NULL, NULL, 4))
s_CurCustomTab = 1; s_CurCustomTab = ASSETS_TAB_GAME;
if(DoButton_MenuTab((void *)&s_aPageTabs[2], Localize("Emoticons"), s_CurCustomTab == 2, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4)) if(DoButton_MenuTab((void *)&s_aPageTabs[2], Localize("Emoticons"), s_CurCustomTab == ASSETS_TAB_EMOTICONS, &Page3Tab, 0, NULL, NULL, NULL, NULL, 4))
s_CurCustomTab = 2; s_CurCustomTab = ASSETS_TAB_EMOTICONS;
if(DoButton_MenuTab((void *)&s_aPageTabs[3], Localize("Particles"), s_CurCustomTab == 3, &Page4Tab, 10, NULL, NULL, NULL, NULL, 4)) if(DoButton_MenuTab((void *)&s_aPageTabs[3], Localize("Particles"), s_CurCustomTab == ASSETS_TAB_PARTICLES, &Page4Tab, 0, NULL, NULL, NULL, NULL, 4))
s_CurCustomTab = 3; s_CurCustomTab = ASSETS_TAB_PARTICLES;
if(DoButton_MenuTab((void *)&s_aPageTabs[4], Localize("HUD"), s_CurCustomTab == ASSETS_TAB_HUD, &Page5Tab, 10, NULL, NULL, NULL, NULL, 4))
s_CurCustomTab = ASSETS_TAB_HUD;
int64_t LoadStartTime = time_get_microseconds(); int64_t LoadStartTime = time_get_microseconds();
SMenuAssetScanUser User; SMenuAssetScanUser User;
@ -356,7 +387,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
if(time_get_microseconds() - LoadStartTime > 500000) if(time_get_microseconds() - LoadStartTime > 500000)
RenderLoading(false, false); RenderLoading(false, false);
}; };
if(s_CurCustomTab == 0) if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
{ {
if(m_EntitiesList.size() == 0) if(m_EntitiesList.size() == 0)
{ {
@ -371,18 +402,22 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
if(m_EntitiesList.size() != s_CustomListSize[s_CurCustomTab]) if(m_EntitiesList.size() != s_CustomListSize[s_CurCustomTab])
s_InitCustomList[s_CurCustomTab] = true; s_InitCustomList[s_CurCustomTab] = true;
} }
else if(s_CurCustomTab == 1) else if(s_CurCustomTab == ASSETS_TAB_GAME)
{ {
InitAssetList(m_GameList, "assets/game", "game", GameScan, Graphics(), Storage(), &User); InitAssetList(m_GameList, "assets/game", "game", GameScan, Graphics(), Storage(), &User);
} }
else if(s_CurCustomTab == 2) else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
{ {
InitAssetList(m_EmoticonList, "assets/emoticons", "emoticons", EmoticonsScan, Graphics(), Storage(), &User); InitAssetList(m_EmoticonList, "assets/emoticons", "emoticons", EmoticonsScan, Graphics(), Storage(), &User);
} }
else if(s_CurCustomTab == 3) else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
{ {
InitAssetList(m_ParticlesList, "assets/particles", "particles", ParticlesScan, Graphics(), Storage(), &User); InitAssetList(m_ParticlesList, "assets/particles", "particles", ParticlesScan, Graphics(), Storage(), &User);
} }
else if(s_CurCustomTab == ASSETS_TAB_HUD)
{
InitAssetList(m_HudList, "assets/hud", "hud", HudScan, Graphics(), Storage(), this);
}
MainView.HSplitTop(10.0f, 0, &MainView); MainView.HSplitTop(10.0f, 0, &MainView);
@ -392,7 +427,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
if(s_InitCustomList[s_CurCustomTab]) if(s_InitCustomList[s_CurCustomTab])
{ {
int ListSize = 0; int ListSize = 0;
if(s_CurCustomTab == 0) if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
{ {
s_SearchEntitiesList.clear(); s_SearchEntitiesList.clear();
ListSize = m_EntitiesList.size(); ListSize = m_EntitiesList.size();
@ -407,18 +442,22 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
s_SearchEntitiesList.add_unsorted(s); s_SearchEntitiesList.add_unsorted(s);
} }
} }
else if(s_CurCustomTab == 1) else if(s_CurCustomTab == ASSETS_TAB_GAME)
{ {
ListSize = InitSearchList(s_SearchGamesList, m_GameList); ListSize = InitSearchList(s_SearchGamesList, m_GameList);
} }
else if(s_CurCustomTab == 2) else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
{ {
ListSize = InitSearchList(s_SearchEmoticonsList, m_EmoticonList); ListSize = InitSearchList(s_SearchEmoticonsList, m_EmoticonList);
} }
else if(s_CurCustomTab == 3) else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
{ {
ListSize = InitSearchList(s_SearchParticlesList, m_ParticlesList); ListSize = InitSearchList(s_SearchParticlesList, m_ParticlesList);
} }
else if(s_CurCustomTab == ASSETS_TAB_HUD)
{
ListSize = InitSearchList(s_SearchHudList, m_HudList);
}
s_InitCustomList[s_CurCustomTab] = false; s_InitCustomList[s_CurCustomTab] = false;
s_CustomListSize[s_CurCustomTab] = ListSize; s_CustomListSize[s_CurCustomTab] = ListSize;
} }
@ -430,23 +469,28 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
int SearchListSize = 0; int SearchListSize = 0;
if(s_CurCustomTab == 0) if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
{ {
SearchListSize = s_SearchEntitiesList.size(); SearchListSize = s_SearchEntitiesList.size();
} }
else if(s_CurCustomTab == 1) else if(s_CurCustomTab == ASSETS_TAB_GAME)
{ {
SearchListSize = s_SearchGamesList.size(); SearchListSize = s_SearchGamesList.size();
TextureHeight = 75; TextureHeight = 75;
} }
else if(s_CurCustomTab == 2) else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
{ {
SearchListSize = s_SearchEmoticonsList.size(); SearchListSize = s_SearchEmoticonsList.size();
} }
else if(s_CurCustomTab == 3) else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
{ {
SearchListSize = s_SearchParticlesList.size(); SearchListSize = s_SearchParticlesList.size();
} }
else if(s_CurCustomTab == ASSETS_TAB_HUD)
{
SearchListSize = s_SearchHudList.size();
TextureHeight = 64;
}
UiDoListboxStart(&s_InitCustomList[s_CurCustomTab], &CustomList, TextureHeight + 15.0f + 10.0f + Margin, "", "", SearchListSize, CustomList.w / (Margin + TextureWidth), OldSelected, s_ScrollValue, true); UiDoListboxStart(&s_InitCustomList[s_CurCustomTab], &CustomList, TextureHeight + 15.0f + 10.0f + Margin, "", "", SearchListSize, CustomList.w / (Margin + TextureWidth), OldSelected, s_ScrollValue, true);
for(int i = 0; i < SearchListSize; ++i) for(int i = 0; i < SearchListSize; ++i)
@ -455,26 +499,31 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
if(s == NULL) if(s == NULL)
continue; continue;
if(s_CurCustomTab == 0) if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
{ {
if(str_comp(s->m_aName, g_Config.m_ClAssetsEntites) == 0) if(str_comp(s->m_aName, g_Config.m_ClAssetsEntites) == 0)
OldSelected = i; OldSelected = i;
} }
else if(s_CurCustomTab == 1) else if(s_CurCustomTab == ASSETS_TAB_GAME)
{ {
if(str_comp(s->m_aName, g_Config.m_ClAssetGame) == 0) if(str_comp(s->m_aName, g_Config.m_ClAssetGame) == 0)
OldSelected = i; OldSelected = i;
} }
else if(s_CurCustomTab == 2) else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
{ {
if(str_comp(s->m_aName, g_Config.m_ClAssetEmoticons) == 0) if(str_comp(s->m_aName, g_Config.m_ClAssetEmoticons) == 0)
OldSelected = i; OldSelected = i;
} }
else if(s_CurCustomTab == 3) else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
{ {
if(str_comp(s->m_aName, g_Config.m_ClAssetParticles) == 0) if(str_comp(s->m_aName, g_Config.m_ClAssetParticles) == 0)
OldSelected = i; OldSelected = i;
} }
else if(s_CurCustomTab == ASSETS_TAB_HUD)
{
if(str_comp(s->m_aName, g_Config.m_ClAssetHud) == 0)
OldSelected = i;
}
CListboxItem Item = UiDoListboxNextItem(s, OldSelected == i); CListboxItem Item = UiDoListboxNextItem(s, OldSelected == i);
CUIRect ItemRect = Item.m_Rect; CUIRect ItemRect = Item.m_Rect;
@ -504,26 +553,31 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
{ {
if(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName[0] != '\0') if(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName[0] != '\0')
{ {
if(s_CurCustomTab == 0) if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
{ {
str_copy(g_Config.m_ClAssetsEntites, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetsEntites)); str_copy(g_Config.m_ClAssetsEntites, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetsEntites));
m_pClient->m_MapImages.ChangeEntitiesPath(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName); m_pClient->m_MapImages.ChangeEntitiesPath(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName);
} }
else if(s_CurCustomTab == 1) else if(s_CurCustomTab == ASSETS_TAB_GAME)
{ {
str_copy(g_Config.m_ClAssetGame, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetGame)); str_copy(g_Config.m_ClAssetGame, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetGame));
GameClient()->LoadGameSkin(g_Config.m_ClAssetGame); GameClient()->LoadGameSkin(g_Config.m_ClAssetGame);
} }
else if(s_CurCustomTab == 2) else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
{ {
str_copy(g_Config.m_ClAssetEmoticons, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetEmoticons)); str_copy(g_Config.m_ClAssetEmoticons, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetEmoticons));
GameClient()->LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons); GameClient()->LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons);
} }
else if(s_CurCustomTab == 3) else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
{ {
str_copy(g_Config.m_ClAssetParticles, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetParticles)); str_copy(g_Config.m_ClAssetParticles, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetParticles));
GameClient()->LoadParticlesSkin(g_Config.m_ClAssetParticles); GameClient()->LoadParticlesSkin(g_Config.m_ClAssetParticles);
} }
else if(s_CurCustomTab == ASSETS_TAB_HUD)
{
str_copy(g_Config.m_ClAssetParticles, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetHud));
GameClient()->LoadHudSkin(g_Config.m_ClAssetHud);
}
} }
} }
@ -567,14 +621,16 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
{ {
char aBuf[IO_MAX_PATH_LENGTH]; char aBuf[IO_MAX_PATH_LENGTH];
char aBufFull[IO_MAX_PATH_LENGTH + 7]; char aBufFull[IO_MAX_PATH_LENGTH + 7];
if(s_CurCustomTab == 0) if(s_CurCustomTab == ASSETS_TAB_ENTITIES)
str_copy(aBufFull, "assets/entities", sizeof(aBufFull)); str_copy(aBufFull, "assets/entities", sizeof(aBufFull));
else if(s_CurCustomTab == 1) else if(s_CurCustomTab == ASSETS_TAB_GAME)
str_copy(aBufFull, "assets/game", sizeof(aBufFull)); str_copy(aBufFull, "assets/game", sizeof(aBufFull));
else if(s_CurCustomTab == 2) else if(s_CurCustomTab == ASSETS_TAB_EMOTICONS)
str_copy(aBufFull, "assets/emoticons", sizeof(aBufFull)); str_copy(aBufFull, "assets/emoticons", sizeof(aBufFull));
else if(s_CurCustomTab == 3) else if(s_CurCustomTab == ASSETS_TAB_PARTICLES)
str_copy(aBufFull, "assets/particles", sizeof(aBufFull)); str_copy(aBufFull, "assets/particles", sizeof(aBufFull));
else if(s_CurCustomTab == ASSETS_TAB_HUD)
str_copy(aBufFull, "assets/hud", sizeof(aBufFull));
Storage()->GetCompletePath(IStorage::TYPE_SAVE, aBufFull, aBuf, sizeof(aBuf)); Storage()->GetCompletePath(IStorage::TYPE_SAVE, aBufFull, aBuf, sizeof(aBuf));
Storage()->CreateFolder("assets", IStorage::TYPE_SAVE); Storage()->CreateFolder("assets", IStorage::TYPE_SAVE);
Storage()->CreateFolder(aBufFull, IStorage::TYPE_SAVE); Storage()->CreateFolder(aBufFull, IStorage::TYPE_SAVE);
@ -654,3 +710,18 @@ void CMenus::ConchainAssetEmoticons(IConsole::IResult *pResult, void *pUserData,
pfnCallback(pResult, pCallbackUserData); pfnCallback(pResult, pCallbackUserData);
} }
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);
}

View file

@ -262,6 +262,7 @@ void CGameClient::OnInit()
m_GameSkinLoaded = false; m_GameSkinLoaded = false;
m_ParticlesSkinLoaded = false; m_ParticlesSkinLoaded = false;
m_EmoticonsSkinLoaded = false; m_EmoticonsSkinLoaded = false;
m_HudSkinLoaded = false;
// setup load amount// load textures // setup load amount// load textures
for(int i = 0; i < g_pData->m_NumImages; i++) for(int i = 0; i < g_pData->m_NumImages; i++)
@ -272,6 +273,8 @@ void CGameClient::OnInit()
LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons); LoadEmoticonsSkin(g_Config.m_ClAssetEmoticons);
else if(i == IMAGE_PARTICLES) else if(i == IMAGE_PARTICLES)
LoadParticlesSkin(g_Config.m_ClAssetParticles); LoadParticlesSkin(g_Config.m_ClAssetParticles);
else if(i == IMAGE_HUD)
LoadHudSkin(g_Config.m_ClAssetHud);
else else
g_pData->m_aImages[i].m_Id = Graphics()->LoadTexture(g_pData->m_aImages[i].m_pFilename, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); g_pData->m_aImages[i].m_Id = Graphics()->LoadTexture(g_pData->m_aImages[i].m_pFilename, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0);
m_Menus.RenderLoading(false); m_Menus.RenderLoading(false);
@ -2999,6 +3002,88 @@ void CGameClient::LoadParticlesSkin(const char *pPath, bool AsDir)
} }
} }
void CGameClient::LoadHudSkin(const char *pPath, bool AsDir)
{
if(m_HudSkinLoaded)
{
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudAirjump);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudAirjumpEmpty);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudSolo);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudNoCollision);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudEndlessJump);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudEndlessHook);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudJetpack);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudFreezeBarFullLeft);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudFreezeBarFull);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudFreezeBarEmpty);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudFreezeBarEmptyRight);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudNoHookHit);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudNoHammerHit);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudNoShotgunHit);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudNoGrenadeHit);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudNoLaserHit);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudTeleportGrenade);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudTeleportGun);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudTeleportLaser);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudDummyHammer);
Graphics()->UnloadTexture(&m_HudSkin.m_SpriteHudDummyCopy);
m_HudSkinLoaded = false;
}
char aPath[IO_MAX_PATH_LENGTH];
bool IsDefault = false;
if(str_comp(pPath, "default") == 0)
{
str_format(aPath, sizeof(aPath), "%s", g_pData->m_aImages[IMAGE_HUD].m_pFilename);
IsDefault = true;
}
else
{
if(AsDir)
str_format(aPath, sizeof(aPath), "assets/hud/%s/%s", pPath, g_pData->m_aImages[IMAGE_HUD].m_pFilename);
else
str_format(aPath, sizeof(aPath), "assets/hud/%s.png", pPath);
}
CImageInfo ImgInfo;
bool PngLoaded = Graphics()->LoadPNG(&ImgInfo, aPath, IStorage::TYPE_ALL);
if(!PngLoaded && !IsDefault)
{
if(AsDir)
LoadHudSkin("default");
else
LoadHudSkin(pPath, true);
}
else if(PngLoaded && Graphics()->CheckImageDivisibility(aPath, ImgInfo, g_pData->m_aSprites[SPRITE_HUD_AIRJUMP].m_pSet->m_Gridx, g_pData->m_aSprites[SPRITE_HUD_AIRJUMP].m_pSet->m_Gridy, true) && Graphics()->IsImageFormatRGBA(aPath, ImgInfo))
{
m_HudSkin.m_SpriteHudAirjump = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_AIRJUMP]);
m_HudSkin.m_SpriteHudAirjumpEmpty = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_AIRJUMP_EMPTY]);
m_HudSkin.m_SpriteHudSolo = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_SOLO]);
m_HudSkin.m_SpriteHudNoCollision = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_NO_COLLISION]);
m_HudSkin.m_SpriteHudEndlessJump = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_ENDLESS_JUMP]);
m_HudSkin.m_SpriteHudEndlessHook = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_ENDLESS_HOOK]);
m_HudSkin.m_SpriteHudJetpack = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_JETPACK]);
m_HudSkin.m_SpriteHudFreezeBarFullLeft = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_FREEZE_BAR_FULL_LEFT]);
m_HudSkin.m_SpriteHudFreezeBarFull = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_FREEZE_BAR_FULL]);
m_HudSkin.m_SpriteHudFreezeBarEmpty = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_FREEZE_BAR_EMPTY]);
m_HudSkin.m_SpriteHudFreezeBarEmptyRight = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_FREEZE_BAR_EMPTY_RIGHT]);
m_HudSkin.m_SpriteHudNoHookHit = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_NO_HOOK_HIT]);
m_HudSkin.m_SpriteHudNoHammerHit = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_NO_HAMMER_HIT]);
m_HudSkin.m_SpriteHudNoShotgunHit = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_NO_SHOTGUN_HIT]);
m_HudSkin.m_SpriteHudNoGrenadeHit = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_NO_GRENADE_HIT]);
m_HudSkin.m_SpriteHudNoLaserHit = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_NO_LASER_HIT]);
m_HudSkin.m_SpriteHudTeleportGrenade = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_TELEPORT_GRENADE]);
m_HudSkin.m_SpriteHudTeleportGun = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_TELEPORT_GUN]);
m_HudSkin.m_SpriteHudTeleportLaser = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_TELEPORT_LASER]);
m_HudSkin.m_SpriteHudDummyHammer = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_DUMMY_HAMMER]);
m_HudSkin.m_SpriteHudDummyCopy = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_DUMMY_COPY]);
m_HudSkinLoaded = true;
free(ImgInfo.m_pData);
}
}
void CGameClient::RefindSkins() void CGameClient::RefindSkins()
{ {
for(auto &Client : m_aClients) for(auto &Client : m_aClients)

View file

@ -530,6 +530,7 @@ public:
void LoadGameSkin(const char *pPath, bool AsDir = false); void LoadGameSkin(const char *pPath, bool AsDir = false);
void LoadEmoticonsSkin(const char *pPath, bool AsDir = false); void LoadEmoticonsSkin(const char *pPath, bool AsDir = false);
void LoadParticlesSkin(const char *pPath, bool AsDir = false); void LoadParticlesSkin(const char *pPath, bool AsDir = false);
void LoadHudSkin(const char *pPath, bool AsDir = false);
void RefindSkins(); void RefindSkins();
@ -641,6 +642,34 @@ public:
SClientEmoticonsSkin m_EmoticonsSkin; SClientEmoticonsSkin m_EmoticonsSkin;
bool m_EmoticonsSkinLoaded; bool m_EmoticonsSkinLoaded;
struct SClientHudSkin
{
IGraphics::CTextureHandle m_SpriteHudAirjump;
IGraphics::CTextureHandle m_SpriteHudAirjumpEmpty;
IGraphics::CTextureHandle m_SpriteHudSolo;
IGraphics::CTextureHandle m_SpriteHudNoCollision;
IGraphics::CTextureHandle m_SpriteHudEndlessJump;
IGraphics::CTextureHandle m_SpriteHudEndlessHook;
IGraphics::CTextureHandle m_SpriteHudJetpack;
IGraphics::CTextureHandle m_SpriteHudFreezeBarFullLeft;
IGraphics::CTextureHandle m_SpriteHudFreezeBarFull;
IGraphics::CTextureHandle m_SpriteHudFreezeBarEmpty;
IGraphics::CTextureHandle m_SpriteHudFreezeBarEmptyRight;
IGraphics::CTextureHandle m_SpriteHudNoHookHit;
IGraphics::CTextureHandle m_SpriteHudNoHammerHit;
IGraphics::CTextureHandle m_SpriteHudNoShotgunHit;
IGraphics::CTextureHandle m_SpriteHudNoGrenadeHit;
IGraphics::CTextureHandle m_SpriteHudNoLaserHit;
IGraphics::CTextureHandle m_SpriteHudTeleportGrenade;
IGraphics::CTextureHandle m_SpriteHudTeleportGun;
IGraphics::CTextureHandle m_SpriteHudTeleportLaser;
IGraphics::CTextureHandle m_SpriteHudDummyHammer;
IGraphics::CTextureHandle m_SpriteHudDummyCopy;
};
SClientHudSkin m_HudSkin;
bool m_HudSkinLoaded;
const std::vector<CSnapEntities> &SnapEntities() { return m_aSnapEntities; } const std::vector<CSnapEntities> &SnapEntities() { return m_aSnapEntities; }
private: private: