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 5 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
25 changes: 25 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,17 @@ 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):
if controlKey in [PlasmaControlKeys.kKeyMoveBackward, PlasmaControlKeys.kKeyRotateLeft, PlasmaControlKeys.kKeyRotateRight, PlasmaControlKeys.kKeyExitMode] and activeFlag:
if self._round_played:
PtYesNoDialog(self.key, PtGetLocalizedString("Heek.Messages.Quit"))
Hazado marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -442,6 +456,9 @@ def _OnSitDown(self, state, seat, events):
if state:
if PtWasLocallyNotified(self.key):
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 +727,11 @@ def _SendLocalStatusMsg(self, msg):
"""Sends a status chat message (purple text) to the local player's KI."""
PtSendKIMessage(kKILocalChatStatusMsg, msg)

def _QuitGame(self, YesNo):
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 +963,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