Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIsplay toasts on beatmap/skin save #19243

Merged
merged 6 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions osu.Game/Localisation/ToastStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ public static class ToastStrings
/// </summary>
public static LocalisableString RestartTrack => new TranslatableString(getKey(@"restart_track"), @"Restart track");

/// <summary>
/// "Beatmap saved"
/// </summary>
public static LocalisableString BeatmapSaved => new TranslatableString(getKey(@"beatmap_saved"), @"Beatmap saved");

/// <summary>
/// "Skin saved"
/// </summary>
public static LocalisableString SkinSaved => new TranslatableString(getKey(@"skin_saved"), @"Skin saved");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
15 changes: 14 additions & 1 deletion osu.Game/Screens/Edit/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Screens;
Expand All @@ -31,10 +32,11 @@
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Overlays.OSD;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
Expand All @@ -50,6 +52,7 @@
using osu.Game.Users;
using osuTK.Graphics;
using osuTK.Input;
using CommonStrings = osu.Game.Resources.Localisation.Web.CommonStrings;

namespace osu.Game.Screens.Edit
{
Expand Down Expand Up @@ -169,6 +172,9 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);

[Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; }

public Editor(EditorLoader loader = null)
{
this.loader = loader;
Expand Down Expand Up @@ -405,6 +411,7 @@ protected bool Save()
// no longer new after first user-triggered save.
isNewBeatmap = false;
updateLastSavedHash();
onScreenDisplay?.Display(new BeatmapEditorToast(ToastStrings.BeatmapSaved, editorBeatmap.BeatmapInfo.GetDisplayTitle()));
return true;
}

Expand Down Expand Up @@ -934,5 +941,11 @@ private void cancelExit()
ControlPointInfo IBeatSyncProvider.ControlPoints => editorBeatmap.ControlPointInfo;
IClock IBeatSyncProvider.Clock => clock;
ChannelAmplitudes? IBeatSyncProvider.Amplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : null;

private class BeatmapEditorToast : Toast
{
public BeatmapEditorToast(LocalisableString value, string beatmapDisplayName)
: base(InputSettingsStrings.EditorSection, value, beatmapDisplayName) { }
}
}
}
13 changes: 13 additions & 0 deletions osu.Game/Skinning/Editor/SkinEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Overlays.OSD;
using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Edit.Components.Menus;

Expand Down Expand Up @@ -68,6 +71,9 @@ public class SkinEditor : VisibilityContainer, ICanAcceptFiles
private EditorSidebar componentsSidebar;
private EditorSidebar settingsSidebar;

[Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; }

public SkinEditor()
{
}
Expand Down Expand Up @@ -316,6 +322,7 @@ public void Save()
currentSkin.Value.UpdateDrawableTarget(t);

skins.Save(skins.CurrentSkin.Value);
onScreenDisplay?.Display(new SkinEditorToast(ToastStrings.SkinSaved, currentSkin.Value.SkinInfo.ToString()));
}

protected override bool OnHover(HoverEvent e) => true;
Expand Down Expand Up @@ -395,5 +402,11 @@ protected override void Dispose(bool isDisposing)

game?.UnregisterImportHandler(this);
}

private class SkinEditorToast : Toast
{
public SkinEditorToast(LocalisableString value, string skinDisplayName)
: base(SkinSettingsStrings.SkinLayoutEditor, value, skinDisplayName) { }
}
}
}