Changeset 49


Ignore:
Timestamp:
04/30/09 02:10:48 (11 years ago)
Author:
maximinus_parpg
Message:

/utilities/gfxsplit.py now writes xml files as well.
Adjusted file structure for building objects.
Converted building1 to use split tile gfxs.
Looks ugly but it's a start.

Location:
trunk/PARPG
Files:
29 added
6 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/PARPG/maps/map.xml

    r46 r49  
    88        <import file="../objects/ground/block/block.xml"></import> 
    99         
    10         <import file="../objects/buildings/building1.xml"></import> 
    11         <import file="../objects/buildings/building2.xml"></import> 
    12         <import file="../objects/buildings/building3.xml"></import> 
     10        <import file="../objects/buildings/building1/building1a.xml"></import> 
     11        <import file="../objects/buildings/building1/building1b.xml"></import> 
     12        <import file="../objects/buildings/building1/building1c.xml"></import> 
     13        <import file="../objects/buildings/building1/building1d.xml"></import> 
     14        <import file="../objects/buildings/building1/building1e.xml"></import> 
     15        <import file="../objects/buildings/building1/building1f.xml"></import> 
     16        <import file="../objects/buildings/building1/building1g.xml"></import> 
     17         
     18        <import file="../objects/buildings/building1/building1h.xml"></import> 
     19        <import file="../objects/buildings/building2/building2.xml"></import> 
     20        <import file="../objects/buildings/building3/building3.xml"></import> 
    1321                 
    1422        <import file="../objects/ground/grass/transition/grass-tc01.xml"></import> 
     
    10771085                        <i x="11.0" o="block" z="0.0" y="-7.0" r="0"></i> 
    10781086                        <i x="12.0" o="block" z="0.0" y="-7.0" r="0"></i> 
    1079                         <i x="-6.0" o="building1" z="0.0" y="-13.0" r="0"></i> 
     1087                        <i x="-5.0" o="block" z="0.0" y="-12.0" r="0"></i> 
     1088                         
     1089                        <i x="-6.0" o="building1a" z="0.0" y="-13.0" r="0"></i> 
     1090                        <i x="-6.0" o="building1b" z="0.0" y="-12.0" r="0"></i> 
     1091                        <i x="-6.0" o="building1c" z="0.0" y="-11.0" r="0"></i> 
     1092                        <i x="-5.0" o="building1d" z="0.0" y="-11.0" r="0"></i> 
     1093                        <i x="-4.0" o="building1e" z="0.0" y="-11.0" r="0"></i> 
     1094                        <i x="-3.0" o="building1f" z="0.0" y="-11.0" r="0"></i> 
     1095                        <i x="-2.0" o="building1g" z="0.0" y="-11.0" r="0"></i> 
     1096                        <i x="-1.0" o="building1h" z="0.0" y="-11.0" r="0"></i> 
     1097 
     1098                        <i x="-6.0" o="block" z="0.0" y="-13.0" r="0"></i> 
    10801099                        <i x="-5.0" o="block" z="0.0" y="-13.0" r="0"></i> 
    10811100                        <i x="-4.0" o="block" z="0.0" y="-13.0" r="0"></i> 
     
    10831102                        <i x="-2.0" o="block" z="0.0" y="-13.0" r="0"></i> 
    10841103                        <i x="-1.0" o="block" z="0.0" y="-13.0" r="0"></i> 
    1085                         <i x="-6.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    1086                         <i x="-5.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    10871104                        <i x="-4.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    10881105                        <i x="-3.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    10891106                        <i x="-2.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    10901107                        <i x="-1.0" o="block" z="0.0" y="-12.0" r="0"></i> 
    1091                         <i x="-6.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    1092                         <i x="-6.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    1093                         <i x="-5.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    1094                         <i x="-4.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    1095                         <i x="-3.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    1096                         <i x="-2.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    1097                         <i x="-1.0" o="block" z="0.0" y="-11.0" r="0"></i> 
    10981108                        <i x="-4.0" o="block" z="0.0" y="3.0" r="0"></i> 
    10991109                        <i x="-4.0" o="block" z="0.0" y="4.0" r="0"></i> 
  • trunk/PARPG/utilities/gfxsplit.py

    r47 r49  
    2929        self.filename=name 
    3030 
    31 def SaveFiles(files): 
     31def writeXML(name): 
     32    """Write the XML file as well 
     33       Always the same small file so we do it automatically""" 
     34    # we need to strip off the entire path up to the last 
     35    # TODO: this code will not work on windows 
     36    # strip off the png part and replace with the XML 
     37    filename=name.split('/')[-1] 
     38    x_file=open(name[:-4]+".xml","wt") 
     39    x_file.write('''<?fife type="object"?>\n''') 
     40    x_file.write('''<object id="''') 
     41    x_file.write(filename[:-4]) 
     42    x_file.write('''" namespace="PARPG" blocking="1" static="1">\n''') 
     43    x_file.write('''    <image source="''') 
     44    x_file.write(filename) 
     45    x_file.write('''" direction="0" />\n''') 
     46    # the \n\n is ESSENTIAL otherwise the XML parser in FIFE craps out! 
     47    x_file.write('''</object>\n\n''') 
     48    x_file.close 
     49 
     50def saveFiles(files): 
    3251    """Given a list of TileImages, output them as seperate files 
    3352       Returns True if it worked""" 
     
    3756        try: 
    3857            pygame.image.save(i.image,i.filename) 
     58            # output the XML file as well 
     59            writeXML(i.filename) 
    3960        except: 
    4061            print "Error: Failed to save",filename 
     
    5071    return True 
    5172             
    52 def SplitImage(image,filename): 
     73def splitImage(image,filename): 
    5374    """Quite complex this, as there are many differing layouts on the 
    5475       hexes that we could be dealing with. However, for now we assume 
     
    7495            xpos+=(TILE_WIDTH/2) 
    7596        # store the image for later 
    76         tiles.append(TileImage(new_surface,filename+str(file_counter)+".png")) 
     97        tiles.append(TileImage(new_surface, 
     98            filename+chr(ord('a')+file_counter)+".png")) 
    7799        file_counter+=1 
    78100    return tiles 
    79101             
    80 def ConvertFiles(filename): 
     102def convertFiles(filename): 
    81103    """Take a file, slice into seperate images and then save these new images 
    82104       as filename0, filename1 ... filenameN 
     
    90112    # split into seperate files 
    91113    # the [:-4] is used to split off the .png from the filename 
    92     images=SplitImage(image,filename[:-4]) 
     114    images=splitImage(image,filename[:-4]) 
    93115    # save it and we are done 
    94116    if(images==[]): 
     
    96118        print "Error: Couldn't splice given image file" 
    97119        return False 
    98     return(SaveFiles(images)) 
     120    return(saveFiles(images)) 
    99121 
    100122if __name__=="__main__": 
     
    105127    # ok, so init pygame and do it 
    106128    pygame.init() 
    107     sys.exit(ConvertFiles(sys.argv[1])) 
     129    sys.exit(convertFiles(sys.argv[1])) 
    108130 
Note: See TracChangeset for help on using the changeset viewer.