Esempio n. 1
0
        protected override void Initialize()
        {
            _markerDirectory = DirectoriesManager.GetFullDirectoryPath("markers");

            _moduleControls       = new List <Control>();
            _pathableToggleStates = GameService.Store.RegisterStore(this.Namespace);

            _mapIcon = new CornerIcon()
            {
                IconName = "Markers & Paths",
                Icon     = ContentsManager.GetTexture("marker-pathing-icon.png"),
                Priority = "Markers & Paths".GetHashCode()
            };

            _onNewMapLoaded = delegate {
                if (this.Loaded && _packsLoaded)
                {
                    _currentReader?.UpdatePathableStates();
                }
            };

            _mapIconMenu = new ContextMenuStrip();

            _mapIcon.Click += delegate { _mapIconMenu.Show(_mapIcon); };

            var loadingMenuItem = _mapIconMenu.AddMenuItem("Loading...");

            loadingMenuItem.Enabled = false;
        }
        private void AddCategoryToMenuStrip(ContextMenuStrip parentMenuStrip, PackFormat.TacO.PathingCategory newCategory)
        {
            var newCategoryMenuItem = parentMenuStrip.AddMenuItem(newCategory.DisplayName);

            _moduleControls.Add(newCategoryMenuItem);

            StoreValue <bool> categoryStoreState = _pathableToggleStates.GetOrSetValue(newCategory.Namespace, true);

            newCategory.Visible = categoryStoreState.Value;

            newCategoryMenuItem.CanCheck = true;
            newCategoryMenuItem.Checked  = newCategory.Visible;

            newCategoryMenuItem.CheckedChanged += delegate(object sender, CheckChangedEvent e) {
                newCategory.Visible      = e.Checked;
                categoryStoreState.Value = e.Checked;
            };

            if (newCategory.Any())
            {
                var childMenuStrip = new ContextMenuStrip();

                _moduleControls.Add(childMenuStrip);

                newCategoryMenuItem.Submenu = childMenuStrip;

                foreach (var childCategory in newCategory)
                {
                    AddCategoryToMenuStrip(childMenuStrip, childCategory);
                }
            }
        }
Esempio n. 3
0
        private void BuildOptionMenus()
        {
            var reloadMarkersItem = _mapIconMenu.AddMenuItem("Reload All");

            reloadMarkersItem.Click += delegate {
                ClearMenu();

                UnloadAllPathables();

                var loadTask = Task.Factory.StartNew(LoadAsync, TaskCreationOptions.LongRunning);
                loadTask.ContinueWith((taskResult) => { GameService.Overlay.QueueMainThreadUpdate((gameTime) => { FinalizeLoad(); }); });
            };
        }
