Exemple #1
0
def getProportionalBar(valueName: str,
                       maxValue: int,
                       value: int,
                       barid: str,
                       textWidth=0) -> str:
    '''
    通用用于计算比例条的函数
    Keyword arguments:
    valueName -- 比例条名字
    maxValue -- 最大数值
    value -- 当前数值
    barid -- 用于填充比例条的图形id
    textWidth -- 进度条区域宽度 (default 0)
    '''
    if textWidth == 0:
        textWidth = GameConfig.text_width
    barWidth = textWidth - TextHandle.getTextIndex(
        valueName) - 5 - TextHandle.getTextIndex(
            str(maxValue)) - TextHandle.getTextIndex(str(value))
    proportion = int(int(value) / int(maxValue) * barWidth)
    trueBar = "1"
    nullBar = "0"
    proportionBar = trueBar * proportion
    fixProportionBar = nullBar * int(barWidth - proportion)
    proportionBar = '<' + barid + '>' + proportionBar + fixProportionBar + '</' + barid + '>'
    proportionBar = str(valueName) + '[' + proportionBar + ']' + '(' + str(
        value) + '/' + str(maxValue) + ')'
    return proportionBar
Exemple #2
0
def cmdSizePrint(cmdText,
                 cmdTextBak,
                 cmdEvent=None,
                 textWidth=0,
                 cmdSize='left',
                 noNullCmd=True,
                 normalStyle='standard',
                 onStyle='onbutton'):
    '''
    计算命令对齐方式,补全文本并绘制
    Keyword arguments:
    cmdText -- 命令文本
    cmdTextBak -- 命令被触发时返回的文本
    cmdEvent -- 命令绑定的事件 (default None)
    textWidth -- 文本对齐时补全空间宽度
    cmdSize -- 命令对齐方式(left/center/right) (default 'left')
    noNullCmd -- 绘制命令而非null命令样式的文本 (default False)
    normalStyle -- 按钮通常样式 (default 'standard')
    onStyle -- 按钮被按下时样式 (default 'onbutton')
    '''
    if noNullCmd == False:
        cmdText = '<nullcmd>' + cmdText + '</nullcmd>'
    if cmdSize == 'left':
        cmdWidth = TextHandle.getTextIndex(cmdText)
        cmdTextFix = ' ' * (textWidth - cmdWidth)
        if noNullCmd:
            PyCmd.pcmd(cmdText,
                       cmdTextBak,
                       cmdEvent,
                       normal_style=normalStyle,
                       on_style=onStyle)
        else:
            EraPrint.p(cmdText)
        EraPrint.p(cmdTextFix)
    elif cmdSize == 'center':
        cmdWidth = TextHandle.getTextIndex(cmdText)
        cmdTextFix = ' ' * (int(textWidth / 2) - int(cmdWidth / 2))
        EraPrint.p(cmdTextFix)
        if noNullCmd:
            PyCmd.pcmd(cmdText,
                       cmdTextBak,
                       cmdEvent,
                       normal_style=normalStyle,
                       on_style=onStyle)
        else:
            EraPrint.p(cmdText)
        EraPrint.p(cmdTextFix)
    elif cmdSize == 'right':
        cmdWidth = TextHandle.getTextIndex(cmdText)
        cmdTextFix = ' ' * (textWidth - cmdWidth)
        if noNullCmd:
            PyCmd.pcmd(cmdText,
                       cmdTextBak,
                       cmdEvent,
                       normal_style=normalStyle,
                       on_style=onStyle)
        else:
            EraPrint.p(cmdText)
        EraPrint.p(cmdTextFix)
Exemple #3
0
def seeCharacterWearClothes(characterId:str,changeButton:bool):
    '''
    查看角色穿戴服装列表面板
    Keyword arguments:
    characterId -- 角色id
    changeButton -- 将服装列表绘制成按钮的开关
    '''
    EraPrint.p('\n')
    characterClothingData = CacheContorl.characterData['character'][characterId]['Clothing']
    characterPutOnList = CacheContorl.characterData['character'][characterId]['PutOn']
    clothingTextData = {}
    tagTextIndex = 0
    for i in range(len(Clothing.clothingTypeTextList.keys())):
        clothingType = list(Clothing.clothingTypeTextList.keys())[i]
        clothingId = characterPutOnList[clothingType]
        if clothingId == '':
            clothingTextData[clothingType] = 'None'
        else:
            clothingData = characterClothingData[clothingType][clothingId]
            clothingText = Clothing.clothingTypeTextList[clothingType] + ':' + clothingData['Evaluation'] + clothingData['Tag'] + clothingData['Name']
            clothingTextData[clothingText] = {}
            for tag in Clothing.clothingTagTextList:
                tagText = Clothing.clothingTagTextList[tag] + str(clothingData[tag])
                clothingTextData[clothingText][tagText] = 0
                nowTagTextIndex = TextHandle.getTextIndex(tagText)
                if nowTagTextIndex > tagTextIndex:
                    tagTextIndex = nowTagTextIndex
    longClothingTextIndex = TextHandle.getTextIndex(max(clothingTextData.keys(),key=TextHandle.getTextIndex))
    i = 0
    inputS = []
    for clothingText in clothingTextData:
        drawText = ''
        EraPrint.plittleline()
        if clothingTextData[clothingText] == 'None':
            drawText = Clothing.clothingTypeTextList[clothingText] + ':' + TextLoading.getTextData(TextLoading.stageWordPath,'117')
        else:
            nowClothingTextIndex = TextHandle.getTextIndex(clothingText)
            drawText += clothingText + ' '
            if nowClothingTextIndex < longClothingTextIndex:
                drawText += ' ' * (longClothingTextIndex - nowClothingTextIndex)
            for tagText in clothingTextData[clothingText]:
                nowTagTextIndex = TextHandle.getTextIndex(tagText)
                if nowTagTextIndex < tagTextIndex:
                    drawText += ' ' + tagText + ' ' * (tagTextIndex - nowTagTextIndex)
                else:
                    drawText += ' ' + tagText
        if changeButton:
            idInfo = CmdButtonQueue.idIndex(i)
            cmdText = idInfo + drawText
            PyCmd.pcmd(cmdText,i,None)
        else:
            EraPrint.p(drawText)
        i += 1
        inputS.append(str(i))
        EraPrint.p('\n')
    return inputS
def seeCharacterListPanel(maxPage):
    titleText = TextLoading.getTextData(TextLoading.stageWordPath,'74')
    EraPrint.plt(titleText)
    inputS = []
    pageId = int(CacheContorl.panelState['SeeCharacterListPanel'])
    pageShow = int(GameConfig.characterlist_show)
    maxPage = int(maxPage)
    characterMax = CharacterHandle.getCharacterIndexMax()
    if pageId == maxPage:
        showPageStart = pageShow * pageId
        showPageOver = showPageStart + (characterMax + 1 - showPageStart)
    else:
        showPageOver = pageShow * (pageId + 1)
        showPageStart = showPageOver - pageShow
    for i in range(showPageStart,showPageOver):
        characterId = str(i)
        cmdId = i - showPageStart
        cmdIdText = CmdButtonQueue.idIndex(cmdId)
        cmdText = AttrText.getCharacterAbbreviationsInfo(characterId)
        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
Exemple #5
0
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)
Exemple #6
0
def plist(stringList:list,stringColumn=1,stringSize='left'):
    '''
    绘制字符串列表
    Keyword arguments:
    stringList -- 要进行绘制的字符串列表
    stringColum -- 每行的绘制数量(列宽由行宽平分为行数而来) (default 1)
    stringSize -- 每列在列宽中的对齐方式(left/center/right) (default 'left')
    '''
    textWait = CacheContorl.textWait
    textWidth = GameConfig.text_width
    if textWait != 0:
        time.sleep(textWait)
    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
            nowTextIndex = TextHandle.getTextIndex(stringText)
            if stringTextFix != '' and nowTextIndex < stringIndex:
                stringText += ' ' * (stringIndex - nowTextIndex)
            elif stringTextFix != '' and nowTextIndex > stringIndex:
                stringText = stringText[-1]
        elif stringSize == 'right':
            stringTextFix = ' ' * (stringIndex - stringIdIndex)
            stringText = stringTextFix + stringText
        stringTextIndex = TextHandle.getTextIndex(stringText)
        if stringTextIndex > stringIndex:
            stringText = stringText[:stringIndex]
        elif stringTextIndex < stringIndex:
            stringText = ' ' * (stringIndex - stringTextIndex) + stringText
        if i == 0:
            p(stringText)
        elif i / stringColumn >= 1 and i % stringColumn == 0:
            p('\n')
            p(stringText)
        else:
            p(stringText)
Exemple #7
0
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)
Exemple #8
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)
Exemple #9
0
def startInputNamePanel():
    EraPrint.pline()
    EraPrint.pl(TextLoading.getTextData(TextLoading.messagePath, '3'))
    inputState = 0
    while inputState == 0:
        characterName = GameInit.askfor_str()
        EraPrint.pl(characterName)
        if TextHandle.getTextIndex(characterName) > 10:
            EraPrint.pl(
                TextLoading.getTextData(TextLoading.errorPath,
                                        'inputNameTooLongError'))
        else:
            inputState = 1
            CacheContorl.temporaryCharacter['Name'] = characterName
