forked from ozkl/doomgeneric
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add landing page and ability to load custom wads
- Loading branch information
Showing
12 changed files
with
191 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
* { | ||
font-family: Arial, Helvetica, sans-serif; | ||
box-sizing: border-box; | ||
} | ||
body { | ||
padding: 8px; | ||
margin: 0px; | ||
width: 100%; | ||
background-color: #222222; | ||
} | ||
|
||
.spacer { | ||
flex-grow: 1; | ||
} | ||
|
||
#article { | ||
background-color: whitesmoke; | ||
padding: 12px; | ||
border-radius: 4px; | ||
|
||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 550px; | ||
height: 300px; | ||
margin-left: -275px; | ||
margin-top: -150px; | ||
} | ||
#header_box { | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
} | ||
#header_box > h1 { | ||
margin: 0px; | ||
} | ||
#controls_box { | ||
display: flex; | ||
align-items: center; | ||
} | ||
#controls_box > * { | ||
font-size: 14px; | ||
} | ||
#wad_container { | ||
align-items: center; | ||
font-size: 12px; | ||
display: none; | ||
margin-top: 12px; | ||
} | ||
#play_button { | ||
text-decoration: none; | ||
color: black; | ||
background-color: lightgray; | ||
padding: 8px; | ||
border-radius: 3px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<title>DoomPDF</title> | ||
<link rel="stylesheet" href="/index.css"> | ||
<script src="/index.js" defer></script> | ||
</head> | ||
<body> | ||
<div id="article"> | ||
<div id="header_box"> | ||
<img src="/favicon.png" width="48px" height="48px"> | ||
<h1>DoomPDF</h1> | ||
</div> | ||
|
||
<p>This is a Doom source port that runs inside a PDF file.</p> | ||
<p>Source code: <a href="https://github.com/ading2210/doompdf">https://github.com/ading2210/doompdf</a></p> | ||
|
||
<hr><br> | ||
|
||
<div id="controls_box"> | ||
<a href="/doom.pdf" id="play_button">Start Game</a> | ||
<p id="shareware_note" style="margin: 0px; margin-left: 8px;">(shareware)</p> | ||
<div class="spacer"></div> | ||
<input type="checkbox" id="custom_wad_checkbox"> | ||
<label for="custom_wad_checkbox">Custom WAD</label> | ||
</div> | ||
<div id="wad_container"> | ||
<div> | ||
<label for="iwad_file_picker">IWAD file:</label><br> | ||
<input type="file" id="iwad_file_picker" name="iwad_file_picker" accept=".wad"> | ||
</div> | ||
<div class="spacer"></div> | ||
<div> | ||
<label for="iwad_file_picker">PWAD file:</label><br> | ||
<input type="file" id="wad_file_picker" name="wad_file_picker" accept=".wad"> | ||
</div> | ||
</div> | ||
<br> | ||
<p style="font-size: 12px; margin-top: 4px; margin-bottom: 4px;">Note: the PDF only works inside Chromium-based browsers.</p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const from_id = (id) => {return document.getElementById(id)}; | ||
const custom_wad_checkbox = from_id("custom_wad_checkbox"); | ||
const wad_file_picker = from_id("wad_file_picker"); | ||
const iwad_file_picker = from_id("iwad_file_picker"); | ||
const wad_container = from_id("wad_container"); | ||
const play_button = from_id("play_button"); | ||
const shareware_note = from_id("shareware_note"); | ||
|
||
custom_wad_checkbox.onchange = () => { | ||
if (custom_wad_checkbox.checked) { | ||
wad_container.style.display = "flex"; | ||
shareware_note.style.display = "none"; | ||
} | ||
else { | ||
wad_container.style.display = "none"; | ||
shareware_note.style.display = "initial"; | ||
} | ||
} | ||
|
||
play_button.onclick = (event) => { | ||
if (!custom_wad_checkbox.checked) | ||
return; | ||
event.stopImmediatePropagation(); | ||
event.preventDefault(); | ||
|
||
launch_custom_wads(); | ||
} | ||
|
||
function get_file_b64(file) { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.readAsDataURL(file); | ||
reader.onload = () => resolve(reader.result.split(",")[1]); | ||
reader.onerror = error => reject(error); | ||
}); | ||
} | ||
|
||
async function launch_custom_wads() { | ||
let iwad_file = iwad_file_picker.files[0]; | ||
if (!iwad_file) | ||
alert("Error: No IWAD file selected."); | ||
let pwad_file = wad_file_picker.files[0]; | ||
|
||
let response = await fetch("/doom_nowad.pdf"); | ||
let pdf = await response.text(); | ||
|
||
let iwad_b64 = await get_file_b64(iwad_file); | ||
pdf = pdf.replace("__iwad_file__", iwad_b64); | ||
pdf = pdf.replace("__iwad_filename__", iwad_file.name); | ||
|
||
if (pwad_file) { | ||
let pwad_b64 = await get_file_b64(pwad_file); | ||
pdf = pdf.replace("__wad_file__", pwad_b64); | ||
pdf = pdf.replace("__wad_filename__", pwad_file.name); | ||
} | ||
|
||
let blob = new Blob([pdf], {type: "application/pdf"}); | ||
open(URL.createObjectURL(blob)); | ||
} |