Skip to content

Commit

Permalink
Merge branch 'ddnet:master' into insta
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon authored Nov 27, 2023
2 parents 039ea30 + 0213535 commit 6e2cb1a
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 129 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
- name: Prepare Linux (non-fancy)
if: ${{ contains(matrix.os, 'ubuntu') && !matrix.fancy }}
run: |
rustup default 1.48.0
sudo rm -rf /var/lib/mysql/ /var/run/mysqld
sudo mkdir /var/lib/mysql/ /var/run/mysqld/
sudo chown mysql:mysql /var/lib/mysql/ /var/run/mysqld/
Expand Down
254 changes: 126 additions & 128 deletions src/game/client/components/menus_ingame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,21 +631,19 @@ void CMenus::RenderServerControl(CUIRect MainView)
MainView.HSplitBottom(90.0f, &MainView, &RconExtension);

// tab bar
{
TabBar.VSplitLeft(TabBar.w / 3, &Button, &TabBar);
static CButtonContainer s_Button0;
if(DoButton_MenuTab(&s_Button0, Localize("Change settings"), s_ControlPage == 0, &Button, 0))
s_ControlPage = 0;

TabBar.VSplitMid(&Button, &TabBar);
static CButtonContainer s_Button1;
if(DoButton_MenuTab(&s_Button1, Localize("Kick player"), s_ControlPage == 1, &Button, 0))
s_ControlPage = 1;

static CButtonContainer s_Button2;
if(DoButton_MenuTab(&s_Button2, Localize("Move player to spectators"), s_ControlPage == 2, &TabBar, 0))
s_ControlPage = 2;
}
TabBar.VSplitLeft(TabBar.w / 3, &Button, &TabBar);
static CButtonContainer s_Button0;
if(DoButton_MenuTab(&s_Button0, Localize("Change settings"), s_ControlPage == 0, &Button, 0))
s_ControlPage = 0;

TabBar.VSplitMid(&Button, &TabBar);
static CButtonContainer s_Button1;
if(DoButton_MenuTab(&s_Button1, Localize("Kick player"), s_ControlPage == 1, &Button, 0))
s_ControlPage = 1;

static CButtonContainer s_Button2;
if(DoButton_MenuTab(&s_Button2, Localize("Move player to spectators"), s_ControlPage == 2, &TabBar, 0))
s_ControlPage = 2;

// render page
MainView.HSplitBottom(ms_ButtonHeight + 5 * 2, &MainView, &Bottom);
Expand All @@ -660,50 +658,105 @@ void CMenus::RenderServerControl(CUIRect MainView)
Call = RenderServerControlKick(MainView, true);

// vote menu
CUIRect QuickSearch;

// render quick search
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &QuickSearch, &Bottom);
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);

UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);

if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()))
{
CUIRect QuickSearch;
UI()->SetActiveItem(&m_FilterInput);
m_ControlPageOpening = false;
m_FilterInput.SelectAll();
}
m_FilterInput.SetEmptyText(Localize("Search"));
UI()->DoClearableEditBox(&m_FilterInput, &QuickSearch, 14.0f);

// call vote
Bottom.VSplitRight(10.0f, &Bottom, 0);
Bottom.VSplitRight(120.0f, &Bottom, &Button);
Button.HSplitTop(5.0f, 0, &Button);

// render quick search
static CButtonContainer s_CallVoteButton;
if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || Call)
{
if(s_ControlPage == 0)
{
Bottom.VSplitLeft(240.0f, &QuickSearch, &Bottom);
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);

UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0);
TextRender()->SetFontPreset(EFontPreset::DEFAULT_FONT);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);

