*Disabled Game-Input while in InputField
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import game, { GlobalData } from "..";
|
import game, { GlobalData } from "..";
|
||||||
|
import { INSPECT_MAX_BYTES } from "buffer";
|
||||||
|
let disableInputTimer;
|
||||||
|
|
||||||
export default class InputHelper {
|
export default class InputHelper {
|
||||||
private title: string;
|
private title: string;
|
||||||
@@ -26,20 +28,24 @@ export default class InputHelper {
|
|||||||
|
|
||||||
mp.events.add('closeinputhelper', this.finish);
|
mp.events.add('closeinputhelper', this.finish);
|
||||||
|
|
||||||
|
mp.events.add("render", () => {
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
if (this.created) return;
|
if (this.created) return;
|
||||||
|
|
||||||
this.data.InMenu = true;
|
this.data.InMenu = true;
|
||||||
this.data.InInput = true;
|
this.data.InInput = true;
|
||||||
this.created = true;
|
this.created = true;
|
||||||
this.browser = mp.browsers.new('package://assets/html/inputhelper/index.html');
|
this.browser = mp.browsers.new('package://assets/html/inputhelper/index.html');
|
||||||
mp.gui.cursor.show(true, true);
|
mp.gui.cursor.show(true, true);
|
||||||
|
disableInputTimer = setInterval(disableInput, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private finish() {
|
private finish() {
|
||||||
if (this.browser) {
|
if (this.browser) {
|
||||||
|
clearInterval(disableInputTimer);
|
||||||
mp.events.remove('cef_inputhelper_sendvalue');
|
mp.events.remove('cef_inputhelper_sendvalue');
|
||||||
mp.events.remove('cef_request_title');
|
mp.events.remove('cef_request_title');
|
||||||
this.browser.destroy();
|
this.browser.destroy();
|
||||||
@@ -48,6 +54,7 @@ export default class InputHelper {
|
|||||||
this.created = false;
|
this.created = false;
|
||||||
this.browser = null;
|
this.browser = null;
|
||||||
mp.gui.cursor.show(false, false);
|
mp.gui.cursor.show(false, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,14 +75,16 @@ export default class InputHelper {
|
|||||||
resolve(this.value);
|
resolve(this.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getValue(callback: Function) {
|
async getValue(callback: Function) {
|
||||||
var getVal = await this.valueGetter();
|
var getVal = await this.valueGetter();
|
||||||
callback(getVal);
|
callback(getVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disableInput() {
|
||||||
|
for (var x = 0; x < 32; x++) {
|
||||||
|
mp.game.controls.disableAllControlActions(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exports = InputHelper;
|
exports = InputHelper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user