def load():
    print("LOAD")
    themap = v.totalMap[str(v.currentID)][1][1]
    v.topTiles = py.sprite.Group()
    v.baseTiles = py.sprite.Group()
    v.tiles = py.sprite.Group()
    for x in range(len(themap[0])):
        for y in range(len(themap[1])):
            tp = None
            ep = False
            nc = None
            if "+" in themap[y][x]:
                ep = True
            if "&" in themap[y][x]:
                tp = literal_eval(themap[y][x].replace('&', "").split("|")[0])
            if "%" in themap[y][x]:
                nc = literal_eval(themap[y][x].replace('%', "").split("|")[0])
            
            if "|" in themap[y][x]:
                img = themap[y][x].split("|")[1]
            else:
                img = themap[y][x]
            v.topTiles.add(tileEdit.tile(x, y, "top", img, ep, tp, nc))
    
    themap = v.totalMap[str(v.currentID)][1][0]
    for x in range(len(themap[0])):
        for y in range(len(themap[1])):
            if "#" in themap[y][x]:
                hb = True
            else:
                hb = False
            if "|" in themap[y][x]:
                img = themap[y][x].split("|")[1]
            else:
                img = themap[y][x]
            img = img.strip("#")
            v.baseTiles.add(tileEdit.tile(x, y, "base", img, ep, tp, nc, hb))
    
    mapEditor()
def setup():
    tinps = py.sprite.Group()
    texts = py.sprite.Group()
    v.textNum = 1
    tinps.add(mapMenuItems.textInput((500, 100), 60, 2, 1, button=None, default=['1', '0'], type="int"))
    texts.add(mapMenuItems.textLabel("Map Width:", (240, 110), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    tinps.add(mapMenuItems.textInput((500, 180), 60, 2, 2, button=None, default=['1', '0'], type="int"))
    texts.add(mapMenuItems.textLabel("Map Height:", (240, 190), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    if v.tempId == None:
        df = ['1']
    else:
        df = list(str(v.tempId))
    tinps.add(mapMenuItems.textInput((500, 260), 60, 2, 3, button=None, default=df, type="int"))
    texts.add(mapMenuItems.textLabel("Map ID:", (240, 270), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    tinps.add(mapMenuItems.textInput((400, 350), 30, 24, 4, button=None, default=['P', 'l', 'a', 'c', 'e'], type="str"))
    texts.add(mapMenuItems.textLabel("Location Name:", (40, 350), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    tinps.add(mapMenuItems.textInput((500, 430), 40, 10, 5, button=None, default=['P', 'l', 'a', 'i', 'n', 's'], type="str"))
    texts.add(mapMenuItems.textLabel("Biome:", (240, 440), (0, 0, 0), "../Resources/Fonts/RPGSystem.ttf", 60))
    
    buttons = py.sprite.Group()
    buttons.add(mapMenuItems.button("Back", (10, 550),80, (255, 255, 255), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "B"))
    buttons.add(mapMenuItems.button("Continue", (690, 550), 70, (255, 255, 255), (255, 0, 0), "../Resources/Fonts/RPGSystem.ttf", "C"))
    
    while True:
        py.event.pump()
        v.events = []
        v.events = py.event.get()
        v.screen.fill((0, 255, 0))
        tinps.update()
        texts.update()
        buttons.update()
        py.display.flip()
        
        for b in buttons:
            if b.pressed():
                if py.mouse.get_pressed()[0]:
                    if b.ID == "B":
                        startMenu()
                        return
                    if b.ID == "C":
                        for i in tinps:
                            if i.num == 1:
                                x = int(i.outText)
                            if i.num == 2:
                                y = int(i.outText)
                            if i.num == 3:
                                v.currentID = int(i.outText)
                            if i.num == 4:
                                v.currentName = str(i.outText)
                            if i.num == 5:
                                v.currentBiome = str(i.outText)
                        v.size = (x, y)
                        v.baseTiles = py.sprite.Group()
                        v.topTiles = py.sprite.Group()
                        v.tiles = py.sprite.Group()
                        for x in range(v.size[0]):
                            for y in range(v.size[1]):
                                v.baseTiles.add(tileEdit.tile(x, y, "base"))
                                v.topTiles.add(tileEdit.tile(x, y, "top"))
                        mapEditor()
                        return