if(m_ControlPageOpening || (Input()->KeyPress(KEY_F) && Input()->ModifierIsPressed()))
m_pClient->m_Voting.CallvoteOption(m_CallvoteSelectedOption, m_CallvoteReasonInput.GetString());
if(g_Config.m_UiCloseWindowAfterChangingSetting)
SetActive(false);
}
else if(s_ControlPage == 1)
{
if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
m_pClient->m_Snap.m_apPlayerInfos[m_CallvoteSelectedPlayer])
{
UI()->SetActiveItem(&m_FilterInput);
m_ControlPageOpening = false;
m_FilterInput.SelectAll();
m_pClient->m_Voting.CallvoteKick(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString());
SetActive(false);
}
m_FilterInput.SetEmptyText(Localize("Search"));
UI()->DoClearableEditBox(&m_FilterInput, &QuickSearch, 14.0f);
}
else if(s_ControlPage == 2)
{
if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
m_pClient->m_Snap.m_apPlayerInfos[m_CallvoteSelectedPlayer])
{
m_pClient->m_Voting.CallvoteSpectate(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString());
SetActive(false);
}
}
m_CallvoteReasonInput.Clear();
}

Bottom.VSplitRight(120.0f, &Bottom, &Button);
// render kick reason
CUIRect Reason;
Bottom.VSplitRight(20.0f, &Bottom, 0);
Bottom.VSplitRight(200.0f, &Bottom, &Reason);
Reason.HSplitTop(5.0f, 0, &Reason);
const char *pLabel = Localize("Reason:");
UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_ML);
float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f);
Reason.VSplitLeft(w + 10.0f, 0, &Reason);
if(Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())
{
UI()->SetActiveItem(&m_CallvoteReasonInput);
m_CallvoteReasonInput.SelectAll();
}
UI()->DoEditBox(&m_CallvoteReasonInput, &Reason, 14.0f);

static CButtonContainer s_CallVoteButton;
if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || Call)
// extended features (only available when authed in rcon)
if(Client()->RconAuthed())
{
// background
RconExtension.HSplitTop(10.0f, 0, &RconExtension);
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
RconExtension.HSplitTop(5.0f, 0, &RconExtension);

// force vote
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(120.0f, &Button, &Bottom);

static CButtonContainer s_ForceVoteButton;
if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button))
{
if(s_ControlPage == 0)
{
m_pClient->m_Voting.CallvoteOption(m_CallvoteSelectedOption, m_CallvoteReasonInput.GetString());
if(g_Config.m_UiCloseWindowAfterChangingSetting)
SetActive(false);
}
m_pClient->m_Voting.CallvoteOption(m_CallvoteSelectedOption, m_CallvoteReasonInput.GetString(), true);
else if(s_ControlPage == 1)
{
if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
m_pClient->m_Snap.m_apPlayerInfos[m_CallvoteSelectedPlayer])
{
m_pClient->m_Voting.CallvoteKick(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString());
m_pClient->m_Voting.CallvoteKick(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString(), true);
SetActive(false);
}
}
Expand All @@ -712,102 +765,47 @@ void CMenus::RenderServerControl(CUIRect MainView)
if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
m_pClient->m_Snap.m_apPlayerInfos[m_CallvoteSelectedPlayer])
{
m_pClient->m_Voting.CallvoteSpectate(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString());
m_pClient->m_Voting.CallvoteSpectate(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString(), true);
SetActive(false);
}
}
m_CallvoteReasonInput.Clear();
}

// render kick reason
CUIRect Reason;
Bottom.VSplitRight(40.0f, &Bottom, 0);
Bottom.VSplitRight(160.0f, &Bottom, &Reason);
Reason.HSplitTop(5.0f, 0, &Reason);
const char *pLabel = Localize("Reason:");
UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_ML);
float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f);
Reason.VSplitLeft(w + 10.0f, 0, &Reason);
if(Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())
if(s_ControlPage == 0)
{
UI()->SetActiveItem(&m_CallvoteReasonInput);
m_CallvoteReasonInput.SelectAll();
}
UI()->DoEditBox(&m_CallvoteReasonInput, &Reason, 14.0f);
// remove vote
Bottom.VSplitRight(10.0f, &Bottom, 0);
Bottom.VSplitRight(120.0f, 0, &Button);
static CButtonContainer s_RemoveVoteButton;
if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button))
m_pClient->m_Voting.RemovevoteOption(m_CallvoteSelectedOption);

