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

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
428517d
Sort functions in Python stubs in case-sensitive alphabetical order
dgelessus Feb 1, 2025
d01b18d
Sort classes in Python stubs in case-sensitive alphabetical order
dgelessus Feb 1, 2025
af3749c
Sort enum constants in Python stubs by their numeric values
dgelessus Feb 1, 2025
9ccd592
Add script for automatically generating the Python interface stubs
dgelessus Jan 29, 2025
63fe68f
Add Plasma enum support to stub generator
dgelessus Feb 1, 2025
f1b599e
Don't output empty class and property docstrings into stubs
dgelessus Feb 1, 2025
d5dd90e
Disable stub module docstrings to avoid issues with __future__ imports
dgelessus Feb 1, 2025
bcb68d3
Define a stable order for enum constants with equal values
dgelessus Feb 1, 2025
0f4eecd
Fix Python glue docstrings with missing space after "Params:"
dgelessus Feb 2, 2025
e23d7e0
Fix uncapitalized "false" in Python glue parameter defaults
dgelessus Feb 2, 2025
5059827
Update C++ docstrings that got out of sync with stubs for no good reason
dgelessus Feb 2, 2025
759cf91
Fix assorted missing parameter lists and defaults in Python glue
dgelessus Feb 2, 2025
0d90923
Add type annotation support to stub generator
dgelessus Feb 2, 2025
bb806e9
Add existing type annotations from stubs to C++-defined docstrings
dgelessus Feb 2, 2025
281e484
Add special case for Plasma needing an import of PlasmaConstants
dgelessus Feb 2, 2025
74dba5f
Add missing period to C++-defined PtYesNoDialog docstring
dgelessus Feb 2, 2025
e76a5a8
Regenerate Python stubs using generate_stubs.py
dgelessus Feb 2, 2025
7e9ba51
Add default values for keyword arguments to PtDebugPrint docstrings
dgelessus Feb 2, 2025
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
945 changes: 566 additions & 379 deletions Scripts/Python/plasma/Plasma.py

Large diffs are not rendered by default.

84 changes: 49 additions & 35 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 @@ -68,25 +80,25 @@ class PtAccountUpdateType:

class PtBehaviorTypes:
"""(none)"""
kBehaviorTypeFall = 8192
kBehaviorTypeIdle = 32
kBehaviorTypeStandingJump = 1
kBehaviorTypeWalkingJump = 2
kBehaviorTypeSidestepRight = 4096
kBehaviorTypeRunningJump = 4
kBehaviorTypeLinkIn = 65536
kBehaviorTypeAnyJump = 7
kBehaviorTypeRunningImpact = 8
kBehaviorTypeGroundImpact = 16
kBehaviorTypeAnyImpact = 24
kBehaviorTypeIdle = 32
kBehaviorTypeWalk = 64
kBehaviorTypeRun = 128
kBehaviorTypeTurnRight = 1024
kBehaviorTypeWalkBack = 256
kBehaviorTypeMovingTurnLeft = 16384
kBehaviorTypeGroundImpact = 16
kBehaviorTypeStandingJump = 1
kBehaviorTypeTurnLeft = 512
kBehaviorTypeAnyImpact = 24
kBehaviorTypeTurnRight = 1024
kBehaviorTypeSidestepLeft = 2048
kBehaviorTypeSidestepRight = 4096
kBehaviorTypeFall = 8192
kBehaviorTypeMovingTurnLeft = 16384
kBehaviorTypeMovingTurnRight = 32768
kBehaviorTypeLinkIn = 65536
kBehaviorTypeLinkOut = 131072

class PtBookEventTypes:
Expand All @@ -104,40 +116,43 @@ 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)"""
kNotifyOnUp = 0
kNotifyOnDown = 1
kNotifyOnUpAndDown = 2

class PtCCRPetitionType:
"""(none)"""
kGeneralHelp = 0
kBug = 1
kFeedback = 2
kExploit = 3
kHarass = 4
kStuck = 5
kTechnical = 6

class PtConfirmationResult:
OK = 1
"""(none)"""
Cancel = 0
Yes = 1
No = 0
OK = 1
Quit = 1
Yes = 1
Logout = 62

class PtConfirmationType:
"""(none)"""
OK = 0
ConfirmQuit = 1
ForceQuit = 2
YesNo = 3

class PtCCRPetitionType:
"""(none)"""
kGeneralHelp = 0
kBug = 1
kFeedback = 2
kExploit = 3
kHarass = 4
kStuck = 5
kTechnical = 6

class PtEventType:
"""(none)"""
kCollision = 1
Expand All @@ -155,6 +170,12 @@ class PtEventType:
kOfferLinkingBook = 14
kBook = 15

class PtFontFlags:
"""(none)"""
kFontBold = 1
kFontItalic = 2
kFontShadowed = 4

class PtGUIMultiLineDirection:
"""(none)"""
kLineStart = 1
Expand Down Expand Up @@ -182,12 +203,6 @@ class PtJustify:
kCenter = 1
kRightJustify = 2

class PtFontFlags:
"""(none)"""
kFontBold = 1
kFontItalic = 2
kFontShadowed = 4

class PtLOSObjectType:
"""(none)"""
kClickables = 0
Expand Down Expand Up @@ -247,13 +262,14 @@ class PtNotifyDataType:

class PtSDLReadWriteOptions:
"""(none)"""
kTimeStampOnRead = 16
kDirtyOnly = 1
kSkipNotificationInfo = 2
kBroadcast = 4
kTimeStampOnRead = 16

class PtSDLVarType:
"""(none)"""
kNone = -1
kInt = 0
kFloat = 1
kBool = 2
Expand All @@ -270,7 +286,6 @@ class PtSDLVarType:
kRGB = 52
kRGBA = 53
kQuaternion = 54
kNone = -1

class PtScoreRankGroups:
"""(none)"""
Expand All @@ -286,14 +301,13 @@ class PtScoreTimePeriods:

class PtStatusLogFlags:
"""(none)"""
kDebugOutput = 32
kFilledBackground = 1
kAppendToLast = 2
kDontWriteFile = 4
kDeleteForMe = 8
kAlignToTop = 16
kDebugOutput = 32
kTimestamp = 64
kStdout = 128
kTimeInSeconds = 256
kAlignToTop = 16
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,9 +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:
"""(none)"""
kGameJoinSuccess = 0
kGameJoinErrNotExist = 1
kGameJoinErrInitFailed = 2
Expand All @@ -53,12 +63,11 @@ class PtGameJoinError:
kGameJoinErrAlreadyJoined = 6
kGameJoinErrNoInvite = 7
kNumGameJoinErrors = 8
kGameJoinPending = -1

kGameJoinPending = 4294967295

class PtMarkerGameType:
"""(none)"""
kMarkerGameQuest = 0
kMarkerGameCGZ = 1
kMarkerGameCapture = 2
kMarkerGameCaptureAndHold = 3
kNumMarkerGameTypes = 4
Loading