Skip to content

Commit

Permalink
More updates PNK 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvdjagt committed Nov 15, 2023
1 parent 65be1bd commit d432536
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 101 deletions.
2 changes: 1 addition & 1 deletion osu.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace osu.Desktop
public static class Program
{
#if DEBUG
private const string base_game_name = @"osu-development";
private const string base_game_name = @"osu";
#else
private const string base_game_name = @"osu";
#endif
Expand Down
6 changes: 4 additions & 2 deletions osu.Game.Tournament/Components/DrawableTeamFlag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ namespace osu.Game.Tournament.Components
public partial class DrawableTeamFlag : Container
{
private readonly TournamentTeam? team;
private readonly Vector2? size;

[UsedImplicitly]
private Bindable<string>? flag;

private Sprite? flagSprite;

public DrawableTeamFlag(TournamentTeam? team)
public DrawableTeamFlag(TournamentTeam? team, Vector2? size = null)
{
this.team = team;
this.size = size;
}

[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
if (team == null) return;

Size = new Vector2(75, 54);
Size = size ?? new Vector2(75, 54);
Masking = true;
CornerRadius = 5;
Child = flagSprite = new Sprite
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tournament/Components/DrawableTeamHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace osu.Game.Tournament.Components
{
public partial class DrawableTeamHeader : TournamentSpriteTextWithBackground
{
public DrawableTeamHeader(TeamColour colour)
public DrawableTeamHeader(TeamColour colour, string? name = null)
{
Background.Colour = TournamentGame.GetTeamColour(colour);

Text.Colour = TournamentGame.TEXT_COLOUR;
Text.Text = $"Team {colour}".ToUpperInvariant();
Text.Text = $"{name ?? colour.ToString()}".ToUpperInvariant();
Text.Scale = new Vector2(0.6f);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public DrawableTeamTitleWithHeader(TournamentTeam? team, TeamColour colour)
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new DrawableTeamHeader(colour),
new DrawableTeamTitle(team),
new DrawableTeamHeader(colour, team?.FullName.Value),
new DrawableTeamSeed(team),
}
};
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Components/DrawableTeamWithPlayers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public DrawableTeamWithPlayers(TournamentTeam? team, TeamColour colour)
},
};

TournamentSpriteText createPlayerText(TournamentUser p) =>
static TournamentSpriteText createPlayerText(TournamentUser p) =>
new TournamentSpriteText
{
Text = p.Username,
Expand Down
23 changes: 7 additions & 16 deletions osu.Game.Tournament/Components/SongBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,9 @@ private void refreshContent()

double bpm = beatmap.BPM;
double length = beatmap.Length;
string hardRockExtra = "";
string srExtra = "";

float ar = beatmap.Difficulty.ApproachRate;

if ((mods & LegacyMods.HardRock) > 0)
{
hardRockExtra = "*";
srExtra = "*";
}

if ((mods & LegacyMods.DoubleTime) > 0)
{
// temporary local calculation (taken from OsuDifficultyCalculator)
Expand All @@ -128,7 +120,6 @@ private void refreshContent()

bpm *= 1.5f;
length /= 1.5f;
srExtra = "*";
}

(string heading, string content)[] stats;
Expand All @@ -138,25 +129,25 @@ private void refreshContent()
default:
stats = new (string heading, string content)[]
{
("CS", $"{beatmap.Difficulty.CircleSize:0.#}{hardRockExtra}"),
("AR", $"{ar:0.#}{hardRockExtra}"),
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}{hardRockExtra}"),
("CS", $"{beatmap.Difficulty.CircleSize:0.#}"),
("AR", $"{ar:0.#}"),
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}"),
};
break;

case 1:
case 3:
stats = new (string heading, string content)[]
{
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}{hardRockExtra}"),
("HP", $"{beatmap.Difficulty.DrainRate:0.#}{hardRockExtra}")
("OD", $"{beatmap.Difficulty.OverallDifficulty:0.#}"),
("HP", $"{beatmap.Difficulty.DrainRate:0.#}")
};
break;

