Example #1
0
def main_help():
	opt = ''
	while opt != 'q':
		opt = menu()
		clearconsole()
		if opt == '1':
			cnt = read(os.path.join('util', 'data', 'formats_tbl.txt')).split(';;;;')
		elif opt == '2':
			cnt = read(os.path.join('util', 'data', 'output.txt')).split(';;;;')
		elif opt == '3':
			cnt = read(os.path.join('util', 'data', 'options.txt')).split(';;;;')
		elif opt == '4':
			plugins_help()
			continue
		elif opt == '5':
			cnt = read(os.path.join('util', 'data', 'errors.txt')).split(';;;;')
		elif opt == '6':
			cnt = read(os.path.join('util', 'data', 'contrib.txt')).split(';;;;')
		elif opt == '7':
			cnt = read(os.path.join('util', 'data', 'dev.txt')).split(';;;;')
		else:
			continue
		for block in cnt:
			print(block)
			input('----')
		input('(Return to menu)')
Example #2
0
def plugins_help():
	plugins = []
	for el in os.scandir('plugins'):
		if el.is_dir():
			plugins.append(el.name)
	plugins.sort()
	helps = {}
	refs = {i: name for i, name in enumerate(plugins)}
	menu = ['%d-%s' % (i, name) for i, name in enumerate(plugins)]
	menu.append('%d-Return to menu' % len(plugins))
	for i, name in enumerate(plugins):
		mod = __import__('plugins.%s.help' % name)
		exec('helps[name] = mod.%s.help.make_help()' % name, globals(), locals())
	opt = -1
	menu = '\n'.join(menu)
	while opt != len(plugins):
		clearconsole()
		print(menu)
		opt = int(input('Your choice: '))
		clearconsole()
		if opt == len(plugins):
			break
		cnt = helps[refs[opt]].split(';;;;')
		for part in cnt:
			print(part)
			input('----')
		input('(return to menu)')
Example #3
0
def main(options):
    '''The plugin's entry point. Options are strings placed instead of the normal input name argument'''
    opt = menu().lower()
    clearconsole()
    if opt == 'q':
        quit()
    elif opt == '1':
        create_unpacker()
    elif opt == '2':
        create_packer()
    elif opt == '3':
        create_plugin()
    clearconsole()
Example #4
0
def textinput(prompt):
    print(prompt)
    print('Enter 2 blank lines to end writing')
    blanks = 0
    final = ''
    while blanks < 2:
        line = input('| ')
        if line == '':
            blanks += 1
        else:
            blanks = 0
        final += line + '\n'
    clearconsole()
    return final.rstrip()
Example #5
0
def setuplist():
    names = list(setups.keys())
    descs = [setups[name] for name in names]
    for i in range(0, len(names)):
        print('%d-%s: %s' % (i, names[i], descs[i]))
    print('')
    num = int(input('Your choice: '))
    clearconsole()
    name = names[num]
    code = readdata(name + '.s')
    c = Code(code)
    c.preprocess()
    c.assemble()
    bin = c.assembled[0]
    print(gensetup(bin))
Example #6
0
def menu():
	clearconsole()
	print('3DSkit detailed help')
	print('====================')
	print('')
	print('Select one of the following sections:')
	print('1-Informations on supported formats')
	print('2-Informations on output formats')
	print('3-Detailed help on program\'s options')
	print('4-Plugins help')
	print('5-Error codes list and troubleshooting')
	print('6-Guide to create new modules and plugins')
	print('7-Documentation on the 3DSkit\'s developper interface')
	print('    Enter Q to quit')
	print('')
	opt = input('Your choice: ').lower()
	return opt
Example #7
0
def create_plugin():
    name = input("Plugin's name: ")
    outpath = path('plugins', name, '')
    mkdir(outpath)
    mkdir(outpath + 'data')
    helpname = outpath + 'help.py'
    mainname = outpath + 'main.py'
    initname = outpath + '__init__.py'
    description = textinput('Enter the plugin description')
    howto = textinput('Enter the usage help')
    help_temp = readdata('help.py')
    help = help_temp.replace('{{NAME}}', name)
    help = help.replace('{{DESC}}', description)
    help = help.replace('{{HOWTO}}', howto)
    write(help, helpname)
    main_temp = readdata('main.py')
    write(main_temp, mainname)
    write('', initname)
    clearconsole()