Esempio n. 4
0
        private void AddCategoryToMenuStrip(ContextMenuStrip parentMenuStrip, PackFormat.TacO.PathingCategory newCategory)
        {
            var newCategoryMenuItem = parentMenuStrip.AddMenuItem(newCategory.DisplayName);

            newCategoryMenuItem.CanCheck = true;
            newCategoryMenuItem.Checked  = newCategory.Visible;

            newCategoryMenuItem.CheckedChanged += delegate(object sender, CheckChangedEvent e) { newCategory.Visible = e.Checked; };

            if (newCategory.Any())
            {
                var childMenuStrip = new ContextMenuStrip();
                newCategoryMenuItem.Submenu = childMenuStrip;

                foreach (var childCategory in newCategory)
                {
                    AddCategoryToMenuStrip(childMenuStrip, childCategory);
                }
            }
        }
        /// <summary>
        /// Allows you to perform an action once your module has finished loading (once
        /// <see cref="LoadAsync"/> has completed).  You must call "base.OnModuleLoaded(e)" at the
        /// end for the <see cref="Module.ModuleLoaded"/> event to fire and for
        /// <see cref="Module.Loaded" /> to update correctly.
        /// </summary>
        protected override void OnModuleLoaded(EventArgs e)
        {
            // Add a mug icon in the top left next to the other icons
            _exampleIcon = new CornerIcon()
            {
                Icon             = _mugTexture,
                BasicTooltipText = $"{this.Name} [{this.Namespace}]",
                Parent           = GameService.Graphics.SpriteScreen
            };

            // Show a notification in the middle of the screen when the icon is clicked
            _exampleIcon.Click += delegate(object sender, MouseEventArgs args) {
                ScreenNotification.ShowNotification("Hello from Blish HUD!");
            };

            // Add a right click menu to the icon that shows each Revenant legend (pulled from the API)
            _dungeonContextMenuStrip = new ContextMenuStrip();

            foreach (var dungeon in _dungeons)
            {
                var dungeonItem = _dungeonContextMenuStrip.AddMenuItem(dungeon.Id);

                var dungeonMenu = new ContextMenuStrip();

                foreach (var path in dungeon.Paths)
                {
                    dungeonMenu.AddMenuItem($"{path.Id} ({path.Type})");
                }

                dungeonItem.Submenu = dungeonMenu;
            }

            _exampleIcon.Menu = _dungeonContextMenuStrip;

            base.OnModuleLoaded(e);
        }
        public static void BuildSingleModuleSettings(Panel buildPanel, object module)
        {
            if (!(module is ModuleManager cModuleMan)) return;

            var moduleText = new Label() {
                Text           = "Manage Modules",
                Location       = new Point(24, 0),
                AutoSizeHeight = true,
                AutoSizeWidth  = true,
                StrokeText     = true,
                Parent         = buildPanel
            };

            var moduleHeader = new Image() {
                Texture  = GameService.Content.GetTexture("358411"),
                Location = new Point(0,   moduleText.Bottom - 6),
                Size     = new Point(875, 110),
                Parent   = buildPanel
            };

            var moduleName = new Label() {
                Text           = cModuleMan.Manifest.Name,
                Font           = GameService.Content.DefaultFont32,
                AutoSizeHeight = true,
                AutoSizeWidth  = true,
                StrokeText     = true,
                Location       = new Point(moduleText.Left, moduleText.Bottom),
                Parent         = buildPanel
            };

            var moduleVersion = new Label() {
                Text              = $"v{cModuleMan.Manifest.Version}",
                Height            = moduleName.Height - 6,
                VerticalAlignment = VerticalAlignment.Bottom,
                AutoSizeWidth     = true,
                StrokeText        = true,
                Font              = GameService.Content.DefaultFont12,
                Location          = new Point(moduleName.Right + 8, moduleName.Top),
                Parent            = buildPanel
            };

            var moduleState = new Label() {
                Text              = cModuleMan.State.Enabled ? "Enabled" : "Disabled",
                Height            = moduleName.Height - 6,
                VerticalAlignment = VerticalAlignment.Bottom,
                AutoSizeWidth     = true,
                StrokeText        = true,
                Font              = GameService.Content.DefaultFont12,
                TextColor         = cModuleMan.State.Enabled ? Color.FromNonPremultiplied(0, 255, 25, 255) : Color.Red,
                Location          = new Point(moduleVersion.Right + 8, moduleName.Top),
                Parent            = buildPanel
            };

            // Author & Contributors
            if (cModuleMan.Manifest.Author != null) {
                // Author
                var authorImage = new Image() {
                    Texture  = GameService.Content.GetTexture("733268"),
                    Location = new Point(moduleName.Left, moduleName.Bottom),
                    Size     = new Point(32,              32),
                    Parent   = buildPanel
                };

                var authorName = new Label() {
                    Text           = cModuleMan.Manifest.Author.Name,
                    Font           = GameService.Content.DefaultFont16,
                    AutoSizeWidth  = true,
                    AutoSizeHeight = true,
                    StrokeText     = true,
                    Parent         = buildPanel
                };

                authorName.Location = new Point(authorImage.Right + 2, authorImage.Bottom - authorName.Height);

                var authoredBy = new Label() {
                    Text              = "Authored by",
                    Height            = authorImage.Height - authorName.Height,
                    AutoSizeWidth     = true,
                    StrokeText        = true,
                    VerticalAlignment = VerticalAlignment.Bottom,
                    Font              = GameService.Content.DefaultFont12,
                    Location          = new Point(authorImage.Right + 2, authorImage.Top),
                    Parent            = buildPanel
                };

            } else if (cModuleMan.Manifest.Contributors.Any()) {
                // TODO: Draw out contributors
            }

            // Enable & disable module

            var enableButton = new StandardButton() {
                Location = new Point(buildPanel.Right - 192, moduleHeader.Top + moduleHeader.Height / 4 - StandardButton.STANDARD_CONTROL_HEIGHT / 2),
                Text     = "Enable Module",
                Enabled  = !cModuleMan.State.Enabled,
                Parent   = buildPanel
            };

            var disableButton = new StandardButton() {
                Location = new Point(buildPanel.Right - 192, enableButton.Bottom + 2),
                Text     = "Disable Module",
                Enabled  = cModuleMan.State.Enabled,
                Parent   = buildPanel
            };

            enableButton.Click += delegate {
                enableButton.Enabled = false;
                disableButton.Enabled = false;

                cModuleMan.Enabled = true;

                moduleState.Text      = "Loading";
                moduleState.TextColor = Control.StandardColors.Yellow;

                cModuleMan.ModuleInstance.ModuleLoaded += delegate {
                    enableButton.Enabled  = !cModuleMan.Enabled;
                    disableButton.Enabled = cModuleMan.Enabled;

                    moduleState.Text      = cModuleMan.State.Enabled ? "Enabled" : "Disabled";
                    moduleState.TextColor = cModuleMan.State.Enabled ? Color.FromNonPremultiplied(0, 255, 25, 255) : Color.Red;
                };
            };

            disableButton.Click += delegate {
                enableButton.Enabled = false;
                disableButton.Enabled = false;

                cModuleMan.Enabled = false;

                enableButton.Enabled  = !cModuleMan.Enabled;
                disableButton.Enabled = cModuleMan.Enabled;

                moduleState.Text      = cModuleMan.State.Enabled ? "Enabled" : "Disabled";
                moduleState.TextColor = cModuleMan.State.Enabled ? Color.FromNonPremultiplied(0, 255, 25, 255) : Color.Red;
            };

            // Settings Menu
            var settingsMenu = new ContextMenuStrip();

            var settingsButton = new GlowButton() {
                Location = new Point(enableButton.Right + 12, enableButton.Top),

                Icon       = GameService.Content.GetTexture(@"common\157109"),
                ActiveIcon = GameService.Content.GetTexture(@"common\157110"),

                BasicTooltipText = "Options",

                Parent = buildPanel
            };

            settingsButton.Click += delegate { settingsMenu.Show(settingsButton); };

            var viewModuleLogs = settingsMenu.AddMenuItem("View Module Logs");

            if (cModuleMan.Manifest.Directories.Any()) {
                var directoriesMenu = settingsMenu.AddMenuItem("Directories");
                var subDirectoriesMenu = new ContextMenuStrip();

                foreach (var directory in cModuleMan.Manifest.Directories) {
                    subDirectoriesMenu.AddMenuItem($"Explore '{directory}'");
                }

                directoriesMenu.Submenu = subDirectoriesMenu;
            }

            var deleteModule = settingsMenu.AddMenuItem("Delete Module");

            // Collapse Sections

            var collapsePanel = new FlowPanel() {
                Size          = new Point(buildPanel.Width, buildPanel.Height - moduleName.Bottom + 32 + 4),
                Location      = new Point(0,                moduleName.Bottom + 32                     + 4),
                CanScroll     = true,
                Parent        = buildPanel
            };

            // Description

            var descriptionPanel = new Panel() {
                Size       = new Point(collapsePanel.ContentRegion.Width, 155),
                CanScroll  = true,
                Location = new Point(0, moduleName.Bottom + 32 + 4),
                Title      = "Description",
                ShowBorder = true,
                Parent     = collapsePanel
            };

            var descriptionLabel = new Label() {
                Text           = cModuleMan.Manifest.Description,
                Location       = new Point(8, 8),
                Width          = descriptionPanel.Width - 16,
                AutoSizeHeight = true,
                WrapText       = true,
                Parent         = descriptionPanel
            };

            // Permissions

            var permissionPanel = new FlowPanel() {
                Size                 = descriptionPanel.Size,
                CanScroll            = true,
                Location             = new Point(0, descriptionPanel.Bottom + Panel.MenuStandard.ControlOffset.Y),
                PadLeftBeforeControl = true,
                PadTopBeforeControl  = true,
                ControlPadding       = new Vector2(10),
                Title                = "Permissions",
                ShowBorder           = true,
                Parent               = collapsePanel
            };

            foreach (var perm in cModuleMan.Manifest.ApiPermissions) {
                var permCheckbox = new Checkbox() {
                    Text   = perm.Key.ToString(),
                    Parent = permissionPanel,
                    Width  = permissionPanel.Width / 3
                };
            }
        }
