コード例 #1
0
def openMap(url):
    global root
    fileName = url
    if not os.path.exists(fileName):
        fileName = os.path.join(root, 'data', 'assets', 'maps', url + ".feods")
        if not os.path.exists(fileName):
            fileName = os.path.join(root, 'data', 'assets', 'maps', "random", url + ".feods")
    if not os.path.exists(fileName):
        raise Exception("File {} is not found (latest {})".format(url, fileName))

    name = str(os.path.basename(fileName)).partition('.')[0]
    tmp = os.path.join(root, "data", "state", "maps.open")
    return feods.load(name, os.path.dirname(fileName), temp=tmp)
コード例 #2
0
 def loadMap(self, url):
     url = url.replace('.feods', '')
     print("Path: " + url)
     paths = [url, os.path.join(self.root_path, 'data', 'assets', 'maps', url), os.path.join(self.root_path, 'data', 'assets', 'maps', "random", url)]
     for fileName in paths:
         if os.path.exists(fileName + ".feods"):
             name = str(os.path.basename(fileName))
             tmp = os.path.join(self.root_path, "data", "state", "maps.open")
             print("File {}.feods has name {} and open to {}".format(fileName, name, tmp))
             return feods.load(name, os.path.dirname(fileName), temp=tmp)
         else:
             print("Not found {}.feods".format(fileName))
     raise Exception(res.str_resources[46].format(url, fileName))
コード例 #3
0
 def regen(self, event):
     # Generate a new map with old parameters and reopen
     mess = res.str_resources[44]
     userChoise = messagebox.askyesnocancel(title=res.str_resources[45], message=mess, default=messagebox.YES)
     if userChoise: # YES
         self.save(None)
     elif userChoise is None: # CANCEL
         return
     # How we name a new map?
     name = simpledialog.askstring(title=res.str_resources[0], prompt=res.str_resources[1])
     if name is None:
         messagebox.showerror(title=res.str_resources[28], message=res.str_resources[2])
         return
     w = self.source.face
     t = self.source.top
     b = self.source.bottom
     p = self.source.meta['PlayersLimit']
     a = self.source.meta['Level']
     r = len(self.source.domains)
     if event is None:
         pattern = self.source.meta.get('Generator', 'Classic')
     else:
         pattern = event
     if type(pattern) == type(0):
         pattern = "Classic"
     z = self.ZOOM
     waitForm = dialogs.Splash(caption=res.str_resources[28], comment=res.str_resources[65], parent=self)
     exe = os.path.join(self.root_path, 'tools', 'new_map.py')
     command = "python {0} -n={1} -f={2} -s={3} -t={4} -b={5} -p={6} -l={7} -r={8} -c={9} -z={10}".format(exe, name, name, w, t, b, p, a, r, pattern, z)
     print(command)
     output = os.system(command)
     print(output)
     print("")
     waitForm.progress['value'] = 50
     waitForm.title(res.str_resources[20])
     waitForm.message.set(res.str_resources[21])
     # Load from file
     tmp = os.path.join(self.root_path, "data", "state", "maps.open", name)
     fileName = os.path.join(self.root_path, 'data', 'assets', 'maps', "random")
     if not os.path.exists(os.path.join(fileName, name + ".feods")):
         waitForm.destroy()
         self.deiconify()
         messagebox.showerror(title=res.str_resources[20], message=res.str_resources[64].format(name))
         return
     mapBox = feods.load(name, path=fileName, temp=tmp)
     # Reset window controllers
     mapBox['meta']['Title'] = name
     self.reset(mapBox, pattern=pattern, edition=time.ctime(time.time()))
     waitForm.destroy()
     self.deiconify()
