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

Generate the Python stubs automatically #1661

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
623 changes: 405 additions & 218 deletions Scripts/Python/plasma/Plasma.py

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions Scripts/Python/plasma/PlasmaConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
Mead, WA 99021

*==LICENSE==* """

# NOTE: This stub file was generated automatically from Plasma's Python interface.
# Do not edit this file manually.
# To change any of the docstrings or function signatures,
# edit the corresponding C++ glue code in pfPython.
# If the Python interface has changed, regenerate these stubs
# by running the following call in the in-game Python console:
# >>> __import__("generate_stubs").run()

from __future__ import annotations
from typing import *

class Enum:
"""Enum base class"""
def __init__(self):
Expand Down Expand Up @@ -104,9 +116,10 @@ class PtBrainModes:
kGeneric = 0
kLadder = 1
kSit = 2
kEmote = 3
kAFK = 4
kNonGeneric = 5
kSitOnGround = 3
kEmote = 4
kAFK = 5
kNonGeneric = 6

class PtButtonNotifyTypes:
"""(none)"""
Expand All @@ -125,6 +138,7 @@ class PtCCRPetitionType:
kTechnical = 6

class PtConfirmationResult:
"""(none)"""
Cancel = 0
No = 0
OK = 1
Expand All @@ -133,6 +147,7 @@ class PtConfirmationResult:
Logout = 62

class PtConfirmationType:
"""(none)"""
OK = 0
ConfirmQuit = 1
ForceQuit = 2
Expand Down Expand Up @@ -296,4 +311,3 @@ class PtStatusLogFlags:
kStdout = 128
kTimeInSeconds = 256
kTimeAsDouble = 512

123 changes: 97 additions & 26 deletions Scripts/Python/plasma/PlasmaGame.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,79 +41,150 @@

*==LICENSE==* """

# NOTE: This stub file was generated automatically from Plasma's Python interface.
# Do not edit this file manually.
# To change any of the docstrings or function signatures,
# edit the corresponding C++ glue code in pfPython.
# If the Python interface has changed, regenerate these stubs
# by running the following call in the in-game Python console:
# >>> __import__("generate_stubs").run()

from __future__ import annotations
from typing import *

class ptGameCli:
"""Abstract bass class for legacy game clients."""

gameID: int = ...
gameID: int
"""The ID of the game instance on the server."""

handler: Any
"""The game event handler."""

isLocallyOwned: bool
"""Whether or not we are the owner of this game instance."""

ownerID: int
"""The ID of the player who owns this game instance."""

def __init__(self):
"""None"""
pass

def leaveGame(self) -> None:
"""Explicitly ask the server to allow us to leave the game."""
pass

class ptGmBlueSpiral(ptGameCli):
"""Legacy blue spiral game client."""

gameID: int
"""The ID of the game instance on the server."""

handler: Any = ...
handler: Any
"""The game event handler."""

isLocallyOwned: bool = ...
isLocallyOwned: bool
"""Whether or not we are the owner of this game instance."""

ownerID: int = ...
ownerID: int
"""The ID of the player who owns this game instance."""

def __init__(self):
"""None"""
pass

def hitCloth(self):
"""Request for the server to hit a specific cloth index and validate the correct sequence of cloth inputs."""
pass

@staticmethod
def isSupported():
"""Checks for the presence of a server-side blue spiral game manager."""
pass

@staticmethod
def join():
"""Join a common blue spiral game in the current Age."""
pass

def leaveGame(self) -> None:
"""Explicitly ask the server to allow us to leave the game."""
...
pass

def startGame(self):
"""Request for the server to start the game timer."""
pass

class ptGmMarker(ptGameCli):
"""Legacy marker game client."""

def addMarker(self, x: float, y: float, z: float, name: str, age: str) -> None:
gameID: int
"""The ID of the game instance on the server."""

handler: Any
"""The game event handler."""

isLocallyOwned: bool
"""Whether or not we are the owner of this game instance."""

ownerID: int
"""The ID of the player who owns this game instance."""

def __init__(self):
"""None"""
pass

def addMarker(self,x: float, y: float, z: float, name: str, age: str) -> None:
"""Request for the server to add a new marker to the game."""
...
pass

def captureMarker(self, markerId: int) -> None:
def captureMarker(self,markerId: int) -> None:
"""Request for the server to register a capture of the specified marker for our team."""
...
pass

def changeGameName(self, name: str) -> None:
def changeGameName(self,name: str) -> None:
"""Request for the server to change the internal marker game name."""
...
pass

