mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-04 07:37:48 -05:00
Hotkeys in Main Menu (#903)
* Escape in MainMenu cause game exit * Escape in MainMenu cause game exit * Shortcuts in d2 main menu * Shortcuts in Main Menu * Shortcuts in Main Menu * hotfix for "Shortcuts in Main Menu" * hotfix for "Shortcuts in Main Menu" - removet some lint error * fix lint errors Co-authored-by: M. Sz <mszeptuch@protonmail.com> Co-authored-by: gravestench <dknuth0101@gmail.com>
This commit is contained in:
parent
9e89d5b891
commit
d5a26fd495
@ -367,6 +367,8 @@ func (v *MainMenu) onMapTestClicked() {
|
||||
}
|
||||
|
||||
func (v *MainMenu) onSinglePlayerClicked() {
|
||||
v.SetScreenMode(ScreenModeUnknown)
|
||||
|
||||
if v.heroState.HasGameStates() {
|
||||
// Go here only if existing characters are available to select
|
||||
v.navigator.ToCharacterSelect(d2clientconnectiontype.Local, v.tcpJoinGameEntry.GetText())
|
||||
@ -493,15 +495,43 @@ func (v *MainMenu) OnMouseButtonDown(event d2interface.MouseEvent) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// OnKeyUp is called when a key is released
|
||||
func (v *MainMenu) OnKeyUp(_ d2interface.KeyEvent) bool {
|
||||
// On retail version of D2, any key event puts you onto the main menu.
|
||||
if v.screenMode == ScreenModeTrademark {
|
||||
v.SetScreenMode(ScreenModeMainMenu)
|
||||
return true
|
||||
func (v *MainMenu) onEscapePressed(event d2interface.KeyEvent, mode mainMenuScreenMode) {
|
||||
if event.Key() == d2enum.KeyEscape {
|
||||
v.SetScreenMode(mode)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
// OnKeyUp is called when a key is released
|
||||
func (v *MainMenu) OnKeyUp(event d2interface.KeyEvent) bool {
|
||||
preventKeyEventPropagation := false
|
||||
|
||||
switch v.screenMode {
|
||||
case ScreenModeTrademark: // On retail version of D2, some specific key events (Escape, Space and Enter) puts you onto the main menu.
|
||||
switch event.Key() {
|
||||
case d2enum.KeyEscape, d2enum.KeyEnter, d2enum.KeySpace:
|
||||
v.SetScreenMode(ScreenModeMainMenu)
|
||||
}
|
||||
|
||||
preventKeyEventPropagation = true
|
||||
case ScreenModeMainMenu: // pressing escape in Main Menu close the game
|
||||
if event.Key() == d2enum.KeyEscape {
|
||||
v.onExitButtonClicked()
|
||||
}
|
||||
case ScreenModeMultiplayer: // back to previous menu
|
||||
v.onEscapePressed(event, ScreenModeMainMenu)
|
||||
|
||||
preventKeyEventPropagation = true
|
||||
case ScreenModeTCPIP: // back to previous menu
|
||||
v.onEscapePressed(event, ScreenModeMultiplayer)
|
||||
|
||||
preventKeyEventPropagation = true
|
||||
case ScreenModeServerIP: // back to previous menu
|
||||
v.onEscapePressed(event, ScreenModeTCPIP)
|
||||
|
||||
preventKeyEventPropagation = true
|
||||
}
|
||||
|
||||
return preventKeyEventPropagation
|
||||
}
|
||||
|
||||
// SetScreenMode sets the screen mode (which sub-menu the screen is on)
|
||||
|
Loading…
Reference in New Issue
Block a user