Esempio n. 1
0
def DeleteChoice(node: ChoiceNode):
    if len(node.outcomes) < 1:
        return

    choices = node.getOutcomesAsObjects()

    altDeleteChoice = CreateNewPrompt(edit.DeleteChoice)
    EditPrompt(altDeleteChoice, 0, 'choices', choices)

    values: dict = prompt(altDeleteChoice)

    node.deleteOutcome(values['Index'], OnDelete(values['OnDelete']))
Esempio n. 2
0
def EditChoice(node: ChoiceNode):
    if len(node.outcomes) < 1:
        return

    choices = node.getOutcomesAsObjects()

    altEditChoice = CreateNewPrompt(edit.EditChoice)
    EditPrompt(altEditChoice, 0, 'choices', choices)

    values: dict = prompt(altEditChoice)

    node.editOutcome(values['Index'], values['Value'])
Esempio n. 3
0
def InitEditor():
    editManager: EditManager = None

    newOrEdit = prompt(edit.NewOrEditChoice)

    # Create new
    if newOrEdit['NewOrEditChoice'] == '1':
        newStory = prompt(edit.CreateStory)
        editManager = EditManager(newStory['Name'], newStory['Path'],
                                  newStory['Description'],
                                  ChoiceNode(None, newStory['FirstNarration']))
    # Edit existing
    else:
        while True:
            result = prompt(utils.SelectFile)
            if os.path.exists(result['Value']) and \
               os.path.isfile(result['Value']):
                break
            else:
                print('Error: Invalid path provided.',
                      ' Needs to be a valid file')

        editManager = LoadEditManager(result['Value'])
        if editManager is None:
            print(f'Error: could not load story file {result["Value"]}')
            return None

        editManager.currentNode = editManager.startNode

    return editManager
Esempio n. 4
0
def multipleChoiceNode():
    node: ChoiceNode = ChoiceNode('One')
    node.addOutcome('Two')
    node.addOutcome('Three')
    node.outcomes[0].addOutcome('Four')
    node.outcomes[0].addOutcome('Five')
    node.outcomes[1].addOutcome('Six')
    node.outcomes[1].addOutcome('Seven')
    return node
Esempio n. 5
0
def EditNarration(node: ChoiceNode):
    altEditNarration = CreateNewPrompt(edit.EditNarration)
    EditPrompt(altEditNarration, 0, 'default', node.narration)

    userInput = prompt(altEditNarration)
    value = userInput['Value']

    if len(value) > 0:
        node.narration = value
    else:
        print('Error: cannot set narration to an empty value.\n')
Esempio n. 6
0
def test_seralization():
    node = ChoiceNode('Text')
    src: EditManager = EditManager('TestName', './', 'Desc', node)
    path = src.storyPath + '/' + src.storyName + '.test.his'

    SerializeEditManager(src, path)

    dst: EditManager = LoadEditManager(path)

    assert src.storyName == dst.storyName
    assert src.storyPath == dst.storyPath
    assert src.storyDesc == dst.storyDesc
    assert src.startNode.choiceText == dst.startNode.choiceText
    assert len(src.startNode.outcomes) == len(dst.startNode.outcomes)

    os.remove(path)
Esempio n. 7
0
def emptyManager():
    node: ChoiceNode = ChoiceNode('Text')
    manager: EditManager = EditManager('Name', './', 'Desc', node)
    return manager
Esempio n. 8
0
def AddChoice(node: ChoiceNode):
    choiceText: dict = prompt(edit.AddChoice)

    node.addOutcome(choiceText['Value'])
Esempio n. 9
0
def ConfirmNode(node: ChoiceNode):
    if node.outcomes is None or len(node.outcomes) < 1:
        value: dict = prompt(edit.AddDefaultChoice)

        if value['Value'] == 0:
            node.addOutcome('Continue...')
Esempio n. 10
0
def testNode():
    node: ChoiceNode = ChoiceNode(testName, testNarration)
    return node
Esempio n. 11
0
def emptyNode():
    node: ChoiceNode = ChoiceNode(testName)
    return node