Example #8
0
def main(options):
    '''The plugin's entry point. Options are strings placed instead of the normal input name argument'''
    lang = options[0]
    opt = None
    while opt != 'q':
        clearconsole()
        print('ASMto8F v%s' % version)
        print('1-Inventory assembler')
        print('2-Inventory disassembler')
        print('3-Setup generator')
        print('	Q-Quit')
        print('')
        opt = input('Your choice: ').lower()
        clearconsole()
        if opt == 'q':
            continue
        elif opt == '1':
            print('1-Write code to compile')
            print('2-Compile code from a file')
            print('3-Generate inventory from hexadecimal')
            print('4-Generate simulated AR code')
            print('')
            o = input('Your choice: ')
            clearconsole()
            if o == '1':
                print('Enter a blank line to end')
                print('')
                code = ''
                ln = None
                while ln != '':
                    ln = input('| ')
                    code += ln + '\n'
                c = Code(code)
                c.preprocess()
                c.assemble()
                bin = c.assembled[0]
                print(generate(bin, lang))
            elif o == '2':
                bsdir = os.getcwd()
                filename = input('File Name: ')
                dir = os.path.dirname(filename)
                filename = filename.replace(dir, '')
                if filename.startswith(os.path.sep):
                    filename.lstrip(os.path.sep)
                if dir != '':
                    os.chdir(dir)
                code = read(filename)
                c = Code(code)
                c.preprocess()
                c.assemble()
                bin = c.assembled[0]
                os.chdir(bsdir)
                print(generate(bin, lang))
            elif o == '3':
                print(
                    'Write code as hexadecimal. Enter a blank line to end. Whitespaces are ignored'
                )
                ln = None
                code = ''
                while ln != '':
                    ln = input('$ ')
                    code += ln
                code = code.replace(' ', '')
                bin = binascii.unhexlify(code).decode('ascii')
                print(generate(bin, lang))
            elif o == '4':
                print('Enter the AR (Gameshark) code you want to simulate')
                ar = input(': ')
                val = ar[2:4]
                addr = ar[6:8] + ar[4:6]
                code = readdata('ar.s') % (val, addr)
                c = Code(code)
                c.preprocess()
                c.assemble()
                bin = c.assembled[0]
                print(generate(bin, lang))
        elif opt == '2':
            print('1-Write inventory to disassemble')
            print('2-Disassemble inventory from file')
            print('3-Convert inventory to hexadecimal')
            print('4-Convert inventory to hexadecimal from file')
            print('')
            o = input('Your choice: ')
            clearconsole()
            if o == '1':
                print('Enter a blank line to end')
                print('Each line should be like that:')
                print('<item name> <item quantity>')
                print('')
                inv = ''
                ln = None
                while ln != '':
                    ln = input('| ')
                    inv += ln + '\n'
                code = disinventory(inv)
                c = Code.frombin(code)
                c.disassemble()
                print(c.code)
            elif o == '2':
                print('Each line should be like that:')
                print('<item name> <item quantity>')
                print('')
                filename = input('File name: ')
                inv = read(filename)
                code = disinventory(inv)
                c = Code.frombin(code)
                c.disassemble()
                print(c.code)
            elif o == '3':
                print('Enter a blank line to end')
                print('Each line should be like that:')
                print('<item name> <item quantity>')
                print('')
                inv = ''
                ln = None
                while ln != '':
                    ln = input('| ')
                    inv += ln + '\n'
                code = disinventory(inv)
                hx = binascii.hexlify(code).decode('ascii')
                l = split(hx, 2)
                print(' '.join(l))
            elif o == '4':
                filename = input('File name: ')
                inv = read(filename)
                code = disinventory(inv)
                hx = binascii.hexlify(code).decode('ascii')
                l = split(hx, 2)
                print(' '.join(l))
        elif opt == '3':
            print('1-Setups list')
            print('2-Write code to compile')
            print('3-Compile setup from file')
            print('')
            o = input('Your choice: ')
            clearconsole()
            if o == '1':
                setuplist()
            elif o == '2':
                print('Enter a blank line to end')
                print('')
                code = ''
                ln = None
                while ln != '':
                    ln = input('| ')
                    code += ln + '\n'
                c = Code(code)
                c.preprocess()
                c.assemble()
                bin = c.assembled[0]
                print(gensetup(bin, lang))
            elif o == '3':
                bsdir = os.getcwd()
                filename = input('File Name: ')
                dir = os.path.dirname(filename)
                filename = filename.replace(dir, '')
                if filename.startswith(os.path.sep):
                    filename.lstrip(os.path.sep)
                if dir != '':
                    os.chdir(dir)
                code = read(filename)
                c = Code(code)
                c.preprocess()
                c.assemble()
                bin = c.assembled[0]
                os.chdir(bsdir)
                print(gensetup(bin, lang))
        input('(return to menu)')