Esempio n. 1
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(GetSerializedVersion(container.ExportVersion));
            node.Add(LineSpacingName, LineSpacing);
            node.Add(DefaultMaterialName, DefaultMaterial.ExportYAML(container));
            node.Add(FontSizeName, FontSize);
            node.Add(TextureName, Texture.ExportYAML(container));
            node.Add(AsciiStartOffsetName, AsciiStartOffset);
            node.Add(TrackingName, GetTracking(container.Version));
            node.Add(CharacterSpacingName, CharacterSpacing);
            node.Add(CharacterPaddingName, GetCharacterPadding(container.Version));
            node.Add(ConvertCaseName, ConvertCase);
            node.Add(CharacterRectsName, CharacterRects.ExportYAML(container));
            node.Add(KerningValuesName, KerningValues.ExportYAML(container));
            node.Add(PixelScaleName, GetPixelScale(container.Version));
            node.Add(FontDataName, GetFontData(container.Version).ExportYAML());
            node.Add(AscentName, Ascent);
            node.Add(DescentName, Descent);
            node.Add(DefaultStyleName, (int)DefaultStyle);
            node.Add(FontNamesName, GetFontNames(container.Version).ExportYAML());
            node.Add(FallbackFontsName, GetFallbackFonts(container.Version).ExportYAML(container));
            node.Add(FontRenderingModeName, (int)FontRenderingMode);
            node.Add(UseLegacyBoundsCalculationName, UseLegacyBoundsCalculation);
            node.Add(ShouldRoundAdvanceValueName, GetShouldRoundAdvanceValue(container.Version));
            return(node);
        }
Esempio n. 2
0
        private static void LoadCharacterRects(string character)
        {
            character = character.ToLower();
            try
            {
                using (StreamReader sr = new StreamReader($@".\GameFiles\{character}Rects.txt"))
                {
                    while (!sr.EndOfStream)
                    {
                        string action = sr.ReadLine();
                        string coords = sr.ReadLine();
                        CharacterRects.Add($"{character}_" + action, new List <Rectangle>());

                        do
                        {
                            string xCoord = coords.Substring(0, coords.IndexOf(' '));
                            string yCoord = coords.Substring(coords.IndexOf(' ') + 1);
                            CharacterRects[$"{character}_" + action].Add(new Rectangle(int.Parse(xCoord), int.Parse(yCoord), Game.CellSize, Game.CellSize));
                            coords = sr.ReadLine();
                        }while (!string.IsNullOrWhiteSpace(coords));
                    }
                }
            }
            catch
            {
                MessageBox.Show($"Could not read the {character}Rects text file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }