• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MiniYaml类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MiniYaml的典型用法代码示例。如果您正苦于以下问题:C# MiniYaml类的具体用法?C# MiniYaml怎么用?C# MiniYaml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MiniYaml类属于命名空间,在下文中一共展示了MiniYaml类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CursorProvider

        public CursorProvider(ModData modData)
        {
            var sequenceFiles = modData.Manifest.Cursors;

            cursors = new Dictionary<string, CursorSequence>();
            palettes = new Cache<string, PaletteReference>(CreatePaletteReference);
            var sequences = new MiniYaml(null, sequenceFiles.Select(s => MiniYaml.FromFile(s)).Aggregate(MiniYaml.MergeLiberal));
            var shadowIndex = new int[] { };

            if (sequences.NodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
                Exts.TryParseIntegerInvariant(sequences.NodesDict["ShadowIndex"].Value,
                    out shadowIndex[shadowIndex.Length - 1]);
            }

            palette = new HardwarePalette();
            foreach (var p in sequences.NodesDict["Palettes"].Nodes)
                palette.AddPalette(p.Key, new Palette(GlobalFileSystem.Open(p.Value.Value), shadowIndex), false);

            var spriteLoader = new SpriteLoader(new string[0], new SheetBuilder(SheetType.Indexed));
            foreach (var s in sequences.NodesDict["Cursors"].Nodes)
                LoadSequencesForCursor(spriteLoader, s.Key, s.Value);

            palette.Initialize();
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:26,代码来源:CursorProvider.cs


示例2: MergeAndPrint

        void MergeAndPrint(Map map, string key, MiniYaml value)
        {
            var nodes = new List<MiniYamlNode>();
            var includes = new List<string>();
            if (value != null && value.Value != null)
            {
                // The order of the included files matter, so we can defer to system files
                // only as long as they are included first.
                var include = false;
                var files = FieldLoader.GetValue<string[]>("value", value.Value);
                foreach (var f in files)
                {
                    include |= map.Package.Contains(f);
                    if (include)
                        nodes.AddRange(MiniYaml.FromStream(map.Open(f)));
                    else
                        includes.Add(f);
                }
            }

            if (value != null)
                nodes.AddRange(value.Nodes);

            var output = new MiniYaml(includes.JoinWith(", "), nodes);
            Console.WriteLine(output.ToLines(key).JoinWith("\n"));
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:ExtractMapRules.cs


示例3: CursorProvider

        public CursorProvider(ModData modData)
        {
            var fileSystem = modData.DefaultFileSystem;
            var sequenceYaml = MiniYaml.Merge(modData.Manifest.Cursors.Select(
                s => MiniYaml.FromStream(fileSystem.Open(s), s)));

            var shadowIndex = new int[] { };

            var nodesDict = new MiniYaml(null, sequenceYaml).ToDictionary();
            if (nodesDict.ContainsKey("ShadowIndex"))
            {
                Array.Resize(ref shadowIndex, shadowIndex.Length + 1);
                Exts.TryParseIntegerInvariant(nodesDict["ShadowIndex"].Value,
                    out shadowIndex[shadowIndex.Length - 1]);
            }

            var palettes = new Dictionary<string, ImmutablePalette>();
            foreach (var p in nodesDict["Palettes"].Nodes)
                palettes.Add(p.Key, new ImmutablePalette(fileSystem.Open(p.Value.Value), shadowIndex));

            Palettes = palettes.AsReadOnly();

            var frameCache = new FrameCache(fileSystem, modData.SpriteLoaders);
            var cursors = new Dictionary<string, CursorSequence>();
            foreach (var s in nodesDict["Cursors"].Nodes)
                foreach (var sequence in s.Value.Nodes)
                    cursors.Add(sequence.Key, new CursorSequence(frameCache, sequence.Key, s.Key, s.Value.Value, sequence.Value));

            Cursors = cursors.AsReadOnly();
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:30,代码来源:CursorProvider.cs


示例4: LoadVersus

		static object LoadVersus(MiniYaml y)
		{
			var nd = y.ToDictionary();
			return nd.ContainsKey("Versus")
				? nd["Versus"].ToDictionary(my => FieldLoader.GetValue<float>("(value)", my.Value))
				: new Dictionary<string, float>();
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:7,代码来源:WeaponInfo.cs


示例5: ProcessYaml

        static void ProcessYaml(ModData modData, Map map, MiniYaml yaml, int engineDate, UpgradeAction processYaml)
        {
            if (yaml == null)
                return;

            if (yaml.Value != null)
            {
                var files = FieldLoader.GetValue<string[]>("value", yaml.Value);
                foreach (var filename in files)
                {
                    var fileNodes = MiniYaml.FromStream(map.Open(filename), filename);
                    processYaml(modData, engineDate, ref fileNodes, null, 0);

                    // HACK: Obtain the writable save path using knowledge of the underlying filesystem workings
                    var packagePath = filename;
                    var package = map.Package;
                    if (filename.Contains("|"))
                        modData.DefaultFileSystem.TryGetPackageContaining(filename, out package, out packagePath);

                    ((IReadWritePackage)package).Update(packagePath, Encoding.ASCII.GetBytes(fileNodes.WriteToString()));
                }
            }

            processYaml(modData, engineDate, ref yaml.Nodes, null, 1);
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:25,代码来源:UpgradeMapCommand.cs


示例6: Load

 static Dictionary<string, string[]> Load(MiniYaml y, string name)
 {
     var nd = y.ToDictionary();
     return nd.ContainsKey(name)
         ? nd[name].ToDictionary(my => FieldLoader.GetValue<string[]>("(value)", my.Value))
         : new Dictionary<string, string[]>();
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:7,代码来源:SoundInfo.cs


示例7: TerrainTemplateInfo

        public TerrainTemplateInfo(TileSet tileSet, MiniYaml my)
        {
            FieldLoader.Load(this, my);

            var nodes = my.ToDictionary()["Tiles"].Nodes;

            if (!PickAny)
            {
                tileInfo = new TerrainTileInfo[Size.X * Size.Y];
                foreach (var node in nodes)
                {
                    int key;
                    if (!int.TryParse(node.Key, out key) || key < 0 || key >= tileInfo.Length)
                        throw new InvalidDataException("Invalid tile key '{0}' on template '{1}' of tileset '{2}'.".F(node.Key, Id, tileSet.Id));

                    tileInfo[key] = LoadTileInfo(tileSet, node.Value);
                }
            }
            else
            {
                tileInfo = new TerrainTileInfo[nodes.Count];

                var i = 0;
                foreach (var node in nodes)
                {
                    int key;
                    if (!int.TryParse(node.Key, out key) || key != i++)
                        throw new InvalidDataException("Invalid tile key '{0}' on template '{1}' of tileset '{2}'.".F(node.Key, Id, tileSet.Id));

                    tileInfo[key] = LoadTileInfo(tileSet, node.Value);
                }
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:33,代码来源:TileSet.cs


示例8: ValidateMods

        static Dictionary<string, ModMetadata> ValidateMods()
        {
            var basePath = Platform.ResolvePath(".", "mods");
            var mods = Directory.GetDirectories(basePath)
                .Select(x => x.Substring(basePath.Length + 1));

            var ret = new Dictionary<string, ModMetadata>();
            foreach (var m in mods)
            {
                var yamlPath = Platform.ResolvePath(".", "mods", m, "mod.yaml");
                if (!File.Exists(yamlPath))
                    continue;

                var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
                var nd = yaml.ToDictionary();
                if (!nd.ContainsKey("Metadata"))
                    continue;

                var mod = FieldLoader.Load<ModMetadata>(nd["Metadata"]);
                mod.Id = m;

                ret.Add(m, mod);
            }

            return ret;
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:26,代码来源:ModMetadata.cs


示例9: Manifest

		public Manifest(string mod)
		{
			var path = new[] { "mods", mod, "mod.yaml" }.Aggregate(Path.Combine);
			var yaml = new MiniYaml(null, MiniYaml.FromFile(path)).ToDictionary();

			Mod = FieldLoader.Load<ModMetadata>(yaml["Metadata"]);
			Mod.Id = mod;

			// TODO: Use fieldloader
			Folders = YamlList(yaml, "Folders");
			MapFolders = YamlDictionary(yaml, "MapFolders");
			Packages = YamlDictionary(yaml, "Packages");
			Rules = YamlList(yaml, "Rules");
			ServerTraits = YamlList(yaml, "ServerTraits");
			Sequences = YamlList(yaml, "Sequences");
			VoxelSequences = YamlList(yaml, "VoxelSequences");
			Cursors = YamlList(yaml, "Cursors");
			Chrome = YamlList(yaml, "Chrome");
			Assemblies = YamlList(yaml, "Assemblies");
			ChromeLayout = YamlList(yaml, "ChromeLayout");
			Weapons = YamlList(yaml, "Weapons");
			Voices = YamlList(yaml, "Voices");
			Notifications = YamlList(yaml, "Notifications");
			Music = YamlList(yaml, "Music");
			Movies = YamlList(yaml, "Movies");
			Translations = YamlList(yaml, "Translations");
			TileSets = YamlList(yaml, "TileSets");
			ChromeMetrics = YamlList(yaml, "ChromeMetrics");
			PackageContents = YamlList(yaml, "PackageContents");
			LuaScripts = YamlList(yaml, "LuaScripts");
			Missions = YamlList(yaml, "Missions");

			LoadScreen = yaml["LoadScreen"];
			LobbyDefaults = yaml["LobbyDefaults"];

			if (yaml.ContainsKey("ContentInstaller"))
				ContentInstaller = FieldLoader.Load<InstallData>(yaml["ContentInstaller"]);

			Fonts = yaml["Fonts"].ToDictionary(my =>
				{
					var nd = my.ToDictionary();
					return Pair.New(nd["Font"].Value, Exts.ParseIntegerInvariant(nd["Size"].Value));
				});

			if (yaml.ContainsKey("TileSize"))
				TileSize = FieldLoader.GetValue<Size>("TileSize", yaml["TileSize"].Value);

			if (yaml.ContainsKey("TileShape"))
				TileShape = FieldLoader.GetValue<TileShape>("TileShape", yaml["TileShape"].Value);

			// Allow inherited mods to import parent maps.
			var compat = new List<string>();
			compat.Add(mod);

			if (yaml.ContainsKey("SupportsMapsFrom"))
				foreach (var c in yaml["SupportsMapsFrom"].Value.Split(','))
					compat.Add(c.Trim());

			MapCompatibility = compat.ToArray();
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:60,代码来源:Manifest.cs


示例10: MappedImage

 public MappedImage(string defaultSrc, MiniYaml info)
 {
     FieldLoader.LoadField(this, "rect", info.Value);
     FieldLoader.Load(this, info);
     if (src == null)
         src = defaultSrc;
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:7,代码来源:MappedImage.cs


示例11: SoundInfo

		public SoundInfo(MiniYaml y)
		{
			FieldLoader.Load(this, y);

			VoicePools = Exts.Lazy(() => Voices.ToDictionary(a => a.Key, a => new SoundPool(a.Value)));
			NotificationsPools = Exts.Lazy(() => Notifications.ToDictionary(a => a.Key, a => new SoundPool(a.Value)));
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:SoundInfo.cs


示例12: ActorInfo

        public ActorInfo(string name, MiniYaml node, Dictionary<string, MiniYaml> allUnits)
        {
            try
            {
                var allParents = new HashSet<string>();
                var abstractActorType = name.StartsWith("^");

                // Guard against circular inheritance
                allParents.Add(name);
                var mergedNode = MergeWithParents(node, allUnits, allParents).ToDictionary();

                Name = name;

                foreach (var t in mergedNode)
                {
                    if (t.Key[0] == '-')
                        throw new YamlException("Bogus trait removal: " + t.Key);

                    if (t.Key != "Inherits" && !t.Key.StartsWith("[email protected]"))
                        try
                        {
                            Traits.Add(LoadTraitInfo(t.Key.Split('@')[0], t.Value));
                        }
                        catch (FieldLoader.MissingFieldsException e)
                        {
                            if (!abstractActorType)
                                throw new YamlException(e.Message);
                        }
                }
            }
            catch (YamlException e)
            {
                throw new YamlException("Actor type {0}: {1}".F(name, e.Message));
            }
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:35,代码来源:ActorInfo.cs


示例13: LoadFilesToExtract

        public static Dictionary<string, string[]> LoadFilesToExtract(MiniYaml yaml)
        {
            var md = yaml.ToDictionary();

            return md.ContainsKey("ExtractFilesFromCD")
                ? md["ExtractFilesFromCD"].ToDictionary(my => FieldLoader.GetValue<string[]>("(value)", my.Value))
                : new Dictionary<string, string[]>();
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:8,代码来源:InstallUtils.cs


示例14: LoadSpeeds

		static object LoadSpeeds(MiniYaml y)
		{
			var ret = new Dictionary<string, GameSpeed>();
			foreach (var node in y.Nodes)
				ret.Add(node.Key, FieldLoader.Load<GameSpeed>(node.Value));

			return ret;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:8,代码来源:GameSpeed.cs


示例15: LoadProjectile

		static object LoadProjectile(MiniYaml yaml)
		{
			MiniYaml proj;
			if (!yaml.ToDictionary().TryGetValue("Projectile", out proj))
				return null;
			var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
			FieldLoader.Load(ret, proj);
			return ret;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:9,代码来源:WeaponInfo.cs


示例16: LoadTraitInfo

		static ITraitInfo LoadTraitInfo(string traitName, MiniYaml my)
		{
			if (!string.IsNullOrEmpty(my.Value))
				throw new YamlException("Junk value `{0}` on trait node {1}"
				.F(my.Value, traitName));
			var info = Game.CreateObject<ITraitInfo>(traitName + "Info");
			FieldLoader.Load(info, my);
			return info;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:9,代码来源:ActorInfo.cs


示例17: LoadConsiderations

		static object LoadConsiderations(MiniYaml yaml)
		{
			var ret = new List<Consideration>();
			foreach (var d in yaml.Nodes)
				if (d.Key.Split('@')[0] == "Consideration")
					ret.Add(new Consideration(d.Value));

			return ret;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:9,代码来源:SupportPowerDecision.cs


示例18: LoadOptions

		static object LoadOptions(MiniYaml y)
		{
			var options = new MapOptions();
			var nodesDict = y.ToDictionary();
			if (nodesDict.ContainsKey("Options"))
				FieldLoader.Load(options, nodesDict["Options"]);

			return options;
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:9,代码来源:Map.cs


示例19: LoadVoxelsForUnit

		static void LoadVoxelsForUnit(string unit, MiniYaml sequences)
		{
			Game.ModData.LoadScreen.Display();
			try
			{
				var seq = sequences.ToDictionary(my => LoadVoxel(unit, my));
				units.Add(unit, seq);
			}
			catch (FileNotFoundException) { } // Do nothing; we can crash later if we actually wanted art
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:10,代码来源:VoxelProvider.cs


示例20: MapGrid

		public MapGrid(MiniYaml yaml)
		{
			FieldLoader.Load(this, yaml);

			// The default subcell index defaults to the middle entry
			if (SubCellDefaultIndex == byte.MaxValue)
				SubCellDefaultIndex = (byte)(SubCellOffsets.Length / 2);
			else if (SubCellDefaultIndex < (SubCellOffsets.Length > 1 ? 1 : 0) || SubCellDefaultIndex >= SubCellOffsets.Length)
				throw new InvalidDataException("Subcell default index must be a valid index into the offset triples and must be greater than 0 for mods with subcells");
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:10,代码来源:MapGrid.cs



注:本文中的MiniYaml类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Minion类代码示例发布时间:2022-05-24
下一篇:
C# MiniProfiler类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap