コード例 #1
0
ファイル: CmdButtonQueue.py プロジェクト: watry/dieloli
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
コード例 #2
0
ファイル: ChangeClothesPanel.py プロジェクト: homer12/dieloli
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
コード例 #3
0
ファイル: ChangeClothesPanel.py プロジェクト: homer12/dieloli
def seeCharacterWearClothes(characterId: str, changeButton: bool):
    '''
    查看角色穿戴服装列表面板
    Keyword arguments:
    characterId -- 角色id
    changeButton -- 将服装列表绘制成按钮的开关
    '''
    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)
        inputS.append(f'{i}')
        i += 1
        EraPrint.p('\n')
    return inputS
コード例 #4
0
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
コード例 #5
0
ファイル: CmdButtonQueue.py プロジェクト: irrik/dieloli
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
コード例 #6
0
ファイル: MainFrame.py プロジェクト: irrik/dieloli
# 垂直滚动条
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', {