コード例 #1
0
        public void Init(IntersectionTemplate template)
        {
            Screenshot.texture     = template.HasPreview ? template.Preview : Empty;
            NoScreenshot.isVisible = !template.HasPreview;

            Roads.text      = template.Roads.ToString();
            Lines.text      = template.Lines.ToString();
            Crosswalks.text = template.Crosswalks.ToString();
            Fillers.text    = template.Fillers.ToString();

            for (var i = 0; i < template.Enters.Length; i += 1)
            {
                Temp.Add(AddTitleData(string.Format(NodeMarkup.Localize.PresetInfo_RoadPoints, i + 1)));
                Temp.Add(AddValueData(template.Enters[i].Points.ToString()));
            }

            Titles.autoLayout = true;
            Titles.autoLayout = false;
            Titles.FitChildrenVertically();
            Values.autoLayout = true;
            Values.autoLayout = false;
            Values.FitChildrenVertically();

            Init();
        }
コード例 #2
0
ファイル: Loader.cs プロジェクト: MacSergey/NodeMarkup
        public static bool LoadScreenshot(IntersectionTemplate template, out Image image)
        {
            try
            {
                var path = Path.Combine(ScreenshotDirectory, $"{template.Id}.png");

                if (File.Exists(path))
                {
                    var data = File.ReadAllBytes(path);
                    image = new Image(data);
                    return(true);
                }
                else
                {
                    SingletonMod <Mod> .Logger.Debug($"Could not load screenshot for template \"{template}\", file {path} not exist");

                    image = null;
                    return(false);
                }
            }
            catch (Exception error)
            {
                SingletonMod <Mod> .Logger.Error($"Could not load screenshot for template \"{template}\"", error);

                image = null;
                return(false);
            }
        }
コード例 #3
0
        public void Init(IntersectionTemplate template)
        {
            Screenshot.texture     = template.HasPreview ? template.Preview : Empty;
            NoScreenshot.isVisible = !template.HasPreview;

            var titlesText = new List <string>();
            var valuesText = new List <string>();

            titlesText.Add(NodeMarkup.Localize.PresetInfo_Roads);
            valuesText.Add(template.Roads.ToString());
            titlesText.Add(NodeMarkup.Localize.PresetInfo_Lines);
            valuesText.Add(template.Lines.ToString());
            titlesText.Add(NodeMarkup.Localize.PresetInfo_Crosswalks);
            valuesText.Add(template.Crosswalks.ToString());
            titlesText.Add(NodeMarkup.Localize.PresetInfo_Fillers);
            valuesText.Add(template.Fillers.ToString());

            for (var i = 0; i < template.Enters.Length; i += 1)
            {
                titlesText.Add(string.Format(NodeMarkup.Localize.PresetInfo_RoadPoints, i + 1));
                valuesText.Add(template.Enters[i].PointCount.ToString());
            }

            Titles.text = string.Join("\n", titlesText.ToArray());
            Values.text = string.Join("\n", valuesText.ToArray());

            Init();
        }
コード例 #4
0
ファイル: Loader.cs プロジェクト: MacSergey/NodeMarkup
        public static bool SaveScreenshot(IntersectionTemplate template, Image image)
        {
            try
            {
                if (!Directory.Exists(ScreenshotDirectory))
                {
                    Directory.CreateDirectory(ScreenshotDirectory);
                }

                var data = image.GetFormattedImage(Image.BufferFileFormat.PNG);
                var path = Path.Combine(ScreenshotDirectory, $"{template.Id}.png");
                File.WriteAllBytes(path, data);
                return(true);
            }
            catch (Exception error)
            {
                SingletonMod <Mod> .Logger.Error($"Could not save screenshot for template \"{template}\"", error);

                return(false);
            }
        }
コード例 #5
0
 public void EditIntersectionTemplate(IntersectionTemplate template, bool editName = true) => EditTemplate <IntersectionTemplateEditor, IntersectionTemplate>(template, editName);