Version 1.1

This commit is contained in:
voxonoly 2024-05-29 22:21:00 -05:00
parent a42549b8f1
commit df1c937695
22 changed files with 162 additions and 80 deletions

BIN
.github/assets/ingame.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 KiB

View File

@ -1,7 +1,9 @@
# Eaglercraft Mobile UI # Eaglercraft Mobile UI v1.1
A revamp of FlamedDogo99's eaglercraft mobile UI using pocked edition UI.<br> A revamp of FlamedDogo99's eaglercraft mobile UI using pocked edition UI.<br>
Currently **STILL IN BETA** testing/making so expect some bugs! Currently **STILL IN BETA** testing/making so expect some bugs!
![Ingame](.github/assets/ingame.png)<br>
<hr> <hr>
## Implementation ## Implementation
@ -17,12 +19,26 @@
<hr> <hr>
## Features ## Features added
- Pocket Edition UI <details>
- Better controls positioning <summary>Click here to expand feature list</summary>
- Toggle perspective
- Bug fixes from original - [x] Strafe buttons when holding forward
- [x] Crouch lock on hold
- [x] Sprint button (sperate from double tapping forward)
- [ ] Misc Platform support (Controller, Keyboard arrows, etc)
- [ ] Cancel button for file upload
- [ ] Styling for file upload
- [x] Back button for Kiwi browser?
- [x] Re-orginize button layout (With new icons)
- [ ] Redo the display button functions
- [x] Pocket Edition UI
- [x] Toggle perspective
- [x] Bug fixes from original
- [ ] Config file for features
- [ ] Organized Code
</details>
<hr> <hr>

View File

