|
(function() { |
|
window.godotFilePath = null; |
|
window.urlParameter = window.location.search; |
|
|
|
window.uploadFile = function() { |
|
var input = document.createElement('input'); |
|
input.type = 'file'; |
|
input.onchange = function(event) { |
|
var file = event.target.files[0]; |
|
if (file) { |
|
var reader = new FileReader(); |
|
reader.onload = function(e) { |
|
var fileContent = e.target.result; |
|
window.godotFilePath = fileContent; |
|
if (typeof window.fileUploaded === 'function') { |
|
window.fileUploaded(fileContent); |
|
} |
|
}; |
|
reader.readAsDataURL(file); |
|
} |
|
}; |
|
input.click(); |
|
}; |
|
window.gdjs = { |
|
godotFilePath: null |
|
}; |
|
|
|
|
|
window.showVirtualKeyboard = function() { |
|
var inputField = document.createElement('input'); |
|
inputField.type = 'text'; |
|
inputField.style.position = 'absolute'; |
|
inputField.style.top = '-1000px'; |
|
document.body.appendChild(inputField); |
|
setTimeout(function() { |
|
inputField.focus(); |
|
}, 100); |
|
inputField.onblur = function() { |
|
document.body.removeChild(inputField); |
|
}; |
|
inputField.addEventListener('input', function() { |
|
var value = inputField.value; |
|
if (typeof window.godotUserInput === 'function') { |
|
window.godotUserInput(value); |
|
} |
|
}); |
|
}; |
|
window.closeVirtualKeyboard = function() { |
|
document.activeElement.blur(); |
|
}; |
|
|
|
|
|
window.setOrientation = function(orientation) { |
|
console.log("2222") |
|
console.log(orientation) |
|
if (orientation === "landscape") { |
|
screen.orientation.lock(orientation).catch(function(error) { |
|
console.log("Orientation lock failed: " + error); |
|
}); |
|
} else if (orientation === "portrait") { |
|
screen.lockOrientation(orientation).catch(function(error) { |
|
console.log("Orientation lock failed: " + error); |
|
}); |
|
} |
|
console.log(document.body) |
|
}; |
|
window.setWindowSize = function(width, height) { |
|
var canvas = document.getElementById('canvas'); |
|
canvas.style.width = width + 'px'; |
|
canvas.style.height = height + 'px'; |
|
}; |
|
window.setScreenStretch = function(mode, aspect, width, height) { |
|
var canvas = document.getElementById('canvas'); |
|
if (mode === 'viewport') { |
|
canvas.style.objectFit = 'contain'; |
|
} |
|
if (aspect === 'keep') { |
|
canvas.style.width = width + 'px'; |
|
canvas.style.height = height + 'px'; |
|
} |
|
}; |
|
})(); |
|
|