case 2:
stats = new (string heading, string content)[]
{
("CS", $"{beatmap.Difficulty.CircleSize:0.#}{hardRockExtra}"),
("CS", $"{beatmap.Difficulty.CircleSize:0.#}"),
("AR", $"{ar:0.#}"),
};
break;
Expand Down Expand Up @@ -192,7 +183,7 @@ private void refreshContent()
Children = new Drawable[]
{
new DiffPiece(stats),
new DiffPiece(("Star Rating", $"{beatmap.StarRating:0.00}{srExtra}"))
new DiffPiece(("SR", $"{beatmap.StarRating:0.00}"))
}
},
new FillFlowContainer
Expand Down
37 changes: 37 additions & 0 deletions osu.Game.Tournament/Models/TournamentMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Net.Http;
using Newtonsoft.Json;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Game.Tournament.Screens.Ladder.Components;

namespace osu.Game.Tournament.Models
Expand All @@ -17,7 +19,16 @@ namespace osu.Game.Tournament.Models
[Serializable]
public class TournamentMatch
{
public class MatchPickems
{
public float Player1 { get; set; }
public float Player2 { get; set; }
}

private static readonly HttpClient client = new HttpClient();

public int ID;
public int DatabaseId;

public List<string> Acronyms
{
Expand Down Expand Up @@ -126,5 +137,31 @@ public void Reset()
Completed.Value = false;
PicksBans.Clear();
}

public async void RetrievePickemsResults()
{
if (DatabaseId == 0) return;
string url = @"https://tourney-api.huismetbenen.nl/pickems/get-by-match/" + DatabaseId;

var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
requestMessage.Headers.Add("ContentType", "application/json");
requestMessage.Headers.Add("x-tourney-id", "9");
var response = await client.SendAsync(requestMessage).ConfigureAwait(false);
var result = response.Content.ReadAsStringAsync();

if (result != null && Team1.Value != null && Team2.Value != null)
{
string safeResult = result.GetResultSafely();
if (safeResult != null)
{
MatchPickems? pickems = JsonConvert.DeserializeObject<MatchPickems>(safeResult);
Team1.Value.PickemsRate.Value = pickems?.Player1 ?? 0;
Team2.Value.PickemsRate.Value = pickems?.Player2 ?? 0;

Team1.Value.PickemsRate.TriggerChange();
Team2.Value.PickemsRate.TriggerChange();
}
}
}
}
}
2 changes: 2 additions & 0 deletions osu.Game.Tournament/Models/TournamentTeam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class TournamentTeam

public Bindable<double> QualifiersCarryFactor = new Bindable<double>(0);

public Bindable<float> PickemsRate = new Bindable<float>(-1);

[JsonProperty]
public BindableList<TournamentUser> Players { get; } = new BindableList<TournamentUser>();

Expand Down
35 changes: 21 additions & 14 deletions osu.Game.Tournament/Screens/Gameplay/Components/TeamDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
using osuTK;
using System;

namespace osu.Game.Tournament.Screens.Gameplay.Components
{
public partial class TeamDisplay : DrawableTournamentTeam
{
private readonly TeamScore score;
private TournamentSpriteTextWithBackground? pickemsSprite;

private readonly TournamentSpriteTextWithBackground teamNameText;

Expand All @@ -35,7 +37,7 @@ public bool ShowScore
}
}

