Remove some bad spacing, allow silencing sound when typing to screen, and mute the output from the hack screen

This commit is contained in:
Firepup Sixfifty 2024-04-27 17:01:54 -05:00
parent 8c75e3a0b2
commit 7ef74c2d0c
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
2 changed files with 12 additions and 12 deletions

View file

@ -28,17 +28,17 @@ _soundQueue = []
global _queueRunning global _queueRunning
_queueRunning = False _queueRunning = False
def slowWrite(window, text, pause = LETTER_PAUSE, fake_user = False): def slowWrite(window, text, pause = LETTER_PAUSE, fake_user = False, silent = False):
""" """
wrapper for curses.addstr() which writes the text slowly wrapper for curses.addstr() which writes the text slowly
""" """
if not fake_user: if not fake_user and not silent:
addSound("beep") addSound("beep")
for i in range(len(text)): for i in range(len(text)):
window.addstr(text[i]) window.addstr(text[i])
window.refresh() window.refresh()
curses.napms(pause) curses.napms(pause)
if fake_user: if fake_user and not silent:
_playSound("keyenter", True) _playSound("keyenter", True)
def upperInput(window, hidden = False, can_newline = True): def upperInput(window, hidden = False, can_newline = True):

View file

@ -43,7 +43,7 @@ def generateHex(n):
num += 12 num += 12
return list return list
def getSymbols(n): def getSymbols(n):
""" """
return n random symbols return n random symbols
@ -64,7 +64,7 @@ def getPasswords():
# script file / password file location # script file / password file location
__location__ = os.path.realpath(os.path.join(os.getcwd(), __location__ = os.path.realpath(os.path.join(os.getcwd(),
os.path.dirname(__file__))) os.path.dirname(__file__)))
# read from passwords.txt # read from passwords.txt
with open(os.path.join(__location__, "passwords.txt")) as pwfile: with open(os.path.join(__location__, "passwords.txt")) as pwfile:
for line in pwfile: for line in pwfile:
@ -87,7 +87,7 @@ def getFiller(length, passwords):
passwords - an array of passwords to hide in the symbols passwords - an array of passwords to hide in the symbols
""" """
filler = getSymbols(length) filler = getSymbols(length)
# add the passwords to the symbols # add the passwords to the symbols
pwdLen = len(passwords[0]) pwdLen = len(passwords[0])
pwdCount = len(passwords) pwdCount = len(passwords)
@ -99,12 +99,12 @@ def getFiller(length, passwords):
filler = filler[:i] + pwd + filler[i + pwdLen:] filler = filler[:i] + pwd + filler[i + pwdLen:]
i += pwdLen i += pwdLen
return filler return filler
def initScreen(scr): def initScreen(scr):
""" """
Fill the screen to prepare for password entry Fill the screen to prepare for password entry
scr - curses window returned from curses.initscr() scr - curses window returned from curses.initscr()
""" """
size = scr.getmaxyx() size = scr.getmaxyx()
@ -122,12 +122,12 @@ def initScreen(scr):
passwords = getPasswords() passwords = getPasswords()
filler = getFiller(fillerLength, passwords) filler = getFiller(fillerLength, passwords)
fillerCol1, fillerCol2 = filler[0:len(filler)//2], filler[len(filler)//2:] fillerCol1, fillerCol2 = filler[0:len(filler)//2], filler[len(filler)//2:]
#print(fillerCol1) #print(fillerCol1)
#time.sleep(15) #time.sleep(15)
#print(fillerCol2) #print(fillerCol2)
#time.sleep(15) #time.sleep(15)
# each column of symbols and passwords should be 1/4 of the screen # each column of symbols and passwords should be 1/4 of the screen
fillerWidth = int(width / 4) fillerWidth = int(width / 4)
@ -142,13 +142,13 @@ def initScreen(scr):
# print the hex and filler # print the hex and filler
for i in range(fillerHeight): for i in range(fillerHeight):
slowWrite(scr, "0x%X %s" % (hexCol1[i], fillerCol1[i * fillerWidth: (i + 1) * fillerWidth]), 1) slowWrite(scr, "0x%X %s" % (hexCol1[i], fillerCol1[i * fillerWidth: (i + 1) * fillerWidth]), 1, silent = True)
if i < fillerHeight - 1: if i < fillerHeight - 1:
scr.addstr('\n') scr.addstr('\n')
for i in range(fillerHeight): for i in range(fillerHeight):
scr.move(HEADER_LINES + i, int(CONST_CHARS / 2 + fillerWidth)) scr.move(HEADER_LINES + i, int(CONST_CHARS / 2 + fillerWidth))
slowWrite(scr, '0x%X %s' % (hexCol2[i], fillerCol2[i * fillerWidth: (i + 1) * fillerWidth]), 1) slowWrite(scr, '0x%X %s' % (hexCol2[i], fillerCol2[i * fillerWidth: (i + 1) * fillerWidth]), 1, silent = True)
scr.refresh() scr.refresh()