OSDN Git Service

#34546 DTXC起動時ならびにDTXファイルを開いたときの最初のモードを、編集モードと選択モードのどちらにするかをオプションで選べるようにした。
[dtxmania/dtxmania.git] / DTXCreatorプロジェクト / コード / 00.全体 / AppSetting.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.IO;\r
5 \r
6 namespace DTXCreator\r
7 {\r
8         // 使い方\r
9         //\r
10         // 保存方法:\r
11         //  var xmlsl = new System.Xml.Serialization.XmlSerializer(typeof(AppSetting));\r
12         //  FileStream fs = new FileStream(設定ファイル名, FileMode.Create);\r
13         //  xmlsl.Serialize(fs, this.アプリ設定);\r
14         //  fs.Close();\r
15         // \r
16         // 読み込み方法:\r
17         //   try\r
18         //   {\r
19         //       var xmlsl = new System.Xml.Serialization.XmlSerializer(typeof(AppSetting));\r
20         //       FileStream fs = new FileStream(設定ファイル名, FileMode.Open);\r
21         //       this.アプリ設定 = (AppSetting)xmlsl.Deserialize(fs);\r
22         //       fs.Close();\r
23         //   }\r
24         //   catch (Exception)\r
25         //   {\r
26         //       Debug.WriteLine("アプリ設定ファイルの読み込みに失敗しました。");\r
27         //       return;\r
28         //   }\r
29 \r
30         public class AppSetting\r
31         {\r
32                 #region [ コンストラクタ ]\r
33                 //-----------------\r
34                 public AppSetting()\r
35                 {\r
36                         this._SoundListColumnWidth[ 0 ] = 80;\r
37                         this._SoundListColumnWidth[ 1 ] = 28;\r
38                         this._SoundListColumnWidth[ 2 ] = 80;\r
39                         this._SoundListColumnWidth[ 3 ] = 40;\r
40                         this._SoundListColumnWidth[ 4 ] = 60;\r
41                         this._GraphicListColumnWidth[ 0 ] = 34;\r
42                         this._GraphicListColumnWidth[ 1 ] = 127;\r
43                         this._GraphicListColumnWidth[ 2 ] = 28;\r
44                         this._GraphicListColumnWidth[ 3 ] = 120;\r
45                         this._MovieListColumnWidth[ 0 ] = 127;\r
46                         this._MovieListColumnWidth[ 1 ] = 28;\r
47                         this._MovieListColumnWidth[ 2 ] = 120;\r
48                         this._LastWorkFolder = Directory.GetCurrentDirectory();\r
49                         this._ViewerInfo = new Viewer();\r
50                         this._InitialOperationMode = false;\r
51                 }\r
52                 //-----------------\r
53                 #endregion\r
54 \r
55                 // プロパティ(1) オプション項目関連\r
56 \r
57                 #region [ List<string> RecentUsedFile - 最近使ったファイル名のリスト ]\r
58                 //-----------------\r
59                 public List<string> RecentUsedFile\r
60                 {\r
61                         get { return _RecentUsedFile; }\r
62                         set { _RecentUsedFile = value; }\r
63                 }\r
64                 private List<string> _RecentUsedFile = new List<string>();\r
65                 //-----------------\r
66                 #endregion\r
67 \r
68                 public void AddRecentUsedFile( string fileName )\r
69                 {\r
70                         for( int i = 0; i < this._RecentUsedFile.Count; i++ )\r
71                         {\r
72                                 if( this._RecentUsedFile[ i ].Equals( fileName ) )\r
73                                 {\r
74                                         this._RecentUsedFile.RemoveAt( i );\r
75                                         break;\r
76                                 }\r
77                         }\r
78                         this._RecentUsedFile.Insert( 0, fileName );\r
79                         if( this._RecentUsedFile.Count > 10 )\r
80                         {\r
81                                 int num2 = this._RecentUsedFile.Count - 10;\r
82                                 for( int j = 0; j < num2; j++ )\r
83                                 {\r
84                                         this._RecentUsedFile.RemoveAt( 10 + j );\r
85                                 }\r
86                         }\r
87                 }\r
88 \r
89                 #region [ List<Lanes> LanesInfo - レーンの表示/非表示 ]\r
90                 //-----------------\r
91                 public List<Lanes> LanesInfo\r
92                 {\r
93                         get { return _LanesInfo; }\r
94                         set { _LanesInfo = value; }\r
95                 }\r
96                 private List<Lanes> _LanesInfo = new List<Lanes>();\r
97                 //-----------------\r
98                 #endregion\r
99 \r
100                 public void AddLanesInfo( string Name, bool Checked )\r
101                 {\r
102                         this._LanesInfo.Add( new Lanes( Name, Checked ) );\r
103                 }\r
104                 \r
105                 public bool bSameVersion()\r
106                 {\r
107                         return ( this._ConfigVersion == _ConfigSchemaVersion );\r
108                 }\r
109                 public void Confirm()\r
110                 {\r
111                         if( this._RecentFilesNum <= 0 )\r
112                         {\r
113                                 this._RecentFilesNum = 5;\r
114                                 this._ShowRecentFiles = false;\r
115                         }\r
116                         else if( this._RecentFilesNum > 10 )\r
117                         {\r
118                                 this._RecentFilesNum = 10;\r
119                         }\r
120                 }\r
121 \r
122                 public bool AutoFocus\r
123                 {\r
124                         get\r
125                         {\r
126                                 return this._AutoFocus;\r
127                         }\r
128                         set\r
129                         {\r
130                                 this._AutoFocus = value;\r
131                         }\r
132                 }\r
133                 public int ConfigVersion\r
134                 {\r
135                         get\r
136                         {\r
137                                 return this._ConfigVersion;\r
138                         }\r
139                         set\r
140                         {\r
141                                 this._ConfigVersion = value;\r
142                         }\r
143                 }\r
144                 public int[] GraphicListColumnWidth\r
145                 {\r
146                         get\r
147                         {\r
148                                 return this._GraphicListColumnWidth;\r
149                         }\r
150                         set\r
151                         {\r
152                                 this._GraphicListColumnWidth = value;\r
153                         }\r
154                 }\r
155                 public int GuideIndex\r
156                 {\r
157                         get\r
158                         {\r
159                                 return this._GuideIndex;\r
160                         }\r
161                         set\r
162                         {\r
163                                 this._GuideIndex = value;\r
164                                 if( this._GuideIndex < 0 )\r
165                                 {\r
166                                         this._GuideIndex = 0;\r
167                                 }\r
168                                 else if( this._GuideIndex > 8 )\r
169                                 {\r
170                                         this._GuideIndex = 8;\r
171                                 }\r
172                         }\r
173                 }\r
174                 public int Height\r
175                 {\r
176                         get\r
177                         {\r
178                                 return this._Height;\r
179                         }\r
180                         set\r
181                         {\r
182                                 this._Height = value;\r
183                                 if( this._Height < 0 )\r
184                                 {\r
185                                         this._Height = 10;\r
186                                 }\r
187                         }\r
188                 }\r
189                 public int HViewScaleIndex\r
190                 {\r
191                         get\r
192                         {\r
193                                 return this._HViewScaleIndex;\r
194                         }\r
195                         set\r
196                         {\r
197                                 this._HViewScaleIndex = value;\r
198                                 if( this._HViewScaleIndex < 0 )\r
199                                 {\r
200                                         this._HViewScaleIndex = 0;\r
201                                 }\r
202                                 else if( this._HViewScaleIndex > 9 )\r
203                                 {\r
204                                         this._HViewScaleIndex = 9;\r
205                                 }\r
206                         }\r
207                 }\r
208                 public string LastWorkFolder\r
209                 {\r
210                         get\r
211                         {\r
212                                 return this._LastWorkFolder;\r
213                         }\r
214                         set\r
215                         {\r
216                                 this._LastWorkFolder = value;\r
217                         }\r
218                 }\r
219                 public bool Maximized\r
220                 {\r
221                         get\r
222                         {\r
223                                 return this._Maximized;\r
224                         }\r
225                         set\r
226                         {\r
227                                 this._Maximized = value;\r
228                         }\r
229                 }\r
230                 public int[] MovieListColumnWidth\r
231                 {\r
232                         get\r
233                         {\r
234                                 return this._MovieListColumnWidth;\r
235                         }\r
236                         set\r
237                         {\r
238                                 this._MovieListColumnWidth = value;\r
239                         }\r
240                 }\r
241                 public bool NoPreviewBGM\r
242                 {\r
243                         get\r
244                         {\r
245                                 return this._NoPreviewBGM;\r
246                         }\r
247                         set\r
248                         {\r
249                                 this._NoPreviewBGM = value;\r
250                         }\r
251                 }\r
252                 public bool PlaySoundOnWAVChipAllocated\r
253                 {\r
254                         get\r
255                         {\r
256                                 return this._PlaySoundOnWAVChipAllocated;\r
257                         }\r
258                         set\r
259                         {\r
260                                 this._PlaySoundOnWAVChipAllocated = value;\r
261                         }\r
262                 }\r
263                 public int RecentFilesNum\r
264                 {\r
265                         get\r
266                         {\r
267                                 return this._RecentFilesNum;\r
268                         }\r
269                         set\r
270                         {\r
271                                 this._RecentFilesNum = value;\r
272                         }\r
273                 }\r
274                 public bool ShowRecentFiles\r
275                 {\r
276                         get\r
277                         {\r
278                                 return this._ShowRecentFiles;\r
279                         }\r
280                         set\r
281                         {\r
282                                 this._ShowRecentFiles = value;\r
283                         }\r
284                 }\r
285                 public int[] SoundListColumnWidth\r
286                 {\r
287                         get\r
288                         {\r
289                                 return this._SoundListColumnWidth;\r
290                         }\r
291                         set\r
292                         {\r
293                                 this._SoundListColumnWidth = value;\r
294                         }\r
295                 }\r
296                 public int SplitterDistance\r
297                 {\r
298                         get\r
299                         {\r
300                                 return this._SplitterDistance;\r
301                         }\r
302                         set\r
303                         {\r
304                                 this._SplitterDistance = value;\r
305                         }\r
306                 }\r
307                 public Viewer ViewerInfo\r
308                 {\r
309                         get\r
310                         {\r
311                                 return this._ViewerInfo;\r
312                         }\r
313                         set\r
314                         {\r
315                                 this._ViewerInfo = value;\r
316                         }\r
317                 }\r
318                 public int Width\r
319                 {\r
320                         get\r
321                         {\r
322                                 return this._Width;\r
323                         }\r
324                         set\r
325                         {\r
326                                 this._Width = value;\r
327                                 if( this._Width < 0 )\r
328                                 {\r
329                                         this._Width = 10;\r
330                                 }\r
331                         }\r
332                 }\r
333                 public int X\r
334                 {\r
335                         get\r
336                         {\r
337                                 return this._X;\r
338                         }\r
339                         set\r
340                         {\r
341                                 this._X = value;\r
342                         }\r
343                 }\r
344                 public int Y\r
345                 {\r
346                         get\r
347                         {\r
348                                 return this._Y;\r
349                         }\r
350                         set\r
351                         {\r
352                                 this._Y = value;\r
353                         }\r
354                 }\r
355 \r
356                 /// <summary>\r
357                 /// 操作モードの初期値\r
358                 /// false: 編集モード\r
359                 /// true:  選択モード\r
360                 /// </summary>\r
361                 public bool InitialOperationMode\r
362                 {\r
363                         get\r
364                         {\r
365                                 return this._InitialOperationMode;\r
366                         }\r
367                         set\r
368                         {\r
369                                 this._InitialOperationMode = value;\r
370                         }\r
371                 }\r
372 \r
373                 //public enum ViewerSoundType\r
374                 //{\r
375                 //    DirectSound,\r
376                 //    WASAPI,\r
377                 //    ASIO\r
378                 //}\r
379 \r
380                 public class Viewer\r
381                 {\r
382                         private const string PathDTXV = "DTXV.exe";\r
383                         private const string PathDTXM = "DTXManiaGR.exe";\r
384 \r
385                         public string Path = PathDTXM;\r
386                         public string PlayStartFromOption = "-N";\r
387                         public string PlayStartOption = "-N-1";\r
388                         public string PlayStopOption = "-S";\r
389                         // public ViewerSoundType SoundType = ( FDK.COS.bIsVistaOrLater ) ? ViewerSoundType.WASAPI : ViewerSoundType.DirectSound;\r
390                         public FDK.ESoundDeviceType SoundType = ( FDK.COS.bIsVistaOrLater ) ? FDK.ESoundDeviceType.ExclusiveWASAPI : FDK.ESoundDeviceType.DirectSound;\r
391                         public int ASIODeviceNo = 0;\r
392                         public bool GRmode;\r
393                         public bool TimeStretch;\r
394                         public bool VSyncWait = true;\r
395 \r
396                         // 引数無しのコンストラクタがないとSerializeできないのでダミー定義する\r
397                         public Viewer()\r
398                         {\r
399                                 Path = PathDTXM;\r
400                                 PlayStartFromOption = "-N";\r
401                                 PlayStartOption = "-N-1";\r
402                                 PlayStopOption = "-S";\r
403                                 //SoundType =  (FDK.COS.bIsVistaOrLater)? ViewerSoundType.WASAPI : ViewerSoundType.DirectSound;\r
404                                 SoundType = ( FDK.COS.bIsVistaOrLater ) ? FDK.ESoundDeviceType.ExclusiveWASAPI : FDK.ESoundDeviceType.DirectSound;\r
405                                 ASIODeviceNo = 0;\r
406                                 GRmode = false;\r
407                                 TimeStretch = false;\r
408                                 VSyncWait = true;\r
409                         }\r
410                         public bool bViewerIsDTXV\r
411                         {\r
412                                 get\r
413                                 {\r
414                                         return ( this.Path == PathDTXV );\r
415                                 }\r
416                                 set\r
417                                 {\r
418                                         this.Path = value ? PathDTXV : PathDTXM;\r
419                                 }\r
420                         }\r
421 \r
422                         public string PlaySoundOption\r
423                         {\r
424                                 get\r
425                                 {\r
426                                         string opt = "";\r
427                                         if ( bViewerIsDTXV )\r
428                                         {\r
429                                                 opt = "";\r
430                                         }\r
431                                         else\r
432                                         {\r
433                                                 string soundtypeopt = "";\r
434                                                 switch ( SoundType )\r
435                                                 {\r
436                                                         //case ViewerSoundType.DirectSound:\r
437                                                         case FDK.ESoundDeviceType.DirectSound:\r
438                                                                 soundtypeopt = "D";\r
439                                                                 break;\r
440                                                         //case ViewerSoundType.WASAPI:\r
441                                                         case FDK.ESoundDeviceType.ExclusiveWASAPI:\r
442                                                                 soundtypeopt = "W";\r
443                                                                 break;\r
444                                                         //case ViewerSoundType.ASIO:\r
445                                                         case FDK.ESoundDeviceType.ASIO:\r
446                                                                 soundtypeopt = "A";\r
447                                                                 soundtypeopt += ASIODeviceNo.ToString();\r
448                                                                 break;\r
449                                                 }\r
450 \r
451                                                 opt = "-D" + soundtypeopt;\r
452                                                 opt += GRmode     ? "Y" : "N";  // この辺は手抜き\r
453                                                 opt += TimeStretch? "Y" : "N";  //\r
454                                                 opt += VSyncWait  ? "Y" : "N";  //\r
455                                         }\r
456                                         return opt;\r
457                                 }\r
458                         }\r
459                 }\r
460 \r
461                 /// <summary>\r
462                 /// レーン名と表示/非表示の状態の保持/復元\r
463                 /// </summary>\r
464                 public class Lanes\r
465                 {\r
466                         public string Name;\r
467                         public bool Checked;\r
468 \r
469                         // 引数無しのコンストラクタがないとSerializeできないのでダミー定義する\r
470                         public Lanes()\r
471                         {\r
472                                 Name = "";\r
473                                 Checked = false;\r
474                         }\r
475                         public Lanes( string Name_, bool Checked_ )\r
476                         {\r
477                                 Name = Name_;\r
478                                 Checked = Checked_;\r
479                         }\r
480                 }\r
481 \r
482                 #region [ private ]\r
483                 //-----------------\r
484                 private bool _AutoFocus = true;\r
485                 private static int _ConfigSchemaVersion = 0x69;\r
486                 private int _ConfigVersion = _ConfigSchemaVersion;\r
487                 private int[] _GraphicListColumnWidth = new int[ 4 ];\r
488                 private int _GuideIndex = 3;\r
489                 private int _Height = 0x1db;\r
490                 private int _HViewScaleIndex;\r
491                 private string _LastWorkFolder = "";\r
492                 private bool _Maximized;\r
493                 private int[] _MovieListColumnWidth = new int[ 3 ];\r
494                 private bool _NoPreviewBGM = true;\r
495                 private bool _PlaySoundOnWAVChipAllocated = true;\r
496                 private int _RecentFilesNum = 5;\r
497                 private bool _ShowRecentFiles = true;\r
498                 private int[] _SoundListColumnWidth = new int[ 5 ];\r
499                 private int _SplitterDistance = 0x128;\r
500                 private Viewer _ViewerInfo;\r
501                 private int _Width = 600;\r
502                 private int _X;\r
503                 private int _Y;\r
504                 private bool _InitialOperationMode;\r
505                 //-----------------\r
506                 #endregion\r
507         }\r
508 }\r