private void GenerateSceneFile()
        {
            string[]       rowData;
            TileMapBuilder tb = new TileMapBuilder();

            if (CSVString.Text.Trim() != "")
            {
                rowData = CSVString.Text.Trim().Split('|');
            }
            else if (CSVImport.Text.Trim() != "")
            {
                rowData = File.ReadAllLines(CSVImport.Text.Trim());
            }
            else
            {
                rowData = null;
            }

            try
            {
                tb.SetMapData(tb.TransformInputData(rowData));
            }
            catch (Exception e)
            {
                MessageBox.Show($"Failed: {e.Message}");
            }

            string sceneFile = tb
                               .SetCellSizePixels(uint.Parse(CellWidth.Text), uint.Parse(CellHeight.Text))
                               .SetTileSheetSizeUnits(uint.Parse(UnitWidth.Text), uint.Parse(UnitHeight.Text))
                               .SetTileSheetStartIndex(uint.Parse(StartCellIndex.Text))
                               .SetTileSheet(ImportSheet.Text)
                               .SetFormat(int.Parse(InternalFormat.Text))
                               .SetLoadSteps(int.Parse(InternalSteps.Text))
                               .SetNodeType(InternalMapClass.Text)
                               .SetTileSetType(InternalTileClass.Text)
                               .SetGodotTileWidth(uint.Parse(InternalMapWidth.Text))
                               .SetMapDataEmptyCellIndex(int.Parse(MapIgnoreCell.Text))
                               .SetNodeName(NodeName.Text)
                               .Build();

            try
            {
                File.WriteAllText(OutFile.Text, sceneFile);
                MessageBox.Show($"File written to:\n {OutFile.Text}");
            }
            catch (Exception e)
            {
                MessageBox.Show($"Failed to write output file: {OutFile.Text}\n\n{e.Message}");
            }
        }
        /// <summary>
        /// Sample command line program to use the tilemap builder
        /// Will take various input values and create a scene file for a tileset and tilemap.
        /// If no parameters are supplied, help with be shown.
        ///
        /// Usage:
        /// <code>TileMapConsole -out myfile.tscn -ir spritesheet.png -cw 10 -ch 10</code>
        /// </summary>
        /// <param name="args">Refer to DisplayHelp</param>
        static void Main(string[] args)
        {
            Header();

            try
            {
                string sceneFormat    = GetArgument(args, "-sf");
                string loadSteps      = GetArgument(args, "-ls");
                string nodeType       = GetArgument(args, "-nt");
                string setType        = GetArgument(args, "-st");
                string cellIndex      = GetArgument(args, "-ci");
                string nodeName       = GetArgument(args, "-nn");
                string cellWidth      = GetArgument(args, "-cw");
                string cellHeight     = GetArgument(args, "-ch");
                string imageWidth     = GetArgument(args, "-iw");
                string imageHeight    = GetArgument(args, "-ih");
                string imageFile      = GetArgument(args, "-ir");
                string godotWidth     = GetArgument(args, "-gw");
                string mapIgnoreIndex = GetArgument(args, "-ms");
                string csvData        = GetArgument(args, "-csd");
                string csvFile        = GetArgument(args, "-csv");
                string outFile        = GetArgument(args, "-out");

                if (outFile == null || ((csvData != null && csvFile != null)))
                {
                    throw new Exception("An output file and either CSV data or a CSV file must be supplied, as follows");
                }

                TileMapBuilder tb = new TileMapBuilder();

                if (sceneFormat != null)
                {
                    tb.SetFormat(Convert.ToInt32(sceneFormat));
                }
                if (loadSteps != null)
                {
                    tb.SetLoadSteps(Convert.ToInt32(loadSteps));
                }
                if (nodeType != null)
                {
                    tb.SetNodeType(nodeType);
                }
                if (setType != null)
                {
                    tb.SetTileSetType(setType);
                }
                if (nodeName != null)
                {
                    tb.SetNodeName(nodeName);
                }
                if (cellIndex != null)
                {
                    tb.SetTileSheetStartIndex(Convert.ToUInt32(cellIndex));
                }
                if (cellHeight != null || cellWidth != null)
                {
                    //will error if either not supplied
                    tb.SetCellSizePixels(Convert.ToUInt32(cellWidth), Convert.ToUInt32(cellHeight));
                }
                if (imageWidth != null | imageHeight != null)
                {
                    tb.SetTileSheetSizeUnits(Convert.ToUInt32(imageWidth), Convert.ToUInt32(imageHeight));
                }
                if (imageFile != null)
                {
                    tb.SetTileSheet(imageFile);
                }
                if (godotWidth != null)
                {
                    tb.SetGodotTileWidth(Convert.ToUInt32(godotWidth));
                }
                if (mapIgnoreIndex != null)
                {
                    tb.SetMapDataEmptyCellIndex(Convert.ToInt32(mapIgnoreIndex));
                }

                try
                {
                    int[,] data = GetInputData(tb, csvData, csvFile);
                    tb.SetMapData(data);

                    string sceneFile = tb.Build();
                    Console.WriteLine(sceneFile);
                    File.WriteAllText(outFile, sceneFile);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed: {e.Message}");
                }
                //Console.ReadKey();
                Console.WriteLine($"Success. Scene file written to {outFile}");
            }
            catch (Exception e)
            {
                DisplayHelp(e.Message);
            }
        }