Exemple #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;
        }
Exemple #2
0
        protected override async Task LoadAsync()
        {
            _searchIcon = new CornerIcon()
            {
                IconName  = "Landmark Search",
                Icon      = ContentsManager.GetTexture(@"textures\landmark-search.png"),
                HoverIcon = ContentsManager.GetTexture(@"textures\landmark-search-hover.png"),
                Priority  = 5
            };

            GameService.Debug.StartTimeFunc($"Loading all items");
            var regions = await Gw2ApiManager.Gw2ApiClient.Continents[1].Floors[1].Regions.AllAsync();

            foreach (var region in regions)
            {
                _searchIcon.LoadingMessage = $"Loading {region.Name}...";
                var maps = await Gw2ApiManager.Gw2ApiClient.Continents[1].Floors[1].Regions[region.Id].Maps.AllAsync();

                foreach (var map in maps)
                {
                    _searchIcon.LoadingMessage = $"Loading {region.Name}: {map.Name}...";

                    LoadedLandmarks.UnionWith(map.PointsOfInterest.Values.Where(landmark => landmark.Name != null));
                    HeroPoints.UnionWith(map.SkillChallenges);
                    MasteryPoints.UnionWith(map.MasteryPoints);
                    HeroHearts.UnionWith(map.Tasks.Values);
                    Areas.UnionWith(map.Sectors.Values);
                }
            }

            _searchIcon.LoadingMessage = null;
            GameService.Debug.StopTimeFuncAndOutput($"Loading all items");

            _searchIcon.Click += delegate { _searchWindow.ToggleWindow(); };
        }
        /// <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="ExternalModule.ModuleLoaded"/> event to fire and for
        /// <see cref="ExternalModule.Loaded" /> to update correctly.
        /// </summary>
        protected override void OnModuleLoaded(EventArgs e)
        {
            _todoTab = GameService.Overlay.BlishHudWindow.AddTab("To-Do", _mugTexture, _tabPanel);

            // 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
            };

            base.OnModuleLoaded(e);
        }
Exemple #4
0
        private Panel BuildCornerIcon()
        {
            Icon = new CornerIcon()
            {
                BasicTooltipText = "Pathing",
                Icon             = Content.GetTexture("marker-pathing-icon")
            };

            IconContextMenu = new ContextMenuStrip();

            Icon.Click += delegate {
                IconContextMenu.Show(Icon.Location + Icon.Size);
            };

            return(null);
        }
Exemple #5
0
        private Panel BuildCornerIcon()
        {
            Icon = new CornerIcon()
            {
                BasicTooltipText = "Pathing",
                Icon             = Content.GetTexture("marker-pathing-icon"),
                Parent           = Graphics.SpriteScreen,
                Priority         = Int32.MaxValue - 1,
            };

            IconContextMenu = new ContextMenuStrip();

            Icon.Click += delegate {
                IconContextMenu.Show(Icon);
            };

            return(null);
        }
Exemple #6
0
        protected override void Unload()
        {
            // Unsubscribe from events
            GameService.Pathing.NewMapLoaded -= _onNewMapLoaded;

            // Dispose all controls
            _moduleControls.ForEach(c => c.Dispose());
            _moduleControls.Clear();
            _mapIcon.Dispose();
            _mapIconMenu.Dispose();

            _mapIcon     = null;
            _mapIconMenu = null;

            // Unload and dispose all loaded pathables
            UnloadAllPathables();

            // Release static reference to this module instance
            ModuleInstance = null;
        }
 protected override void Initialize()
 {
     LoadTextures();
     GameService.Overlay.UserLocaleChanged += ChangeLocalization;
     ChangeLocalization(null, null);
     printScreenKey            = new KeyBinding(Keys.PrintScreen);
     printScreenKey.Activated += ScreenshotNotify;
     printScreenKey.Enabled    = true;
     screensPathWatchers       = new List <FileSystemWatcher>();
     displayedThumbnails       = new Dictionary <string, Panel>();
     foreach (var f in _imageFilters)
     {
         var w = new FileSystemWatcher
         {
             Path                = DirectoryUtil.ScreensPath,
             NotifyFilter        = NotifyFilters.LastWrite | NotifyFilters.FileName,
             Filter              = f,
             EnableRaisingEvents = true
         };
         w.Created += OnScreenshotCreated;
         w.Deleted += OnScreenshotDeleted;
         w.Renamed += OnScreenshotRenamed;
         screensPathWatchers.Add(w);
     }
     moduleCornerIcon = new CornerIcon
     {
         IconName = Name,
         Icon     = ContentsManager.GetTexture("screenshots_icon_64x64.png"),
         Priority = Name.GetHashCode()
     };
     moduleCornerIcon.Click += delegate
     {
         GameService.Overlay.BlishHudWindow.Show();
         GameService.Overlay.BlishHudWindow.Navigate(modulePanel);
         //TODO: Select the correct tab.
     };
 }
        /// <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);
        }
Exemple #9
0
        public override void OnEnabled()
        {
            LandmarkSearchWindow = new PoiLookupWindow(this)
            {
                Parent   = GameService.Graphics.SpriteScreen,
                Location = GameService.Graphics.SpriteScreen.Size / new Point(2)
            };

            LandmarkSearch = new SkillBox()
            {
                Location = new Point(GameService.Graphics.WindowWidth / 4 * 1 - 30, 0),
                Icon     = GameService.Content.GetTexture("landmark-search-icon"),
                Parent   = GameService.Graphics.SpriteScreen,
                Menu     = new ContextMenuStrip(),
                Visible  = false
            };

            LandmarkSearch.Menu.AddMenuItem("Use small icon").Click += delegate {
                LandmarkSearch.Visible     = false;
                landmarkSearchIcon.Visible = true;
            };

            landmarkSearchIcon = new CornerIcon()
            {
                Icon             = GameService.Content.GetTexture("landmark-search"),
                HoverIcon        = GameService.Content.GetTexture("landmark-search-hover"),
                Menu             = new ContextMenuStrip(),
                BasicTooltipText = "Landmark Search",
                Priority         = 5,
            };

            landmarkSearchIcon.Menu.AddMenuItem("Use large icon").Click += delegate {
                LandmarkSearch.Visible     = true;
                landmarkSearchIcon.Visible = false;
            };

            landmarkSearchIcon.Click += delegate {
                LandmarkSearchWindow.ToggleWindow();
            };

            GameService.Graphics.SpriteScreen.Resized += delegate { LandmarkSearch.Location = new Point(GameService.Graphics.WindowWidth / 4 * 1 - 30, 0); };

            LandmarkSearch.LeftMouseButtonReleased += delegate {
                LandmarkSearchWindow.ToggleWindow();
            };

            var floorInfo = BHGw2Api.Floor.FloorFromContinentAndId(1, 1);

            if (floorInfo == null)
            {
                GameService.Debug.WriteWarningLine("PoiLookup: Could not load landmark information from API. Aborting.");
                return;
            }

            foreach (var region in floorInfo.Regions)
            {
                foreach (var map in region.Maps)
                {
                    foreach (var upoi in map.Landmarks)
                    {
                        if (upoi.Name?.Length > 0 && !PointsOfInterest.ContainsKey(upoi.Name))
                        {
                            PointsOfInterest.Add(upoi.Name, upoi);
                        }
                    }
                }
            }
        }
Exemple #10
0
        protected override async Task LoadAsync()
        {
            _debugIcon = new CornerIcon()
            {
                Icon             = ContentsManager.GetTexture(@"textures\156736.png"),
                BasicTooltipText = "Debug"
            };

            _debugContextMenuStrip = new ContextMenuStrip();

            var screenshotAction = _debugContextMenuStrip.AddMenuItem("Take Screenshot of Control");
            var magentaAction    = _debugContextMenuStrip.AddMenuItem("Mark Control Bounds");
            var forceGcAction    = _debugContextMenuStrip.AddMenuItem("Force GC");
            var showToolbox      = _debugContextMenuStrip.AddMenuItem("Show Toolbox");

            forceGcAction.Enabled = false;

            showToolbox.CanCheck = true;

            _controlHighlighter = new Tools.ControlScreenshot.HighlightControl()
            {
                Visible = false
            };
            _controlHighlighter.Parent = GameService.Graphics.SpriteScreen;

            screenshotAction.Click += delegate { _screenshotPickerActive = true; };
            magentaAction.Click    += delegate { _magentaPickerActive = true; };

            forceGcAction.Click += delegate {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            };

            showToolbox.CheckedChanged += delegate {
                if (showToolbox.Checked)
                {
                    if (_toolboxForm == null || _toolboxForm.IsDisposed)
                    {
                        _toolboxForm             = new RuntimeToolbox();
                        _toolboxForm.FormClosed += delegate { _showToolbox.Value = false; };
                    }
                    _toolboxForm.Show();
                }
                else
                {
                    _toolboxForm.Hide();
                }

                _showToolbox.Value = showToolbox.Checked;
            };

            // Thread safety
            GameService.Overlay.QueueMainThreadUpdate((gameTime) => {
                _showToolbox.SettingChanged += delegate { showToolbox.Checked = _showToolbox.Value; };
                showToolbox.Checked          = _showToolbox.Value;
            });

            _debugIcon.Click += delegate {
                _debugContextMenuStrip.Show(_debugIcon);
            };

            Control.ActiveControlChanged += ControlOnActiveControlChanged;
            GameService.Input.LeftMouseButtonReleased  += InputOnLeftMouseButtonReleased;
            GameService.Input.RightMouseButtonReleased += InputOnRightMouseButtonReleased;
        }