Compare commits

...

7 commits

Author SHA1 Message Date
archimede67 47d77fad07
Merge pull request #8120 from Robyt3/UI-Color-Picker-Line-Improvement
Support clicking line color picker label to toggle checkbox
2024-03-17 10:56:31 +00:00
Robert Müller d7f3c4fb6d
Merge pull request #8118 from dobrykafe/pr-nameplates-strong
`ClNameplatesStrong` improvements
2024-03-17 10:43:24 +00:00
Robert Müller 67329acae9 Support clicking line color picker label to toggle checkbox
Closes #8117.
2024-03-17 11:37:40 +01:00
archimede67 d853a17f20
Merge pull request #8119 from Robyt3/UI-String-Fix
Fix replacement of `UI` with `Ui` in strings
2024-03-17 10:33:28 +00:00
Robert Müller bef399f296 Fix replacement of UI with Ui in strings 2024-03-17 11:16:14 +01:00
dobrykafe 19ea53998f show nameplates strong indicator from perspective of spectated player 2024-03-17 11:13:44 +01:00
dobrykafe 7f4974616a fix nameplates strong indicator 2024-03-17 11:11:51 +01:00
4 changed files with 29 additions and 27 deletions

View file

@ -380,27 +380,27 @@ ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetId, const float Lin
pMainRect->HSplitTop(LineSize, &Section, pMainRect); pMainRect->HSplitTop(LineSize, &Section, pMainRect);
pMainRect->HSplitTop(BottomMargin, nullptr, pMainRect); pMainRect->HSplitTop(BottomMargin, nullptr, pMainRect);
if(CheckBoxSpacing || pCheckBoxValue != nullptr)
{
CUIRect CheckBox;
Section.VSplitLeft(Section.h, &CheckBox, &Section);
if(pCheckBoxValue != nullptr)
{
CheckBox.Margin(2.0f, &CheckBox);
if(DoButton_CheckBox(pCheckBoxValue, "", *pCheckBoxValue, &CheckBox))
*pCheckBoxValue ^= 1;
}
Section.VSplitLeft(5.0f, nullptr, &Section);
}
Section.VSplitRight(88.0f, &Label, &Section);
Section.VSplitRight(60.0f, &Section, &ResetButton); Section.VSplitRight(60.0f, &Section, &ResetButton);
Section.VSplitRight(8.0f, &Section, nullptr); Section.VSplitRight(8.0f, &Section, nullptr);
Section.VSplitRight(Section.h, &Section, &ColorPickerButton); Section.VSplitRight(Section.h, &Section, &ColorPickerButton);
Section.VSplitRight(8.0f, &Label, nullptr);
Ui()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_ML); if(pCheckBoxValue != nullptr)
{
Label.Margin(2.0f, &Label);
if(DoButton_CheckBox(pCheckBoxValue, pText, *pCheckBoxValue, &Label))
*pCheckBoxValue ^= 1;
}
else if(CheckBoxSpacing)
{
Label.VSplitLeft(Label.h + 5.0f, nullptr, &Label);
}
if(pCheckBoxValue == nullptr)
{
Ui()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_ML);
}
ColorHSLA PickedColor = DoButton_ColorPicker(&ColorPickerButton, pColorValue, Alpha); const ColorHSLA PickedColor = DoButton_ColorPicker(&ColorPickerButton, pColorValue, Alpha);
ResetButton.HMargin(2.0f, &ResetButton); ResetButton.HMargin(2.0f, &ResetButton);
if(DoButton_Menu(pResetId, Localize("Reset"), 0, &ResetButton, nullptr, IGraphics::CORNER_ALL, 4.0f, 0.1f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f))) if(DoButton_Menu(pResetId, Localize("Reset"), 0, &ResetButton, nullptr, IGraphics::CORNER_ALL, 4.0f, 0.1f, ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f)))

View file

