コード例 #1
0
        public ModContentPromptLogic(Widget widget, Manifest mod, ModContent content, Action continueLoading)
        {
            var panel = widget.Get("CONTENT_PROMPT_PANEL");

            var headerTemplate = panel.Get<LabelWidget>("HEADER_TEMPLATE");
            var headerLines = !string.IsNullOrEmpty(content.InstallPromptMessage) ? content.InstallPromptMessage.Replace("\\n", "\n").Split('\n') : new string[0];
            var headerHeight = 0;
            foreach (var l in headerLines)
            {
                var line = (LabelWidget)headerTemplate.Clone();
                line.GetText = () => l;
                line.Bounds.Y += headerHeight;
                panel.AddChild(line);

                headerHeight += headerTemplate.Bounds.Height;
            }

            panel.Bounds.Height += headerHeight;
            panel.Bounds.Y -= headerHeight / 2;

            var advancedButton = panel.Get<ButtonWidget>("ADVANCED_BUTTON");
            advancedButton.Bounds.Y += headerHeight;
            advancedButton.OnClick = () =>
            {
                Ui.OpenWindow("CONTENT_PANEL", new WidgetArgs
                {
                    { "mod", mod },
                    { "content", content },
                    { "onCancel", Ui.CloseWindow }
                });
            };

            var quickButton = panel.Get<ButtonWidget>("QUICK_BUTTON");
            quickButton.IsVisible = () => !string.IsNullOrEmpty(content.QuickDownload);
            quickButton.Bounds.Y += headerHeight;
            quickButton.OnClick = () =>
            {
                var modFileSystem = new FileSystem.FileSystem(Game.Mods);
                modFileSystem.LoadFromManifest(mod);
                var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
                modFileSystem.UnmountAll();

                var download = downloadYaml.FirstOrDefault(n => n.Key == content.QuickDownload);
                if (download == null)
                    throw new InvalidOperationException("Mod QuickDownload `{0}` definition not found.".F(content.QuickDownload));

                Ui.OpenWindow("PACKAGE_DOWNLOAD_PANEL", new WidgetArgs
                {
                    { "download", new ModContent.ModDownload(download.Value) },
                    { "onSuccess", continueLoading }
                });
            };

            var backButton = panel.Get<ButtonWidget>("BACK_BUTTON");
            backButton.Bounds.Y += headerHeight;
            backButton.OnClick = Ui.CloseWindow;
            Game.RunAfterTick(Ui.ResetTooltips);
        }
コード例 #2
0
ファイル: ModContentLogic.cs プロジェクト: pchote/OpenRA
        public ModContentLogic(Widget widget, Manifest mod, ModContent content, Action onCancel)
        {
            this.content = content;

            var panel = widget.Get("CONTENT_PANEL");

            var modFileSystem = new FileSystem.FileSystem(Game.Mods);
            modFileSystem.LoadFromManifest(mod);

            var sourceYaml = MiniYaml.Load(modFileSystem, content.Sources, null);
            foreach (var s in sourceYaml)
                sources.Add(s.Key, new ModContent.ModSource(s.Value));

            var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
            foreach (var d in downloadYaml)
                downloads.Add(d.Key, new ModContent.ModDownload(d.Value));

            modFileSystem.UnmountAll();

            scrollPanel = panel.Get<ScrollPanelWidget>("PACKAGES");
            template = scrollPanel.Get<ContainerWidget>("PACKAGE_TEMPLATE");

            var headerTemplate = panel.Get<LabelWidget>("HEADER_TEMPLATE");
            var headerLines = !string.IsNullOrEmpty(content.HeaderMessage) ? content.HeaderMessage.Replace("\\n", "\n").Split('\n') : new string[0];
            var headerHeight = 0;
            foreach (var l in headerLines)
            {
                var line = (LabelWidget)headerTemplate.Clone();
                line.GetText = () => l;
                line.Bounds.Y += headerHeight;
                panel.AddChild(line);

                headerHeight += headerTemplate.Bounds.Height;
            }

            panel.Bounds.Height += headerHeight;
            panel.Bounds.Y -= headerHeight / 2;
            scrollPanel.Bounds.Y += headerHeight;

            var discButton = panel.Get<ButtonWidget>("CHECK_DISC_BUTTON");
            discButton.Bounds.Y += headerHeight;
            discButton.IsVisible = () => discAvailable;

            discButton.OnClick = () => Ui.OpenWindow("DISC_INSTALL_PANEL", new WidgetArgs
            {
                { "afterInstall", () => { } },
                { "sources", sources },
                { "content", content }
            });

            var backButton = panel.Get<ButtonWidget>("BACK_BUTTON");
            backButton.Bounds.Y += headerHeight;
            backButton.OnClick = () => { Ui.CloseWindow(); onCancel(); };

            PopulateContentList();
            Game.RunAfterTick(Ui.ResetTooltips);
        }
コード例 #3
0
        void IUtilityCommand.Run(Utility utility, string[] args)
        {
            var filename = Path.GetFileName(args[1]);
            var path     = Path.GetDirectoryName(args[1]);

            var fs = new FileSystem.FileSystem(utility.Mods);

            // Needed to access the global mix database
            fs.LoadFromManifest(utility.ModData.Manifest);

            fs.Mount(path, "parent");
            var package = new MixFile(fs, "parent|" + filename);

            foreach (var kv in package.Index.OrderBy(kv => kv.Value.Offset))
            {
                Console.WriteLine("{0}:", kv.Key);
                Console.WriteLine("\tOffset: {0}", kv.Value.Offset);
                Console.WriteLine("\tLength: {0}", kv.Value.Length);
            }
        }
