diff --git a/UTGame/Src/SpectatorUI/Classes/SpectatorUI_ClientSettings.uc b/UTGame/Src/SpectatorUI/Classes/SpectatorUI_ClientSettings.uc index b7c123f..4100d23 100644 --- a/UTGame/Src/SpectatorUI/Classes/SpectatorUI_ClientSettings.uc +++ b/UTGame/Src/SpectatorUI/Classes/SpectatorUI_ClientSettings.uc @@ -26,6 +26,7 @@ var config name SwitchViewToButton; var config float PlayerSwitchDelay; var config float PostPlayerSwitchDelay; +var config float PlayerlistRenderMode; var config string PickupNotificationPattern; var config string RedFlagNotificationPattern, BlueFlagNotificationPattern; @@ -58,4 +59,5 @@ defaultproperties PlayerSwitchDelay=0.5 PostPlayerSwitchDelay=2.0 + PlayerlistRenderMode=0 } diff --git a/UTGame/Src/SpectatorUI/Classes/SpectatorUI_Interaction.uc b/UTGame/Src/SpectatorUI/Classes/SpectatorUI_Interaction.uc index f5fd0f6..af2196f 100644 --- a/UTGame/Src/SpectatorUI/Classes/SpectatorUI_Interaction.uc +++ b/UTGame/Src/SpectatorUI/Classes/SpectatorUI_Interaction.uc @@ -561,47 +561,121 @@ function float GetLongestPlayerListEntry(Canvas C) } return Res; } - -function RenderPlayerList(Canvas C) + +function RenderPlayerList(Canvas C) +{ + local UTHUD HUD; + local int Count, MaxCount, MaxElements; + local bool bTruncated; + local float TopY, XL, YL; + local vector2d POS; + local float OldClipX; + HUD = UTHUD(myHUD); + if (HUD == None) return; + + C.Reset(); + HUD.Canvas = C; // XXX Canvas was cleared somehow. Set it back + C.Font = HUD.GetFontSizeIndex(1); + + C.StrLen(SelectedPrefix, XL, YL); + + // XXX why clock? to be honest, I forgot + POS = HUD.ResolveHudPosition(HUD.ClockPosition, 0, 0); + POS.x += 28 * HUD.ResolutionScale; // XXX magic constant = bad + + C.SetOrigin(0.0, C.ClipY / 6); + OldClipX = C.ClipX; + C.ClipX = GetLongestPlayerListEntry(C) + 2 * POS.x; + + // calculate lines count for pagination + TopY = C.ClipY * 0.85 - 2*YL; // Spectator bar // XXX magic constant = bad + TopY -= 20 * HUD.ResolutionScale; // XXX magic constant = bad + MaxElements = Min(PRIs.Length, Max(2, (TopY - C.OrgY) / YL)); + bTruncated = MaxElements != PRIs.Length; + if (bTruncated) { + MaxElements -= 2; + TopY = YL; + } else { + TopY = 0; + } + + // draw background + C.SetPos(0.0, 0.0); + C.SetDrawColor(0, 0, 0, 150); + C.DrawRect(C.ClipX, YL * MaxElements + (bTruncated ? 2*YL : 0.0)); + + if (Settings.PlayerlistRenderMode == 1) { + Count = Max(0, SelectedPRIIndex - MaxElements + 1); + RenderPlayerListPart(C, HUD, 0+Count, MaxElements, false, Pos.X, TopY, XL, YL); + + if (bTruncated) { + if (Count > 0) RenderPlayerListPager(C, HUD, Count, 0, YL, false); + + Count = PRIs.Length - MaxElements - Count; + if (Count > 0) RenderPlayerListPager(C, HUD, Count, MaxElements+1, YL, true); + } + } else { + MaxCount = MaxElements / 2; + RenderPlayerListPart(C, HUD, SelectedPRIIndex-MaxCount, MaxCount, false, Pos.X, TopY, XL, YL); + RenderPlayerListPart(C, HUD, SelectedPRIIndex, MaxCount+(MaxElements % 2), false, Pos.X, TopY+MaxCount*YL, XL, YL); + + if (bTruncated) { + Count = (SelectedPRIIndex-MaxCount) mod PRIs.Length; + if (Count > 0) RenderPlayerListPager(C, HUD, Count, 0, YL, false); + + Count = (SelectedPRIIndex+MaxCount+(MaxElements % 2)) mod PRIs.Length; + Count = PRIs.Length - Count; + if (Count < PRIs.Length) RenderPlayerListPager(C, HUD, Count, MaxElements+1, YL, true); + } + } + C.ClipX = OldClipX; +} + +function RenderPlayerListPager(Canvas C, UTHUD HUD, int Value, int Count, float LineHeight, bool bUp) +{ + local float TempXL, TempYL; + local string s, ls, rs; + + ls = bUp ? "`L" : "`R"; + rs = Repl("`L`R", ls, ""); + + s = "--- `L `x more `R ---"; + C.Font = HUD.GetFontSizeIndex(0); + C.StrLen(S, TempXL, TempYL); + TempXL = (C.ClipX-TempXL)*0.5; + TempYL = (LineHeight - TempYL)*0.5; + + C.SetDrawColor(255,255,255,255); + C.SetPos(TempXL, Count*LineHeight + TempYL); + C.DrawTextClipped(Repl(Repl(Repl(s, "`x", Value), ls, "\\"), rs, "/")); +} + +function RenderPlayerListPart(Canvas C, UTHUD HUD, int StartIndex, int Count, bool Reverse, float PaddingX, float PaddingY, float XL, float YL) { - local UTHUD HUD; + local int i, Index; + local float SlotY; local PlayerReplicationInfo PRI; - local int Index; local LinearColor LC; - local float XL, YL; - local vector2d POS; - local float OldClipX; - HUD = UTHUD(myHUD); - if (HUD == None) return; - - C.Reset(); - C.Font = HUD.GetFontSizeIndex(1); - C.StrLen(SelectedPrefix, XL, YL); - - // XXX why clock? to be honest, I forgot - POS = HUD.ResolveHudPosition(HUD.ClockPosition, 0, 0); - POS.x += 28 * HUD.ResolutionScale; // XXX magic constant = bad - - C.SetOrigin(0.0, C.ClipY / 6); - OldClipX = C.ClipX; - C.ClipX = GetLongestPlayerListEntry(C) + 2 * POS.x; - - C.SetPos(0.0, 0.0); - C.SetDrawColor(0, 0, 0, 150); - C.DrawRect(C.ClipX, YL * PRIs.Length); - - foreach PRIs(PRI, Index) { + for (Index=StartIndex; i