11import builtins
2+ from datetime import datetime
23import getopt
34import glob
45import json
@@ -255,7 +256,8 @@ def startUp(self, dnaPath = None):
255256 ('page_down' , self .pageDown ),
256257 ('shift-o' , self .toggleOrth ),
257258 ('f12' , self .screenshot ),
258- ('shift-f12' , self .renderMap ),
259+ ('shift-f12' , self .renderMapScaled ),
260+ ('alt-f12' , self .renderMap ), # doesnt do automatic stuff, likely wont get used, but just incase
259261 ('control-c' , self .toggleVisibleCollisions ),
260262 ('control-s' , self .outputDNADefaultFile ),
261263 ('tab' , self .enterGlobalRadialMenu )
@@ -3555,8 +3557,9 @@ async def renderMap(self):
35553557 return
35563558
35573559 # Save the above frame to the maps folder
3558- # Saves as maprender-DAY-MM-DD-HH-MM-SS-YYYY-SOMETHING.png
3559- base .screenshot (f"maps/maprender" )
3560+ # Saves as map_neighborhood_datetime.png
3561+ base .screenshot (f"maps/map_{ self .neighborhood } _{ datetime .now ().strftime ('%Y_%m_%d-%I_%M_%S_%p' )} .png" ,
3562+ defaultFilename = 0 )
35603563
35613564 # Unhide the marker and dropshadows
35623565 for marker in markers :
@@ -3574,6 +3577,65 @@ async def renderMap(self):
35743577 props .setSize (normX , normY )
35753578 base .win .requestProperties (props )
35763579
3580+ async def renderMapScaled (self ):
3581+ """
3582+ Render a map with automatic scaling and data
3583+ """
3584+
3585+ # Get the bounds
3586+ tl = self .getNPToplevel ()
3587+ bounds = tl .getBounds ()
3588+ radius = bounds .getRadius ()
3589+ center = bounds .getCenter ()
3590+
3591+ size = (radius * 2 )
3592+
3593+ # Set the film size to the size above
3594+ self .orthLens .setFilmSize (size , size )
3595+
3596+ # Set the camera to the center of the street
3597+ base .camera .setPos (center )
3598+
3599+ # And move it back up
3600+ base .camera .setZ (100 )
3601+
3602+ # make it look down
3603+ base .camera .setHpr (0 , - 90 , 0 )
3604+
3605+ # Force orth cam
3606+ self .orthCam = True
3607+ base .cam .node ().setLens (self .orthLens )
3608+
3609+ # Export the map
3610+ await self .renderMap ()
3611+
3612+ # Calculate the corners
3613+ tr = Vec3 (center [0 ] + radius , center [1 ] + radius , 0 )
3614+ bl = Vec3 (center [0 ] - radius , center [1 ] - radius , 0 )
3615+
3616+ data = "This file is automatically generated by the Open Level Editor\n " \
3617+ "https://github.com/OpenToontownTools/TTOpenLevelEditor\n " \
3618+ "This data is to be entered in $TOONTOWN/src/quest/QuestMapGlobals\n \n "
3619+
3620+ # Write the top right, and bottom left corners
3621+ # This is the order used in $TOONTOWN/src/quest/QuestMapGlobals
3622+ data += f"Corners:(Top Right, Bottom Left):\n { tr } , { bl } \n "
3623+
3624+ # Get the HQ position (if there is one)
3625+ hq = tl .find ("**/*toon_landmark_hq*" )
3626+ if not hq .isEmpty ():
3627+ data += f"HQ Position:\n { hq .getPos ()} \n "
3628+
3629+ # Get the Fishing Pond position (if there is one)
3630+ pond = tl .find ("**/*_pond*" )
3631+ if not pond .isEmpty ():
3632+ data += f"Fishing Pond Position:\n { pond .getPos ()} "
3633+
3634+ # Write the data to a txt file
3635+ file = open (f"maps/map_{ self .neighborhood } _data_{ datetime .now ().strftime ('%Y_%m_%d-%I_%M_%S_%p' )} .txt" , 'w' )
3636+ file .write (data )
3637+ file .close ()
3638+
35773639 def toggleOrth (self ):
35783640 if not self .orthCam :
35793641 base .cam .node ().setLens (self .orthLens )
0 commit comments