graphics: use dehacked for skill+episode names. (#1286)

This commit is contained in:
mc776 2024-01-29 07:50:28 -08:00 committed by GitHub
parent 66696cb620
commit 57bf37ec77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 44 deletions

View file

@ -72,6 +72,40 @@ FONT_KERNING_RULES = {
r"[O0][O0]": -1, r"[O0][O0]": -1,
} }
# Level names are also included in this dictionary, with the
# data added programatically from the DEHACKED lump.
def read_bex_lump(filename):
"""Read the BEX (Dehacked) lump from the given filename.
Returns:
Dictionary mapping from name to value.
"""
result = {}
with open(filename) as f:
for line in f:
# Ignore comments:
line = line.strip()
if len(line) == 0 or line[0] in "#;":
continue
# Just split on '=' and interpret that as an
# assignment. This is primitive and doesn't read
# like a full BEX parser should, but it's good
# enough for our purposes here.
assign = line.split("=", 2)
if len(assign) != 2:
continue
result[assign[0].strip()] = assign[1].strip()
return result
freedoom_bex = read_bex_lump("../../lumps/p2_deh.lmp")
freedm_bex = read_bex_lump("../../lumps/fdm_deh.lmp")
def read_bex_string(whichbex,defn):
return re.sub("^\w*\d:\s*", "", whichbex[defn])
white_graphics = { white_graphics = {
"wibp1": "P1", "wibp1": "P1",
"wibp2": "P2", "wibp2": "P2",
@ -81,9 +115,6 @@ white_graphics = {
# These files are for the title screens of Phase 1 and Phase 2 # These files are for the title screens of Phase 1 and Phase 2
"t_phase1": "PHASE 1", "t_phase1": "PHASE 1",
"t_phase2": "PHASE 2", "t_phase2": "PHASE 2",
# Note: level names are also included in this dictionary, with
# the data added programatically from the DEHACKED lump, see
# code below.
} }
blue_graphics = { blue_graphics = {
@ -105,15 +136,15 @@ red_graphics = {
"m_rdthis": "Read This!", "m_rdthis": "Read This!",
"m_quitg": "Quit Game", "m_quitg": "Quit Game",
"m_newg": "NEW GAME", "m_newg": "NEW GAME",
"m_epi1": "Outpost Outbreak", "m_epi1": read_bex_string(freedoom_bex,"TXT_D1E1"),
"m_epi2": "Military Labs", "m_epi2": read_bex_string(freedoom_bex,"TXT_D1E2"),
"m_epi3": "Event Horizon", "m_epi3": read_bex_string(freedoom_bex,"TXT_D1E3"),
"m_epi4": "Double Impact", "m_epi4": read_bex_string(freedoom_bex,"TXT_D1E4"),
"m_jkill": "Please don't kill me!", "m_jkill": read_bex_string(freedoom_bex,"SKILL_BABY"),
"m_rough": "Will this hurt?", "m_rough": read_bex_string(freedoom_bex,"SKILL_EASY"),
"m_hurt": "Bring on the pain.", "m_hurt": read_bex_string(freedoom_bex,"SKILL_NORMAL"),
"m_ultra": "Extreme Carnage.", "m_ultra": read_bex_string(freedoom_bex,"SKILL_HARD"),
"m_nmare": "MAYHEM!", "m_nmare": read_bex_string(freedoom_bex,"SKILL_NIGHTMARE"),
"m_lgttl": "LOAD GAME", "m_lgttl": "LOAD GAME",
"m_sgttl": "SAVE GAME", "m_sgttl": "SAVE GAME",
"m_endgam": "End Game", "m_endgam": "End Game",
@ -208,30 +239,6 @@ red_graphics = {
} }
def read_bex_lump(filename):
"""Read the BEX (Dehacked) lump from the given filename.
Returns:
Dictionary mapping from name to value.
"""
result = {}
with open(filename) as f:
for line in f:
# Ignore comments:
line = line.strip()
if len(line) == 0 or line[0] in "#;":
continue
# Just split on '=' and interpret that as an
# assignment. This is primitive and doesn't read
# like a full BEX parser should, but it's good
# enough for our purposes here.
assign = line.split("=", 2)
if len(assign) != 2:
continue
result[assign[0].strip()] = assign[1].strip()
return result
def update_level_name(lumpname, bexdata, bexname): def update_level_name(lumpname, bexdata, bexname):
"""Set the level name for the given graphic from BEX file. """Set the level name for the given graphic from BEX file.
@ -248,10 +255,6 @@ def update_level_name(lumpname, bexdata, bexname):
levelname = re.sub("^\w*\d:\s*", "", bexdata[bexname]) levelname = re.sub("^\w*\d:\s*", "", bexdata[bexname])
white_graphics[lumpname] = levelname white_graphics[lumpname] = levelname
freedoom_bex = read_bex_lump("../../lumps/p2_deh.lmp")
freedm_bex = read_bex_lump("../../lumps/fdm_deh.lmp")
for e in range(4): for e in range(4):
for m in range(9): for m in range(9):
# HUSTR_E1M1 from BEX => wilv00 # HUSTR_E1M1 from BEX => wilv00

View file

@ -678,11 +678,11 @@ QUITMSG12 = Don't quit!\nMonsters will kill\nyou while you sleep.
QUITMSG13 = Do you think you can\nwalk away just like that? QUITMSG13 = Do you think you can\nwalk away just like that?
QUITMSG14 = Not even going to\nstay for Deathmatch? QUITMSG14 = Not even going to\nstay for Deathmatch?
# Episodes and Difficulty. # Episodes and Difficulty.
SKILL_BABY = Please Don't Kill Me! SKILL_BABY = Please don't kill me!
SKILL_EASY = Will This Hurt? SKILL_EASY = Will this hurt?
SKILL_NORMAL = Bring on The Pain. SKILL_NORMAL = Bring on the pain.
SKILL_HARD = Extreme Carnage. SKILL_HARD = Extreme Carnage.
SKILL_NIGHTMARE = Mayhem! SKILL_NIGHTMARE = MAYHEM!
TXT_D1E1 = Outpost Outbreak TXT_D1E1 = Outpost Outbreak
TXT_D1E2 = Military Labs TXT_D1E2 = Military Labs
TXT_D1E3 = Event Horizon TXT_D1E3 = Event Horizon