Skip to content

Commit

Permalink
custom font folder button
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Dec 25, 2024
1 parent 16fe2e3 commit 71d2ed4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
3 changes: 2 additions & 1 deletion src/engine/shared/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/engine/shared/tater_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")



Expand Down
72 changes: 41 additions & 31 deletions src/game/client/components/tclient/menus_tclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char *> s_FontDropDownNames = {};
static CUi::SDropDownState s_FontDropDownState;
static CScrollRegion s_FontDropDownScrollRegion;
Expand All @@ -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)
Expand All @@ -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 ***** //
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 71d2ed4

Please sign in to comment.