OSDN Git Service

refactored
[tdcgexplorer/tso2mqo.git] / Program.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.IO;\r
4 using System.Text;\r
5 using System.Windows.Forms;\r
6 \r
7 namespace Tso2MqoGui\r
8 {\r
9     static class Program\r
10     {\r
11         /// <summary>\r
12         /// アプリケーションのメイン エントリ ポイントです。\r
13         /// </summary>\r
14         [STAThread]\r
15         static int Main(string[] args)\r
16         {\r
17             if (args.Length != 0)\r
18             {   // バッチで処理する\r
19                 try\r
20                 {\r
21                     string tso = null;\r
22                     string mqo = null;\r
23                     string tsoref = null;\r
24 \r
25                     foreach (string i in args)\r
26                     {\r
27                         string o = i.ToLower();\r
28 \r
29                         switch (o)\r
30                         {\r
31                             default:\r
32                                 if (o.StartsWith("-tso:")) tso = o.Substring(5).Trim('\r', '\n');\r
33                                 else if (o.StartsWith("-mqo:")) mqo = o.Substring(5).Trim('\r', '\n');\r
34                                 else if (o.StartsWith("-ref:")) tsoref = o.Substring(5).Trim('\r', '\n');\r
35                                 else throw new ArgumentException("Invalid option: " + i);\r
36                                 break;\r
37                         }\r
38                     }\r
39 \r
40                     TSOGeneratorConfig config = new TSOGeneratorConfig();\r
41                     config.cui = true;\r
42                     config.ShowMaterials = false;\r
43                     TSOGeneratorRefBone gen = new TSOGeneratorRefBone(config);\r
44 \r
45                     if (mqo == null) throw new ArgumentException("「-mso:ファイル名」の形式で入力Mqoファイル名を指定してください");\r
46                     if (tso == null) throw new ArgumentException("「-tso:ファイル名」の形式で出力Tsoファイル名を指定してください");\r
47                     if (tsoref == null) throw new ArgumentException("「-ref:ファイル名」の形式で参照Tsoファイル名を指定してください");\r
48 \r
49                     gen.Generate(mqo, tsoref, tso);\r
50                 }\r
51                 catch (ArgumentException e)\r
52                 {\r
53                     System.Diagnostics.Debug.WriteLine(e.Message);\r
54                     System.Console.Out.WriteLine(e.Message);\r
55                     System.Console.Out.Flush();\r
56                     return 1;\r
57                 }\r
58                 catch (Exception e)\r
59                 {\r
60                     System.Diagnostics.Debug.WriteLine(e.Message);\r
61                     System.Console.Out.WriteLine(e.Message);\r
62                     System.Console.Out.Flush();\r
63                     return 1;\r
64                 }\r
65 \r
66                 return 0;\r
67             }\r
68 \r
69             Application.EnableVisualStyles();\r
70             Application.SetCompatibleTextRenderingDefault(false);\r
71             Application.Run(new Form1());\r
72 \r
73             return 0;\r
74         }\r
75     }\r
76 }\r