|
@@ -19,6 +19,7 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
private static string sceneData;
|
|
|
private static List<ScenePng> scenes = new List<ScenePng>(50);
|
|
|
private GUIStyle selectedButtonStyle;
|
|
|
+ private GUIStyle sceneSortComboStyle;
|
|
|
private GUIContent infoString;
|
|
|
private string[] directoryList;
|
|
|
private Texture2D frame;
|
|
@@ -45,17 +46,41 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
private int selectedDirectory = 0;
|
|
|
private string currentDirectory = sceneDirectoryName;
|
|
|
private string textFieldValue = "";
|
|
|
+ private readonly ComboBox2 sceneSortCombo = new ComboBox2();
|
|
|
+ private static GUIContent[] sceneSortComboList;
|
|
|
+ private static int sceneSortModeOld = 0;
|
|
|
+ private static bool sceneSortAscendingOld = true;
|
|
|
+ private static int selectedSceneSortMode = 0;
|
|
|
+ private static bool sceneSortAscending = true;
|
|
|
+ private static readonly string[] ConfigSortMode = new[] { "name", "date_created", "date_modified" };
|
|
|
+ private enum SortMode
|
|
|
+ {
|
|
|
+ Name, DateCreated, DateModified
|
|
|
+ }
|
|
|
|
|
|
public void InitializeSceneManager()
|
|
|
{
|
|
|
frame = MakeTex(2, 2, Color.white);
|
|
|
infoHighlight = MakeTex(2, 2, new Color(0f, 0f, 0f, 0.8f));
|
|
|
|
|
|
+ sceneSortCombo.selectedItemIndex = selectedSceneSortMode;
|
|
|
+ sceneSortComboList = new GUIContent[] {
|
|
|
+ new GUIContent("Name"),
|
|
|
+ new GUIContent("Date Created"),
|
|
|
+ new GUIContent("Date Modified")
|
|
|
+ };
|
|
|
|
|
|
selectedButtonStyle = new GUIStyle("button");
|
|
|
selectedButtonStyle.normal.background = MakeTex(1, 1, new Color(0.5f, 0.5f, 0.5f, 0.4f));
|
|
|
selectedButtonStyle.normal.textColor = Color.white;
|
|
|
|
|
|
+ sceneSortComboStyle = new GUIStyle();
|
|
|
+ sceneSortComboStyle.normal.textColor = Color.white;
|
|
|
+ sceneSortComboStyle.normal.background = MakeTex(2, 2, new Color(0.0f, 0.0f, 0.0f, 0.5f));
|
|
|
+ sceneSortComboStyle.onHover.background = sceneSortComboStyle.hover.background = new Texture2D(2, 2);
|
|
|
+ sceneSortComboStyle.padding.left = sceneSortComboStyle.padding.right = sceneSortComboStyle.padding.top = sceneSortComboStyle.padding.bottom = GetPix(0);
|
|
|
+ sceneSortComboStyle.fontSize = GetPix(13);
|
|
|
+
|
|
|
currentDirectory = kankyoModeFlag ? kankyoDirectoryName : sceneDirectoryName;
|
|
|
|
|
|
GetSceneDirectories();
|
|
@@ -71,6 +96,18 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
sceneManagerInitialize = true;
|
|
|
}
|
|
|
|
|
|
+ private void SaveSceneSortPreferences()
|
|
|
+ {
|
|
|
+ if (sceneSortAscending != sceneSortAscendingOld || sceneSortModeOld != selectedSceneSortMode)
|
|
|
+ {
|
|
|
+ Preferences["scenemanager"]["scene_sort_ascending"].Value = sceneSortAscending ? "true" : "false";
|
|
|
+ Preferences["scenemanager"]["scene_sort_mode"].Value = ConfigSortMode[selectedSceneSortMode];
|
|
|
+ SaveConfig();
|
|
|
+ sceneSortAscendingOld = sceneSortAscending;
|
|
|
+ sceneSortModeOld = selectedSceneSortMode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void RefreshSceneManager()
|
|
|
{
|
|
|
SwitchDirectory(currentDirectory);
|
|
@@ -150,10 +187,61 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
}
|
|
|
|
|
|
selectedScene = scenes.Count == 0 ? 0 : scenes.Count - 1;
|
|
|
- scenes.Sort((a, b) => a.info.LastWriteTime.CompareTo(b.info.LastWriteTime));
|
|
|
+
|
|
|
+ SortScenes();
|
|
|
+
|
|
|
sceneManagerScrollPos.y = 0;
|
|
|
}
|
|
|
|
|
|
+ private void SortScenes()
|
|
|
+ {
|
|
|
+ Comparison<ScenePng> sortMode = null;
|
|
|
+ switch ((SortMode)selectedSceneSortMode)
|
|
|
+ {
|
|
|
+ case SortMode.Name:
|
|
|
+ sortMode = SortByName;
|
|
|
+ break;
|
|
|
+ case SortMode.DateCreated:
|
|
|
+ sortMode = SortByDateCreated;
|
|
|
+ break;
|
|
|
+ case SortMode.DateModified:
|
|
|
+ sortMode = SortByDateModified;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ scenes.Sort(sortMode);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetSceneSortAscending(bool ascending)
|
|
|
+ {
|
|
|
+ sceneSortAscending = ascending;
|
|
|
+ SortScenes();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void SetSceneSortMode(int sortMode)
|
|
|
+ {
|
|
|
+ selectedSceneSortMode = Mathf.Clamp(sortMode, 0, 2);
|
|
|
+ SortScenes();
|
|
|
+ }
|
|
|
+
|
|
|
+ private static int SortByName(ScenePng a, ScenePng b)
|
|
|
+ {
|
|
|
+ int direction = sceneSortAscending ? -1 : 1;
|
|
|
+ return direction * a.info.Name.CompareTo(b.info.Name);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static int SortByDateCreated(ScenePng a, ScenePng b)
|
|
|
+ {
|
|
|
+ int direction = sceneSortAscending ? -1 : 1;
|
|
|
+ return direction * a.info.CreationTime.CompareTo(b.info.CreationTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static int SortByDateModified(ScenePng a, ScenePng b)
|
|
|
+ {
|
|
|
+ int direction = sceneSortAscending ? -1 : 1;
|
|
|
+ return direction * a.info.LastWriteTime.CompareTo(b.info.LastWriteTime);
|
|
|
+ }
|
|
|
+
|
|
|
private void CreateDirectory(string directoryName)
|
|
|
{
|
|
|
string root = kankyoModeFlag ? kankyoScenePath : saveScenePath;
|
|
@@ -204,12 +292,6 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
{
|
|
|
RefreshSceneManager();
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- File.Delete(file);
|
|
|
- scenes.RemoveAt(selectedScene);
|
|
|
- sceneManagerScrollPos.y = 0;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void SaveScene()
|
|
@@ -276,7 +358,18 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
|
|
|
string filePath;
|
|
|
|
|
|
- filePath = Path.Combine(saveDirectory, $"{sceneType}{DateTime.Now:yyyyMMddHHmmss}.png");
|
|
|
+ string fileName = $"{sceneType}{DateTime.Now:yyyyMMddHHmmss}.png";
|
|
|
+
|
|
|
+ FileInfo oldFileInfo = null;
|
|
|
+
|
|
|
+ if (overwriteFlag)
|
|
|
+ {
|
|
|
+ oldFileInfo = scenes[selectedScene].info;
|
|
|
+ fileName = oldFileInfo.Name;
|
|
|
+ scenes.RemoveAt(selectedScene);
|
|
|
+ }
|
|
|
+
|
|
|
+ filePath = Path.Combine(saveDirectory, fileName);
|
|
|
|
|
|
using (FileStream fileStream = File.Create(filePath))
|
|
|
using (MemoryStream sceneStream = new MemoryStream(Encoding.Unicode.GetBytes(sceneString)))
|
|
@@ -287,8 +380,19 @@ namespace CM3D2.MultipleMaids.Plugin
|
|
|
if (kankyoModeFlag) fileStream.Write(kankyoHeader, 0, kankyoHeader.Length);
|
|
|
fileStream.Write(sceneBuffer, 0, sceneBuffer.Length);
|
|
|
}
|
|
|
- scenes.Add(new ScenePng(new FileInfo(filePath), screenshot));
|
|
|
+
|
|
|
+ ScenePng newScenePng = new ScenePng(new FileInfo(filePath), screenshot);
|
|
|
+
|
|
|
+ if (oldFileInfo != null)
|
|
|
+ {
|
|
|
+ File.SetCreationTime(filePath, oldFileInfo.CreationTime);
|
|
|
+ newScenePng.info.CreationTime = oldFileInfo.CreationTime;
|
|
|
+ }
|
|
|
+
|
|
|
+ scenes.Add(newScenePng);
|
|
|
selectedScene = scenes.Count - 1;
|
|
|
+
|
|
|
+ SortScenes();
|
|
|
}
|
|
|
|
|
|
private void ReadScene()
|