コード例 #4
0
 def new(self, event):
     mess = res.str_resources[44]
     if self.modify:
         userChoise = messagebox.askyesnocancel(title=res.str_resources[45], message=mess, default=messagebox.YES)
         if userChoise: # YES
             self.save(event)
         elif userChoise is None: # CANCEL
             return
     # Options of new map.
     config = MetaWindow(meta={}, isNew=True, parent=self)
     self.wait_window(config)
     props = config.meta
     self.source.rehead(props)
     #
     name = self.source.name
     w = self.source.face
     t = self.source.top
     b = self.source.bottom
     p = self.source.meta['PlayersLimit']
     a = self.source.meta['Level']
     r = 0
     pattern = "New"
     z = self.ZOOM
     waitForm = dialogs.Splash(caption=res.str_resources[28], comment=res.str_resources[65], parent=self)
     exe = os.path.join(self.root_path, 'tools', 'new_map.py')
     command = "python {0} -n={1} -f={2} -s={3} -t={4} -b={5} -p={6} -l={7} -r={8} -c={9} -z={10}".format(exe, name, name, w, t, b, p, a, r, pattern, z)
     print(command)
     output = os.system(command)
     print(output)
     print("")
     waitForm.progress['value'] = 50
     waitForm.title(res.str_resources[20])
     waitForm.message.set(res.str_resources[21])
     # Load from file
     tmp = os.path.join(self.root_path, "data", "state", "maps.open", name)
     fileName = os.path.join(self.root_path, 'data', 'assets', 'maps', "random")
     if not os.path.exists(os.path.join(fileName, name + ".feods")):
         waitForm.destroy()
         self.deiconify()
         messagebox.showerror(title=res.str_resources[20], message=res.str_resources[64].format(name))
         return
     mapBox = feods.load(name, path=fileName, temp=tmp)
     # Reset window controllers
     mapBox['meta']['Title'] = name
     self.reset(mapBox, pattern=pattern, edition=time.ctime(time.time()))
     waitForm.destroy()
     self.deiconify()
コード例 #5
0
def create(name, config):
    global root
    global tools

    # Use script
    w = config["width"]
    t = config['top']
    b = config['bottom']
    p = config['players']
    a = config['age']
    r = config['regions']
    pattern = config['pattern']
    z = config['zoom']
    output = os.system("python {0}/new_map.py -n={1} -f={2} -s={3} -t={4} -b={5} -p={6} -l={7} -r={8} -c={9} -z={10}".format(tools, name, name, w, t, b, p, a, r, pattern, z))
    print(output)
    print("")
    # Load
    tmp = os.path.join(root, "data", "state", "maps.open", name)
    fileName = os.path.join(root, 'data', 'assets', 'maps', "random")
    return feods.load(name, path=fileName, temp=tmp)
コード例 #6
0
import argparse
import feodal.feods as feods
import mapgenrandom as pattern


def console():
    parser = argparse.ArgumentParser()
    parser.add_argument('-s', '--source', default='test')
    parser.add_argument('-p', '--path', default='out')
    parser.add_argument('-d', '--dest', default='copy')
    return parser


if __name__ == "__main__":
    parser = console()
    args = parser.parse_args()

    packet = feods.load(args.source, args.path)
    print(packet['meta']['Title'], "{0}x{0}".format(packet['meta']['Face']))
    #template = pattern.unpack(packet, args.path)
    #feods.save(template, args.dest, args.path)
コード例 #7
0
try:
    xrange
except Exception:
    xrange = range


def console():
    parser = argparse.ArgumentParser()
    parser.add_argument('-n', '--name', help="Title of Patterm")
    parser.add_argument(
        '-s',
        '--source',
        help="Name of Map (*.feods) file as source of pattern.")
    parser.add_argument('-d',
                        '--dest',
                        help="Name of new Pattern (*.worldbox) file.")
    return parser.parse_args()


if __name__ == '__main__':
    args = console()
    sourceDiretory = os.path.join(root, 'data', 'assests', 'maps')
    destFilePath = os.path.join(root, 'data', 'assest', 'patterns')
    tempDirectory = os.path.join(root, 'data', 'state', 'maps.open')

    package = feods.load(args.source, path='random', sourceDiretory)
    world = World.Map(package)
    template = mt.MapTemplate(parser.name, world.landscapes)
    template.createFromMap(world)