Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add popup quit when sitting at heek table #1446

Merged
merged 8 commits into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Hazado marked this conversation as resolved.
Show resolved Hide resolved
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()
Hazado marked this conversation as resolved.
Show resolved Hide resolved
PtAvatarExitAFK()
Hazado marked this conversation as resolved.
Show resolved Hide resolved

#########
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
Loading