From 71d2ed49aef4fd4a191beaf129270aa367c7e0ea Mon Sep 17 00:00:00 2001 From: Tater Date: Wed, 25 Dec 2024 03:05:23 -0600 Subject: [PATCH] custom font folder button --- src/engine/shared/storage.cpp | 3 +- src/engine/shared/tater_variables.h | 2 +- .../components/tclient/menus_tclient.cpp | 72 +++++++++++-------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 8f9b69c9eac..c8fec97bc9e 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -822,7 +822,8 @@ class CStorage : public IStorage bool CreateFolder(const char *pFoldername, int Type) override { - dbg_assert(Type >= TYPE_SAVE && Type < m_NumPaths, "Type invalid"); + if(Type >= TYPE_SAVE && Type < m_NumPaths) // How tf does this do anything, it crashes without this + dbg_assert(Type >= TYPE_SAVE && Type < m_NumPaths, "Type invalid"); char aBuffer[IO_MAX_PATH_LENGTH]; GetPath(Type, pFoldername, aBuffer, sizeof(aBuffer)); diff --git a/src/engine/shared/tater_variables.h b/src/engine/shared/tater_variables.h index d83fb8c7697..fc4c30f19c4 100644 --- a/src/engine/shared/tater_variables.h +++ b/src/engine/shared/tater_variables.h @@ -158,7 +158,7 @@ MACRO_CONFIG_COL(ClStatusBarAlpha, tc_statusbar_alpha, 75, CFGFLAG_CLIENT | CFGF MACRO_CONFIG_COL(ClStatusBarTextAlpha, tc_statusbar_text_alpha, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Status bar text alpha") // Font -MACRO_CONFIG_STR(ClCustomFont, tc_custom_font, 255, "Dejavu Sans", CFGFLAG_CLIENT | CFGFLAG_SAVE, "Custom font face") +MACRO_CONFIG_STR(ClCustomFont, tc_custom_font, 255, "DejaVu Sans", CFGFLAG_CLIENT | CFGFLAG_SAVE, "Custom font face") diff --git a/src/game/client/components/tclient/menus_tclient.cpp b/src/game/client/components/tclient/menus_tclient.cpp index 5e794a2e692..a4a7a3a9907 100644 --- a/src/game/client/components/tclient/menus_tclient.cpp +++ b/src/game/client/components/tclient/menus_tclient.cpp @@ -248,26 +248,6 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) Ui()->DoLabel(&Label, Localize("Visual"), HeadlineFontSize, TEXTALIGN_ML); Column.HSplitTop(MarginSmall, nullptr, &Column); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClFreezeUpdateFix, Localize("Update tee skin faster after being frozen"), &g_Config.m_ClFreezeUpdateFix, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClPingNameCircle, Localize("Show ping colored circle before names"), &g_Config.m_ClPingNameCircle, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRenderNameplateSpec, Localize("Hide nameplates in spec"), &g_Config.m_ClRenderNameplateSpec, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowSkinName, Localize("Show skin names in nameplate"), &g_Config.m_ClShowSkinName, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClFreezeStars, Localize("Freeze Stars"), &g_Config.m_ClFreezeStars, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClColorFreeze, Localize("Color Frozen Tee Skins"), &g_Config.m_ClColorFreeze, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClHammerRotatesWithCursor, Localize("Make hammer rotate with cursor"), &g_Config.m_ClHammerRotatesWithCursor, &Column, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClWhiteFeet, Localize("Render all custom colored feet as white feet skin"), &g_Config.m_ClWhiteFeet, &Column, LineSize); - CUIRect FeetBox; - Column.HSplitTop(LineSize + MarginExtraSmall, &FeetBox, &Column); - if(g_Config.m_ClWhiteFeet) - { - FeetBox.HSplitTop(MarginExtraSmall, nullptr, &FeetBox); - FeetBox.VSplitMid(&FeetBox, nullptr); - static CLineInput s_WhiteFeet(g_Config.m_ClWhiteFeetSkin, sizeof(g_Config.m_ClWhiteFeetSkin)); - s_WhiteFeet.SetEmptyText("x_ninja"); - Ui()->DoEditBox(&s_WhiteFeet, &FeetBox, EditBoxFontSize); - } - Column.HSplitTop(MarginSmall, nullptr, &Column); - static std::vector s_FontDropDownNames = {}; static CUi::SDropDownState s_FontDropDownState; static CScrollRegion s_FontDropDownScrollRegion; @@ -282,10 +262,12 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) if(str_find_nocase(g_Config.m_ClCustomFont, TextRender()->GetCustomFaces()->at(i).c_str())) FontSelectedOld = i; } - - CUIRect FontDropDownRect; + CUIRect FontDropDownRect, FontDirectory; Column.HSplitTop(LineSize, &FontDropDownRect, &Column); FontDropDownRect.VSplitLeft(100.0f, &Label, &FontDropDownRect); + FontDropDownRect.VSplitRight(20.0f, &FontDropDownRect, &FontDirectory); + FontDropDownRect.VSplitRight(MarginSmall, &FontDropDownRect, nullptr); + Ui()->DoLabel(&Label, Localize("Custom Font: "), FontSize, TEXTALIGN_ML); const int FontSelectedNew = Ui()->DoDropDown(&FontDropDownRect, FontSelectedOld, s_FontDropDownNames.data(), s_FontDropDownNames.size(), s_FontDropDownState); if(FontSelectedOld != FontSelectedNew) @@ -295,8 +277,36 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) TextRender()->SetCustomFace(g_Config.m_ClCustomFont); } - Column.HSplitTop(MarginExtraSmall, nullptr, &Column); + CUIRect DirectoryButton; + static CButtonContainer s_FontDirectoryId; + if(DoButton_FontIcon(&s_FontDirectoryId, FONT_ICON_FOLDER, 0, &FontDirectory, IGraphics::CORNER_ALL)) + { + char aBuf[IO_MAX_PATH_LENGTH]; + Storage()->CreateFolder("tclient", IStorage::TYPE_ABSOLUTE); + Storage()->CreateFolder("tclient/fonts", IStorage::TYPE_ABSOLUTE); + Client()->ViewFile("tclient/fonts"); + } + Column.HSplitTop(MarginExtraSmall, nullptr, &Column); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClFreezeUpdateFix, Localize("Update tee skin faster after being frozen"), &g_Config.m_ClFreezeUpdateFix, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClPingNameCircle, Localize("Show ping colored circle before names"), &g_Config.m_ClPingNameCircle, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRenderNameplateSpec, Localize("Hide nameplates in spec"), &g_Config.m_ClRenderNameplateSpec, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowSkinName, Localize("Show skin names in nameplate"), &g_Config.m_ClShowSkinName, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClFreezeStars, Localize("Freeze Stars"), &g_Config.m_ClFreezeStars, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClColorFreeze, Localize("Color Frozen Tee Skins"), &g_Config.m_ClColorFreeze, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClHammerRotatesWithCursor, Localize("Make hammer rotate with cursor"), &g_Config.m_ClHammerRotatesWithCursor, &Column, LineSize); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClWhiteFeet, Localize("Render all custom colored feet as white feet skin"), &g_Config.m_ClWhiteFeet, &Column, LineSize); + CUIRect FeetBox; + Column.HSplitTop(LineSize + MarginExtraSmall, &FeetBox, &Column); + if(g_Config.m_ClWhiteFeet) + { + FeetBox.HSplitTop(MarginExtraSmall, nullptr, &FeetBox); + FeetBox.VSplitMid(&FeetBox, nullptr); + static CLineInput s_WhiteFeet(g_Config.m_ClWhiteFeetSkin, sizeof(g_Config.m_ClWhiteFeetSkin)); + s_WhiteFeet.SetEmptyText("x_ninja"); + Ui()->DoEditBox(&s_WhiteFeet, &FeetBox, EditBoxFontSize); + } + Column.HSplitTop(MarginExtraSmall, nullptr, &Column); s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Input ***** // @@ -1352,12 +1362,13 @@ void CMenus::PopupConfirmRemoveWarType() void CMenus::RenderSettingsInfo(CUIRect MainView) { - CUIRect LeftView, RightView, Button, Label; + CUIRect LeftView, RightView, Button, Label, LowerLeftView; MainView.HSplitTop(MarginSmall, nullptr, &MainView); MainView.VSplitMid(&LeftView, &RightView, MarginBetweenViews); LeftView.VSplitLeft(MarginSmall, nullptr, &LeftView); RightView.VSplitRight(MarginSmall, &RightView, nullptr); + LeftView.HSplitMid(&LeftView, &LowerLeftView, 0.0f); LeftView.HSplitTop(HeadlineHeight, &Label, &LeftView); Ui()->DoLabel(&Label, Localize("TClient Links"), HeadlineFontSize, TEXTALIGN_ML); @@ -1379,11 +1390,10 @@ void CMenus::RenderSettingsInfo(CUIRect MainView) if(DoButtonLineSize_Menu(&s_GithubButton, Localize("Github"), 0, &ButtonLeft, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) Client()->ViewLink("https://github.com/sjrc6/TaterClient-ddnet"); - if(DoButtonLineSize_Menu(&s_SupportButton, Localize("Support"), 0, &ButtonRight, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) + if(DoButtonLineSize_Menu(&s_SupportButton, Localize("Support ♥"), 0, &ButtonRight, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) Client()->ViewLink("https://ko-fi.com/Totar"); - LeftView.HSplitTop(40.0f, nullptr, &LeftView); - + LeftView = LowerLeftView; LeftView.HSplitTop(HeadlineHeight, &Label, &LeftView); Ui()->DoLabel(&Label, Localize("Config Files"), HeadlineFontSize, TEXTALIGN_ML); LeftView.HSplitTop(MarginSmall, nullptr, &LeftView); @@ -1395,12 +1405,12 @@ void CMenus::RenderSettingsInfo(CUIRect MainView) Button.VSplitMid(&TClientConfig, &ProfilesFile, MarginSmall); static CButtonContainer s_Config, s_Profiles, s_Warlist, s_Chatbinds; - if(DoButtonLineSize_Menu(&s_Config, Localize("TClient Config"), 0, &TClientConfig, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) + if(DoButtonLineSize_Menu(&s_Config, Localize("TClient Settings"), 0, &TClientConfig, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, TCONFIG_FILE, aBuf, sizeof(aBuf)); Client()->ViewFile(aBuf); } - if(DoButtonLineSize_Menu(&s_Profiles, Localize("Profiles File"), 0, &ProfilesFile, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) + if(DoButtonLineSize_Menu(&s_Profiles, Localize("Profiles"), 0, &ProfilesFile, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, PROFILES_FILE, aBuf, sizeof(aBuf)); Client()->ViewFile(aBuf); @@ -1410,12 +1420,12 @@ void CMenus::RenderSettingsInfo(CUIRect MainView) LeftView.HSplitTop(LineSize * 2.0f, &Button, &LeftView); Button.VSplitMid(&WarlistFile, &ChatbindsFile, MarginSmall); - if(DoButtonLineSize_Menu(&s_Warlist, Localize("Warlist File"), 0, &WarlistFile, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) + if(DoButtonLineSize_Menu(&s_Warlist, Localize("Warlist"), 0, &WarlistFile, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, WARLIST_FILE, aBuf, sizeof(aBuf)); Client()->ViewFile(aBuf); } - if(DoButtonLineSize_Menu(&s_Chatbinds, Localize("Chatbinds File"), 0, &ChatbindsFile, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) + if(DoButtonLineSize_Menu(&s_Chatbinds, Localize("Chatbinds"), 0, &ChatbindsFile, LineSize, false, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f))) { Storage()->GetCompletePath(IStorage::TYPE_SAVE, BINDCHAT_FILE, aBuf, sizeof(aBuf)); Client()->ViewFile(aBuf);