mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 09:38:19 +00:00
parent
f057898ce0
commit
8d7c99fb96
|
@ -251,6 +251,7 @@ protected:
|
|||
int m_TeePartSelected = protocol7::SKINPART_BODY;
|
||||
const CSkins7::CSkin *m_pSelectedSkin = nullptr;
|
||||
CLineInputBuffered<protocol7::MAX_SKIN_ARRAY_SIZE, protocol7::MAX_SKIN_LENGTH> m_SkinNameInput;
|
||||
void PopupConfirmDeleteSkin7();
|
||||
|
||||
// for map download popup
|
||||
int64_t m_DownloadLastCheckTime;
|
||||
|
|
|
@ -249,9 +249,9 @@ void CMenus::RenderSettingsTee7(CUIRect MainView)
|
|||
static CButtonContainer s_CustomSkinDeleteButton;
|
||||
if(DoButton_Menu(&s_CustomSkinDeleteButton, Localize("Delete"), 0, &ButtonMiddle))
|
||||
{
|
||||
// char aBuf[128];
|
||||
// str_format(aBuf, sizeof(aBuf), Localize("Are you sure that you want to delete the skin '%s'?"), m_pSelectedSkin->m_aName);
|
||||
// PopupConfirm(Localize("Delete skin"), aBuf, Localize("Yes"), Localize("No"), &CMenus::PopupConfirmDeleteSkin);
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), Localize("Are you sure that you want to delete the skin '%s'?"), m_pSelectedSkin->m_aName);
|
||||
PopupConfirm(Localize("Delete skin"), aBuf, Localize("Yes"), Localize("No"), &CMenus::PopupConfirmDeleteSkin7);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,6 +292,18 @@ void CMenus::RenderSettingsTee7(CUIRect MainView)
|
|||
}
|
||||
}
|
||||
|
||||
void CMenus::PopupConfirmDeleteSkin7()
|
||||
{
|
||||
dbg_assert(m_pSelectedSkin, "no skin selected for deletion");
|
||||
|
||||
if(!m_pClient->m_Skins7.RemoveSkin(m_pSelectedSkin))
|
||||
{
|
||||
PopupMessage(Localize("Error"), Localize("Unable to delete the skin"), Localize("Ok"));
|
||||
return;
|
||||
}
|
||||
m_pSelectedSkin = nullptr;
|
||||
}
|
||||
|
||||
void CMenus::RenderSettingsTeeBasic7(CUIRect MainView)
|
||||
{
|
||||
RenderSkinSelection7(MainView); // yes thats all here ^^
|
||||
|
|
|
@ -395,10 +395,18 @@ void CSkins7::AddSkin(const char *pSkinName, int Dummy)
|
|||
m_vSkins.emplace_back(Skin);
|
||||
}
|
||||
|
||||
void CSkins7::RemoveSkin(const CSkin *pSkin)
|
||||
bool CSkins7::RemoveSkin(const CSkin *pSkin)
|
||||
{
|
||||
char aBuf[IO_MAX_PATH_LENGTH];
|
||||
str_format(aBuf, sizeof(aBuf), SKINS_DIR "/%s.json", pSkin->m_aName);
|
||||
if(!Storage()->RemoveFile(aBuf, IStorage::TYPE_SAVE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto Position = std::find(m_vSkins.begin(), m_vSkins.end(), *pSkin);
|
||||
m_vSkins.erase(Position);
|
||||
return true;
|
||||
}
|
||||
|
||||
int CSkins7::Num()
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
void OnInit() override;
|
||||
|
||||
void AddSkin(const char *pSkinName, int Dummy);
|
||||
void RemoveSkin(const CSkin *pSkin);
|
||||
bool RemoveSkin(const CSkin *pSkin);
|
||||
|
||||
int Num();
|
||||
int NumSkinPart(int Part);
|
||||
|
|
Loading…
Reference in a new issue