Пример #1
0
int CMenus::RenderSettingsIdentLegacy(CUIRect MainView)
{
	CUIRect Button, Bar;

	enum
	{
		PAGE_PLAYER = 0,
		PAGE_TEE = 1
	};
	static int s_Page = PAGE_PLAYER;

	MainView.HSplitTop(20.0f, &Bar, &MainView);
	Bar.VSplitLeft(MainView.w/5.0f, &Button, &Bar);
	static CButtonContainer s_BackButton;
	if(DoButton_MenuTab(&s_BackButton, Localize("< back"), 0, &Button, CUI::CORNER_L))
		return 0;

	Bar.VSplitMid(&Button, &Bar);
	static CButtonContainer s_ButtonPlayer;
	if(DoButton_MenuTab(&s_ButtonPlayer, Localize("Player"), 0, &Button, 0))
		s_Page = PAGE_PLAYER;

	static CButtonContainer s_ButtonTee;
	if(DoButton_MenuTab(&s_ButtonTee, Localize("Tee"), 0, &Bar, CUI::CORNER_R))
		s_Page = PAGE_TEE;

	if(s_Page == PAGE_PLAYER)
		RenderSettingsPlayer(MainView);
	else if(s_Page == PAGE_TEE)
		RenderSettingsTee(MainView);
	else
		s_Page = PAGE_PLAYER;

	return 1;
}
Пример #2
0
// stolen from H-Client :3
void CMenus::RenderIRC(CUIRect MainView)
{
    CALLSTACK_ADD();

    static float YOffset = -500.0f; // dunno if a constant is optimal...
    if(!m_IRCActive)
    {
        YOffset = -500.0f;
        return;
    }

    smooth_set(&YOffset, 50.0f, 35.0f, Client()->RenderFrameTime());

    // small0r
    MainView.x = 50;
    MainView.y = YOffset;
    MainView.w -= 100;
    MainView.h -= 100;

    CUIRect Screen = *UI()->Screen();
    Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);

    Graphics()->BlendNormal();

    RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActiveIngame-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 5.0f);

    MainView.HSplitTop(15.0f, 0, &MainView);
    MainView.VSplitLeft(15.0f, 0, &MainView);

    MainView.Margin(5.0f, &MainView);
    RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActiveIngame-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 5.0f);

    CUIRect MainIRC, EntryBox, Button;
    MainView.Margin(10.0f, &MainIRC);

    /*if (m_GamePagePanel != PANEL_CHAT && UI()->MouseInside(&MainView) && Input()->KeyPressed(KEY_MOUSE_1))
     {
     m_GamePagePanel = PANEL_CHAT;
     }*/

    if(m_pClient->IRC()->GetState() == IIRC::STATE_DISCONNECTED)
    {
        EntryBox.x = MainIRC.x + (MainIRC.w / 2.0f - 300.0f / 2.0f);
        EntryBox.w = 300.0f;
        EntryBox.y = MainIRC.y + (MainIRC.h / 2.0f - 55.0f / 2.0f);
        EntryBox.h = 55.0f;

        RenderTools()->DrawUIRect(&EntryBox, ms_ColorTabbarActive-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 10.0f);
        EntryBox.Margin(5.0f, &EntryBox);

        EntryBox.HSplitTop(18.0f, &Button, &EntryBox);
        CUIRect Label;
        Button.VSplitLeft(40.0f, &Label, &Button);
        UI()->DoLabelScaled(&Label, Localize("Nick:"), 14.0f, -1);
        static float OffsetNick;
        if(g_Config.m_ClIRCNick[0] == 0)
        {
            str_copy(g_Config.m_ClIRCNick, g_Config.m_PlayerName, sizeof(g_Config.m_ClIRCNick));
            str_irc_sanitize(g_Config.m_ClIRCNick);
        } //TODO_ here?
        static CButtonContainer s_EditboxIRCNick;
        DoEditBox(&s_EditboxIRCNick, &Button, g_Config.m_ClIRCNick, sizeof(g_Config.m_ClIRCNick), 12.0f, &OffsetNick,
                  false, CUI::CORNER_ALL);

        EntryBox.HSplitTop(5.0f, 0x0, &EntryBox);
        EntryBox.HSplitTop(20.0f, &Button, &EntryBox);
        static CButtonContainer s_ButtonConnect;
        if(DoButton_Menu(&s_ButtonConnect, Localize("Connect"), 0, &Button))
            m_pClient->m_pIRCBind->Connect();
    }
    else if(m_pClient->IRC()->GetState() == IIRC::STATE_CONNECTING)
    {
        EntryBox.x = MainIRC.x + (MainIRC.w / 2.0f - 300.0f / 2.0f);
        EntryBox.w = 300.0f;
        EntryBox.y = MainIRC.y + (MainIRC.h / 2.0f - 25.0f / 2.0f);
        EntryBox.h = 25.0f;

        RenderTools()->DrawUIRect(&EntryBox, ms_ColorTabbarActive-vec4(0.0f, 0.0f, 0.0f, 0.2f), CUI::CORNER_ALL, 10.0f);
        EntryBox.Margin(5.0f, &EntryBox);
        UI()->DoLabelScaled(&EntryBox, Localize("Connecting, please wait..."), 14.0f, -1);
    }
    else if(m_pClient->IRC()->GetState() == IIRC::STATE_CONNECTED)
    {
        CUIRect ButtonBox, InputBox;

        // channel list
        MainIRC.HSplitTop(20.0f, &ButtonBox, &EntryBox);
        ButtonBox.VSplitRight(80.0f, &ButtonBox, &Button);
        static CButtonContainer s_ButtonDisc;
        if(DoButton_Menu(&s_ButtonDisc, g_Config.m_ClIRCAutoconnect ? Localize("Reconnect") : Localize("Disconnect"), 0, &Button))
            m_pClient->m_pIRCBind->Disconnect(g_Config.m_ClIRCLeaveMsg);

        // scroll through the tabs
        if(UI()->MouseInside(&ButtonBox) && m_pClient->m_pGameConsole->IsClosed())
        {
            if(m_pClient->Input()->KeyPress(KEY_MOUSE_WHEEL_UP))
                m_pClient->IRC()->NextRoom();
            else if(m_pClient->Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN))
                m_pClient->IRC()->PrevRoom();
        }

        float LW = (ButtonBox.w - ButtonBox.x) / m_pClient->IRC()->GetNumComs();
        static CButtonContainer s_ButsID[64];
        for(unsigned i = 0; i < m_pClient->IRC()->GetNumComs(); i++)
        {
            CIRCCom *pCom = m_pClient->IRC()->GetCom(i);

            //	if(pCom == m_pClient->IRC()->GetActiveCom())
            ButtonBox.VSplitLeft(LW - 25.0f, &Button, &ButtonBox);
            //	else
            //	{
            //		ButtonBox.VSplitLeft(LW, &Button, &ButtonBox);
            //		Button.VSplitRight(2.0f, &Button, 0x0);
            //	}

            // close using middle mouse button
            if(UI()->MouseInside(&Button) && m_pClient->Input()->KeyPress(KEY_MOUSE_3) &&
                    m_pClient->IRC()->CanCloseCom(m_pClient->IRC()->GetCom(i)))
                m_pClient->IRC()->Part(g_Config.m_ClIRCLeaveMsg, m_pClient->IRC()->GetCom(i));

            if(pCom->GetType() == CIRCCom::TYPE_CHANNEL)
            {
                CComChan *pChan = static_cast<CComChan*>(pCom);
                static float FadeVal[64] = { 0.0f };
                static bool Add[64] = { true };

                if(Add[i])
                    smooth_set(&FadeVal[i], 1.0f, 120.0f, Client()->RenderFrameTime());
                else
                    smooth_set(&FadeVal[i], 0.0f, 120.0f, Client()->RenderFrameTime());
                if(FadeVal[i] >= 0.8f) Add[i] = false;
                if(FadeVal[i] <= 0.2f) Add[i] = true;

                char aTab[255];
                if(pCom->m_NumUnreadMsg)
                {
                    str_format(aTab, sizeof(aTab), "%s [%d]", pChan->Channel(), pCom->m_NumUnreadMsg);
                    if(DoButton_MenuTab(&s_ButsID[i], aTab, pCom->m_NumUnreadMsg, &Button, i==m_pClient->IRC()->GetNumComs()-1?CUI::CORNER_R:0, vec4(0.0f, FadeVal[i], 0.0f, 1.0f)))
                        m_pClient->IRC()->SetActiveCom(i);
                }
                else
                {
                    FadeVal[i] = 0.0f;
                    Add[i] = true;
                    str_copy(aTab, pChan->Channel(), sizeof(aTab));
                    if(DoButton_MenuTab(&s_ButsID[i], aTab, pCom == m_pClient->IRC()->GetActiveCom(), &Button, i==m_pClient->IRC()->GetNumComs()-1?CUI::CORNER_R:0))
                        m_pClient->IRC()->SetActiveCom(i);
                }
            }
            else if(pCom->GetType() == CIRCCom::TYPE_QUERY)
            {
                CComQuery *pQuery = static_cast<CComQuery*>(pCom);
                static float FadeVal[64] = { 0.0f };
                static bool Add[64] = { true };

                if(Add[i])
                    smooth_set(&FadeVal[i], 1.0f, 120.0f, Client()->RenderFrameTime());
                else
                    smooth_set(&FadeVal[i], 0.0f, 120.0f, Client()->RenderFrameTime());
                if(FadeVal[i] >= 0.8f) Add[i] = false;
                if(FadeVal[i] <= 0.2f) Add[i] = true;

                char aTab[255];
                if(pCom->m_NumUnreadMsg)
                {
                    str_format(aTab, sizeof(aTab), "%s [%d]", pQuery->User(), pCom->m_NumUnreadMsg);
                    if(DoButton_MenuTab(&s_ButsID[i], aTab, pCom->m_NumUnreadMsg, &Button, i==m_pClient->IRC()->GetNumComs()-1?CUI::CORNER_R:0, vec4(0.0f, FadeVal[i], 0.0f, 1.0f)))
                        m_pClient->IRC()->SetActiveCom(i);
                }
                else
                {
                    FadeVal[i] = 0.0f;
                    Add[i] = true;
                    str_copy(aTab, pQuery->User(), sizeof(aTab));
                    if(DoButton_MenuTab(&s_ButsID[i], aTab, pCom == m_pClient->IRC()->GetActiveCom(), &Button, i==m_pClient->IRC()->GetNumComs()-1?CUI::CORNER_R:0))
                        m_pClient->IRC()->SetActiveCom(i);
                }
            }

            if(i > 0 && pCom == m_pClient->IRC()->GetActiveCom() && m_pClient->IRC()->GetNumComs() > 2 && str_comp_nocase(((CComChan*)pCom)->Channel(), "#AllTheHaxx"))
            {
                Button.VSplitRight(ButtonBox.h, 0, &Button);
                Button.Margin(3.0f, &Button);
                Button.x -= 5.0f;
                Button.h = Button.w;
                static CButtonContainer s_CloseButton;
                if(DoButton_Menu(&s_CloseButton, "×", 0, &Button, 0, CUI::CORNER_ALL, ms_ColorTabbarActive+vec4(0.3f,0.3f,0.3f,0)))
                    m_pClient->IRC()->Part(g_Config.m_ClIRCLeaveMsg);
            }
        }

        static char aEntryText[512];
        static int s_CurrBacklogIndex = -1;
        bool Update = false;
        if(Input()->KeyPress(KEY_UP))
        {
            s_CurrBacklogIndex++;
            Update = true;
        }
        if(Input()->KeyPress(KEY_DOWN))
        {
            s_CurrBacklogIndex--;
            Update = true;
        }
        s_CurrBacklogIndex = clamp(s_CurrBacklogIndex, -1, m_aIRCBacklog.size()-1);

        if(Update)
        {
            if(s_CurrBacklogIndex < 0)
                mem_zero(aEntryText, sizeof(aEntryText));
            else if(m_aIRCBacklog.size() > 0)
            {
                int ActualEntry = m_aIRCBacklog.size()-1-s_CurrBacklogIndex;
                if(str_length(m_aIRCBacklog[ActualEntry].c_str()) > 0)
                    str_copy(aEntryText, m_aIRCBacklog[ActualEntry].c_str(), sizeof(aEntryText));
            }
        }

        // Input Box
        EntryBox.HSplitBottom(20.0f, &EntryBox, &InputBox);
        InputBox.VSplitRight(max(50.0f, TextRender()->TextWidth(0, (InputBox.h-2.0f)*ms_FontmodHeight, Localize("Send"), -1)), &InputBox, &Button);
        //Button.VSplitLeft(5.0f, 0x0, &Button);
        static float s_Offset;
        CPointerContainer s_EditboxInput(&m_IRCActive);
        DoEditBox(&s_EditboxInput, &InputBox, aEntryText, sizeof(aEntryText), 12.0f, &s_Offset, false, CUI::CORNER_L, "", -1);
        static CButtonContainer s_ButtonSend;
        if(DoButton_Menu(&s_ButtonSend, Localize("Send"), 0, &Button, 0, CUI::CORNER_R, vec4(1,1,1,0.6f))
                || m_EnterPressed)
        {
            if(aEntryText[0] == '/'/* || (m_pClient->IRC()->GetActiveCom()->GetType() == CIRCCom::TYPE_QUERY &&
					str_comp_nocase(((CComQuery*)m_pClient->IRC()->GetActiveCom())->m_User, "@Status") == 0)*/)
            {
                std::string strCmdRaw;
                //if(str_comp_nocase(((CComQuery*)m_pClient->IRC()->GetActiveCom())->m_User, "@Status") == 0)
                //	strCmdRaw = aEntryText;
                //else
                strCmdRaw = aEntryText + 1;
                char aCmd[32] = { 0 }, aCmdParams[255] = { 0 };
                size_t del = strCmdRaw.find_first_of(" ");
                if(del != std::string::npos)
                {
                    str_copy(aCmd, strCmdRaw.substr(0, del).c_str(), sizeof(aCmd));
                    str_copy(aCmdParams, strCmdRaw.substr(del + 1).c_str(), sizeof(aCmdParams));
                }
                else
                    str_copy(aCmd, strCmdRaw.c_str(), sizeof(aCmd));

                if(aCmd[0] != 0)
                    m_pClient->IRC()->ExecuteCommand(aCmd, aCmdParams);
            }
            else
                m_pClient->IRC()->SendMsg(0x0, aEntryText);

            if(str_length(aEntryText) > 0)
                m_aIRCBacklog.add(std::string(aEntryText));
            s_CurrBacklogIndex = -1;
            aEntryText[0] = 0;
            UI()->SetActiveItem(s_EditboxInput.GetID());
        }

        if(!UI()->HotItem())
            UI()->SetActiveItem(s_EditboxInput.GetID());

        //Channel/Query
        CIRCCom *pCom = m_pClient->IRC()->GetActiveCom();
        if(!pCom)
            return;

        if(pCom->GetType() == CIRCCom::TYPE_CHANNEL)
        {
            CComChan *pChan = static_cast<CComChan*>(pCom);

            CUIRect Chat, HorizScrollBar, UserList;
            EntryBox.Margin(5.0f, &EntryBox);
            EntryBox.VSplitRight(150.0f, &Chat, &UserList);
            Chat.HSplitBottom(15.0f, &Chat, &HorizScrollBar);

            static CButtonContainer s_HScrollbar;
            static float s_HScrollbarVal = 0.0f;
            s_HScrollbarVal = DoScrollbarH(&s_HScrollbar, &HorizScrollBar, s_HScrollbarVal);
            if(Input()->KeyIsPressed(KEY_LSHIFT) && m_pClient->m_pGameConsole->IsClosed())
            {
                if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) // to the right
                    s_HScrollbarVal += 0.1f;
                if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) // to the left
                    s_HScrollbarVal -= 0.1f;
                s_HScrollbarVal = clamp(s_HScrollbarVal, 0.0f, 1.0f);
            }

            static int Selected = 0;
            static CButtonContainer s_UsersList;
            static float s_UsersScrollValue = 0;
            /*if(!Input()->KeyIsPressed(KEY_LSHIFT) && UI()->MouseInside(&UserList))
            {
            	if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) // to the right
            		s_UsersScrollValue -= 0.1f;
            	if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) // to the left
            		s_UsersScrollValue += 0.1f;
            	s_UsersScrollValue = clamp(s_UsersScrollValue, 0.0f, 1.0f);
            }*/
            char aBuff[50];
            str_format(aBuff, sizeof(aBuff), Localize("Total: %d"), pChan->m_Users.size());
            UiDoListboxStart(&s_UsersList, &UserList, 18.0f, Localize("Users"), aBuff, pChan->m_Users.size(), 1, Selected,
                             s_UsersScrollValue, CUI::CORNER_TR);

            for(int u = 0; u < pChan->m_Users.size(); u++)
            {
                std::string& Name = pChan->m_Users[u].m_Nick;
                CPointerContainer Container(&Name);
                CListboxItem Item = UiDoListboxNextItem(&Container, false, UI()->MouseInside(&UserList) != 0);

                if(!Item.m_Visible)
                    continue;

                // quick join button
                CUIRect Label, ButtonQS;
                Item.m_Rect.VSplitRight(Item.m_Rect.h, &Label, &ButtonQS);

                if(Selected == u)
                {
                    if(UI()->DoButtonLogic(&Item.m_Selected, "", Selected, &Label))
                    {
                        if(str_comp_nocase(Name.c_str()+1, m_pClient->IRC()->GetNick()) != 0)
                            m_pClient->IRC()->OpenQuery(Name.c_str());
                    }
                }

                CComChan::CUser *pUser = &(pChan->m_Users[u]);
                dbg_assert(pUser != NULL, "in render: pChan->m_Users contains invalid pointer");

                //DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_JOIN, &ButtonQS/*, vec4(0.47f, 0.58f, 0.72f, 1.0f)*/);
                CPointerContainer s_JoinButton(pUser);
                ButtonQS.Margin(2.0f, &ButtonQS);
                if(!pUser->IsVoice() && !pUser->IsAdmin() && str_comp(pUser->m_Nick.c_str(), m_pClient->IRC()->GetNick()) != 0)
                    if(DoButton_Menu(&s_JoinButton, "→", 0, &ButtonQS, Localize("Join"), CUI::CORNER_ALL, vec4(0, 0, 1, 0.7f)))
                        //if(UI()->DoButtonLogic(&Item.m_Visible, "", Selected, &ButtonQS))
                    {
                        m_pClient->IRC()->SendGetServer(Name.c_str());
                    }

                // colors for admin and voice
                if(pUser->IsAdmin())
                    TextRender()->TextColor(0.2f, 0.7f, 0.2f, 1);
                else if(pUser->IsVoice())
                    TextRender()->TextColor(0.2f, 0.2f, 0.7f, 1);

                UI()->DoLabelScaled(&Item.m_Rect, Name.c_str(), 12.0f, -1);
                TextRender()->TextColor(1,1,1,1);
            }
            Selected = UiDoListboxEnd(&s_UsersScrollValue, 0);

            static CButtonContainer s_Chat;
            static float s_ChatScrollValue = 1.0f;
            /*if(!Input()->KeyIsPressed(KEY_LSHIFT) && UI()->MouseInside(&Chat))
            {
            	if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) // to the right
            		s_ChatScrollValue -= 0.1f;
            	if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) // to the left
            		s_ChatScrollValue += 0.1f;
            	s_ChatScrollValue = clamp(s_ChatScrollValue, 0.0f, 1.0f);
            }*/
            UiDoListboxStart(&s_Chat, &Chat, 12.0f,
                             pChan->m_Topic.c_str()[0] ? pChan->m_Topic.c_str() : "", "",
                             (int)pChan->m_Buffer.size(), 1, -1, s_ChatScrollValue, CUI::CORNER_TL);
            for(size_t i = 0; i < pChan->m_Buffer.size(); i++)
            {
                CPointerContainer Container(&pChan->m_Buffer[i]);
                CListboxItem Item = UiDoListboxNextItem(&Container, false, !Input()->KeyIsPressed(KEY_LSHIFT) && UI()->MouseInside(&UserList));

                if(Item.m_Visible)
                {
                    Item.m_Rect.x -= 1.7f*Item.m_Rect.w * s_HScrollbarVal;
                    const char *pSearchFrom = str_find(pChan->m_Buffer[i].c_str(), ">");
                    if(!pSearchFrom)
                        pSearchFrom = pChan->m_Buffer[i].c_str();
                    if(str_find_nocase(pSearchFrom, m_pClient->IRC()->GetNick()))
                    {
                        vec3 rgb = HslToRgb(vec3((float)g_Config.m_ClMessageHighlightHue/255.0f, (float)g_Config.m_ClMessageHighlightSat/255.0f, (float)g_Config.m_ClMessageHighlightLht/255.0f));
                        TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
                    }
                    UI()->DoLabelScaled(&Item.m_Rect, pChan->m_Buffer[i].c_str(), 10.0f, -1);
                    TextRender()->TextColor(1,1,1,1);
                }
            }
            UiDoListboxEnd(&s_ChatScrollValue, 0);
        }
        else if(pCom->GetType() == CIRCCom::TYPE_QUERY)
        {
            CComQuery *pQuery = static_cast<CComQuery*>(pCom);
            CUIRect Chat, HorizScrollBar;
            EntryBox.Margin(5.0f, &Chat);
            Chat.HSplitBottom(15.0f, &Chat, &HorizScrollBar);

            static CButtonContainer s_HScrollbar;
            static float s_HScrollbarVal = 0.0f;
            s_HScrollbarVal = DoScrollbarH(&s_HScrollbar, &HorizScrollBar, s_HScrollbarVal);
            if(Input()->KeyIsPressed(KEY_LSHIFT) && m_pClient->m_pGameConsole->IsClosed())
            {
                if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) // to the right
                    s_HScrollbarVal += 0.1f;
                if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) // to the left
                    s_HScrollbarVal -= 0.1f;
                s_HScrollbarVal = clamp(s_HScrollbarVal, 0.0f, 1.0f);
            }

            static CButtonContainer s_Chat;
            static float s_ChatScrollValue = 1.0f;
            /*if(!Input()->KeyIsPressed(KEY_LSHIFT) && UI()->MouseInside(&Chat))
            {
            	if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP)) // to the right
            		s_ChatScrollValue -= 0.1f;
            	if(Input()->KeyPress(KEY_MOUSE_WHEEL_DOWN)) // to the left
            		s_ChatScrollValue += 0.1f;
            	s_ChatScrollValue = clamp(s_ChatScrollValue, 0.0f, 1.0f);
            }*/
            UiDoListboxStart(&s_Chat, &Chat, 12.0f, pQuery->User(), "", (int)pQuery->m_Buffer.size(), 1, -1,
                             s_ChatScrollValue);
            for(size_t i = 0; i < pQuery->m_Buffer.size(); i++)
            {
                CPointerContainer Container(&pQuery->m_Buffer[i]);
                CListboxItem Item = UiDoListboxNextItem(&Container, false, !Input()->KeyIsPressed(KEY_LSHIFT) && UI()->MouseInside(&Chat));

                if(Item.m_Visible)
                {
                    Item.m_Rect.x -= 1.7f*Item.m_Rect.w * s_HScrollbarVal;
                    if(pQuery->m_Buffer[i].c_str())
                        if(str_length(pQuery->m_Buffer[i].c_str()))
                            UI()->DoLabelScaled(&Item.m_Rect, pQuery->m_Buffer[i].c_str(), 10.0f, -1);
                }
            }
            UiDoListboxEnd(&s_ChatScrollValue, 0);

            // the join button
            if(str_comp_nocase(pQuery->User(), "@status") != 0 && str_comp(pQuery->User(), m_pClient->IRC()->GetNick()) != 0 &&
                    ((CComChan*)m_pClient->IRC()->GetCom(1))->GetUser(std::string(pQuery->User())) && // this is kinda inefficient but whatever...
                    !((CComChan*)m_pClient->IRC()->GetCom(1))->GetUser(std::string(pQuery->User()))->IsVoice() &&
                    !((CComChan*)m_pClient->IRC()->GetCom(1))->GetUser(std::string(pQuery->User()))->IsAdmin()
              )
            {
                CUIRect ButtonQS;
                Chat.VSplitRight(32.0f, 0x0, &ButtonQS);
                ButtonQS.h = 32.0f;
                ButtonQS.x -= 20.0f;
                ButtonQS.y += 25.0f;
                RenderTools()->DrawUIRect(&ButtonQS, vec4(0.2f, 0.6f, 0.4f, UI()->MouseInside(&ButtonQS) ? 1.0f : 0.6f),
                                          CUI::CORNER_ALL, 15.0f);
                ButtonQS.x += 5.0f;
                ButtonQS.y += 7.0f;
                UI()->DoLabelScaled(&ButtonQS, Localize("Join"), 11.0f, -1);
                //DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_CONNECT, &ButtonQS, vec4(0.47f, 0.58f, 0.72f, 1.0f));
                static int s_ButtonQSLog = 0;
                if(UI()->DoButtonLogic(&s_ButtonQSLog, "", 0, &ButtonQS))
                {
                    m_pClient->IRC()->SendGetServer(pQuery->User());
                }
            }
        }
    }
}
Пример #3
0
int CMenus::RenderMenubar(CUIRect r)
{
	CUIRect Box = r;
	CUIRect Button;
	
	m_ActivePage = g_Config.m_UiPage;
	int NewPage = -1;
	
	if(Client()->State() != IClient::STATE_OFFLINE)
		m_ActivePage = m_GamePage;
	
	if(Client()->State() == IClient::STATE_OFFLINE)
	{
		// offline menus
		if(0) // this is not done yet
		{
			Box.VSplitLeft(90.0f, &Button, &Box);
			static int s_NewsButton=0;
			if (DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage==PAGE_NEWS, &Button, 0))
				NewPage = PAGE_NEWS;
			Box.VSplitLeft(30.0f, 0, &Box); 
		}

		Box.VSplitLeft(100.0f, &Button, &Box);
		static int s_InternetButton=0;
		if(DoButton_MenuTab(&s_InternetButton, Localize("Internet"), m_ActivePage==PAGE_INTERNET, &Button, CUI::CORNER_TL))
		{
			ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
			NewPage = PAGE_INTERNET;
		}

		//Box.VSplitLeft(4.0f, 0, &Box);
		Box.VSplitLeft(80.0f, &Button, &Box);
		static int s_LanButton=0;
		if(DoButton_MenuTab(&s_LanButton, Localize("LAN"), m_ActivePage==PAGE_LAN, &Button, 0))
		{
			ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
			NewPage = PAGE_LAN;
		}

		//box.VSplitLeft(4.0f, 0, &box);
		Box.VSplitLeft(110.0f, &Button, &Box);
		static int s_FavoritesButton=0;
		if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage==PAGE_FAVORITES, &Button, CUI::CORNER_TR))
		{
			ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
			NewPage  = PAGE_FAVORITES;
		}
		
		Box.VSplitLeft(4.0f*5, 0, &Box);
		Box.VSplitLeft(100.0f, &Button, &Box);
		static int s_DemosButton=0;
		if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage==PAGE_DEMOS, &Button, CUI::CORNER_T))
		{
			DemolistPopulate();
			NewPage  = PAGE_DEMOS;
		}		
	}
	else
	{
		// online menus
		Box.VSplitLeft(90.0f, &Button, &Box);
		static int s_GameButton=0;
		if(DoButton_MenuTab(&s_GameButton, Localize("Game"), m_ActivePage==PAGE_GAME, &Button, CUI::CORNER_TL))
			NewPage = PAGE_GAME;

		Box.VSplitLeft(90.0f, &Button, &Box);
		static int s_PlayersButton=0;
		if(DoButton_MenuTab(&s_PlayersButton, Localize("Players"), m_ActivePage==PAGE_PLAYERS, &Button, 0))
			NewPage = PAGE_PLAYERS;

		Box.VSplitLeft(130.0f, &Button, &Box);
		static int s_ServerInfoButton=0;
		if(DoButton_MenuTab(&s_ServerInfoButton, Localize("Server info"), m_ActivePage==PAGE_SERVER_INFO, &Button, 0))
			NewPage = PAGE_SERVER_INFO;

		Box.VSplitLeft(130.0f, &Button, &Box);
		static int s_CallVoteButton=0;
		if(DoButton_MenuTab(&s_CallVoteButton, Localize("Call vote"), m_ActivePage==PAGE_CALLVOTE, &Button, CUI::CORNER_TR))
			NewPage = PAGE_CALLVOTE;
	}
		
	/*
	box.VSplitRight(110.0f, &box, &button);
	static int system_button=0;
	if (UI()->DoButton(&system_button, "System", g_Config.m_UiPage==PAGE_SYSTEM, &button))
		g_Config.m_UiPage = PAGE_SYSTEM;
		
	box.VSplitRight(30.0f, &box, 0);
	*/
	
	Box.VSplitRight(90.0f, &Box, &Button);
	static int s_QuitButton=0;
	if(DoButton_MenuTab(&s_QuitButton, Localize("Quit"), 0, &Button, CUI::CORNER_T))
		m_Popup = POPUP_QUIT;

	Box.VSplitRight(10.0f, &Box, &Button);
	Box.VSplitRight(130.0f, &Box, &Button);
	static int s_SettingsButton=0;
	if(DoButton_MenuTab(&s_SettingsButton, Localize("Settings"), m_ActivePage==PAGE_SETTINGS, &Button, CUI::CORNER_T))
		NewPage = PAGE_SETTINGS;
	
	if(NewPage != -1)
	{
		if(Client()->State() == IClient::STATE_OFFLINE)
			g_Config.m_UiPage = NewPage;
		else
			m_GamePage = NewPage;
	}
		
	return 0;
}
Пример #4
0
void CMenus::RenderServerbrowser(CUIRect MainView)
{
	/*
		+-----------------+	+-------+
		|				  |	|		|
		|				  |	| tool	|
		|   server list	  |	| box 	|
		|				  |	|	  	|
		|				  |	|		|
		+-----------------+	|	 	|
			status box	tab	+-------+
	*/

	CUIRect ServerList, ToolBox, StatusBox, TabBar;

	// background
	RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
	MainView.Margin(10.0f, &MainView);

	// create server list, status box, tab bar and tool box area
	MainView.VSplitRight(205.0f, &ServerList, &ToolBox);
	ServerList.HSplitBottom(70.0f, &ServerList, &StatusBox);
	StatusBox.VSplitRight(100.0f, &StatusBox, &TabBar);
	ServerList.VSplitRight(5.0f, &ServerList, 0);

	// server list
	{
		RenderServerbrowserServerList(ServerList);
	}

	int ToolboxPage = g_Config.m_UiToolboxPage;

	// tab bar
	{
		CUIRect TabButton0, TabButton1, TabButton2;
		TabBar.HSplitTop(5.0f, 0, &TabBar);
		TabBar.HSplitTop(20.0f, &TabButton0, &TabBar);
		TabBar.HSplitTop(2.5f, 0, &TabBar);
		TabBar.HSplitTop(20.0f, &TabButton1, &TabBar);
		TabBar.HSplitTop(2.5f, 0, &TabBar);
		TabBar.HSplitTop(20.0f, &TabButton2, 0);
		vec4 Active = ms_ColorTabbarActive;
		vec4 InActive = ms_ColorTabbarInactive;
		ms_ColorTabbarActive = vec4(0.0f, 0.0f, 0.0f, 0.3f);
		ms_ColorTabbarInactive = vec4(0.0f, 0.0f, 0.0f, 0.15f);

		static int s_FiltersTab = 0;
		if (DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage==0, &TabButton0, CUI::CORNER_L))
			ToolboxPage = 0;

		static int s_InfoTab = 0;
		if (DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage==1, &TabButton1, CUI::CORNER_L))
			ToolboxPage = 1;

		static int s_FriendsTab = 0;
		if (DoButton_MenuTab(&s_FriendsTab, Localize("Friends"), ToolboxPage==2, &TabButton2, CUI::CORNER_L))
			ToolboxPage = 2;

		ms_ColorTabbarActive = Active;
		ms_ColorTabbarInactive = InActive;
		g_Config.m_UiToolboxPage = ToolboxPage;
	}

	// tool box
	{
		RenderTools()->DrawUIRect(&ToolBox, vec4(0.0f, 0.0f, 0.0f, 0.15f), CUI::CORNER_T, 4.0f);


		if(ToolboxPage == 0)
			RenderServerbrowserFilters(ToolBox);
		else if(ToolboxPage == 1)
			RenderServerbrowserServerDetail(ToolBox);
		else if(ToolboxPage == 2)
			RenderServerbrowserFriends(ToolBox);
	}

	// status box
	{
		CUIRect Button, ButtonArea;
		StatusBox.HSplitTop(5.0f, 0, &StatusBox);

		// version note
		StatusBox.HSplitBottom(15.0f, &StatusBox, &Button);
		char aBuf[64];
		if(str_comp(Client()->LatestVersion(), "0") != 0)
		{
			str_format(aBuf, sizeof(aBuf), Localize("Teeworlds %s is out! Download it at www.teeworlds.com!"), Client()->LatestVersion());
			TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
		}
		else
			str_format(aBuf, sizeof(aBuf), Localize("Current version: %s"), GAME_VERSION);
		UI()->DoLabelScaled(&Button, aBuf, 14.0f, -1);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);

		// button area
		StatusBox.VSplitRight(80.0f, &StatusBox, 0);
		StatusBox.VSplitRight(170.0f, &StatusBox, &ButtonArea);
		ButtonArea.VSplitRight(150.0f, 0, &ButtonArea);
		ButtonArea.HSplitTop(20.0f, &Button, &ButtonArea);
		Button.VMargin(2.0f, &Button);

		static int s_RefreshButton = 0;
		if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &Button))
		{
			if(g_Config.m_UiPage == PAGE_INTERNET)
				ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
			else if(g_Config.m_UiPage == PAGE_LAN)
				ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
			else if(g_Config.m_UiPage == PAGE_FAVORITES)
				ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
		}

		ButtonArea.HSplitTop(5.0f, 0, &ButtonArea);
		ButtonArea.HSplitTop(20.0f, &Button, &ButtonArea);
		Button.VMargin(2.0f, &Button);

		static int s_JoinButton = 0;
		if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed)
		{
			Client()->Connect(g_Config.m_UiServerAddress);
			m_EnterPressed = false;
		}

		// address info
		StatusBox.VSplitLeft(20.0f, 0, &StatusBox);
		StatusBox.HSplitTop(20.0f, &Button, &StatusBox);
		UI()->DoLabelScaled(&Button, Localize("Host address"), 14.0f, -1);
		StatusBox.HSplitTop(20.0f, &Button, 0);
		static float Offset = 0.0f;
		DoEditBox(&g_Config.m_UiServerAddress, &Button, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), 14.0f, &Offset);
	}
}
Пример #5
0
void CMenus::RenderServerbrowser(CUIRect MainView)
{
    RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);

    CUIRect View;
    MainView.Margin(10.0f, &View);

    /*
    	+-----------------+ +------+
    	|                 | |      |
    	|                 | | tool |
    	|                 | | box  |
    	|                 | |      |
    	|                 | +------+
    	+-----------------+  button
          status toolbar      box
    */


    //CUIRect filters;
    CUIRect StatusToolBox;
    CUIRect ToolBox;
    CUIRect ButtonBox;

    // split off a piece for filters, details and scoreboard
    View.VSplitRight(200.0f, &View, &ToolBox);
    ToolBox.HSplitBottom(80.0f, &ToolBox, &ButtonBox);
    View.HSplitBottom(ms_ButtonHeight+5.0f, &View, &StatusToolBox);

    RenderServerbrowserServerList(View);

    int ToolboxPage = g_Config.m_UiToolboxPage;

    ToolBox.VSplitLeft(5.0f, 0, &ToolBox);

    // do tabbar
    {
        CUIRect TabBar;
        CUIRect TabButton0, TabButton1;
        ToolBox.HSplitTop(22.0f, &TabBar, &ToolBox);

        TabBar.VSplitMid(&TabButton0, &TabButton1);
        //TabButton0.VSplitRight(5.0f, &TabButton0, 0);
        //TabButton1.VSplitLeft(5.0f, 0, &TabButton1);

        static int s_FiltersTab = 0;
        if (DoButton_MenuTab(&s_FiltersTab, Localize("Filter"), ToolboxPage==0, &TabButton0, CUI::CORNER_TL))
            ToolboxPage = 0;

        static int s_InfoTab = 0;
        if (DoButton_MenuTab(&s_InfoTab, Localize("Info"), ToolboxPage==1, &TabButton1, CUI::CORNER_TR))
            ToolboxPage = 1;
    }

    g_Config.m_UiToolboxPage = ToolboxPage;

    RenderTools()->DrawUIRect(&ToolBox, vec4(0,0,0,0.15f), 0, 0);

    ToolBox.HSplitTop(5.0f, 0, &ToolBox);

    if(ToolboxPage == 0)
        RenderServerbrowserFilters(ToolBox);
    else if(ToolboxPage == 1)
        RenderServerbrowserServerDetail(ToolBox);

    {
        StatusToolBox.HSplitTop(5.0f, 0, &StatusToolBox);

        CUIRect Button;
        //buttons.VSplitRight(20.0f, &buttons, &button);
        StatusToolBox.VSplitRight(110.0f, &StatusToolBox, &Button);
        Button.VMargin(2.0f, &Button);
        static int s_RefreshButton = 0;
        if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &Button))
        {
            if(g_Config.m_UiPage == PAGE_INTERNET)
                ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET);
            else if(g_Config.m_UiPage == PAGE_LAN)
                ServerBrowser()->Refresh(IServerBrowser::TYPE_LAN);
            else if(g_Config.m_UiPage == PAGE_FAVORITES)
                ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES);
        }

        char aBuf[512];
        if(str_comp(Client()->LatestVersion(), "0") != 0)
            str_format(aBuf, sizeof(aBuf), Localize("Teeworlds %s is out! Download it at www.teeworlds.com!"), Client()->LatestVersion());
        else
            str_format(aBuf, sizeof(aBuf), Localize("Current version: %s"), GAME_VERSION);
        UI()->DoLabelScaled(&StatusToolBox, aBuf, 14.0f, -1);
    }

    // do the button box
    {

        ButtonBox.VSplitLeft(5.0f, 0, &ButtonBox);
        ButtonBox.VSplitRight(5.0f, &ButtonBox, 0);

        CUIRect Button;
        ButtonBox.HSplitBottom(ms_ButtonHeight, &ButtonBox, &Button);
        Button.VSplitRight(120.0f, 0, &Button);
        Button.VMargin(2.0f, &Button);
        //button.VMargin(2.0f, &button);
        static int s_JoinButton = 0;
        if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed)
        {
            //dbg_msg("", "%s", g_Config.m_UiServerAddress);
            Client()->Connect(g_Config.m_UiServerAddress);
            m_EnterPressed = false;
        }

        ButtonBox.HSplitBottom(5.0f, &ButtonBox, &Button);
        ButtonBox.HSplitBottom(20.0f, &ButtonBox, &Button);
        static float Offset = 0.0f;
        DoEditBox(&g_Config.m_UiServerAddress, &Button, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), 14.0f, &Offset);
        ButtonBox.HSplitBottom(20.0f, &ButtonBox, &Button);
        UI()->DoLabelScaled(&Button, Localize("Host address"), 14.0f, -1);
    }
}
Пример #6
0
void CMenus::RenderServerControl(CUIRect MainView)
{
	if(m_pClient->m_LocalClientID == -1)
		return;

	static int s_ControlPage = 0;
	const char *pNotification = 0;
	char aBuf[64];

	if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS)
		pNotification = Localize("Spectators aren't allowed to start a vote.");
	else if(m_pClient->m_pVoting->IsVoting())
		pNotification = Localize("Wait for current vote to end before calling a new one.");
	else if(m_pClient->m_pVoting->CallvoteBlockTime() != 0)
	{
		str_format(aBuf, sizeof(aBuf), Localize("You must wait %d seconds before making another vote"), m_pClient->m_pVoting->CallvoteBlockTime());
		pNotification = aBuf;
	}

	bool Authed = Client()->RconAuthed();
	if(pNotification && !Authed)
	{
		// only print notice
		CUIRect Bar;
		MainView.HSplitTop(45.0f, &Bar, &MainView);
		RenderTools()->DrawUIRect(&Bar, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
		Bar.HMargin(15.0f, &Bar);
		UI()->DoLabelScaled(&Bar, pNotification, 14.0f, CUI::ALIGN_CENTER);
		return;
	}

	// tab bar
	CUIRect Bottom, Extended, TabBar, Button;
	MainView.HSplitTop(20.0f, &Bottom, &MainView);
	RenderTools()->DrawUIRect(&Bottom, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_T, 10.0f);
	MainView.HSplitTop(20.0f, &TabBar, &MainView);
	{
		TabBar.VSplitLeft(TabBar.w/3, &Button, &TabBar);
		static int s_Button0 = 0;
		if(DoButton_MenuTab(&s_Button0, Localize("Change settings"), s_ControlPage == 0, &Button, 0))
			s_ControlPage = 0;

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

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

	if(s_ControlPage == 1)
	{
		if(!m_pClient->m_ServerSettings.m_KickVote)
			pNotification = Localize("Server does not allow voting to kick players");
		else if(m_pClient->m_GameInfo.m_aTeamSize[TEAM_RED]+m_pClient->m_GameInfo.m_aTeamSize[TEAM_BLUE] < m_pClient->m_ServerSettings.m_KickMin)
		{
			str_format(aBuf, sizeof(aBuf), Localize("Kick voting requires %d players on the server"), m_pClient->m_ServerSettings.m_KickMin);
			pNotification = aBuf;
		}
	}
	else if(s_ControlPage == 2 && !m_pClient->m_ServerSettings.m_SpecVote)
		pNotification = Localize("Server does not allow voting to move players to spectators");

	if(pNotification && !Authed)
	{
		// only print notice
		CUIRect Bar;
		MainView.HSplitTop(45.0f, &Bar, &MainView);
		RenderTools()->DrawUIRect(&Bar, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 10.0f);
		Bar.HMargin(15.0f, &Bar);
		UI()->DoLabelScaled(&Bar, pNotification, 14.0f, CUI::ALIGN_CENTER);
		return;
	}

	// render background
	RenderTools()->DrawUIRect(&MainView, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 10.0f);
	MainView.Margin(10.0f, &MainView);
	MainView.HSplitBottom(90.0f, &MainView, &Extended);

	// render page
	MainView.HSplitBottom(ms_ButtonHeight + 5*2, &MainView, &Bottom);
	Bottom.HMargin(5.0f, &Bottom);

	if(s_ControlPage == 0)
		RenderServerControlServer(MainView);
	else if(s_ControlPage == 1)
		RenderServerControlKick(MainView, false);
	else if(s_ControlPage == 2)
		RenderServerControlKick(MainView, true);

	// vote menu
	{
		Bottom.VSplitRight(120.0f, &Bottom, &Button);

		// render kick reason
		CUIRect Reason, ClearButton;
		Bottom.VSplitRight(40.0f, &Bottom, 0);
		Bottom.VSplitRight(160.0f, &Bottom, &Reason);
		Reason.HSplitTop(5.0f, 0, &Reason);
		Reason.VSplitRight(Reason.h, &Reason, &ClearButton);
		const char *pLabel = Localize("Reason:");
		UI()->DoLabelScaled(&Reason, pLabel, 14.0f, CUI::ALIGN_LEFT);
		float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1);
		Reason.VSplitLeft(w+10.0f, 0, &Reason);
		static float s_Offset = 0.0f;
		DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_L);

		// clear button
		{
			static CButtonContainer s_ClearButton;
			float Fade = ButtonFade(&s_ClearButton, 0.6f);
			RenderTools()->DrawUIRect(&ClearButton, vec4(1.0f, 1.0f, 1.0f, 0.33f+(Fade/0.6f)*0.165f), CUI::CORNER_R, 3.0f);
			UI()->DoLabel(&ClearButton, "x", ClearButton.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
			if(UI()->DoButtonLogic(s_ClearButton.GetID(), "x", 0, &ClearButton))
				m_aCallvoteReason[0] = 0;
		}

		if(pNotification == 0)
		{
			// call vote
			static CButtonContainer s_CallVoteButton;
			if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button))
				HandleCallvote(s_ControlPage, false);
		}
		else
		{
			// print notice
			UI()->DoLabelScaled(&Bottom, pNotification, 14.0f, CUI::ALIGN_LEFT, Bottom.w);
		}

		// extended features (only available when authed in rcon)
		if(Authed)
		{
			// background
			Extended.Margin(10.0f, &Extended);
			Extended.HSplitTop(20.0f, &Bottom, &Extended);
			Extended.HSplitTop(5.0f, 0, &Extended);

			// 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))
				HandleCallvote(s_ControlPage, true);

			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_pVoting->RemovevoteOption(m_CallvoteSelectedOption);


				// add vote
				Extended.HSplitTop(20.0f, &Bottom, &Extended);
				Bottom.VSplitLeft(5.0f, 0, &Bottom);
				Bottom.VSplitLeft(250.0f, &Button, &Bottom);
				UI()->DoLabelScaled(&Button, Localize("Vote description:"), 14.0f, CUI::ALIGN_LEFT);

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

				static char s_aVoteDescription[64] = {0};
				static char s_aVoteCommand[512] = {0};
				Extended.HSplitTop(20.0f, &Bottom, &Extended);
				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_aVoteDescription[0] != 0 && s_aVoteCommand[0] != 0)
						m_pClient->m_pVoting->AddvoteOption(s_aVoteDescription, s_aVoteCommand);

				Bottom.VSplitLeft(5.0f, 0, &Bottom);
				Bottom.VSplitLeft(250.0f, &Button, &Bottom);
				static float s_OffsetDesc = 0.0f;
				DoEditBox(&s_aVoteDescription, &Button, s_aVoteDescription, sizeof(s_aVoteDescription), 14.0f, &s_OffsetDesc, false, CUI::CORNER_ALL);

				Bottom.VMargin(20.0f, &Button);
				static float s_OffsetCmd = 0.0f;
				DoEditBox(&s_aVoteCommand, &Button, s_aVoteCommand, sizeof(s_aVoteCommand), 14.0f, &s_OffsetCmd, false, CUI::CORNER_ALL);
			}
		}
	}
}
Пример #7
0
void CMenus::RenderServerControl(CUIRect MainView)
{
	static int s_ControlPage = 0;

	// render background
	CUIRect Bottom, Extended, TabBar, Button;
	MainView.HSplitTop(20.0f, &Bottom, &MainView);
	RenderTools()->DrawUIRect(&Bottom, ms_ColorTabbarActive, CUI::CORNER_T, 10.0f);
	MainView.HSplitTop(20.0f, &TabBar, &MainView);
	RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_B, 10.0f);
	MainView.Margin(10.0f, &MainView);
	MainView.HSplitBottom(90.0f, &MainView, &Extended);

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

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

		static int s_Button2 = 0;
		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);
	Bottom.HMargin(5.0f, &Bottom);

	if(s_ControlPage == 0)
		RenderServerControlServer(MainView);
	else if(s_ControlPage == 1)
		RenderServerControlKick(MainView, false);
	else if(s_ControlPage == 2)
		RenderServerControlKick(MainView, true);

	// vote menu
	{
		CUIRect Button;
		Bottom.VSplitRight(120.0f, &Bottom, &Button);

		static int s_CallVoteButton = 0;
		if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button))
		{
			if(s_ControlPage == 0)
				m_pClient->m_pVoting->CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason);
			else if(s_ControlPage == 1)
			{
				if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
					m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer])
				{
					m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason);
					SetActive(false);
				}
			}
			else if(s_ControlPage == 2)
			{
				if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
					m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer])
				{
					m_pClient->m_pVoting->CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason);
					SetActive(false);
				}
			}
			m_aCallvoteReason[0] = 0;
		}

		// 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()->DoLabelScaled(&Reason, pLabel, 14.0f, -1);
		float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1);
		Reason.VSplitLeft(w+10.0f, 0, &Reason);
		static float s_Offset = 0.0f;
		DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL);

		// extended features (only available when authed in rcon)
		if(Client()->RconAuthed())
		{
			// background
			Extended.Margin(10.0f, &Extended);
			Extended.HSplitTop(20.0f, &Bottom, &Extended);
			Extended.HSplitTop(5.0f, 0, &Extended);

			// force vote
			Bottom.VSplitLeft(5.0f, 0, &Bottom);
			Bottom.VSplitLeft(120.0f, &Button, &Bottom);
			static int s_ForceVoteButton = 0;
			if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button))
			{
				if(s_ControlPage == 0)
					m_pClient->m_pVoting->CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason, true);
				else if(s_ControlPage == 1)
				{
					if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
						m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer])
					{
						m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason, true);
						SetActive(false);
					}
				}
				else if(s_ControlPage == 2)
				{
					if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&
						m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer])
					{
						m_pClient->m_pVoting->CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason, true);
						SetActive(false);
					}
				}
				m_aCallvoteReason[0] = 0;
			}

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


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

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

				static char s_aVoteDescription[64] = {0};
				static char s_aVoteCommand[512] = {0};
				Extended.HSplitTop(20.0f, &Bottom, &Extended);
				Bottom.VSplitRight(10.0f, &Bottom, 0);
				Bottom.VSplitRight(120.0f, &Bottom, &Button);
				static int s_AddVoteButton = 0;
				if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button))
					if(s_aVoteDescription[0] != 0 && s_aVoteCommand[0] != 0)
						m_pClient->m_pVoting->AddvoteOption(s_aVoteDescription, s_aVoteCommand);

				Bottom.VSplitLeft(5.0f, 0, &Bottom);
				Bottom.VSplitLeft(250.0f, &Button, &Bottom);
				static float s_OffsetDesc = 0.0f;
				DoEditBox(&s_aVoteDescription, &Button, s_aVoteDescription, sizeof(s_aVoteDescription), 14.0f, &s_OffsetDesc, false, CUI::CORNER_ALL);

				Bottom.VMargin(20.0f, &Button);
				static float s_OffsetCmd = 0.0f;
				DoEditBox(&s_aVoteCommand, &Button, s_aVoteCommand, sizeof(s_aVoteCommand), 14.0f, &s_OffsetCmd, false, CUI::CORNER_ALL);
			}
		}
	}
}
Пример #8
0
void CMenus::RenderSettingsIdent(CUIRect MainView)
{
	CALLSTACK_ADD();

	static int s_LegacyIsOpen = 0;
	if(s_LegacyIsOpen)
	{
		s_LegacyIsOpen = RenderSettingsIdentLegacy(MainView);
		return;
	}

	// render background
	CUIRect Temp, TabBar, Button, Label, View;
	static int Page = 0;
		
	int numID = m_pClient->m_pIdentity->NumIdents();

	// add a new identity from current settings as we need at least one
	if(numID == 0)
		m_pClient->m_pIdentity->AddIdent();

	MainView.VSplitLeft(240.0f, &TabBar, &MainView);
	TabBar.VSplitRight(2.0f, &TabBar, &Button);
	RenderTools()->DrawUIRect(&Button, vec4(0.0f, 0.8f, 0.6f, 0.5f), 0, 0);

	TabBar.HSplitTop(20.0f, &Button, &TabBar);
	static CButtonContainer s_ButtonOpenLegacy;
	if(DoButton_Menu(&s_ButtonOpenLegacy, Localize("Open legacy view"), 0, &Button, 0, CUI::CORNER_T))
		s_LegacyIsOpen = 1;
	
	static CButtonContainer s_aDeleteIDs[512];
	static CButtonContainer s_aUpIDs[512];
	static CButtonContainer s_aDownIDs[512];
	static CButtonContainer s_aPageIDs[512];
	static CButtonContainer s_LeftListbox;
	static float s_LeftListboxScrollVal = 0.0f;
	UiDoListboxStart(&s_LeftListbox, &TabBar, 24.0f, "", "", numID+1, 1, -1, s_LeftListboxScrollVal, 0);
	for(int i = 0; i < numID+1; i++)
	{
		if(i >= 512)
			break;

		CIdentity::CIdentEntry *pEntry = m_pClient->m_pIdentity->GetIdent(i);
		CPointerContainer Container(pEntry);
		CListboxItem Item = UiDoListboxNextItem(&Container, false/*Page == i*/);

		if(!Item.m_Visible)
			continue;

		Button = Item.m_Rect;

		if(i == numID)
		{
			Button.HSplitBottom(4.0f, &Button, 0);
			Button.VSplitRight(240.0f, 0, &Temp);
			if(DoButton_MenuTab(&s_aPageIDs[i], Localize("Add Identity"), false, &Button, CUI::CORNER_B, vec4(0.7f, 0.7f, 0.2f, ms_ColorTabbarActive.a), vec4(0.7f, 0.7f, 0.2f, ms_ColorTabbarInactive.a)))
				m_pClient->m_pIdentity->AddIdent();
			break;
		}

		if(DoButton_MenuTab(&s_aPageIDs[i], "", Page == i, &Button, i == 0 ? CUI::CORNER_T : 0, vec4(0.2f, 0.6f, 0.2f, ms_ColorTabbarActive.a), vec4(0.2f, 0.6f, 0.2f, ms_ColorTabbarInactive.a)))
			Page = i;

		Button.VSplitRight(Button.h, 0, &Temp);
		Temp.Margin(4.0f, &Temp);
		if(m_pClient->m_pIdentity->NumIdents() > 1)
		{
			if(DoButton_Menu(&s_aDeleteIDs[i], "×", 0, &Temp, 0, CUI::CORNER_R | (i < numID - 1 ? 0 : CUI::CORNER_L), vec4(0.7f, 0.2f, 0.2f, 0.9f)))
			{
				m_pClient->m_pIdentity->DeleteIdent(i);
				if(i < Page)
					Page--;
			}
		}

		if(i < numID-1)
		{
			Button.VSplitRight(Button.h, 0, &Temp);
			Temp.Margin(4.0f, &Temp);
			Temp.x -= 16.0f;
			if(DoButton_Menu(&s_aDownIDs[i], "↓", 0, &Temp, 0, i >= 1 ? 0 : CUI::CORNER_L))
			{
				m_pClient->m_pIdentity->SwapIdent(i, 1);
				m_MousePos.y += 36.0f;
				if(Page == i)
					Page++;
				else if(i == Page-1)
					Page--;
			}
		}

		if(i >= 1)
		{
			Button.VSplitRight(Button.h, 0, &Temp);
			Temp.Margin(4.0f, &Temp);
			Temp.x -= 32.0f;
			if(DoButton_Menu(&s_aUpIDs[i], "↑", 0, &Temp, 0, i < numID-1 ? CUI::CORNER_L : CUI::CORNER_ALL))
			{
				m_MousePos.y -= 36.0f;
				m_pClient->m_pIdentity->SwapIdent(i, -1);
				if(i == Page)
					Page--;
				else if(i == Page+1)
					Page++;
			}
		}

		Button.HSplitTop(Button.h*0.25f, 0, &Label);

		static int DefaultSkin = -1;
		if(DefaultSkin < 0)
			 DefaultSkin = m_pClient->m_pSkins->Find("default");

		int SkinID = m_pClient->m_pSkins->Find(pEntry->m_aSkin);
		if(SkinID < 0)
			SkinID = DefaultSkin;

		const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(SkinID);
		CTeeRenderInfo OwnSkinInfo;
		if(pEntry->m_UseCustomColor)
		{
			OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture;
			OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColorV4(pEntry->m_ColorBody);
			OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(pEntry->m_ColorFeet);
		}
		else
		{
			OwnSkinInfo.m_Texture = pOwnSkin->m_OrgTexture;
			OwnSkinInfo.m_ColorBody = vec4(1.0f, 1.0f, 1.0f, 1.0f);
			OwnSkinInfo.m_ColorFeet = vec4(1.0f, 1.0f, 1.0f, 1.0f);
		}
		OwnSkinInfo.m_Size = 26.0f*UI()->Scale();
		RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Button.x + OwnSkinInfo.m_Size, Button.y + Button.h *0.6f));
		Button.HMargin(2.0f, &Button);
		Button.HSplitBottom(16.0f, 0, &Button);
		const bool IsMain = m_pClient->m_pIdentity->UsingIdent(i, false);
		const bool IsDummy = m_pClient->m_pIdentity->UsingIdent(i, true);
		vec3 rgb = IsMain && !IsDummy ? vec3(0.7f, 0.7f, 0.2f) : !IsMain && IsDummy ? vec3(0.2f, 0.7f, 0.7f) : IsMain && IsDummy ? vec3(0.2f, 0.7f, 0.2f) : vec3(1,1,1);
		TextRender()->TextColor(rgb.r, rgb.g, rgb.b, 1.0f);
		if(str_length(pEntry->m_aTitle) > 0)
			UI()->DoLabelScaled(&Button, pEntry->m_aTitle, 14.0f, 0);
		else
			UI()->DoLabelScaled(&Button, pEntry->m_aName, 14.0f, 0);
		TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
	}
	UiDoListboxEnd(&s_LeftListboxScrollVal, 0);


	MainView.HSplitTop(20.0f, &Temp, &View);
	Temp.VMargin(5.0f, &Temp);
	Temp.VSplitMid(&Button, &Temp);
	MainView.Margin(10.0f, &MainView);

	static int s_ControlPage = 0;
	CButtonContainer s_ButtonPlayer;
	if(DoButton_MenuTab(&s_ButtonPlayer, Localize("Player"), s_ControlPage == 0, &Button, CUI::CORNER_L))
		s_ControlPage = 0;
	CButtonContainer s_ButtonTee;
	if(DoButton_MenuTab(&s_ButtonTee, Localize("Tee"), s_ControlPage == 1, &Temp, CUI::CORNER_R))
		s_ControlPage = 1;

	if(s_ControlPage == 0)
		RenderSettingsIdentPlayer(View, Page);
	if(s_ControlPage == 1)
		RenderSettingsIdentTee(View, Page);
}