1- using LitJson ;
2- using NoteEditor . Common ;
3- using NoteEditor . Model . JSON ;
4- using NoteEditor . Notes ;
1+ using NoteEditor . Common ;
52using NoteEditor . Model ;
3+ using NoteEditor . Notes ;
64using NoteEditor . Utility ;
75using System ;
86using System . Collections ;
@@ -28,11 +26,6 @@ public class MusicSelectorPresenter : MonoBehaviour
2826 Button loadButton ;
2927 [ SerializeField ]
3028 GameObject notesRegion ;
31-
32- /*
33- [SerializeField]
34- Text selectedFileNameText;
35- */
3629 [ SerializeField ]
3730 GameObject noteObjectPrefab ;
3831
@@ -45,21 +38,18 @@ void Start()
4538 MusicSelector . DirectoryPath . Subscribe ( path => directoryPathInputField . text = path ) ;
4639 MusicSelector . DirectoryPath . Value = Settings . WorkSpaceDirectoryPath . Value + "/Musics/" ;
4740
48-
4941 if ( ! Directory . Exists ( MusicSelector . DirectoryPath . Value ) )
5042 {
5143 Directory . CreateDirectory ( MusicSelector . DirectoryPath . Value ) ;
5244 }
5345
54-
5546 Observable . Timer ( TimeSpan . FromMilliseconds ( 300 ) , TimeSpan . Zero )
5647 . Where ( _ => Directory . Exists ( MusicSelector . DirectoryPath . Value ) )
5748 . Select ( _ => new DirectoryInfo ( MusicSelector . DirectoryPath . Value ) . GetFiles ( ) )
5849 . Select ( fileInfo => fileInfo . Select ( file => file . FullName ) . ToList ( ) )
5950 . Where ( x => ! x . SequenceEqual ( MusicSelector . FilePathList . Value ) )
6051 . Subscribe ( filePathList => MusicSelector . FilePathList . Value = filePathList ) ;
6152
62-
6353 MusicSelector . FilePathList . AsObservable ( )
6454 . Select ( filePathList => filePathList . Select ( path => Path . GetFileName ( path ) ) )
6555 . Do ( _ => Enumerable . Range ( 0 , fileItemContainerTransform . childCount )
@@ -71,13 +61,10 @@ void Start()
7161 . Do ( elm => elm . obj . transform . SetParent ( fileItemContainer . transform ) )
7262 . Subscribe ( elm => elm . obj . GetComponent < FileListItem > ( ) . SetName ( elm . fileName ) ) ;
7363
74-
7564 loadButton . OnClickAsObservable ( )
7665 . Select ( _ => MusicSelector . SelectedFileName . Value )
7766 . Where ( fileName => ! string . IsNullOrEmpty ( fileName ) )
7867 . Subscribe ( fileName => StartCoroutine ( LoadMusic ( fileName ) ) ) ;
79-
80- // MusicSelector.SelectedFileName.SubscribeToText(selectedFileNameText);
8168 }
8269
8370 IEnumerator LoadMusic ( string fileName )
@@ -92,6 +79,7 @@ IEnumerator LoadMusic(string fileName)
9279
9380 if ( Audio . Source . clip == null )
9481 {
82+ // TODO: 読み込み失敗時の処理
9583 }
9684 else
9785 {
@@ -111,42 +99,7 @@ void LoadEditData()
11199 if ( File . Exists ( filePath ) )
112100 {
113101 var json = File . ReadAllText ( filePath , System . Text . Encoding . UTF8 ) ;
114- var editData = JsonMapper . ToObject < SaveDataModel . EditData > ( json ) ;
115- InstantiateEditData ( editData ) ;
116- }
117- }
118-
119- void InstantiateEditData ( SaveDataModel . EditData editData )
120- {
121- var notePresenter = EditNotesPresenter . Instance ;
122-
123- EditData . BPM . Value = editData . BPM ;
124- EditData . MaxBlock . Value = editData . maxBlock ;
125- EditData . OffsetSamples . Value = editData . offset ;
126-
127- foreach ( var note in editData . notes )
128- {
129- if ( note . type == 1 )
130- {
131- notePresenter . AddNote ( ConvertUtils . ToNote ( note ) ) ;
132- continue ;
133- }
134-
135- var longNoteObjects = new [ ] { note } . Concat ( note . notes )
136- . Select ( note_ =>
137- {
138- notePresenter . AddNote ( ConvertUtils . ToNote ( note_ ) ) ;
139- return EditData . Notes [ ConvertUtils . ToNote ( note_ ) . position ] ;
140- } )
141- . ToList ( ) ;
142-
143- for ( int i = 1 ; i < longNoteObjects . Count ; i ++ )
144- {
145- longNoteObjects [ i ] . note . prev = longNoteObjects [ i - 1 ] . note . position ;
146- longNoteObjects [ i - 1 ] . note . next = longNoteObjects [ i ] . note . position ;
147- }
148-
149- EditState . LongNoteTailPosition . Value = NotePosition . None ;
102+ EditDataSerializer . Deserialize ( json ) ;
150103 }
151104 }
152105
0 commit comments