1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:52:57 +08:00

Fix some weird private field names (#7149)

Fix some weird private field names
This commit is contained in:
Dean Herbert 2019-12-11 15:02:24 +09:00 committed by GitHub
commit ae0121c30f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 105 deletions

View File

@ -12,14 +12,14 @@ namespace osu.Game.Rulesets.Catch.MathUtils
{
private const double int_to_real = 1.0 / (int.MaxValue + 1.0);
private const uint int_mask = 0x7FFFFFFF;
private const uint y = 842502087;
private const uint z = 3579807591;
private const uint w = 273326509;
private uint _x, _y = y, _z = z, _w = w;
private const uint y_initial = 842502087;
private const uint z_initial = 3579807591;
private const uint w_initial = 273326509;
private uint x, y = y_initial, z = z_initial, w = w_initial;
public FastRandom(int seed)
{
_x = (uint)seed;
x = (uint)seed;
}
public FastRandom()
@ -33,11 +33,11 @@ namespace osu.Game.Rulesets.Catch.MathUtils
/// <returns>The random value.</returns>
public uint NextUInt()
{
uint t = _x ^ (_x << 11);
_x = _y;
_y = _z;
_z = _w;
return _w = _w ^ (_w >> 19) ^ t ^ (t >> 8);
uint t = x ^ (x << 11);
x = y;
y = z;
z = w;
return w = w ^ (w >> 19) ^ t ^ (t >> 8);
}
/// <summary>

View File

@ -83,88 +83,81 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
};
}
private ScrollState _scrollState;
private ScrollState scrollState;
private ScrollState scrollState
private void setScrollState(ScrollState newstate)
{
get => _scrollState;
if (scrollState == newstate)
return;
set
delayedStateChangeDelegate?.Cancel();
switch (scrollState = newstate)
{
if (_scrollState == value)
return;
case ScrollState.Scrolling:
resetSelected();
_scrollState = value;
OnScrollStarted?.Invoke();
delayedStateChangeDelegate?.Cancel();
speedTo(1000f, 200);
tracker.FadeOut(100);
break;
switch (value)
{
case ScrollState.Scrolling:
resetSelected();
case ScrollState.Stopping:
speedTo(0f, 2000);
tracker.FadeIn(200);
OnScrollStarted?.Invoke();
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Stopped), 2300);
break;
speedTo(1000f, 200);
tracker.FadeOut(100);
case ScrollState.Stopped:
// Find closest to center
if (!Children.Any())
break;
case ScrollState.Stopping:
speedTo(0f, 2000);
tracker.FadeIn(200);
ScrollingTeam closest = null;
delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Stopped, 2300);
break;
foreach (var c in Children)
{
if (!(c is ScrollingTeam stc))
continue;
case ScrollState.Stopped:
// Find closest to center
if (!Children.Any())
break;
ScrollingTeam closest = null;
foreach (var c in Children)
if (closest == null)
{
if (!(c is ScrollingTeam stc))
continue;
if (closest == null)
{
closest = stc;
continue;
}
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
if (o < lastOffset)
closest = stc;
closest = stc;
continue;
}
Trace.Assert(closest != null, "closest != null");
float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f);
float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f);
// ReSharper disable once PossibleNullReferenceException
offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
if (o < lastOffset)
closest = stc;
}
ScrollingTeam st = closest;
Trace.Assert(closest != null, "closest != null");
availableTeams.RemoveAll(at => at == st.Team);
// ReSharper disable once PossibleNullReferenceException
offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f);
st.Selected = true;
OnSelected?.Invoke(st.Team);
ScrollingTeam st = closest;
delayedStateChangeDelegate = Scheduler.AddDelayed(() => scrollState = ScrollState.Idle, 10000);
break;
availableTeams.RemoveAll(at => at == st.Team);
case ScrollState.Idle:
resetSelected();
st.Selected = true;
OnSelected?.Invoke(st.Team);
OnScrollStarted?.Invoke();
delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Idle), 10000);
break;
speedTo(40f, 200);
tracker.FadeOut(100);
break;
}
case ScrollState.Idle:
resetSelected();
OnScrollStarted?.Invoke();
speedTo(40f, 200);
tracker.FadeOut(100);
break;
}
}
@ -176,7 +169,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
availableTeams.Add(team);
RemoveAll(c => c is ScrollingTeam);
scrollState = ScrollState.Idle;
setScrollState(ScrollState.Idle);
}
public void AddTeams(IEnumerable<TournamentTeam> teams)
@ -192,7 +185,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
{
availableTeams.Clear();
RemoveAll(c => c is ScrollingTeam);
scrollState = ScrollState.Idle;
setScrollState(ScrollState.Idle);
}
public void RemoveTeam(TournamentTeam team)
@ -217,7 +210,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
if (availableTeams.Count == 0)
return;
scrollState = ScrollState.Scrolling;
setScrollState(ScrollState.Scrolling);
}
public void StopScrolling()
@ -232,13 +225,13 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
return;
}
scrollState = ScrollState.Stopping;
setScrollState(ScrollState.Stopping);
}
protected override void LoadComplete()
{
base.LoadComplete();
scrollState = ScrollState.Idle;
setScrollState(ScrollState.Idle);
}
protected override void UpdateAfterChildren()
@ -305,7 +298,7 @@ namespace osu.Game.Tournament.Screens.Drawings.Components
private void speedTo(float value, double duration = 0, Easing easing = Easing.None) =>
this.TransformTo(nameof(speed), value, duration, easing);
private enum ScrollState
protected enum ScrollState
{
None,
Idle,

View File

@ -45,23 +45,25 @@ namespace osu.Game.Online.Multiplayer
[JsonProperty("beatmap")]
private APIBeatmap apiBeatmap { get; set; }
private APIMod[] allowedModsBacking;
[JsonProperty("allowed_mods")]
private APIMod[] allowedMods
{
get => AllowedMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
set => _allowedMods = value;
set => allowedModsBacking = value;
}
private APIMod[] requiredModsBacking;
[JsonProperty("required_mods")]
private APIMod[] requiredMods
{
get => RequiredMods.Select(m => new APIMod { Acronym = m.Acronym }).ToArray();
set => _requiredMods = value;
set => requiredModsBacking = value;
}
private BeatmapInfo beatmap;
private APIMod[] _allowedMods;
private APIMod[] _requiredMods;
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
{
@ -70,20 +72,20 @@ namespace osu.Game.Online.Multiplayer
Beatmap = apiBeatmap == null ? beatmaps.QueryBeatmap(b => b.OnlineBeatmapID == BeatmapID) : apiBeatmap.ToBeatmap(rulesets);
Ruleset = rulesets.GetRuleset(RulesetID);
if (_allowedMods != null)
if (allowedModsBacking != null)
{
AllowedMods.Clear();
AllowedMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => _allowedMods.Any(m => m.Acronym == mod.Acronym)));
AllowedMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => allowedModsBacking.Any(m => m.Acronym == mod.Acronym)));
_allowedMods = null;
allowedModsBacking = null;
}
if (_requiredMods != null)
if (requiredModsBacking != null)
{
RequiredMods.Clear();
RequiredMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => _requiredMods.Any(m => m.Acronym == mod.Acronym)));
RequiredMods.AddRange(Ruleset.CreateInstance().GetAllMods().Where(mod => requiredModsBacking.Any(m => m.Acronym == mod.Acronym)));
_requiredMods = null;
requiredModsBacking = null;
}
}

