コード例 #1
0
def choiceOrderWizard():
    # Prepare the orders
    orders = []

    # Print the welcome message
    print('\n[ Render Order Wizard ]')

    # Enter the add another loop
    addedAtLeastOne = False
    while (not addedAtLeastOne) or gu.askUserYesNo('Would you like to add another task', True):
        # Ask the user to choose the media type
        print('Select the type of media being added to the order.')
        targetTypeChoices = ['image', 'video']
        targetTypeIndex = int(gu.presentTextMenu(None, targetTypeChoices))

        # Collect and add manipulation specs
        orders.append(collectManipulationSpecs(targetTypeChoices[targetTypeIndex]))

        # Set added at least one
        addedAtLeastOne = True

        # Add a spacer
        print('')

    # Ask if the user wants to save the order
    if gu.askUserYesNo('Do you want to save the order to a file', True):
        # Convert the orders to a json
        ordersJson = json.dumps(orders)

        # Get the file name
        outputFileName = gu.managedInputForced('Enter the desired order file\'s name (without extension)')

        # Write the order's json file
        gu.writeFullFile(outputFileName+'.json', ordersJson)

    # Ask if the user wants to run the order
    if gu.askUserYesNo('Do you want to run the order now', True):
        # Process the order
        processOrder(orders)
コード例 #2
0
def settingsMenuOptions(choice):
    # Decide what action to take
    if choice == "0":
        # Change if packer closes on game start
        # Ask the user if the game should close
        shouldClose = gu.askUserYesNo(
            "Should the Brigador Mod Packer close when Brigador is started?",
            True)

        # Alter the settings in memory
        SETTINGS['Settings']['remainOpen'] = (not shouldClose)

        # Save the settings
        with open(SETTINGS_FILE, "w") as sFile:
            json.dump(SETTINGS, sFile)
コード例 #3
0
def main():
    # Indicate global
    global MERCER

    # Startup Mercer in specified mode
    mode = utils.askUserYesNo("Start in Debug Mode?", True)
    MERCER = mercerControl.MERCER(mode)

    # Welcome message
    print("\n<< Welcome to Mercer Main Control >>")

    # Enter menu functions
    options = ["Learning Menu", "Generation Menu", "Administration Menu"]
    utils.textMenu("Mercer Main Menu", options, "Save and Quit",
                   mainMenuFunctions)

    # Exit Mercer safely
    MERCER.exitMercer()

    # Safe to exit message
    print(
        "\nMercer has shutdown successfully.\nIt is now safe to close this window."
    )
コード例 #4
0
def collectManipulationSpecs(targetType):
    # Prepare the specs dictionary
    specs = {
        "type": targetType
    }

    # Get the filepath
    specs['path'] = gu.managedInputForced('Enter the filepath of the source '+targetType)

    # Get the output name
    specs['output'] = gu.managedInputForced('Enter the name for the output file (without extension)')

    # Ask if advanced options are needed
    specs['warp'] = ac.getDefaultWarp()
    specs['fontFile'] = FONT_FONT
    specs['fontSize'] = FONT_SIZE
    specs['fontColors'] = ac.getDefaultTextColors()
    specs['backgroundColor'] = ac.getDefaultBackgroundColor()
    if gu.askUserYesNo('Modify advanced options?', True):
        # Advanced options
        (specs['warp'], specs['fontSize'], specs['fontColors'], specs['backgroundColor']) = askForAdvancedSettings()

    return specs
