Skip to content

Commit

Permalink
Removed viewport scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
jobtalle committed Aug 26, 2022
1 parent 9c4d99a commit 77dcdae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 47 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta charset="utf-8">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width height=device-height initial-scale=0.5 user-scalable=no">
</head>
<body>
<script src="js/styleOverrides.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion js/koi/gui/menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Menu.prototype.LANGUAGES = [
* @param {AudioEngine} audioEngine The audio engine
* @param {Object} externalSettings The external settings object
* @param {AudioBank} audio Game audio
* @param {createFullscreenButton} If set to true, a fullscreen button will be created
* @param {Boolean} createFullscreenButton If set to true, a fullscreen button will be created
* @returns {HTMLDivElement} The menu box
*/
Menu.prototype.createBox = function(
Expand Down
78 changes: 33 additions & 45 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ let chosenSlot = -1;
const RUNNING_ON_WEBVIEW_IOS = (window.webkit && window.webkit.messageHandlers) ? true : false;

/**
* Reload the currently loaded game
* Reload the game into the menu
*/
const reloadGame = () => {
if (chosenSlot === -1)
return;

window.location = window.location.protocol + "//" + window.location.host + window.location.pathname + "?resume=" + chosenSlot.toString();
const reloadMenu = () => {
window.location = window.location.protocol + "//" + window.location.host + window.location.pathname;
};

/**
* Reload the game into the menu
* Reload the currently loaded game
*/
const reloadMenu = () => {
window.location = window.location.protocol + "//" + window.location.host + window.location.pathname;
const reloadGame = () => {
if (chosenSlot === -1)
reloadMenu();
else
window.location = window.location.protocol + "//" + window.location.host + window.location.pathname + "?resume=" + chosenSlot.toString();
};

/**
Expand Down Expand Up @@ -179,11 +179,11 @@ if (gl &&
canvas.height = wrapper.clientHeight;

window.onresize = () => {
if (canvas.width === wrapper.offsetWidth && canvas.height === wrapper.offsetHeight)
if (canvas.width === wrapper.clientWidth && canvas.height === wrapper.clientHeight)
return;

canvas.width = wrapper.offsetWidth;
canvas.height = wrapper.offsetHeight;
canvas.width = wrapper.clientWidth;
canvas.height = wrapper.clientHeight;

systems.resize(canvas.width, canvas.height);
gui.resize();
Expand All @@ -204,6 +204,7 @@ if (gl &&
* @param {number} index Create a new game at a given slot index
*/
const newSession = index => {
chosenSlot = index;
slot = slotNames[index];
session = new Session();

Expand Down Expand Up @@ -255,57 +256,44 @@ if (gl &&
}
};

window.addEventListener("mousedown", event => {
if (koi) {
event.preventDefault();
canvas.addEventListener("mousedown", event => {
event.preventDefault();

koi.touchStart(event.clientX, event.clientY, control, shift);
}
koi.touchStart(event.clientX, event.clientY, control, shift);
});

window.addEventListener("touchstart", event => {
if (koi) {
event.preventDefault();
canvas.addEventListener("touchstart", event => {
event.preventDefault();

koi.touchStart(event.changedTouches[0].clientX, event.changedTouches[0].clientY, control, shift);
}
koi.touchStart(event.changedTouches[0].clientX, event.changedTouches[0].clientY, control, shift);
});

window.addEventListener("mousemove", event => {
if (koi) {
koi.touchMove(event.clientX, event.clientY, mouseLeft);
canvas.addEventListener("mousemove", event => {
koi.touchMove(event.clientX, event.clientY, mouseLeft);

mouseLeft = false;
}
mouseLeft = false;
});

window.addEventListener("touchmove", event => {
if (koi) {
event.preventDefault();
canvas.addEventListener("touchmove", event => {
event.preventDefault();

koi.touchMove(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
}
koi.touchMove(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
})

window.addEventListener("mouseup", () => {
if (koi)
koi.touchEnd();
canvas.addEventListener("mouseup", () => {
koi.touchEnd();
});

window.addEventListener("touchend", event => {
if (koi) {
event.preventDefault();
canvas.addEventListener("touchend", event => {
event.preventDefault();

koi.touchEnd();
}
koi.touchEnd();
});

window.addEventListener("mouseleave", () => {
if (koi) {
koi.mouseLeave();
canvas.addEventListener("mouseleave", () => {
koi.mouseLeave();

mouseLeft = true;
}
mouseLeft = true;
});

window.onkeydown = event => {
Expand Down

0 comments on commit 77dcdae

Please sign in to comment.