diff --git a/www.rus/js/plugins/VND_ONSControls.js b/www.rus/js/plugins/VND_ONSControls.js index 776609b..30b38a8 100644 --- a/www.rus/js/plugins/VND_ONSControls.js +++ b/www.rus/js/plugins/VND_ONSControls.js @@ -25,6 +25,7 @@ ONSControls.createCanvas = function() { transparent: true }); document.body.appendChild(canvas.view); + canvas.view.id = "ControlsCanvas"; canvas.view.style.zIndex = this.options.zIndex; canvas.view.style.position = "absolute"; canvas.view.style.left = 0; @@ -150,6 +151,19 @@ ONSControls.sendEvent = function(event, button) { const key = VirtualGamepad.keys.find((element) => element.name == button); VirtualGamepad.gamepad.buttons[key.code].pressed = event.type == "pointerdown" ? true : false } +//============================================================================= +// * Fix controls size on empty screen +//============================================================================= +document.addEventListener("deviceready", onCordovaDeviceReady, false); + +ONSControls.onCordovaDeviceReady = function () { + console.log("ONSControls - SETUP!!!"); //Remove in release + document.addEventListener("resume", onCordovaResume, false); +}; + +ONSControls.onCordovaResume = function () { + // TODO: HERE CONTROLS WILL BE UPDATED OR RECREATED +}; diff --git a/www.rus/js/porting/css/controls.css b/www.rus/js/porting/css/controls.css index 1debe9a..42845d3 100644 --- a/www.rus/js/porting/css/controls.css +++ b/www.rus/js/porting/css/controls.css @@ -51,6 +51,15 @@ z-index: 1489; } +.new-button { + position: absolute; + right: 5px; + top: 5px; + width: 90px; + height: 40px; + z-index: 1489; +} + .gamepad-buttons { opacity: 0.6; z-index: 1488; diff --git a/www.rus/js/porting/jscontrols.js b/www.rus/js/porting/jscontrols.js index 54ce530..aef1097 100644 --- a/www.rus/js/porting/jscontrols.js +++ b/www.rus/js/porting/jscontrols.js @@ -66,6 +66,24 @@ function create_fps_button() { } } +function create_new_controls() { + // Remove in release + const NewBtn = document.createElement("div"); + NewBtn.className = "new-button"; + document.body.appendChild(NewBtn); + + NewBtn.addEventListener("pointerdown", () => { + var controls_canvas = document.getElementById("ControlsCanvas"); + if (controls_canvas === null) { + document.getElementById("show-gamepad").remove(); + ONSControls.initialize(); + } else { + controls_canvas.remove(); + create_show_button(); + } + }); +} + function create_dpad_buttons() { // Скуфting elements const DivDMain = document.createElement("div"); @@ -283,6 +301,7 @@ function setupKey(id, key, keyCode) { window.addEventListener('load', () => { create_fps_button(); // Remove in release + create_new_controls(); // Remove in release if (navigator.getGamepads().length == 0) { create_control_buttons(); create_dpad_buttons();