// add vote
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoLabel(&Button, Localize("Vote description:"), 14.0f, TEXTALIGN_ML);

// extended features (only available when authed in rcon)
if(Client()->RconAuthed())
{
// background
RconExtension.Margin(10.0f, &RconExtension);
Bottom.VSplitLeft(20.0f, 0, &Button);
UI()->DoLabel(&Button, Localize("Vote command:"), 14.0f, TEXTALIGN_ML);

static CLineInputBuffered<VOTE_DESC_LENGTH> s_VoteDescriptionInput;
static CLineInputBuffered<VOTE_CMD_LENGTH> s_VoteCommandInput;
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
RconExtension.HSplitTop(5.0f, 0, &RconExtension);
Bottom.VSplitRight(10.0f, &Bottom, 0);
Bottom.VSplitRight(120.0f, &Bottom, &Button);
static CButtonContainer s_AddVoteButton;
if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button))
if(!s_VoteDescriptionInput.IsEmpty() && !s_VoteCommandInput.IsEmpty())
m_pClient->m_Voting.AddvoteOption(s_VoteDescriptionInput.GetString(), s_VoteCommandInput.GetString());

// force vote
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(120.0f, &Button, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoEditBox(&s_VoteDescriptionInput, &Button, 14.0f);

static CButtonContainer s_ForceVoteButton;
if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button))
{
if(s_ControlPage == 0)
m_pClient->m_Voting.CallvoteOption(m_CallvoteSelectedOption, m_CallvoteReasonInput.GetString(), true);
else if(s_ControlPage == 1)
{
if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
m_pClient->m_Snap.m_apPlayerInfos[m_CallvoteSelectedPlayer])
{
m_pClient->m_Voting.CallvoteKick(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString(), true);
SetActive(false);
}
}
else if(s_ControlPage == 2)
{
if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
m_pClient->m_Snap.m_apPlayerInfos[m_CallvoteSelectedPlayer])
{
m_pClient->m_Voting.CallvoteSpectate(m_CallvoteSelectedPlayer, m_CallvoteReasonInput.GetString(), true);
SetActive(false);
}
}
m_CallvoteReasonInput.Clear();
}

if(s_ControlPage == 0)
{
// remove vote
Bottom.VSplitRight(10.0f, &Bottom, 0);
Bottom.VSplitRight(120.0f, 0, &Button);
static CButtonContainer s_RemoveVoteButton;
if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button))
m_pClient->m_Voting.RemovevoteOption(m_CallvoteSelectedOption);

// add vote
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoLabel(&Button, Localize("Vote description:"), 14.0f, TEXTALIGN_ML);

Bottom.VSplitLeft(20.0f, 0, &Button);
UI()->DoLabel(&Button, Localize("Vote command:"), 14.0f, TEXTALIGN_ML);

static CLineInputBuffered<64> s_VoteDescriptionInput;
static CLineInputBuffered<512> s_VoteCommandInput;
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
Bottom.VSplitRight(10.0f, &Bottom, 0);
Bottom.VSplitRight(120.0f, &Bottom, &Button);
static CButtonContainer s_AddVoteButton;
if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button))
if(!s_VoteDescriptionInput.IsEmpty() && !s_VoteCommandInput.IsEmpty())
m_pClient->m_Voting.AddvoteOption(s_VoteDescriptionInput.GetString(), s_VoteCommandInput.GetString());

Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoEditBox(&s_VoteDescriptionInput, &Button, 14.0f);

Bottom.VMargin(20.0f, &Button);
UI()->DoEditBox(&s_VoteCommandInput, &Button, 14.0f);
}
Bottom.VMargin(20.0f, &Button);
UI()->DoEditBox(&s_VoteCommandInput, &Button, 14.0f);
}
}
}
Expand Down

0 comments on commit 6e2cb1a

Please sign in to comment.