def changeMarkerName(self, markerID: int) -> None:
def changeMarkerName(self,markerID: int) -> None:
"""Request for the server to change the name of a specific marker from the game."""
...
pass

def changeTimeLimit(self, timeLimit: int) -> None:
def changeTimeLimit(self,timeLimit: int) -> None:
"""Request for the server to change the marker game's time limit."""
...
pass

@staticmethod
def create(handler: Any, gameType: int, templateId: Optional[str]) -> None:
"""Initialize a new marker game client with the server."""
...
pass

def deleteGame(self) -> None:
"""Request for the server to delete all data associated with this game, including
the marker definitions and game name.
"""
...
"""Request for the server to delete all data associated with this game, including the marker definitions and game name."""
pass

def deleteMarker(self, markerID: int) -> None:
def deleteMarker(self,markerID: int) -> None:
"""Request for the server to delete a specific marker from the game."""
...
pass

@staticmethod
def isSupported() -> bool:
...
"""Checks for the presence of a server-side marker game manager."""
pass

def leaveGame(self) -> None:
"""Explicitly ask the server to allow us to leave the game."""
pass

def pauseGame(self) -> None:
"""Request for the server to pause the marker game."""
...
pass

def resetGame(self) -> None:
"""Request for the server to clear all markers to the uncaptured state."""
...
pass

def startGame(self) -> None:
"""Request for the server to start the marker game."""
...
pass
15 changes: 12 additions & 3 deletions Scripts/Python/plasma/PlasmaGameConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@

*==LICENSE==* """

# NOTE: This stub file was generated automatically from Plasma's Python interface.
# Do not edit this file manually.
# To change any of the docstrings or function signatures,
# edit the corresponding C++ glue code in pfPython.
# If the Python interface has changed, regenerate these stubs
# by running the following call in the in-game Python console:
# >>> __import__("generate_stubs").run()

from __future__ import annotations
from typing import *

class PtGameJoinError:
kGameJoinPending = -1
"""(none)"""
kGameJoinSuccess = 0
kGameJoinErrNotExist = 1
kGameJoinErrInitFailed = 2
Expand All @@ -54,11 +63,11 @@ class PtGameJoinError:
kGameJoinErrAlreadyJoined = 6
kGameJoinErrNoInvite = 7
kNumGameJoinErrors = 8

kGameJoinPending = 4294967295
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this was -1, but I'm guessing it's handled as a uint internally so it keeps the positive value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a good question is whether a comparison against -1 would ever work in Python, maybe this MAX_UINT32 is the only correct option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's declared in C++ as kGameJoinPending = (uint32_t)-1, so it gets output as unsigned.

Also worth noting that I used a 64-bit client to generate the stubs. Plasma's custom EnumValues store the numeric value as Py_ssize_t, so it's possible that a 32-bit client would see this constant as -1 on the Python side. That seems like something we should fix...


class PtMarkerGameType:
"""(none)"""
kMarkerGameQuest = 0
kMarkerGameCGZ = 1
kMarkerGameCapture = 2
kMarkerGameCaptureAndHold = 3
kNumMarkerGameTypes = 4
13 changes: 12 additions & 1 deletion Scripts/Python/plasma/PlasmaNetConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
Mead, WA 99021

*==LICENSE==* """

# NOTE: This stub file was generated automatically from Plasma's Python interface.
# Do not edit this file manually.
# To change any of the docstrings or function signatures,
# edit the corresponding C++ glue code in pfPython.
# If the Python interface has changed, regenerate these stubs
# by running the following call in the in-game Python console:
# >>> __import__("generate_stubs").run()

from __future__ import annotations
from typing import *

class PtLinkingRules:
"""(none)"""
kBasicLink = 0
Expand All @@ -48,4 +60,3 @@ class PtLinkingRules:
kOwnedBook = 3
kVisitBook = 4
kChildAgeBook = 5

13 changes: 12 additions & 1 deletion Scripts/Python/plasma/PlasmaVaultConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
Mead, WA 99021

*==LICENSE==* """

# NOTE: This stub file was generated automatically from Plasma's Python interface.
# Do not edit this file manually.
# To change any of the docstrings or function signatures,
# edit the corresponding C++ glue code in pfPython.
# If the Python interface has changed, regenerate these stubs
# by running the following call in the in-game Python console:
# >>> __import__("generate_stubs").run()

from __future__ import annotations
from typing import *

class PtVaultCallbackTypes:
"""(none)"""
kVaultConnected = 1
Expand Down Expand Up @@ -112,4 +124,3 @@ class PtVaultTextNoteTypes:
"""(none)"""
kGeneric = 0
kCCRPetition = 1

Loading