Compare commits

...

10 commits

Author SHA1 Message Date
e1ca6ce440
Unused file 2024-04-27 16:02:02 -05:00
b03027218c
Test file 2024-04-27 16:01:09 -05:00
e2b99a0270
Lots of changes, almost exactly how I want it now 2024-04-27 16:00:01 -05:00
Josh d'Entremont
d502fd3ee5 removed debug login and fixed width of columns for different sized consoles 2021-05-20 12:29:00 -03:00
joshdentremont
6fcb867b99
Merge pull request #4 from unown294/patch-1
Updated Fallout.py
2021-05-20 11:27:09 -03:00
Dalton
4443de3257
Add files via upload 2021-05-19 13:47:24 -05:00
Dalton
efddc5dab1
Update fallout_functions.py
These are the changes on remove xrange and replacing with range()
2021-05-19 13:45:06 -05:00
Dalton
c00cbf61d3
Add files via upload 2021-05-19 13:42:44 -05:00
Dalton
daa930fce0
Updated Fallout.py
As per the new version of Python these changes were required to comply with the syntax changes
2021-05-19 07:49:57 -05:00
Josh d'Entremont
1c1215325f added selection script 2015-06-14 19:31:01 -03:00
16 changed files with 451 additions and 58 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
*.pyc
original**
test**
__pycache__**

View file