@ -1164,7 +1164,7 @@ float CMenus::RenderSettingsControlsJoystick(CUIRect View)
View.HSplitTop(Spacing, nullptr, &View); View.HSplitTop(Spacing, nullptr, &View);
View.HSplitTop(ButtonHeight, &Button, &View); View.HSplitTop(ButtonHeight, &Button, &View);
Ui()->DoScrollbarOption(&g_Config.m_UiControllerSens, &g_Config.m_UiControllerSens, &Button, Localize("Ui controller sens."), 1, 500, &CUi::ms_LogarithmicScrollbarScale, CUi::SCROLLBAR_OPTION_NOCLAMPVALUE); Ui()->DoScrollbarOption(&g_Config.m_UiControllerSens, &g_Config.m_UiControllerSens, &Button, Localize("UI controller sens."), 1, 500, &CUi::ms_LogarithmicScrollbarScale, CUi::SCROLLBAR_OPTION_NOCLAMPVALUE);
View.HSplitTop(Spacing, nullptr, &View); View.HSplitTop(Spacing, nullptr, &View);
View.HSplitTop(ButtonHeight, &Button, &View); View.HSplitTop(ButtonHeight, &Button, &View);
@ -1331,7 +1331,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
MouseSettings.HSplitTop(2.0f, nullptr, &MouseSettings); MouseSettings.HSplitTop(2.0f, nullptr, &MouseSettings);
MouseSettings.HSplitTop(20.0f, &Button, &MouseSettings); MouseSettings.HSplitTop(20.0f, &Button, &MouseSettings);
Ui()->DoScrollbarOption(&g_Config.m_UiMousesens, &g_Config.m_UiMousesens, &Button, Localize("Ui mouse sens."), 1, 500, &CUi::ms_LogarithmicScrollbarScale, CUi::SCROLLBAR_OPTION_NOCLAMPVALUE); Ui()->DoScrollbarOption(&g_Config.m_UiMousesens, &g_Config.m_UiMousesens, &Button, Localize("UI mouse sens."), 1, 500, &CUi::ms_LogarithmicScrollbarScale, CUi::SCROLLBAR_OPTION_NOCLAMPVALUE);
} }
} }
@ -1689,7 +1689,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
MainView.HSplitTop(2.0f, nullptr, &MainView); MainView.HSplitTop(2.0f, nullptr, &MainView);
static CButtonContainer s_UiColorResetId; static CButtonContainer s_UiColorResetId;
DoLine_ColorPicker(&s_UiColorResetId, 25.0f, 13.0f, 2.0f, &MainView, Localize("Ui Color"), &g_Config.m_UiColor, color_cast<ColorRGBA>(ColorHSLA(0xE4A046AFU, true)), false, nullptr, true); DoLine_ColorPicker(&s_UiColorResetId, 25.0f, 13.0f, 2.0f, &MainView, Localize("UI Color"), &g_Config.m_UiColor, color_cast<ColorRGBA>(ColorHSLA(0xE4A046AFU, true)), false, nullptr, true);
// Backend list // Backend list
struct SMenuBackendInfo struct SMenuBackendInfo

View file

@ -220,13 +220,15 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
if((g_Config.m_Debug || g_Config.m_ClNameplatesStrong) && g_Config.m_ClNameplates) if((g_Config.m_Debug || g_Config.m_ClNameplatesStrong) && g_Config.m_ClNameplates)
{ {
if(m_pClient->m_Snap.m_LocalClientId != -1 && m_pClient->m_Snap.m_aCharacters[pPlayerInfo->m_ClientId].m_HasExtendedData && m_pClient->m_Snap.m_aCharacters[m_pClient->m_Snap.m_LocalClientId].m_HasExtendedData) bool Following = (m_pClient->m_Snap.m_SpecInfo.m_Active && !GameClient()->m_MultiViewActivated && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != SPEC_FREEVIEW);
if(m_pClient->m_Snap.m_LocalClientId != -1 || Following)
{ {
CCharacter *pLocalChar = m_pClient->m_GameWorld.GetCharacterById(m_pClient->m_Snap.m_LocalClientId); int SelectedId = Following ? m_pClient->m_Snap.m_SpecInfo.m_SpectatorId : m_pClient->m_Snap.m_LocalClientId;
CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterById(pPlayerInfo->m_ClientId); const CGameClient::CSnapState::CCharacterInfo &Selected = m_pClient->m_Snap.m_aCharacters[SelectedId];
if(pCharacter && pLocalChar) const CGameClient::CSnapState::CCharacterInfo &Other = m_pClient->m_Snap.m_aCharacters[ClientId];
if(Selected.m_HasExtendedData && Other.m_HasExtendedData)
{ {
if(pPlayerInfo->m_Local) if(SelectedId == ClientId)
TextRender()->TextColor(rgb); TextRender()->TextColor(rgb);
else else
{ {
@ -237,7 +239,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
Graphics()->QuadsBegin(); Graphics()->QuadsBegin();
ColorRGBA StrongWeakStatusColor; ColorRGBA StrongWeakStatusColor;
int StrongWeakSpriteId; int StrongWeakSpriteId;
if(pLocalChar->GetStrongWeakId() > pCharacter->GetStrongWeakId()) if(Selected.m_ExtendedData.m_StrongWeakId > Other.m_ExtendedData.m_StrongWeakId)
{ {
StrongWeakStatusColor = color_cast<ColorRGBA>(ColorHSLA(6401973)); StrongWeakStatusColor = color_cast<ColorRGBA>(ColorHSLA(6401973));
StrongWeakSpriteId = SPRITE_HOOK_STRONG; StrongWeakSpriteId = SPRITE_HOOK_STRONG;
@ -271,7 +273,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
{ {
YOffset -= FontSize; YOffset -= FontSize;
char aBuf[12]; char aBuf[12];
str_from_int(pCharacter->GetStrongWeakId(), aBuf); str_from_int(Other.m_ExtendedData.m_StrongWeakId, aBuf);
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f; float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f); TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
} }

View file

@ -28,7 +28,7 @@ void CUIElement::Init(CUi *pUI, int RequestedRectCount)
void CUIElement::InitRects(int RequestedRectCount) void CUIElement::InitRects(int RequestedRectCount)
{ {
dbg_assert(m_vUIRects.empty(), "Ui rects can only be initialized once, create another ui element instead."); dbg_assert(m_vUIRects.empty(), "UI rects can only be initialized once, create another ui element instead.");
m_vUIRects.resize(RequestedRectCount); m_vUIRects.resize(RequestedRectCount);
for(auto &Rect : m_vUIRects) for(auto &Rect : m_vUIRects)
Rect.m_pParent = this; Rect.m_pParent = this;