Ejemplo n.º 1
0
    def openFile(self, w3xInfo=None):
        if self.w3x:
            mapInfo = read_W3E(w3xInfo)
            self.mapInfo = mapInfo

            print("Time to generate a topdown")
            #time to run TopDownViewer
            topdownImage = self.WC3_Topdown_ImageGen.createImage(
                mapInfo, self.debugSettings)
            print("Generated.")
            self.topDownTab.setImage(topdownImage)

            tmpInfo = copy.copy(mapInfo)
            del tmpInfo["info"]
            self.headerTab.setText(
                simplejson.dumps(tmpInfo, sort_keys=True, indent=4 * ' '))
        else:
            options = {
                "initialdir": "input/",
                "initialfile": "war3map.w3e",
                "defaultextension": ".w3e",
                "filetypes": [("Warcraft III Terrain", ".w3e")],
                "title": "This is a title"
            }
            filename = askopenfilename(**options)
            self.filenameText.set(filename)
            if filename:
                with open(filename, "rb") as mapfile:
                    mapInfo = read_W3E(mapfile)
                    self.mapInfo = mapInfo

                if self.rawOption.get() == 1:
                    self.rawTab.setInfo(mapInfo)

                if self.topDownOption.get() == 1:
                    print("Time to generate a topdown")
                    #time to run TopDownViewer
                    topdownImage = self.WC3_Topdown_ImageGen.createImage(
                        mapInfo, self.debugSettings)
                    print("Generated.")
                    self.topDownTab.setImage(topdownImage)

                tmpInfo = mapInfo
                del tmpInfo["info"]
                self.headerTab.setText(
                    simplejson.dumps(tmpInfo, sort_keys=True, indent=4 * ' '))
            else:
                self.headerInfoText.set("")
Ejemplo n.º 2
0
 def openFile(self, w3xInfo = None):
     if self.w3x:
         mapInfo = read_W3E(w3xInfo)
         self.mapInfo = mapInfo
         
         print("Time to generate a topdown")
         #time to run TopDownViewer
         topdownImage = self.WC3_Topdown_ImageGen.createImage(mapInfo, self.debugSettings)
         print("Generated.")
         self.topDownTab.setImage(topdownImage)
             
         tmpInfo = copy.copy(mapInfo)
         del tmpInfo["info"]
         self.headerTab.setText(simplejson.dumps(tmpInfo, sort_keys=True, indent=4 * ' '))
     else:
         options = {
             "initialdir" : "input/",
             "initialfile" : "war3map.w3e",
             "defaultextension" : ".w3e",
             "filetypes"    : [("Warcraft III Terrain", ".w3e")],
             "title" : "This is a title"
         }
         filename = askopenfilename(**options)
         self.filenameText.set(filename)
         if filename:
             with open(filename, "rb") as mapfile:
                 mapInfo = read_W3E(mapfile)
                 self.mapInfo = mapInfo
             
             if self.rawOption.get() == 1:
                 self.rawTab.setInfo(mapInfo)
                 
             if self.topDownOption.get() == 1:
                 print("Time to generate a topdown")
                 #time to run TopDownViewer
                 topdownImage = self.WC3_Topdown_ImageGen.createImage(mapInfo, self.debugSettings)
                 print("Generated.")
                 self.topDownTab.setImage(topdownImage)
                 
             tmpInfo = mapInfo
             del tmpInfo["info"]
             self.headerTab.setText(simplejson.dumps(tmpInfo, sort_keys=True, indent=4 * ' '))
         else:
             self.headerInfoText.set("")
Ejemplo n.º 3
0
 def __readWar3map__(self):
     start = timer()
     
     with open(self.wc3_filename, "rb") as f:
         self.wc3_mapinfo = read_W3E(f)
         
     self.debug_timetaken["WC3 Map Reading"] = timer()-start
     
     self.WC3map_xSize =  self.wc3_mapinfo["width"]
     self.WC3map_ySize =  self.wc3_mapinfo["height"]
     self.WC3map_zSize = 15 # The maximal layer height for a wc3 map is 15 
     
     self.WC3map_heightmap, self.WC3map_rampmap, maxHeight = self.__war3_setup_bytemaps__()
Ejemplo n.º 4
0
def write(f, indent, string):
    f.write(indent*"    " + string + "\n")
    
wc3fileName = "input/TreeTag,TFI_5.13 (1).w3x-war3map.w3e" #TODO: Replace with better system
doodadFileName = "input/TreeTag,TFI_5.13 (1).w3x-war3map.doo"
dotafileName = "output/war3map_treetag_t.vmf" # ^
if len(sys.argv)>0:
    wc3fileName = sys.argv[0]
if len(sys.argv)>1:
    doodadFileName = sys.argv[1]
if len(sys.argv)>2:
    dotafileName = sys.argv[2]
print("Starting up...")

with open(wc3fileName, "rb") as f:
    wc3_mapinfo = read_W3E(f)
    print("Making a map that will be:")
    print(" {x}x{y}".format(x=wc3_mapinfo["width"]*128,y=wc3_mapinfo["height"]*128))
    print(" contain {0} textures*".format(len(wc3_mapinfo["groundTileSets"])))
    print(" and therefor, each texture will be {0} different".format(256.0/len(wc3_mapinfo["groundTileSets"])))
    with open(dotafileName, "w") as f:
        indent = 0
        f.write("""cameras
{
}
cordon
{
    "mins" "(99999 99999 99999)"
    "maxs" "(-99999 -99999 -99999)"
    "active" "0"
}
Ejemplo n.º 5
0
    f.write(indent * "    " + string + "\n")


wc3fileName = "input/TreeTag,TFI_5.13 (1).w3x-war3map.w3e"  #TODO: Replace with better system
doodadFileName = "input/TreeTag,TFI_5.13 (1).w3x-war3map.doo"
dotafileName = "output/war3map_treetag_t.vmf"  # ^
if len(sys.argv) > 0:
    wc3fileName = sys.argv[0]
if len(sys.argv) > 1:
    doodadFileName = sys.argv[1]
if len(sys.argv) > 2:
    dotafileName = sys.argv[2]
print("Starting up...")

with open(wc3fileName, "rb") as f:
    wc3_mapinfo = read_W3E(f)
    print("Making a map that will be:")
    print(" {x}x{y}".format(x=wc3_mapinfo["width"] * 128,
                            y=wc3_mapinfo["height"] * 128))
    print(" contain {0} textures*".format(len(wc3_mapinfo["groundTileSets"])))
    print(" and therefor, each texture will be {0} different".format(
        256.0 / len(wc3_mapinfo["groundTileSets"])))
    with open(dotafileName, "w") as f:
        indent = 0
        f.write("""cameras
{
}
cordon
{
    "mins" "(99999 99999 99999)"
    "maxs" "(-99999 -99999 -99999)"