mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
reduce code duplication to move intro background
This commit is contained in:
parent
2ffc479411
commit
5b22c5a453
@ -37,7 +37,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
private MusicController musicController;
|
private MusicController musicController;
|
||||||
|
|
||||||
private NotificationOverlay notificationOverlay;
|
private NotificationOverlay notifications;
|
||||||
|
|
||||||
private DialogOverlay dialogOverlay;
|
private DialogOverlay dialogOverlay;
|
||||||
|
|
||||||
@ -75,8 +75,6 @@ namespace osu.Game
|
|||||||
|
|
||||||
private SettingsOverlay settings;
|
private SettingsOverlay settings;
|
||||||
|
|
||||||
private float backgroundOffset;
|
|
||||||
|
|
||||||
public OsuGame(string[] args = null)
|
public OsuGame(string[] args = null)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
@ -138,7 +136,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
if (s.Beatmap == null)
|
if (s.Beatmap == null)
|
||||||
{
|
{
|
||||||
notificationOverlay.Post(new SimpleNotification
|
notifications.Post(new SimpleNotification
|
||||||
{
|
{
|
||||||
Text = @"Tried to load a score for a beatmap we don't have!",
|
Text = @"Tried to load a score for a beatmap we don't have!",
|
||||||
Icon = FontAwesome.fa_life_saver,
|
Icon = FontAwesome.fa_life_saver,
|
||||||
@ -156,7 +154,7 @@ namespace osu.Game
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
// hook up notifications to components.
|
// hook up notifications to components.
|
||||||
BeatmapManager.PostNotification = n => notificationOverlay?.Post(n);
|
BeatmapManager.PostNotification = n => notifications?.Post(n);
|
||||||
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
@ -209,7 +207,7 @@ namespace osu.Game
|
|||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}, overlayContent.Add);
|
}, overlayContent.Add);
|
||||||
|
|
||||||
loadComponentSingleFile(notificationOverlay = new NotificationOverlay
|
loadComponentSingleFile(notifications = new NotificationOverlay
|
||||||
{
|
{
|
||||||
Depth = -4,
|
Depth = -4,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
@ -225,7 +223,7 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
if (entry.Level < LogLevel.Important) return;
|
if (entry.Level < LogLevel.Important) return;
|
||||||
|
|
||||||
notificationOverlay.Post(new SimpleNotification
|
notifications.Post(new SimpleNotification
|
||||||
{
|
{
|
||||||
Text = $@"{entry.Level}: {entry.Message}"
|
Text = $@"{entry.Level}: {entry.Message}"
|
||||||
});
|
});
|
||||||
@ -238,7 +236,7 @@ namespace osu.Game
|
|||||||
dependencies.Cache(userProfile);
|
dependencies.Cache(userProfile);
|
||||||
dependencies.Cache(musicController);
|
dependencies.Cache(musicController);
|
||||||
dependencies.Cache(beatmapSetOverlay);
|
dependencies.Cache(beatmapSetOverlay);
|
||||||
dependencies.Cache(notificationOverlay);
|
dependencies.Cache(notifications);
|
||||||
dependencies.Cache(dialogOverlay);
|
dependencies.Cache(dialogOverlay);
|
||||||
|
|
||||||
// ensure only one of these overlays are open at once.
|
// ensure only one of these overlays are open at once.
|
||||||
@ -273,33 +271,20 @@ namespace osu.Game
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.StateChanged += delegate
|
Action<Visibility> stateChanged = delegate
|
||||||
{
|
{
|
||||||
switch (settings.State)
|
float offset = intro.X;
|
||||||
{
|
|
||||||
case Visibility.Hidden:
|
if (settings.State == Visibility.Hidden || notifications.State == Visibility.Visible)
|
||||||
backgroundOffset -= ToolbarButton.WIDTH / 2;
|
offset -= ToolbarButton.WIDTH / 2;
|
||||||
break;
|
else if (settings.State == Visibility.Visible || notifications.State == Visibility.Hidden)
|
||||||
case Visibility.Visible:
|
offset += ToolbarButton.WIDTH / 2;
|
||||||
backgroundOffset += ToolbarButton.WIDTH / 2;
|
|
||||||
break;
|
intro.MoveToX(offset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
}
|
|
||||||
intro.MoveToX(backgroundOffset, SettingsOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
notificationOverlay.StateChanged += delegate
|
settings.StateChanged += stateChanged;
|
||||||
{
|
notifications.StateChanged += stateChanged;
|
||||||
switch (notificationOverlay.State)
|
|
||||||
{
|
|
||||||
case Visibility.Hidden:
|
|
||||||
backgroundOffset += ToolbarButton.WIDTH / 2;
|
|
||||||
break;
|
|
||||||
case Visibility.Visible:
|
|
||||||
backgroundOffset -= ToolbarButton.WIDTH / 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
intro.MoveToX(backgroundOffset, NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
|
||||||
};
|
|
||||||
|
|
||||||
Cursor.State = Visibility.Hidden;
|
Cursor.State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
@ -368,7 +353,7 @@ namespace osu.Game
|
|||||||
direct.State = Visibility.Hidden;
|
direct.State = Visibility.Hidden;
|
||||||
social.State = Visibility.Hidden;
|
social.State = Visibility.Hidden;
|
||||||
userProfile.State = Visibility.Hidden;
|
userProfile.State = Visibility.Hidden;
|
||||||
notificationOverlay.State = Visibility.Hidden;
|
notifications.State = Visibility.Hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void screenChanged(Screen newScreen)
|
private void screenChanged(Screen newScreen)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user