コード例 #1
0
ファイル: PyCmd.py プロジェクト: irrik/dieloli
def pcmd(cmd_str,
         cmd_id,
         cmd_func=FlowHandle.null_func,
         arg=(),
         kw={},
         normal_style='standard',
         on_style='onbutton'):
    '''
    打印一条指令
    Keyword arguments:
    cmd_str -- 命令对应文字
    cmd_id -- 命令数字
    cmd_func -- 命令函数
    arg -- 传给命令函数的顺序参数
    kw -- 传给命令函数的字典参数
    normal_style -- 正常状态下命令显示样式
    on_style -- 鼠标在其上的时候命令显示样式
    '''
    cmd_str = Dictionaries.handleText(cmd_str)
    cmd_id = Dictionaries.handleText(str(cmd_id))
    CacheContorl.textWait = float(GameConfig.text_wait)
    global last_char
    if len(cmd_str) > 0:
        last_char = cmd_str[-1:]
    FlowHandle.print_cmd(cmd_str, cmd_id, cmd_func, arg, kw, normal_style,
                         on_style)
コード例 #2
0
def pcmd(cmd_str, cmd_id, cmd_func=FlowHandle.null_func, arg=(), kw={}, normal_style='standard', on_style='onbutton'):
    cmd_str = Dictionaries.handleText(cmd_str)
    cmd_id = Dictionaries.handleText(str(cmd_id))
    CacheContorl.textWait = float(GameConfig.text_wait)
    global last_char
    if len(cmd_str) > 0:
        last_char = cmd_str[-1:]
    FlowHandle.print_cmd(cmd_str, cmd_id, cmd_func, arg, kw, normal_style, on_style)
コード例 #3
0
ファイル: EraPrint.py プロジェクト: homer12/dieloli
def p(string:str, style='standard',richTextJudge=True):
    '''
    游戏基础的文本绘制实现
    Keyword arguments:
    string -- 需要绘制的文本
    style -- 文本的默认样式 (default 'standard')
    richTextJudge -- 启用富文本的开关 (default True)
    '''
    if richTextJudge:
        barlist = list(TextLoading.getGameData(TextLoading.barConfigPath).keys())
        string = Dictionaries.handleText(string)
        styleList = RichText.setRichTextPrint(string, style)
        global last_char
        if len(string) > 0:
            last_char = string[-1:]
        string = RichText.removeRichCache(string)
        string = r'' + string
        for i in range(0,len(string)):
            if styleList[i] in barlist:
                styledata = TextLoading.getTextData(TextLoading.barConfigPath,styleList[i])
                truebar = styledata['truebar']
                nullbar = styledata['nullbar']
                if string[i] == '0':
                    pimage(nullbar, 'bar')
                elif string[i] == '1':
                    pimage(truebar, 'bar')
                else:
                    IoInit.eraPrint(string[i], styleList[i])
            else:
                IoInit.eraPrint(string[i], styleList[i])
    else:
        IoInit.eraPrint(string,style)
コード例 #4
0
def removeRichCache(string):
    string = str(string)
    string = Dictionaries.handleText(string)
    barlist = TextLoading.getTextData(TextLoading.barConfigPath, 'barlist')
    styleNameList = GameConfig.getFontDataList() + barlist
    for i in range(0, len(styleNameList)):
        styleTextHead = '<' + styleNameList[i] + '>'
        styleTextTail = '</' + styleNameList[i] + '>'
        if styleTextHead in string:
            string = string.replace(styleTextHead, '')
            string = string.replace(styleTextTail, '')
        else:
            pass
    return string
コード例 #5
0
def removeRichCache(string: str) -> str:
    '''
    移除文本中的富文本标签
    Keyword arguments:
    string -- 原始文本
    '''
    string = Dictionaries.handleText(string)
    barlist = list(TextLoading.getGameData(TextLoading.barConfigPath).keys())
    styleNameList = GameConfig.getFontDataList() + barlist
    for i in range(0, len(styleNameList)):
        styleTextHead = '<' + styleNameList[i] + '>'
        styleTextTail = '</' + styleNameList[i] + '>'
        if styleTextHead in string:
            string = string.replace(styleTextHead, '')
            string = string.replace(styleTextTail, '')
    return string
