main.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import sys, file_ops
  2. from riiv import get_riiv_patches_inf
  3. from riiv import apply_riiv_patches_wrapper
  4. # remove if they are there:
  5. file_ops.rm_folder("tmp")
  6. file_ops.rm_file("tmp_wit.xml")
  7. file_ops.rm_file("tmp_gl.txt")
  8. file_ops.rm_file("result.wbfs")
  9. sections = get_riiv_patches_inf(sys.argv[1], sys.argv[2], sys.argv[3])
  10. if (sections == None):
  11. print("Riivolution XML is faulty")
  12. exit(1)
  13. print()
  14. # possible choices
  15. pos_choices = []
  16. for sec in sections:
  17. print("Section name: %s" % (sec.name))
  18. print("#-Options names:")
  19. for opt in sec.options:
  20. print("----%s" % (opt.name))
  21. print("##----Choices names:")
  22. for cho in opt.choices:
  23. print("--------%s" % (cho.name))
  24. pos_choices.append(cho.name)
  25. print("###-------Patches ids:")
  26. for pat in cho.patches:
  27. print("------------%s" % (pat.id))
  28. print()
  29. print("Please, select the \"Choices\" to apply to the game.")
  30. print("Example: " + sections[0].options[0].choices[0].name + " ...")
  31. input_choices = input("Enter: ")
  32. input_choices = input_choices.split()
  33. for cho in input_choices:
  34. if (cho not in pos_choices):
  35. print("\nInvalid choice: " + cho)
  36. exit(1)
  37. print("\nSelected choices: ", end = "")
  38. print(input_choices)
  39. result = apply_riiv_patches_wrapper(sys.argv[1], sys.argv[2], sys.argv[3], input_choices)
  40. if (result):
  41. print("Done!")
  42. else:
  43. print("Errors happened...")
  44. exit(1)
  45. exit(0)