Skip to content

Commit

Permalink
Finishing touches on the MP client list popup menu.
Browse files Browse the repository at this point in the history
* fixed mouse hover region being too short on right side.
* corrected spacing between the popup and client list panels.
* made the [ < ] buttons thinner to fix alignment with nicknames and add vertical gaps.
  • Loading branch information
ohlidalp committed Jan 25, 2025
1 parent c5f345e commit 360f75b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions source/main/gui/panels/GUI_MultiplayerClientList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void MpClientList::Draw()
{
ImGui::Dummy(ImVec2(ImGui::CalcTextSize(" < ").x + ImGui::GetStyle().FramePadding.x*2 , ImGui::GetTextLineHeight()));
}
else if (ImGui::Button(" < "))
else if (ImGui::SmallButton(" < "))
{
if (m_peeropts_menu_active_user_vectorpos == vectorpos)
{
Expand All @@ -124,7 +124,7 @@ void MpClientList::Draw()
else
{
m_peeropts_menu_active_user_vectorpos = vectorpos; // show menu
m_peeropts_menu_corner_tl = hover_tl - ImVec2(PEEROPTS_MENU_WIDTH + 15, 0);
m_peeropts_menu_corner_tl = hover_tl - ImVec2(PEEROPTS_MENU_CONTENT_WIDTH + ImGui::GetStyle().WindowPadding.x*3 + PEEROPTS_MENU_MARGIN, 0);
}
}
ImGui::SameLine();
Expand Down Expand Up @@ -323,6 +323,7 @@ void MpClientList::DrawPeerOptionsMenu()

// Draw UI
ImGui::SetNextWindowPos(m_peeropts_menu_corner_tl);
ImGui::SetNextWindowContentWidth(PEEROPTS_MENU_CONTENT_WIDTH);
const int flags = ImGuiWindowFlags_NoDecoration;
if (ImGui::Begin("PeerOptions", nullptr, flags))
{
Expand All @@ -339,14 +340,14 @@ void MpClientList::DrawPeerOptionsMenu()
this->DrawServerCommandBtn("!kick {}", _LC("MultiplayerClientList", "Kick"));
this->DrawServerCommandBtn("!ban {}", _LC("MultiplayerClientList", "Ban"));
}
m_peeropts_menu_corner_br = ImGui::GetCursorScreenPos();
m_peeropts_menu_corner_br = m_peeropts_menu_corner_tl + ImGui::GetWindowContentRegionMax();

ImGui::End();
}

// Check hover and hide
const ImVec2 hoverbox_tl = m_peeropts_menu_corner_tl - ImVec2(PEEROPTS_HOVER_PAD, PEEROPTS_HOVER_PAD);
const ImVec2 hoverbox_br = m_peeropts_menu_corner_br + ImVec2(PEEROPTS_HOVER_PAD, PEEROPTS_HOVER_PAD);
const ImVec2 hoverbox_tl = m_peeropts_menu_corner_tl - ImVec2(PEEROPTS_HOVER_MARGIN, PEEROPTS_HOVER_MARGIN);
const ImVec2 hoverbox_br = m_peeropts_menu_corner_br + ImVec2(PEEROPTS_HOVER_MARGIN, PEEROPTS_HOVER_MARGIN);
const ImVec2 mousepos = ImGui::GetIO().MousePos;
if (mousepos.x < hoverbox_tl.x || mousepos.x > hoverbox_br.x
|| mousepos.y < hoverbox_tl.y || mousepos.y > hoverbox_br.y)
Expand Down
5 changes: 3 additions & 2 deletions source/main/gui/panels/GUI_MultiplayerClientList.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class MpClientList
void DrawPeerOptionsMenu();
void DrawPeerOptCheckbox(const BitMask_t flag, const std::string& label);
void DrawServerCommandBtn(const std::string& cmdfmt, const std::string& label);
const int PEEROPTS_MENU_WIDTH = 150;
const int PEEROPTS_HOVER_PAD = 170;
const int PEEROPTS_MENU_CONTENT_WIDTH = 150;
const int PEEROPTS_MENU_MARGIN = 10;
const int PEEROPTS_HOVER_MARGIN = 100;
int m_peeropts_menu_active_user_vectorpos = -1;
ImVec2 m_peeropts_menu_corner_tl = ImVec2(0, 0);
ImVec2 m_peeropts_menu_corner_br = ImVec2(0, 0);
Expand Down

0 comments on commit 360f75b

Please sign in to comment.