diff --git a/src/game/client/components/bindwheel.cpp b/src/game/client/components/bindwheel.cpp index 18933653312..8fef0d95654 100644 --- a/src/game/client/components/bindwheel.cpp +++ b/src/game/client/components/bindwheel.cpp @@ -16,6 +16,7 @@ CBindWheel::CBindWheel() { OnReset(); } + void CBindWheel::ConExecuteHover(IConsole::IResult *pResult, void *pUserData) { CBindWheel *pThis = (CBindWheel *)pUserData; @@ -29,14 +30,21 @@ void CBindWheel::ConOpenBindwheel(IConsole::IResult *pResult, void *pUserData) pThis->m_Active = pResult->GetInteger(0) != 0; } -void CBindWheel::ConAddBindwheel_Legacy(IConsole::IResult *pResult, void *pUserData) +void CBindWheel::ConAddBindwheelLegacy(IConsole::IResult *pResult, void *pUserData) { - //int Bindpos_Legacy = pResult->GetInteger(0); + int BindPos = pResult->GetInteger(0); + if (BindPos < 0 || BindPos >= MAX_BINDS) + return; + const char *aName = pResult->GetString(1); const char *aCommand = pResult->GetString(2); CBindWheel *pThis = static_cast(pUserData); - pThis->AddBind(aName, aCommand); + while(pThis->m_vBinds.size() <= (size_t)BindPos) + pThis->AddBind("EMPTY", ""); + + str_copy(pThis->m_vBinds[BindPos].m_aName, aName); + str_copy(pThis->m_vBinds[BindPos].m_aCommand, aCommand); } void CBindWheel::ConAddBindwheel(IConsole::IResult *pResult, void *pUserData) @@ -65,27 +73,21 @@ void CBindWheel::ConRemoveAllBinds(IConsole::IResult *pResult, void *pUserData) void CBindWheel::AddBind(const char *pName, const char *pCommand) { - if((pName[0] == 0 && pCommand[0] == 0) || m_vBinds.size() > MAX_BINDS) + if((pName[0] == '\0' && pCommand[0] == '\0') || m_vBinds.size() >= MAX_BINDS) return; - // Don't allow duplicates - // for(SBind &Bind : m_vBinds) - //{ - // if(!str_comp(Bind.m_aName, pName) && !str_comp(Bind.m_aCommand, pCommand)) - // return; - //} - SBind TempBind; - str_copy(TempBind.m_aName, pName); - str_copy(TempBind.m_aCommand, pCommand); - m_vBinds.push_back(TempBind); + SBind Bind; + str_copy(Bind.m_aName, pName); + str_copy(Bind.m_aCommand, pCommand); + m_vBinds.push_back(Bind); } void CBindWheel::RemoveBind(const char *pName, const char *pCommand) { - SBind TempBind; - str_copy(TempBind.m_aName, pName); - str_copy(TempBind.m_aCommand, pCommand); - auto it = std::find(m_vBinds.begin(), m_vBinds.end(), TempBind); + SBind Bind; + str_copy(Bind.m_aName, pName); + str_copy(Bind.m_aCommand, pCommand); + auto it = std::find(m_vBinds.begin(), m_vBinds.end(), Bind); if(it != m_vBinds.end()) m_vBinds.erase(it); } @@ -112,7 +114,7 @@ void CBindWheel::OnConsoleInit() Console()->Register("+bindwheel", "", CFGFLAG_CLIENT, ConOpenBindwheel, this, "Open bindwheel selector"); Console()->Register("+bindwheel_execute_hover", "", CFGFLAG_CLIENT, ConExecuteHover, this, "Execute hovered bindwheel bind"); - Console()->Register("bindwheel", "i[index] s[name] s[command]", CFGFLAG_CLIENT, ConAddBindwheel_Legacy, this, "DONT USE THIS! USE add_bindwheel INSTEAD!"); + Console()->Register("bindwheel", "i[index] s[name] s[command]", CFGFLAG_CLIENT, ConAddBindwheelLegacy, this, "DONT USE THIS! USE add_bindwheel INSTEAD!"); Console()->Register("add_bindwheel", "s[name] s[command]", CFGFLAG_CLIENT, ConAddBindwheel, this, "Add a bind to the bindwheel"); Console()->Register("remove_bindwheel", "s[name] s[command]", CFGFLAG_CLIENT, ConRemoveBindwheel, this, "Remove a bind from the bindwheel"); Console()->Register("delete_all_bindwheel_binds", "", CFGFLAG_CLIENT, ConRemoveAllBinds, this, "Removes all bindwheel binds"); @@ -150,7 +152,7 @@ void CBindWheel::OnRender() if(!m_Active) { if(g_Config.m_ClResetBindWheelMouse) - m_SelectorMouse = vec2(0, 0); + m_SelectorMouse = vec2(0.0f, 0.0f); if(m_WasActive && m_SelectedBind != -1) ExecuteBindwheel(m_SelectedBind); m_WasActive = false; @@ -163,15 +165,15 @@ void CBindWheel::OnRender() m_SelectorMouse = normalize(m_SelectorMouse) * 170.0f; int SegmentCount = m_vBinds.size(); - float SegmentAngle = 2 * pi / SegmentCount; - - float SelectedAngle = angle(m_SelectorMouse) + SegmentAngle / 2; - if(SelectedAngle < 0) - SelectedAngle += 2 * pi; + float SegmentAngle = 2.0f * pi / SegmentCount; - m_SelectedBind = -1; + float SelectedAngle = angle(m_SelectorMouse) + SegmentAngle / 2.0f; + if(SelectedAngle < 0.0f) + SelectedAngle += 2.0f * pi; if(length(m_SelectorMouse) > 110.0f) - m_SelectedBind = (int)(SelectedAngle / (2 * pi) * SegmentCount); + m_SelectedBind = (int)(SelectedAngle / (2.0f * pi) * SegmentCount); + else + m_SelectedBind = -1; CUIRect Screen = *Ui()->Screen(); @@ -180,12 +182,12 @@ void CBindWheel::OnRender() Graphics()->BlendNormal(); Graphics()->TextureClear(); Graphics()->QuadsBegin(); - Graphics()->SetColor(0, 0, 0, 0.3f); - DrawCircle(Screen.w / 2, Screen.h / 2, 190.0f, 64); + Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f); + DrawCircle(Screen.w / 2.0f, Screen.h / 2.0f, 190.0f, 64); Graphics()->QuadsEnd(); Graphics()->WrapClamp(); - const float Theta = pi * 2 / m_vBinds.size(); + const float Theta = pi * 2.0f / m_vBinds.size(); for(int i = 0; i < static_cast(m_vBinds.size()); i++) { const SBind &Bind = m_vBinds[i]; @@ -201,11 +203,11 @@ void CBindWheel::OnRender() Graphics()->TextureClear(); Graphics()->QuadsBegin(); - Graphics()->SetColor(1.0, 1.0, 1.0, 0.3f); - DrawCircle(Screen.w / 2, Screen.h / 2, 100.0f, 64); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.3f); + DrawCircle(Screen.w / 2.0f, Screen.h / 2.0f, 100.0f, 64); Graphics()->QuadsEnd(); - RenderTools()->RenderCursor(m_SelectorMouse + vec2(Screen.w, Screen.h) / 2, 24.0f); + RenderTools()->RenderCursor(m_SelectorMouse + vec2(Screen.w, Screen.h) / 2.0f, 24.0f); } void CBindWheel::ExecuteBindwheel(int Bind) diff --git a/src/game/client/components/bindwheel.h b/src/game/client/components/bindwheel.h index 8ee967c2194..f2218c08161 100644 --- a/src/game/client/components/bindwheel.h +++ b/src/game/client/components/bindwheel.h @@ -1,6 +1,6 @@ -#ifndef GAME_CLIENT_COMPONENTS_BIND_WHEEL_H -#define GAME_CLIENT_COMPONENTS_BIND_WHEEL_H +#ifndef GAME_CLIENT_COMPONENTS_BINDWHEEL_H +#define GAME_CLIENT_COMPONENTS_BINDWHEEL_H #include class IConfigManager; @@ -22,7 +22,7 @@ class CBindWheel : public CComponent int m_SelectedBind; static void ConOpenBindwheel(IConsole::IResult *pResult, void *pUserData); - static void ConAddBindwheel_Legacy(IConsole::IResult *pResult, void *pUserData); + static void ConAddBindwheelLegacy(IConsole::IResult *pResult, void *pUserData); static void ConAddBindwheel(IConsole::IResult *pResult, void *pUserData); static void ConRemoveBindwheel(IConsole::IResult *pResult, void *pUserData); static void ConRemoveAllBinds(IConsole::IResult *pResult, void *pUserData); @@ -38,8 +38,7 @@ class CBindWheel : public CComponent bool operator==(const SBind &Other) const { - return str_comp(m_aName, Other.m_aName) == 0 && - str_comp(m_aCommand, Other.m_aCommand) == 0; + return str_comp(m_aName, Other.m_aName) == 0 && str_comp(m_aCommand, Other.m_aCommand) == 0; } }; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index bbdd9c7ab0e..583c274df5d 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -503,7 +503,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) pEmote = &g_Config.m_ClDummyDefaultEyes; } - const float EyeButtonSize = 40.0f; + const float EyeLineSize = 40.0f; const bool RenderEyesBelow = MainView.w < 750.0f; CUIRect YourSkin, Checkboxes, SkinPrefix, Eyes, Button, Label; MainView.HSplitTop(90.0f, &YourSkin, &MainView); @@ -512,12 +512,12 @@ void CMenus::RenderSettingsTee(CUIRect MainView) YourSkin.VSplitLeft(MainView.w * 0.45f, &YourSkin, &Checkboxes); Checkboxes.VSplitLeft(MainView.w * 0.35f, &Checkboxes, &SkinPrefix); MainView.HSplitTop(5.0f, nullptr, &MainView); - MainView.HSplitTop(EyeButtonSize, &Eyes, &MainView); - Eyes.VSplitRight(EyeButtonSize * NUM_EMOTES + 5.0f * (NUM_EMOTES - 1), nullptr, &Eyes); + MainView.HSplitTop(EyeLineSize, &Eyes, &MainView); + Eyes.VSplitRight(EyeLineSize * NUM_EMOTES + 5.0f * (NUM_EMOTES - 1), nullptr, &Eyes); } else { - YourSkin.VSplitRight(3 * EyeButtonSize + 2 * 5.0f, &YourSkin, &Eyes); + YourSkin.VSplitRight(3 * EyeLineSize + 2 * 5.0f, &YourSkin, &Eyes); const float RemainderWidth = YourSkin.w; YourSkin.VSplitLeft(RemainderWidth * 0.4f, &YourSkin, &Checkboxes); Checkboxes.VSplitLeft(RemainderWidth * 0.35f, &Checkboxes, &SkinPrefix); @@ -642,7 +642,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) static CButtonContainer s_RandomizeColors; if(*pUseCustomColor) { - //RandomColorsButton.VSplitLeft(120.0f, &RandomColorsButton, 0); + // RandomColorsButton.VSplitLeft(120.0f, &RandomColorsButton, 0); if(DoButton_Menu(&s_RandomizeColors, "Random Colors", 0, &RandomColorsButton, 0, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0, 0, 0, 0.5f))) { if(m_Dummy) @@ -670,21 +670,21 @@ void CMenus::RenderSettingsTee(CUIRect MainView) // Default eyes { CTeeRenderInfo EyeSkinInfo = OwnSkinInfo; - EyeSkinInfo.m_Size = EyeButtonSize; + EyeSkinInfo.m_Size = EyeLineSize; vec2 OffsetToMid; CRenderTools::GetRenderTeeOffsetToRenderedTee(CAnimState::GetIdle(), &EyeSkinInfo, OffsetToMid); CUIRect EyesRow; - Eyes.HSplitTop(EyeButtonSize, &EyesRow, &Eyes); + Eyes.HSplitTop(EyeLineSize, &EyesRow, &Eyes); static CButtonContainer s_aEyeButtons[NUM_EMOTES]; for(int CurrentEyeEmote = 0; CurrentEyeEmote < NUM_EMOTES; CurrentEyeEmote++) { - EyesRow.VSplitLeft(EyeButtonSize, &Button, &EyesRow); + EyesRow.VSplitLeft(EyeLineSize, &Button, &EyesRow); EyesRow.VSplitLeft(5.0f, nullptr, &EyesRow); if(!RenderEyesBelow && (CurrentEyeEmote + 1) % 3 == 0) { Eyes.HSplitTop(5.0f, nullptr, &Eyes); - Eyes.HSplitTop(EyeButtonSize, &EyesRow, &Eyes); + Eyes.HSplitTop(EyeLineSize, &EyesRow, &Eyes); } const ColorRGBA EyeButtonColor = ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f + (*pEmote == CurrentEyeEmote ? 0.25f : 0.0f)); @@ -3237,7 +3237,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) const float HeadlineHeight = 30.0f; const float MarginSmall = 5.0f; const float MarginExtraSmall = 2.5f; - const float MarignBetweenSections = MarginSmall * 2.0f + MarginExtraSmall; + const float MarginBetweenSections = MarginSmall * 2.0f + MarginExtraSmall; const float MarginBetweenViews = 20.0f - MarginExtraSmall; const float ColorPickerLabelSize = 13.0f; @@ -3267,7 +3267,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) } } - MainView.HSplitTop(10.0f, nullptr, &MainView); + MainView.HSplitTop(MarginSmall, nullptr, &MainView); if(s_CurCustomTab == TCLIENT_TAB_SETTINGS) { @@ -3306,7 +3306,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) Column = LeftView; // ***** Visual Miscellaneous ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Visual"), HeadlineFontSize, TEXTALIGN_ML); @@ -3332,7 +3332,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Input ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Input"), HeadlineFontSize, TEXTALIGN_ML); @@ -3349,7 +3349,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Anti Latency Tools ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Anti Latency Tools"), HeadlineFontSize, TEXTALIGN_ML); @@ -3382,7 +3382,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Other ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Other"), HeadlineFontSize, TEXTALIGN_ML); @@ -3413,7 +3413,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Player Indicator ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Player Indicator"), HeadlineFontSize, TEXTALIGN_ML); @@ -3456,7 +3456,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) Column = RightView; // ***** HUD ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("HUD"), HeadlineFontSize, TEXTALIGN_ML); @@ -3480,7 +3480,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Frozen Tee Display ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Frozen Tee Display"), HeadlineFontSize, TEXTALIGN_ML); @@ -3512,7 +3512,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Tile Outlines ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Tile Outlines"), HeadlineFontSize, TEXTALIGN_ML); @@ -3538,7 +3538,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Ghost Tools ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Ghost Tools"), HeadlineFontSize, TEXTALIGN_ML); @@ -3590,7 +3590,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) s_SectionBoxes.back().h = Column.y - s_SectionBoxes.back().y; // ***** Rainbow ***** // - Column.HSplitTop(MarignBetweenSections, nullptr, &Column); + Column.HSplitTop(MarginBetweenSections, nullptr, &Column); s_SectionBoxes.push_back(Column); Column.HSplitTop(HeadlineHeight, &Label, &Column); Ui()->DoLabel(&Label, Localize("Rainbow"), HeadlineFontSize, TEXTALIGN_ML); @@ -3630,15 +3630,11 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) if(s_CurCustomTab == TCLIENT_TAB_BINDWHEEL) { - CUIRect Section, LeftColumn, RightColumn; - CUIRect Screen = *Ui()->Screen(); - MainView.VSplitMid(&LeftColumn, &RightColumn, 0.0f); - - MainView.HSplitTop(30.0f, &Section, &MainView); + MainView.HSplitTop(MarginBetweenSections, nullptr, &MainView); + MainView.VSplitLeft(MainView.w / 2.1f, &LeftView, &RightView); - const float Radius = 190.0f; - vec2 Pos{Screen.w / 2.0f - 55.0f, Screen.h / 2.0f}; - Pos = vec2(MainView.x + MainView.w / 1.5f, MainView.y + MainView.h / 2.0f); + const float Radius = minimum(RightView.w, RightView.h) / 2.0f; + vec2 Pos{RightView.x + RightView.w / 2.0f, RightView.y + RightView.h / 2.0f}; // Draw Circle Graphics()->TextureClear(); Graphics()->QuadsBegin(); @@ -3646,96 +3642,86 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) Graphics()->DrawCircle(Pos.x, Pos.y, Radius, 64); Graphics()->QuadsEnd(); - - static int s_SelectedBindIndex = -1; - static int s_AltSelectedBindIndex = -1; - static char s_aBindName[BINDWHEEL_MAX_NAME]; static char s_aBindCommand[BINDWHEEL_MAX_CMD]; - const float Theta = pi * 2 / GameClient()->m_Bindwheel.m_vBinds.size(); - for(int i = 0; i < static_cast(GameClient()->m_Bindwheel.m_vBinds.size()); i++) + static int s_SelectedBindIndex = -1; + int HoveringIndex = -1; + + float MouseDist = distance(Pos, Ui()->MousePos()); + if(MouseDist < Radius && MouseDist > Radius * 0.25f) { - float FontSize = 12.0f; - if(i == s_SelectedBindIndex) + int SegmentCount = GameClient()->m_Bindwheel.m_vBinds.size(); + + float HoveringAngle = angle(Ui()->MousePos() - Pos); + if(HoveringAngle < 0.0f) + HoveringAngle += 2.0f * pi; + + HoveringIndex = round_to_int(HoveringAngle / (2.0f * pi) * SegmentCount); + if(Ui()->MouseButtonClicked(0)) { - FontSize = 25.0f; - TextRender()->TextColor(ColorRGBA(0.25f, 1.0f, 0.25f, 1.0f)); + s_SelectedBindIndex = HoveringIndex; + str_copy(s_aBindName, GameClient()->m_Bindwheel.m_vBinds[HoveringIndex].m_aName); + str_copy(s_aBindCommand, GameClient()->m_Bindwheel.m_vBinds[HoveringIndex].m_aCommand); } - if(i == s_AltSelectedBindIndex) + else if(Ui()->MouseButtonClicked(1) && s_SelectedBindIndex >= 0 && HoveringIndex != s_SelectedBindIndex) { - FontSize = 25.0f; - TextRender()->TextColor(ColorRGBA(0.0f, 0.75f, 1.0f, 0.5f)); + CBindWheel::SBind BindA = GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex]; + CBindWheel::SBind BindB = GameClient()->m_Bindwheel.m_vBinds[HoveringIndex]; + str_copy(GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex].m_aName, BindB.m_aName); + str_copy(GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex].m_aCommand, BindB.m_aCommand); + str_copy(GameClient()->m_Bindwheel.m_vBinds[HoveringIndex].m_aName, BindA.m_aName); + str_copy(GameClient()->m_Bindwheel.m_vBinds[HoveringIndex].m_aCommand, BindA.m_aCommand); } + } + else if(MouseDist < Radius && Ui()->MouseButtonClicked(0)) + { + s_SelectedBindIndex = -1; + str_copy(s_aBindName, ""); + str_copy(s_aBindCommand, ""); + } + + const float Theta = pi * 2.0f / GameClient()->m_Bindwheel.m_vBinds.size(); + for(int i = 0; i < static_cast(GameClient()->m_Bindwheel.m_vBinds.size()); i++) + { + float FontSize = 12.0f; + if(i == s_SelectedBindIndex) + FontSize = 16.0f; + else if(i == HoveringIndex) + FontSize = 13.0f; const CBindWheel::SBind Bind = GameClient()->m_Bindwheel.m_vBinds[i]; const float Angle = Theta * i; vec2 TextPos = direction(Angle); - TextPos *= 145.0f; - float MouseDist = distance(Pos, Ui()->MousePos()); - if(MouseDist < 190.0f && MouseDist > 40.0f) - { - int SegmentCount = GameClient()->m_Bindwheel.m_vBinds.size(); - float SegmentAngle = 2 * pi / SegmentCount; - - float HoveringAngle = angle(Ui()->MousePos() - Pos) + SegmentAngle / 2; - if(HoveringAngle < 0) - HoveringAngle += 2 * pi; + TextPos *= Radius * 0.75f; - int HoveringIndex = (int)(HoveringAngle / (2 * pi) * SegmentCount); - if(HoveringIndex == i) - { - FontSize = 28.0f; - if(Ui()->MouseButtonClicked(0)) - { - s_SelectedBindIndex = i; - str_copy(s_aBindName, GameClient()->m_Bindwheel.m_vBinds[i].m_aName); - str_copy(s_aBindCommand, GameClient()->m_Bindwheel.m_vBinds[i].m_aCommand); - s_AltSelectedBindIndex = -1; - } - // Alt Select - if(Ui()->MouseButtonClicked(1) && i != s_SelectedBindIndex) - { - s_AltSelectedBindIndex = i; - } - } - } - else if(MouseDist < 190.0f && Ui()->MouseButtonClicked(0)) - { - s_AltSelectedBindIndex = -1; - s_SelectedBindIndex = -1; - str_copy(s_aBindName, ""); - str_copy(s_aBindCommand, ""); - } float Width = TextRender()->TextWidth(FontSize, Bind.m_aName); TextPos += Pos; TextPos.x -= Width / 2.0f; TextRender()->Text(TextPos.x, TextPos.y, FontSize, Bind.m_aName); - TextRender()->TextColor(TextRender()->DefaultTextColor()); } - const float ButtonSize = 25.0f; - CUIRect BindWheelZone, BindWheelOptions; - LeftColumn.HSplitTop(60.0f, &BindWheelZone, &LeftColumn); - BindWheelZone.VSplitMid(&BindWheelOptions, nullptr, 10.0f); - - BindWheelOptions.HSplitTop(ButtonSize, &Button, &BindWheelOptions); + LeftView.HSplitTop(LineSize, &Button, &LeftView); + Button.VSplitLeft(100.0f, &Label, &Button); + Ui()->DoLabel(&Label, Localize("Name:"), 14.0f, TEXTALIGN_ML); static CLineInput s_NameInput; s_NameInput.SetBuffer(s_aBindName, sizeof(s_aBindName)); s_NameInput.SetEmptyText("Name"); - Ui()->DoEditBox(&s_NameInput, &Button, 17.0f); + Ui()->DoEditBox(&s_NameInput, &Button, 12.0f); - BindWheelOptions.HSplitTop(MarginSmall, nullptr, &BindWheelOptions); - BindWheelOptions.HSplitTop(ButtonSize, &Button, &BindWheelOptions); + LeftView.HSplitTop(MarginSmall, nullptr, &LeftView); + LeftView.HSplitTop(LineSize, &Button, &LeftView); + Button.VSplitLeft(100.0f, &Label, &Button); + Ui()->DoLabel(&Label, Localize("Command:"), 14.0f, TEXTALIGN_ML); static CLineInput s_BindInput; s_BindInput.SetBuffer(s_aBindCommand, sizeof(s_aBindCommand)); - s_BindInput.SetEmptyText("Command"); - Ui()->DoEditBox(&s_BindInput, &Button, 17.0f); + s_BindInput.SetEmptyText(Localize("Command")); + Ui()->DoEditBox(&s_BindInput, &Button, 12.0f); - static CButtonContainer s_AddButton, s_RemoveButton, s_OverrideButton, s_SwapButton; + static CButtonContainer s_AddButton, s_RemoveButton, s_OverrideButton; - BindWheelOptions.HSplitTop(MarginSmall, nullptr, &BindWheelOptions); - BindWheelOptions.HSplitTop(ButtonSize, &Button, &BindWheelOptions); + LeftView.HSplitTop(MarginSmall, nullptr, &LeftView); + LeftView.HSplitTop(LineSize, &Button, &LeftView); if(DoButton_Menu(&s_AddButton, Localize("Add Bind"), 0, &Button)) { CBindWheel::SBind TempBind; @@ -3747,21 +3733,11 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) GameClient()->m_Bindwheel.AddBind(TempBind.m_aName, s_aBindCommand); } - BindWheelOptions.HSplitTop(MarginSmall, nullptr, &BindWheelOptions); - BindWheelOptions.HSplitTop(ButtonSize, &Button, &BindWheelOptions); - if(DoButton_Menu(&s_SwapButton, Localize("Swap Selected"), 0, &Button) && s_SelectedBindIndex >= 0 && s_AltSelectedBindIndex >= 0) - { - CBindWheel::SBind BindA = GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex]; - CBindWheel::SBind BindB = GameClient()->m_Bindwheel.m_vBinds[s_AltSelectedBindIndex]; - str_copy(GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex].m_aName, BindB.m_aName); - str_copy(GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex].m_aCommand, BindB.m_aCommand); - str_copy(GameClient()->m_Bindwheel.m_vBinds[s_AltSelectedBindIndex].m_aName, BindA.m_aName); - str_copy(GameClient()->m_Bindwheel.m_vBinds[s_AltSelectedBindIndex].m_aCommand, BindA.m_aCommand); - } - - BindWheelOptions.HSplitTop(MarginSmall * 4.0f, nullptr, &BindWheelOptions); - BindWheelOptions.HSplitTop(ButtonSize, &Button, &BindWheelOptions); - if(DoButton_Menu(&s_OverrideButton, Localize("Override Selected"), 0, &Button) && s_SelectedBindIndex >= 0) + LeftView.HSplitTop(MarginSmall, nullptr, &LeftView); + LeftView.HSplitTop(LineSize, &Button, &LeftView); + CUIRect ButtonOverride, ButtonRemove; + Button.VSplitMid(&ButtonOverride, &ButtonRemove, MarginSmall); + if(DoButton_Menu(&s_OverrideButton, Localize("Override Selected"), 0, &ButtonOverride) && s_SelectedBindIndex >= 0) { CBindWheel::SBind TempBind; if(str_length(s_aBindName) == 0) @@ -3772,19 +3748,17 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) str_copy(GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex].m_aName, TempBind.m_aName); str_copy(GameClient()->m_Bindwheel.m_vBinds[s_SelectedBindIndex].m_aCommand, s_aBindCommand); } - - BindWheelOptions.HSplitTop(MarginSmall, nullptr, &BindWheelOptions); - BindWheelOptions.HSplitTop(ButtonSize, &Button, &BindWheelOptions); - if(DoButton_Menu(&s_RemoveButton, Localize("Remove Bind"), 0, &Button) && s_SelectedBindIndex >= 0) + if(DoButton_Menu(&s_RemoveButton, Localize("Remove Bind"), 0, &ButtonRemove) && s_SelectedBindIndex >= 0) { GameClient()->m_Bindwheel.RemoveBind(s_SelectedBindIndex); s_SelectedBindIndex = -1; - s_AltSelectedBindIndex = -1; } - BindWheelOptions.HSplitTop(10.0f, nullptr, &BindWheelOptions); - BindWheelOptions.HSplitTop(25.0f, &Button, &BindWheelOptions); - Ui()->DoLabel(&Button, Localize("Use left mouse to select\nUse right mouse to alt-select"), 14.0f, TEXTALIGN_ML); - + + LeftView.HSplitTop(MarginSmall, nullptr, &LeftView); + LeftView.HSplitTop(LineSize, &Label, &LeftView); + Ui()->DoLabel(&Label, Localize("Use left mouse to select"), 14.0f, TEXTALIGN_ML); + LeftView.HSplitTop(LineSize, &Label, &LeftView); + Ui()->DoLabel(&Label, Localize("Use right mouse to swap with selected"), 14.0f, TEXTALIGN_ML); // Do Settings Key CKeyInfo Key = CKeyInfo{"Bind Wheel Key", "+bindwheel", 0, 0}; @@ -3806,8 +3780,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) } CUIRect KeyLabel; - LeftColumn.HSplitBottom(LineSize, &LeftColumn, nullptr); - LeftColumn.HSplitBottom(LineSize, &LeftColumn, &Button); + LeftView.HSplitBottom(LineSize, &LeftView, &Button); Button.VSplitLeft(120.0f, &KeyLabel, &Button); Button.VSplitLeft(100.0f, &Button, nullptr); char aBuf[64]; @@ -3823,8 +3796,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) if(NewId != 0) m_pClient->m_Binds.Bind(NewId, Key.m_pCommand, false, NewModifierCombination); } - LeftColumn.HSplitBottom(10.0f, &LeftColumn, nullptr); - LeftColumn.HSplitBottom(LineSize, &LeftColumn, &Button); + LeftView.HSplitBottom(LineSize, &LeftView, &Button); DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClResetBindWheelMouse, Localize("Reset position of mouse when opening bindwheel"), &g_Config.m_ClResetBindWheelMouse, &Button, LineSize); } @@ -3833,7 +3805,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) void CMenus::RenderSettingsProfiles(CUIRect MainView) { CUIRect Label, LabelMid, Section, LabelRight; - static int SelectedProfile = -1; + static int s_SelectedProfile = -1; const float LineSize = 20.0f; const float MarginSmall = 5.0f; @@ -3883,7 +3855,7 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) Label.VSplitLeft(250.0f, &Label, &LabelMid); const CAnimState *pIdleState = CAnimState::GetIdle(); vec2 OffsetToMid; - RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &OwnSkinInfo, OffsetToMid); + CRenderTools::GetRenderTeeOffsetToRenderedTee(pIdleState, &OwnSkinInfo, OffsetToMid); vec2 TeeRenderPos(Label.x + LineSize, Label.y + Label.h / 2.0f + OffsetToMid.y); int Emote = m_Dummy ? g_Config.m_ClDummyDefaultEyes : g_Config.m_ClPlayerDefaultEyes; RenderTools()->RenderTee(pIdleState, &OwnSkinInfo, Emote, vec2(1.0f, 0.0f), TeeRenderPos); @@ -3908,23 +3880,23 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) str_format(aTempBuf, sizeof(aTempBuf), Localize("Skin: %s"), pSkinName); Ui()->DoLabel(&Section, aTempBuf, FontSize, TEXTALIGN_ML); - FlagRect.VSplitRight(50.f, nullptr, &FlagRect); - FlagRect.HSplitBottom(25.f, nullptr, &FlagRect); + FlagRect.VSplitRight(50.0f, nullptr, &FlagRect); + FlagRect.HSplitBottom(25.0f, nullptr, &FlagRect); FlagRect.y -= 10.0f; ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f); m_pClient->m_CountryFlags.Render(m_Dummy ? g_Config.m_ClDummyCountry : g_Config.m_PlayerCountry, Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h); - bool doSkin = g_Config.m_ClApplyProfileSkin; - bool doColors = g_Config.m_ClApplyProfileColors; - bool doEmote = g_Config.m_ClApplyProfileEmote; - bool doName = g_Config.m_ClApplyProfileName; - bool doClan = g_Config.m_ClApplyProfileClan; - bool doFlag = g_Config.m_ClApplyProfileFlag; + bool DoSkin = g_Config.m_ClApplyProfileSkin; + bool DoColors = g_Config.m_ClApplyProfileColors; + bool DoEmote = g_Config.m_ClApplyProfileEmote; + bool DoName = g_Config.m_ClApplyProfileName; + bool DoClan = g_Config.m_ClApplyProfileClan; + bool DoFlag = g_Config.m_ClApplyProfileFlag; //======AFTER LOAD====== - if(SelectedProfile != -1 && SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) + if(s_SelectedProfile != -1 && s_SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) { - CProfile LoadProfile = GameClient()->m_SkinProfiles.m_Profiles[SelectedProfile]; + CProfile LoadProfile = GameClient()->m_SkinProfiles.m_Profiles[s_SelectedProfile]; MainView.HSplitTop(LineSize, nullptr, &MainView); MainView.HSplitTop(10.0f, &Label, &MainView); str_format(aTempBuf, sizeof(aTempBuf), "%s:", Localize("After Load")); @@ -3933,29 +3905,29 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) MainView.HSplitTop(50.0f, &Label, &MainView); Label.VSplitLeft(250.0f, &Label, nullptr); - if(doSkin && strlen(LoadProfile.SkinName) != 0) + if(DoSkin && strlen(LoadProfile.SkinName) != 0) { const CSkin *pLoadSkin = m_pClient->m_Skins.Find(LoadProfile.SkinName); OwnSkinInfo.m_OriginalRenderSkin = pLoadSkin->m_OriginalSkin; OwnSkinInfo.m_ColorableRenderSkin = pLoadSkin->m_ColorableSkin; OwnSkinInfo.m_SkinMetrics = pLoadSkin->m_Metrics; } - if(*pUseCustomColor && doColors && LoadProfile.BodyColor != -1 && LoadProfile.FeetColor != -1) + if(*pUseCustomColor && DoColors && LoadProfile.BodyColor != -1 && LoadProfile.FeetColor != -1) { OwnSkinInfo.m_ColorBody = color_cast(ColorHSLA(LoadProfile.BodyColor).UnclampLighting(ColorHSLA::DARKEST_LGT)); OwnSkinInfo.m_ColorFeet = color_cast(ColorHSLA(LoadProfile.FeetColor).UnclampLighting(ColorHSLA::DARKEST_LGT)); } - RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &OwnSkinInfo, OffsetToMid); + CRenderTools::GetRenderTeeOffsetToRenderedTee(pIdleState, &OwnSkinInfo, OffsetToMid); TeeRenderPos = vec2(Label.x + LineSize, Label.y + Label.h / 2.0f + OffsetToMid.y); int LoadEmote = Emote; - if(doEmote && LoadProfile.Emote != -1) + if(DoEmote && LoadProfile.Emote != -1) LoadEmote = LoadProfile.Emote; - RenderTools()->RenderTee(pIdleState, &OwnSkinInfo, LoadEmote, vec2(1, 0), TeeRenderPos); + RenderTools()->RenderTee(pIdleState, &OwnSkinInfo, LoadEmote, vec2(1.0f, 0.0f), TeeRenderPos); - if(doName && strlen(LoadProfile.Name) != 0) + if(DoName && strlen(LoadProfile.Name) != 0) str_format(aName, sizeof(aName), "%s", LoadProfile.Name); - if(doClan && strlen(LoadProfile.Clan) != 0) + if(DoClan && strlen(LoadProfile.Clan) != 0) str_format(aClan, sizeof(aClan), "%s", LoadProfile.Clan); Label.VSplitLeft(90.0f, &FlagRect, &Label); @@ -3969,14 +3941,14 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) Ui()->DoLabel(&Section, aTempBuf, FontSize, TEXTALIGN_ML); Label.HSplitTop(LineSize, &Section, &Label); - str_format(aTempBuf, sizeof(aTempBuf), Localize("Skin: %s"), (doSkin && strlen(LoadProfile.SkinName) != 0) ? LoadProfile.SkinName : pSkinName); + str_format(aTempBuf, sizeof(aTempBuf), Localize("Skin: %s"), (DoSkin && strlen(LoadProfile.SkinName) != 0) ? LoadProfile.SkinName : pSkinName); Ui()->DoLabel(&Section, aTempBuf, FontSize, TEXTALIGN_ML); - FlagRect.VSplitRight(50.f, nullptr, &FlagRect); - FlagRect.HSplitBottom(25.f, nullptr, &FlagRect); + FlagRect.VSplitRight(50.0f, nullptr, &FlagRect); + FlagRect.HSplitBottom(25.0f, nullptr, &FlagRect); FlagRect.y -= 10.0f; int RenderFlag = m_Dummy ? g_Config.m_ClDummyCountry : g_Config.m_PlayerCountry; - if(doFlag && LoadProfile.CountryFlag != -2) + if(DoFlag && LoadProfile.CountryFlag != -2) RenderFlag = LoadProfile.CountryFlag; m_pClient->m_CountryFlags.Render(RenderFlag, Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h); @@ -4025,43 +3997,43 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) if(DoButton_Menu(&s_LoadButton, Localize("Load"), 0, &Button)) { - if(SelectedProfile != -1 && SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) + if(s_SelectedProfile != -1 && s_SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) { - CProfile LoadProfile = GameClient()->m_SkinProfiles.m_Profiles[SelectedProfile]; + CProfile LoadProfile = GameClient()->m_SkinProfiles.m_Profiles[s_SelectedProfile]; if(!m_Dummy) { - if(doSkin && strlen(LoadProfile.SkinName) != 0) + if(DoSkin && strlen(LoadProfile.SkinName) != 0) str_copy(g_Config.m_ClPlayerSkin, LoadProfile.SkinName, sizeof(g_Config.m_ClPlayerSkin)); - if(doColors && LoadProfile.BodyColor != -1 && LoadProfile.FeetColor != -1) + if(DoColors && LoadProfile.BodyColor != -1 && LoadProfile.FeetColor != -1) { g_Config.m_ClPlayerColorBody = LoadProfile.BodyColor; g_Config.m_ClPlayerColorFeet = LoadProfile.FeetColor; } - if(doEmote && LoadProfile.Emote != -1) + if(DoEmote && LoadProfile.Emote != -1) g_Config.m_ClPlayerDefaultEyes = LoadProfile.Emote; - if(doName && strlen(LoadProfile.Name) != 0) + if(DoName && strlen(LoadProfile.Name) != 0) str_copy(g_Config.m_PlayerName, LoadProfile.Name, sizeof(g_Config.m_PlayerName)); - if(doClan && strlen(LoadProfile.Clan) != 0) + if(DoClan && strlen(LoadProfile.Clan) != 0) str_copy(g_Config.m_PlayerClan, LoadProfile.Clan, sizeof(g_Config.m_PlayerClan)); - if(doFlag && LoadProfile.CountryFlag != -2) + if(DoFlag && LoadProfile.CountryFlag != -2) g_Config.m_PlayerCountry = LoadProfile.CountryFlag; } else { - if(doSkin && strlen(LoadProfile.SkinName) != 0) + if(DoSkin && strlen(LoadProfile.SkinName) != 0) str_copy(g_Config.m_ClDummySkin, LoadProfile.SkinName, sizeof(g_Config.m_ClDummySkin)); - if(doColors && LoadProfile.BodyColor != -1 && LoadProfile.FeetColor != -1) + if(DoColors && LoadProfile.BodyColor != -1 && LoadProfile.FeetColor != -1) { g_Config.m_ClDummyColorBody = LoadProfile.BodyColor; g_Config.m_ClDummyColorFeet = LoadProfile.FeetColor; } - if(doEmote && LoadProfile.Emote != -1) + if(DoEmote && LoadProfile.Emote != -1) g_Config.m_ClDummyDefaultEyes = LoadProfile.Emote; - if(doName && strlen(LoadProfile.Name) != 0) + if(DoName && strlen(LoadProfile.Name) != 0) str_copy(g_Config.m_ClDummyName, LoadProfile.Name, sizeof(g_Config.m_ClDummyName)); - if(doClan && strlen(LoadProfile.Clan) != 0) + if(DoClan && strlen(LoadProfile.Clan) != 0) str_copy(g_Config.m_ClDummyClan, LoadProfile.Clan, sizeof(g_Config.m_ClDummyClan)); - if(doFlag && LoadProfile.CountryFlag != -2) + if(DoFlag && LoadProfile.CountryFlag != -2) g_Config.m_ClDummyCountry = LoadProfile.CountryFlag; } } @@ -4074,13 +4046,13 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) if(DoButton_Menu(&s_SaveButton, Localize("Save"), 0, &Button)) { GameClient()->m_SkinProfiles.AddProfile( - doColors ? *pColorBody : -1, - doColors ? *pColorFeet : -1, - doFlag ? CurrentFlag : -2, - doEmote ? Emote : -1, - doSkin ? pSkinName : "", - doName ? aName : "", - doClan ? aClan : ""); + DoColors ? *pColorBody : -1, + DoColors ? *pColorFeet : -1, + DoFlag ? CurrentFlag : -2, + DoEmote ? Emote : -1, + DoSkin ? pSkinName : "", + DoName ? aName : "", + DoClan ? aClan : ""); GameClient()->m_SkinProfiles.SaveProfiles(); } LabelRight.HSplitTop(5.0f, nullptr, &LabelRight); @@ -4095,9 +4067,9 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) static CButtonContainer s_DeleteButton; if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &Button)) { - if(SelectedProfile != -1 && SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) + if(s_SelectedProfile != -1 && s_SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) { - GameClient()->m_SkinProfiles.m_Profiles.erase(GameClient()->m_SkinProfiles.m_Profiles.begin() + SelectedProfile); + GameClient()->m_SkinProfiles.m_Profiles.erase(GameClient()->m_SkinProfiles.m_Profiles.begin() + s_SelectedProfile); GameClient()->m_SkinProfiles.SaveProfiles(); } } @@ -4107,16 +4079,16 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) static CButtonContainer s_OverrideButton; if(DoButton_Menu(&s_OverrideButton, Localize("Override"), 0, &Button)) { - if(SelectedProfile != -1 && SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) + if(s_SelectedProfile != -1 && s_SelectedProfile < (int)GameClient()->m_SkinProfiles.m_Profiles.size()) { - GameClient()->m_SkinProfiles.m_Profiles[SelectedProfile] = CProfile( - doColors ? *pColorBody : -1, - doColors ? *pColorFeet : -1, - doFlag ? CurrentFlag : -2, - doEmote ? Emote : -1, - doSkin ? pSkinName : "", - doName ? aName : "", - doClan ? aClan : ""); + GameClient()->m_SkinProfiles.m_Profiles[s_SelectedProfile] = CProfile( + DoColors ? *pColorBody : -1, + DoColors ? *pColorFeet : -1, + DoFlag ? CurrentFlag : -2, + DoEmote ? Emote : -1, + DoSkin ? pSkinName : "", + DoName ? aName : "", + DoClan ? aClan : ""); GameClient()->m_SkinProfiles.SaveProfiles(); } } @@ -4131,7 +4103,7 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) std::vector *pProfileList = &GameClient()->m_SkinProfiles.m_Profiles; static CListBox s_ListBox; - s_ListBox.DoStart(50.0f, pProfileList->size(), 4, 3, SelectedProfile, &SelectorRect, true); + s_ListBox.DoStart(50.0f, pProfileList->size(), 4, 3, s_SelectedProfile, &SelectorRect, true); static bool s_Indexs[1024]; @@ -4147,7 +4119,7 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) const CSkin *pSkinToBeDraw = m_pClient->m_Skins.Find(RenderSkin); - CListboxItem Item = s_ListBox.DoNextItem(&s_Indexs[i], SelectedProfile >= 0 && (size_t)SelectedProfile == i); + CListboxItem Item = s_ListBox.DoNextItem(&s_Indexs[i], s_SelectedProfile >= 0 && (size_t)s_SelectedProfile == i); if(!Item.m_Visible) continue; @@ -4157,7 +4129,7 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) CTeeRenderInfo Info; Info.m_ColorBody = color_cast(ColorHSLA(CurrentProfile.BodyColor).UnclampLighting(ColorHSLA::DARKEST_LGT)); Info.m_ColorFeet = color_cast(ColorHSLA(CurrentProfile.FeetColor).UnclampLighting(ColorHSLA::DARKEST_LGT)); - Info.m_CustomColoredSkin = 1; + Info.m_CustomColoredSkin = true; Info.m_OriginalRenderSkin = pSkinToBeDraw->m_OriginalSkin; Info.m_ColorableRenderSkin = pSkinToBeDraw->m_ColorableSkin; Info.m_SkinMetrics = pSkinToBeDraw->m_Metrics; @@ -4169,7 +4141,7 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) Info.m_ColorFeet = ColorRGBA(1.0f, 1.0f, 1.0f); } - RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &Info, OffsetToMid); + CRenderTools::GetRenderTeeOffsetToRenderedTee(pIdleState, &Info, OffsetToMid); int RenderEmote = CurrentProfile.Emote == -1 ? Emote : CurrentProfile.Emote; TeeRenderPos = vec2(Item.m_Rect.x + 30.0f, Item.m_Rect.y + Item.m_Rect.h / 2.0f + OffsetToMid.y); @@ -4177,7 +4149,7 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) Item.m_Rect.VSplitLeft(60.0f, nullptr, &Item.m_Rect); CUIRect PlayerRect, ClanRect, FeetColorSquare, BodyColorSquare; - Item.m_Rect.VSplitLeft(60.0f, nullptr, &BodyColorSquare); //Delete this maybe + Item.m_Rect.VSplitLeft(60.0f, nullptr, &BodyColorSquare); // Delete this maybe Item.m_Rect.VSplitRight(60.0f, &BodyColorSquare, &FlagRect); BodyColorSquare.x -= 11.0f; @@ -4230,9 +4202,9 @@ void CMenus::RenderSettingsProfiles(CUIRect MainView) } const int NewSelected = s_ListBox.DoEnd(); - if(SelectedProfile != NewSelected) + if(s_SelectedProfile != NewSelected) { - SelectedProfile = NewSelected; + s_SelectedProfile = NewSelected; } static CButtonContainer s_ProfilesFile; FileButton.VSplitLeft(130.0f, &FileButton, nullptr); diff --git a/src/game/client/components/rainbow.cpp b/src/game/client/components/rainbow.cpp index 0eab6466a72..e231ee288b0 100644 --- a/src/game/client/components/rainbow.cpp +++ b/src/game/client/components/rainbow.cpp @@ -8,56 +8,69 @@ #include -#include - -#include "base/color.h" -#include "engine/shared/protocol.h" #include "rainbow.h" -void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pInfo) +void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pinfo) { if(!Mode) return; - int Deftick = Tick % 255; + int DefTick = Tick % 255; + + const ColorHSLA PlayerColBody = ColorHSLA(g_Config.m_ClPlayerColorBody); + const ColorHSLA PlayerColFeet = ColorHSLA(g_Config.m_ClPlayerColorFeet); + + pinfo->m_CustomColoredSkin = true; if(Mode == COLORMODE_RAINBOW) { - const ColorRGBA Col = color_cast(ColorHSLA((float)Deftick / 255.0f, 1.0f, 0.5f)); - pInfo->m_CustomColoredSkin = true; - pInfo->m_ColorBody = Col; - pInfo->m_ColorFeet = Col; - pInfo->m_BloodColor = Col; - return; + const ColorRGBA Col = color_cast(ColorHSLA((float)DefTick / 255.0f, 1.0f, 0.5f)); + pinfo->m_ColorBody = Col; + pinfo->m_ColorFeet = Col; + pinfo->m_BloodColor = Col; } else if(Mode == COLORMODE_PULSE) { - float Light = 0.5f + (std::sin(((float)Deftick / 255.0f) * 2.0f * pi) + 1.0f) / 4.0f; - pInfo->m_CustomColoredSkin = true; - ColorHSLA Body = color_cast(pInfo->m_ColorBody); - Body.l = Light; - pInfo->m_ColorBody = color_cast(Body); - pInfo->m_BloodColor = pInfo->m_ColorBody; - ColorHSLA Feet = color_cast(pInfo->m_ColorFeet); - Feet.l = Light; - pInfo->m_ColorFeet = color_cast(Feet); - return; + pinfo->m_ColorBody.s = 1.0f; + pinfo->m_ColorFeet.s = 1.0f; + pinfo->m_BloodColor.s = 1.0f; + pinfo->m_ColorBody.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f); + pinfo->m_ColorFeet.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f); + pinfo->m_BloodColor.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f); + pinfo->m_ColorBody.h = (float)DefTick / 255.0f; + pinfo->m_ColorFeet.h = (float)DefTick / 255.0f; + pinfo->m_BloodColor.h = (float)DefTick / 255.0f; } else if(Mode == COLORMODE_DARKNESS) { - pInfo->m_CustomColoredSkin = true; - pInfo->m_ColorBody = ColorRGBA(0.0f, 0.0f, 0.0f); - pInfo->m_ColorFeet = ColorRGBA(0.0f, 0.0f, 0.0f); - pInfo->m_BloodColor = ColorRGBA(0.0f, 0.0f, 0.0f); - return; + pinfo->m_ColorBody = ColorRGBA(0.0f, 0.0f, 0.0f); + pinfo->m_ColorFeet = ColorRGBA(0.0f, 0.0f, 0.0f); + pinfo->m_BloodColor = ColorRGBA(0.0f, 0.0f, 0.0f); + } + else + { + pinfo->m_CustomColoredSkin = true; + pinfo->m_ColorBody = color_cast(PlayerColBody); + pinfo->m_ColorFeet = color_cast(PlayerColFeet); + // pinfo->m_BloodColor = pinfo->m_BloodColor; // TODO reset blood color } } void CRainbow::OnRender() { - if(g_Config.m_ClRainbowOthers) - for(int i = 0; i < MAX_CLIENTS; ++i) - if(i != m_pClient->m_Snap.m_LocalClientId) - TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, &m_pClient->m_aClients[i].m_RenderInfo); - if(g_Config.m_ClRainbow) - TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, &m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientId].m_RenderInfo); + for(int i = 0; i < MAX_CLIENTS; i++) + { + // check if local player + bool Local = m_pClient->m_Snap.m_LocalClientId == i; + + CTeeRenderInfo *RenderInfo = &m_pClient->m_aClients[i].m_RenderInfo; + // check if rainbow is enabled + if(g_Config.m_ClRainbow && Local) // rainbow is enabled and is own player + { + TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo); + } + else if(g_Config.m_ClRainbowOthers && !Local) // rainbow is enabled and is not own player + { + TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo); + } + } } diff --git a/src/game/client/components/rainbow.h b/src/game/client/components/rainbow.h index 0353aa86a9c..f2c4958c1a3 100644 --- a/src/game/client/components/rainbow.h +++ b/src/game/client/components/rainbow.h @@ -1,16 +1,15 @@ #ifndef GAME_CLIENT_COMPONENTS_RAINBOW_H #define GAME_CLIENT_COMPONENTS_RAINBOW_H -#include "game/client/render.h" #include class CRainbow : public CComponent { public: - int Sizeof() const override { return sizeof(*this); } - void OnRender() override; + virtual int Sizeof() const override { return sizeof(*this); } + virtual void OnRender() override; - void TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pInfo); + void TransformColor(unsigned char mode, int tick, CTeeRenderInfo *pinfo); enum COLORMODE { COLORMODE_RAINBOW = 1,