OSDN Git Service

refactored
authornomeu <nomeu@72ae2088-5f33-de11-a17b-0000e250a282>
Mon, 2 Jan 2012 04:43:21 +0000 (04:43 +0000)
committernomeu <nomeu@72ae2088-5f33-de11-a17b-0000e250a282>
Mon, 2 Jan 2012 04:43:21 +0000 (04:43 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tdcgexplorer/trunk/tso2mqo@2080 72ae2088-5f33-de11-a17b-0000e250a282

Form1.cs
Program.cs
TSOGenerator.cs
TSOGeneratorConfig.cs [moved from TSOGenerateConfig.cs with 79% similarity]
Tso2MqoGui.csproj

index 7538984..31494bb 100644 (file)
--- a/Form1.cs
+++ b/Form1.cs
@@ -235,18 +235,18 @@ namespace Tso2MqoGui
 \r
         private void OpenMQOFile(string file)\r
         {\r
-            TSOGenerateConfig config = new TSOGenerateConfig();\r
+            TSOGeneratorConfig config = new TSOGeneratorConfig();\r
             config.ShowMaterials = cbShowMaterials.Checked;\r
 \r
             if (rbRefBone.Checked)\r
             {\r
-                TSOGeneratorRefBone gen = new TSOGeneratorRefBone();\r
-                gen.Generate(file, tbTso.Text, tbTsoEx.Text, config);\r
+                TSOGeneratorRefBone gen = new TSOGeneratorRefBone(config);\r
+                gen.Generate(file, tbTso.Text, tbTsoEx.Text);\r
             }\r
             else\r
             if (rbOneBone.Checked)\r
             {\r
-                TSOGeneratorOneBone gen = new TSOGeneratorOneBone();\r
+                TSOGeneratorOneBone gen = new TSOGeneratorOneBone(config);\r
 \r
                 foreach (ListViewItem i in lvObject.Items)\r
                 {\r
@@ -259,7 +259,7 @@ namespace Tso2MqoGui
                     gen.ObjectBoneNames.Add(i.SubItems[0].Text, i.SubItems[1].Text);\r
                 }\r
 \r
-                gen.Generate(file, tbTso.Text, tbTsoEx.Text, config);\r
+                gen.Generate(file, tbTso.Text, tbTsoEx.Text);\r
             }\r
             else\r
             {\r
index ee96868..4351f3e 100644 (file)
@@ -14,46 +14,48 @@ namespace Tso2MqoGui
         [STAThread]\r
         static int Main(string[] args)\r
         {\r
-            if(args.Length != 0)\r
+            if (args.Length != 0)\r
             {   // バッチで処理する\r
                 try\r
                 {\r
-                    string  tso = null;\r
-                    string  mqo = null;\r
-                    string  rtso= null;\r
+                    string tso = null;\r
+                    string mqo = null;\r
+                    string tsoref = null;\r
 \r
-                    foreach(string i in args)\r
+                    foreach (string i in args)\r
                     {\r
-                        string  o   = i.ToLower();\r
+                        string o = i.ToLower();\r
 \r
-                        switch(o)\r
+                        switch (o)\r
                         {\r
-                        default:\r
-                                 if(o.StartsWith("-tso:"))  tso = o.Substring(5).Trim('\r', '\n');\r
-                            else if(o.StartsWith("-mqo:"))  mqo = o.Substring(5).Trim('\r', '\n');\r
-                            else if(o.StartsWith("-ref:"))  rtso= o.Substring(5).Trim('\r', '\n');\r
-                            else throw new ArgumentException("Invalid option: " + i);\r
-                            break;\r
+                            default:\r
+                                if (o.StartsWith("-tso:")) tso = o.Substring(5).Trim('\r', '\n');\r
+                                else if (o.StartsWith("-mqo:")) mqo = o.Substring(5).Trim('\r', '\n');\r
+                                else if (o.StartsWith("-ref:")) tsoref = o.Substring(5).Trim('\r', '\n');\r
+                                else throw new ArgumentException("Invalid option: " + i);\r
+                                break;\r
                         }\r
                     }\r
 \r
-                    TSOGeneratorRefBone        gen     = new TSOGeneratorRefBone();\r
-                    TSOGenerateConfig   config  = new TSOGenerateConfig();\r
-                    config.cui                  = true;\r
-                    config.ShowMaterials       = false;\r
+                    TSOGeneratorConfig config = new TSOGeneratorConfig();\r
+                    config.cui = true;\r
+                    config.ShowMaterials = false;\r
+                    TSOGeneratorRefBone gen = new TSOGeneratorRefBone(config);\r
 \r
-                    if(mqo  == null) throw new ArgumentException("「-mso:ファイル名」の形式で入力Mqoファイル名を指定してください");\r
-                    if(tso  == null) throw new ArgumentException("「-tso:ファイル名」の形式で出力Tsoファイル名を指定してください");\r
-                    if(rtso == null) throw new ArgumentException("「-ref:ファイル名」の形式で参照Tsoファイル名を指定してください");\r
+                    if (mqo == null) throw new ArgumentException("「-mso:ファイル名」の形式で入力Mqoファイル名を指定してください");\r
+                    if (tso == null) throw new ArgumentException("「-tso:ファイル名」の形式で出力Tsoファイル名を指定してください");\r
+                    if (tsoref == null) throw new ArgumentException("「-ref:ファイル名」の形式で参照Tsoファイル名を指定してください");\r
 \r
-                    gen.Generate(mqo, rtso, tso, config);\r
-                } catch(ArgumentException e)\r
+                    gen.Generate(mqo, tsoref, tso);\r
+                }\r
+                catch (ArgumentException e)\r
                 {\r
                     System.Diagnostics.Debug.WriteLine(e.Message);\r
                     System.Console.Out.WriteLine(e.Message);\r
                     System.Console.Out.Flush();\r
                     return 1;\r
-                } catch(Exception e)\r
+                }\r
+                catch (Exception e)\r
                 {\r
                     System.Diagnostics.Debug.WriteLine(e.Message);\r
                     System.Console.Out.WriteLine(e.Message);\r
index 6a7ef56..15efd0f 100644 (file)
@@ -12,16 +12,21 @@ namespace Tso2MqoGui
 {\r
     public abstract class TSOGenerator\r
     {\r
-        private string                      dir;\r
-        private TSOGenerateConfig           config;\r
-        protected MqoFile                     mqo;\r
-        protected TSOFile                     tsor;\r
+        private string dir;\r
+        private TSOGeneratorConfig config;\r
+        protected MqoFile mqo;\r
+        protected TSOFile tsor;\r
         protected Dictionary<string, TSONode> nodes;\r
-        protected List<TSOMesh>               meshes;\r
-        private ImportInfo                  ii;\r
-        private BinaryWriter                bw;\r
-        protected Dictionary<string, MaterialInfo>    materials;\r
-        private Dictionary<string, TextureInfo>     textures;\r
+        protected List<TSOMesh> meshes;\r
+        private ImportInfo ii;\r
+        private BinaryWriter bw;\r
+        protected Dictionary<string, MaterialInfo> materials;\r
+        private Dictionary<string, TextureInfo> textures;\r
+\r
+        public TSOGenerator(TSOGeneratorConfig config)\r
+        {\r
+            this.config = config;\r
+        }\r
 \r
         public TSOFile  LoadTSO(string file)\r
         {\r
@@ -272,7 +277,6 @@ namespace Tso2MqoGui
             tsor        = null;\r
             nodes       = null;\r
             meshes      = null;\r
-            config      = null;\r
             mqo         = null;\r
             ii          = null;\r
             bw          = null;\r
@@ -283,9 +287,8 @@ namespace Tso2MqoGui
             return true;\r
         }\r
 \r
-        public void Generate(string mqoin, string tsoref, string tsoex, TSOGenerateConfig config)\r
+        public void Generate(string mqoin, string tsoref, string tsoex)\r
         {\r
-            this.config = config;\r
             string importinfo_file = Path.ChangeExtension(mqoin, ".xml");\r
 \r
             try\r
@@ -425,6 +428,11 @@ namespace Tso2MqoGui
     {\r
         public Dictionary<string, string> ObjectBoneNames = new Dictionary<string, string>();\r
 \r
+        public TSOGeneratorOneBone(TSOGeneratorConfig config)\r
+            : base(config)\r
+        {\r
+        }\r
+\r
         protected override bool DoLoadRefTSO(string tsoref)\r
         {\r
             // 参照TSOロード\r
@@ -533,8 +541,13 @@ namespace Tso2MqoGui
     \r
     public unsafe class TSOGeneratorRefBone : TSOGenerator\r
     {\r
-        private List<Vertex>                vlst;\r
-        private PointCluster                pc;\r
+        private List<Vertex> vlst;\r
+        private PointCluster pc;\r
+\r
+        public TSOGeneratorRefBone(TSOGeneratorConfig config)\r
+            : base(config)\r
+        {\r
+        }\r
 \r
         private void CreatePointCluster(TSOFile tso)\r
         {\r
similarity index 79%
rename from TSOGenerateConfig.cs
rename to TSOGeneratorConfig.cs
index c7031d3..78a8db8 100644 (file)
@@ -4,7 +4,7 @@ using System.Text;
 \r
 namespace Tso2MqoGui\r
 {\r
-    public class TSOGenerateConfig\r
+    public class TSOGeneratorConfig\r
     {\r
         public bool ShowMaterials = false;\r
         public bool cui = false;\r
index c2fe50c..aab76d5 100644 (file)
@@ -1,4 +1,4 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">\r
   <PropertyGroup>\r
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
     <Compile Include="RDBBonFile.cs" />\r
     <Compile Include="TDCGFile.cs" />\r
     <Compile Include="TSOFile.cs" />\r
-    <Compile Include="TSOGenerateConfig.cs" />\r
+    <Compile Include="TSOGeneratorConfig.cs" />\r
     <Compile Include="TSOGenerator.cs" />\r
     <Compile Include="TSOWriter.cs" />\r
     <Compile Include="VertexHeap.cs" />\r
   <Target Name="AfterBuild">\r
   </Target>\r
   -->\r
-</Project>\r
+</Project>
\ No newline at end of file