Exemple #10
0
def startInputNamePanel():
    '''
    玩家姓名输入处理面板
    '''
    EraPrint.pline()
    EraPrint.pl(TextLoading.getTextData(TextLoading.messagePath, '3'))
    while 1:
        characterName = GameInit.askfor_str()
        EraPrint.pl(characterName)
        if TextHandle.getTextIndex(characterName) > 10:
            EraPrint.pl(TextLoading.getTextData(TextLoading.errorPath, 'inputNameTooLongError'))
        else:
            CacheContorl.characterData['character'][0].Name = characterName
            break
Exemple #11
0
def printPageLine(sample = ':',string = '',style = 'standard'):
    '''
    绘制页数线
    Keyword arguments:
    sample -- 填充线样式 (default ':')
    string -- 页数字符串 (default '')
    style -- 页数线默认样式 (default 'standard')
    '''
    textWait = CacheContorl.textWait
    if textWait != 0:
        time.sleep(textWait)
    textWidth = int(GameConfig.text_width)
    stringWidth = int(TextHandle.getTextIndex(string))
    fixText = sample * int(textWidth / 2 - stringWidth / 2)
    stringText = fixText + string + fixText
    p(stringText,style)
Exemple #12
0
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)
Exemple #13
0
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)
Exemple #14
0
def lcp(sleepTime:float,string='',style='standard'):
    '''
    将多行文本以居中的对齐方式进行逐字绘制
    Keyword arguments:
    sleepTime -- 逐字的间隔时间
    string -- 需要逐字绘制的文本
    style -- 文本的默认样式
    '''
    textWait = CacheContorl.textWait
    if textWait != 0:
        time.sleep(textWait)
    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
Exemple #15
0
def startInputSelfName():
    '''
    玩家自称输入处理面板
    '''
    EraPrint.pline()
    EraPrint.pl(TextLoading.getTextData(TextLoading.messagePath, '15'))
    inputState = 0
    while inputState == 0:
        characterSelfName = GameInit.askfor_str()
        EraPrint.pl(characterSelfName)
        if TextHandle.getTextIndex(characterSelfName) > 10:
            EraPrint.pl(
                TextLoading.getTextData(TextLoading.errorPath,
                                        'inputSelfNameTooLongError'))
        else:
            inputState = 1
            CacheContorl.temporaryCharacter['SelfName'] = characterSelfName
    EraPrint.p('\n')
Exemple #16
0
def plt(string:str):
    '''
    按预订样式"littletitle(小标题)"绘制文本
    示例:
    ====▢小标题▢====
    文本将用=补全至与行同宽
    Keyword arguments:
    string -- 小标题文本
    '''
    textWait = CacheContorl.textWait
    if textWait != 0:
        time.sleep(textWait)
    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)
Exemple #17
0
def sontitleprint(string:str):
    '''
    按预订样式"sontitle(子标题)"绘制文本
    示例:
    ::::子标题::::
    文本将用=补全至与行同宽
    Keyword arguments:
    string -- 子标题文本
    '''
    textWait = CacheContorl.textWait
    if textWait != 0:
        time.sleep(textWait)
    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)
Exemple #18
0
def optionint(cmdList: list,
              cmdColumn=1,
              idSize='left',
              idSwitch=True,
              askfor=True,
              cmdSize='left',
              startId=0,
              cmdListData=None,
              lastLine=False) -> list:
    '''
    批量绘制带id命令列表
    例:
    [000]开始游戏
    Keyword arguments:
    cmdList -- 命令列表id,当cmdListData为None时,根据此id调用cmdList内的命令数据
    cmdColumn -- 每行命令列数 (default 1)
    idSize -- id文本位置(left/center/right) (default 'left')
    idSwitch -- id显示开关 (default True)
    askfor -- 绘制完成时等待玩家输入的开关 (default True)
    cmdSize -- 命令文本在当前列的对齐方式(left/center/right) (default 'left')
    startId -- 命令列表的起始id (default 0)
    cmdListData -- 命令列表数据 (default None)
    lastLine -- 最后一个命令换行绘制 (default False)
    '''
    if cmdListData == None:
        cmdListData = TextLoading.getTextData(TextLoading.cmdPath,
                                              cmdList).copy()
    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])
        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))
    EraPrint.p('\n')
    if askfor == True:
        ans = int(GameInit.askfor_Int(inputI))
        return ans
    else:
        return inputI