public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin)
public TeamDisplay(TournamentTeam? team, TournamentMatch? match, TeamColour colour, Bindable<int?> currentTeamScore, int pointsToWin)
: base(team)
{
AutoSizeAxes = Axes.Both;
Expand All @@ -50,6 +52,22 @@ public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> curre
Flag.Anchor = anchor;

Margin = new MarginPadding(20);
teamNameText = new TournamentSpriteTextWithBackground("");

pickemsSprite = new TournamentSpriteTextWithBackground("")
{
Scale = new Vector2(0.3f),
Origin = anchor,
Anchor = anchor
};

if (team != null)
{
team.PickemsRate.ValueChanged += val =>
{
pickemsSprite.Text.Text = val.NewValue >= 0 ? $"Pickem rate: {Math.Round(val.NewValue, 2)}%" : "";
};
}

InternalChild = new Container
{
Expand Down Expand Up @@ -82,7 +100,7 @@ public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> curre
Anchor = anchor,
Children = new Drawable[]
{
new DrawableTeamHeader(colour)
new DrawableTeamHeader(colour, team?.FullName?.Value)
{
Scale = new Vector2(0.75f),
Origin = anchor,
Expand All @@ -95,18 +113,7 @@ public TeamDisplay(TournamentTeam? team, TeamColour colour, Bindable<int?> curre
}
}
},
teamNameText = new TournamentSpriteTextWithBackground
{
Scale = new Vector2(0.5f),
Origin = anchor,
Anchor = anchor,
},
new DrawableTeamSeed(Team)
{
Scale = new Vector2(0.5f),
Origin = anchor,
Anchor = anchor,
},
pickemsSprite
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void teamChanged(ValueChangedEvent<TournamentTeam?> team)

InternalChildren = new Drawable[]
{
teamDisplay = new TeamDisplay(team.NewValue, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0),
teamDisplay = new TeamDisplay(team.NewValue, currentMatch.Value, teamColour, currentTeamScore, currentMatch.Value?.PointsToWin ?? 0),
};

teamDisplay.ShowScore = wasShowingScores;
Expand Down
7 changes: 7 additions & 0 deletions osu.Game.Tournament/Screens/Gameplay/GameplayScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ private void load(MatchIPCInfo ipc)
Text = "Toggle chat",
Action = () => { State.Value = State.Value == TourneyState.Idle ? TourneyState.Playing : TourneyState.Idle; }
},
new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Refresh pickems",
Action = () => { CurrentMatch.Value?.RetrievePickemsResults(); }
},
new SettingsSlider<int>
{
LabelText = "Chroma width",
Expand Down Expand Up @@ -148,6 +154,7 @@ protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?>
return;

warmup.Value = match.NewValue.Team1Score.Value + match.NewValue.Team2Score.Value == 0;
match.NewValue.RetrievePickemsResults();
scheduledScreenChange?.Cancel();
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/MapPool/MapPoolScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private void updateDisplay()
flowCount = 0;
}

if (++flowCount > 2)
if (++flowCount > 3)
{
totalRows++;
flowCount = 1;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/Schedule/ScheduleScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public ScheduleMatch(TournamentMatch match, bool showTimestamp = true)
Colour = OsuColour.Gray(0.7f),
Alpha = conditional ? 0.6f : 1,
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
Text = match.Date.Value.ToUniversalTime().ToString("HH:mm UTC") + (conditional ? " (conditional)" : "")
Text = match.Date.Value.ToLocalTime().ToString("HH:mm UTC") + (conditional ? " (conditional)" : "")
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tournament/Screens/TeamIntro/TeamIntroScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch?>
{
Position = new Vector2(100, 100)
},
new DrawableTeamFlag(match.NewValue.Team1.Value)
new DrawableTeamFlag(match.NewValue.Team1.Value, new Vector2(150, 108))
{
Position = new Vector2(165, y_flag_offset),
},
new DrawableTeamWithPlayers(match.NewValue.Team1.Value, TeamColour.Red)
{
Position = new Vector2(165, y_offset),
},
new DrawableTeamFlag(match.NewValue.Team2.Value)
new DrawableTeamFlag(match.NewValue.Team2.Value, new Vector2(150, 108))
{
Position = new Vector2(740, y_flag_offset),
},
Expand Down
10 changes: 0 additions & 10 deletions osu.Game/Graphics/Cursor/MenuCursorContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public bool HideCursorOnNonMouseInput
private Vector2 lastMovePosition;

private Bindable<bool> cursorRotate = null!;
private Sample tapSample = null!;

private MouseInputDetector mouseInputDetector = null!;

Expand All @@ -61,8 +60,6 @@ private void load(OsuConfigManager config, ScreenshotManager? screenshotManager,
if (screenshotManager != null)
screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility);

tapSample = audio.Samples.Get(@"UI/cursor-tap");

Add(mouseInputDetector = new MouseInputDetector());
}

Expand Down Expand Up @@ -230,13 +227,6 @@ protected override void PopOut()

private void playTapSample(double baseFrequency = 1f)
{
const float random_range = 0.02f;
SampleChannel channel = tapSample.GetChannel();

// Scale to [-0.75, 0.75] so that the sample isn't fully panned left or right (sounds weird)
channel.Balance.Value = ((activeCursor.X / DrawWidth) * 2 - 1) * OsuGameBase.SFX_STEREO_STRENGTH;
channel.Frequency.Value = baseFrequency - (random_range / 2f) + RNG.NextDouble(random_range);
channel.Volume.Value = baseFrequency;
}

public partial class Cursor : Container
Expand Down
Loading

0 comments on commit d432536

Please sign in to comment.