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
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)
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)
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