@ -3,8 +3,6 @@ Fallout Terminal
Simulates a computer terminal from fallout.
Currently only implements the login portion.
Usage
================
@ -13,21 +11,12 @@ python fallout.py
```
or for hard mode where the user must manually enter the correct input in the
boot script,
boot and login scripts
```
python fallout.py hard
```
To only use the login in another program:
```
import fallout_login
# returns true if the correct password is entered, false otherwise
fallout_login.beginLogin()
```
Passwords
================

BIN
audio/beep.wav Normal file

Binary file not shown.

BIN
audio/correctpass.wav Normal file

Binary file not shown.

BIN
audio/keyenter.wav Normal file

Binary file not shown.

BIN
audio/poweroff.wav Normal file

Binary file not shown.

BIN
audio/poweron.wav Normal file

Binary file not shown.

BIN
audio/wrongpass.wav Normal file

Binary file not shown.

View file

@ -3,18 +3,80 @@ import fallout_login as login
import fallout_boot as boot
import fallout_locked as locked
import fallout_hack as hack
import fallout_selection as select
import fallout_data as data
from fallout_functions import soundTest, isQueueEmpty, addSound
from time import sleep
import sys
hard = False
if len(sys.argv) == 2 and sys.argv[1].lower() == 'hard':
if '--hard' in sys.argv:
hard = True
if boot.beginBoot(hard):
pwd = hack.beginLogin()
if pwd != None:
login.beginLogin(hard, 'ADMIN', pwd)
print 'Login successful'
else:
locked.beginLocked()
print 'Login failed'
skip = False
if '--skip' in sys.argv:
skip = True
if '--skip-preload' not in sys.argv:
soundTest()
try:
addSound("poweron")
while not isQueueEmpty():
sleep(0.2)
if skip or boot.beginBoot(hard):
while not isQueueEmpty():
sleep(0.2)
pwd = None
if not skip:
pwd = hack.beginLogin()
else:
pwd = "VERYVERYSECUREPASSWORD"
if pwd != None:
login.beginLogin(hard, 'ADMIN', pwd)
while not isQueueEmpty():
sleep(0.2)
sel = 0
while sel != 3:
sel = select.beginSelection(data.ROBCO_HEADERS, data.SOFT_HEADERS, data.MAIN_MENU)
while not isQueueEmpty():
sleep(0.2)
if sel == 0:
loc = 0
while loc != 1:
MENU = [data.LOCK_MENU[tog][data.LOCK_CONDS[tog]] for tog in data.LOCK_CONDS.keys()]
MSGS = [data.LOCK_MSGS[tog][data.LOCK_CONDS[tog]] for tog in data.LOCK_CONDS.keys()]
loc = select.beginSelection(data.ROBCO_HEADERS, data.SOFT_HEADERS, MENU, MSGS)
if loc == 0:
if data.LOCK_CONDS['LOCKED']:
data.LOCK_CONDS['LOCKED'] = 0
else:
data.LOCK_CONDS['LOCKED'] = 1
elif sel == 1:
tur = 0
while tur != 2:
MENU = [data.TURRET_MENU[tog][data.TURRET_CONDS[tog]] for tog in data.TURRET_CONDS.keys()]
MSGS = [data.TURRET_MSGS[tog][data.TURRET_CONDS[tog]] for tog in data.TURRET_CONDS.keys()]
tur = select.beginSelection(data.TURRET_HEADERS, data.TURRET_HEADERS2, MENU, MSGS)
if tur == 0:
data.TURRET_CONDS['TARGETING'] = 1
elif tur == 1:
if data.TURRET_CONDS['ENABLED']:
data.TURRET_CONDS['ENABLED'] = 0
else:
data.TURRET_CONDS['ENABLED'] = 1
elif sel == 2:
log = 0
while log != data.LOG_RET_ID:
log = select.beginSelection(data.ROBCO_HEADERS, data.SOFT_HEADERS, data.LOG_NAMES)
if log != data.LOG_RET_ID:
select.beginSelection(data.ROBCO_HEADERS, data.LOGS[data.LOG_NAMES[log]].split("\n"), ["Return"])
else:
locked.beginLocked()
print('Login failed')
except KeyboardInterrupt:
pass
addSound("poweroff")
while not isQueueEmpty():
sleep(0.2)

View file

@ -58,7 +58,7 @@ def runBoot(scr, hardMode):
# input is entered for them
slowWrite(scr, '>')
curses.napms(INPUT_PAUSE)
slowWrite(scr, ENTRY_1 + '\n', TYPE_DELAY)
slowWrite(scr, ENTRY_1 + '\n', TYPE_DELAY, True)
slowWrite(scr, '\n' + MESSAGE_2 + '\n\n')
@ -73,10 +73,10 @@ def runBoot(scr, hardMode):
else:
slowWrite(scr, '>')
curses.napms(INPUT_PAUSE)
slowWrite(scr, ENTRY_2 + '\n', TYPE_DELAY)
slowWrite(scr, ENTRY_2 + '\n', TYPE_DELAY, True)
slowWrite(scr, '>')
curses.napms(INPUT_PAUSE)
slowWrite(scr, ENTRY_3 + '\n', TYPE_DELAY)
slowWrite(scr, ENTRY_3 + '\n', TYPE_DELAY, True)
slowWrite(scr, '\n' + MESSAGE_3 + '\n\n')
@ -88,7 +88,7 @@ def runBoot(scr, hardMode):
else:
slowWrite(scr, '>')
curses.napms(INPUT_PAUSE)
slowWrite(scr, ENTRY_4 + '\n', TYPE_DELAY)
slowWrite(scr, ENTRY_4 + '\n', TYPE_DELAY, True)
curses.napms(INPUT_PAUSE)
return True

147
fallout_data.py Normal file
View file

@ -0,0 +1,147 @@
####################### text strings ########################
ROBCO_HEADERS = (
'ROBCO INDUSTRIES UNIFIED OPERATING SYSTEM',
'COPYRIGHT 2075-2077 ROBCO INDUSTRIES',
'-SERVER 6-',
''
)
TURRET_HEADERS = (
'-RobCo Trespasser Management System-',
'====================================',
''
)
TURRET_HEADERS2 = (
'RobcOS v.85',
'(C)2076 RobCo',
'========================',
'| User Log:',
'| >> Administrator (RobCoID 2398-H)',
'| >> New_Admin: FIRE PUP',
'| Welcome new user, FIRE PUP',
'| >> New_Targeting_Param:',
'| >>> FIRE PUP_userGroup',
''
)
SOFT_HEADERS = (
'\tSoftLock Solutions, Inc',
'"Your Security is Our Security"',
'>\\ Welcome, USER',
''
)
MAIN_MENU = (
'Lock Control',
'Turret Control',
'Read Log',
'Logoff Terminal'
)
LOCK_MENU = {
'LOCKED': ["Disengage Lock", "Engage Lock"],
'RETURN': ["Return"]
}
TURRET_MENU = {
'TARGETING': ["Re-configure Targeting Parameters", "<!>WARNING: No Targeting Data<!>"],
'ENABLED': ["Deactivate Turret System", "Activate Turret System"],
'RETURN': ["Return"]
}
TURRET_MSGS = {
'TARGETING': ['Target Data Cleared. Exercise Caution.', '<!>Please Exercise Caution<!>'],
'ENABLED': ['Powering Down...', 'Booting...'],
'RETURN': ['']
}
LOCK_MSGS = {
'LOCKED': ['Clearance granted, Unlocking...', 'Clearance granted, Locking...'],
'RETURN': ['']
}
TURRET_CONDS = {
'TARGETING': 0,
'ENABLED': 0,
'RETURN': 0
}
LOCK_CONDS = {
'LOCKED': 0,
'RETURN': 0
}
LOGS = {
'Megaton - Afterword': """USER: MOIRA BROWN
PASS: ***********
Date: 09.10.2297
Welcome, MOIRA. It is another lovely day for science!
DAILY LOG:
Experiment Reports:
Irradiated AgricultureGood response from mutfruit, strangely aggressive response to baseline sample. Purified water very helpful.
Deathclaw CommunicationNo language that I can discern, unless "Mutilating assistants" counts. What would they have to say, anyway?
Jefferson Purifier - Guards still refuse to allow access to see how the Purifier works. They say it's to prevent sabotage, but I think they aren't entirely certain.
Personal Note:
Just shipped out another crate of survival guides, and the caravans just can't seem to get enough of them. Sheriff Simms says they've really put Megaton on the mappretty ironic, since I've had to redraw that map about a million times since the first edition came out 20 years ago. At least all the attention means there's no shortage of assistants, but I'm never getting another assistant like the Lone Wanderer who stumbled into my shop so long ago.
Just about everyone in the Capital Wasteland has a story about the Lone Wanderer, even though precious few ever really knew him. But that doesn't stop them from telling crazy tall tales about how he saved their lives, or blew up a mountain, or ate a car or something. Heck, if you get Simms drunk, he'll tell you that his dad died because of the Wanderer, even though he saved the town. People can't even agree on whether the Wanderer was a man or a woman, much less a saint or a monster. But they all agree on one thing: the Lone Wanderer changed the Capital Wasteland.
Of course, that's why I'm working on the new book, compiling the best and most useful tales of the Lone Wanderer for the next generation. It's not easy sorting out all the conflicting stories, but that'll be half of the fun for the readers. More importantly, between all of those crazy stories of bravery, barbarity, and everything in-between, we can all find a reason to keep on fighting our war for survival.
I guess some things never change, huh?""",
'ERR - Ikkm00:Mvkz6x1ml:Nqtm': "[ERROR HX40-399: invalid decry.key]",
'Nuka Cola - Quantum Progress Report 0041': """Isotope CE770 has proven to be a disastrous failure. All of the test subjects suffered severe internal organ failures and died within three days of ingestion. We recommend the immediate destruction of container A32 in the production rooms and suggest switching to isotope CE772. Please send standard "Nuka Condolences" Fruit and Cheese Packages to test group member's families.""",
'Nuka Cola - Quantum Progress Report 0055': "Isotope CE772 has proven too damaging to the initial test group which now needs to be disbanded due to their reluctance to continue in our program. This group has suffered 4 fatalities, 12 major internal organ failures and 32 internal radiation burns. This is an unacceptable number of issues in a given test group and recommend we switch to an alternate isotope (such as CE774 or UR993).",
'Nuka Cola - Quantum Progress Report 0067': "Test subjects in the Nuka-Cola Quantum program are responding well to the reconfigured taste and the new isotope. The only listed side effects from the group are: 3 cases of dizziness, 1 case of nausea and 1 case of impaired vision. We find from a sampling of 50 that this is an acceptable number of cases and approve this product for production.",
'Nuka Cola - Company Announcement': "The Nuka-Cola Corporation is pleased to announce to all it's employees that the first shipments of our Nuka-Cola Quantum® are on their way to retailers in the Washington D.C. area! This flagship test market program is the culmination of a three year research program to bring the refreshing taste of Quantum to market. Congratulations to all employees on a job well done!",
'Nuka Cola - New Flavor Coming!': """Attention all Nuka-Cola Corporation Employees
We are very proud to announce that R&D has been completed on Nuka-Cola Clear! With an only minimal loss of life, we've been able to modify the look of Nuka-Cola but give it the same great taste. We will be submitting the product to Marketing shortly for bottle design and advertising strategies. From all of us in the Research Department, thanks for the support!""",
'Nuka Cola - From: Marketing': """The following locations have been accepted into the flagship Nuka-Cola Quantum test program. Please ensure that 1 (one) crate of Quantum is included with their regular deliveries along with the advertising package provided by our Marketing Department.
1. Paradise Falls Shopping Mart
2. Super Duper Mart
3. Old Olney Grocery""",
'Nuka Cola - Packing Line Instructions': """Welcome to the Nuka-Cola Packing Line Operator's Station! You are now instrumental in getting Nuka-Cola from our factory and to the public, so please read the simple instructions below. If you need assistance, please call x347 and ask for your Line Supervisor.
1. Access the Packing Terminal and choose desired inventory to load into Sorting Units.
2. Select "Activate Packing Line."
3. Monitor the Packing Line by listening for things such as mechanical screeching, explosions and/or human cries for help.
4. If there is an emergency, DO NOT PANIC! Simply call x347 and ask for your Line Supervisor. The Packing Line will automatically shut down in the event of an issue.
Remember, only you can prevent inventory loss by being attentive and vigilant!""",
'Nuka Cola - Packing Line Notice': """Attention all Packing Line employees!
Due to an oversight by the design department, the new Nuka-Cola Quantum bottles are slightly heavier than the standard Nuka-Cola bottles. As a result, the Packing Line is prone to jams and may cause damage to the equipment. Please DO NOT load Nuka-Cola Quantum bottles into the Sorting Units until further notice. All test samples of Quantum will be packaged by hand until a solution is reached.""",
'Nuka Cola - Stage One': """Stage One of the Nuka-Cola Quantum marketing will include: 2 (two) 15 (fifteen)-second television commercials, 4 (four) 10 (ten)-second radio commercials and a highway billboard campaign.
The spots on TV and radio will tease the consumer with the blue glow of the new drink, never showing the bottle in an illuminated environment. The billboard will show the bottle's blue silhouette on a black background.
The tag line will be "Try something new... Go Blue!". The name will not be revealed until Stage Two.""",
'Nuka Cola - Stage Two': """Stage Two of the Nuka-Cola Quantum marketing will include: 2 (two) 30 (thirty)-second television commercials, 4 (four) 15 (fifteen)-second radio commercials and a highway billboard campaign.
In this stage, the name "Quantum" will be revealed and the bottle shown in full view. We will emphasize the drink's new energy content and flavor.
The tag line will be "Take the leap... enjoy a Quantum!" """,
'Nuka Cola - Stage Three': """Stage Three of the Nuka-Cola Quantum marketing will include: 4 (four) 30 (thirty)-second television commercials, 4 (four) 15 (fifteen)-second radio commercials and a highway billboard campaign.
In this final stage we will aggressively compare the drink to other competitors and show their inferiority using hired actors at "taste tests". The actors will read pre-written scripts approved by our department. The text should give an authentic "on the spot" impression but still clearly point out Quantum's strengths.
The tag line will remain: "Take the leap... enjoy a Quantum!" """,
}
LOG_NAMES = list(LOGS.keys())
LOG_NAMES.extend(["Return"])
LOG_RET_ID = len(LOG_NAMES) - 1

View file

@ -1,27 +1,45 @@
import curses
import time
import sys
from pathlib import Path as _Path
from playsound import playsound as _play
from threading import Thread
from time import sleep
LETTER_PAUSE = 5
INPUT_PAUSE = 500 # ms
TYPE_DELAY = 30
TYPE_DELAY = 40
HIDDEN_MASK = '*'
NEWLINE = 10
DELETE = 127
DELETE = 330
def slowWrite(window, text, pause = LETTER_PAUSE):
BACKSPACE = 263
_playing = False
_soundQueue = []
global _queueRunning
_queueRunning = False
def slowWrite(window, text, pause = LETTER_PAUSE, fake_user = False):
"""
wrapper for curses.addstr() which writes the text slowely
"""
for i in xrange(len(text)):
if not fake_user:
addSound("beep")
for i in range(len(text)):
window.addstr(text[i])
window.refresh()
curses.napms(pause)
if fake_user:
_playSound("keyenter", True)
def upperInput(window, hidden = False, can_newline = True):
"""
@ -39,8 +57,9 @@ def upperInput(window, hidden = False, can_newline = True):
if inchar > 96 and inchar < 123:
inchar -= 32
# deal with backspace
if inchar == DELETE:
if inchar in [DELETE, BACKSPACE]:
if len(instr) > 0:
#addSound("keyenter")
instr = instr[:-1]
cur = window.getyx()
window.move(cur[0], cur[1] - 1)
@ -51,11 +70,91 @@ def upperInput(window, hidden = False, can_newline = True):
continue
# output the character
elif inchar != NEWLINE:
#addSound("keyenter")
instr += chr(inchar)
if hidden:
window.addch(HIDDEN_MASK)
else:
window.addch(inchar)
elif can_newline:
#addSound("keyenter")
window.addch(NEWLINE)
return instr
def centeredWrite(window, text, pause = LETTER_PAUSE):
"""
Writes to the current line but centers the text
"""
width = window.getmaxyx()[1]
window.move(window.getyx()[0], int(width / 2 - len(text) / 2))
slowWrite(window, text, pause)
def _soundCheck():
"""
Internal use - Checks if the user explicity disabled sound or not
"""
return '--no-sound' not in sys.argv
def _playSound(file, block = False):
"""
Internal use - plays a specific sound from the current directory
"""
if _soundCheck():
_play(str(_Path.cwd() / f'audio/{file}.wav'), block)
def _playQueue():
"""
Internal use - play sounds from a queue
"""
global _queueRunning
global _soundQueue
if _queueRunning:
return
_queueRunning = True
while 1:
if len(_soundQueue) > 0:
_playSound(_soundQueue[0], True)
_soundQueue.pop(0)
else:
sleep(0.02)
def isQueueEmpty():
"""
Check if the sound queue is empty
"""
return len(_soundQueue) == 0
def soundTest():
addSound("beep")
addSound("beep")
addSound("keyenter")
addSound("keyenter")
addSound("wrongpass")
addSound("wrongpass")
addSound("correctpass")
addSound("correctpass")
addSound("poweron")
addSound("poweron")
addSound("poweroff")
addSound("poweroff")
global _soundQueue
while not isQueueEmpty():
sleep(0.2)
def addSound(file):
"""
Add sounds to the queue
"""
global _soundQueue
_soundQueue.extend([file])
_queueMgr = Thread(target=_playQueue)
_queueMgr.daemon = True
_queueMgr.start()

View file

@ -1,8 +1,8 @@
import curses
import random
import time
import os
from fallout_functions import slowWrite
from fallout_functions import upperInput
from fallout_functions import slowWrite, upperInput, addSound
################## text strings ######################
@ -22,7 +22,7 @@ LOGIN_ATTEMPTS = 4
HEADER_LINES = 5
# amount of time to pause after correct password input
LOGIN_PAUSE = 3000
LOGIN_PAUSE = 3
# starting number for hex generation
START_HEX = 0xf650
@ -38,7 +38,7 @@ def generateHex(n):
"""
num = START_HEX
list = []
for i in xrange(n):
for i in range(n):
list.append(num)
num += 12
return list
@ -50,7 +50,7 @@ def getSymbols(n):
"""
count = len(SYMBOLS)
result = ""
for i in xrange(n):
for i in range(int(n)):
result += SYMBOLS[random.randint(0, count - 1)]
return result
@ -94,7 +94,7 @@ def getFiller(length, passwords):
i = 0
for pwd in passwords:
# skip a distance based on total size to cover then place a password
maxSkip = length / pwdCount - pwdLen
maxSkip = int(length / pwdCount - pwdLen)
i += random.randint(maxSkip - 2, maxSkip)
filler = filler[:i] + pwd + filler[i + pwdLen:]
i += pwdLen
@ -121,29 +121,33 @@ def initScreen(scr):
fillerLength = width / 2 * fillerHeight
passwords = getPasswords()
filler = getFiller(fillerLength, passwords)
fillerCol1 = filler[:len(filler) / 2]
fillerCol2 = filler[len(filler) / 2:]
fillerCol1, fillerCol2 = filler[0:len(filler)//2], filler[len(filler)//2:]
#print(fillerCol1)
#time.sleep(15)
#print(fillerCol2)
#time.sleep(15)
# each column of symbols and passwords should be 1/4 of the screen
fillerWidth = width / 4
fillerWidth = int(width / 4)
# print the header stuff
slowWrite(scr, HEADER_TEXT)
slowWrite(scr, '\nENTER PASSWORD NOW\n\n')
slowWrite(scr, str(LOGIN_ATTEMPTS) + ' ATTEMPT(S) LEFT: ')
for i in xrange(LOGIN_ATTEMPTS):
for i in range(LOGIN_ATTEMPTS):
scr.addch(curses.ACS_BLOCK)
slowWrite(scr, ' ')
slowWrite(scr, '\n\n')
# print the hex and filler
for i in xrange(fillerHeight):
for i in range(fillerHeight):
slowWrite(scr, "0x%X %s" % (hexCol1[i], fillerCol1[i * fillerWidth: (i + 1) * fillerWidth]), 1)
if i < fillerHeight - 1:
scr.addstr('\n')
for i in xrange(fillerHeight):
scr.move(HEADER_LINES + i, CONST_CHARS / 2 + fillerWidth)
for i in range(fillerHeight):
scr.move(HEADER_LINES + i, int(CONST_CHARS / 2 + fillerWidth))
slowWrite(scr, '0x%X %s' % (hexCol2[i], fillerCol2[i * fillerWidth: (i + 1) * fillerWidth]), 1)
scr.refresh()
@ -165,10 +169,10 @@ def moveInput(scr, inputPad):
cursorPos = inputPad.getyx()
inputPad.refresh(0, 0,
height - cursorPos[0] - 1,
width / 2 + CONST_CHARS,
height - 1,
width - 1)
int(height - cursorPos[0] - 1),
int(width / 2 + CONST_CHARS),
int(height - 1),
int(width - 1))
def userInput(scr, passwords):
@ -183,7 +187,7 @@ def userInput(scr, passwords):
width = size[1]
# set up a pad for user input
inputPad = curses.newpad(height, width / 2 + CONST_CHARS)
inputPad = curses.newpad(height, int(width / 2 + CONST_CHARS))
attempts = LOGIN_ATTEMPTS
@ -193,7 +197,7 @@ def userInput(scr, passwords):
while attempts > 0:
# move the curser to the correct spot for typing
scr.move(height - 1, width / 2 + CONST_CHARS + 1)
scr.move(int(height - 1), int(width / 2 + CONST_CHARS + 1))
# scroll user input up as the user tries passwords
moveInput(scr, inputPad)
@ -207,6 +211,8 @@ def userInput(scr, passwords):
# user got password right
if guess.upper() == pwd.upper():
addSound("correctpass")
inputPad.addstr('>Exact match!\n')
inputPad.addstr('>Please wait\n')
inputPad.addstr('>while system\n')
@ -214,7 +220,7 @@ def userInput(scr, passwords):
moveInput(scr, inputPad)
curses.napms(LOGIN_PAUSE)
time.sleep(LOGIN_PAUSE)
return pwd
# wrong password
@ -222,12 +228,13 @@ def userInput(scr, passwords):
pwdLen = len(pwd)
matched = 0
try:
for i in xrange(pwdLen):
for i in range(pwdLen):
if pwd[i].upper() == guess[i].upper():
matched += 1
except IndexError:
pass # user did not enter enough letters
addSound("wrongpass")
inputPad.addstr('>Entry denied\n')
inputPad.addstr('>' + str(matched) + '/' + str(pwdLen) +
' correct.\n')
@ -237,7 +244,7 @@ def userInput(scr, passwords):
scr.move(SQUARE_Y, 0)
scr.addstr(str(attempts))
scr.move(SQUARE_Y, SQUARE_X)
for i in xrange(LOGIN_ATTEMPTS):
for i in range(LOGIN_ATTEMPTS):
if i < attempts:
scr.addch(curses.ACS_BLOCK)
else:

View file

@ -1,6 +1,7 @@
import curses
from fallout_functions import slowWrite
from fallout_functions import centeredWrite
################## text strings ######################
@ -25,10 +26,10 @@ def runLocked(scr):
# set screen to initial position
scr.erase()
curses.curs_set(0)
scr.move(height / 2 - 1, width / 2 - len(LOCKED_1) / 2)
slowWrite(scr, LOCKED_1)
scr.move(height / 2 + 1, width / 2 - len(LOCKED_2) / 2)
slowWrite(scr, LOCKED_2)
scr.move(int(height / 2 - 1), 0)
centeredWrite(scr, LOCKED_1)
scr.move(int(height / 2 + 1), 0)
centeredWrite(scr, LOCKED_2)
scr.refresh()
curses.napms(LOCKED_OUT_TIME)

View file

@ -47,7 +47,7 @@ def runLogin(scr, hardMode, username, password):
# input is entered for them
slowWrite(scr, '> ')
curses.napms(INPUT_PAUSE)
slowWrite(scr, ENTRY + username.upper() + '\n', TYPE_DELAY)
slowWrite(scr, ENTRY + username.upper() + '\n', TYPE_DELAY, True)
slowWrite(scr, '\n' + PASSWORD_PROMPT + '\n\n')
@ -65,7 +65,7 @@ def runLogin(scr, hardMode, username, password):
slowWrite(scr, '> ')
curses.napms(INPUT_PAUSE)
password_stars = HIDDEN_MASK * len(password)
slowWrite(scr, password_stars + '\n', TYPE_DELAY)
slowWrite(scr, password_stars + '\n', TYPE_DELAY, True)
curses.napms(500)

84
fallout_selection.py Normal file
View file

@ -0,0 +1,84 @@
import curses
from time import sleep
from fallout_functions import slowWrite, centeredWrite, NEWLINE, addSound
###################### Functions ############################
def makeSelection(scr, SELECTIONS, MSGS):
"""
ALlow the user to select an option
Returns the line number of the users selection starting at 0
"""
inchar = 0
selection = 0
selection_count = len(SELECTIONS)
selection_start_y = scr.getyx()[0]
width = scr.getmaxyx()[1]
while inchar != NEWLINE:
# move to start of selections and hightlight current selection
scr.move(selection_start_y, 0)
line = 0
for sel in SELECTIONS:
whole_line = '> ' + SELECTIONS[line]
space = width - len(whole_line) % width
whole_line += ' ' * space
if line == selection:
scr.addstr(whole_line, curses.A_REVERSE)
else:
scr.addstr(whole_line)
line += 1
scr.refresh()
inchar = scr.getch()
# move up and down
if inchar == curses.KEY_UP and selection > 0:
selection -= 1
addSound("keyenter")
elif inchar == curses.KEY_DOWN and selection < selection_count - 1:
selection += 1
addSound("keyenter")
if MSGS and MSGS[selection]:
whole_line = '> ' + MSGS[selection]
space = width - len(whole_line) % width
whole_line += ' ' * space
scr.addstr(' ' * width)
scr.addstr(whole_line)
scr.refresh()
sleep(2)
addSound("keyenter")
return selection
def runSelection(scr, CENTERED_HEADERS, OTHER_HEADERS, OPTIONS, MESSAGES):
"""
Print the selections and allow the user to select one
"""
curses.use_default_colors()
scr.erase()
scr.move(0, 0)
curses.curs_set(0)
curses.noecho()
width = scr.getmaxyx()[1]
for header in CENTERED_HEADERS:
centeredWrite(scr, header + '\n')
for header in OTHER_HEADERS:
slowWrite(scr, header + '\n')
for i in range(width):
scr.addch(curses.ACS_BSBS)
scr.refresh()
return makeSelection(scr, OPTIONS, MESSAGES)
def beginSelection(center, other, options, messages = []):
"""
Initialize curses and start the boot process
"""
res = curses.wrapper(runSelection, center, other, options, messages)
return res