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 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 see_scene_panel(): """ 当前场景信息面板 """ title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "75") era_print.little_title_print(title_text) time_text = game_time.get_date_text() era_print.normal_print(time_text) era_print.normal_print(" ") scene_path = cache_contorl.character_data["character"][0].position scene_path_str = map_handle.get_map_system_path_str_for_list(scene_path) map_list = map_handle.get_map_hierarchy_list_for_scene_path(scene_path, []) map_path_text = "" map_list.reverse() for now_map in map_list: now_map_map_system_str = map_handle.get_map_system_path_str_for_list( now_map) map_name = cache_contorl.map_data[now_map_map_system_str]["MapName"] map_path_text += map_name + "-" scene_data = cache_contorl.scene_data[scene_path_str].copy() scene_name = map_path_text + scene_data["SceneName"] scene_info_head = text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "76") scene_info = scene_info_head + scene_name era_print.normal_print(scene_info) panel_state = cache_contorl.panel_state["SeeSceneCharacterListPage"] switch = panel_state_on_text if panel_state == "0": switch = panel_state_off_text scene_character_list = scene_data["SceneCharacterData"] if len(scene_character_list) > 1: era_print.normal_print(" ") py_cmd.pcmd(switch, "SeeSceneCharacterListPage") era_print.little_line_print()
def print_map(map_path: list) -> list: """ 按地图路径绘制地图 Ketword arguments: map_path -- 地图路径 """ map_path_str = get_map_system_path_str_for_list(map_path) map_draw = get_map_draw_for_map_path(map_path_str) character_position = cache_contorl.character_data["character"][0].position character_now_scene_id = get_scene_id_in_map_for_scene_path_on_map_path( character_position, map_path ) input_s = [] map_y_list = map_draw["Draw"] map_x_cmd_list_data = map_draw["Cmd"] map_x_cmd_id_list_data = map_draw["CmdId"] for map_x_list_id in range(len(map_y_list)): map_x_list = map_y_list[map_x_list_id] now_cmd_list = map_x_cmd_list_data[map_x_list_id] now_cmd_id_list = map_x_cmd_id_list_data[map_x_list_id] cmd_list_str = "".join(now_cmd_list) era_print.normal_print( text_handle.align(map_x_list + cmd_list_str, "center", True), rich_text_judge=False, ) i = 0 while i in range(len(map_x_list)): if now_cmd_id_list != []: while i == now_cmd_id_list[0]: if now_cmd_list[0] == character_now_scene_id: era_print.normal_print( now_cmd_list[0], "nowmap", rich_text_judge=False ) input_s.append(None) else: py_cmd.pcmd(now_cmd_list[0], now_cmd_list[0], None) input_s.append(now_cmd_list[0]) now_cmd_list = now_cmd_list[1:] now_cmd_id_list = now_cmd_id_list[1:] if now_cmd_list == []: break if now_cmd_id_list != []: era_print.normal_print(map_x_list[i : now_cmd_id_list[0]]) i = now_cmd_id_list[0] else: era_print.normal_print(map_x_list[i:]) i = len(map_x_list) else: era_print.normal_print(map_x_list[i:]) i = len(map_x_list) era_print.line_feed_print() return input_s
def main_frame_panel() -> list: """ 游戏主菜单 """ cmd_list = [] character_id = cache_contorl.character_data[0].target_character_id character_data = cache_contorl.character_data[character_id] title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "64") era_print.little_title_print(title_text) date_text = game_time.get_date_text() era_print.normal_print(date_text) era_print.normal_print(" ") week_date_text = game_time.get_week_day_text() era_print.normal_print(week_date_text) era_print.normal_print(" ") character_name = character_data.name py_cmd.pcmd(character_name, character_name, None) cmd_list.append(character_name) era_print.normal_print(" ") gold_text = attr_text.get_gold_text(character_id) era_print.line_feed_print(gold_text) attr_print.print_hp_and_mp_bar(character_id) main_menu_text = text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "68") era_print.son_title_print(main_menu_text) era_print.line_feed_print("\n") ask_for_main_menu = cmd_button_queue.option_int(constant.CmdMenu.MAIN_MENU, 3, "left", askfor=False, cmd_size="center") cmd_list = cmd_list + ask_for_main_menu system_menu_text = text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "69") era_print.son_title_print(system_menu_text) era_print.line_feed_print() system_menu_start_id = len(ask_for_main_menu) ask_for_system_menu = cmd_button_queue.option_int( constant.CmdMenu.SYSTEM_MENU, 4, "left", askfor=False, cmd_size="center", start_id=system_menu_start_id, ) cmd_list = cmd_list + ask_for_system_menu return cmd_list
def see_character_item_panel(character_id: int) -> list: """ 查看角色背包道具列表面板 Keyword arguments: character_id -- 角色Id """ era_print.normal_print( attr_text.get_see_attr_panel_head_character_info(character_id)) era_print.restart_line_print(".") if character_id != 0: era_print.line_feed_print( text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "37")) return [] character_item_data = cache_contorl.character_data["character"][ character_id].item if len(character_item_data) == 0: era_print.line_feed_print( text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "36")) return [] now_page_id = int(cache_contorl.panel_state["SeeCharacterItemListPanel"]) now_page_max = game_config.see_character_item_max now_page_start_id = now_page_id * now_page_max now_page_end_id = now_page_start_id + now_page_max if now_page_end_id > len(character_item_data.keys()): now_page_end_id = len(character_item_data.keys()) input_s = [] index = 0 for i in range(now_page_start_id, now_page_end_id): item_id = list(character_item_data.keys())[i] item_data = character_item_data[item_id] item_text = (item_data["ItemName"] + " " + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "136") + str(item_data["ItemNum"])) if character_id == "0": id_info = cmd_button_queue.id_index(index) cmd_text = id_info + item_text py_cmd.pcmd(cmd_text, index, None) else: era_print.normal_print(item_text) index += 1 input_s.append(str(index)) era_print.line_feed_print() return input_s
def show_scene_name_list_panel() -> str: """ 地图下场景名称绘制面板 """ title_text = text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "86") era_print.normal_print(title_text) panel_state = cache_contorl.panel_state["SeeSceneNameListPanel"] if panel_state == "0": py_cmd.pcmd(panel_state_off_text, "SeeSceneNameListPanel") era_print.line_feed_print() now_map = cache_contorl.now_map now_position = cache_contorl.character_data[0].position now_scene = map_handle.get_scene_id_in_map_for_scene_path_on_map_path( now_position, now_map) now_map_map_system_str = map_handle.get_map_system_path_str_for_list( now_map) scene_name_data = map_handle.get_scene_name_list_for_map_path( now_map_map_system_str) scene_name_list = {} null_scene = now_scene for scene in scene_name_data: scene_name_list[scene] = scene + ":" + scene_name_data[scene] cmd_button_queue.option_str( None, 4, "center", False, False, list(scene_name_list.values()), null_scene, list(scene_name_list.keys()), ) else: py_cmd.pcmd(panel_state_on_text, "SeeSceneNameListPanel") era_print.line_feed_print() era_print.little_line_print() return "SeeSceneNameListPanel"
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 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 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_food_shop_list_by_food_type(max_page: int, food_list: list) -> list: """ 用于查看餐馆出售食物列表的面板 Keyword arguments: max_page -- 最大页数 Return arguments: list -- 监听的按钮列表 """ era_print.restart_line_print("+") tag_text_index = 0 now_page_id = int( cache_contorl.panel_state["SeeFoodShopListByFoodTypePanel"] ) now_page_max = game_config.food_shop_item_max now_page_start_id = now_page_id * now_page_max now_page_end_id = now_page_start_id + now_page_max if not len(food_list): 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(food_list): now_page_end_id = len(food_list) input_s = [] text_list = [] fix_text = "" for i in range(now_page_start_id, now_page_end_id): now_food = food_list[i] if now_food.recipe == -1: food_config = text_loading.get_text_data( constant.FilePath.FOOD_PATH, now_food.id ) food_name = food_config["Name"] else: food_name = cache_contorl.recipe_data[now_food.recipe].name now_index = cmd_button_queue.id_index(tag_text_index) food_text = now_index + " " + food_name food_text += " " + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "154" ) if "Hunger" in now_food.feel: food_text += str(round(now_food.feel["Hunger"], 2)) else: food_text += "0" food_text += " " + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "153" ) if "Thirsty" in now_food.feel: food_text += str(round(now_food.feel["Thirsty"], 2)) else: food_text += "0" food_text += ( " " + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "155" ) + str(now_food.weight) ) food_text += text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "156" ) food_text += " " + text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "152" ) food_text += text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "151" )[now_food.quality] text_list.append(food_text) now_fix_text = text_handle.align(food_text, "center", True) if fix_text == "": fix_text = now_fix_text if len(now_fix_text) < len(fix_text): fix_text = now_fix_text tag_text_index += 1 for i in range(tag_text_index): now_text = fix_text + text_list[i] now_text = text_handle.align(now_text) py_cmd.pcmd(now_text, i) era_print.normal_print("\n") input_s.append(str(i)) if i < tag_text_index - 1: era_print.restart_line_print("*") return input_s
def cmd_size_print( cmd_text, cmd_text_bak, cmd_event=None, text_width=0, cmd_size="left", no_null_cmd=True, normal_style="standard", on_style="onbutton", ): """ 计算命令对齐方式,补全文本并绘制 Keyword arguments: cmd_text -- 命令文本 cmd_text_bak -- 命令被触发时返回的文本 cmd_event -- 命令绑定的事件 (default None) text_width -- 文本对齐时补全空间宽度 cmd_size -- 命令对齐方式(left/center/right) (default 'left') no_null_cmd -- 绘制命令而非null命令样式的文本 (default False) normal_style -- 按钮通常样式 (default 'standard') on_style -- 按钮被按下时样式 (default 'onbutton') """ if not no_null_cmd: cmd_text = "<nullcmd>" + cmd_text + "</nullcmd>" if cmd_size == "left": cmd_width = text_handle.get_text_index(cmd_text) cmd_text_fix = " " * (text_width - cmd_width) if no_null_cmd: py_cmd.pcmd( cmd_text, cmd_text_bak, cmd_event, normal_style=normal_style, on_style=on_style, ) else: era_print.normal_print(cmd_text) era_print.normal_print(cmd_text_fix) elif cmd_size == "center": cmd_width = text_handle.get_text_index(cmd_text) cmd_text_fix = " " * (int(text_width / 2) - int(cmd_width / 2)) era_print.normal_print(cmd_text_fix) if no_null_cmd: py_cmd.pcmd( cmd_text, cmd_text_bak, cmd_event, normal_style=normal_style, on_style=on_style, ) else: era_print.normal_print(cmd_text) era_print.normal_print(cmd_text_fix) elif cmd_size == "right": cmd_width = text_handle.get_text_index(cmd_text) cmd_text_fix = " " * (text_width - cmd_width) if no_null_cmd: py_cmd.pcmd( cmd_text, cmd_text_bak, cmd_event, normal_style=normal_style, on_style=on_style, ) else: era_print.normal_print(cmd_text) era_print.normal_print(cmd_text_fix)
def see_save_list_panel(page_save_value: int, last_save_page_value: int, auto_save=False) -> list: """ 查看存档页面面板 Keyword arguments: page_save_value -- 单页最大存档显示数量 last_save_page_value -- 最后一页存档显示数量 auto_save -- 自动存档显示开关 (default False) """ save_panel_page = int(cache_contorl.panel_state["SeeSaveListPanel"]) + 1 input_s = [] id_text_list = [] id_info_text = text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "72") text_width = int(game_config.text_width) save_none_text = text_loading.get_text_data(constant.FilePath.MESSAGE_PATH, "20") if save_panel_page == int(game_config.save_page) + 1: start_save_id = int(page_save_value) * (save_panel_page - 1) over_save_id = start_save_id + last_save_page_value else: over_save_id = int(page_save_value) * save_panel_page start_save_id = over_save_id - int(page_save_value) for i in range(0, over_save_id - start_save_id): id = cmd_button_queue.id_index(i) save_id = start_save_id + i if auto_save and not save_handle.judge_save_file_exist(str(save_id)): id_text = id_info_text + " " + str(save_id) + ":" id_text_list.append(id_text) else: id_text = id + id_info_text + " " + str(save_id) + ":" id_text_list.append(id_text) for i in range(0, over_save_id - start_save_id): id = str(i) id_text = id_text_list[i] era_print.little_line_print() save_id = str(save_handle.get_save_page_save_id(page_save_value, i)) if save_handle.judge_save_file_exist(save_id): save_info_head = save_handle.load_save_info_head(save_id) game_time_data = save_info_head["game_time"] game_time_text = game_time.get_date_text(game_time_data) character_name = save_info_head["character_name"] save_verson = save_info_head["game_verson"] save_text = (character_name + " " + game_time_text + " " + save_verson) id_text_index = int(text_handle.get_text_index(id_text)) fix_id_width = text_width - id_text_index save_align = text_handle.align(save_text, "center", text_width=fix_id_width) id_text = id_text + save_align py_cmd.pcmd(id_text, id, None) input_s.append(id) era_print.normal_print("\n") else: id_text_index = int(text_handle.get_text_index(id_text)) fix_id_width = text_width - id_text_index save_none_align = text_handle.align(save_none_text, "center", text_width=fix_id_width) id_text = id_text + save_none_align if auto_save: era_print.normal_print(id_text) else: py_cmd.pcmd(id_text, id, None) input_s.append(id) era_print.line_feed_print() if auto_save: auto_info_text = text_loading.get_text_data( constant.FilePath.STAGE_WORD_PATH, "73") i = page_save_value id = cmd_button_queue.id_index(i) era_print.little_line_print() if save_handle.judge_save_file_exist("auto"): save_info_head = save_handle.load_save_info_head("auto") game_time_data = save_info_head["game_time"] game_time_text = game_time.get_date_text(game_time_data) character_name = save_info_head["character_name"] save_verson = save_info_head["game_verson"] save_text = (character_name + " " + game_time_text + " " + save_verson) id_text = id + auto_info_text id_text_index = int(text_handle.get_text_index(id_text)) fix_id_width = text_width - id_text_index save_text_align = text_handle.align(save_text, "center", text_width=fix_id_width) id_text = id_text + save_text_align py_cmd.pcmd(id_text, id, None) input_s.append(id) era_print.line_feed_print() else: id_text_index = int(text_handle.get_text_index(auto_info_text)) fix_id_width = text_width - id_text_index save_none_align = text_handle.align(save_none_text, "center", text_width=fix_id_width) id_text = auto_info_text + save_none_align era_print.normal_print(id_text) era_print.line_feed_print() return input_s