Advertisement
CrankySupertoon

Untitled

Jun 20th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.79 KB | None | 0 0
  1. import time
  2. from ctypes import * # Used to interact with DLL
  3. from direct.task import Task # Used to manage the Callback timer
  4.  
  5. class DiscordRPC:
  6. zone2imgdesc =
  7. {
  8. 1000: ["rainbow-reef", "In Rainbow Reef"],
  9. 1100: ["coral-court", "On Coral Court"],
  10. 1200: ["ocean-overpass", "On Ocean Overpass"],
  11. 1300: ["pirate-place", "On Pirate Place"],
  12.  
  13. 2000: ["toon-island-central", "In Toon Island Central"],
  14. 2100: ["beach-ball-boulevard", "On Beach Ball Boulevard"],
  15. 2200: ["aloha-avenue", "On Aloha Avenue"],
  16. 2300: ["pineapple-place", "On Pineapple Place"],
  17.  
  18. 3000: ["cirrus-circus", "In Cirrus Circus"],
  19. 3100: ["balloon-boulevard", "On Balloon Boulevard"],
  20. 3200: ["horizon-hill", "On Horizon Hill"],
  21. 3300: ["stratus-strait", "On Stratus Strait"],
  22.  
  23. 4000: ["olive-oasis", "In Olive Oasis"],
  24. 4100: ["desert-drive", "On Desert Drive"],
  25. 4200: ["sandy-station", "On Sandy Station"],
  26. 4300: ["palm-tree-place", "On Palm Tree Place"],
  27.  
  28. 5000: ["withering-woods", "In Withering Woods"],
  29. 5100: ["willow-way", "On Willow Way"],
  30. 5200: ["torched-terrace", "On Torched Terrace"],
  31. 5300: ["dastardly-drive", "On Dastardly Drive"],
  32.  
  33. 6000: ["acorn-acres", "At Acorn Acres"],
  34.  
  35. 8000: ["toontown-speedway", "In Toontown Speedway"],
  36.  
  37. 9000: ["minty-mines", "In Minty Mines"],
  38. 9100: ["candy-close", "On Candy Close"],
  39. 9200: ["peppermint-place", "On Peppermint Place"],
  40.  
  41. 10000: ["bossbot-hq", "In Bossbot HQ"],
  42. 10100: ["bossbot-hq", "In the CEO Lobby"],
  43. 10500: ["front-three", "In the Front Three"],
  44. 10600: ["middle-six", "In the Middle Six"],
  45. 10700: ["back-nine", "In the Back Nine"],
  46.  
  47. 11000: ["sellbot-hq","At Sellbot HQ"],
  48. 11100: ["sellbot-hq", "In the VP Lobby"],
  49. 11200: ["sellbot-factory", "In the Sellbot Factory"],
  50. 11500: ["sellbot-factory", "In the Sellbot Factory"],
  51.  
  52. 12000: ["cashbot-hq", "At Cashbot HQ"],
  53. 12100: ["cashbot-hq", "In the CFO Lobby"],
  54. 12500: ["cashbot-mint", "In A Coin Mint"],
  55. 12600: ["cashbot-mint", "In A Dollar Mint"],
  56. 12700: ["cashbot-mint", "In A Bullion Mint"],
  57.  
  58. 13000: ["lawbot-hq", "At Lawbot HQ"],
  59. 13100: ["lawbot-hq","In The CJ Lobby"],
  60. 13200: ["lawbot-hq","In The DA Office Lobby"],
  61. 13300: ["lawbot-office", "In The Lawbot Office A"],
  62. 13400: ["lawbot-office", "In The Lawbot Office B"],
  63. 13500: ["lawbot-office", "In The Lawbot Office C"],
  64. 13600: ["lawbot-office", "In The Lawbot Office D"],
  65.  
  66. 14000: ["tutorial", "In The Toontorial"],
  67.  
  68.  
  69. 16000: ["estate", "At A Toon Estate"],
  70.  
  71. 17000: ["minigames", "In The Minigames Area"],
  72.  
  73. 18000: ["party", "At A Toon Party"],
  74. }
  75.  
  76. def __init__(self):
  77. self.CodeHandle = cdll.LoadLibrary("SDK.dll") # Load the RP code
  78. self.CodeHandle.DLLMain()
  79. self.UpdateTask = None
  80. self.details = "Loading" # The writing next to the photo
  81. self.image = "logo" #The main photo
  82. self.imageTxt = "Loading Toontown" # Hover text for the main photo
  83. self.smallLogo = "" # Small photo in corner
  84. self.smallTxt = "" # Text on hover of that photo
  85. self.state = "" # Displayed underneath details - used for boarding groups
  86. self.PartySize = 0
  87. self.MaxParty = 0
  88.  
  89. def stopBoarding(self): #Boarding groups :D
  90. self.PartySize = 0
  91. self.state = ""
  92. self.MaxParty = 0
  93. self.setData()
  94.  
  95. def AllowBoarding(self, size):
  96. self.state = "In A Boarding Group"
  97. self.PartySize = 1
  98. self.MaxParty = size
  99. self.setData()
  100.  
  101. def setBoarding(self, size): # Sets how many members are in a boarding group
  102. self.PartySize = size
  103. self.setData()
  104.  
  105. def setData(self): # Manually update all vars
  106. self.CodeHandle.DoCallbacks()
  107. details = self.details
  108. image = self.image
  109. imageTxt = self.imageTxt
  110. smallLogo = self.smallLogo
  111. smallTxt = self.smallTxt
  112. state = self.state
  113. party = self.PartySize
  114. maxSize = self.MaxParty
  115. self.CodeHandle.SetData(details.encode('utf_8'), state.encode('utf_8'), smallLogo.encode('utf_8'), smallTxt.encode('utf_8'), image.encode('utf_8'), imageTxt.encode('utf_8'), maxSize, party)
  116.  
  117. def DoCallbacks(self, task): # Recieves any messages from discord and handles them
  118. self.CodeHandle.DoCallbacks()
  119. return task.again
  120.  
  121. def UpdateTasks(self, task):
  122. self.UpdateTask = True
  123. self.setData()
  124. return task.again
  125.  
  126. def AvChoice(self): # Call in pick-a-toon
  127. self.image = "logo"
  128. self.details = "Picking-A-Toon"
  129. self.setData()
  130.  
  131. def Launching(self): # Call When loading game - toontownstart
  132. self.image = "logo"
  133. self.details = "Loading"
  134. self.setData()
  135.  
  136. def Making(self): # Call in make-a-toon
  137. self.image = "logo"
  138. self.details = "Making A Toon"
  139. self.setData()
  140.  
  141. def StartTasks(self): # Call JUST before base.run() in toontown-start
  142. taskMgr.doMethodLater(10, self.UpdateTasks, 'UpdateTask')
  143. taskMgr.doMethodLater(0.016, self.DoCallbacks, 'RPC-Callbacks')
  144.  
  145. def setZone(self,Zone): # Set image and text based on the zone
  146. if not isinstance(Zone, int):
  147. return
  148. Zone -= Zone % 100
  149. data = self.zone2imgdesc.get(Zone,None)
  150. if data:
  151. self.image = data[0]
  152. self.details = data[1]
  153. self.setData()
  154. else:
  155. print("Error: Zone Not Found!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement