自动保存Beatmap
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -109,6 +109,8 @@ namespace Ichni.RhythmGame
|
||||
noteVisual.effectSubmodule.effectCollection["Miss"].ForEach(e => e.UpdateEffect(exactJudgeTime));
|
||||
break;
|
||||
}
|
||||
|
||||
noteScreenPosition = EditorManager.instance.cameraManager.gameCamera.camera.WorldToScreenPoint(noteVisual.transform.position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +148,8 @@ namespace Ichni.RhythmGame
|
||||
inspector.GenerateInputField(this, container, "exactJudgeTime", nameof(exactJudgeTime));
|
||||
exactJudgeTimeInputField.AddListenerFunction(_ => UpdateNoteInTrack());
|
||||
|
||||
var noteScreenPositionText = inspector.GenerateHintText(this, container, () => "Note Screen Position: " + noteScreenPosition);
|
||||
|
||||
foreach (var submodule in submoduleList)
|
||||
{
|
||||
submodule.SetUpInspector();
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Ichni
|
||||
{
|
||||
public static EditorManager instance;
|
||||
|
||||
public bool isLoaded;
|
||||
|
||||
public ProjectManager projectManager;
|
||||
public MusicPlayer musicPlayer;
|
||||
public EditorUIManager uiManager;
|
||||
@@ -37,12 +39,13 @@ namespace Ichni
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
isLoaded = false;
|
||||
projectManager = new ProjectManager();
|
||||
operationManager = new OperationManager();
|
||||
|
||||
if (!ES3.FileExists(Application.streamingAssetsPath + "/EditorSettings.es3"))
|
||||
{
|
||||
editorSettings = new EditorSettings(300, 100, 100);
|
||||
editorSettings = new EditorSettings(300, 3, 100, 100);
|
||||
EditorSettings.SaveSettings(editorSettings);
|
||||
}
|
||||
else
|
||||
@@ -57,22 +60,25 @@ namespace Ichni
|
||||
this.elementGuid = Guid.Empty;
|
||||
uiManager.hierarchy.GenerateTab(this, null);
|
||||
StartCoroutine(DelayLoading());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(isLoaded) projectManager.autoSaveManager.UpdateAutoSave();
|
||||
}
|
||||
|
||||
public IEnumerator DelayLoading()
|
||||
{
|
||||
StartCoroutine(projectManager.loadManager.Load("TestProject"));
|
||||
musicPlayer.audioSource.clip = songInformation.song;
|
||||
yield return new WaitForSeconds(2);//什么时候能加个loading界面
|
||||
|
||||
|
||||
yield return new WaitForSeconds(1);//什么时候能加个loading界面
|
||||
|
||||
beatmapContainer.gameElementList.ForEach(gameElement =>
|
||||
{
|
||||
gameElement.AfterInitialize();
|
||||
gameElement.Refresh();
|
||||
});
|
||||
isLoaded = true;
|
||||
}
|
||||
public override void SetUpInspector()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
@@ -30,6 +31,7 @@ namespace Ichni
|
||||
public LoadManager loadManager;
|
||||
public ExportManager exportManager;
|
||||
public BeatmapClipManager beatmapClipManager;
|
||||
public AutoSaveManager autoSaveManager;
|
||||
|
||||
public ProjectManager()
|
||||
{
|
||||
@@ -37,6 +39,7 @@ namespace Ichni
|
||||
loadManager = new LoadManager();
|
||||
exportManager = new ExportManager();
|
||||
beatmapClipManager = new BeatmapClipManager();
|
||||
autoSaveManager = new AutoSaveManager();
|
||||
}
|
||||
|
||||
public void GenerateProject(string projectName)
|
||||
@@ -286,4 +289,77 @@ namespace Ichni
|
||||
clip.ForEach(e => e.ExecuteBM());
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoSaveManager
|
||||
{
|
||||
private string autoSavePath => Application.streamingAssetsPath + "/AutoSave/" +
|
||||
EditorManager.instance.projectInformation.projectName;
|
||||
private string GetAutoSavePath(string autoSaveName) => autoSavePath + "/" + autoSaveName + ".json";
|
||||
private float autoSaveInterval => EditorManager.instance.editorSettings.autoSaveInterval;
|
||||
private int maximumAutoSaveCount => EditorManager.instance.editorSettings.maximumAutoSaveCount;
|
||||
|
||||
public float autoSaveTimer;
|
||||
|
||||
public AutoSaveManager()
|
||||
{
|
||||
autoSaveTimer = 0;
|
||||
}
|
||||
|
||||
public void UpdateAutoSave()
|
||||
{
|
||||
autoSaveTimer += Time.deltaTime;
|
||||
if (autoSaveTimer >= autoSaveInterval)
|
||||
{
|
||||
AutoSave();
|
||||
autoSaveTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void AutoSave()
|
||||
{
|
||||
List<string> saveFiles = GetSortedSaveFiles();
|
||||
|
||||
if (saveFiles.Count > 0)
|
||||
{
|
||||
// 删除最旧的存档(如果超过数量)
|
||||
if (saveFiles.Count >= maximumAutoSaveCount)
|
||||
{
|
||||
string oldestSave = saveFiles[saveFiles.Count - 1];
|
||||
File.Delete(oldestSave);
|
||||
saveFiles.RemoveAt(saveFiles.Count - 1);
|
||||
}
|
||||
|
||||
// 依次重命名存档
|
||||
for (int i = saveFiles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
string oldPath = saveFiles[i];
|
||||
string newPath = GetAutoSavePath($"AutoSave_{i + 1}");
|
||||
File.Move(oldPath, newPath);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存最新存档
|
||||
string newestSavePath = GetAutoSavePath("AutoSave_0");
|
||||
SaveBeatMap(newestSavePath);
|
||||
}
|
||||
|
||||
private void SaveBeatMap(string autoSavePath)
|
||||
{
|
||||
EditorManager.instance.beatmapContainer.SaveBM();
|
||||
ES3.Save("BeatMap", EditorManager.instance.beatmapContainer.matchedBM as BeatmapContainer_BM,
|
||||
autoSavePath, ProjectManager.SaveSettings);
|
||||
}
|
||||
|
||||
private List<string> GetSortedSaveFiles()
|
||||
{
|
||||
if(!ES3.DirectoryExists(autoSavePath))
|
||||
{
|
||||
Directory.CreateDirectory(autoSavePath);
|
||||
}
|
||||
|
||||
List<string> saveFiles = new List<string>(Directory.GetFiles(autoSavePath, "AutoSave_*.es3"));
|
||||
saveFiles.Sort(string.Compare);
|
||||
return saveFiles;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,14 @@ namespace Ichni.Editor
|
||||
public class EditorSettings
|
||||
{
|
||||
public int autoSaveInterval = 300;
|
||||
public int maximumAutoSaveCount = 3;
|
||||
public int musicVolume = 100;
|
||||
public int soundFXVolume = 100;
|
||||
|
||||
public EditorSettings(int autoSaveInterval, int musicVolume, int soundFXVolume)
|
||||
public EditorSettings(int autoSaveInterval, int maximumAutoSaveCount, int musicVolume, int soundFXVolume)
|
||||
{
|
||||
this.autoSaveInterval = autoSaveInterval;
|
||||
this.maximumAutoSaveCount = maximumAutoSaveCount;
|
||||
this.musicVolume = musicVolume;
|
||||
this.soundFXVolume = soundFXVolume;
|
||||
}
|
||||
|
||||
BIN
Assets/StreamingAssets/.DS_Store
vendored
BIN
Assets/StreamingAssets/.DS_Store
vendored
Binary file not shown.
8
Assets/StreamingAssets/AutoSave.meta
Normal file
8
Assets/StreamingAssets/AutoSave.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a67c799c4f674b288fab2d57759b4fb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/StreamingAssets/AutoSave/.DS_Store
vendored
Normal file
BIN
Assets/StreamingAssets/AutoSave/.DS_Store
vendored
Normal file
Binary file not shown.
8
Assets/StreamingAssets/AutoSave/TestProject.meta
Normal file
8
Assets/StreamingAssets/AutoSave/TestProject.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8403371c2481d4e37a563d372f2be857
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1515
Assets/StreamingAssets/AutoSave/TestProject/AutoSave_0.json
Normal file
1515
Assets/StreamingAssets/AutoSave/TestProject/AutoSave_0.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07260670e384a482488fa056cb714307
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/StreamingAssets/Projects/.DS_Store
vendored
BIN
Assets/StreamingAssets/Projects/.DS_Store
vendored
Binary file not shown.
Reference in New Issue
Block a user