rustplus 6.1.0__tar.gz → 6.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. {rustplus-6.1.0/rustplus.egg-info → rustplus-6.1.1}/PKG-INFO +2 -1
  2. {rustplus-6.1.0 → rustplus-6.1.1}/requirements.txt +1 -0
  3. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/__init__.py +1 -1
  4. rustplus-6.1.1/rustplus/annotations/chat_event.py +34 -0
  5. rustplus-6.1.1/rustplus/annotations/clan_event.py +34 -0
  6. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/annotations/command.py +13 -0
  7. rustplus-6.1.1/rustplus/annotations/entity_event.py +32 -0
  8. rustplus-6.1.1/rustplus/annotations/protobuf_event.py +32 -0
  9. rustplus-6.1.1/rustplus/annotations/team_event.py +32 -0
  10. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/rust_api.py +9 -5
  11. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/__init__.py +1 -1
  12. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/utils.py +92 -50
  13. {rustplus-6.1.0 → rustplus-6.1.1/rustplus.egg-info}/PKG-INFO +2 -1
  14. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus.egg-info/SOURCES.txt +0 -35
  15. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus.egg-info/requires.txt +1 -0
  16. {rustplus-6.1.0 → rustplus-6.1.1}/setup.cfg +1 -1
  17. rustplus-6.1.0/rustplus/annotations/chat_event.py +0 -21
  18. rustplus-6.1.0/rustplus/annotations/clan_event.py +0 -21
  19. rustplus-6.1.0/rustplus/annotations/entity_event.py +0 -19
  20. rustplus-6.1.0/rustplus/annotations/protobuf_event.py +0 -19
  21. rustplus-6.1.0/rustplus/annotations/team_event.py +0 -19
  22. rustplus-6.1.0/rustplus/icons/airfield.png +0 -0
  23. rustplus-6.1.0/rustplus/icons/arctic_base.png +0 -0
  24. rustplus-6.1.0/rustplus/icons/bandit.png +0 -0
  25. rustplus-6.1.0/rustplus/icons/barn.png +0 -0
  26. rustplus-6.1.0/rustplus/icons/desert_base.png +0 -0
  27. rustplus-6.1.0/rustplus/icons/dome.png +0 -0
  28. rustplus-6.1.0/rustplus/icons/excavator.png +0 -0
  29. rustplus-6.1.0/rustplus/icons/ferryterminal.png +0 -0
  30. rustplus-6.1.0/rustplus/icons/fishing.png +0 -0
  31. rustplus-6.1.0/rustplus/icons/harbour.png +0 -0
  32. rustplus-6.1.0/rustplus/icons/jungle_ziggurat.png +0 -0
  33. rustplus-6.1.0/rustplus/icons/junkyard.png +0 -0
  34. rustplus-6.1.0/rustplus/icons/large_oil_rig.png +0 -0
  35. rustplus-6.1.0/rustplus/icons/launchsite.png +0 -0
  36. rustplus-6.1.0/rustplus/icons/lighthouse.png +0 -0
  37. rustplus-6.1.0/rustplus/icons/military_tunnels.png +0 -0
  38. rustplus-6.1.0/rustplus/icons/mining_outpost.png +0 -0
  39. rustplus-6.1.0/rustplus/icons/mining_quarry_hqm.png +0 -0
  40. rustplus-6.1.0/rustplus/icons/mining_quarry_stone.png +0 -0
  41. rustplus-6.1.0/rustplus/icons/mining_quarry_sulfur.png +0 -0
  42. rustplus-6.1.0/rustplus/icons/missile_silo.png +0 -0
  43. rustplus-6.1.0/rustplus/icons/outpost.png +0 -0
  44. rustplus-6.1.0/rustplus/icons/oxums.png +0 -0
  45. rustplus-6.1.0/rustplus/icons/power_plant.png +0 -0
  46. rustplus-6.1.0/rustplus/icons/radtown.png +0 -0
  47. rustplus-6.1.0/rustplus/icons/satellite.png +0 -0
  48. rustplus-6.1.0/rustplus/icons/sewer.png +0 -0
  49. rustplus-6.1.0/rustplus/icons/small_oil_rig.png +0 -0
  50. rustplus-6.1.0/rustplus/icons/stables.png +0 -0
  51. rustplus-6.1.0/rustplus/icons/supermarket.png +0 -0
  52. rustplus-6.1.0/rustplus/icons/swamp.png +0 -0
  53. rustplus-6.1.0/rustplus/icons/train.png +0 -0
  54. rustplus-6.1.0/rustplus/icons/train_yard.png +0 -0
  55. rustplus-6.1.0/rustplus/icons/underwater_lab.png +0 -0
  56. rustplus-6.1.0/rustplus/icons/water_treatment.png +0 -0
  57. {rustplus-6.1.0 → rustplus-6.1.1}/LICENSE +0 -0
  58. {rustplus-6.1.0 → rustplus-6.1.1}/MANIFEST.in +0 -0
  59. {rustplus-6.1.0 → rustplus-6.1.1}/README.md +0 -0
  60. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/annotations/__init__.py +0 -0
  61. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/commands/__init__.py +0 -0
  62. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/commands/chat_command.py +0 -0
  63. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/commands/chat_command_data.py +0 -0
  64. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/commands/command_options.py +0 -0
  65. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/events/__init__.py +0 -0
  66. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/events/chat_event.py +0 -0
  67. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/events/clan_info_event.py +0 -0
  68. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/events/entity_event.py +0 -0
  69. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/events/protobuf_event.py +0 -0
  70. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/events/team_event.py +0 -0
  71. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/exceptions/__init__.py +0 -0
  72. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/exceptions/exceptions.py +0 -0
  73. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/__init__.py +0 -0
  74. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/cargo.png +0 -0
  75. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/chinook.png +0 -0
  76. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/chinook_blades.png +0 -0
  77. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/crate.png +0 -0
  78. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/explosion.png +0 -0
  79. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/icon.png +0 -0
  80. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/patrol.png +0 -0
  81. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/icons/vending_machine.png +0 -0
  82. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/identification/__init__.py +0 -0
  83. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/identification/handler_list.py +0 -0
  84. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/identification/registered_listener.py +0 -0
  85. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/identification/server_details.py +0 -0
  86. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/__init__.py +0 -0
  87. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/camera/__init__.py +0 -0
  88. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/camera/camera_constants.py +0 -0
  89. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/camera/camera_manager.py +0 -0
  90. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/camera/camera_parser.py +0 -0
  91. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/camera/structures.py +0 -0
  92. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/fcm/__init__.py +0 -0
  93. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/fcm/fcm_listener.py +0 -0
  94. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/nexus/__init__.py +0 -0
  95. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/nexus/nexus_interface.py +0 -0
  96. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/proxy/__init__.py +0 -0
  97. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/proxy/proxy_value_grabber.py +0 -0
  98. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/ratelimiter/__init__.py +0 -0
  99. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/rustplus_proto/__init__.py +0 -0
  100. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/rustplus_proto/rustplus.py +0 -0
  101. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/websocket/__init__.py +0 -0
  102. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/remote/websocket/ws.py +0 -0
  103. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/__init__.py +0 -0
  104. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/clans/__init__.py +0 -0
  105. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/clans/rust_clan_info.py +0 -0
  106. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/clans/rust_clan_message.py +0 -0
  107. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_chat_message.py +0 -0
  108. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_contents.py +0 -0
  109. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_entity_info.py +0 -0
  110. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_error.py +0 -0
  111. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_info.py +0 -0
  112. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_item.py +0 -0
  113. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_map.py +0 -0
  114. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_marker.py +0 -0
  115. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_team_info.py +0 -0
  116. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/rust_time.py +0 -0
  117. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/serialization.py +0 -0
  118. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/structs/util.py +0 -0
  119. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/deprecated.py +0 -0
  120. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/emojis.py +0 -0
  121. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/fonts/PermanentMarker.ttf +0 -0
  122. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/fonts/__init__.py +0 -0
  123. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/grab_items.py +0 -0
  124. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus/utils/yielding_event.py +0 -0
  125. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus.egg-info/dependency_links.txt +0 -0
  126. {rustplus-6.1.0 → rustplus-6.1.1}/rustplus.egg-info/top_level.txt +0 -0
  127. {rustplus-6.1.0 → rustplus-6.1.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rustplus
3
- Version: 6.1.0
3
+ Version: 6.1.1
4
4
  Summary: A python wrapper for the Rust Plus API
5
5
  Home-page: https://github.com/olijeffers0n/rustplus
6
6
  Author: olijeffers0n
@@ -18,6 +18,7 @@ Requires-Dist: requests
18
18
  Requires-Dist: numpy
19
19
  Requires-Dist: scipy
20
20
  Requires-Dist: betterproto==2.0.0b7
21
+ Requires-Dist: resvg
21
22
  Dynamic: author
22
23
  Dynamic: description
23
24
  Dynamic: description-content-type
@@ -7,3 +7,4 @@ requests
7
7
  numpy
8
8
  scipy
9
9
  betterproto==2.0.0b7
10
+ resvg
@@ -22,5 +22,5 @@ from .structs import RustError, RustMarker, Vector
22
22
 
23
23
  __name__ = "rustplus"
24
24
  __author__ = "olijeffers0n"
25
- __version__ = "6.1.0"
25
+ __version__ = "6.1.1"
26
26
  __support__ = "Discord: https://discord.gg/nQqJe8qvP8"
@@ -0,0 +1,34 @@
1
+ from typing import Callable
2
+
3
+ from .. import ServerDetails
4
+ from ..identification import RegisteredListener
5
+ from ..events import ChatEventPayload as ChatEventManager
6
+
7
+
8
+ def ChatEvent(server_details: ServerDetails) -> Callable:
9
+
10
+ def wrapper(func) -> RegisteredListener:
11
+
12
+ if isinstance(func, RegisteredListener):
13
+ func = func.get_coro()
14
+
15
+ listener = RegisteredListener(func.__name__, func)
16
+
17
+ ChatEventManager.HANDLER_LIST.register(listener, server_details)
18
+
19
+ return listener
20
+
21
+ if not isinstance(server_details, ServerDetails):
22
+ if callable(server_details):
23
+ message = (
24
+ "ChatEvent decorator requires a ServerDetails object as an argument. You have probably "
25
+ "forgotten the brackets on the decorator to pass the server details object."
26
+ )
27
+ else:
28
+ message = (
29
+ "ChatEvent decorator requires a ServerDetails object as an argument. Please provide a valid "
30
+ "ServerDetails instance."
31
+ )
32
+ raise TypeError(message)
33
+
34
+ return wrapper
@@ -0,0 +1,34 @@
1
+ from typing import Callable
2
+
3
+ from .. import ServerDetails
4
+ from ..identification import RegisteredListener
5
+ from ..events import ClanInfoEventPayload as ClanInfoEventManager
6
+
7
+
8
+ def ClanEvent(server_details: ServerDetails) -> Callable:
9
+
10
+ def wrapper(func) -> RegisteredListener:
11
+
12
+ if isinstance(func, RegisteredListener):
13
+ func = func.get_coro()
14
+
15
+ listener = RegisteredListener(func.__name__, func)
16
+
17
+ ClanInfoEventManager.HANDLER_LIST.register(listener, server_details)
18
+
19
+ return listener
20
+
21
+ if not isinstance(server_details, ServerDetails):
22
+ if callable(server_details):
23
+ message = (
24
+ "ClanEvent decorator requires a ServerDetails object as an argument. You have probably "
25
+ "forgotten the brackets on the decorator to pass the server details object."
26
+ )
27
+ else:
28
+ message = (
29
+ "ClanEvent decorator requires a ServerDetails object as an argument. Please provide a valid "
30
+ "ServerDetails instance."
31
+ )
32
+ raise TypeError(message)
33
+
34
+ return wrapper
@@ -20,4 +20,17 @@ def Command(
20
20
 
21
21
  return RegisteredListener(func.__name__, func)
22
22
 
23
+ if not isinstance(server_details, ServerDetails):
24
+ if callable(server_details):
25
+ message = (
26
+ "Command decorator requires a ServerDetails object as an argument. You have probably "
27
+ "forgotten the brackets on the decorator to pass the server details object."
28
+ )
29
+ else:
30
+ message = (
31
+ "Command decorator requires a ServerDetails object as an argument. Please provide a valid "
32
+ "ServerDetails instance."
33
+ )
34
+ raise TypeError(message)
35
+
23
36
  return wrapper
@@ -0,0 +1,32 @@
1
+ from typing import Callable
2
+
3
+ from .. import ServerDetails
4
+ from ..identification import RegisteredListener
5
+ from ..events import EntityEventPayload as EntityEventManager
6
+
7
+
8
+ def EntityEvent(server_details: ServerDetails, eid: int) -> Callable:
9
+ def wrapper(func) -> RegisteredListener:
10
+ if isinstance(func, RegisteredListener):
11
+ func = func.get_coro()
12
+
13
+ listener = RegisteredListener(str(eid), func)
14
+
15
+ EntityEventManager.HANDLER_LIST.register(listener, server_details)
16
+
17
+ return listener
18
+
19
+ if not isinstance(server_details, ServerDetails):
20
+ if callable(server_details):
21
+ message = (
22
+ "EntityEvent decorator requires a ServerDetails object as an argument. You have probably "
23
+ "forgotten the brackets on the decorator to pass the server details object."
24
+ )
25
+ else:
26
+ message = (
27
+ "EntityEvent decorator requires a ServerDetails object as an argument. Please provide a valid "
28
+ "ServerDetails instance."
29
+ )
30
+ raise TypeError(message)
31
+
32
+ return wrapper
@@ -0,0 +1,32 @@
1
+ from typing import Callable
2
+
3
+ from .. import ServerDetails
4
+ from ..identification import RegisteredListener
5
+ from ..events import ProtobufEventPayload as ProtobufEventManager
6
+
7
+
8
+ def ProtobufEvent(server_details: ServerDetails) -> Callable:
9
+ def wrapper(func) -> RegisteredListener:
10
+ if isinstance(func, RegisteredListener):
11
+ func = func.get_coro()
12
+
13
+ listener = RegisteredListener(func.__name__, func)
14
+
15
+ ProtobufEventManager.HANDLER_LIST.register(listener, server_details)
16
+
17
+ return listener
18
+
19
+ if not isinstance(server_details, ServerDetails):
20
+ if callable(server_details):
21
+ message = (
22
+ "ProtobufEvent decorator requires a ServerDetails object as an argument. You have probably "
23
+ "forgotten the brackets on the decorator to pass the server details object."
24
+ )
25
+ else:
26
+ message = (
27
+ "ProtobufEvent decorator requires a ServerDetails object as an argument. Please provide a valid "
28
+ "ServerDetails instance."
29
+ )
30
+ raise TypeError(message)
31
+
32
+ return wrapper
@@ -0,0 +1,32 @@
1
+ from typing import Callable
2
+
3
+ from .. import ServerDetails
4
+ from ..identification import RegisteredListener
5
+ from ..events import TeamEventPayload as TeamEventManager
6
+
7
+
8
+ def TeamEvent(server_details: ServerDetails) -> Callable:
9
+ def wrapper(func) -> RegisteredListener:
10
+ if isinstance(func, RegisteredListener):
11
+ func = func.get_coro()
12
+
13
+ listener = RegisteredListener(func.__name__, func)
14
+
15
+ TeamEventManager.HANDLER_LIST.register(listener, server_details)
16
+
17
+ return listener
18
+
19
+ if not isinstance(server_details, ServerDetails):
20
+ if callable(server_details):
21
+ message = (
22
+ "TeamEvent decorator requires a ServerDetails object as an argument. You have probably "
23
+ "forgotten the brackets on the decorator to pass the server details object."
24
+ )
25
+ else:
26
+ message = (
27
+ "TeamEvent decorator requires a ServerDetails object as an argument. Please provide a valid "
28
+ "ServerDetails instance."
29
+ )
30
+ raise TypeError(message)
31
+
32
+ return wrapper
@@ -44,7 +44,7 @@ from .utils import (
44
44
  fetch_avatar_icon,
45
45
  format_coord,
46
46
  convert_marker,
47
- convert_monument,
47
+ convert_monument_to_image,
48
48
  )
49
49
  from .remote.ratelimiter import RateLimiter
50
50
  from .utils.utils import error_present
@@ -317,6 +317,9 @@ class RustSocket:
317
317
  await self.get_markers() if add_events or add_vending_machines else []
318
318
  )
319
319
 
320
+ if isinstance(map_markers, RustError):
321
+ return map_markers
322
+
320
323
  if add_icons:
321
324
  for monument in monuments:
322
325
  if str(monument.token) == "DungeonBase":
@@ -326,11 +329,12 @@ class RustSocket:
326
329
  # reported as separate markers next to the lab; they aren't
327
330
  # standalone monuments, so don't draw them.
328
331
  continue
329
- icon = convert_monument(monument.token, override_images)
332
+
330
333
  if monument.token in override_images:
331
- icon = icon.resize((150, 150))
332
- if str(monument.token) == "train_tunnel_display_name":
333
- icon = icon.resize((100, 125))
334
+ icon = override_images[monument.token].resize((150, 150))
335
+ else:
336
+ icon = convert_monument_to_image(monument.token)
337
+
334
338
  output.paste(
335
339
  icon,
336
340
  (format_coord(int(monument.x), int(monument.y), map_size)),
@@ -5,7 +5,7 @@ from .utils import (
5
5
  fetch_avatar_icon,
6
6
  format_coord,
7
7
  convert_marker,
8
- convert_monument,
8
+ convert_monument_to_image,
9
9
  convert_event_type_to_name,
10
10
  convert_coordinates,
11
11
  )
@@ -1,10 +1,13 @@
1
1
  import logging
2
2
  import string
3
3
  from importlib import resources
4
- from typing import Tuple, Dict
4
+ from typing import Tuple
5
5
 
6
6
  import requests
7
7
  from PIL import ImageFont, Image, ImageDraw
8
+ from pathlib import Path
9
+ from resvg import render, usvg
10
+ from io import BytesIO
8
11
 
9
12
  ICONS_PATH = "rustplus.icons"
10
13
  FONT_PATH = "rustplus.utils.fonts"
@@ -179,64 +182,69 @@ def convert_marker(marker_type: int, angle) -> Image.Image:
179
182
  return icon
180
183
 
181
184
 
182
- def convert_monument(name: str, override_images: Dict[str, Image.Image]) -> Image.Image:
185
+ def convert_monument_to_image(name: str) -> Image.Image:
183
186
  name_to_file = {
184
- "supermarket": "supermarket.png",
185
- "mining_outpost_display_name": "mining_outpost.png",
186
- "gas_station": "oxums.png",
187
- "fishing_village_display_name": "fishing.png",
188
- "large_fishing_village_display_name": "fishing.png",
189
- "lighthouse_display_name": "lighthouse.png",
190
- "excavator": "excavator.png",
191
- "water_treatment_plant_display_name": "water_treatment.png",
192
- "train_yard_display_name": "train_yard.png",
193
- "outpost": "outpost.png",
194
- "bandit_camp": "bandit.png",
195
- "jungle_ziggurat": "jungle_ziggurat.png",
196
- "junkyard_display_name": "junkyard.png",
197
- "dome_monument_name": "dome.png",
198
- "satellite_dish_display_name": "satellite.png",
199
- "power_plant_display_name": "power_plant.png",
200
- "military_tunnels_display_name": "military_tunnels.png",
201
- "airfield_display_name": "airfield.png",
202
- "launchsite": "launchsite.png",
203
- "sewer_display_name": "sewer.png",
204
- "oil_rig_small": "small_oil_rig.png",
205
- "large_oil_rig": "large_oil_rig.png",
206
- "underwater_lab": "underwater_lab.png",
207
- "AbandonedMilitaryBase": "desert_base.png",
208
- "ferryterminal": "ferryterminal.png",
209
- "harbor_display_name": "harbour.png",
210
- "harbor_2_display_name": "harbour.png",
211
- "arctic_base_a": "arctic_base.png",
212
- "arctic_base_b": "arctic_base.png",
213
- "missile_silo_monument": "missile_silo.png",
214
- "stables_a": "stables.png",
215
- "stables_b": "stables.png",
216
- "mining_quarry_stone_display_name": "mining_quarry_stone.png",
217
- "mining_quarry_sulfur_display_name": "mining_quarry_sulfur.png",
218
- "mining_quarry_hqm_display_name": "mining_quarry_hqm.png",
219
- "train_tunnel_link_display_name": "train.png",
220
- "train_tunnel_display_name": "train.png",
221
- "radtown": "radtown.png",
187
+ "ferryterminal": "Ferry_Terminal.svg",
188
+ "train_tunnel_display_name": "Tunnel_Entrance.svg",
189
+ "train_tunnel_link_display_name": "Tunnel_Entrance.svg",
190
+ "apartmentcomplex": "Apartments_Complex.svg",
191
+ "harbor_display_name": "Harbor.svg",
192
+ "harbor_2_display_name": "Harbor.svg",
193
+ "large_fishing_village_display_name": "Fishing_Village.svg",
194
+ "fishing_village_display_name": "Fishing_Village.svg",
195
+ "AbandonedMilitaryBase": "Military_Base.svg",
196
+ "power_plant_display_name": "Powerplant.svg",
197
+ "missile_silo_monument": "Missile_Silo.svg",
198
+ "outpost": "Outpost.svg",
199
+ "bandit_camp": "Bandit_Camp.svg",
200
+ "stables_a": "Stables.svg",
201
+ "stables_b": "Stables.svg",
202
+ "mining_quarry_stone_display_name": "Stone_Quarry.svg",
203
+ "mining_quarry_sulfur_display_name": "Sulfur_Quarry.svg",
204
+ "mining_quarry_hqm_display_name": "HQM_Quarry.svg",
205
+ "satellite_dish_display_name": "Satellite_Dish.svg",
206
+ "dome_monument_name": "Dome.svg",
207
+ "junkyard_display_name": "Junkyard.svg",
208
+ "sewer_display_name": "Sewer_Branch.svg",
209
+ "oil_rig_small": "Oil_Rig_Small.svg",
210
+ "large_oil_rig": "Oil_Rig_Large.svg",
211
+ "lighthouse_display_name": "Lighthouse.svg",
212
+ "mining_outpost_display_name": "Mining_Outpost.svg",
213
+ "supermarket": "Supermarket.svg",
214
+ "arctic_base_a": "Arctic_Research_Base.svg",
215
+ "arctic_base_b": "Arctic_Research_Base.svg",
216
+ "launchsite": "Launch_Site.svg",
217
+ "water_treatment_plant_display_name": "Water_Treatment.svg",
218
+ "excavator": "Excavator.svg",
219
+ "train_yard_display_name": "Trainyard.svg",
220
+ "airfield_display_name": "Airfield.svg",
221
+ "military_tunnels_display_name": "Military_Tunnels.svg",
222
+ "gas_station": "Gas_Station.svg",
223
+ "jungle_ziggurat": "Jungle_Ziggurat.svg",
224
+ "radtown": "Radtown.svg",
222
225
  }
223
226
 
224
- try:
225
- return override_images[name]
226
- except KeyError:
227
- pass
228
-
229
227
  if name in name_to_file:
230
228
  file_name = name_to_file[name]
231
229
  with resources.path(ICONS_PATH, file_name) as path:
232
- icon = Image.open(path).convert("RGBA")
230
+ if file_name.endswith(".png"):
231
+ return Image.open(path).convert("RGBA")
232
+ elif file_name.endswith(".svg"):
233
+ return svg_to_pil(path, (150, 150))
234
+ else:
235
+ logging.getLogger("rustplus.py").info(
236
+ f"{name} - Has no icon, report this as an issue"
237
+ )
238
+ with resources.path(ICONS_PATH, "icon.png") as path:
239
+ return Image.open(path).convert("RGBA")
240
+
233
241
  elif "swamp" in name:
234
- with resources.path(ICONS_PATH, "swamp.png") as path:
235
- icon = Image.open(path).convert("RGBA")
242
+ with resources.path(ICONS_PATH, "Swamp.svg") as path:
243
+ return svg_to_pil(path, (150, 150))
236
244
  elif "underwater_lab" in name:
237
245
  # Same story with swamp, no rust+ specific token so prefab name is sent instead
238
- with resources.path(ICONS_PATH, "underwater_lab.png") as path:
239
- icon = Image.open(path).convert("RGBA")
246
+ with resources.path(ICONS_PATH, "Underwater_Lab.svg") as path:
247
+ return svg_to_pil(path, (150, 150))
240
248
  else:
241
249
  logging.getLogger("rustplus.py").info(
242
250
  f"{name} - Has no icon, report this as an issue"
@@ -245,3 +253,37 @@ def convert_monument(name: str, override_images: Dict[str, Image.Image]) -> Imag
245
253
  icon = Image.open(path).convert("RGBA")
246
254
 
247
255
  return icon
256
+
257
+
258
+ def svg_to_pil(filepath: str | Path, size: tuple[int, int]) -> Image.Image:
259
+ target_w, target_h = size
260
+
261
+ svg = Path(filepath).read_text()
262
+
263
+ opts = usvg.Options.default()
264
+ tree = usvg.Tree.from_str(svg, opts)
265
+
266
+ orig_w, orig_h = tree.int_size()
267
+
268
+ # Preserve aspect ratio (fit inside target)
269
+ scale_x = target_w / orig_w
270
+ scale_y = target_h / orig_h
271
+ scale = min(scale_x, scale_y) # use max for "cover" behavior
272
+
273
+ # center the scaled image in the target canvas
274
+ tx = (target_w - orig_w * scale) / 2.0
275
+ ty = (target_h - orig_h * scale) / 2.0
276
+
277
+ # transform tuple format: (a, b, c, d, e, f)
278
+ # corresponds to the affine matrix rows:
279
+ # [ a b c ]
280
+ # [ d e f ]
281
+ transform_fit = (scale, 0.0, tx, 0.0, scale, ty)
282
+
283
+ png_bytes = render(
284
+ tree,
285
+ transform_fit,
286
+ bg_size=(target_w, target_h),
287
+ )
288
+
289
+ return Image.open(BytesIO(png_bytes)).convert("RGBA")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rustplus
3
- Version: 6.1.0
3
+ Version: 6.1.1
4
4
  Summary: A python wrapper for the Rust Plus API
5
5
  Home-page: https://github.com/olijeffers0n/rustplus
6
6
  Author: olijeffers0n
@@ -18,6 +18,7 @@ Requires-Dist: requests
18
18
  Requires-Dist: numpy
19
19
  Requires-Dist: scipy
20
20
  Requires-Dist: betterproto==2.0.0b7
21
+ Requires-Dist: resvg
21
22
  Dynamic: author
22
23
  Dynamic: description
23
24
  Dynamic: description-content-type
@@ -31,49 +31,14 @@ rustplus/events/team_event.py
31
31
  rustplus/exceptions/__init__.py
32
32
  rustplus/exceptions/exceptions.py
33
33
  rustplus/icons/__init__.py
34
- rustplus/icons/airfield.png
35
- rustplus/icons/arctic_base.png
36
- rustplus/icons/bandit.png
37
- rustplus/icons/barn.png
38
34
  rustplus/icons/cargo.png
39
35
  rustplus/icons/chinook.png
40
36
  rustplus/icons/chinook_blades.png
41
37
  rustplus/icons/crate.png
42
- rustplus/icons/desert_base.png
43
- rustplus/icons/dome.png
44
- rustplus/icons/excavator.png
45
38
  rustplus/icons/explosion.png
46
- rustplus/icons/ferryterminal.png
47
- rustplus/icons/fishing.png
48
- rustplus/icons/harbour.png
49
39
  rustplus/icons/icon.png
50
- rustplus/icons/jungle_ziggurat.png
51
- rustplus/icons/junkyard.png
52
- rustplus/icons/large_oil_rig.png
53
- rustplus/icons/launchsite.png
54
- rustplus/icons/lighthouse.png
55
- rustplus/icons/military_tunnels.png
56
- rustplus/icons/mining_outpost.png
57
- rustplus/icons/mining_quarry_hqm.png
58
- rustplus/icons/mining_quarry_stone.png
59
- rustplus/icons/mining_quarry_sulfur.png
60
- rustplus/icons/missile_silo.png
61
- rustplus/icons/outpost.png
62
- rustplus/icons/oxums.png
63
40
  rustplus/icons/patrol.png
64
- rustplus/icons/power_plant.png
65
- rustplus/icons/radtown.png
66
- rustplus/icons/satellite.png
67
- rustplus/icons/sewer.png
68
- rustplus/icons/small_oil_rig.png
69
- rustplus/icons/stables.png
70
- rustplus/icons/supermarket.png
71
- rustplus/icons/swamp.png
72
- rustplus/icons/train.png
73
- rustplus/icons/train_yard.png
74
- rustplus/icons/underwater_lab.png
75
41
  rustplus/icons/vending_machine.png
76
- rustplus/icons/water_treatment.png
77
42
  rustplus/identification/__init__.py
78
43
  rustplus/identification/handler_list.py
79
44
  rustplus/identification/registered_listener.py
@@ -7,3 +7,4 @@ requests
7
7
  numpy
8
8
  scipy
9
9
  betterproto==2.0.0b7
10
+ resvg
@@ -1,5 +1,5 @@
1
1
  [metadata]
2
- description-file = README
2
+ description_file = README
3
3
 
4
4
  [egg_info]
5
5
  tag_build =
@@ -1,21 +0,0 @@
1
- from typing import Callable
2
-
3
- from .. import ServerDetails
4
- from ..identification import RegisteredListener
5
- from ..events import ChatEventPayload as ChatEventManager
6
-
7
-
8
- def ChatEvent(server_details: ServerDetails) -> Callable:
9
-
10
- def wrapper(func) -> RegisteredListener:
11
-
12
- if isinstance(func, RegisteredListener):
13
- func = func.get_coro()
14
-
15
- listener = RegisteredListener(func.__name__, func)
16
-
17
- ChatEventManager.HANDLER_LIST.register(listener, server_details)
18
-
19
- return listener
20
-
21
- return wrapper
@@ -1,21 +0,0 @@
1
- from typing import Callable
2
-
3
- from .. import ServerDetails
4
- from ..identification import RegisteredListener
5
- from ..events import ClanInfoEventPayload as ClanInfoEventManager
6
-
7
-
8
- def ClanEvent(server_details: ServerDetails) -> Callable:
9
-
10
- def wrapper(func) -> RegisteredListener:
11
-
12
- if isinstance(func, RegisteredListener):
13
- func = func.get_coro()
14
-
15
- listener = RegisteredListener(func.__name__, func)
16
-
17
- ClanInfoEventManager.HANDLER_LIST.register(listener, server_details)
18
-
19
- return listener
20
-
21
- return wrapper
@@ -1,19 +0,0 @@
1
- from typing import Callable
2
-
3
- from .. import ServerDetails
4
- from ..identification import RegisteredListener
5
- from ..events import EntityEventPayload as EntityEventManager
6
-
7
-
8
- def EntityEvent(server_details: ServerDetails, eid: int) -> Callable:
9
- def wrapper(func) -> RegisteredListener:
10
- if isinstance(func, RegisteredListener):
11
- func = func.get_coro()
12
-
13
- listener = RegisteredListener(str(eid), func)
14
-
15
- EntityEventManager.HANDLER_LIST.register(listener, server_details)
16
-
17
- return listener
18
-
19
- return wrapper
@@ -1,19 +0,0 @@
1
- from typing import Callable
2
-
3
- from .. import ServerDetails
4
- from ..identification import RegisteredListener
5
- from ..events import ProtobufEventPayload as ProtobufEventManager
6
-
7
-
8
- def ProtobufEvent(server_details: ServerDetails) -> Callable:
9
- def wrapper(func) -> RegisteredListener:
10
- if isinstance(func, RegisteredListener):
11
- func = func.get_coro()
12
-
13
- listener = RegisteredListener(func.__name__, func)
14
-
15
- ProtobufEventManager.HANDLER_LIST.register(listener, server_details)
16
-
17
- return listener
18
-
19
- return wrapper
@@ -1,19 +0,0 @@
1
- from typing import Callable
2
-
3
- from .. import ServerDetails
4
- from ..identification import RegisteredListener
5
- from ..events import TeamEventPayload as TeamEventManager
6
-
7
-
8
- def TeamEvent(server_details: ServerDetails) -> Callable:
9
- def wrapper(func) -> RegisteredListener:
10
- if isinstance(func, RegisteredListener):
11
- func = func.get_coro()
12
-
13
- listener = RegisteredListener(func.__name__, func)
14
-
15
- TeamEventManager.HANDLER_LIST.register(listener, server_details)
16
-
17
- return listener
18
-
19
- return wrapper
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
File without changes
File without changes
File without changes