def order_deal(flag='order', print_order=True): global __skip_flag__ __skip_flag__ = False while True: time.sleep(0.01) while not IoInit._order_queue.empty(): order = IoInit.getorder() if CacheContorl.flowContorl['quitGame']: os._exit(0) return if CacheContorl.flowContorl['restartGame'] == 1: CacheContorl.flowContorl['restartGame'] = 0 reset_func() return if print_order == True and order != '': IoInit.print('\n' + order + '\n') if flag == 'str': return order if flag == 'console': # TODO add_console_method 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 cmd_clear(*number): set_tail_deal_cmd_func(default_tail_deal_cmd_func) if number: for num in number: cmd_map.pop(num) IoInit.io_clear_cmd(num) else: cmd_map.clear() IoInit.io_clear_cmd()
def p(string, style='standard'): barlist = TextLoading.getTextData(TextLoading.barListId, 'barlist') styleList = RichText.setRichTextPrint(string, style) global last_char if len(string) > 0: last_char = string[-1:] string = RichText.removeRichCache(string) for i in range(0, len(string)): if styleList[i] in barlist: styledata = TextLoading.getTextData(TextLoading.barListId, styleList[i]) truebar = styledata['truebar'] nullbar = styledata['nullbar'] if string[i] == '0': pimage(nullbar, 'bar') elif string[i] == '1': pimage(truebar, 'bar') else: IoInit.print(string[i], styleList[i]) else: IoInit.print(string[i], styleList[i])
def askfor_All(list,print_order=False): while True: order = order_deal('str', print_order) if order in list: IoInit.print(order + '\n') return order elif order == '': continue else: IoInit.print(order + '\n') IoInit.print(TextLoading.getTextData(TextLoading.errorId, 'noInputListError') + '\n') continue
def init(main_flow): global def_style IoInit.clear_screen() IoInit.clearorder() FlowHandle.cmd_clear() # 载入数据库数据 GameData.init() # 事件载入 Event.load_event_file() # 载入按键监听 KeyListionEvent.onWFrameListion() # 设置背景颜色 IoInit.set_background(GameData.gamedata()['core_cfg']['background_color']) # 初始化字体 IoInit.init_style() # 初始化地图数据 MapHandle.initSceneData() MapHandle.initMapData() FlowHandle.reset_func = reset global _main_flow _main_flow = main_flow _have_run = False def run_main_flow(): nonlocal _have_run while True: if _have_run == False: main_flow() _have_run = True askfor_order() FlowHandle.call_default_flow() if FlowHandle.exit_flag == True: break run_main_flow()
def print_cmd(cmd_str, cmd_number, cmd_func=null_func, arg=(), kw={}, normal_style='standard', on_style='onbutton'): '''arg is tuple contain args which cmd_func could be used''' bind_cmd(cmd_number, cmd_func, arg, kw) IoInit.io_print_cmd(cmd_str, cmd_number, normal_style, on_style) return cmd_str
def pimage(imageName, imagePath=''): IoInit.imageprint(imageName, imagePath) pass
def reset(): global _main_flow IoInit.io_clear_cmd() IoInit.clear_screen() IoInit.clearorder() init(_main_flow)
def run(main_func): def _init(): init(main_func) IoInit.run(_init)