コード例 #5
0
def adminMenuFunctions(answer):
    # Indicate global
    global MERCER

    # Because Python Switch statements don't exist
    if answer == "0":
        # Log dictionary process
        # Ask if user is sure
        print("This is a massive text dump that is often not human readable.")
        shouldContinue = utils.askUserYesNo(
            "Are you sure you want to continue?", True)

        # Check if should continue
        if shouldContinue:
            print(MERCER.logDictionary())
    elif answer == "1":
        # Show dictionary statistics process
        MERCER.getDictionaryStats()
    elif answer == "2":
        # Show toggle debug mode process
        # Ask for mode to switch
        mode = utils.askUserYesNo("Enable Debug Mode?", True)

        # Set the mode
        MERCER.setDebug(mode)

        # Choose print
        if mode:
            print("Debug Mode has been enabled.")
        else:
            print("Debug Mode has been disabled.")
    elif answer == "3":
        # Show set max generation attempts process
        # Enter number
        maxNum = utils.managedInputNumber("Set max generation attempts to",
                                          "Cancel")

        # Check
        minLimit = 1
        if maxNum != None and maxNum >= minLimit:
            # Set max generation attempts
            MERCER.setMaxGenerationAttempts(maxNum)

            # Report
            print("Set max generation attempts to " + str(maxNum) + ".")
        elif maxNum < minLimit:
            # Report
            print(
                str(minLimit) +
                " is minimum max generation attempts that can be set.")
    elif answer == "4":
        # Set max commonality difference process
        # Notes
        print(
            "Higher numbers will allow more words to be considered as options under most circumstances."
        )
        print("Max commonality difference is currently set to top " +
              str(MERCER.getMaxCommonalityDifference()) + "%.")

        # Get number
        amount = utils.managedInputNumberRange(
            "Set max commonality difference to", 100, 1, "Cancel")

        # Check
        if amount != None:
            # Set number
            MERCER.setMaxCommonalityDifference(amount)

            # Report
            print("Set max commonality difference to top " + str(amount) +
                  "%.")
コード例 #6
0
def generateModDetailsFile():
    # Mark globals
    global MODS_AVAILABLE
    global MOD_INFO_FILE
    global GLOBAL_FILE
    global MOD_INFO_FILE
    global ARCH_MECH
    global ARCH_MISSION
    global ARCH_OVERMAP
    global ARCH_PILOT
    global ARCH_WEAPON

    # Ask the user which mod to generate a details file for
    modChoice = gu.presentTextMenu(
        "What mod should the details file be generated for?", MODS_AVAILABLE)

    # Get the actual mod choice string
    modChoice = MODS_AVAILABLE[int(modChoice)]

    # Establish the mod's base directory
    modBaseDir = ("../" + modChoice)

    # Get the title of the mod from the user
    modTitle = gu.managedInputForced("Enter a title for the mod")

    # Create the base for the new mod details file
    detailsFileData = {}
    detailsFileData['title'] = modTitle
    detailsFileData['description'] = gu.managedInputForced(
        "Enter a short description for the mod")
    detailsFileData['author'] = gu.managedInputForced("Enter the mod's author")
    detailsFileData['version'] = gu.managedInputForced(
        "Enter the mod's current version (like v1.0.0)")
    detailsFileData['category'] = (modTitle.upper() + " | SNC Requisitions")
    detailsFileData['files'] = []

    # Loop through the files in the mod folder
    for dirpath, dirnames, filenames in os.walk(modBaseDir):
        # Loop through the files in the current directory
        for filename in filenames:
            # Make sure it's a valid json
            if filename != GLOBAL_FILE and filename != MOD_INFO_FILE and os.fsdecode(
                    filename).endswith(".json"):
                # Create a file data dict
                fileData = {}

                # Formulate the local file path
                path = (dirpath + "/" + filename).replace("\\", "/").replace(
                    "//", "/")
                print(path)

                # Add the standardized game time file path
                fileData['path'] = pathToStandard(path)

                # Check what type of archetype the json file is
                with open(path, "r", encoding="latin-1") as jsonFile:
                    # Get the archetype of the file
                    fileArchetype = getFileArchetype(json.load(jsonFile))

                    # Decide if the file should be marked as player usable
                    playerUsableList = [ARCH_MECH, ARCH_PILOT, ARCH_WEAPON]
                    if fileArchetype in playerUsableList:
                        # Mark as player usable
                        fileData['forPlayer'] = True
                    else:
                        # Mark as not player usable
                        fileData['forPlayer'] = False

                # Add the new file data to the details
                detailsFileData['files'].append(fileData)

    # Check if a details file already exists
    canContinue = True
    if os.path.exists(modBaseDir + "/" + MOD_INFO_FILE):
        # Ask the user if an overwrite is ok
        canContinue = gu.askUserYesNo(
            "A " + MOD_INFO_FILE +
            " file already exists. Would you like to overwrite it?", True)

    # Check if this can continue
    if canContinue:
        # Create a new mod details file
        with open((modBaseDir + "/" + MOD_INFO_FILE), "w+") as detailsFile:
            # Dump the details string to the file
            json.dump(detailsFileData, detailsFile)

        # Report the process
        print("\nCreated a " + MOD_INFO_FILE + " file for " + modChoice + ".")
    else:
        # Report the cancel
        print("\nCanceled the " + MOD_INFO_FILE + " file generation.")