コード例 #6
0
ファイル: EraPrint.py プロジェクト: watry/dieloli
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)
コード例 #7
0
ファイル: EraPrint.py プロジェクト: watry/dieloli
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)
コード例 #8
0
ファイル: CmdButtonQueue.py プロジェクト: watry/dieloli
def optionstr(cmdList,
              cmdColumn=1,
              cmdSize='left',
              lastLine=False,
              askfor=True,
              cmdListData=None):
    if cmdListData == None:
        cmdListData = TextLoading.getTextData(TextLoading.cmdPath,
                                              cmdList).copy()
    else:
        pass
    inputS = []
    textWidth = GameConfig.text_width
    if lastLine == True:
        if len(cmdListData) - 1 < cmdColumn:
            cmdColumn = len(cmdListData) - 1
    else:
        if len(cmdListData) < cmdColumn:
            cmdColumn = len(cmdListData)
    cmdIndex = int(textWidth / cmdColumn)
    for i in range(0, len(cmdListData)):
        cmdTextBak = Dictionaries.handleText(cmdListData[i])
        cmdText = '[' + cmdTextBak + ']'
        if i == 0:
            cmdSizePrint(cmdText, cmdTextBak, None, cmdIndex, cmdSize)
            inputS.append(cmdListData[i])
        elif i / cmdColumn >= 1 and i % cmdColumn == 0:
            EraPrint.p('\n')
            cmdSizePrint(cmdText, cmdTextBak, None, cmdIndex, cmdSize)
            inputS.append(cmdTextBak)
        elif i == len(cmdListData) - 1 and lastLine == True:
            EraPrint.p('\n')
            cmdSizePrint(cmdText, cmdTextBak, None, cmdIndex, cmdSize)
            inputS.append(cmdTextBak)
        else:
            cmdSizePrint(cmdText, cmdTextBak, None, cmdIndex, cmdSize)
            inputS.append(cmdTextBak)
    EraPrint.p('\n')
    if askfor == True:
        ans = GameInit.askfor_All(inputS)
        return ans
    else:
        return inputS
コード例 #9
0
ファイル: EraPrint.py プロジェクト: qsjl11/dieloli
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)
コード例 #10
0
ファイル: EraPrint.py プロジェクト: qsjl11/dieloli
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)
コード例 #11
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
コード例 #12
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
コード例 #13
0
ファイル: CmdButtonQueue.py プロジェクト: irrik/dieloli
def optionstr(cmdList: str,
              cmdColumn=1,
              cmdSize='left',
              lastLine=False,
              askfor=True,
              cmdListData=None,
              nullCmd='',
              returnData=None) -> list:
    '''
    绘制无id的文本命令列表
    例:
    [长寿的青蛙]
    Keyword arguments:
    cmdList -- 命令列表id,当cmdListData为None时,根据此id调用cmdList内的命令数据
    cmdColumn -- 每行命令列数 (default 1)
    cmdSize -- 命令文本在当前列的对齐方式(left/center/right) (default 'left')
    lastLine -- 最后一个命令换行绘制 (default False)
    cmdListData -- 命令列表数据 (default None)
    nullCmd -- 在列表中按纯文本绘制,并不加入监听列表的命令文本
    returnData -- 命令返回数据 (default None)
    '''
    if cmdListData == None:
        cmdListData = TextLoading.getTextData(TextLoading.cmdPath,
                                              cmdList).copy()
    inputS = []
    textWidth = GameConfig.text_width
    if lastLine == True:
        if len(cmdListData) - 1 < cmdColumn:
            cmdColumn = len(cmdListData) - 1
    else:
        if len(cmdListData) < cmdColumn:
            cmdColumn = len(cmdListData)
    cmdIndex = int(textWidth / cmdColumn)
    nowNullCmd = nullCmd
    for i in range(0, len(cmdListData)):
        nowNullCmd = True
        if returnData == None:
            if nullCmd == cmdListData[i]:
                nowNullCmd = False
            cmdTextBak = Dictionaries.handleText(cmdListData[i])
            cmdText = '[' + cmdTextBak + ']'
        else:
            if nullCmd == returnData[i]:
                nowNullCmd = False
            cmdTextBak = returnData[i]
            cmdText = '[' + cmdListData[i] + ']'
        if i == 0:
            cmdSizePrint(cmdText,
                         cmdTextBak,
                         None,
                         cmdIndex,
                         cmdSize,
                         noNullCmd=nowNullCmd)
            if nowNullCmd:
                inputS.append(cmdListData[i])
        elif i / cmdColumn >= 1 and i % cmdColumn == 0:
            EraPrint.p('\n')
            cmdSizePrint(cmdText,
                         cmdTextBak,
                         None,
                         cmdIndex,
                         cmdSize,
                         noNullCmd=nowNullCmd)
            if nowNullCmd:
                inputS.append(cmdTextBak)
        elif i == len(cmdListData) - 1 and lastLine == True:
            EraPrint.p('\n')
            cmdSizePrint(cmdText,
                         cmdTextBak,
                         None,
                         cmdIndex,
                         cmdSize,
                         noNullCmd=nowNullCmd)
            if nowNullCmd:
                inputS.append(cmdTextBak)
        else:
            cmdSizePrint(cmdText,
                         cmdTextBak,
                         None,
                         cmdIndex,
                         cmdSize,
                         noNullCmd=nowNullCmd)
            if nowNullCmd:
                inputS.append(cmdTextBak)
    EraPrint.p('\n')
    if askfor == True:
        ans = GameInit.askfor_All(inputS)
        return ans
    else:
        return inputS