def draw_dialog(dialog_id): _dialog = get_dialog(dialog_id) _last_message = get_last_message(dialog_id) _x = numbers.clip(MAP_WINDOW_SIZE[0]/2-len(_last_message['text'])/2, 3, 100) _y = 10 _line_of_sight = drawing.diag_line(LIFE[_dialog['started_by']]['pos'], LIFE[_dialog['target']]['pos']) locks.unlock('camera_free') if len(_line_of_sight)<=1: _center_pos = LIFE[_dialog['started_by']]['pos'] else: _center_pos = list(_line_of_sight[len(_line_of_sight)/2]) _center_pos.append(2) if SETTINGS['controlling'] == _dialog['started_by']: _target = _dialog['target'] else: _target = _dialog['started_by'] _target_portrait = lfe.draw_life_icon(LIFE[_target]) _lines = [] gfx.camera_track(_center_pos) gfx.blit_string(_x-2, _y-2, ' '.join(LIFE[_target]['name']), 'overlay', fore_color=_target_portrait[1]) gfx.blit_string(_x-2, _y, _target_portrait[0], 'overlay', fore_color=_target_portrait[1])#, back_color=tcod.darkest_gray) _text = _last_message['text'] _y_mod = 0 while _text: _x = MAP_WINDOW_SIZE[0]/2-len(_text[:MAP_WINDOW_SIZE[0]-4])/2 gfx.blit_string(_x, _y+_y_mod, _text[:MAP_WINDOW_SIZE[0]-4], 'overlay') _text = _text[MAP_WINDOW_SIZE[0]-4:] _y_mod += 1 for choice in _dialog['choices']: _text = choice['text'][choice['text'].index('\"')+1:choice['text'].index('\"')-1] if not _text.startswith('>'): _text = '> '+_text _n_x = MAP_WINDOW_SIZE[0]/2-len(_text)/2 if _n_x < _x: _x = _n_x for choice in _dialog['choices']: _text = choice['text'][choice['text'].index('\"')+1:choice['text'].index('\"')-1] if _dialog['cursor_index'] == _dialog['choices'].index(choice): _text = '> '+_text _lines.append(_text) for line in _lines: gfx.blit_string(_x, _y+3, line, 'overlay')#, back_color=tcod.darkest_gray) _y += 2
def create_target_list(): _menu_items = [] for target_id in LIFE[SETTINGS['controlling']]['seen']: if LIFE[target_id]['dead']: continue if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append(create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) return _menu_items
def _create_target_list(target_list): _menu_items = [] _near_targets = [] _group_targets = [] if LIFE[SETTINGS['controlling']]['group']: _group = alife.groups.get_group(LIFE[SETTINGS['controlling']], LIFE[SETTINGS['controlling']]['group']) else: _group = None for target_id in target_list: if LIFE[target_id]['dead'] or target_id == SETTINGS['controlling']: continue if target_id in LIFE[SETTINGS['controlling']]['seen']: _near_targets.append(target_id) if _group and target_id in _group['members']: _group_targets.append(target_id) if _near_targets: _menu_items.append(create_item('title', 'Near', None)) for target_id in _near_targets: if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append( create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) if _group_targets: _menu_items.append(create_item('title', 'Group', None)) for target_id in _group_targets: if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append( create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) if not target_list: return [] _menu_items.append(create_item('title', 'All', None)) for target_id in target_list: if target_id == SETTINGS['controlling']: continue if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append( create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) return _menu_items
def draw_dialog(dialog_id): _dialog = get_dialog(dialog_id) _last_message = get_last_message(dialog_id) _x = bad_numbers.clip( MAP_WINDOW_SIZE[0] / 2 - len(_last_message['text']) / 2, 3, 100) _y = 10 _line_of_sight = drawing.diag_line(LIFE[_dialog['started_by']]['pos'], LIFE[_dialog['target']]['pos']) locks.unlock('camera_free') if len(_line_of_sight) <= 1: _center_pos = LIFE[_dialog['started_by']]['pos'] else: _center_pos = list(_line_of_sight[len(_line_of_sight) / 2]) _center_pos.append(2) if SETTINGS['controlling'] == _dialog['started_by']: _target = _dialog['target'] else: _target = _dialog['started_by'] _target_portrait = lfe.draw_life_icon(LIFE[_target]) _lines = [] gfx.camera_track(_center_pos) gfx.blit_string(_x - 2, _y - 2, ' '.join(LIFE[_target]['name']), 'overlay', fore_color=_target_portrait[1]) gfx.blit_string( _x - 2, _y, _target_portrait[0], 'overlay', fore_color=_target_portrait[1]) #, back_color=tcod.darkest_gray) _text = _last_message['text'] _y_mod = 0 while _text: _x = MAP_WINDOW_SIZE[0] / 2 - len(_text[:MAP_WINDOW_SIZE[0] - 4]) / 2 gfx.blit_string(_x, _y + _y_mod, _text[:MAP_WINDOW_SIZE[0] - 4], 'overlay') _text = _text[MAP_WINDOW_SIZE[0] - 4:] _y_mod += 1 for choice in _dialog['choices']: _text = choice['text'][choice['text'].index('\"') + 1:choice['text'].index('\"') - 1] if not _text.startswith('>'): _text = '> ' + _text _n_x = MAP_WINDOW_SIZE[0] / 2 - len(_text) / 2 if _n_x < _x: _x = _n_x for choice in _dialog['choices']: _text = choice['text'][choice['text'].index('\"') + 1:choice['text'].index('\"') - 1] if _dialog['cursor_index'] == _dialog['choices'].index(choice): _text = '> ' + _text _lines.append(_text) for line in _lines: gfx.blit_string(_x, _y + 3, line, 'overlay') #, back_color=tcod.darkest_gray) _y += 2
def _create_target_list(target_list): _menu_items = [] _near_targets = [] _group_targets = [] if LIFE[SETTINGS['controlling']]['group']: _group = alife.groups.get_group(LIFE[SETTINGS['controlling']], LIFE[SETTINGS['controlling']]['group']) else: _group = None for target_id in target_list: if LIFE[target_id]['dead'] or target_id == SETTINGS['controlling']: continue if target_id in LIFE[SETTINGS['controlling']]['seen']: _near_targets.append(target_id) if _group and target_id in _group['members']: _group_targets.append(target_id) if _near_targets: _menu_items.append(create_item('title', 'Near', None)) for target_id in _near_targets: if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append(create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) if _group_targets: _menu_items.append(create_item('title', 'Group', None)) for target_id in _group_targets: if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append(create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) if not target_list: return [] _menu_items.append(create_item('title', 'All', None)) for target_id in target_list: if target_id == SETTINGS['controlling']: continue if not _menu_items: SETTINGS['following'] = target_id _color = life.draw_life_icon(LIFE[target_id])[1] _menu_items.append(create_item('single', ' '.join(LIFE[target_id]['name']), None, target=target_id, color=(_color, tcod.color_lerp(_color, tcod.white, 0.5)))) return _menu_items