Skip to content

Commit

Permalink
use heroes2-pixed font for wasm launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
ololoken committed Jan 3, 2025
1 parent 885de6e commit 37d06f1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
Binary file added files/emscripten/heroes2-pixed.otf
Binary file not shown.
Binary file added files/emscripten/heroes2-pixed.ttf
Binary file not shown.
80 changes: 53 additions & 27 deletions files/emscripten/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
<title>fheroes2</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">

<!-- progress.js {{ -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/progress.js/0.1.0/progress.min.js" integrity="sha512-CklrzCqwODBOEJHJq73SZrgWC7xcxssgg5M1xokosfDDz2/nLTCuMDyc51gbJtb8DriV4EYjJSlklPH5Ejn9XA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/progress.js/0.1.0/progressjs.min.css" integrity="sha512-ovRFHsWpnYUBNZd/8CmbaWAKBDO8xb0l5Y8PdIae1O5RXO2QyU3CZGNzuYuE0CQHKazIzWMQpnTn26WpPjexfw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- }} progress.js -->

<style>
body { margin: 0; height: 0; font-family: "Roboto", serif;}
@font-face {
font-family: 'Heroes2-pixed';
src: url('heroes2-pixed.otf') format('opentype'),
url('heroes2-pixed.ttf') format('truetype');
}
body { margin: 0; height: 0; font-family: 'Heroes2-pixed', serif;}
#canvas {
height: 100vh;
width: 100vw;
Expand All @@ -23,15 +31,9 @@
position: absolute;
color: #fff;
font-size: 30px;
text-stroke: 1px #000;
-webkit-text-stroke: 1px #000;
height: 100vh;
width: 100vw;
}
#launcher {
display: none;
text-stroke: 1px #fff;
-webkit-text-stroke: 1px #fff;
}
#uploader input[type=file] {
display: none
Expand All @@ -47,9 +49,20 @@
#uploader label span {
padding: 10vh 0 0 0;
display: block;
text-shadow: #FC0 4px 0 10px;
}
#launcher button {
font-size: 30px;
color: #fff;
font-family: 'Heroes2-pixed', serif;
text-shadow: #FC0 1px 0 10px;
background: url(data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAGoAAABYCAMAAAAqTZIDAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw1AUhU9TRZGKoB1EHDJUQbBLFXGsVShChVArtOpg8tI/aNKQpLg4Cq4FB38Wqw4uzro6uAqC4A+Iu+Ck6CIl3pcUWsR44fE+zrvn8N59gNCoMM3qigOabpvpZELM5lbFnlcEEMQgJhCTmWXMSVIKvvV1T91Ud1Ge5d/3Z/WreYsBAZE4zgzTJt4gntm0Dc77xGFWklXic+JJky5I/Mh1xeM3zkWXBZ4ZNjPpeeIwsVjsYKWDWcnUiKeJI6qmU76Q9VjlvMVZq9RY6578haG8vrLMdVqjSGIRS5AgQkENZVRgI0q7ToqFNJ0nfPwjrl8il0KuMhg5FlCFBtn1g//B79lahamYlxRKAN0vjvMxBvTsAs2643wfO07zBAg+A1d6219tALOfpNfbWuQIGNgGLq7bmrIHXO4Aw0+GbMquFKQlFArA+xl9Uw4YugX61ry5tc5x+gBkaFapG+DgEBgvUva6z7t7O+f2b09rfj+6E3LD5wGtGwAAAwBQTFRFAP///5b//2T//zL//wD///8AtAD/AP8Aycn/ubn//Pz88PDw6Ojo3Nzc1NTUyMjIwMDAtLS0rKyspKSkmJiYkJCQhISEfHx8cHBwaGhoXFxcVFRUSEhIQEBAODg4LCwsJCQkGBgYEBAQBAQEAAAA/Ozc8NzI6NC44MSo2LiY0KiIyKB4wJRsuIhgrHxUpHBInGg8lGA0jFQshEwgfEQcdDwUaDQQYDAMWCgIUCQESBwEPBgANBQAL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UOcVOtvmp02RNGou4W+W4UxUaK2xZdH84F2fhpPGNAm62NELz9IzCPNxYmN1DNSsaPkhxCQ9HR8ft5uxuySjAlrcSxwij5jDLXD5qRlNMkRzfgzqUUkmhk53KNN4WagcBf7cP+qA4AY5aawQvdeY4sNjuGUeE07NiJcGWO4Gf/CgqPCyevkJ7RgtCdydZgMvKn03JvKGvroWruGk3X7SjKx2wXRW2XE6hH6/HwKsTIOf+iA1Zk0HZCBLGOAKhtOHtLU53DKPW8+nNNtAJqEn2XlU5ldWr6mJyDHkPzoEcf0vOVwfGGhMpP003P8ANv1TR56qpoAAAAAASUVORK5CYII=);
border-radius: 5px;
padding: 3px 10px;
}
#launcher button:hover {
box-shadow: 0 0 20px 2px #FC0;
cursor: pointer;
}
#launcher .buttons {
text-align: center;
Expand Down Expand Up @@ -80,11 +93,6 @@
<script>
const S_IFMT = 61440; /* 0x0170000 type of file */
const S_IFDIR = 16384; /* 0x0040000 directory */
const progressBar = progressJs("#canvas").setOptions({
theme: 'blueOverlayRadiusWithPercentBar',
overlayMode: true,
considerTransition: true
});
const canvas = document.querySelector('canvas');
canvas.oncontextmenu = event => event.preventDefault();
Object.assign(window, { Module: {
Expand All @@ -100,12 +108,16 @@
FS.syncfs(true, (err) => {
if (err) throw err;
try {
if (Object.keys(FS.lookupPath(`${ENV.FHEROES2_DATA}`)).length === 0) return;
document.querySelector('#uploader').style.display = 'none';
document.querySelector('#launcher').style.display = 'block';
if (Object.keys(FS.lookupPath(`${ENV.FHEROES2_DATA}`)).length === 0) {
Module.show('#uploader');
}
else {
Module.show('#launcher');
}
}
catch (ignore) {
FS.mkdir(`${ENV.FHEROES2_DATA}`);
Module.show('#uploader');
}
});
},
Expand All @@ -119,13 +131,16 @@
requiredFiles.some(rq => path.toLocaleLowerCase().endsWith(rq.toLocaleLowerCase()))).length === 2;
if (!requiredResolved) return Module.clearInput('wrong directory');
const whitListed = ['data', 'heroes2', 'maps', 'music'];
files.filter(file => {
const filtered = files.filter(file => {
const [fileName, ...path] = file.webkitRelativePath.split('/').reverse();
if (fileName.startsWith('.')) return false;
return path
.map(folder => folder.toLocaleLowerCase())
.some(folder => whitListed.includes(folder))
}).reduce((uploaded, file, _ignore, queue) => {
});
Module.show('nothing');
const progressBarImport = progressJs().start();
filtered.reduce((uploaded, file, _ignore, queue) => {
const [fileName, ...path] = file.webkitRelativePath.split('/').reverse();
const [ignore, ...relativePath] = path.reverse();
Module.mkdirWithParents(`${ENV.FHEROES2_DATA}/${relativePath.join('/')}`);
Expand All @@ -137,11 +152,12 @@
encoding: 'binary'
});
uploaded.push(file);
progressBarImport.set(Math.round(uploaded.length / queue.length * 100))
if (uploaded.length === queue.length) {
progressBarImport.end();
FS.syncfs(false, err => {
if (err) return Module.clearInput('Failed to sync FS');
document.querySelector('#uploader').style.display = 'none';
document.querySelector('#launcher').style.display = 'block';
Module.show('#launcher');
})
}
});
Expand All @@ -151,6 +167,18 @@
})
}
],
progressBarMain: progressJs("#canvas").setOptions({
theme: 'blueOverlayRadiusWithPercentBar',
overlayMode: true,
considerTransition: true
}),
show: selector => {
document.querySelector('#uploader').style.display = 'none';
document.querySelector('#launcher').style.display = 'none';
if (document.querySelector(selector)) {
document.querySelector(selector).style.display = 'block';
}
},
clearInput: (msg = '') => {
document.querySelector('input[type=file]').value = null;
msg && alert(msg);
Expand Down Expand Up @@ -178,28 +206,26 @@
},
startGame: () => {
removeRunDependency('syncfs');
document.querySelector('#uploader').style.display = 'none';
document.querySelector('#launcher').style.display = 'none';
Module.show('game')
},
deleteFiles: () => {
if (false === confirm('Are you sure?')) return;
Module.clearPath(ENV.FHEROES2_DATA);
FS.syncfs(false, ignore => {});
Module.clearInput();
document.querySelector('#uploader').style.display = 'block';
document.querySelector('#launcher').style.display = 'none';
Module.show('#uploader')
},
setStatus: status => {
const dlProgressRE = /(?<progress>\d+)\/(?<total>\d+)/ig;
if (!status || !dlProgressRE.test(status)) {
if ((status ?? '').startsWith('Downloading data')) progressBar.start();
if ((status ?? '').startsWith('Downloading data')) Module.progressBarMain.start();
return;
}
dlProgressRE.lastIndex = 0;
const {groups: {progress, total}} = [...status.matchAll(dlProgressRE)][0];
const done = Math.round(progress / total * 100);
progressBar.set(done);
if (100 === done) progressBar.end();
Module.progressBarMain.set(done);
if (100 === done) Module.progressBarMain.end();
},
canvas
}
Expand Down
4 changes: 4 additions & 0 deletions files/emscripten/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The FontStruction “Heroes2-pixed”
(https://fontstruct.com/fontstructions/show/1088376) by “GodRage” is
licensed under a Creative Commons Attribution Non-commercial No Derivatives
license (http://creativecommons.org/licenses/by-nc-nd/3.0/).

0 comments on commit 37d06f1

Please sign in to comment.