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, button_list: List[str], message: str, start_id=0): """ 设置要绘制的信息 Keyword arguments: button_list -- 监听的按钮列表 message -- 绘制的消息 start_id -- id的起始位置 """ new_button_list = [] return_list = [] for i in range(len(button_list)): now_id = text_handle.id_index(i + start_id) now_id_text = now_id + button_list[i] new_button_list.append(now_id_text) now_i_str = str(start_id + i) return_list.append(now_i_str) width = normal_config.config_normal.text_width self.message = draw.NormalDraw() self.message.text = message self.message.width = width self.button_panel = SingleColumnButton() self.button_panel.width = width self.button_panel.max_height = len(return_list) self.button_panel.set(new_button_list, return_list) self.button_panel.return_list = dict(zip(return_list, button_list))
def __init__(self, text: str, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text: int = int(text) """ 道具的配表id """ self.draw_text: str = "" """ 道具名绘制文本 """ self.width: int = width """ 最大宽度 """ 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) """ 按钮返回值 """ item_config = game_config.config_item[self.text] item_name = item_config.name if is_button: if num_button: index_text = text_handle.id_index(button_id) self.draw_text = f"{index_text} {item_name}" self.button_return = str(button_id) else: self.draw_text = item_name self.button_return = item_name else: self.draw_text = f"[{item_name}]"
def draw_save_handle(self): """ 处理读写存档 """ py_cmd.clr_cmd() line_feed.draw() if self.save_exist_judge: now_ask_list = [] now_id = 0 load_save_button = draw.Button(text_handle.id_index(now_id) + _("读取"), str(now_id), cmd_func=self.load_save) load_save_button.width = self.width load_save_button.draw() line_feed.draw() now_ask_list.append(str(now_id)) now_id += 1 if self.write_save: re_write_save_button = draw.Button( text_handle.id_index(now_id) + _("覆盖"), str(now_id), cmd_func=save_handle.establish_save, args=(self.text, ), ) re_write_save_button.width = self.width re_write_save_button.draw() now_ask_list.append(str(now_id)) line_feed.draw() now_id += 1 delete_save_button = draw.Button(text_handle.id_index(now_id) + _("删除"), str(now_id), cmd_func=self.delete_save) delete_save_button.width = self.width delete_save_button.draw() now_ask_list.append(str(now_id)) now_id += 1 line_feed.draw() back_button = draw.Button( text_handle.id_index(now_id) + _("返回"), str(now_id)) back_button.width = self.width back_button.draw() line_feed.draw() now_ask_list.append(str(now_id)) flow_handle.askfor_all(now_ask_list) py_cmd.clr_cmd() else: save_handle.establish_save(self.text)
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 __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): """ 绘制面板 """ 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 __init__(self, text: Tuple[str, UUID], width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text: UUID = text[1] """ 食物uid """ self.cid: str = text[0] """ 食物商店索引id """ self.draw_text: str = "" """ 食物名字绘制文本 """ self.width: int = width """ 最大宽度 """ self.num_button: bool = num_button """ 绘制数字按钮 """ self.button_id: int = str(button_id) """ 按钮返回值 """ self.button_return: str = str(button_id) """ 按钮返回值 """ name_draw = draw.NormalDraw() food_data: game_type.Food = cache.restaurant_data[self.cid][self.text] quality_text_data = [_("垃圾"), _("饲料"), _("粮食"), _("美味"), _("春药")] food_name = "" if isinstance(self.cid, str): food_recipe: game_type.Recipes = cache.recipe_data[int(self.cid)] food_name = food_recipe.name else: food_config = game_config.config_food[self.cid] food_name = food_config.name hunger_text = _("热量:") if 27 in food_data.feel: hunger_text = f"{hunger_text}{round(food_data.feel[27],2)}" else: hunger_text = f"{hunger_text}0.00" thirsty_text = _("水份:") if 28 in food_data.feel: thirsty_text = f"{thirsty_text}{round(food_data.feel[28],2)}" else: thirsty_text = f"{thirsty_text}0.00" price = round(1 + sum(food_data.feel.values()) * food_data.quality, 2) food_name = (food_name + f" {hunger_text} {thirsty_text} " + _("重量:") + str(round(food_data.weight, 2)) + _("克") + " " + _("品质:") + quality_text_data[food_data.quality] + " " + _("售价:" + str(price))) index_text = text_handle.id_index(button_id) button_text = f"{index_text}{food_name}" name_draw = draw.LeftButton(button_text, self.button_return, self.width, cmd_func=self.buy_food) self.now_draw = name_draw """ 绘制的对象 """
def __init__(self, text: str, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text: str = str(text[0]) """ 存档id """ self.write_save: bool = text[1] """ 是否存储存档 """ self.draw_text: str = "" """ 存档信息绘制文本 """ self.width: int = width """ 最大宽度 """ self.is_button: bool = is_button """ 绘制按钮 """ self.is_num_button: bool = num_button """ 绘制数字按钮 """ self.button_id: int = button_id """ 数字按钮的id """ self.button_return: str = str(button_id) """ 按钮返回值 """ self.save_exist_judge = save_handle.judge_save_file_exist(self.text) """ 存档位是否已存在 """ save_name = _("空存档位") if self.save_exist_judge: save_head = save_handle.load_save_info_head(self.text) game_time: datetime.datetime = save_head["game_time"] save_time: datetime.datetime = save_head["save_time"] game_time_text = _("游戏时间:") + game_time.strftime("%Y-%m-%d %H:%M") save_time_text = _("存档时间:") + save_time.strftime("%Y-%m-%d %H:%M") save_name = f"No.{self.text} {save_head['game_verson']} {game_time_text} {save_head['character_name']} {save_time_text}" if is_button: if num_button: index_text = text_handle.id_index(button_id) now_text_width = self.width - len(index_text) new_text = text_handle.align(save_name, "center", text_width=now_text_width) self.draw_text = f"{index_text}{new_text}" self.button_return = str(button_id) else: new_text = text_handle.align(save_name, "center", text_width=self.width) self.draw_text = new_text self.button_return = text[0] else: new_text = text_handle.align(save_name, "center", text_width=self.width) self.draw_text = new_text
def __init__(self, text: int, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text: int = text """ 角色id """ self.draw_text: str = "" """ 角色缩略信息绘制文本 """ self.width: int = width """ 最大宽度 """ 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 = cache.character_data[self.text] character_name = character_data.name id_text = f"No.{self.text}" sex_config = game_config.config_sex_tem[character_data.sex] sex_text = _(f"性别:{sex_config.name}") age_text = _(f"年龄:{character_data.age}岁") hit_point_text = _( f"体力:({character_data.hit_point}/{character_data.hit_point_max})") mana_point_text = _( f"气力:({character_data.mana_point}/{character_data.mana_point_max})" ) now_text = f"{id_text} {character_name} {sex_text} {age_text} {hit_point_text} {mana_point_text}" if is_button: if num_button: index_text = text_handle.id_index(self.button_id) now_text_width = self.width - len(index_text) new_text = text_handle.align(now_text, "center", text_width=now_text_width) self.draw_text = f"{index_text}{new_text}" self.button_return = str(button_id) else: new_text = text_handle.align(now_text, "center", text_width=self.width) self.draw_text = new_text self.button_return = character_name else: new_text = text_handle.align(now_text, "center", text_width=self.width) self.draw_text = new_text
def __init__(self, text: str, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.character_id: int = int(text) """ 角色id """ self.draw_text: str = "" """ 角色名绘制文本 """ self.width: int = width """ 最大宽度 """ 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[ self.character_id] sex_text = game_config.config_sex_tem[character_data.sex].name character_name = character_data.name + f"({sex_text})" name_draw = draw.NormalDraw() if is_button: if num_button: index_text = text_handle.id_index(button_id) button_text = f"{index_text} {character_name}" name_draw = draw.CenterButton(button_text, self.button_return, self.width, cmd_func=self.see_character) else: button_text = f"[{character_name}]" name_draw = draw.CenterButton(button_text, character_name, self.width, cmd_func=self.see_character) self.button_return = character_name self.draw_text = button_text else: character_name = f"[{character_name}]" character_name = text_handle.align(character_name, "center", 0, 1, self.width) name_draw.text = character_name self.draw_text = character_name name_draw.width = self.width self.now_draw = name_draw """ 绘制的对象 """
def __init__(self, text: UUID, width: int, is_button: bool, num_button: bool, button_id: int): self.text: UUID = text """ 食物id """ self.draw_text: str = "" """ 食物名字绘制文本 """ self.width: int = width """ 最大宽度 """ self.num_button: bool = num_button """ 绘制数字按钮 """ self.button_id: int = str(button_id) """ 按钮返回值 """ self.button_return: str = str(button_id) """ 按钮返回值 """ name_draw = draw.NormalDraw() food_data: game_type.Food = cache.character_data[0].food_bag[self.text] quality_text_data = [_("垃圾"), _("饲料"), _("粮食"), _("美味"), _("春药")] food_name = "" if food_data.recipe != -1: food_recipe: game_type.Recipes = cache.recipe_data[ food_data.recipe] food_name = food_recipe.name else: food_config = game_config.config_food[food_data.id] food_name = food_config.name hunger_text = _("热量:") if 27 in food_data.feel: hunger_text = f"{hunger_text}{round(food_data.feel[27],2)}" else: hunger_text = f"{hunger_text}0.00" thirsty_text = _("水份:") if 28 in food_data.feel: thirsty_text = f"{thirsty_text}{round(food_data.feel[28],2)}" else: thirsty_text = f"{thirsty_text}0.00" food_name = (food_name + f" {hunger_text} {thirsty_text} " + _("重量:") + str(round(food_data.weight, 2)) + _("克") + " " + _("品质:") + quality_text_data[food_data.quality]) index_text = text_handle.id_index(button_id) button_text = f"{index_text}{food_name}" name_draw = draw.LeftButton(button_text, self.button_return, self.width, cmd_func=self.eat_food) self.now_draw = name_draw """ 绘制的对象 """
def __init__(self, text: str, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.language_id: int = text[0] """ 语言id """ self.language_exp: int = text[1] """ 语言经验 """ self.draw_text: str = "" """ 语言名绘制文本 """ self.width: int = width """ 最大宽度 """ 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) """ 按钮返回值 """ self.draw_list: List[draw.NormalDraw] = [] """ 绘制的对象列表 """ language_config = game_config.config_language[self.language_id] language_name = language_config.name name_draw = draw.NormalDraw() name_draw.width = self.width if is_button: button_text = "" if num_button: index_text = text_handle.id_index(button_id) button_text = f"{index_text} {language_name}:" name_draw = draw.Button(button_text, self.button_return, cmd_func=self.see_language_info) else: button_text = f"{language_name}:" name_draw = draw.Button(button_text, language_name, cmd_func=self.see_language_info) self.button_return = language_name else: name_draw.text = f"{language_name}:" level_draw = draw.ExpLevelDraw(self.language_exp) name_draw.width = self.width - len(level_draw) self.draw_list = [name_draw, level_draw]
def __init__(self, text: Tuple[str, str], width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text = text[1] """ 食物名字 """ self.cid = text[0] """ 食物在食堂内的表id """ self.draw_text: str = "" """ 食物名字绘制文本 """ self.width: int = width """ 最大宽度 """ self.num_button: bool = num_button """ 绘制数字按钮 """ self.button_id: int = button_id """ 数字按钮的id """ self.button_return: str = str(button_id) """ 按钮返回值 """ name_draw = draw.NormalDraw() if is_button: if num_button: index_text = text_handle.id_index(button_id) button_text = f"{index_text}{self.text}" name_draw = draw.LeftButton( button_text, self.button_return, self.width, cmd_func=self.see_food_shop_food_list) else: button_text = f"[{self.text}]" name_draw = draw.CenterButton( button_text, self.text, self.width, cmd_func=self.see_food_shop_food_list) self.button_return = text self.draw_text = button_text else: name_draw = draw.CenterDraw() name_draw.text = f"[{self.text}]" name_draw.width = self.width self.draw_text = name_draw.text self.now_draw = name_draw """ 绘制的对象 """
def __init__(self, text: int, width: int, is_button: bool, num_button: bool, button_id: int): """ 初始化绘制对象 """ self.text = text """ 道具id """ self.draw_text: str = "" """ 道具名字绘制文本 """ self.width: int = width """ 最大宽度 """ self.num_button: bool = num_button """ 绘制数字按钮 """ self.button_id: int = button_id """ 数字按钮的id """ self.button_return: str = str(button_id) """ 按钮返回值 """ name_draw = draw.NormalDraw() item_config = game_config.config_item[self.text] if is_button: if num_button: index_text = text_handle.id_index(button_id) button_text = f"{index_text}{item_config.name}" name_draw = draw.LeftButton(button_text, self.button_return, self.width, cmd_func=self.buy_item) else: button_text = f"[{item_config.name}]" name_draw = draw.CenterButton(button_text, item_config.name, self.width, cmd_func=self.buy_item) self.button_return = item_config.name self.draw_text = button_text else: name_draw = draw.CenterDraw() name_draw.text = f"[{item_config.name}]" name_draw.width = self.width self.draw_text = name_draw.text self.now_draw = name_draw """ 绘制的对象 """
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()
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 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