Skip to content

Commit 90c916f

Browse files
committed
made an enum for the haxState variable
see: #16 (sorry @dg4l)
1 parent 25ff9e2 commit 90c916f

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

MSET9_installer_script/mset9.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,21 @@ def writeProtectCheck():
222222

223223
ID0, ID0Count, ID1, ID1Count = "", 0, "", 0
224224

225-
haxStates = {
226-
0: "\033[30;1mID1 not created\033[0m",
227-
1: "\033[33;1mNot ready - check MSET9 status for more details\033[0m",
228-
2: "\033[32mReady\033[0m",
225+
class haxStates:
226+
ID1_NOT_PRESENT = 0
227+
NOT_READY = 1
228+
READY_TO_INJECT = 2
229+
TRIGGER_FILE_REMOVED = 3
230+
231+
haxStateLabel = {
232+
haxStates.ID1_NOT_PRESENT: "\033[30;1mID1 not created\033[0m",
233+
haxStates.NOT_READY: "\033[33;1mNot ready - check MSET9 status for more details\033[0m",
234+
haxStates.READY_TO_INJECT: "\033[32mReady\033[0m",
229235
# "\033[32;1mInjected\033[0m", # you must go
230-
3: "\033[32mRemoved trigger file\033[0m"
236+
haxStates.TRIGGER_FILE_REMOVED: "\033[32mRemoved trigger file\033[0m"
231237
}
232-
haxState = 0
238+
239+
haxState = haxStates.ID1_NOT_PRESENT
233240

234241
realID1Path = ""
235242
realID1BackupTag = "_user-id1"
@@ -453,7 +460,7 @@ def remove():
453460
ID1 = ID1[:32]
454461
realID1Path = ID0 + "/" + ID1
455462

456-
haxState = 0
463+
haxState = haxStates.ID1_NOT_PRESENT
457464
prgood("Successfully removed MSET9!")
458465

459466
def softcheck(keyfile, expectedSize = None, crc32 = None, silent = False):
@@ -569,30 +576,30 @@ def is3DSID(name):
569576

570577
if os.path.exists(triggerFilePath):
571578
os.remove(triggerFilePath)
572-
haxState = 3 # Removed
579+
haxState = haxStates.TRIGGER_FILE_REMOVED
573580
elif sanityOK:
574-
haxState = 2 # Ready!
581+
haxState = haxStates.READY_TO_INJECT
575582
else:
576-
haxState = 1 # Not ready...
583+
haxState = haxStates.NOT_READY
577584

578585
if ID1Count != 1:
579586
prbad(f"Error 05: You don't have 1 ID1 in your Nintendo 3DS folder, you have {ID1Count}!")
580587
prinfo("Consult: https://3ds.hacks.guide/troubleshooting-mset9.html for help!")
581588
exitOnEnter()
582589

583-
if haxState != 0 and not realID1Path.endswith(realID1BackupTag): # ?
590+
if haxState != haxStates.ID1_NOT_PRESENT and not realID1Path.endswith(realID1BackupTag): # ?
584591
os.rename(abs(realID1Path), abs(realID1Path + realID1BackupTag))
585592

586593
clearScreen()
587594
print(f"MSET9 {VERSION} SETUP by zoogie, Aven, DannyAAM and thepikachugamer")
588595
print()
589-
print(f"Current MSET9 state: {haxStates[haxState]}")
596+
print(f"Current MSET9 state: {haxStateLabel[haxState]}")
590597

591598
print("\n-- Please type in a number then hit return --\n")
592599

593600
print("↓ Input one of these numbers!")
594601

595-
if haxState == 0:
602+
if haxState == haxStates.ID1_NOT_PRESENT:
596603
print("1. Create MSET9 ID1")
597604
else:
598605
print(f"1. Change console version (Current: {consoleNames[consoleIndex]})")
@@ -614,21 +621,21 @@ def is3DSID(name):
614621
exitOnEnter()
615622

616623
elif optSelect == 2: # Check status
617-
if haxState == 0: # MSET9 ID1 not present
624+
if haxState == haxStates.ID1_NOT_PRESENT:
618625
prbad("Can't do that now!")
619626
continue
620627
sanityReport()
621628
exitOnEnter()
622629

623630
elif optSelect == 3: # Inject trigger file
624-
if haxState != 2: # Ready to inject
631+
if haxState != haxStates.READY_TO_INJECT:
625632
prbad("Can't do that now!")
626633
continue
627634
injection()
628635
exitOnEnter()
629636

630637
elif optSelect == 4: # Remove MSET9
631-
if haxState == 0:
638+
if haxState == haxStates.ID1_NOT_PRESENT:
632639
prinfo("Nothing to do.")
633640
continue
634641

0 commit comments

Comments
 (0)