Exemple #19
0
def seeCharacterClothesPanel(characterId: str, clothingType: str,
                             maxPage: int):
    '''
    用于查看角色服装列表的面板
    Keyword arguments:
    characterId -- 角色id
    clothingType -- 服装类型
    maxPage -- 服装列表最大页数
    '''
    EraPrint.p('\n')
    characterClothingData = CacheContorl.characterData['character'][
        characterId].Clothing[clothingType]
    characterPutOnList = CacheContorl.characterData['character'][
        characterId].PutOn
    clothingTextData = {}
    tagTextIndex = 0
    nowPageId = int(CacheContorl.panelState["SeeCharacterClothesPanel"])
    nowPageMax = GameConfig.see_character_clothes_max
    nowPageStartId = nowPageId * nowPageMax
    nowPageEndId = nowPageStartId + nowPageMax
    if characterClothingData == {}:
        EraPrint.p(TextLoading.getTextData(TextLoading.messagePath, '34'))
        EraPrint.p('\n')
        return []
    if nowPageEndId > len(characterClothingData.keys()):
        nowPageEndId = len(characterClothingData.keys())
    passId = None
    for i in range(nowPageStartId, nowPageEndId):
        clothingId = list(characterClothingData.keys())[i]
        if clothingId == CacheContorl.characterData['character'][
                characterId].PutOn[clothingType]:
            passId = i - nowPageStartId
        clothingData = characterClothingData[clothingId]
        clothingText = clothingData['Evaluation'] + clothingData[
            'Tag'] + clothingData['Name']
        clothingTextData[clothingText] = {}
        for tag in Clothing.clothingTagTextList:
            tagText = Clothing.clothingTagTextList[tag] + str(
                clothingData[tag])
            clothingTextData[clothingText][tagText] = 0
            nowTagTextIndex = TextHandle.getTextIndex(tagText)
            if nowTagTextIndex == nowTagTextIndex:
                tagTextIndex = nowTagTextIndex
    longClothingTextIndex = TextHandle.getTextIndex(
        max(clothingTextData.keys(), key=TextHandle.getTextIndex))
    i = 0
    inputS = []
    for clothingText in clothingTextData:
        drawText = ''
        EraPrint.plittleline()
        nowClothingTextIndex = TextHandle.getTextIndex(clothingText)
        drawText += clothingText + ' '
        if nowClothingTextIndex < longClothingTextIndex:
            drawText += ' ' * (longClothingTextIndex - nowClothingTextIndex)
        for tagText in clothingTextData[clothingText]:
            nowTagTextIndex = TextHandle.getTextIndex(tagText)
            if nowTagTextIndex < tagTextIndex:
                drawText += ' ' + tagText + ' ' * (tagTextIndex -
                                                   nowTagTextIndex)
            else:
                drawText += ' ' + tagText
        if i == passId:
            drawText += ' ' + TextLoading.getTextData(
                TextLoading.stageWordPath, '125')
        idInfo = CmdButtonQueue.idIndex(i)
        cmdText = idInfo + drawText
        inputS.append(f'{i}')
        PyCmd.pcmd(cmdText, i, None)
        i += 1
    EraPrint.p('\n')
    pageText = '(' + str(nowPageId) + '/' + str(maxPage) + ')'
    EraPrint.printPageLine(sample='-', string=pageText)
    EraPrint.p('\n')
    return inputS
Exemple #20
0
# 垂直滚动条
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.fontConfigPath, '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', {
Exemple #21
0
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.cmdPath,
                                              cmdList).copy()
    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: int,
                     lastSavePageValue: int,
                     autoSave=False) -> list:
    '''
    查看存档页面面板
    Keyword arguments:
    pageSaveValue -- 单页最大存档显示数量
    lastSavePageValue -- 最后一页存档显示数量
    autoSave -- 自动存档显示开关 (default False)
    '''
    savePanelPage = int(CacheContorl.panelState['SeeSaveListPanel']) + 1
    inputS = []
    idTextList = []
    idInfoText = TextLoading.getTextData(TextLoading.stageWordPath, '72')
    textWidth = int(GameConfig.text_width)
    saveNoneText = TextLoading.getTextData(TextLoading.messagePath, '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':
            saveInfoHead = SaveHandle.loadSaveInfoHead(saveId)
            gameTimeData = saveInfoHead['gameTime']
            gameTimeText = GameTime.getDateText(gameTimeData)
            characterName = saveInfoHead['characterName']
            saveVerson = saveInfoHead['gameVerson']
            saveText = characterName + ' ' + 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.stageWordPath, "73")
        i = pageSaveValue
        id = CmdButtonQueue.idIndex(i)
        EraPrint.plittleline()
        if SaveHandle.judgeSaveFileExist('auto') == '1':
            saveInfoHead = SaveHandle.loadSaveInfoHead('auto')
            gameTimeData = saveInfoHead['gameTime']
            gameTimeText = GameTime.getDateText(gameTimeData)
            characterName = saveInfoHead['characterName']
            saveVerson = saveInfoHead['gameVerson']
            saveText = characterName + ' ' + 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')
    return inputS