mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 20:53:04 +08:00
Swap order of background/audio track changing methods
Mostly for quality of reviewing (restores previous order) and more consistency overall.
This commit is contained in:
parent
a0f0ae7979
commit
0a1417bc67
@ -93,6 +93,33 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public bool ChangeBackgroundImage(string path)
|
||||||
|
{
|
||||||
|
var info = new FileInfo(path);
|
||||||
|
|
||||||
|
if (!info.Exists)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var set = working.Value.BeatmapSetInfo;
|
||||||
|
|
||||||
|
// remove the previous background for now.
|
||||||
|
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
||||||
|
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
|
||||||
|
|
||||||
|
using (var stream = info.OpenRead())
|
||||||
|
{
|
||||||
|
if (oldFile != null)
|
||||||
|
beatmaps.ReplaceFile(set, oldFile, stream, info.Name);
|
||||||
|
else
|
||||||
|
beatmaps.AddFile(set, stream, info.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
working.Value.Metadata.BackgroundFile = info.Name;
|
||||||
|
header.Background.UpdateBackground();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ChangeAudioTrack(string path)
|
public bool ChangeAudioTrack(string path)
|
||||||
{
|
{
|
||||||
var info = new FileInfo(path);
|
var info = new FileInfo(path);
|
||||||
@ -122,33 +149,6 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ChangeBackgroundImage(string path)
|
|
||||||
{
|
|
||||||
var info = new FileInfo(path);
|
|
||||||
|
|
||||||
if (!info.Exists)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var set = working.Value.BeatmapSetInfo;
|
|
||||||
|
|
||||||
// remove the previous background for now.
|
|
||||||
// in the future we probably want to check if this is being used elsewhere (other difficulties?)
|
|
||||||
var oldFile = set.Files.FirstOrDefault(f => f.Filename == working.Value.Metadata.BackgroundFile);
|
|
||||||
|
|
||||||
using (var stream = info.OpenRead())
|
|
||||||
{
|
|
||||||
if (oldFile != null)
|
|
||||||
beatmaps.ReplaceFile(set, oldFile, stream, info.Name);
|
|
||||||
else
|
|
||||||
beatmaps.AddFile(set, stream, info.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
working.Value.Metadata.BackgroundFile = info.Name;
|
|
||||||
header.Background.UpdateBackground();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void backgroundChanged(ValueChangedEvent<string> filePath)
|
private void backgroundChanged(ValueChangedEvent<string> filePath)
|
||||||
{
|
{
|
||||||
if (!ChangeBackgroundImage(filePath.NewValue))
|
if (!ChangeBackgroundImage(filePath.NewValue))
|
||||||
|
Loading…
Reference in New Issue
Block a user