public void Run(ModData modData, string[] args) { // HACK: The engine code assumes that Game.modData is set. Game.ModData = modData; Game.ModData.ModFiles.LoadFromManifest(Game.ModData.Manifest); Game.ModData.SpriteSequenceLoader.OnMissingSpriteError = s => Console.WriteLine("\t" + s); foreach (var t in Game.ModData.Manifest.TileSets) { var ts = new TileSet(Game.ModData, t); Console.WriteLine("Tileset: " + ts.Name); var sc = new SpriteCache(modData.SpriteLoaders, new SheetBuilder(SheetType.Indexed)); var sequenceFiles = modData.Manifest.Sequences; var partial = sequenceFiles .Select(s => MiniYaml.FromFile(s)) .Aggregate(MiniYaml.MergePartial); var nodes = MiniYaml.ApplyRemovals(partial); foreach (var n in nodes) { Game.ModData.SpriteSequenceLoader.ParseSequences(Game.ModData, ts, sc, n); } } }
Sequences Load(List <MiniYamlNode> sequenceNodes) { var sequenceFiles = modData.Manifest.Sequences; var partial = sequenceFiles .Select(s => MiniYaml.FromFile(s)) .Aggregate(sequenceNodes, MiniYaml.MergePartial); var nodes = MiniYaml.ApplyRemovals(partial); var items = new Dictionary <string, UnitSequences>(); foreach (var n in nodes) { // Work around the loop closure issue in older versions of C# var node = n; var key = node.Value.ToLines(node.Key).JoinWith("|"); UnitSequences t; if (sequenceCache.TryGetValue(key, out t)) { items.Add(node.Key, t); } else { t = Exts.Lazy(() => modData.SpriteSequenceLoader.ParseSequences(modData, tileSet, SpriteCache, node)); sequenceCache.Add(key, t); items.Add(node.Key, t); } } return(new ReadOnlyDictionary <string, UnitSequences>(items)); }
public static void Initialize(string[] voxelFiles, List <MiniYamlNode> voxelNodes) { units = new Dictionary <string, Dictionary <string, Voxel> >(); var partial = voxelFiles .Select(s => MiniYaml.FromFile(s)) .Aggregate(voxelNodes, MiniYaml.MergePartial); var sequences = MiniYaml.ApplyRemovals(partial); foreach (var s in sequences) { LoadVoxelsForUnit(s.Key, s.Value); } Game.ModData.VoxelLoader.RefreshBuffer(); }
public static void Initialize(IEnumerable <string> yaml) { data = new Dictionary <string, string>(); var partial = yaml .Select(y => MiniYaml.FromFile(y)) .Aggregate(MiniYaml.MergePartial); var metrics = MiniYaml.ApplyRemovals(partial); foreach (var m in metrics) { foreach (var n in m.Value.Nodes) { data[n.Key] = n.Value.Value; } } }
public static void Initialize(IEnumerable <string> chromeFiles) { Deinitialize(); collections = new Dictionary <string, Collection>(); cachedSheets = new Dictionary <string, Sheet>(); cachedSprites = new Dictionary <string, Dictionary <string, Sprite> >(); var partial = chromeFiles .Select(s => MiniYaml.FromFile(s)) .Aggregate(MiniYaml.MergePartial); var chrome = MiniYaml.ApplyRemovals(partial); foreach (var c in chrome) { LoadCollection(c.Key, c.Value); } }
public CursorProvider(ModData modData) { var sequenceFiles = modData.Manifest.Cursors; var partial = sequenceFiles .Select(s => MiniYaml.FromFile(s)) .Aggregate(MiniYaml.MergePartial); var sequences = new MiniYaml(null, MiniYaml.ApplyRemovals(partial)); var shadowIndex = new int[] { }; var nodesDict = sequences.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(modData.ModFiles.Open(p.Value.Value), shadowIndex)); } Palettes = palettes.AsReadOnly(); var frameCache = new FrameCache(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(); }
public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit) { this.onStart = onStart; missionList = widget.Get <ScrollPanelWidget>("MISSION_LIST"); headerTemplate = widget.Get <ScrollItemWidget>("HEADER"); template = widget.Get <ScrollItemWidget>("TEMPLATE"); var title = widget.GetOrNull <LabelWidget>("MISSIONBROWSER_TITLE"); if (title != null) { title.GetText = () => playingVideo != PlayingVideo.None ? selectedMapPreview.Title : title.Text; } widget.Get("MISSION_INFO").IsVisible = () => selectedMapPreview != null; var previewWidget = widget.Get <MapPreviewWidget>("MISSION_PREVIEW"); previewWidget.Preview = () => selectedMapPreview; previewWidget.IsVisible = () => playingVideo == PlayingVideo.None; videoPlayer = widget.Get <VqaPlayerWidget>("MISSION_VIDEO"); widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None; fullscreenVideoPlayer = Ui.LoadWidget <BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs { { "world", world } }); descriptionPanel = widget.Get <ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL"); description = descriptionPanel.Get <LabelWidget>("MISSION_DESCRIPTION"); descriptionFont = Game.Renderer.Fonts[description.Font]; difficultyButton = widget.Get <DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON"); gameSpeedButton = widget.GetOrNull <DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON"); startBriefingVideoButton = widget.Get <ButtonWidget>("START_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton = widget.Get <ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON"); stopBriefingVideoButton.IsVisible = () => playingVideo == PlayingVideo.Briefing; stopBriefingVideoButton.OnClick = () => StopVideo(videoPlayer); startInfoVideoButton = widget.Get <ButtonWidget>("START_INFO_VIDEO_BUTTON"); stopInfoVideoButton = widget.Get <ButtonWidget>("STOP_INFO_VIDEO_BUTTON"); stopInfoVideoButton.IsVisible = () => playingVideo == PlayingVideo.Info; stopInfoVideoButton.OnClick = () => StopVideo(videoPlayer); var allMaps = new List <Map>(); missionList.RemoveChildren(); // Add a group for each campaign if (Game.ModData.Manifest.Missions.Any()) { var partial = Game.ModData.Manifest.Missions .Select(MiniYaml.FromFile) .Aggregate(MiniYaml.MergePartial); var yaml = MiniYaml.ApplyRemovals(partial); foreach (var kv in yaml) { var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)); var maps = Game.ModData.MapCache .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path))) .Select(p => p.Map); CreateMissionGroup(kv.Key, maps); allMaps.AddRange(maps); } } // Add an additional group for loose missions var looseMissions = Game.ModData.MapCache .Where(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && !allMaps.Contains(p.Map)) .Select(p => p.Map); if (looseMissions.Any()) { CreateMissionGroup("Missions", looseMissions); allMaps.AddRange(looseMissions); } if (allMaps.Any()) { SelectMap(allMaps.First()); } var startButton = widget.Get <ButtonWidget>("STARTGAME_BUTTON"); startButton.OnClick = StartMissionClicked; startButton.IsDisabled = () => selectedMapPreview == null || selectedMapPreview.RuleStatus != MapRuleStatus.Cached; widget.Get <ButtonWidget>("BACK_BUTTON").OnClick = () => { StopVideo(videoPlayer); Game.Disconnect(); Ui.CloseWindow(); onExit(); }; }