def set(self, info_list: List[str], width: int, column: int): """ 设置绘制信息 Keyword arguments: info_list -- 信息列表 width -- 绘制宽度 column -- 每行最大元素数 """ self.width = width self.column = column new_info_list = value_handle.list_of_groups(info_list, column) for now_info_list in new_info_list: now_width = int(width / column) now_list = [] index = 0 now_sub_width = 0 for now_info in now_info_list: if index == len(now_info_list) - 1: now_width = self.width - now_sub_width else: index += 1 now_sub_width += now_width now_info_draw = draw.LeftDraw() now_info_draw.width = now_width now_info_draw.text = now_info now_list.append(now_info_draw) self.draw_list.append(now_list)
def set(self, info_list: List[draw.NormalDraw], width: int, column: int): """ 设置绘制信息 Keyword arguments: info_list -- 绘制对象列表 width -- 绘制宽度 column -- 每行最大元素数 """ self.width = width self.column = column self.draw_list = value_handle.list_of_groups(info_list, column)
def draw(self): """ 绘制对象 """ title_draw = draw.TitleLineDraw(_("人物性格"), self.width) title_draw.draw() for value in self.draw_list: if isinstance(value, list): now_draw = panel.VerticalDrawTextListGroup(self.width) now_group = value_handle.list_of_groups(value, 1) now_draw.draw_list = now_group now_draw.draw() else: value.draw()
def set( self, text_list: List[str], start_id: int, width: int, column: int, null_text: str = "", cmd_func: FunctionType = None, func_args: List[Tuple] = [], ): """ 设置绘制信息 Keyword arguments: text_list -- 按钮文本列表 start_id -- 编号的启始id width -- 绘制宽度 column -- 每行最大元素数 null_text -- 不作为按钮绘制的文本 cmd_func -- 列表元素按钮绑定函数 """ self.width = width self.column = column new_text_list = value_handle.list_of_groups(text_list, column) index = start_id now_index = 0 self.draw_list: List[List[draw.Button]] = [] for now_text_list in new_text_list: now_width = int(width / len(now_text_list)) now_list = [] for now_text in now_text_list: if now_text != null_text: now_text = text_handle.id_index(index) + now_text now_button = draw.LeftButton( now_text, str(index), now_width, cmd_func=cmd_func, args=(func_args[now_index]), ) now_list.append(now_button) self.return_list.append(str(index)) else: now_text = text_handle.id_index(index) + now_text now_info_draw = draw.LeftDraw() now_info_draw.width = now_width now_info_draw.text = now_text now_info_draw.style = "onbutton" now_list.append(now_info_draw) index += 1 now_index += 1 self.draw_list.append(now_list)
def set( self, text_list: List[str], return_list: List[str], width: int, column: int, null_text: str = "", cmd_func: FunctionType = None, ): """ 设置绘制信息 Keyword arguments: text_list -- 按钮文本列表 return_list -- 按钮返回列表 width -- 绘制宽度 column -- 每行最大元素数 null_text -- 不作为按钮绘制的文本 cmd_func -- 列表元素按钮绑定函数 """ self.width = width self.column = column new_text_list = value_handle.list_of_groups(text_list, column) index = 0 self.return_list = return_list self.draw_list: List[List[draw.Button]] = [] for now_text_list in new_text_list: now_width = int(width / len(now_text_list)) now_list = [] for now_text in now_text_list: if now_text != null_text: now_button = draw.CenterButton( now_text, return_list[index], now_width, cmd_func=cmd_func, args=(return_list[index]), ) now_list.append(now_button) else: now_info_draw = draw.CenterDraw() now_info_draw.width = now_width now_info_draw.text = now_text now_info_draw.style = "onbutton" now_list.append(now_info_draw) index += 1 self.draw_list.append(now_list)
def __init__(self, character_id: int, width: int): """ 初始化绘制对象 """ self.character_id: int = character_id """ 要绘制的角色id """ self.width: int = width """ 面板最大宽度 """ self.draw_list: List[draw.NormalDraw] = [] """ 绘制的文本列表 """ self.return_list: List[str] = [] """ 当前面板监听的按钮列表 """ character_data = cache.character_data[character_id] for nature_type in game_config.config_nature_tag: type_config = game_config.config_nature_tag[nature_type] nature_set = game_config.config_nature_tag_data[nature_type] type_value = 0 nature_draw_list = [] nature_group = value_handle.list_of_groups(list(nature_set), 1) for nature_list in nature_group: for nature_id in nature_list: nature_config = game_config.config_nature[nature_id] nature_value = 0 if nature_id in character_data.nature: nature_value = character_data.nature[nature_id] type_value += nature_value good_judge = False if nature_value >= 50: good_judge = True nature_draw = draw.CenterDraw() if good_judge: nature_draw.text = nature_config.good else: nature_draw.text = nature_config.bad nature_draw.width = int(self.width / len(nature_group)) nature_draw_list.append(nature_draw) judge_value = len(nature_set) * 100 / 2 nature_type_text = "" if type_value >= judge_value: nature_type_text = type_config.good else: nature_type_text = type_config.bad nature_draw = draw.LittleTitleLineDraw(nature_type_text, self.width, ":") self.draw_list.append(nature_draw) self.draw_list.append(nature_draw_list)
def draw(self): """ 绘制面板 """ self.return_list = [] map_path_str = map_handle.get_map_system_path_str_for_list( self.now_map) map_data: game_type.Map = cache.map_data[map_path_str] path_edge = map_data.path_edge scene_id_list = list(path_edge.keys()) if len(scene_id_list): character_data: game_type.Character = cache.character_data[0] character_scene_id = map_handle.get_map_scene_id_for_scene_path( self.now_map, character_data.position) scene_path = path_edge[character_scene_id].copy() if character_scene_id in scene_path: del scene_path[character_scene_id] scene_path_list = list(scene_path.keys()) draw_list = [] for scene_id in scene_id_list: load_scene_data = map_handle.get_scene_data_for_map( map_path_str, scene_id) now_scene_path = map_handle.get_map_system_path_for_str( load_scene_data.scene_path) now_id_text = f"{scene_id}:{load_scene_data.scene_name}" now_draw = draw.LeftButton(now_id_text, now_id_text, self.width, cmd_func=self.move_now, args=(now_scene_path, )) self.return_list.append(now_draw.return_text) draw_list.append(now_draw) draw_group = value_handle.list_of_groups(draw_list, 4) now_width_index = 0 for now_draw_list in draw_group: if len(now_draw_list) > now_width_index: now_width_index = len(now_draw_list) now_width = self.width / now_width_index for now_draw_list in draw_group: for now_draw in now_draw_list: now_draw.width = now_width now_draw.draw() line_feed.draw() self.end_index = len(scene_id_list) - 1
def set(self, info_list: List[str], width: int, column: int): """ 设置绘制信息 Keyword arguments: info_list -- 信息列表 width -- 绘制宽度 column -- 每行最大元素数 """ self.width = width self.column = column new_info_list = value_handle.list_of_groups(info_list, column) for now_info_list in new_info_list: now_width = int(width / column) now_list = [] for now_info in now_info_list: now_info_draw = draw.CenterDraw() now_info_draw.width = now_width now_info_draw.text = now_info now_list.append(now_info_draw) self.draw_list.append(now_list)
def __init__(self, character_id: int, width: int): """ 初始化绘制对象 """ self.character_id = character_id """ 要绘制的角色id """ self.width = width """ 面板最大宽度 """ self.draw_list: List[draw.NormalDraw] = [] """ 绘制的文本列表 """ self.return_list: List[str] = [] """ 当前面板监听的按钮列表 """ character_data = cache.character_data[character_id] for skill_type in game_config.config_knowledge_type_data: skill_set = game_config.config_knowledge_type_data[skill_type] type_config = game_config.config_knowledge_type[skill_type] type_draw = draw.LittleTitleLineDraw(type_config.name, self.width, ":") self.draw_list.append(type_draw) now_list = [] skill_group = value_handle.list_of_groups(list(skill_set), 3) for skill_list in skill_group: for skill in skill_list: skill_config = game_config.config_knowledge[skill] skill_draw = draw.CenterMergeDraw( int(self.width / len(skill_group))) now_text_draw = draw.NormalDraw() now_text_draw.text = skill_config.name now_text_draw.width = text_handle.get_text_index( skill_config.name) now_exp = 0 if skill in character_data.knowledge: now_exp = character_data.knowledge[skill] now_level_draw = draw.ExpLevelDraw(now_exp) skill_draw.draw_list.append(now_text_draw) skill_draw.draw_list.append(now_level_draw) skill_draw.width = int(self.width / len(skill_group)) now_list.append(skill_draw) self.draw_list.append(now_list)
def update(self): """ 更新绘制对象 """ self.return_list = [] start_id = self.now_page * self.limit total_page = int((len(self.text_list) - 1) / self.limit) if start_id >= len(self.text_list): self.now_page = total_page start_id = self.now_page * self.limit now_page_list = [] for i in range(start_id, len(self.text_list)): if len(now_page_list) >= self.limit: break now_page_list.append(self.text_list[i]) draw_text_group = value_handle.list_of_groups(now_page_list, self.column) draw_list: List[draw.NormalDraw] = [] self.end_index = self.button_start_id index = self.button_start_id line_feed = draw.NormalDraw() line_feed.text = "\n" line_feed.width = 1 for draw_text_list in draw_text_group: if self.row_septal_lines != "" and index: line_draw = draw.LineDraw(self.row_septal_lines, self.width) draw_list.append(line_draw) now_width = self.width if self.col_septal_lines != "": col_index = len(draw_text_list) + 1 col_width = text_handle.get_text_index(self.col_septal_lines) now_width -= col_width * col_index value_width = int(now_width / self.column) col_fix_draw = draw.NormalDraw() col_fix_draw.text = self.col_septal_lines col_fix_draw.width = 1 draw_list.append(col_fix_draw) for value in draw_text_list: is_button = 1 if value == self.null_button_text: is_button = 0 value_draw = self.draw_type(value, value_width, is_button, self.num_button, index) value_draw.draw_text = text_handle.align(value_draw.draw_text, "center", 0, 1, value_width) if self.num_button: self.return_list.append(str(index)) else: self.return_list.append(value_draw.button_return) index += 1 draw_list.append(value_draw) draw_list.append(col_fix_draw) draw_list.append(line_feed) if self.num_button: self.end_index = index if total_page: now_line = draw.LineDraw("-", self.width) draw_list.append(now_line) page_change_start_id = self.button_start_id if self.num_button: page_change_start_id = index old_page_index_text = text_handle.id_index(page_change_start_id) old_page_button = draw.CenterButton( _("{old_page_index_text} 上一页").format(old_page_index_text=old_page_index_text), str(page_change_start_id), int(self.width / 3), cmd_func=self.old_page, ) self.return_list.append(str(page_change_start_id)) draw_list.append(old_page_button) page_text = f"({self.now_page}/{total_page})" page_draw = draw.CenterDraw() page_draw.width = int(self.width / 3) page_draw.text = page_text draw_list.append(page_draw) next_page_index_text = text_handle.id_index(page_change_start_id + 1) next_page_button = draw.CenterButton( _("{next_page_index_text} 下一页").format(next_page_index_text=next_page_index_text), str(page_change_start_id + 1), int(self.width / 3), cmd_func=self.next_page, ) self.end_index = page_change_start_id + 1 self.return_list.append(str(page_change_start_id + 1)) draw_list.append(next_page_button) draw_list.append(line_feed) self.draw_list = draw_list
def draw(self): """ 绘制对象 """ move_menu_panel_data = { 0: MapSceneNameDraw(self.now_map, self.width), 1: GlobalSceneNamePanel(self.now_map, self.width), 2: SocialSceneNamePanel(self.now_map, self.width), 3: CollectionSceneNamePanel(self.now_map, self.width), } move_menu_panel = MoveMenuPanel(self.width) while 1: line_feed.draw() if cache.now_panel_id != constant.Panel.SEE_MAP: break map_path_str = map_handle.get_map_system_path_str_for_list( self.now_map) map_data: game_type.Map = cache.map_data[map_path_str] map_name = attr_text.get_map_path_text(self.now_map) title_draw = draw.TitleLineDraw(_("移动:") + map_name, self.width) title_draw.draw() now_draw_list: game_type.MapDraw = map_data.map_draw character_data: game_type.Character = cache.character_data[0] character_scene_id = map_handle.get_map_scene_id_for_scene_path( self.now_map, character_data.position) return_list = [] index = 0 for now_draw_line in now_draw_list.draw_text: fix_width = int((self.width - now_draw_line.width) / 2) fix_text = " " * fix_width fix_draw = draw.NormalDraw() fix_draw.text = fix_text fix_draw.width = fix_width fix_draw.draw() for draw_text in now_draw_line.draw_list: if draw_text.is_button and draw_text.text != character_scene_id: scene_path = map_handle.get_scene_path_for_map_scene_id( self.now_map, draw_text.text) now_draw = draw.Button(draw_text.text, draw_text.text, cmd_func=self.move_now, args=(scene_path, )) now_draw.width = self.width now_draw.draw() return_list.append(now_draw.return_text) else: now_draw = draw.NormalDraw() now_draw.text = draw_text.text now_draw.width = self.width if draw_text.is_button and draw_text.text == character_scene_id: now_draw.style = "nowmap" now_draw.draw() line_feed.draw() path_edge = map_data.path_edge scene_path = path_edge[character_scene_id].copy() if character_scene_id in scene_path: del scene_path[character_scene_id] scene_path_list = list(scene_path.keys()) if len(scene_path_list): line = draw.LineDraw(".", self.width) line.draw() message_draw = draw.NormalDraw() message_draw.text = _("你可以从这里前往:\n") message_draw.width = self.width message_draw.draw() draw_list = [] for scene in scene_path_list: load_scene_data = map_handle.get_scene_data_for_map( map_path_str, scene) now_scene_path = map_handle.get_map_system_path_for_str( load_scene_data.scene_path) now_draw = draw.CenterButton( f"[{load_scene_data.scene_name}]", load_scene_data.scene_name, self.width / 4, cmd_func=self.move_now, args=(now_scene_path, ), ) return_list.append(now_draw.return_text) draw_list.append(now_draw) draw_group = value_handle.list_of_groups(draw_list, 4) for now_draw_list in draw_group: for now_draw in now_draw_list: now_draw.draw() line_feed.draw() scene_id_list = list(path_edge.keys()) now_index = len(scene_id_list) index = now_index move_menu_panel.update() move_menu_panel.draw() return_list.extend(move_menu_panel.return_list) if move_menu_panel.now_type in move_menu_panel_data: now_move_menu = move_menu_panel_data[move_menu_panel.now_type] now_move_menu.update(self.now_map, index) now_move_menu.draw() now_index = now_move_menu.end_index + 1 return_list.extend(now_move_menu.return_list) line = draw.LineDraw("=", self.width) line.draw() if self.now_map != []: now_id = text_handle.id_index(now_index) now_text = now_id + _("查看上级地图") up_button = draw.CenterButton(now_text, str(now_index), self.width / 3, cmd_func=self.up_map) up_button.draw() return_list.append(up_button.return_text) now_index += 1 else: now_draw = draw.NormalDraw() now_draw.text = " " * int(self.width / 3) now_draw.width = self.width / 3 now_draw.draw() back_id = text_handle.id_index(now_index) now_text = back_id + _("返回") back_button = draw.CenterButton(now_text, str(now_index), self.width / 3) back_button.draw() return_list.append(back_button.return_text) now_index += 1 character_map = map_handle.get_map_for_path( character_data.position) if character_map != self.now_map: now_id = text_handle.id_index(now_index) now_text = now_id + _("查看下级地图") down_button = draw.CenterButton(now_text, str(now_index), self.width / 3, cmd_func=self.down_map) down_button.draw() return_list.append(down_button.return_text) line_feed.draw() yrn = flow_handle.askfor_all(return_list) py_cmd.clr_cmd() if yrn == back_button.return_text: cache.now_panel_id = constant.Panel.IN_SCENE break
def draw(self): """ 绘制操作菜单面板 """ self.return_list = [] line = draw.LineDraw("-.-", self.width) line.draw() fix_draw = draw.NormalDraw() fix_width = int( (self.width - int(self.width / len(cache.instruct_filter)) * len(cache.instruct_filter)) / 2 ) fix_draw.width = fix_width fix_draw.text = " " * fix_width fix_draw.draw() for now_type in cache.instruct_filter: now_config = game_config.config_instruct_type[now_type] if cache.instruct_filter[now_type]: now_button = draw.CenterButton( f"[{now_config.name}]", now_config.name, self.width / len(cache.instruct_filter), " ", "onbutton", "standard", cmd_func=self.change_filter, args=(now_type,), ) else: now_button = draw.CenterButton( f"[{now_config.name}]", now_config.name, self.width / len(cache.instruct_filter), cmd_func=self.change_filter, args=(now_type,), ) now_button.width = int(self.width / len(cache.instruct_filter)) self.return_list.append(now_button.return_text) now_button.draw() line_feed.draw() line = draw.LineDraw("~..", self.width) line.draw() now_instruct_list = [] now_premise_data = {} for now_type in cache.instruct_filter: if cache.instruct_filter[now_type] and now_type in constant.instruct_type_data: for instruct in constant.instruct_type_data[now_type]: premise_judge = 0 if instruct in constant.instruct_premise_data: for premise in constant.instruct_premise_data[instruct]: if premise in now_premise_data: if now_premise_data[premise]: continue premise_judge = 1 break else: now_premise_value = handle_premise.handle_premise(premise, 0) now_premise_data[premise] = now_premise_value if not now_premise_value: premise_judge = 1 break if premise_judge: continue now_instruct_list.append(instruct) now_instruct_list.sort() instruct_group = value_handle.list_of_groups(now_instruct_list, 3) now_draw_list = [] for instruct_list in instruct_group: for instruct_id in instruct_list: instruct_name = constant.handle_instruct_name_data[instruct_id] id_text = text_handle.id_index(instruct_id) now_text = f"{id_text}{instruct_name}" now_draw = draw.LeftButton( now_text, str(instruct_id), int(self.width / len(instruct_group)), cmd_func=self.handle_instruct, args=(instruct_id,), ) now_draw_list.append(now_draw) self.return_list.append(now_draw.return_text) now_draw = panel.VerticalDrawTextListGroup(self.width) now_group = value_handle.list_of_groups(now_draw_list, 3) now_draw.draw_list = now_group now_draw.draw()