View File

@ -188,26 +188,22 @@ namespace osu.Game.Screens.Play
InternalButtons.Add(button);
}
private int _selectionIndex = -1;
private int selectionIndex = -1;
private int selectionIndex
private void setSelected(int value)
{
get => _selectionIndex;
set
{
if (_selectionIndex == value)
return;
if (selectionIndex == value)
return;
// Deselect the previously-selected button
if (_selectionIndex != -1)
InternalButtons[_selectionIndex].Selected.Value = false;
// Deselect the previously-selected button
if (selectionIndex != -1)
InternalButtons[selectionIndex].Selected.Value = false;
_selectionIndex = value;
selectionIndex = value;
// Select the newly-selected button
if (_selectionIndex != -1)
InternalButtons[_selectionIndex].Selected.Value = true;
}
// Select the newly-selected button
if (selectionIndex != -1)
InternalButtons[selectionIndex].Selected.Value = true;
}
protected override bool OnKeyDown(KeyDownEvent e)
@ -218,16 +214,16 @@ namespace osu.Game.Screens.Play
{
case Key.Up:
if (selectionIndex == -1 || selectionIndex == 0)
selectionIndex = InternalButtons.Count - 1;
setSelected(InternalButtons.Count - 1);
else
selectionIndex--;
setSelected(selectionIndex - 1);
return true;
case Key.Down:
if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1)
selectionIndex = 0;
setSelected(0);
else
selectionIndex++;
setSelected(selectionIndex + 1);
return true;
}
}
@ -266,9 +262,9 @@ namespace osu.Game.Screens.Play
private void buttonSelectionChanged(DialogButton button, bool isSelected)
{
if (!isSelected)
selectionIndex = -1;
setSelected(-1);
else
selectionIndex = InternalButtons.IndexOf(button);
setSelected(InternalButtons.IndexOf(button));
}
private void updateRetryCount()