コード例 #1
0
ファイル: Program.cs プロジェクト: mengtest/FlatTable
        public static void Main(string[] args)
        {
            TableLoader.fileLoadPath = @"D:\CSProjects\FlatTable\FlatTable\Test\BinaryFile";
            TableLoader.Load <TestTable>();
            TableLoader.Load <AnotherTestTable>();

            if (AnotherTestTable.ins == null)
            {
                return;
            }
            List <AnotherTestTable.Value> valueList = AnotherTestTable.ins.list;

            for (int i = 0; i < valueList.Count; i++)
            {
                Debug.WriteLine(valueList[i].id);
                Debug.WriteLine(valueList[i].hero_name);
                Debug.WriteLine(valueList[i].speed);
                Debug.WriteLine(valueList[i].damage);
                Debug.WriteLine(valueList[i].is_lock);

                for (int j = 0; j < valueList[i].resource.Length; j++)
                {
                    Debug.WriteLine(valueList[i].resource[j]);
                }
            }
        }
コード例 #2
0
ファイル: LoadTest.cs プロジェクト: mengtest/FlatTable
    private void LoadFromStreamingAssetsFolder()
    {
        TableLoader.loadType     = LoadType.FilePath;
        TableLoader.fileLoadPath = Application.streamingAssetsPath + "/Table";
        TableLoader.Load <AnotherTestTable>();

        if (AnotherTestTable.ins == null)
        {
            return;
        }
        List <AnotherTestTable.Value> valueList = AnotherTestTable.ins.list;

        for (int i = 0; i < valueList.Count; i++)
        {
            Debug.Log(valueList[i].id);
            Debug.Log(valueList[i].hero_name);
            Debug.Log(valueList[i].speed);
            Debug.Log(valueList[i].damage);
            Debug.Log(valueList[i].is_lock);

            for (int j = 0; j < valueList[i].resource.Length; j++)
            {
                Debug.Log(valueList[i].resource[j]);
            }
        }
    }
コード例 #3
0
        /// <summary>
        /// Gets the table. If <see cref="Owner" /> is specified, it is used.
        /// </summary>
        /// <param name="tableName">Name of the table. Oracle names can be case sensitive.</param>
        /// <param name="ct">The ct.</param>
        public DatabaseTable Table(string tableName, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentNullException("tableName");
            }

            var loader  = new TableLoader(_schemaReader, DatabaseSchema);
            var handler = ReaderProgress;

            if (handler != null)
            {
                loader.ReaderProgress += RaiseReadingProgress;
            }
            var table = loader.Load(tableName, ct);

            if (ct.IsCancellationRequested)
            {
                return(table);
            }

            if (DatabaseSchema.DataTypes.Count > 0)
            {
                DatabaseSchemaFixer.UpdateDataTypes(DatabaseSchema);
            }
            _schemaReader.PostProcessing(DatabaseSchema);

            return(table);
        }
コード例 #4
0
        public void TryingToLoadUnregisteredTagReturnsUnknownTable()
        {
            TableLoader loader = new TableLoader();

            string tag    = Guid.NewGuid().ToString();
            Table  result = loader.Load(tag, null);

            UnknownTable table = Assert.IsType <UnknownTable>(result);

            Assert.Equal(tag, table.Name);
        }
コード例 #5
0
    public static T GetDeploy <T>(int id) where T : BaseDeploy
    {
        Type type = typeof(T);

        object[] attributes = type.GetCustomAttributes(false);
        for (int i = 0; i < attributes.Length; i++)
        {
            if (attributes[i] is Deploy)
            {
                Deploy deploy = (Deploy)attributes[i];
                return(TableLoader.Load <T>(deploy.path, id));
            }
        }

        return(null);
    }
