*/ private static array $texts = [ 'GOTARMOR' => 'Picked up the armor.', 'GOTMEGA' => 'Picked up the MegaArmor!', 'GOTHTHBONUS' => 'Picked up a health bonus.', 'GOTARMBONUS' => 'Picked up an armor bonus.', 'GOTSTIM' => 'Picked up a stimpack.', 'GOTMEDINEED' => 'Picked up a medikit that you REALLY need!', 'GOTMEDIKIT' => 'Picked up a medikit.', 'GOTSUPER' => 'Supercharge!', 'GOTBLUECARD' => 'Picked up a blue keycard.', 'GOTYELWCARD' => 'Picked up a yellow keycard.', 'GOTREDCARD' => 'Picked up a red keycard.', 'GOTBLUESKUL' => 'Picked up a blue skull key.', 'GOTYELWSKUL' => 'Picked up a yellow skull key.', 'GOTREDSKULL' => 'Picked up a red skull key.', 'GOTINVUL' => 'Invulnerability!', 'GOTBERSERK' => 'Berserk!', 'GOTINVIS' => 'Partial Invisibility', 'GOTSUIT' => 'Radiation Shielding Suit', 'GOTMAP' => 'Computer Area Map', 'GOTVISOR' => 'Light Amplification Visor', 'GOTMSPHERE' => 'MegaSphere!', 'GOTCLIP' => 'Picked up a clip.', 'GOTCLIPBOX' => 'Picked up a box of bullets.', 'GOTROCKET' => 'Picked up a rocket.', 'GOTROCKBOX' => 'Picked up a box of rockets.', 'GOTCELL' => 'Picked up an energy cell.', 'GOTCELLBOX' => 'Picked up an energy cell pack.', 'GOTSHELLS' => 'Picked up 4 shotgun shells.', 'GOTSHELLBOX' => 'Picked up a box of shotgun shells.', 'GOTBACKPACK' => 'Picked up a backpack full of ammo!', 'GOTBFG9000' => 'You got the BFG9000! Oh, yes.', 'GOTCHAINGUN' => 'You got the chaingun!', 'GOTCHAINSAW' => 'A chainsaw! Find some meat!', 'GOTLAUNCHER' => 'You got the rocket launcher!', 'GOTPLASMA' => 'You got the plasma gun!', 'GOTSHOTGUN' => 'You got the shotgun!', 'PD_BLUEO' => 'You need a blue key to activate this object', 'PD_REDO' => 'You need a red key to activate this object', 'PD_YELLOWO' => 'You need a yellow key to activate this object', 'PD_BLUEK' => 'You need a blue key to open this door', 'PD_REDK' => 'You need a red key to open this door', 'PD_YELLOWK' => 'You need a yellow key to open this door', 'NIGHTMARE' => "Are you sure? This skill level\nisn't even remotely fair.\n\nPress Y or N.", ]; /** @var array "E1M1" => par time in seconds */ private static array $pars = []; public static function load(Wad $wad): void { if (!$wad->has('DEHACKED')) { return; } $text = str_replace("\r", '', $wad->lump('DEHACKED')); $text = preg_replace("~\\\\\n\\s*~", '', $text) ?? $text; // joined continued lines $section = ''; foreach (explode("\n", $text) as $line) { $trim = trim($line); if ($trim === '' || $trim[0] === '#') { continue; } if (preg_match('~^\[(\w+)\]~', $trim, $m)) { $section = strtoupper($m[1]); continue; } if ($section === 'STRINGS' && preg_match('~^(\w+)\s*=\s*(.*)$~', $trim, $m)) { self::$texts[$m[1]] = str_replace('\n', "\n", $m[2]); } elseif ($section === 'PARS' && preg_match('~^par\s+(\d+)\s+(\d+)\s+(\d+)~i', $trim, $m)) { self::$pars["E{$m[1]}M{$m[2]}"] = (int) $m[3]; } elseif ($section === 'PARS' && preg_match('~^par\s+(\d+)\s+(\d+)\s*(#|$)~i', $trim, $m)) { self::$pars[sprintf('MAP%02d', $m[1])] = (int) $m[2]; // Phase 2: par } } } public static function get(string $key, string $default = ''): string { return self::$texts[$key] ?? ($default !== '' ? $default : $key); } public static function par(string $map): int { return self::$pars[$map] ?? 0; } }