示例#1
0
def load_flags_file(name):
    img = graphics.load_image('data/flags/%s-output.png' % name)
    for line in osutil.open_res('data/flags/%s.index' % name):
        name, rect = line.split(' ', 1)
        rect = map(int, rect.split())
        flag = graphics.create_surface_small(rect[2], rect[3])
        flag.blit(img, (0, 0), rect)
        flag_index[name] = flag
示例#2
0
def load_flags_file(name):
    img = graphics.load_image('data/flags/%s-output.png' % name)
    for line in osutil.open_res('data/flags/%s.index' % name):
        name, rect = line.split(' ', 1)
        rect = map(int, rect.split())
        flag = graphics.create_surface_small(rect[2], rect[3])
        flag.blit(img, (0, 0), rect)
        flag_index[name] = flag
示例#3
0
def _load_help():
    acum = []
    title = None
    lines = osutil.open_res('data/android-help.txt').read().splitlines()
    for line in lines:
        if line.startswith('=== '):
            if acum: yield title, '\n'.join(acum)
            acum = []
            title = line[4:]
        else:
            acum.append(line)
    if acum: yield title, '\n'.join(acum)
示例#4
0
def _load_help():
    acum = []
    title = None
    lines = osutil.open_res('userdata/android-help.txt').read().splitlines()
    for line in lines:
        if line.startswith('=== '):
            if acum: yield title, '\n'.join(acum)
            acum = []
            title = line[4:]
        else:
            acum.append(line)
    if acum: yield title, '\n'.join(acum)
示例#5
0
def load_techtree(fn):
    edges = []
    nodes = []
    size = None
    for line in osutil.open_res(fn):
        tpl = split(line.strip())
        if tpl[0] == 'graph':
            size = map(float, tpl[2:4])
        elif tpl[0] == 'node':
            name = tpl[1]
            rect = map(float, tpl[2:6])
            nodes.append((name, rect))
        elif tpl[0] == 'edge':
            coord = map(float, tpl[4:-2])
            assert len(coord) % 2 == 0
            points = zip(coord[::2], coord[1::2])
            edges.append(points)
    return size, edges, nodes
def load_techtree(fn):
    edges = []
    nodes = []
    size = None
    for line in osutil.open_res(fn):
        tpl = split(line.strip())
        if tpl[0] == 'graph':
            size = map(float, tpl[2:4])
        elif tpl[0] == 'node':
            name = tpl[1]
            rect = map(float, tpl[2:6])
            nodes.append((name, rect))
        elif tpl[0] == 'edge':
            coord = map(float, tpl[4:-2])
            assert len(coord) % 2 == 0
            points = zip(coord[::2], coord[1::2])
            edges.append(points)
    return size, edges, nodes