mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Remove migration setting in favour of export option in the editor
This commit is contained in:
parent
a3fcc0b60c
commit
b2c0b013aa
@ -553,76 +553,6 @@ namespace osu.Game.Beatmaps
|
|||||||
return beatmapSet;
|
return beatmapSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateContent(BeatmapInfo beatmapInfo, Stream newData)
|
|
||||||
{
|
|
||||||
var context = createContext();
|
|
||||||
|
|
||||||
using (var transaction = context.BeginTransaction())
|
|
||||||
{
|
|
||||||
var setInfo = beatmapInfo.BeatmapSet;
|
|
||||||
var existingSetFileInfo = setInfo.Files.First(f => f.FileInfo.Hash == beatmapInfo.Hash);
|
|
||||||
var existingFileInfo = existingSetFileInfo.FileInfo;
|
|
||||||
|
|
||||||
existingSetFileInfo.FileInfo = files.Add(newData);
|
|
||||||
files.Dereference(existingFileInfo);
|
|
||||||
|
|
||||||
beatmapInfo.Hash = newData.ComputeSHA2Hash();
|
|
||||||
beatmapInfo.MD5Hash = newData.ComputeMD5Hash();
|
|
||||||
|
|
||||||
context.Update(existingSetFileInfo);
|
|
||||||
context.Update(beatmapInfo);
|
|
||||||
|
|
||||||
context.SaveChanges(transaction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MigrateAllToNewFormat()
|
|
||||||
{
|
|
||||||
var usableSets = GetAllUsableBeatmapSets();
|
|
||||||
|
|
||||||
if (usableSets.Count == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var notification = new ProgressNotification
|
|
||||||
{
|
|
||||||
Progress = 0,
|
|
||||||
State = ProgressNotificationState.Active,
|
|
||||||
};
|
|
||||||
|
|
||||||
PostNotification?.Invoke(notification);
|
|
||||||
|
|
||||||
int i = 1;
|
|
||||||
foreach (var set in usableSets)
|
|
||||||
{
|
|
||||||
if (notification.State == ProgressNotificationState.Cancelled)
|
|
||||||
// user requested abort
|
|
||||||
return;
|
|
||||||
|
|
||||||
notification.Text = $"Migrating ({i} of {usableSets.Count})";
|
|
||||||
notification.Progress = (float)i++ / usableSets.Count;
|
|
||||||
|
|
||||||
foreach (var beatmap in set.Beatmaps)
|
|
||||||
{
|
|
||||||
if (notification.State == ProgressNotificationState.Cancelled)
|
|
||||||
// user requested abort
|
|
||||||
return;
|
|
||||||
|
|
||||||
var working = GetWorkingBeatmap(beatmap);
|
|
||||||
using (var ms = new MemoryStream())
|
|
||||||
using (var sw = new StreamWriter(ms))
|
|
||||||
{
|
|
||||||
sw.Write(working.Beatmap.Serialize());
|
|
||||||
sw.Flush();
|
|
||||||
|
|
||||||
ms.Position = 0;
|
|
||||||
UpdateContent(beatmap, ms);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Completed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of all usable <see cref="BeatmapSetInfo"/>s.
|
/// Returns a list of all usable <see cref="BeatmapSetInfo"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -10,6 +10,10 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
|
using osu.Framework.IO.File;
|
||||||
|
using System.IO;
|
||||||
|
using osu.Game.IO.Serialization;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
@ -38,6 +42,17 @@ namespace osu.Game.Beatmaps
|
|||||||
storyboard = new AsyncLazy<Storyboard>(populateStoryboard);
|
storyboard = new AsyncLazy<Storyboard>(populateStoryboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the <see cref="Beatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
var path = FileSafety.GetTempPath(Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json");
|
||||||
|
using (var sw = new StreamWriter(path))
|
||||||
|
sw.WriteLine(Beatmap.Serialize());
|
||||||
|
Process.Start(path);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract Beatmap GetBeatmap();
|
protected abstract Beatmap GetBeatmap();
|
||||||
protected abstract Texture GetBackground();
|
protected abstract Texture GetBackground();
|
||||||
protected abstract Track GetTrack();
|
protected abstract Track GetTrack();
|
||||||
|
@ -58,18 +58,6 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!osuGame.IsDeployedBuild)
|
|
||||||
{
|
|
||||||
Add(migrateButton = new SettingsButton
|
|
||||||
{
|
|
||||||
Text = "Migrate all beatmaps to the new format",
|
|
||||||
Action = () =>
|
|
||||||
{
|
|
||||||
migrateButton.Enabled.Value = false;
|
|
||||||
Task.Factory.StartNew(beatmaps.MigrateAllToNewFormat).ContinueWith(t => Schedule(() => migrateButton.Enabled.Value = true), TaskContinuationOptions.LongRunning);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
Items = new[]
|
Items = new[]
|
||||||
{
|
{
|
||||||
|
new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap),
|
||||||
new EditorMenuItem("Exit", MenuItemType.Standard, Exit)
|
new EditorMenuItem("Exit", MenuItemType.Standard, Exit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,6 +137,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
bottomBackground.Colour = colours.Gray2;
|
bottomBackground.Colour = colours.Gray2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void exportBeatmap()
|
||||||
|
{
|
||||||
|
Beatmap.Value.Save();
|
||||||
|
}
|
||||||
|
|
||||||
private void onModeChanged(EditorScreenMode mode)
|
private void onModeChanged(EditorScreenMode mode)
|
||||||
{
|
{
|
||||||
currentScreen?.Exit();
|
currentScreen?.Exit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user