Skip to content

Commit

Permalink
Map Code fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
olijeffers0n committed Oct 22, 2021
1 parent 1ca5d5a commit 620131b
Showing 1 changed file with 34 additions and 35 deletions.
69 changes: 34 additions & 35 deletions rustplus/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,43 +94,42 @@ async def __getAndFormatMap(self, addIcons : bool, addEvents : bool, addVendingM
map, monuments = await self.__getMap(MAPSIZE)

if addIcons or addEvents or addVendingMachines:
mapMarkers = await self.__getMarkers()
cood_formatter = CoordUtil()

if addIcons:
monument_name_converter = MonumentNameToImage(overrideImages)
for monument in monuments:
if str(monument.token) == "DungeonBase":
continue
icon = monument_name_converter.convert(monument.token)
icon = icon.resize((150, 150))
if str(monument.token) == "train_tunnel_display_name":
icon = icon.resize((100, 125))
map.paste(icon, (cood_formatter.format(int(monument.x), int(monument.y), MAPSIZE)), icon)

mapMarkers = list((await self.__getMarkers()).response.mapMarkers.markers)

if addVendingMachines:
with resources.path("rustplus.api.icons", "vending_machine.png") as path:
vendingMachine = Image.open(path).convert("RGBA")
vendingMachine = vendingMachine.resize((100, 100))

for marker in mapMarkers:
if addEvents:
markerConverter = MapMarkerConverter()
if marker.type == 2 or marker.type == 4 or marker.type == 5 or marker.type == 6:
icon = markerConverter.convert(str(marker.type), marker.rotation)
if marker.type == 6:
x = marker.x
y = marker.y
if y > MAPSIZE: y = MAPSIZE
if y < 0: y = 100
if x > MAPSIZE: x = MAPSIZE - 75
if x < 0: x = 50
map.paste(icon, (int(x), MAPSIZE - int(y)), icon)
else:
map.paste(icon, (cood_formatter.format(int(marker.x), int(marker.y), MAPSIZE)), icon)
if addVendingMachines and marker.type == 3:
map.paste(vendingMachine, (int(marker.x) - 50, MAPSIZE - int(marker.y) - 50), vendingMachine)
if addIcons:
monument_name_converter = MonumentNameToImage(overrideImages)
for monument in monuments:
if str(monument.token) == "DungeonBase":
continue
icon = monument_name_converter.convert(monument.token)
icon = icon.resize((150, 150))
if str(monument.token) == "train_tunnel_display_name":
icon = icon.resize((100, 125))
map.paste(icon, (cood_formatter.format(int(monument.x), int(monument.y), MAPSIZE)), icon)

if addVendingMachines:
with resources.path("rustplus.api.icons", "vending_machine.png") as path:
vendingMachine = Image.open(path).convert("RGBA")
vendingMachine = vendingMachine.resize((100, 100))

for marker in mapMarkers:
if addEvents:
markerConverter = MapMarkerConverter()
if marker.type == 2 or marker.type == 4 or marker.type == 5 or marker.type == 6:
icon = markerConverter.convert(str(marker.type), marker.rotation)
if marker.type == 6:
x = marker.x
y = marker.y
if y > MAPSIZE: y = MAPSIZE
if y < 0: y = 100
if x > MAPSIZE: x = MAPSIZE - 75
if x < 0: x = 50
map.paste(icon, (int(x), MAPSIZE - int(y)), icon)
else:
map.paste(icon, (cood_formatter.format(int(marker.x), int(marker.y), MAPSIZE)), icon)
if addVendingMachines and marker.type == 3:
map.paste(vendingMachine, (int(marker.x) - 50, MAPSIZE - int(marker.y) - 50), vendingMachine)

return map.resize((2000, 2000), Image.ANTIALIAS)

Expand Down

0 comments on commit 620131b

Please sign in to comment.