def seePlayerListPanel(maxPage): titleText = TextLoading.getTextData(TextLoading.stageWordId, '74') EraPrint.plt(titleText) inputS = [] pageId = int(CacheContorl.panelState['SeePlayerListPanel']) pageShow = int(GameConfig.playerlist_show) maxPage = int(maxPage) playerMax = CharacterHandle.getCharacterIndexMax() if pageId == maxPage: showPageStart = pageShow * (pageId) showPageOver = showPageStart + (playerMax - showPageStart) else: showPageOver = pageShow * pageId showPageStart = showPageOver - pageShow for i in range(showPageStart, showPageOver + 1): playerId = str(i) cmdId = i - showPageStart cmdIdText = CmdButtonQueue.idIndex(cmdId) cmdText = AttrText.getPlayerAbbreviationsInfo(playerId) cmdIdTextIndex = TextHandle.getTextIndex(cmdIdText) windowWidth = int(GameConfig.text_width) textWidth = windowWidth - cmdIdTextIndex cmdText = TextHandle.align(cmdText, 'center', textWidth=textWidth) cmdText = cmdIdText + ' ' + cmdText cmdId = str(cmdId) EraPrint.plittleline() PyCmd.pcmd(cmdText, cmdId, None) inputS.append(cmdId) EraPrint.p('\n') pageText = '(' + str(pageId) + '/' + str(maxPage) + ')' EraPrint.printPageLine(sample='-', string=pageText) EraPrint.p('\n') return inputS
def plist(stringList, stringColumn=1, stringSize='left'): textWait = CacheContorl.textWait if textWait != 0: time.sleep(textWait) else: pass textWidth = GameConfig.text_width stringIndex = int(textWidth / stringColumn) for i in range(0, len(stringList)): stringText = stringList[i] stringIdIndex = TextHandle.getTextIndex(stringList[i]) if stringSize == 'left': stringTextFix = ' ' * (stringIndex - stringIdIndex) stringText = stringText + stringTextFix elif stringSize == 'center': stringTextFix = ' ' * int((stringIndex - stringIdIndex) / 2) stringText = stringTextFix + stringText + stringTextFix elif stringSize == 'right': stringTextFix = ' ' * (stringIndex - stringIdIndex) stringText = stringTextFix + stringText if i == 0: p(stringText) elif i / stringColumn >= 1 and i % stringColumn == 0: p('\n') p(stringText) else: p(stringText)
def gameMainPanel(): EraPrint.pline() EraPrint.pl(TextHandle.align(GameConfig.game_name, 'center')) EraPrint.pl(TextHandle.align(GameConfig.author, 'right')) EraPrint.pl(TextHandle.align(GameConfig.verson, 'right')) EraPrint.pl(TextHandle.align(GameConfig.verson_time, 'right')) EraPrint.p('\n') EraPrint.pline() EraPrint.lcp(1 / 3, TextLoading.getTextData(TextLoading.messageId, '2')) time.sleep(1) EraPrint.p('\n') EraPrint.pline() time.sleep(1) PyCmd.focusCmd() menuInt = CmdButtonQueue.optionint(CmdButtonQueue.logomenu) return menuInt
def printPageLine(sample=':', string='', style='standard'): textWait = CacheContorl.textWait if textWait != 0: time.sleep(textWait) else: pass textWidth = int(GameConfig.text_width) stringWidth = int(TextHandle.getTextIndex(string)) fixText = sample * int(textWidth / 2 - stringWidth / 2) stringText = fixText + string + fixText p(stringText, style)
def lcp(sleepTime, string='', style='standard'): textWait = CacheContorl.textWait if textWait != 0: time.sleep(textWait) else: pass CacheContorl.wframeMouse['wFrameLineState'] = 1 string = str(string) stringlist = string.split('\n') width = GameConfig.text_width styleNameList = GameConfig.getFontDataList() stringCenterList = '' for i in range(0, len(styleNameList)): styleTextHead = '<' + styleNameList[i] + '>' styleTextTail = '</' + styleNameList[i] + '>' if styleTextHead in string: stringCenter = string.replace(styleTextHead, '') stringCenter = stringCenter.replace(styleTextTail, '') stringCenterList = stringCenter.split('\n') else: stringCenterList = stringlist for i in range(0, len(stringlist)): widthI = int(width) / 2 countIndex = TextHandle.getTextIndex(stringCenterList[i]) countI = int(countIndex) / 2 if CacheContorl.wframeMouse['wFrameRePrint'] == 1: p('\n') p(' ' * int((widthI - countI))) p(stringlist[i]) else: p(' ' * int((widthI - countI))) pobo(sleepTime, stringlist[i]) p('\n') if CacheContorl.wframeMouse['wFrameLinesUp'] == 1: indexIUp = i + 1 CacheContorl.wframeMouse['wFrameLinesUp'] = 2 for indexIUp in range(indexIUp, len(stringlist)): pl(TextHandle.align(stringlist[indexIUp], 'center'), style) CacheContorl.wframeMouse['wFrameLineState'] = 2 break CacheContorl.wframeMouse['wFrameRePrint'] = 0
def cmdSizePrint(cmdText, cmdTextBak, cmdEvent=None, textWidth=0, cmdSize='left'): if cmdSize == 'left': cmdWidth = TextHandle.getTextIndex(cmdText) cmdTextFix = ' ' * (textWidth - cmdWidth) PyCmd.pcmd(cmdText, cmdTextBak, cmdEvent) EraPrint.p(cmdTextFix) elif cmdSize == 'center': cmdWidth = TextHandle.getTextIndex(cmdText) cmdTextFix = ' ' * (int(textWidth / 2) - int(cmdWidth / 2)) EraPrint.p(cmdTextFix) PyCmd.pcmd(cmdText, cmdTextBak, cmdEvent) EraPrint.p(cmdTextFix) elif cmdSize == 'right': cmdWidth = TextHandle.getTextIndex(cmdText) cmdTextFix = ' ' * (textWidth - cmdWidth) EraPrint.p(cmdTextFix) PyCmd.pcmd(cmdText, cmdTextBak, cmdEvent)
def askfor_Int(list,print_order=False): while True: order = order_deal('str', print_order) order = TextHandle.fullToHalfText(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 startInputNamePanel(): EraPrint.pline() EraPrint.pl(TextLoading.getTextData(TextLoading.messageId, '3')) inputState = 0 while inputState == 0: playerName = GameInit.askfor_str() EraPrint.pl(playerName) if TextHandle.getTextIndex(playerName) > 10: EraPrint.pl( TextLoading.getTextData(TextLoading.errorId, 'inputNameTooLongError')) else: inputState = 1 CacheContorl.temporaryObject['Name'] = playerName
def plt(string): textWait = CacheContorl.textWait if textWait != 0: time.sleep(textWait) else: pass string = str(string) string = Dictionaries.handleText(string) global last_char if len(string) > 0: last_char = string[-1:] width = GameConfig.text_width textWidth = TextHandle.getTextIndex(string) lineWidth = int(int(width) / 2 - int(textWidth) / 2 - 2) pl('=' * lineWidth + '<littletitle>▢' + string + '▢</littletitle>' + '=' * lineWidth)
def sontitleprint(string): textWait = CacheContorl.textWait if textWait != 0: time.sleep(textWait) else: pass string = string string = Dictionaries.handleText(string) global last_char if len(string) > 0: last_char = string[-1:] width = GameConfig.text_width textWidth = TextHandle.getTextIndex(string) lineWidth = int(int(width) / 4) lineWidthFix = int(int(width) / 4 - int(textWidth)) pl(':' * lineWidthFix + '<sontitle>' + string + '</sontitle>' + ':' * lineWidth * 3)
def printMap(mapId): mapText = CacheContorl.mapData['MapTextData'][mapId] playerNowSceneId = CacheContorl.playObject['object']['0']['Position'] playerNowSceneId = getMapSceneIdForSceneId(mapId,playerNowSceneId) playerNowSceneId = str(playerNowSceneId) sceneList = getSceneListForMap(mapId) inputS = [] inputCmd = '' passList = [] mapYList = mapText.split('\n') for mapXList in mapYList: mapXListStyle = RichText.setRichTextPrint(mapXList,'standard') mapXList = RichText.removeRichCache(mapXList) mapXFix = TextHandle.align(mapXList,'center',True) EraPrint.p(mapXFix) for i in range(0, len(mapXList)): if str(i) not in passList: if mapXListStyle[i] == 'mapbutton': inputCmd = inputCmd + mapXList[i] for n in range(i + 1,len(mapXList)): if mapXListStyle[n] == 'mapbutton': inputCmd = inputCmd + mapXList[n] passList.append(str(n)) else: break if inputCmd in sceneList: if inputCmd == playerNowSceneId: EraPrint.p(inputCmd,'nowmap') inputS.append(None) else: PyCmd.pcmd(inputCmd, inputCmd, None) inputS.append(inputCmd) else: EraPrint.p(inputCmd,'standard') inputCmd = '' else: EraPrint.p(mapXList[i], mapXListStyle[i]) EraPrint.p('\n') return inputS
def optionint(cmdList, cmdColumn=1, idSize='left', idSwitch=True, askfor=True, cmdSize='left', startId='0', cmdListData=None, lastLine=False): if cmdListData == None: cmdListData = TextLoading.getTextData(TextLoading.cmdId, cmdList).copy() else: pass inputI = [] textWidth = GameConfig.text_width if lastLine == True: if len(cmdListData) < cmdColumn: cmdColumn = len(cmdListData) else: if len(cmdListData) + 1 < cmdColumn: cmdColumn = len(cmdListData) cmdIndex = int(textWidth / cmdColumn) if len(cmdListData) + 1 < cmdColumn: cmdColumn = len(cmdListData) + 1 for i in range(0, len(cmdListData)): cmdText = Dictionaries.handleText(cmdListData[i]) startId = int(startId) returnId = i + startId if idSwitch == True: id = idIndex(returnId) else: id = '' cmdTextAndId = id + cmdText cmdTextAndIdIndex = TextHandle.getTextIndex(cmdTextAndId) if cmdTextAndIdIndex < cmdIndex: if idSize == 'right': cmdTextAndId = cmdText + id elif idSize == 'left': cmdTextAndId = id + cmdText if i == 0: cmdTextAndId = cmdTextAndId.rstrip() cmdSizePrint(cmdTextAndId, returnId, None, cmdIndex, cmdSize) inputI.append(str(returnId)) elif i / cmdColumn >= 1 and i % cmdColumn == 0: EraPrint.p('\n') cmdTextAndId = cmdTextAndId.rstrip() cmdSizePrint(cmdTextAndId, returnId, None, cmdIndex, cmdSize) inputI.append(str(returnId)) elif i == len(cmdListData) and lastLine == True: EraPrint.p('\n') cmdTextAndId = cmdTextAndId.rstrip() cmdSizePrint(cmdTextAndId, returnId, None, cmdIndex, cmdSize) inputI.append(str(returnId)) else: cmdTextAndId = cmdTextAndId.rstrip() cmdSizePrint(cmdTextAndId, returnId, None, cmdIndex, cmdSize) inputI.append(str(returnId)) else: pass EraPrint.p('\n') if askfor == True: ans = int(GameInit.askfor_Int(inputI)) return ans else: return inputI
def seeSaveListPanel(pageSaveValue, lastSavePageValue, autoSave=False): savePanelPage = int(CacheContorl.panelState['SeeSaveListPanel']) + 1 inputS = [] idTextList = [] idInfoText = TextLoading.getTextData(TextLoading.stageWordId, '72') textWidth = int(GameConfig.text_width) saveNoneText = TextLoading.getTextData(TextLoading.messageId, '20') if savePanelPage == int(GameConfig.save_page) + 1: startSaveId = int(pageSaveValue) * (savePanelPage - 1) overSaveId = startSaveId + lastSavePageValue else: overSaveId = int(pageSaveValue) * savePanelPage startSaveId = overSaveId - int(pageSaveValue) for i in range(0, overSaveId - startSaveId): id = CmdButtonQueue.idIndex(i) saveId = startSaveId + i if autoSave == True and SaveHandle.judgeSaveFileExist(saveId) != '1': idText = idInfoText + " " + str(saveId) + ":" idTextList.append(idText) else: idText = id + idInfoText + " " + str(saveId) + ":" idTextList.append(idText) for i in range(0, overSaveId - startSaveId): id = str(i) idText = idTextList[i] EraPrint.plittleline() saveid = SaveHandle.getSavePageSaveId(pageSaveValue, i) if SaveHandle.judgeSaveFileExist(saveid) == '1': saveData = SaveHandle.loadSave(saveid) playerData = saveData['playerData'] gameTimeData = saveData['gameTime'] gameTimeText = GameTime.getDateText(gameTimeData) playerName = playerData['object']['0']['Name'] saveVerson = saveData['gameVerson'] saveText = playerName + ' ' + gameTimeText + ' ' + saveVerson idTextIndex = int(TextHandle.getTextIndex(idText)) fixIdWidth = textWidth - idTextIndex saveAlign = TextHandle.align(saveText, 'center', textWidth=fixIdWidth) idText = idText + saveAlign PyCmd.pcmd(idText, id, None) EraPrint.p('\n') inputS.append(id) else: idTextIndex = int(TextHandle.getTextIndex(idText)) fixIdWidth = textWidth - idTextIndex saveNoneAlign = TextHandle.align(saveNoneText, 'center', textWidth=fixIdWidth) idText = idText + saveNoneAlign if autoSave == True: EraPrint.p(idText) EraPrint.p('\n') else: PyCmd.pcmd(idText, id, None) inputS.append(id) EraPrint.p('\n') if autoSave == True: autoInfoText = TextLoading.getTextData(TextLoading.stageWordId, "73") i = pageSaveValue id = CmdButtonQueue.idIndex(i) EraPrint.plittleline() if SaveHandle.judgeSaveFileExist('auto') == '1': saveData = SaveHandle.loadSave('auto') playerData = saveData['playerData'] gameTimeData = saveData['gameTime'] gameTimeText = GameTime.getDateText(gameTimeData) saveVerson = saveData['gameVerson'] playerName = playerData['object']['0']['Name'] saveText = playerName + ' ' + gameTimeText + ' ' + saveVerson idText = id + autoInfoText idTextIndex = int(TextHandle.getTextIndex(idText)) fixIdWidth = textWidth - idTextIndex saveTextAlign = TextHandle.align(saveText, 'center', textWidth=fixIdWidth) idText = idText + saveTextAlign PyCmd.pcmd(idText, id, None) inputS.append(id) EraPrint.p('\n') else: idTextIndex = int(TextHandle.getTextIndex(autoInfoText)) fixIdWidth = textWidth - idTextIndex saveNoneAlign = TextHandle.align(saveNoneText, 'center', textWidth=fixIdWidth) idText = autoInfoText + saveNoneAlign EraPrint.p(idText) EraPrint.p('\n') else: pass return inputS
textbox = Text(mainframe, width=GameConfig.textbox_width, height=GameConfig.textbox_hight, highlightbackground = GameConfig.background_color,bd = 0) textbox.grid(column=0, row=0, sticky=(N, W, E, S)) # 垂直滚动条 s_vertical = ttk.Scrollbar(mainframe, orient=VERTICAL, command=textbox.yview) textbox.configure(yscrollcommand=s_vertical.set) s_vertical.grid(column=1, row=0, sticky=(N, E, S),rowspan=2) # 输入框背景容器 orderFontData = TextLoading.getTextData(TextLoading.fontListId,'order') inputBackgroundBox = Text(mainframe,highlightbackground = GameConfig.background_color,background = GameConfig.background_color,bd = 0) inputBackgroundBox.grid(column=0, row=1, sticky=(W, E, S)) cursorText = GameConfig.cursor cursorWidth = TextHandle.getTextIndex(cursorText) inputBackgroundBoxCursor = Text(inputBackgroundBox,width=cursorWidth, height=1,highlightbackground = orderFontData['background'],background = orderFontData['background'],bd = 0) inputBackgroundBoxCursor.grid(column=0, row=0, sticky=(W, E, S)) inputBackgroundBoxCursor.insert('end',cursorText) inputBackgroundBoxCursor.config(foreground=orderFontData['foreground']) # 输入栏 estyle = ttk.Style() estyle.element_create("plain.field", "from", "clam") estyle.layout( "EntryStyle.TEntry", [( 'Entry.plain.field',{ 'children':[( 'Entry.background',{ 'children':[(