def order_deal(flag="order", print_order=True): """ 处理命令函数 Keyword arguments: flag -- 类型,默认为order,如果为console,这回执行输入得到的内容 print_order -- 是否将输入的order输出到屏幕上 """ global __skip_flag__ __skip_flag__ = False while True: time.sleep(0.01) while not io_init._order_queue.empty(): order = io_init.get_order() if cache_contorl.flow_contorl["quit_game"]: os._exit(0) if cache_contorl.flow_contorl["restart_game"] == 1: cache_contorl.flow_contorl["restart_game"] = 0 reset_func() return if print_order and order != "": io_init.era_print("\n" + order + "\n") if flag == "str": if order.isdigit(): order = str(int(order)) return order if flag == "console": exec(order) if flag == "order" and order.isdigit(): if _cmd_valid(int(order)): _cmd_deal(int(order)) return else: global tail_deal_cmd_func tail_deal_cmd_func(int(order)) return
def draw(self): """ 绘制面板 """ now_draw = VerticalDrawTextListGroup(self.width) for now_list in self.draw_list: for value in now_list: value.draw() io_init.era_print("\n")
def order_deal(flag="order", print_order=True, donot_return_null_str=True): """ 处理命令函数 Keyword arguments: flag -- 类型,默认为order,如果为console,这回执行输入得到的内容 print_order -- 是否将输入的order输出到屏幕上 donot_return_null_str -- 不接受输入空字符串 """ global __skip_flag__ __skip_flag__ = False while True: time.sleep(0.01) if not donot_return_null_str and cache_contorl.wframe_mouse.w_frame_up: return "" while not io_init._order_queue.empty(): order = io_init.get_order() if cache_contorl.flow_contorl.quit_game: os._exit(0) if print_order and order != "": io_init.era_print("\n" + order + "\n") if flag == "str": if order.isdigit(): order = str(int(order)) return order if flag == "console": exec(order) if flag == "order" and order.isdigit(): if _cmd_valid(int(order)): _cmd_deal(int(order)) return else: global tail_deal_cmd_func tail_deal_cmd_func(int(order)) return
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 draw(self): """ 绘制对象 """ new_group = itertools.zip_longest(*self.draw_list) for draw_list in new_group: now_width = int(self.width / len(draw_list)) for value in draw_list: if value != None: value.draw() else: now_draw = draw.NormalDraw() now_draw.text = " " * now_width now_draw.draw() io_init.era_print("\n")
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) if not cache.wframe_mouse.w_frame_skip_wait_mouse: flow_handle.askfor_wait()
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 draw(self): """ 绘制线条 """ title_draw = NormalDraw() title_draw.width = self.width title_draw.text = self.title title_draw.style = self.title_style line_a_width = int(self.width / 4) - len(title_draw) if line_a_width < 0: line_a_width = 0 line_a = NormalDraw() line_a.width = line_a_width line_a.style = self.style line_a.text = self.line * line_a_width line_b = NormalDraw() line_b.width = self.width - len(title_draw) - len(line_a) line_b.style = self.style line_b.text = self.line * int(line_b.width) for value in [line_a, title_draw, line_b]: value.draw() if self.line_feed: io_init.era_print("\n")
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 normal_print(string: str, style="standard", rich_text_judge=True): """ 游戏基础的文本绘制实现 Keyword arguments: string -- 需要绘制的文本 style -- 文本的默认样式 (default 'standard') rich_text_judge -- 启用富文本的开关 (default True) """ if rich_text_judge: bar_list = list( text_loading.get_game_data( constant.FilePath.BAR_CONFIG_PATH).keys()) string = dictionaries.handle_text(string) style_list = rich_text.set_rich_text_print(string, style) global last_char if len(string) > 0: last_char = string[-1:] string = rich_text.remove_rich_cache(string) string = r"" + string for i in range(0, len(string)): if style_list[i] in bar_list: style_data = text_loading.get_text_data( constant.FilePath.BAR_CONFIG_PATH, style_list[i]) true_bar = style_data["truebar"] null_bar = style_data["nullbar"] if string[i] == "0": image_print(null_bar, "bar") elif string[i] == "1": image_print(true_bar, "bar") else: io_init.era_print(string[i], style_list[i]) else: io_init.era_print(string[i], style_list[i]) else: io_init.era_print(string, style)
def draw(self): """ 绘制线条 """ title_draw = NormalDraw() title_draw.width = self.width title_draw.style = self.title_style title_draw.text = f" {self.title} " fix_width = self.width - len(title_draw) if fix_width < 0: fix_width = 0 frame_width = int(fix_width / 2) frame_draw = NormalDraw() frame_draw.width = frame_width frame_draw.style = self.frame_style frame_draw.text = self.frame line_width = int(fix_width / 2 - len(frame_draw)) if line_width < 0: line_width = 0 line_draw = NormalDraw() line_draw.width = line_width line_draw.style = self.style line_draw.text = self.line * line_width for text in [line_draw, frame_draw, title_draw, frame_draw, line_draw]: text.draw() io_init.era_print("\n")
def askfor_int(list, print_order=False): """ 用于请求位于列表中的整数的输入,如果输入没有在列表中,则告知用户出错。 Keyword arguments: list -- 用于判断的列表内容 print_order -- 是否将输入的order输出到屏幕上 """ while True: order = order_deal("str", print_order) order = text_handle.full_to_half_text(order) if order in list: io_init.era_print(order + "\n\n") return order elif order == "": continue else: io_init.era_print(order + "\n") io_init.era_print(_("您输入的选项无效,请重试\n")) continue
def askfor_all(list, print_order=False): """ 用于请求一个位于列表中的输入,如果输入没有在列表中,则告知用户出错。 Keyword arguments: list -- 用于判断的列表内容 print_order -- 是否将输入的order输出到屏幕上 """ while True: order = order_deal("str", print_order) if order in list: io_init.era_print(order + "\n") return order elif order == "": continue else: io_init.era_print(order + "\n") io_init.era_print( text_loading.get_text_data(constant.FilePath.ERROR_PATH, "noInputListError") + "\n") continue
def askfor_all(input_list: list, print_order=False): """ 用于请求一个位于列表中的输入,如果输入没有在列表中,则告知用户出错。 Keyword arguments: input_list -- 用于判断的列表内容 print_order -- 是否将输入的order输出到屏幕上 """ while 1: order = order_deal("str", print_order) if order in input_list: io_init.era_print(order + "\n") if _cmd_valid(order): _cmd_deal(order) return order elif order == "": continue else: io_init.era_print(order + "\n") io_init.era_print(_("您输入的选项无效,请重试\n")) continue
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): """ 绘制面板 """ self.message.draw() io_init.era_print("\n") self.button_panel.draw()
def draw(self): """ 绘制面板 """ for now_list in self.draw_list: for value in now_list: value.draw() io_init.era_print("\n")
def draw(self): """ 绘制面板 """ panel = "\n" * 50 io_init.era_print(panel)
def draw(self): """ 绘制按钮列表 """ for button in self.button_list: button.draw() io_init.era_print("\n")