Esempio n. 7
0
        private Panel BuildTemplatePanel(Rectangle rect)
        {
            var btPanel = new Panel()
            {
                CanScroll = false,
                Size      = rect.Size,
            };

            int topOffset = Panel.MenuStandard.ControlOffset.Y;

            var menuSection = new Panel
            {
                Title      = "Build Templates",
                ShowBorder = true,
                Size       = Panel.MenuStandard.Size - new Point(0, 2 * topOffset + Panel.MenuStandard.ControlOffset.Y + 57),
                Location   = new Point(Panel.MenuStandard.PanelOffset.X, topOffset + 37),
                Parent     = btPanel
            };

            var scrollPanel = new Panel
            {
                CanScroll = true,
                Parent    = menuSection,
                Size      = new Point(menuSection.Size.X, menuSection.ContentRegion.Size.Y),
            };
            //Adhesive.Binding.CreateOneWayBinding(() => scrollPanel.Size, () => menuSection.ContentRegion, c => c.Size);

            var buildTemplates = new Menu
            {
                //Height = menuSection.ContentRegion.Size.Y - 40,
                MenuItemHeight = 40,
                Parent         = scrollPanel,
                CanSelect      = true,
                Size           = scrollPanel.Size,
            };
            //Adhesive.Binding.CreateOneWayBinding(() => buildTemplates.Size, () => scrollPanel.ContentRegion, c => c.Size);

            var newButton = new StandardButton
            {
                Parent = btPanel,
                Text   = "New Template",
                Width  = menuSection.ContentRegion.Width - 10,
                Left   = menuSection.ContentRegion.Left + Panel.MenuStandard.PanelOffset.X,
                Top    = menuSection.Bottom + 3,
            };


            var _templates = new ObservableCollection <Template>();

            _templates.CollectionChanged += (sender, args) => {
                if (args.Action != System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    return;
                }
                Template t  = (Template)args.NewItems[0];
                var      bt = buildTemplates.AddMenuItem(t.Name, t.Icon);
                bt.Click += delegate
                {
                    _tplPanel.Template = t;
                };
                var ctxMenu = new ContextMenuStrip();
                ctxMenu.AddMenuItem("Copy Chatcode").Click += (s, a) => System.Windows.Forms.Clipboard.SetText(t.Value);
                bt.Menu = ctxMenu;
                Adhesive.Binding.CreateOneWayBinding(() => bt.Text, () => t.Name);
            };
            Func <string, Template> findTplByName = name => _templates.SingleOrDefault(t => t.Name == name);

            foreach (var t in
                     Directory
                     .GetFiles(_templatePath, "*.txt", SearchOption.TopDirectoryOnly)
                     .Select(f => new Template(Path.GetFileNameWithoutExtension(f)))
                     )
            {
                _templates.Add(t);
            }

            newButton.Click += delegate
            {
                var toAdd = new Template("[New Template]");
                _templates.Add(toAdd);
                buildTemplates.Select((MenuItem)buildTemplates.Children.SingleOrDefault(t => ((MenuItem)t).Text == toAdd.Name));
                _tplPanel.Template = toAdd;
            };


            if (_templates.Count > 0)
            {
                buildTemplates.Select((MenuItem)buildTemplates.Children.First());
            }
            else
            {
                var toAdd = new Template("[New Template]");
                _templates.Add(toAdd);
                buildTemplates.Select((MenuItem)buildTemplates.Children.SingleOrDefault(t => ((MenuItem)t).Text == toAdd.Name));
            }


            GameService.Overlay.QueueMainThreadUpdate((gameTime) => {
                var searchBox = new TextBox()
                {
                    PlaceholderText = "Search",
                    Width           = menuSection.ContentRegion.Width,
                    Location        = new Point(menuSection.ContentRegion.Left + Panel.MenuStandard.PanelOffset.X, TextBox.ControlStandard.ControlOffset.Y),
                    Parent          = btPanel
                };

                searchBox.TextChanged += delegate(object sender, EventArgs args) {
                    foreach (MenuItem mi in buildTemplates.GetDescendants())
                    {
                        mi.MenuItemHeight = 40;
                        if (!mi.Text.ToLower().Contains(searchBox.Text.ToLower()))
                        {
                            mi.MenuItemHeight = 0;
                        }
                    }
                };
            });

            var tmp = findTplByName(buildTemplates.SelectedMenuItem.Text);

            // Main panel
            _tplPanel = new TemplateDetails(tmp)
            {
                Location = new Point(menuSection.Right + Panel.ControlStandard.ControlOffset.X, Panel.ControlStandard.ControlOffset.Y),
                Size     = new Point(btPanel.ContentRegion.Width - menuSection.Right - Control.ControlStandard.ControlOffset.X, rect.Height - 2 * Panel.ControlStandard.ControlOffset.Y),
                Parent   = btPanel,
            };


            return(btPanel);
        }