コード例 #4
0
        void IUtilityCommand.Run(Utility utility, string[] args)
        {
            var filename = Path.GetFileName(args[1]);
            var path = Path.GetDirectoryName(args[1]);

            var fs = new FileSystem.FileSystem(utility.Mods);

            // Needed to access the global mix database
            fs.LoadFromManifest(utility.ModData.Manifest);

            fs.Mount(path, "parent");
            var package = new MixFile(fs, "parent|" + filename);

            foreach (var kv in package.Index.OrderBy(kv => kv.Value.Offset))
            {
                Console.WriteLine("{0}:", kv.Key);
                Console.WriteLine("\tOffset: {0}", kv.Value.Offset);
                Console.WriteLine("\tLength: {0}", kv.Value.Length);
            }
        }
コード例 #5
0
        public ModContentLogic(Widget widget, Manifest mod, ModContent content, Action onCancel)
        {
            this.content = content;

            var panel = widget.Get("CONTENT_PANEL");

            var modFileSystem = new FileSystem.FileSystem(Game.Mods);

            modFileSystem.LoadFromManifest(mod);

            var sourceYaml = MiniYaml.Load(modFileSystem, content.Sources, null);

            foreach (var s in sourceYaml)
            {
                sources.Add(s.Key, new ModContent.ModSource(s.Value));
            }

            var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);

            foreach (var d in downloadYaml)
            {
                downloads.Add(d.Key, new ModContent.ModDownload(d.Value));
            }

            modFileSystem.UnmountAll();

            scrollPanel = panel.Get <ScrollPanelWidget>("PACKAGES");
            template    = scrollPanel.Get <ContainerWidget>("PACKAGE_TEMPLATE");

            var headerTemplate = panel.Get <LabelWidget>("HEADER_TEMPLATE");
            var headerLines    = !string.IsNullOrEmpty(content.HeaderMessage) ? content.HeaderMessage.Replace("\\n", "\n").Split('\n') : new string[0];
            var headerHeight   = 0;

            foreach (var l in headerLines)
            {
                var line = (LabelWidget)headerTemplate.Clone();
                line.GetText   = () => l;
                line.Bounds.Y += headerHeight;
                panel.AddChild(line);

                headerHeight += headerTemplate.Bounds.Height;
            }

            panel.Bounds.Height  += headerHeight;
            panel.Bounds.Y       -= headerHeight / 2;
            scrollPanel.Bounds.Y += headerHeight;

            var discButton = panel.Get <ButtonWidget>("CHECK_DISC_BUTTON");

            discButton.Bounds.Y += headerHeight;
            discButton.IsVisible = () => discAvailable;

            discButton.OnClick = () => Ui.OpenWindow("DISC_INSTALL_PANEL", new WidgetArgs
            {
                { "afterInstall", () => { } },
                { "sources", sources },
                { "content", content }
            });

            var backButton = panel.Get <ButtonWidget>("BACK_BUTTON");

            backButton.Bounds.Y += headerHeight;
            backButton.OnClick   = () => { Ui.CloseWindow(); onCancel(); };

            PopulateContentList();
            Game.RunAfterTick(Ui.ResetTooltips);
        }
コード例 #6
0
        public ModContentPromptLogic(Widget widget, Manifest mod, ModContent content, Action continueLoading)
        {
            var panel = widget.Get("CONTENT_PROMPT_PANEL");

            var headerTemplate = panel.Get <LabelWidget>("HEADER_TEMPLATE");
            var headerLines    = !string.IsNullOrEmpty(content.InstallPromptMessage) ? content.InstallPromptMessage.Replace("\\n", "\n").Split('\n') : new string[0];
            var headerHeight   = 0;

            foreach (var l in headerLines)
            {
                var line = (LabelWidget)headerTemplate.Clone();
                line.GetText   = () => l;
                line.Bounds.Y += headerHeight;
                panel.AddChild(line);

                headerHeight += headerTemplate.Bounds.Height;
            }

            panel.Bounds.Height += headerHeight;
            panel.Bounds.Y      -= headerHeight / 2;

            var advancedButton = panel.Get <ButtonWidget>("ADVANCED_BUTTON");

            advancedButton.Bounds.Y += headerHeight;
            advancedButton.OnClick   = () =>
            {
                Ui.OpenWindow("CONTENT_PANEL", new WidgetArgs
                {
                    { "mod", mod },
                    { "content", content },
                    { "onCancel", Ui.CloseWindow }
                });
            };

            var quickButton = panel.Get <ButtonWidget>("QUICK_BUTTON");

            quickButton.IsVisible = () => !string.IsNullOrEmpty(content.QuickDownload);
            quickButton.Bounds.Y += headerHeight;
            quickButton.OnClick   = () =>
            {
                var modFileSystem = new FileSystem.FileSystem(Game.Mods);
                modFileSystem.LoadFromManifest(mod);
                var downloadYaml = MiniYaml.Load(modFileSystem, content.Downloads, null);
                modFileSystem.UnmountAll();

                var download = downloadYaml.FirstOrDefault(n => n.Key == content.QuickDownload);
                if (download == null)
                {
                    throw new InvalidOperationException("Mod QuickDownload `{0}` definition not found.".F(content.QuickDownload));
                }

                Ui.OpenWindow("PACKAGE_DOWNLOAD_PANEL", new WidgetArgs
                {
                    { "download", new ModContent.ModDownload(download.Value) },
                    { "onSuccess", continueLoading }
                });
            };

            var backButton = panel.Get <ButtonWidget>("BACK_BUTTON");

            backButton.Bounds.Y += headerHeight;
            backButton.OnClick   = Ui.CloseWindow;
            Game.RunAfterTick(Ui.ResetTooltips);
        }