Skip to content

Commit

Permalink
Move chillerbot settings to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Aug 26, 2024
1 parent 39fd0e8 commit cc57ce3
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 121 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
156 changes: 156 additions & 0 deletions src/game/client/components/menus_chillerbot.cpp
Original file line number Diff line number Diff line change
@@ -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 <base/log.h>
#include <base/math.h>
#include <base/system.h>

#include <engine/graphics.h>
#include <engine/shared/config.h>
#include <engine/shared/linereader.h>
#include <engine/shared/localization.h>
#include <engine/shared/protocol7.h>
#include <engine/storage.h>
#include <engine/textrender.h>
#include <engine/updater.h>

#include <game/generated/protocol.h>

#include <game/client/animstate.h>
#include <game/client/components/chat.h>
#include <game/client/components/menu_background.h>
#include <game/client/components/sounds.h>
#include <game/client/gameclient.h>
#include <game/client/render.h>
#include <game/client/skin.h>
#include <game/client/ui.h>
#include <game/client/ui_listbox.h>
#include <game/client/ui_scrollregion.h>
#include <game/localization.h>

#include <game/client/components/chillerbot/chillerbotux.h>
#include <game/client/components/chillerbot/warlist.h>

#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);
}
}

121 changes: 0 additions & 121 deletions src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3336,127 +3336,6 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
#endif
}

#include <game/client/components/chillerbot/chillerbotux.h>
#include <game/client/components/chillerbot/warlist.h>

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<CPopupMapPickerContext *>(pContext);
Expand Down

0 comments on commit cc57ce3

Please sign in to comment.