mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-09 17:48:19 +00:00
implement 0.7 skin save button
This commit is contained in:
parent
14f1b36dd1
commit
31ee6abe82
|
@ -1282,6 +1282,11 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
|
||||||
pButtonText = m_aMessageButton;
|
pButtonText = m_aMessageButton;
|
||||||
TopAlign = true;
|
TopAlign = true;
|
||||||
}
|
}
|
||||||
|
else if(m_Popup == POPUP_SAVE_SKIN)
|
||||||
|
{
|
||||||
|
pTitle = Localize("Save skin");
|
||||||
|
pExtraText = Localize("Are you sure you want to save your skin? If a skin with this name already exists, it will be replaced.");
|
||||||
|
}
|
||||||
|
|
||||||
CUIRect Box, Part;
|
CUIRect Box, Part;
|
||||||
Box = Screen;
|
Box = Screen;
|
||||||
|
@ -1756,6 +1761,52 @@ void CMenus::RenderPopupFullscreen(CUIRect Screen)
|
||||||
SetActive(false);
|
SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(m_Popup == POPUP_SAVE_SKIN)
|
||||||
|
{
|
||||||
|
CUIRect Label, TextBox, Yes, No;
|
||||||
|
|
||||||
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
|
Box.HSplitBottom(24.f, &Box, &Part);
|
||||||
|
Part.VMargin(80.0f, &Part);
|
||||||
|
|
||||||
|
Part.VSplitMid(&No, &Yes);
|
||||||
|
|
||||||
|
Yes.VMargin(20.0f, &Yes);
|
||||||
|
No.VMargin(20.0f, &No);
|
||||||
|
|
||||||
|
static CButtonContainer s_ButtonNo;
|
||||||
|
if(DoButton_Menu(&s_ButtonNo, Localize("No"), 0, &No) || Ui()->ConsumeHotkey(CUi::HOTKEY_ESCAPE))
|
||||||
|
m_Popup = POPUP_NONE;
|
||||||
|
|
||||||
|
static CButtonContainer s_ButtonYes;
|
||||||
|
if(DoButton_Menu(&s_ButtonYes, Localize("Yes"), m_SkinNameInput.IsEmpty() ? 1 : 0, &Yes) || Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER))
|
||||||
|
{
|
||||||
|
if(m_SkinNameInput.GetLength())
|
||||||
|
{
|
||||||
|
if(m_SkinNameInput.GetString()[0] != 'x' && m_SkinNameInput.GetString()[1] != '_')
|
||||||
|
{
|
||||||
|
if(m_pClient->m_Skins7.SaveSkinfile(m_SkinNameInput.GetString(), m_Dummy))
|
||||||
|
{
|
||||||
|
m_Popup = POPUP_NONE;
|
||||||
|
m_SkinListNeedsUpdate = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
PopupMessage(Localize("Error"), Localize("Unable to save the skin"), Localize("Ok"), POPUP_SAVE_SKIN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
PopupMessage(Localize("Error"), Localize("Unable to save the skin with a reserved name"), Localize("Ok"), POPUP_SAVE_SKIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Box.HSplitBottom(60.f, &Box, &Part);
|
||||||
|
Box.HSplitBottom(24.f, &Box, &Part);
|
||||||
|
|
||||||
|
Part.VMargin(60.0f, &Label);
|
||||||
|
Label.VSplitLeft(100.0f, &Label, &TextBox);
|
||||||
|
TextBox.VSplitLeft(20.0f, nullptr, &TextBox);
|
||||||
|
Ui()->DoLabel(&Label, Localize("Name"), 18.0f, TEXTALIGN_ML);
|
||||||
|
Ui()->DoClearableEditBox(&m_SkinNameInput, &TextBox, 12.0f);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Box.HSplitBottom(20.f, &Box, &Part);
|
Box.HSplitBottom(20.f, &Box, &Part);
|
||||||
|
|
|
@ -811,6 +811,7 @@ public:
|
||||||
POPUP_QUIT,
|
POPUP_QUIT,
|
||||||
POPUP_RESTART,
|
POPUP_RESTART,
|
||||||
POPUP_WARNING,
|
POPUP_WARNING,
|
||||||
|
POPUP_SAVE_SKIN,
|
||||||
|
|
||||||
// demo player states
|
// demo player states
|
||||||
DEMOPLAYER_NONE = 0,
|
DEMOPLAYER_NONE = 0,
|
||||||
|
|
|
@ -237,6 +237,14 @@ void CMenus::RenderSettingsTee7(CUIRect MainView)
|
||||||
// bottom buttons
|
// bottom buttons
|
||||||
if(s_CustomSkinMenu)
|
if(s_CustomSkinMenu)
|
||||||
{
|
{
|
||||||
|
static CButtonContainer s_CustomSkinSaveButton;
|
||||||
|
if(DoButton_Menu(&s_CustomSkinSaveButton, Localize("Save"), 0, &ButtonLeft))
|
||||||
|
{
|
||||||
|
m_Popup = POPUP_SAVE_SKIN;
|
||||||
|
m_SkinNameInput.SelectAll();
|
||||||
|
Ui()->SetActiveItem(&m_SkinNameInput);
|
||||||
|
}
|
||||||
|
|
||||||
static CButtonContainer s_RandomizeSkinButton;
|
static CButtonContainer s_RandomizeSkinButton;
|
||||||
if(DoButton_Menu(&s_RandomizeSkinButton, Localize("Randomize"), 0, &ButtonMiddle))
|
if(DoButton_Menu(&s_RandomizeSkinButton, Localize("Randomize"), 0, &ButtonMiddle))
|
||||||
{
|
{
|
||||||
|
|
|
@ -525,7 +525,7 @@ bool CSkins7::ValidateSkinParts(char *apPartNames[protocol7::NUM_SKINPARTS], int
|
||||||
bool CSkins7::SaveSkinfile(const char *pSaveSkinName, int Dummy)
|
bool CSkins7::SaveSkinfile(const char *pSaveSkinName, int Dummy)
|
||||||
{
|
{
|
||||||
char aBuf[IO_MAX_PATH_LENGTH];
|
char aBuf[IO_MAX_PATH_LENGTH];
|
||||||
str_format(aBuf, sizeof(aBuf), "skins/%s.json", pSaveSkinName);
|
str_format(aBuf, sizeof(aBuf), SKINS_DIR "/%s.json", pSaveSkinName);
|
||||||
IOHANDLE File = Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_SAVE);
|
IOHANDLE File = Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_SAVE);
|
||||||
if(!File)
|
if(!File)
|
||||||
return false;
|
return false;
|
||||||
|
@ -547,7 +547,7 @@ bool CSkins7::SaveSkinfile(const char *pSaveSkinName, int Dummy)
|
||||||
Writer.WriteAttribute("filename");
|
Writer.WriteAttribute("filename");
|
||||||
Writer.WriteStrValue(ms_apSkinVariables[Dummy][PartIndex]);
|
Writer.WriteStrValue(ms_apSkinVariables[Dummy][PartIndex]);
|
||||||
|
|
||||||
const bool CustomColors = *ms_apUCCVariables[PartIndex];
|
const bool CustomColors = *ms_apUCCVariables[Dummy][PartIndex];
|
||||||
Writer.WriteAttribute("custom_colors");
|
Writer.WriteAttribute("custom_colors");
|
||||||
Writer.WriteBoolValue(CustomColors);
|
Writer.WriteBoolValue(CustomColors);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue