public override void receiveLeftClick(int x, int y, bool playSound = true) { // Clicking show/hide button if (ExpandButton.containsPoint(x, y)) { this.SetActiveState(!IsExpanded); return; } // Clicking main icon if (AvatarButton.containsPoint(x, y)) { IClickableMenu menu = Desktop.Children.FirstOrDefault(child => nameof(ModInfoMenu) == child.GetType().Name); if (menu == null) { Point position = new Point(width + (75 * MenuScale), 15 * MenuScale); menu = new ModInfoMenu(position); ((ModInfoMenu)menu).WindowBar.RealignElements(); Desktop.Children.Insert(0, menu); } else { // Redirect to existing menu windows if they exist if (menu.GetParentMenu() is WindowBar windowBar) { windowBar.IsMinimised = false; } } return; } // Clicking mute icon if (MuteButton.containsPoint(x, y)) { Desktop.IsMuted = !Desktop.IsMuted; MuteButton.sourceRect.X = MuteButtonSource.X + (Desktop.IsMuted ? MuteButtonSource.Width : 0); return; } // Clicking taskbar icons if (Icons.FirstOrDefault(i => i.containsPoint(x, y)) is ClickableTextureComponent icon && icon != null) { IClickableMenu menu = Desktop.Children.FirstOrDefault(child => icon.name == child.GetType().Name); if (menu == null) { // Add a new menu window to the desktop if no instance currently exists IClickableMenu lastChild = Desktop.Children.LastOrDefault(); Point position = lastChild != null ? new Point(lastChild.xPositionOnScreen + (25 * MenuScale), lastChild.yPositionOnScreen + (25 * MenuScale)) : new Point(width + (50 * MenuScale), 50 * MenuScale); if (icon.name == nameof(CharacterListMenu)) { menu = new CharacterListMenu(position: position); } else if (icon.name == nameof(TileInfoMenu)) { menu = new TileInfoMenu(position: position); } else if (icon.name == nameof(MapViewMenu)) { menu = new MapViewMenu(position: position); } if (menu != null) { // Resize the window bar once content has been loaded menu.xPositionOnScreen -= Math.Max(0, Game1.viewport.Width - (menu.xPositionOnScreen + menu.width)); menu.yPositionOnScreen -= Math.Max(0, Game1.viewport.Height - (menu.yPositionOnScreen + menu.height)); ((WindowPage)menu).WindowBar.RealignElements(); // Register our new menu to the desktop Desktop.Children.Add(menu); } } else { // Redirect to existing menu windows if they exist if (menu.GetParentMenu() is WindowBar windowBar) { windowBar.IsMinimised = false; } } return; } base.receiveLeftClick(x, y, playSound); }
private void Input_ButtonPressed(object sender, ButtonPressedEventArgs e) { if (ModEntry.Config.DebugMode) { switch (e.Button) { case SButton.J: { Log.D("INTERFACE: Set enabled: " + !_isEnabled); _isEnabled = !_isEnabled; break; } case SButton.K: { Log.D("INTERFACE: Set new interface"); this.exitThisMenu(); Desktop newInterface = new Desktop(); ModEntry.Instance.Desktop = newInterface; break; } case SButton.L: { if (!_isEnabled) { break; } Log.D("INTERFACE: Clear children"); this.Reset(); break; } case SButton.OemSemicolon: { if (!_isEnabled) { break; } Log.D("INTERFACE: Add new CharacterListMenu"); CharacterListMenu childMenu = new CharacterListMenu(new Point(75, 25)); Children.Add(childMenu); break; } } } if (!Game1.game1.IsActive || !_isEnabled) { return; } e.Button.TryGetKeyboard(out Keys key); if (Taskbar.IsExpanded) { // Menu if (Game1.options.doesInputListContain(Game1.options.menuButton, key)) { Helper.Input.Suppress(e.Button); return; } // Journal if (Game1.options.doesInputListContain(Game1.options.journalButton, key)) { Helper.Input.Suppress(e.Button); return; } } }