コード例 #6
0
        static void Main(string[] args)
        {
            // validate inputs
            try {
                if (args.Length < 1)
                {
                    throw new ArgumentException("USAGE: VisualPinball.TableScript <input file or folder> [<output folder>]");
                }

                // input file(s)
                if (!FileOrDirectoryExists(args[0]))
                {
                    throw new ArgumentException($"Non-existent input path: \"{args[0]}\".");
                }
                var inputAttr  = File.GetAttributes(args[0]);
                var inputFiles = (inputAttr & FileAttributes.Directory) == FileAttributes.Directory
                                        ? Directory.GetFiles(args[0], "*.vpx")
                                        : new[] { args[0] };
                if (inputFiles.Length == 0)
                {
                    throw new ArgumentException($"No .vpx files found at \"{args[0]}\"");
                }

                // output folder
                string outputDir = null;

                if (args.Length > 1)
                {
                    outputDir = args[1];
                    if (!Directory.Exists(outputDir))
                    {
                        throw new ArgumentException($"Invalid output folder \"{outputDir}\".");
                    }
                }

                foreach (var inputFile in inputFiles)
                {
                    Console.WriteLine($"Processing \"{inputFile}\"...");

                    var inputTable = TableLoader.Load(inputFile, false);

                    var code = inputTable.Data.Code;

                    if (Environment.NewLine == "\n")
                    {
                        code = code.Replace("\r\r\n", "\n");
                        code = code.Replace("\r\n", "\n");
                        code = code.Replace("\r", "\n");
                    }

                    if (outputDir != null)
                    {
                        var outputFilePath = Path.Join(outputDir, Path.GetFileNameWithoutExtension(inputFile) + ".vbs");

                        File.WriteAllText(outputFilePath, code);
                    }
                    else
                    {
                        Console.WriteLine(code);
                    }
                }
            } catch (ArgumentException e) {
                Console.WriteLine(e.Message);
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
コード例 #7
0
        static void Main(string[] args)
        {
            // validate inputs
            try {
                if (args.Length != 3)
                {
                    throw new ArgumentException("USAGE: VisualPinball.MaterialPatcher.exe <.mat file> <input file or folder> <output folder>");
                }

                // material file
                var materialFile = args[0];
                if (!File.Exists(materialFile))
                {
                    throw new ArgumentException($"Cannot find material file at \"{materialFile}\"");
                }

                // input file(s)
                if (!FileOrDirectoryExists(args[1]))
                {
                    throw new ArgumentException($"Non-existent input path: \"{args[1]}\".");
                }
                var inputAttr  = File.GetAttributes(args[1]);
                var inputFiles = (inputAttr & FileAttributes.Directory) == FileAttributes.Directory
                                        ? Directory.GetFiles(args[1], "*.vpx")
                                        : new[] { args[1] };
                if (inputFiles.Length == 0)
                {
                    throw new ArgumentException($"No .vpx files found at \"{args[1]}\"");
                }

                // output folder
                var outputDir = args[2];
                if (!Directory.Exists(outputDir))
                {
                    throw new ArgumentException($"Invalid output folder \"{outputDir}\".");
                }

                // read materials
                var inputMaterials = MaterialReader.Load(materialFile).ToArray();
                Console.WriteLine($"Looking for materials: [ {string.Join(", ", inputMaterials.Select(m => m.Name))} ]");


                // apply materials to each table
                var stopWatch = new Stopwatch();
                foreach (var inputFile in inputFiles)
                {
                    stopWatch.Start();
                    var outputFilePath = Path.Join(outputDir, Path.GetFileName(inputFile));
                    Console.WriteLine($"Processing \"{inputFile}\"...");

                    var inputTable   = TableLoader.Load(inputFile);
                    var numMaterials = 0;
                    foreach (var inputMaterial in inputMaterials)
                    {
                        var outputMaterial = inputTable.GetMaterial(inputMaterial.Name);
                        if (outputMaterial != null)
                        {
                            outputMaterial.BaseColor         = inputMaterial.BaseColor;
                            outputMaterial.ClearCoat         = inputMaterial.ClearCoat;
                            outputMaterial.EdgeAlpha         = inputMaterial.EdgeAlpha;
                            outputMaterial.Elasticity        = inputMaterial.Elasticity;
                            outputMaterial.ElasticityFalloff = inputMaterial.ElasticityFalloff;
                            outputMaterial.Friction          = inputMaterial.Friction;
                            outputMaterial.Glossiness        = inputMaterial.Glossiness;
                            outputMaterial.GlossyImageLerp   = inputMaterial.GlossyImageLerp;
                            outputMaterial.IsMetal           = inputMaterial.IsMetal;
                            outputMaterial.IsOpacityActive   = inputMaterial.IsOpacityActive;
                            outputMaterial.Opacity           = inputMaterial.Opacity;
                            outputMaterial.Roughness         = inputMaterial.Roughness;
                            outputMaterial.ScatterAngle      = inputMaterial.ScatterAngle;
                            outputMaterial.Thickness         = inputMaterial.Thickness;
                            outputMaterial.WrapLighting      = inputMaterial.WrapLighting;
                            outputMaterial.UpdateData();
                            numMaterials++;
                        }
                    }

                    new TableWriter(inputTable).WriteTable(outputFilePath);
                    Console.WriteLine($"Written to \"{outputFilePath}\" with {numMaterials} updated materials in {stopWatch.ElapsedMilliseconds}ms.");

                    stopWatch.Stop();
                    stopWatch.Reset();
                }
            } catch (ArgumentException e) {
                Console.WriteLine(e.Message);
            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }