From cc57ce39e989004bc2019df4edb4e11b1ef4b0cd Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Mon, 26 Aug 2024 08:38:10 +0800 Subject: [PATCH] Move chillerbot settings to own file --- CMakeLists.txt | 1 + .../client/components/menus_chillerbot.cpp | 156 ++++++++++++++++++ src/game/client/components/menus_settings.cpp | 121 -------------- 3 files changed, 157 insertions(+), 121 deletions(-) create mode 100644 src/game/client/components/menus_chillerbot.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f83970b2bda..7cc535fbafc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2446,6 +2446,7 @@ if(CLIENT) components/menus.cpp components/menus.h components/menus_browser.cpp + components/menus_chillerbot.cpp components/menus_demo.cpp components/menus_ingame.cpp components/menus_settings.cpp diff --git a/src/game/client/components/menus_chillerbot.cpp b/src/game/client/components/menus_chillerbot.cpp new file mode 100644 index 00000000000..b23f2d93798 --- /dev/null +++ b/src/game/client/components/menus_chillerbot.cpp @@ -0,0 +1,156 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "menus.h" + +using namespace FontIcons; +using namespace std::chrono_literals; + + +void CMenus::RenderSettingsChillerbot(CUIRect MainView) +{ + CUIRect Button, Label; + MainView.HSplitTop(10.0f, 0, &MainView); + + char aBuf[128]; + + // finish name + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Button, &MainView); + Button.VSplitLeft(120.0f, &Label, &Button); + Button.VSplitLeft(200.0f, &Button, &Checkbox); + Button.VSplitLeft(150.0f, &Button, 0); + str_format(aBuf, sizeof(aBuf), "%s:", "Finish name"); + Ui()->DoLabel(&Label, aBuf, 14.0f, -1); + static CLineInput s_NameInput; + s_NameInput.SetBuffer(g_Config.m_ClFinishName, sizeof(g_Config.m_ClFinishName)); + s_NameInput.SetEmptyText("chillerbot-ux"); + Ui()->DoEditBox(&s_NameInput, &Button, 14.0f); + if(DoButton_CheckBox(&g_Config.m_ClFinishRename, "Rename on finish", g_Config.m_ClFinishRename, &Checkbox)) + { + g_Config.m_ClFinishRename ^= 1; + m_pClient->m_ChillerBotUX.UpdateComponents(); + } + } + + MainView.HSplitTop(5.0f, 0, &MainView); + + // auto reply + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Button, &MainView); + Button.VSplitLeft(120.0f, &Label, &Button); + Button.VSplitLeft(200.0f, &Button, &Checkbox); + Button.VSplitLeft(150.0f, &Button, 0); + str_format(aBuf, sizeof(aBuf), "%s:", "auto reply msg"); + Ui()->DoLabel(&Label, aBuf, 14.0f, -1); + static CLineInput s_ReplyMsg; + s_ReplyMsg.SetBuffer(g_Config.m_ClAutoReplyMsg, sizeof(g_Config.m_ClAutoReplyMsg)); + s_ReplyMsg.SetEmptyText("I use chillerbot-ux"); + Ui()->DoEditBox(&s_ReplyMsg, &Button, 14.0f); + if(DoButton_CheckBox(&g_Config.m_ClAutoReply, "Auto reply", g_Config.m_ClAutoReply, &Checkbox)) + { + g_Config.m_ClAutoReply ^= 1; + m_pClient->m_ChillerBotUX.UpdateComponents(); + } + } + + MainView.HSplitTop(5.0f, 0, &MainView); + + // chillerbot hud + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Checkbox, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClChillerbotHud, "show component hud", g_Config.m_ClChillerbotHud, &Checkbox)) + { + g_Config.m_ClChillerbotHud ^= 1; + m_pClient->m_ChillerBotUX.UpdateComponents(); + } + } + // war list + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Checkbox, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClWarList, "war list", g_Config.m_ClWarList, &Checkbox)) + { + g_Config.m_ClWarList ^= 1; + m_pClient->m_ChillerBotUX.UpdateComponents(); + m_pClient->m_WarList.ReloadList(); + } + } + // notify tile change + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Checkbox, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClChangeTileNotification, "notify when tee leaves current tile type (while tabbed out)", g_Config.m_ClChangeTileNotification, &Checkbox)) + { + g_Config.m_ClChangeTileNotification ^= 1; + } + } + // show last killer + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Checkbox, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClShowLastKiller, "Show last killer", g_Config.m_ClShowLastKiller, &Checkbox)) + { + g_Config.m_ClShowLastKiller ^= 1; + g_Config.m_ClChillerbotHud = 1; + m_pClient->m_ChillerBotUX.UpdateComponents(); + } + } + // render laser head + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Checkbox, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClRenderLaserHead, "Render laser heads (bobbles)", g_Config.m_ClRenderLaserHead, &Checkbox)) + g_Config.m_ClRenderLaserHead ^= 1; + } + // skin stealer + { + CUIRect Checkbox; + MainView.HSplitTop(20.0f, &Checkbox, &MainView); + if(DoButton_CheckBox(&g_Config.m_ClSkinStealer, "Skin stealer", g_Config.m_ClSkinStealer, &Checkbox)) + { + str_format(aBuf, sizeof(aBuf), "cl_skin_stealer %d", !g_Config.m_ClSkinStealer); + Console()->ExecuteLine(aBuf); + } + } + // Playtime + { + MainView.HSplitTop(20.0f, &Button, &MainView); + Button.VSplitLeft(120.0f, &Label, &Button); + str_format(aBuf, sizeof(aBuf), "chillerbot-ux playtime: %d hours", m_pClient->m_ChillerBotUX.GetPlayTimeHours()); + Ui()->DoLabel(&Label, aBuf, 14.0f, -1); + } +} + diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 45455b5f0c8..31532408833 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -3336,127 +3336,6 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) #endif } -#include -#include - -void CMenus::RenderSettingsChillerbot(CUIRect MainView) -{ - CUIRect Button, Label; - MainView.HSplitTop(10.0f, 0, &MainView); - - char aBuf[128]; - - // finish name - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Button, &MainView); - Button.VSplitLeft(120.0f, &Label, &Button); - Button.VSplitLeft(200.0f, &Button, &Checkbox); - Button.VSplitLeft(150.0f, &Button, 0); - str_format(aBuf, sizeof(aBuf), "%s:", "Finish name"); - Ui()->DoLabel(&Label, aBuf, 14.0f, -1); - static CLineInput s_NameInput; - s_NameInput.SetBuffer(g_Config.m_ClFinishName, sizeof(g_Config.m_ClFinishName)); - s_NameInput.SetEmptyText("chillerbot-ux"); - Ui()->DoEditBox(&s_NameInput, &Button, 14.0f); - if(DoButton_CheckBox(&g_Config.m_ClFinishRename, "Rename on finish", g_Config.m_ClFinishRename, &Checkbox)) - { - g_Config.m_ClFinishRename ^= 1; - m_pClient->m_ChillerBotUX.UpdateComponents(); - } - } - - MainView.HSplitTop(5.0f, 0, &MainView); - - // auto reply - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Button, &MainView); - Button.VSplitLeft(120.0f, &Label, &Button); - Button.VSplitLeft(200.0f, &Button, &Checkbox); - Button.VSplitLeft(150.0f, &Button, 0); - str_format(aBuf, sizeof(aBuf), "%s:", "auto reply msg"); - Ui()->DoLabel(&Label, aBuf, 14.0f, -1); - static CLineInput s_ReplyMsg; - s_ReplyMsg.SetBuffer(g_Config.m_ClAutoReplyMsg, sizeof(g_Config.m_ClAutoReplyMsg)); - s_ReplyMsg.SetEmptyText("I use chillerbot-ux"); - Ui()->DoEditBox(&s_ReplyMsg, &Button, 14.0f); - if(DoButton_CheckBox(&g_Config.m_ClAutoReply, "Auto reply", g_Config.m_ClAutoReply, &Checkbox)) - { - g_Config.m_ClAutoReply ^= 1; - m_pClient->m_ChillerBotUX.UpdateComponents(); - } - } - - MainView.HSplitTop(5.0f, 0, &MainView); - - // chillerbot hud - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Checkbox, &MainView); - if(DoButton_CheckBox(&g_Config.m_ClChillerbotHud, "show component hud", g_Config.m_ClChillerbotHud, &Checkbox)) - { - g_Config.m_ClChillerbotHud ^= 1; - m_pClient->m_ChillerBotUX.UpdateComponents(); - } - } - // war list - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Checkbox, &MainView); - if(DoButton_CheckBox(&g_Config.m_ClWarList, "war list", g_Config.m_ClWarList, &Checkbox)) - { - g_Config.m_ClWarList ^= 1; - m_pClient->m_ChillerBotUX.UpdateComponents(); - m_pClient->m_WarList.ReloadList(); - } - } - // notify tile change - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Checkbox, &MainView); - if(DoButton_CheckBox(&g_Config.m_ClChangeTileNotification, "notify when tee leaves current tile type (while tabbed out)", g_Config.m_ClChangeTileNotification, &Checkbox)) - { - g_Config.m_ClChangeTileNotification ^= 1; - } - } - // show last killer - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Checkbox, &MainView); - if(DoButton_CheckBox(&g_Config.m_ClShowLastKiller, "Show last killer", g_Config.m_ClShowLastKiller, &Checkbox)) - { - g_Config.m_ClShowLastKiller ^= 1; - g_Config.m_ClChillerbotHud = 1; - m_pClient->m_ChillerBotUX.UpdateComponents(); - } - } - // render laser head - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Checkbox, &MainView); - if(DoButton_CheckBox(&g_Config.m_ClRenderLaserHead, "Render laser heads (bobbles)", g_Config.m_ClRenderLaserHead, &Checkbox)) - g_Config.m_ClRenderLaserHead ^= 1; - } - // skin stealer - { - CUIRect Checkbox; - MainView.HSplitTop(20.0f, &Checkbox, &MainView); - if(DoButton_CheckBox(&g_Config.m_ClSkinStealer, "Skin stealer", g_Config.m_ClSkinStealer, &Checkbox)) - { - str_format(aBuf, sizeof(aBuf), "cl_skin_stealer %d", !g_Config.m_ClSkinStealer); - Console()->ExecuteLine(aBuf); - } - } - // Playtime - { - MainView.HSplitTop(20.0f, &Button, &MainView); - Button.VSplitLeft(120.0f, &Label, &Button); - str_format(aBuf, sizeof(aBuf), "chillerbot-ux playtime: %d hours", m_pClient->m_ChillerBotUX.GetPlayTimeHours()); - Ui()->DoLabel(&Label, aBuf, 14.0f, -1); - } -} - CUi::EPopupMenuFunctionResult CMenus::PopupMapPicker(void *pContext, CUIRect View, bool Active) { CPopupMapPickerContext *pPopupContext = static_cast(pContext);