private string GetProgrammableBlock(string data, string name, int width, int height, int fps, bool multiblockMode = false)
 {
     return(BaseBody
            .Replace("{args}", multiblockMode ? "" : "animate:{fps}:0:{name}")
            .Replace("{name}", name)
            .Replace("{width}", width.ToString())
            .Replace("{height}", height.ToString())
            .Replace("{fps}", fps.ToString())
            .Replace("{size}", GridSize.ToString())
            .Replace("{customData}", name)
            .Replace("{loop}", (!multiblockMode).ToString().ToLower())
            .Replace("{visible}", (!multiblockMode).ToString().ToLower())
            .Replace("{customData}", name)
            .Replace("{data}", data));
 }
        public void GridSizeToString()
        {
            var size = new GridSize(5, 10);

            var expected = "5, 10";
            var actual   = size.ToString();

            Assert.AreEqual(expected, actual);
        }
        public override void Convert()
        {
            MagickImage image         = Converter.MyPreviewImage;
            string      blueprintPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/SpaceEngineers/Blueprints/local/" + BlueprintName;

            Directory.CreateDirectory(blueprintPath);
            image.Write(blueprintPath + "/thumb.png");
            StreamWriter text = File.CreateText(blueprintPath + "/bp.sbc");

            text.Write(Header.Replace("{size}", GridSize.ToString()).Replace("{name}", BlueprintName));

            using var c = image.GetPixelsUnsafe();
            for (int y = 0; y < image.Height; y++)
            {
                for (int x = 0; x < image.Width; x++)
                {
                    var      p = c.GetPixel(x, y).ToColor();
                    double[] b = ConvertRGB2SE(p.ToByteArray());
                    if (p.A > 100)
                    {
                        text.Write(Cube
                                   .Replace("{size}", GridSize.ToString())
                                   .Replace("{x}", x.ToString())
                                   .Replace("{y}", "-" + y.ToString())
                                   .Replace("{h}", b[0].ToString())
                                   .Replace("{s}", b[1].ToString())
                                   .Replace("{v}", b[2].ToString())
                                   .Replace(",", "."));
                    }
                }
            }
            c.Dispose();

            text.Write(Footer.Replace("{name}", BlueprintName));
            text.Close();
        }
Exemple #4
0
    public void CreateGrid(GridSize gridSize)
    {
        this.gridSize = gridSize;
        if (gridSize == GridSize.Small)
        {
            CreateGrid(gridSizeSmall, gridSizeSmall);
        }
        else if (gridSize == GridSize.Medium)
        {
            CreateGrid(gridSizeMedium, gridSizeMedium);
        }
        else if (gridSize == GridSize.Large)
        {
            CreateGrid(gridSizeLarge, gridSizeLarge);
        }
        else
        {
            Debug.LogError("Unknown grid size: " + gridSize.ToString());
        }

        cameraManager.SetSize(width, height);
    }
        public static string ToDescriptionString(this GridSize val)
        {
            var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
        }
 public string GetSelectedGridSizeText()
 {
     return(GridSize.ToString());
 }