@ -1,18 +1,3 @@
// ==UserScript==
// @name Eagler Mobile
// @description Allows eaglercraft to run on mobile, adds touch controls, and fixes a few mobile-related crashes
// @author FlamedDogo99
// @namespace http://github.com/FlamedDogo99
// @downloadURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.js
// @license Apache License 2.0 - http://www.apache.org/licenses/
// @match https://eaglercraft.com/mc/*
// @grant none
// @version 1.1
// @updateURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.js
// @run-at document-start
// ==/UserScript==
// Hides inventory button // Hides inventory button
window.inInventory = false; window.inInventory = false;
// Used for changing touchmove events to mousemove events // Used for changing touchmove events to mousemove events
@ -62,6 +47,7 @@ Object.defineProperty(document, "pointerLockElement", {
document.exitPointerLock = function() { document.exitPointerLock = function() {
window.fakelock = null window.fakelock = null
document.dispatchEvent(new Event('pointerlockchange')); document.dispatchEvent(new Event('pointerlockchange'));
console.log("hide ui")
var hideButtonStyleDOM = document.getElementById('hideButtonStyle'); var hideButtonStyleDOM = document.getElementById('hideButtonStyle');
var hideInventoryStyleDOM = document.getElementById('hideInventoryStyle'); var hideInventoryStyleDOM = document.getElementById('hideInventoryStyle');
hideButtonStyleDOM.disabled = false; hideButtonStyleDOM.disabled = false;
@ -140,9 +126,17 @@ customStyle.textContent = `
button:active { button:active {
opacity: .75; opacity: .75;
} }
.minicontrol {
width: 7.5vh;
height: 7.5vh;
display: none;
}
.show {
display: block;
}
.mini { .mini {
width: 3.5vw; width: 6vh;
height: 3.5vw; height: 6vh;
margin: 1vh 0vh; margin: 1vh 0vh;
} }
.crouch { .crouch {
@ -166,13 +160,20 @@ hideButtonStyle.id = "hideButtonStyle";
hideButtonStyle.textContent = ` hideButtonStyle.textContent = `
#hideButton { #hideButton {
display: none; display: none;
}
.minicontrol {
display: none;
}`; }`;
document.documentElement.appendChild(hideButtonStyle); document.documentElement.appendChild(hideButtonStyle);
let hideInventoryStyle = document.createElement("style"); let hideInventoryStyle = document.createElement("style");
hideInventoryStyle.id = "hideInventoryStyle"; hideInventoryStyle.id = "hideInventoryStyle";
hideInventoryStyle.textContent = ` hideInventoryStyle.textContent = `
#hideInventory { #hideInventory {
display: none; display: none;
}
.inventory {
display: none;
}`; }`;
document.documentElement.appendChild(hideInventoryStyle); document.documentElement.appendChild(hideInventoryStyle);
@ -209,8 +210,8 @@ function insertCanvasElements() {
e.movementX = touch.pageX - previousX; e.movementX = touch.pageX - previousX;
e.movementY = touch.pageY - previousY; e.movementY = touch.pageY - previousY;
var evt = new MouseEvent("mousemove", { var evt = new MouseEvent("mousemove", {
movementX: e.movementX, movementX: e.movementX * 2,
movementY: e.movementY movementY: e.movementY * 2
}); });
canvas.dispatchEvent(evt); canvas.dispatchEvent(evt);
previousX = touch.pageX; previousX = touch.pageX;
@ -224,11 +225,38 @@ function insertCanvasElements() {
}, false) }, false)
// Adds all of the touch screen controls // Adds all of the touch screen controls
// Theres probably a better way to do this but this works for now // Theres probably a better way to do this but this works for now
var forwardButton = document.createElement('button');
function showStrafe() {
forwardLeftButton.classList.add("show")
forwardRightButton.classList.add("show")
}
function hideStrafe() {
forwardLeftButton.classList.remove("show")
forwardRightButton.classList.remove("show")
}
var forwardLeftButton = document.createElement('button');
forwardLeftButton.classList = "minicontrol"
forwardLeftButton.style.cssText = "left:5.5vh;bottom:22vh;background:url(mobile/uiUpLeft.png) no-repeat center;background-size: contain, cover;"
forwardLeftButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown"),keyEvent("a", "keydown"), strafe=true}, false);
forwardLeftButton.addEventListener("touchend", function(e){keyEvent("w", "keyup"),keyEvent("a", "keyup"), hideStrafe(), strafe=false}, false);
forwardLeftButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(forwardLeftButton);
var forwardRightButton = document.createElement('button');
forwardRightButton.classList = "minicontrol hidden"
forwardRightButton.style.cssText = "left:24vh;bottom:22vh;background:url(mobile/uiUpRight.png) no-repeat center;background-size: contain, cover;"
forwardRightButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown"),keyEvent("d", "keydown"), strafe=true}, false);
forwardRightButton.addEventListener("touchend", function(e){keyEvent("w", "keyup"),keyEvent("d", "keyup"), hideStrafe(), strafe=false}, false);
forwardRightButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(forwardRightButton);
var forwardButton = document.createElement('button');
forwardButton.id = "hideButton" forwardButton.id = "hideButton"
forwardButton.style.cssText = "left:14vh;bottom:22vh;background:url(mobile/uiUp.png) no-repeat center;background-size: contain, cover;" forwardButton.style.cssText = "left:14vh;bottom:22vh;background:url(mobile/uiUp.png) no-repeat center;background-size: contain, cover;"
forwardButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown")}, false); forwardButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown"), showStrafe(), strafe=false}, false);
forwardButton.addEventListener("touchend", function(e){keyEvent("w", "keyup")}, false); forwardButton.addEventListener("touchend", function(e){if (strafe===false) {hideStrafe()} keyEvent("w", "keyup")}, false);
forwardButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); forwardButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(forwardButton); document.body.appendChild(forwardButton);
@ -268,15 +296,17 @@ function insertCanvasElements() {
crouchButton.id = "hideButton" crouchButton.id = "hideButton"
crouchButton.classList = "crouch" crouchButton.classList = "crouch"
crouchButton.style.cssText = "left:14vh;bottom:12vh;" crouchButton.style.cssText = "left:14vh;bottom:12vh;"
crouchButton.addEventListener("touchstart", function(e){shiftKey("keydown")}, false); crouchButton.addEventListener("touchstart", function(e){shiftKey("keydown"), cshift=false}, false);
crouchButton.addEventListener("touchend", function(e){shiftKey("keyup")}, false); crouchButton.addEventListener("touchend", function(e){if (cshift===false) {shiftKey("keyup")}}, false);
crouchButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); crouchButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
crouchButton.addEventListener("pointerdown", function(e){ctimer = setTimeout(function(e){shiftKey("keydown"), cshift=true}, 1000)}, false);
crouchButton.addEventListener("pointerup", function(e){clearTimeout(ctimer)}, false);
document.body.appendChild(crouchButton); document.body.appendChild(crouchButton);
var inventoryButton = document.createElement('button'); var inventoryButton = document.createElement('button');
inventoryButton.id = "hideInventory" inventoryButton.id = "hideInventory"
inventoryButton.classList = "mini" inventoryButton.classList = "mini"
inventoryButton.style.cssText = "right:11vw;bottom:0vh;background:url(mobile/uiInventory.png) no-repeat center;background-size: contain, cover;" inventoryButton.style.cssText = "right:11.75vw;bottom:0vh;background:url(mobile/uiInventory.png) no-repeat center;background-size: contain, cover;"
inventoryButton.addEventListener("touchstart", function(e){ inventoryButton.addEventListener("touchstart", function(e){
window.inInventory = (window.fakelock != null) window.inInventory = (window.fakelock != null)
keyEvent("e", "keydown"); keyEvent("e", "keydown");
@ -288,7 +318,7 @@ function insertCanvasElements() {
var chatButton = document.createElement('button'); var chatButton = document.createElement('button');
chatButton.id = "hideButton" chatButton.id = "hideButton"
chatButton.classList = "mini" chatButton.classList = "mini"
chatButton.style.cssText = "left:43.5vw;top:0vh;background:url(mobile/uiChat.png) no-repeat center;background-size: contain, cover;" chatButton.style.cssText = "left:44.5vw;top:0vh;background:url(mobile/uiChat.png) no-repeat center;background-size: contain, cover;"
chatButton.addEventListener("touchstart", function(e){keyEvent("t", "keydown")}, false); chatButton.addEventListener("touchstart", function(e){keyEvent("t", "keydown")}, false);
chatButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); chatButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(chatButton); document.body.appendChild(chatButton);
@ -296,7 +326,7 @@ function insertCanvasElements() {
var angleButton = document.createElement('button'); var angleButton = document.createElement('button');
angleButton.id = "hideButton" angleButton.id = "hideButton"
angleButton.classList = "mini" angleButton.classList = "mini"
angleButton.style.cssText = "left:51.5vw;top:0vh;background:url(mobile/uiAngle.png) no-repeat center;background-size: contain, cover;" angleButton.style.cssText = "left:50.5vw;top:0vh;background:url(mobile/uiAngle.png) no-repeat center;background-size: contain, cover;"
angleButton.addEventListener("touchstart", function(e){keyEvent("f", "keydown"), keyEvent("5", "keydown")}, false); angleButton.addEventListener("touchstart", function(e){keyEvent("f", "keydown"), keyEvent("5", "keydown")}, false);
angleButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); angleButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(angleButton); document.body.appendChild(angleButton);
@ -310,10 +340,17 @@ function insertCanvasElements() {
exitButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); exitButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(exitButton); document.body.appendChild(exitButton);
var sprintButton = document.createElement('button');
sprintButton.id = "hideButton"
sprintButton.style.cssText = "right:6vh;bottom:54vh;background:url(mobile/uiSprint.png) no-repeat center;background-size: contain, cover;"
sprintButton.addEventListener("touchstart", function(e){keyEvent("r", "keydown")}, false);
sprintButton.addEventListener("touchend", function(e){keyEvent("r", "keyup")}, false);
sprintButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(sprintButton);
var placeButton = document.createElement('button'); var placeButton = document.createElement('button');
placeButton.id = "hideButton" placeButton.id = "hideButton"
placeButton.textContent = "⊹"; placeButton.style.cssText = "right:6vh;bottom:38vh;background:url(mobile/uiInteract.png) no-repeat center;background-size: contain, cover;"
placeButton.style.cssText = "right:5vh;bottom:35vh;"
placeButton.addEventListener("touchstart", function(e){mouseEvent(2, "mousedown", canvas)}, false); placeButton.addEventListener("touchstart", function(e){mouseEvent(2, "mousedown", canvas)}, false);
placeButton.addEventListener("touchend", function(e){mouseEvent(2, "mouseup", canvas)}, false); placeButton.addEventListener("touchend", function(e){mouseEvent(2, "mouseup", canvas)}, false);
placeButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); placeButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
@ -321,8 +358,7 @@ function insertCanvasElements() {
var breakButton = document.createElement('button'); var breakButton = document.createElement('button');
breakButton.id = "hideButton" breakButton.id = "hideButton"
breakButton.textContent = "🗡"; breakButton.style.cssText = "right:20vh;bottom:43vh;background:url(mobile/uiAttack.png) no-repeat center;background-size: contain, cover;"
breakButton.style.cssText = "right:25vh;bottom:45vh;"
breakButton.addEventListener("touchstart", function(e){mouseEvent(0, "mousedown", canvas)}, false); breakButton.addEventListener("touchstart", function(e){mouseEvent(0, "mousedown", canvas)}, false);
breakButton.addEventListener("touchend", function(e){mouseEvent(0, "mouseup", canvas)}, false); breakButton.addEventListener("touchend", function(e){mouseEvent(0, "mouseup", canvas)}, false);
breakButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); breakButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
@ -331,8 +367,7 @@ function insertCanvasElements() {
var scrollUpButton = document.createElement('button'); var scrollUpButton = document.createElement('button');
scrollUpButton.id = "hideButton" scrollUpButton.id = "hideButton"
scrollUpButton.classList = "mini" scrollUpButton.classList = "mini"
scrollUpButton.textContent = "⇨"; scrollUpButton.style.cssText = "right:5.25vw;bottom:0vh;background:url(mobile/uiSRight.png) no-repeat center;background-size: contain, cover;"
scrollUpButton.style.cssText = "right:3vw;bottom:0vh;"
scrollUpButton.addEventListener("touchstart", function(e){ scrollUpButton.addEventListener("touchstart", function(e){
canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": -10})) canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": -10}))
}, false); }, false);
@ -342,8 +377,7 @@ function insertCanvasElements() {
var scrollDownButton = document.createElement('button'); var scrollDownButton = document.createElement('button');
scrollDownButton.id = "hideButton" scrollDownButton.id = "hideButton"
scrollDownButton.classList = "mini" scrollDownButton.classList = "mini"
scrollDownButton.textContent = "⇦"; scrollDownButton.style.cssText = "right:15vw;bottom:0vh;background:url(mobile/uiSLeft.png) no-repeat center;background-size: contain, cover;"
scrollDownButton.style.cssText = "right:15vw;bottom:0vh;"
scrollDownButton.addEventListener("touchstart", function(e){ scrollDownButton.addEventListener("touchstart", function(e){
canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": 10})) canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": 10}))
}, false); }, false);
@ -353,8 +387,7 @@ function insertCanvasElements() {
var throwButton = document.createElement('button'); var throwButton = document.createElement('button');
throwButton.id = "hideButton" throwButton.id = "hideButton"
throwButton.classList = "mini" throwButton.classList = "mini"
throwButton.textContent = "Q"; throwButton.style.cssText = "right:8.5vw;bottom:0vh;background:url(mobile/uiDrop.png) no-repeat center;background-size: contain, cover;"
throwButton.style.cssText = "right:7vw;bottom:0vh;"
throwButton.addEventListener("touchstart", function(e){ throwButton.addEventListener("touchstart", function(e){
window.inInventory = (window.fakelock != null) window.inInventory = (window.fakelock != null)
keyEvent("q", "keydown"); keyEvent("q", "keydown");

BIN
demo/mobile/uiAttack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

BIN
demo/mobile/uiDrop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

BIN
demo/mobile/uiInteract.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 558 B

BIN
demo/mobile/uiSLeft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

BIN
demo/mobile/uiSRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

BIN
demo/mobile/uiSprint.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

BIN
demo/mobile/uiUpLeft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

BIN
demo/mobile/uiUpRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

View File

@ -1,18 +1,3 @@
// ==UserScript==
// @name Eagler Mobile
// @description Allows eaglercraft to run on mobile, adds touch controls, and fixes a few mobile-related crashes
// @author FlamedDogo99
// @namespace http://github.com/FlamedDogo99
// @downloadURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.js
// @license Apache License 2.0 - http://www.apache.org/licenses/
// @match https://eaglercraft.com/mc/*
// @grant none
// @version 1.1
// @updateURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.js
// @run-at document-start
// ==/UserScript==
// Hides inventory button // Hides inventory button
window.inInventory = false; window.inInventory = false;
// Used for changing touchmove events to mousemove events // Used for changing touchmove events to mousemove events
@ -62,6 +47,7 @@ Object.defineProperty(document, "pointerLockElement", {
document.exitPointerLock = function() { document.exitPointerLock = function() {
window.fakelock = null window.fakelock = null
document.dispatchEvent(new Event('pointerlockchange')); document.dispatchEvent(new Event('pointerlockchange'));
console.log("hide ui")
var hideButtonStyleDOM = document.getElementById('hideButtonStyle'); var hideButtonStyleDOM = document.getElementById('hideButtonStyle');
var hideInventoryStyleDOM = document.getElementById('hideInventoryStyle'); var hideInventoryStyleDOM = document.getElementById('hideInventoryStyle');
hideButtonStyleDOM.disabled = false; hideButtonStyleDOM.disabled = false;
@ -140,9 +126,17 @@ customStyle.textContent = `
button:active { button:active {
opacity: .75; opacity: .75;
} }
.minicontrol {
width: 7.5vh;
height: 7.5vh;
display: none;
}
.show {
display: block;
}
.mini { .mini {
width: 3.5vw; width: 6vh;
height: 3.5vw; height: 6vh;
margin: 1vh 0vh; margin: 1vh 0vh;
} }
.crouch { .crouch {
@ -166,13 +160,20 @@ hideButtonStyle.id = "hideButtonStyle";
hideButtonStyle.textContent = ` hideButtonStyle.textContent = `
#hideButton { #hideButton {
display: none; display: none;
}
.minicontrol {
display: none;
}`; }`;
document.documentElement.appendChild(hideButtonStyle); document.documentElement.appendChild(hideButtonStyle);
let hideInventoryStyle = document.createElement("style"); let hideInventoryStyle = document.createElement("style");
hideInventoryStyle.id = "hideInventoryStyle"; hideInventoryStyle.id = "hideInventoryStyle";
hideInventoryStyle.textContent = ` hideInventoryStyle.textContent = `
#hideInventory { #hideInventory {
display: none; display: none;
}
.inventory {
display: none;
}`; }`;
document.documentElement.appendChild(hideInventoryStyle); document.documentElement.appendChild(hideInventoryStyle);
@ -209,8 +210,8 @@ function insertCanvasElements() {
e.movementX = touch.pageX - previousX; e.movementX = touch.pageX - previousX;
e.movementY = touch.pageY - previousY; e.movementY = touch.pageY - previousY;
var evt = new MouseEvent("mousemove", { var evt = new MouseEvent("mousemove", {
movementX: e.movementX, movementX: e.movementX * 2,
movementY: e.movementY movementY: e.movementY * 2
}); });
canvas.dispatchEvent(evt); canvas.dispatchEvent(evt);
previousX = touch.pageX; previousX = touch.pageX;
@ -224,11 +225,38 @@ function insertCanvasElements() {
}, false) }, false)
// Adds all of the touch screen controls // Adds all of the touch screen controls
// Theres probably a better way to do this but this works for now // Theres probably a better way to do this but this works for now
var forwardButton = document.createElement('button');
function showStrafe() {
forwardLeftButton.classList.add("show")
forwardRightButton.classList.add("show")
}
function hideStrafe() {
forwardLeftButton.classList.remove("show")
forwardRightButton.classList.remove("show")
}
var forwardLeftButton = document.createElement('button');
forwardLeftButton.classList = "minicontrol"
forwardLeftButton.style.cssText = "left:5.5vh;bottom:22vh;background:url(mobile/uiUpLeft.png) no-repeat center;background-size: contain, cover;"
forwardLeftButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown"),keyEvent("a", "keydown"), strafe=true}, false);
forwardLeftButton.addEventListener("touchend", function(e){keyEvent("w", "keyup"),keyEvent("a", "keyup"), hideStrafe(), strafe=false}, false);
forwardLeftButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(forwardLeftButton);
var forwardRightButton = document.createElement('button');
forwardRightButton.classList = "minicontrol hidden"
forwardRightButton.style.cssText = "left:24vh;bottom:22vh;background:url(mobile/uiUpRight.png) no-repeat center;background-size: contain, cover;"
forwardRightButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown"),keyEvent("d", "keydown"), strafe=true}, false);
forwardRightButton.addEventListener("touchend", function(e){keyEvent("w", "keyup"),keyEvent("d", "keyup"), hideStrafe(), strafe=false}, false);
forwardRightButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(forwardRightButton);
var forwardButton = document.createElement('button');
forwardButton.id = "hideButton" forwardButton.id = "hideButton"
forwardButton.style.cssText = "left:14vh;bottom:22vh;background:url(mobile/uiUp.png) no-repeat center;background-size: contain, cover;" forwardButton.style.cssText = "left:14vh;bottom:22vh;background:url(mobile/uiUp.png) no-repeat center;background-size: contain, cover;"
forwardButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown")}, false); forwardButton.addEventListener("touchstart", function(e){keyEvent("w", "keydown"), showStrafe(), strafe=false}, false);
forwardButton.addEventListener("touchend", function(e){keyEvent("w", "keyup")}, false); forwardButton.addEventListener("touchend", function(e){if (strafe===false) {hideStrafe()} keyEvent("w", "keyup")}, false);
forwardButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); forwardButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(forwardButton); document.body.appendChild(forwardButton);
@ -268,15 +296,17 @@ function insertCanvasElements() {
crouchButton.id = "hideButton" crouchButton.id = "hideButton"
crouchButton.classList = "crouch" crouchButton.classList = "crouch"
crouchButton.style.cssText = "left:14vh;bottom:12vh;" crouchButton.style.cssText = "left:14vh;bottom:12vh;"
crouchButton.addEventListener("touchstart", function(e){shiftKey("keydown")}, false); crouchButton.addEventListener("touchstart", function(e){shiftKey("keydown"), cshift=false}, false);
crouchButton.addEventListener("touchend", function(e){shiftKey("keyup")}, false); crouchButton.addEventListener("touchend", function(e){if (cshift===false) {shiftKey("keyup")}}, false);
crouchButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); crouchButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
crouchButton.addEventListener("pointerdown", function(e){ctimer = setTimeout(function(e){shiftKey("keydown"), cshift=true}, 1000)}, false);
crouchButton.addEventListener("pointerup", function(e){clearTimeout(ctimer)}, false);
document.body.appendChild(crouchButton); document.body.appendChild(crouchButton);
var inventoryButton = document.createElement('button'); var inventoryButton = document.createElement('button');
inventoryButton.id = "hideInventory" inventoryButton.id = "hideInventory"
inventoryButton.classList = "mini" inventoryButton.classList = "mini"
inventoryButton.style.cssText = "right:11vw;bottom:0vh;background:url(mobile/uiInventory.png) no-repeat center;background-size: contain, cover;" inventoryButton.style.cssText = "right:11.75vw;bottom:0vh;background:url(mobile/uiInventory.png) no-repeat center;background-size: contain, cover;"
inventoryButton.addEventListener("touchstart", function(e){ inventoryButton.addEventListener("touchstart", function(e){
window.inInventory = (window.fakelock != null) window.inInventory = (window.fakelock != null)
keyEvent("e", "keydown"); keyEvent("e", "keydown");
@ -288,7 +318,7 @@ function insertCanvasElements() {
var chatButton = document.createElement('button'); var chatButton = document.createElement('button');
chatButton.id = "hideButton" chatButton.id = "hideButton"
chatButton.classList = "mini" chatButton.classList = "mini"
chatButton.style.cssText = "left:43.5vw;top:0vh;background:url(mobile/uiChat.png) no-repeat center;background-size: contain, cover;" chatButton.style.cssText = "left:44.5vw;top:0vh;background:url(mobile/uiChat.png) no-repeat center;background-size: contain, cover;"
chatButton.addEventListener("touchstart", function(e){keyEvent("t", "keydown")}, false); chatButton.addEventListener("touchstart", function(e){keyEvent("t", "keydown")}, false);
chatButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); chatButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(chatButton); document.body.appendChild(chatButton);
@ -296,7 +326,7 @@ function insertCanvasElements() {
var angleButton = document.createElement('button'); var angleButton = document.createElement('button');
angleButton.id = "hideButton" angleButton.id = "hideButton"
angleButton.classList = "mini" angleButton.classList = "mini"
angleButton.style.cssText = "left:51.5vw;top:0vh;background:url(mobile/uiAngle.png) no-repeat center;background-size: contain, cover;" angleButton.style.cssText = "left:50.5vw;top:0vh;background:url(mobile/uiAngle.png) no-repeat center;background-size: contain, cover;"
angleButton.addEventListener("touchstart", function(e){keyEvent("f", "keydown"), keyEvent("5", "keydown")}, false); angleButton.addEventListener("touchstart", function(e){keyEvent("f", "keydown"), keyEvent("5", "keydown")}, false);
angleButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); angleButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(angleButton); document.body.appendChild(angleButton);
@ -310,10 +340,17 @@ function insertCanvasElements() {
exitButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); exitButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(exitButton); document.body.appendChild(exitButton);
var sprintButton = document.createElement('button');
sprintButton.id = "hideButton"
sprintButton.style.cssText = "right:6vh;bottom:54vh;background:url(mobile/uiSprint.png) no-repeat center;background-size: contain, cover;"
sprintButton.addEventListener("touchstart", function(e){keyEvent("r", "keydown")}, false);
sprintButton.addEventListener("touchend", function(e){keyEvent("r", "keyup")}, false);
sprintButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
document.body.appendChild(sprintButton);
var placeButton = document.createElement('button'); var placeButton = document.createElement('button');
placeButton.id = "hideButton" placeButton.id = "hideButton"
placeButton.textContent = "⊹"; placeButton.style.cssText = "right:6vh;bottom:38vh;background:url(mobile/uiInteract.png) no-repeat center;background-size: contain, cover;"
placeButton.style.cssText = "right:5vh;bottom:35vh;"
placeButton.addEventListener("touchstart", function(e){mouseEvent(2, "mousedown", canvas)}, false); placeButton.addEventListener("touchstart", function(e){mouseEvent(2, "mousedown", canvas)}, false);
placeButton.addEventListener("touchend", function(e){mouseEvent(2, "mouseup", canvas)}, false); placeButton.addEventListener("touchend", function(e){mouseEvent(2, "mouseup", canvas)}, false);
placeButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); placeButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
@ -321,8 +358,7 @@ function insertCanvasElements() {
var breakButton = document.createElement('button'); var breakButton = document.createElement('button');
breakButton.id = "hideButton" breakButton.id = "hideButton"
breakButton.textContent = "🗡"; breakButton.style.cssText = "right:20vh;bottom:43vh;background:url(mobile/uiAttack.png) no-repeat center;background-size: contain, cover;"
breakButton.style.cssText = "right:25vh;bottom:45vh;"
breakButton.addEventListener("touchstart", function(e){mouseEvent(0, "mousedown", canvas)}, false); breakButton.addEventListener("touchstart", function(e){mouseEvent(0, "mousedown", canvas)}, false);
breakButton.addEventListener("touchend", function(e){mouseEvent(0, "mouseup", canvas)}, false); breakButton.addEventListener("touchend", function(e){mouseEvent(0, "mouseup", canvas)}, false);
breakButton.addEventListener("touchmove", function(e){e.preventDefault()}, false); breakButton.addEventListener("touchmove", function(e){e.preventDefault()}, false);
@ -331,8 +367,7 @@ function insertCanvasElements() {
var scrollUpButton = document.createElement('button'); var scrollUpButton = document.createElement('button');
scrollUpButton.id = "hideButton" scrollUpButton.id = "hideButton"
scrollUpButton.classList = "mini" scrollUpButton.classList = "mini"
scrollUpButton.textContent = "⇨"; scrollUpButton.style.cssText = "right:5.25vw;bottom:0vh;background:url(mobile/uiSRight.png) no-repeat center;background-size: contain, cover;"
scrollUpButton.style.cssText = "right:3vw;bottom:0vh;"
scrollUpButton.addEventListener("touchstart", function(e){ scrollUpButton.addEventListener("touchstart", function(e){
canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": -10})) canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": -10}))
}, false); }, false);
@ -342,8 +377,7 @@ function insertCanvasElements() {
var scrollDownButton = document.createElement('button'); var scrollDownButton = document.createElement('button');
scrollDownButton.id = "hideButton" scrollDownButton.id = "hideButton"
scrollDownButton.classList = "mini" scrollDownButton.classList = "mini"
scrollDownButton.textContent = "⇦"; scrollDownButton.style.cssText = "right:15vw;bottom:0vh;background:url(mobile/uiSLeft.png) no-repeat center;background-size: contain, cover;"
scrollDownButton.style.cssText = "right:15vw;bottom:0vh;"
scrollDownButton.addEventListener("touchstart", function(e){ scrollDownButton.addEventListener("touchstart", function(e){
canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": 10})) canvas.dispatchEvent(new WheelEvent("wheel", {"wheelDeltaY": 10}))
}, false); }, false);
@ -353,8 +387,7 @@ function insertCanvasElements() {
var throwButton = document.createElement('button'); var throwButton = document.createElement('button');
throwButton.id = "hideButton" throwButton.id = "hideButton"
throwButton.classList = "mini" throwButton.classList = "mini"
throwButton.textContent = "Q"; throwButton.style.cssText = "right:8.5vw;bottom:0vh;background:url(mobile/uiDrop.png) no-repeat center;background-size: contain, cover;"
throwButton.style.cssText = "right:7vw;bottom:0vh;"
throwButton.addEventListener("touchstart", function(e){ throwButton.addEventListener("touchstart", function(e){
window.inInventory = (window.fakelock != null) window.inInventory = (window.fakelock != null)
keyEvent("q", "keydown"); keyEvent("q", "keydown");

BIN
source/mobile/uiAttack.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

BIN
source/mobile/uiDrop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 561 B

After

Width:  |  Height:  |  Size: 558 B

BIN
source/mobile/uiSLeft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

BIN
source/mobile/uiSRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

BIN
source/mobile/uiSprint.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

BIN
source/mobile/uiUpLeft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

BIN
source/mobile/uiUpRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B