def draw(self): """ 绘制按钮 """ if self.width < len(self): now_text = "" if self.width > 0: for i in self.text: if text_handle.get_text_index(now_text) + text_handle.get_text_index(i) < self.width: now_text += i continue break now_text = now_text[:-2] + "~" py_cmd.pcmd( now_text, self.return_text, normal_style=self.normal_style, on_style=self.on_mouse_style, ) else: py_cmd.pcmd( self.text, self.return_text, normal_style=self.normal_style, on_style=self.on_mouse_style, cmd_func=self.cmd_func, arg=self.args, )
def draw(self): """ 绘制按钮 """ if self.width < text_handle.get_text_index(self.text): now_text = "" if self.width > 0: for i in self.text: if text_handle.get_text_index( now_text) + text_handle.get_text_index( i) < self.width: now_text += i break now_text = now_text[:-2] + "~" else: now_index = text_handle.get_text_index(self.text) now_text = text_handle.align(self.text, "left", 0, 1, self.width) now_width = self.width - text_handle.get_text_index(now_text) now_text = " " * int(now_width) + now_text py_cmd.pcmd( now_text, self.return_text, normal_style=self.normal_style, on_style=self.on_mouse_style, cmd_func=self.cmd_func, arg=self.args, )
def __init__(self, text: Tuple, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text: UUID = text[0] """ 服装id """ self.clothing_type: int = text[1] """ 服装类型 """ self.width: int = width """ 绘制宽度 """ self.draw_text: str = "" """ 服装缩略信息绘制文本 """ self.is_button: bool = is_button """ 绘制按钮 """ self.num_button: bool = num_button """ 绘制数字按钮 """ self.button_id: int = button_id """ 数字按钮的id """ self.button_return: str = str(button_id) """ 按钮返回值 """ character_data: game_type.Character = cache.character_data[0] now_id_text = "" now_id_text = text_handle.id_index(self.button_id) fix_width = self.width - len(now_id_text) self.clothing_data: game_type.Clothing = character_data.clothing[self.clothing_type][self.text] value_dict = { _("可爱"): self.clothing_data.sweet, _("性感"): self.clothing_data.sexy, _("帅气"): self.clothing_data.handsome, _("清新"): self.clothing_data.fresh, _("典雅"): self.clothing_data.elegant, _("清洁"): self.clothing_data.cleanliness, _("保暖"): self.clothing_data.warm, } describe_list = [_("可爱的"), _("性感的"), _("帅气的"), _("清新的"), _("典雅的"), _("清洁的"), _("保暖的")] value_list = list(value_dict.values()) describe_id = value_list.index(max(value_list)) describe = describe_list[describe_id] wear_text = "" if ( self.clothing_type in character_data.put_on and character_data.put_on[self.clothing_type] == self.clothing_data.uid ): wear_text = _("(已穿戴)") clothing_config = game_config.config_clothing_tem[self.clothing_data.tem_id] clothing_name = f"{self.clothing_data.evaluation}{describe}{clothing_config.name}{wear_text}" fix_width -= text_handle.get_text_index(clothing_name) value_text = "" for value_id in value_dict: value = str(value_dict[value_id]) if len(value) < 4: value = (4 - len(value)) * " " + value value_text += f"|{value_id}:{value}" value_text += "|" id_text = "" id_text = f"{now_id_text} {clothing_name}" self.text_list: List[str] = [id_text, value_text] """ 绘制的文本列表 """ self.id_width: int = text_handle.get_text_index(id_text) """ id部分的绘制宽度 """ self.draw_text = " " * self.width
def draw(self): """ 绘制文本 """ if int(len(self)) > int(self.width): now_text = "" if self.width: for i in self.text: if text_handle.get_text_index(now_text) + text_handle.get_text_index(i) < self.width: now_text += i break now_text = now_text[:-2] + "~" else: now_text = text_handle.align(self.text, "left", 0, 1, self.width) io_init.era_print(now_text, self.style)
def draw(self): """ 绘制文本 """ if self.__len__() > self.width: now_text = "" if self.width > 0: for i in self.text: if text_handle.get_text_index(now_text) + text_handle.get_text_index(i) < self.width: now_text += i break now_text = now_text[:-2] + "~" io_init.era_print(now_text, self.style) else: io_init.era_print(self.text, self.style)
def get_print_map_data(map_draw: str) -> game_type.MapDraw: """ 获取绘制地图的富文本和按钮数据 Keyword arguments: map_draw -- 绘制地图的原始数据 Return arguments: game_type.MapDraw -- 地图绘制数据 """ map_y_list = map_draw.split("\n") map_draw_data = game_type.MapDraw() for map_x_list_id in range(len(map_y_list)): set_map_button = False map_x_list = map_y_list[map_x_list_id] now_draw_list = game_type.MapDrawLine() new_x_list = "" now_cmd = "" i = 0 while i in range(len(map_x_list)): if not set_map_button and map_x_list[i:i + 11] != "<mapbutton>": new_x_list += map_x_list[i] elif not set_map_button and map_x_list[i:i + 11] == "<mapbutton>": i += 10 set_map_button = 1 if len(new_x_list): now_draw = game_type.MapDrawText() now_draw.text = new_x_list now_draw_list.draw_list.append(now_draw) now_draw_list.width += text_handle.get_text_index( new_x_list) new_x_list = "" elif set_map_button and map_x_list[i:i + 12] != "</mapbutton>": now_cmd += map_x_list[i] else: set_map_button = 0 now_draw = game_type.MapDrawText() now_draw.text = now_cmd now_draw.is_button = 1 now_draw_list.draw_list.append(now_draw) now_draw_list.width += text_handle.get_text_index(now_cmd) now_cmd = "" i += 11 i += 1 if len(new_x_list): now_draw = game_type.MapDrawText() now_draw.text = new_x_list now_draw_list.draw_list.append(now_draw) now_draw_list.width += text_handle.get_text_index(new_x_list) map_draw_data.draw_text.append(now_draw_list) return map_draw_data
def draw(self): """ 绘制文本 """ if self.__len__() > self.width: now_text = "" if self.width > 0: for i in self.text: if text_handle.get_text_index(now_text) + text_handle.get_text_index(i) < self.width: now_text += i break now_text = now_text[:-2] + "~" io_init.era_print(now_text, self.style) else: io_init.era_print(self.text, self.style) if not cache.wframe_mouse.w_frame_skip_wait_mouse: flow_handle.askfor_wait()
def get_proportional_bar( value_name: str, max_value: int, value: int, bar_id: str, text_width=0 ) -> str: """ 通用用于计算比例条的函数 Keyword arguments: value_name -- 比例条名字 max_value -- 最大数值 value -- 当前数值 bar_id -- 用于填充比例条的图形id text_width -- 进度条区域宽度 (default 0) """ if text_width == 0: text_width = game_config.text_width bar_width = ( text_width - text_handle.get_text_index(value_name) - 5 - text_handle.get_text_index(str(max_value)) - text_handle.get_text_index(str(value)) ) proportion = int(int(value) / int(max_value) * bar_width) true_bar = "1" null_bar = "0" proportion_bar = true_bar * proportion fix_proportion_bar = null_bar * int(bar_width - proportion) proportion_bar = ( "<" + bar_id + ">" + proportion_bar + fix_proportion_bar + "</" + bar_id + ">" ) proportion_bar = ( str(value_name) + "[" + proportion_bar + "]" + "(" + str(value) + "/" + str(max_value) + ")" ) return proportion_bar
def __len__(self) -> int: """ 获取按钮文本长度 Return arguments: int -- 文本长度 """ return text_handle.get_text_index(self.text)
def son_title_print(string: str): """ 按预订样式"sontitle(子标题)"绘制文本 示例: ::::子标题:::: 文本将用=补全至与行同宽 Keyword arguments: string -- 子标题文本 """ text_wait = cache_contorl.text_wait if text_wait != 0: time.sleep(text_wait) string = string string = dictionaries.handle_text(string) global last_char if len(string) > 0: last_char = string[-1:] width = game_config.text_width text_width = text_handle.get_text_index(string) line_width = int(int(width) / 4) line_width_fix = int(int(width) / 4 - int(text_width)) line_feed_print( ":" * line_width_fix + "<sontitle>" + string + "</sontitle>" + ":" * line_width * 3 )
def little_title_print(string: str): """ 按预订样式"littletitle(小标题)"绘制文本 示例: ====口小标题口==== 文本将用=补全至与行同宽 Keyword arguments: string -- 小标题文本 """ text_wait = cache_contorl.text_wait if text_wait != 0: time.sleep(text_wait) string = str(string) string = dictionaries.handle_text(string) global last_char if len(string) > 0: last_char = string[-1:] width = game_config.text_width text_width = text_handle.get_text_index(string) line_width = int(int(width) / 2 - int(text_width) / 2 - 2) line_feed_print( "=" * line_width + "<littletitle>口" + string + "口</littletitle>" + "=" * line_width )
def __init__( self, character_id: int, clothing_type: int, clothing_id: UUID, width: int, draw_button: bool = False, button_id: int = 0, ): """ 初始化绘制对象 """ self.character_id: int = character_id """ 服装所属的角色id """ character_data = cache.character_data[character_id] self.clothing_data: game_type.Clothing = character_data.clothing[clothing_type][clothing_id] """ 当前服装数据 """ self.width: int = width """ 最大绘制宽度 """ self.draw_button: bool = draw_button """ 是否按按钮绘制 """ self.button_id: int = button_id """ 绘制按钮时的id """ self.id_width: int = 0 """ 绘制时计算用的id宽度 """ now_id_text = "" if self.draw_button: now_id_text = text_handle.id_index(self.button_id) fix_width = self.width - len(now_id_text) value_dict = { _("可爱"): self.clothing_data.sweet, _("性感"): self.clothing_data.sexy, _("帅气"): self.clothing_data.handsome, _("清新"): self.clothing_data.fresh, _("典雅"): self.clothing_data.elegant, _("清洁"): self.clothing_data.cleanliness, _("保暖"): self.clothing_data.warm, } describe_list = [_("可爱的"), _("性感的"), _("帅气的"), _("清新的"), _("典雅的"), _("清洁的"), _("保暖的")] value_list = list(value_dict.values()) describe_id = value_list.index(max(value_list)) describe = describe_list[describe_id] clothing_config = game_config.config_clothing_tem[self.clothing_data.tem_id] clothing_name = f"{self.clothing_data.evaluation}{describe}{clothing_config.name}" fix_width -= text_handle.get_text_index(clothing_name) value_text = "" for value_id in value_dict: value = str(value_dict[value_id]) if len(value) < 4: value = (4 - len(value)) * " " + value value_text += f"|{value_id}:{value}" value_text += "|" id_text = "" if self.draw_button: id_text = f"{now_id_text} {clothing_name}" else: id_text = clothing_name self.text_list: List[str] = [id_text, value_text] """ 绘制的文本列表 """
def draw(self): """ 绘制线条 """ text_index = text_handle.get_text_index(self.text) text_num = self.width / text_index now_draw = NormalDraw() now_draw.width = self.width now_draw.text = self.text * int(text_num) + "\n" now_draw.style = self.style now_draw.draw()
def list_print(string_list: list, string_column=1, string_size="left"): """ 绘制字符串列表 Keyword arguments: string_list -- 要进行绘制的字符串列表 string_colum -- 每行的绘制数量(列宽由行宽平分为行数而来) (default 1) string_size -- 每列在列宽中的对齐方式(left/center/right) (default 'left') """ text_wait = cache_contorl.text_wait text_width = game_config.text_width if text_wait != 0: time.sleep(text_wait) string_index = int(text_width / string_column) for i in range(0, len(string_list)): string_text = string_list[i] string_id_index = text_handle.get_text_index(string_list[i]) if string_size == "left": string_text_fix = " " * (string_index - string_id_index) string_text = string_text + string_text_fix elif string_size == "center": string_text_fix = " " * int((string_index - string_id_index) / 2) string_text = string_text_fix + string_text + string_text_fix now_text_index = text_handle.get_text_index(string_text) if string_text_fix != "" and now_text_index < string_index: string_text += " " * (string_index - now_text_index) elif string_text_fix != "" and now_text_index > string_index: string_text = string_text[-1] elif string_size == "right": string_text_fix = " " * (string_index - string_id_index) string_text = string_text_fix + string_text string_text_index = text_handle.get_text_index(string_text) if string_text_index > string_index: string_text = string_text[:string_index] elif string_text_index < string_index: string_text = ( " " * (string_index - string_text_index) + string_text ) if i == 0: normal_print(string_text) elif i / string_column >= 1 and i % string_column == 0: normal_print("\n") normal_print(string_text) else: normal_print(string_text)
def __len__(self) -> int: """ 获取当前要绘制的文本的长度 Return arguments: int -- 文本长度 """ text_index = text_handle.get_text_index(self.text) if text_index > self.width: return self.width return text_index
def draw(self): """ 绘制文本 """ text_list = self.text.split(r"\n") for text in text_list: now_width = text_handle.get_text_index(text) if now_width > self.width: now_text = "" if now_width > 0: for i in text: if text_handle.get_text_index(now_text) + text_handle.get_text_index(i) < now_width: now_text += i break now_text = now_text[:-2] + "~" io_init.era_print(now_text, self.style) else: io_init.era_print(text, self.style) if not cache.wframe_mouse.w_frame_skip_wait_mouse: flow_handle.askfor_wait() else: time.sleep(0.001) io_init.era_print("\n")
def draw(self): """ 绘制面板 """ character_data = cache.character_data[self.character_id] title_draw = draw.TitleLineDraw(_("人物服装"), self.width) title_draw.draw() draw_list = [] self.return_list = [] id_width = 0 for clothing_type in game_config.config_clothing_type: type_data = game_config.config_clothing_type[clothing_type] type_draw = draw.LittleTitleLineDraw(type_data.name, self.width, ":") draw_list.append(type_draw) if clothing_type in character_data.put_on and isinstance( character_data.put_on[clothing_type], UUID): now_draw = ClothingInfoDrawPanel( self.character_id, clothing_type, character_data.put_on[clothing_type], self.width, 1, len(self.return_list), ) self.return_list.append(str(len(self.return_list))) now_id_width = text_handle.get_text_index( now_draw.text_list[0]) if now_id_width > id_width: id_width = now_id_width else: now_text = _("未穿戴") if not self.character_id: now_id = len(self.return_list) now_id_text = text_handle.id_index(now_id) now_width = self.width - len(now_id_text) now_text = text_handle.align(now_text, "center", text_width=now_width) now_text = f"{now_id_text}{now_text}" now_draw = draw.Button(now_text, str(now_id), cmd_func=self.see_clothing_list, args=(clothing_type, )) self.return_list.append(str(now_id)) else: now_draw = draw.CenterDraw() now_draw.text = now_text now_draw.width = self.width draw_list.append(now_draw) draw_list.append(line_feed) for value in draw_list: if "id_width" in value.__dict__: value.id_width = id_width value.draw()
def draw(self): """ 绘制文本 """ self.width = int(self.width) if len(self) > self.width: now_text = "" if self.width > 0: for i in self.text: if text_handle.get_text_index(now_text) + text_handle.get_text_index(i) < self.width: now_text += i break now_text = now_text[:-2] + "~" io_init.era_print(now_text, self.style) elif len(self) > self.width - 1: now_text = " " + self.text elif len(self) > self.width - 2: now_text = " " + self.text + " " else: now_text = text_handle.align(self.text, "center", 0, 1, self.width) if len(self) < self.width: now_text += " " * (int(self.width) - text_handle.get_text_index(now_text)) io_init.era_print(now_text, self.style)
def draw(self): self.text_list[1] = text_handle.align(self.text_list[1], "center", 0, 1, self.width - self.id_width) text_width = text_handle.get_text_index(self.text_list[0]) if text_width < self.id_width: self.text_list[0] += " " * (self.id_width - text_width) now_text = f"{self.text_list[0]}{self.text_list[1]}" if self.draw_button: now_draw = draw.Button(now_text, str(self.button_id), cmd_func=self.see_clothing_info) else: now_draw = draw.NormalDraw() now_draw.text = now_text now_draw.width = self.width now_draw.draw()
def draw(self): """ 绘制对象 """ self.text_list[1] = text_handle.align( self.text_list[1], "center", text_width=self.width - self.id_width ) text_width = text_handle.get_text_index(self.text_list[0]) self.text_list[0] += " " * (self.id_width - text_width) now_text = f"{self.text_list[0]}{self.text_list[1]}" now_text = now_text.rstrip() now_text = text_handle.align(now_text, "center", text_width=self.width) now_draw = draw.Button(now_text, str(self.button_id), cmd_func=self.change_clothing) now_draw.width = self.width now_draw.draw()
def lines_center_print(sleep_time: float, string="", style="standard"): """ 将多行文本以居中的对齐方式进行逐字绘制 Keyword arguments: sleep_time -- 逐字的间隔时间 string -- 需要逐字绘制的文本 style -- 文本的默认样式 """ text_wait = cache_contorl.text_wait if text_wait != 0: time.sleep(text_wait) cache_contorl.wframe_mouse["w_frame_line_state"] = 1 string = str(string) string_list = string.split("\n") width = game_config.text_width style_name_list = game_config.get_font_data_list() string_center_list = "" for i in range(0, len(style_name_list)): style_text_head = "<" + style_name_list[i] + ">" style_text_tail = "</" + style_name_list[i] + ">" if style_text_head in string: string_center = string.replace(style_text_head, "") string_center = string_center.replace(style_text_tail, "") string_center_list = string_center.split("\n") else: string_center_list = string_list for i in range(0, len(string_list)): width_i = int(width) / 2 count_index = text_handle.get_text_index(string_center_list[i]) count_i = int(count_index) / 2 if cache_contorl.wframe_mouse["w_frame_re_print"] == 1: normal_print("\n") normal_print(" " * int((width_i - count_i))) normal_print(string_list[i]) else: normal_print(" " * int((width_i - count_i))) one_by_one_print(sleep_time, string_list[i]) normal_print("\n") if cache_contorl.wframe_mouse["w_frame_lines_up"] == 1: index_i_up = i + 1 cache_contorl.wframe_mouse["w_frame_lines_up"] = 2 for index_i_up in range(index_i_up, len(string_list)): restart_line_print( text_handle.align(string_list[index_i_up], "center"), style, ) cache_contorl.wframe_mouse["w_frame_line_state"] = 2 break cache_contorl.wframe_mouse["w_frame_re_print"] = 0
def page_line_print(sample=":", string="", style="standard"): """ 绘制页数线 Keyword arguments: sample -- 填充线样式 (default ':') string -- 页数字符串 (default '') style -- 页数线默认样式 (default 'standard') """ text_wait = cache_contorl.text_wait if text_wait != 0: time.sleep(text_wait) text_width = int(game_config.text_width) string_width = int(text_handle.get_text_index(string)) fix_text = sample * int(text_width / 2 - string_width / 2) string_text = fix_text + string + fix_text normal_print(string_text, style)
def start_input_nick_name_panel(): """ 玩家昵称输入处理面板 """ era_print.line_feed_print( text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "5")) while 1: character_nick_name = game_init.askfor_str() era_print.line_feed_print(character_nick_name) if text_handle.get_text_index(character_nick_name) > 10: era_print.line_feed_print( text_loading.get_text_data(constant.FilePath.ERROR_PATH, "inputNickNameTooLongError")) else: cache_contorl.character_data[0].nick_name = character_nick_name break
def draw(self) -> str: """ 绘制面板 Return arguments: str -- 玩家输入的字符 """ return_text = "" while 1: self.message.draw() return_text = flow_handle.askfor_str(1, 1) text_index = text_handle.get_text_index(return_text) if text_index <= self.input_max: break io_init.era_print(_("输入的字符超长,最大{input_max}个英文字符,请重试。").format(input_max=self.input_max)) io_init.era_print("\n") return return_text
def see_character_list_panel(max_page: int) -> list: """ 查看角色列表面板 Keyword arguments: max_page -- 最大角色列表页数 """ title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "74") era_print.little_title_print(title_text) input_s = [] page_id = int(cache_contorl.panel_state["SeeCharacterListPanel"]) page_show = int(game_config.character_list_show) character_max = len(cache_contorl.character_data["character"]) - 1 if page_id == max_page: show_page_start = page_show * page_id show_page_over = show_page_start + (character_max + 1 - show_page_start) else: show_page_over = page_show * (page_id + 1) show_page_start = show_page_over - page_show for i in range(show_page_start, show_page_over): cmd_id = i - show_page_start cmd_id_text = cmd_button_queue.id_index(cmd_id) cmd_text = attr_text.get_character_abbreviations_info(i) cmd_id_text_index = text_handle.get_text_index(cmd_id_text) window_width = int(game_config.text_width) text_width = window_width - cmd_id_text_index cmd_text = text_handle.align(cmd_text, "center", text_width=text_width) cmd_text = cmd_id_text + " " + cmd_text cmd_id = str(cmd_id) era_print.little_line_print() py_cmd.pcmd(cmd_text, cmd_id, None) input_s.append(cmd_id) era_print.normal_print("\n") page_text = "(" + str(page_id) + "/" + str(max_page) + ")" era_print.page_line_print(sample="-", string=page_text) era_print.line_feed_print() return input_s
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 see_character_clothes_panel( character_id: str, clothing_type: str, max_page: int ) -> list: """ 用于查看角色服装列表的面板 Keyword arguments: character_id -- 角色id clothing_type -- 服装类型 max_page -- 服装列表最大页数 Rerurn arguments: list -- 监听的按钮列表 """ era_print.line_feed_print() character_clothing_data = cache_contorl.character_data[ character_id ].clothing[clothing_type] clothing_text_data = {} tag_text_index = 0 now_page_id = int(cache_contorl.panel_state["SeeCharacterClothesPanel"]) now_page_max = game_config.see_character_clothes_max now_page_start_id = now_page_id * now_page_max now_page_end_id = now_page_start_id + now_page_max if character_clothing_data == {}: era_print.normal_print( text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "34") ) era_print.line_feed_print() return [] if now_page_end_id > len(character_clothing_data.keys()): now_page_end_id = len(character_clothing_data.keys()) pass_id = None for i in range(now_page_start_id, now_page_end_id): clothing_id = list(character_clothing_data.keys())[i] if ( clothing_id == cache_contorl.character_data[character_id].put_on[clothing_type] ): pass_id = i - now_page_start_id clothing_data = character_clothing_data[clothing_id] clothing_text = ( clothing_data["Evaluation"] + clothing_data["Tag"] + clothing_data["Name"] ) clothing_text_data[clothing_text] = {} for tag in clothing.clothing_tag_text_list: tag_text = clothing.clothing_tag_text_list[tag] + str( clothing_data[tag] ) clothing_text_data[clothing_text][tag_text] = 0 now_tag_text_index = text_handle.get_text_index(tag_text) if now_tag_text_index == now_tag_text_index: tag_text_index = now_tag_text_index long_clothing_text_index = text_handle.get_text_index( max(clothing_text_data.keys(), key=text_handle.get_text_index) ) i = 0 input_s = [] for clothing_text in clothing_text_data: draw_text = "" era_print.little_line_print() now_clothing_text_index = text_handle.get_text_index(clothing_text) draw_text += clothing_text + " " if now_clothing_text_index < long_clothing_text_index: draw_text += " " * ( long_clothing_text_index - now_clothing_text_index ) for tag_text in clothing_text_data[clothing_text]: now_tag_text_index = text_handle.get_text_index(tag_text) if now_tag_text_index < tag_text_index: draw_text += ( " " + tag_text + " " * (tag_text_index - now_tag_text_index) ) else: draw_text += " " + tag_text if i == pass_id: draw_text += " " + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "125" ) id_info = cmd_button_queue.id_index(i) cmd_text = id_info + draw_text input_s.append(f"{i}") py_cmd.pcmd(cmd_text, i, None) era_print.line_feed_print() i += 1 era_print.normal_print("\n") page_text = "(" + str(now_page_id) + "/" + str(max_page) + ")" era_print.page_line_print(sample="-", string=page_text) era_print.line_feed_print() return input_s
def see_character_wear_clothes(character_id: int, change_button: bool): """ 查看角色穿戴服装列表面板 Keyword arguments: character_id -- 角色id change_button -- 将服装列表绘制成按钮的开关 """ character_clothing_data = cache_contorl.character_data[ character_id ].clothing character_put_on_list = cache_contorl.character_data[character_id].put_on clothing_text_data = {} tag_text_index = 0 for i in range(len(clothing.clothing_type_text_list.keys())): clothing_type = list(clothing.clothing_type_text_list.keys())[i] clothing_id = character_put_on_list[clothing_type] if clothing_id == "": clothing_text_data[clothing_type] = "None" else: clothing_data = character_clothing_data[clothing_type][clothing_id] clothing_text = ( clothing.clothing_type_text_list[clothing_type] + ":" + clothing_data["Evaluation"] + clothing_data["Tag"] + clothing_data["Name"] ) clothing_text_data[clothing_text] = {} for tag in clothing.clothing_tag_text_list: tag_text = clothing.clothing_tag_text_list[tag] + str( clothing_data[tag] ) clothing_text_data[clothing_text][tag_text] = 0 now_tag_text_index = text_handle.get_text_index(tag_text) if now_tag_text_index > tag_text_index: tag_text_index = now_tag_text_index long_clothing_text_index = text_handle.get_text_index( max(clothing_text_data.keys(), key=text_handle.get_text_index) ) i = 0 input_s = [] for clothing_text in clothing_text_data: draw_text = "" era_print.little_line_print() if clothing_text_data[clothing_text] == "None": draw_text = ( clothing.clothing_type_text_list[clothing_text] + ":" + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "117" ) ) else: now_clothing_text_index = text_handle.get_text_index(clothing_text) draw_text += clothing_text + " " if now_clothing_text_index < long_clothing_text_index: draw_text += " " * ( long_clothing_text_index - now_clothing_text_index ) for tag_text in clothing_text_data[clothing_text]: now_tag_text_index = text_handle.get_text_index(tag_text) if now_tag_text_index < tag_text_index: draw_text += ( " " + tag_text + " " * (tag_text_index - now_tag_text_index) ) else: draw_text += " " + tag_text if change_button: id_info = cmd_button_queue.id_index(i) cmd_text = id_info + draw_text py_cmd.pcmd(cmd_text, i, None) else: era_print.normal_print(draw_text) input_s.append(f"{i}") i += 1 era_print.normal_print("\n") return input_s
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
order_font_data = game_config.config_font[1] for k in game_config.config_font[0].__dict__: if k not in order_font_data.__dict__: order_font_data.__dict__[k] = game_config.config_font[0].__dict__[k] order_font_data.font = normal_config.config_normal.font order_font_data.font_size = normal_config.config_normal.order_font_size input_background_box = Text( main_frame, highlightbackground=normal_config.config_normal.background, background=normal_config.config_normal.background, bd=0, ) input_background_box.grid(column=0, row=1, sticky=(W, E, S)) cursor_text = "~$" cursor_width = text_handle.get_text_index(cursor_text) input_background_box_cursor = Text( input_background_box, width=cursor_width, height=1, highlightbackground=order_font_data.background, background=order_font_data.background, bd=0, ) input_background_box_cursor.grid(column=0, row=0, sticky=(W, E, S)) input_background_box_cursor.insert("end", cursor_text) input_background_box_cursor.config(foreground=order_font_data.foreground) # 输入栏 order = StringVar() order_font = font.Font(family=order_font_data.font,