Skip to content

Commit

Permalink
Fix issues only pointed out on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jun 23, 2023
1 parent b6837e5 commit d002fda
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ public override void OnEntering(ScreenTransitionEvent e)

if (shouldTakeOutLease)
{
DummyBindable.BindTo(((TestScreen)e.Last).DummyBindable);
DummyBindable.BindTo(((TestScreen)e.Last!).DummyBindable);
LeasedCopy = DummyBindable.BeginLease(true);
}

Expand Down
8 changes: 4 additions & 4 deletions osu.Framework/Graphics/UserInterface/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private void menuItemClicked(DrawableMenuItem item)
}

// Check if there is a sub menu to display
if (item.Item.Items?.Count == 0)
if (item.Item.Items.Count == 0)
{
// This item must have attempted to invoke an action - close all menus if item allows
if (item.CloseMenuOnClick)
Expand Down Expand Up @@ -625,7 +625,7 @@ private void closeFromChild(MenuItem source)
{
if (IsHovered || (parentMenu?.IsHovered ?? false)) return;

if (triggeringItem?.Item.Items?.Contains(source) ?? triggeringItem == null)
if (triggeringItem?.Item.Items.Contains(source) ?? triggeringItem == null)
{
Close();
parentMenu?.closeFromChild(triggeringItem?.Item);
Expand Down Expand Up @@ -834,7 +834,7 @@ public MenuItemState State
/// </summary>
protected bool IsActionable => hasSubmenu || (!Item.Action.Disabled && Item.Action.Value != null);

private bool hasSubmenu => Item.Items?.Count > 0;
private bool hasSubmenu => Item.Items.Count > 0;

/// <summary>
/// Called after the <see cref="BackgroundColour"/> is modified or the hover state changes.
Expand Down Expand Up @@ -892,7 +892,7 @@ protected override bool OnClick(ClickEvent e)
if (!IsActionable)
return true;

Item.Action.Value.Invoke();
Item.Action.Value?.Invoke();
Clicked?.Invoke(this);
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion osu.Framework/IO/Stores/FontStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading.Tasks;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging;
Expand Down Expand Up @@ -142,7 +143,7 @@ public ITexturedCharacterGlyph Get(string fontName, char character)
foreach (var store in glyphStores)
{
if ((string.IsNullOrEmpty(fontName) || fontName == store.FontName) && store.HasGlyph(character))
return namespacedGlyphCache[key] = new TexturedCharacterGlyph(store.Get(character), Get(textureName), 1 / ScaleAdjust);
return namespacedGlyphCache[key] = new TexturedCharacterGlyph(store.Get(character).AsNonNull(), Get(textureName), 1 / ScaleAdjust);
}

foreach (var store in nestedFontStores)
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Input/Events/FocusEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class FocusEvent : UIEvent
/// </summary>
public readonly Drawable? PreviouslyFocused;

public FocusEvent(InputState state, Drawable previouslyFocused)
public FocusEvent(InputState state, Drawable? previouslyFocused)
: base(state)
{
PreviouslyFocused = previouslyFocused;
Expand Down
11 changes: 6 additions & 5 deletions osu.Framework/Input/PassThroughInputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#nullable disable

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -181,13 +182,13 @@ protected virtual void SyncInputState(InputState state)
new TouchInput(touchStateDifference.deactivated, false).Apply(CurrentState, this);
new TouchInput(touchStateDifference.activated, true).Apply(CurrentState, this);

new JoystickButtonInput(state?.Joystick?.Buttons, CurrentState.Joystick.Buttons).Apply(CurrentState, this);
new JoystickAxisInput(state?.Joystick?.GetAxes()).Apply(CurrentState, this);
new JoystickButtonInput(state?.Joystick?.Buttons ?? new ButtonStates<JoystickButton>(), CurrentState.Joystick.Buttons).Apply(CurrentState, this);
new JoystickAxisInput(state?.Joystick?.GetAxes() ?? Array.Empty<JoystickAxis>()).Apply(CurrentState, this);

new MidiKeyInput(state?.Midi, CurrentState.Midi).Apply(CurrentState, this);
new MidiKeyInput(state?.Midi ?? new MidiState(), CurrentState.Midi).Apply(CurrentState, this);

new TabletPenButtonInput(state?.Tablet.PenButtons, CurrentState.Tablet.PenButtons).Apply(CurrentState, this);
new TabletAuxiliaryButtonInput(state?.Tablet.AuxiliaryButtons, CurrentState.Tablet.AuxiliaryButtons).Apply(CurrentState, this);
new TabletPenButtonInput(state?.Tablet.PenButtons ?? new ButtonStates<TabletPenButton>(), CurrentState.Tablet.PenButtons).Apply(CurrentState, this);
new TabletAuxiliaryButtonInput(state?.Tablet.AuxiliaryButtons ?? new ButtonStates<TabletAuxiliaryButton>(), CurrentState.Tablet.AuxiliaryButtons).Apply(CurrentState, this);
}
}
}
4 changes: 2 additions & 2 deletions osu.Framework/Screens/ScreenTransitionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ public class ScreenTransitionEvent
/// <summary>
/// The <see cref="IScreen"/> which has been transitioned from.
/// </summary>
public IScreen Last { get; }
public IScreen? Last { get; }

/// <summary>
/// The <see cref="IScreen"/> which has been transitioned to.
/// </summary>
public IScreen Next { get; }

public ScreenTransitionEvent(IScreen last, IScreen next)
public ScreenTransitionEvent(IScreen? last, IScreen next)
{
Last = last;
Next = next;
Expand Down
6 changes: 3 additions & 3 deletions osu.Framework/Testing/Drawables/Steps/ToggleStepButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ namespace osu.Framework.Testing.Drawables.Steps
{
public partial class ToggleStepButton : StepButton
{
private readonly Action<bool> reloadCallback;
private readonly Action<bool>? reloadCallback;
private static readonly Color4 off_colour = Color4.Red;
private static readonly Color4 on_colour = Color4.YellowGreen;

public bool State;

public override int RequiredRepetitions => 2;

public ToggleStepButton(Action<bool> reloadCallback)
public ToggleStepButton(Action<bool>? reloadCallback)
{
this.reloadCallback = reloadCallback;
Action = clickAction;
Expand All @@ -28,7 +28,7 @@ private void clickAction()
{
State = !State;
Light.FadeColour(State ? on_colour : off_colour);
reloadCallback.Invoke(State);
reloadCallback?.Invoke(State);

if (!State)
Success();
Expand Down
4 changes: 2 additions & 2 deletions osu.Framework/Text/TextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ private bool tryCreateGlyph(char character, out TextBuilderGlyph glyph)
private ITexturedCharacterGlyph getTexturedGlyph(char character)
{
return store.Get(font.FontName, character)
?? store.Get(null, character)
?? store.Get(string.Empty, character)
?? store.Get(font.FontName, fallbackCharacter)
?? store.Get(null, fallbackCharacter);
?? store.Get(string.Empty, fallbackCharacter);
}
}
}

0 comments on commit d002fda

Please sign in to comment.