Skip to content

Commit

Permalink
Merge pull request #1446 from Hazado/StopLeavingHeekWhenclicking
Browse files Browse the repository at this point in the history
Add popup quit when sitting at heek table
  • Loading branch information
Hoikas authored Aug 13, 2023
2 parents 1cbd5c7 + 14a281a commit 3df3f2c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Scripts/Python/nb01RPSGame.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from PlasmaConstants import *
from PlasmaKITypes import *
from PlasmaTypes import *
import PlasmaControlKeys

# detectors
detButtonRock = ptAttribActivatorList(1, "Rock ButtonClick det", netForce=True)
Expand Down Expand Up @@ -190,6 +191,7 @@
NOTIFY_HELLO = 0
NOTIFY_JOINLEAVE = 1
NOTIFY_SCORE_UPDATE = 2
NOTIFY_YESNO_QUIT = 3

# Rank stuff
RANK_UP = 100
Expand Down Expand Up @@ -291,6 +293,7 @@ def __init__(self):
NOTIFY_HELLO: self._OnHello,
NOTIFY_JOINLEAVE: self._OnJoinLeave,
NOTIFY_SCORE_UPDATE: self._OnGameOver,
NOTIFY_YESNO_QUIT: self._QuitGame,
}

# These get called when an SDL variable touches itself.
Expand Down Expand Up @@ -380,6 +383,18 @@ def OnSDLNotify(self, VARname, SDLname, playerID, tag):
else:
raise RuntimeError("Got an SDL notify for {}, but no CB".format(VARname))

def OnControlKeyEvent(self, controlKey, activeFlag):
# Captures movement keys and prompt a yes/no dialog during a game or standup animation otherwise
if controlKey in [PlasmaControlKeys.kKeyMoveBackward, PlasmaControlKeys.kKeyRotateLeft, PlasmaControlKeys.kKeyRotateRight, PlasmaControlKeys.kKeyExitMode] and activeFlag:
if self._round_played:
PtLocalizedYesNoDialog(self.key, "Heek.Messages.Quit")
else:
quit = {
"type": NOTIFY_YESNO_QUIT,
"YesNo": 1,
}
self._SendPyNotifyMsg(quit)

def OnNotify(self, state, id, events):
"""Handle Plasma Notification Messages"""

Expand Down Expand Up @@ -441,7 +456,14 @@ def _OnSitDown(self, state, seat, events):
# Manage game state if standing up
if state:
if PtWasLocallyNotified(self.key):
# Disable Yeesha Book to prevent linking out
# Enable control keys to capture button presses or mouse movements
# Disable all movement keys so sit modifier wont trigger before we want it to
# Enable the mouse movement so we can move the camera and use the sides of the screen to trigger a movement
PtSendKIMessage(kDisableEntireYeeshaBook, 0)
PtEnableControlKeyEvents(self.key)
PtDisableMovementKeys()
PtEnableMouseMovement()
self._JoinTheGame(seat)
else:
self._seats[seat].enable()
Expand Down Expand Up @@ -710,6 +732,15 @@ def _SendLocalStatusMsg(self, msg):
"""Sends a status chat message (purple text) to the local player's KI."""
PtSendKIMessage(kKILocalChatStatusMsg, msg)

def _QuitGame(self, YesNo):
# Performs the standup animation when sitting down
# Disable control key events
# Enables the disabled movement keys
# PtAvatarExitAFK() is just doing IExitTopmostGenericMode()
if YesNo:
PtDisableControlKeyEvents(self.key)
PtEnableMovementKeys()
PtAvatarExitAFK()

#########
def _ChangeButtonState(self, seat, enable=True, ff=False, force=False):
Expand Down Expand Up @@ -941,6 +972,9 @@ def _HandleVariableNotify(self, events):
for event in events:
args[event[1]] = event[3]

if "YesNo" in args:
args["type"] = NOTIFY_YESNO_QUIT

# Now, let's fire it off!
type = args["type"]
del args["type"]
Expand Down

0 comments on commit 3df3f2c

Please sign in to comment.