fix input bug
This commit is contained in:
parent
b2a45fcfdd
commit
1ff46c3975
|
@ -535,10 +535,8 @@ Object.unhide = function(obj, ...props)
|
|||
{
|
||||
for (var prop of props) {
|
||||
var p = Object.getOwnPropertyDescriptor(obj,prop);
|
||||
if (!p) {
|
||||
console.warn(`No property of name ${prop}.`);
|
||||
return;
|
||||
}
|
||||
if (!p)
|
||||
continue;
|
||||
p.enumerable = true;
|
||||
Object.defineProperty(obj, prop, p);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ profile.printreport = function(cache, name)
|
|||
|
||||
console.transcript = "";
|
||||
console.say = function(msg) {
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
console.print(msg);
|
||||
console.transcript += msg;
|
||||
};
|
||||
|
@ -354,6 +354,7 @@ function process()
|
|||
var st = profile.now();
|
||||
prosperon.window_render(window.rendersize);
|
||||
prosperon.draw();
|
||||
prosperon.debug();
|
||||
prosperon.gui();
|
||||
prosperon.screengui();
|
||||
prosperon.hookend?.();
|
||||
|
|
|
@ -300,15 +300,20 @@ var Player = {
|
|||
|
||||
raw_input(cmd, state, ...args) {
|
||||
for (var pawn of this.pawns.reversed()) {
|
||||
if (typeof pawn.inputs?.any === 'function') {
|
||||
if (!pawn.inputs) {
|
||||
console.error(`pawn no longer has inputs object.`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof pawn.inputs.any === 'function') {
|
||||
pawn.inputs.any(cmd);
|
||||
|
||||
if (!pawn.inputs.fallthru)
|
||||
if (!pawn.inputs.fallthru)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pawn.inputs?.[cmd]) {
|
||||
if (pawn.inputs?.block) return;
|
||||
if (!pawn.inputs[cmd]) {
|
||||
if (pawn.inputs.block) return;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -316,21 +321,22 @@ var Player = {
|
|||
|
||||
switch (state) {
|
||||
case 'pressed':
|
||||
fn = pawn.inputs[cmd];
|
||||
break;
|
||||
fn = pawn.inputs[cmd];
|
||||
break;
|
||||
case 'rep':
|
||||
fn = pawn.inputs[cmd].rep ? pawn.inputs[cmd] : null;
|
||||
break;
|
||||
fn = pawn.inputs[cmd].rep ? pawn.inputs[cmd] : null;
|
||||
break;
|
||||
case 'released':
|
||||
fn = pawn.inputs[cmd].released;
|
||||
break;
|
||||
break;
|
||||
case 'down':
|
||||
fn = pawn.inputs[cmd].down;
|
||||
fn = pawn.inputs[cmd].down;
|
||||
}
|
||||
|
||||
if (typeof fn === 'function') {
|
||||
fn.call(pawn, ... args);
|
||||
pawn.inputs.post?.call(pawn);
|
||||
if (!pawn.inputs) continue; // TODO: OK? Checking if the call uncontrolled the pawn
|
||||
pawn.inputs.post?.call(pawn);
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
|
@ -370,6 +376,10 @@ var Player = {
|
|||
pawns: [],
|
||||
|
||||
control(pawn) {
|
||||
if (!pawn.inputs) {
|
||||
console.warn(`attempted to control a pawn without any input object.`);
|
||||
return;
|
||||
}
|
||||
this.pawns.push_unique(pawn);
|
||||
},
|
||||
|
||||
|
|
|
@ -354,7 +354,7 @@ render.device.doc = `Device resolutions given as [x,y,inches diagonal].`;
|
|||
|
||||
/* All draw in screen space */
|
||||
render.point = function(pos,size,color = Color.blue) {
|
||||
render.circle(pos,size,size,color);
|
||||
render.circle(pos,size,size,color);
|
||||
};
|
||||
|
||||
render.cross = function(pos, size, color = Color.red) {
|
||||
|
|
|
@ -92,7 +92,7 @@ void mYughLog(int category, int priority, int line, const char *file, const char
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
if (priority >= LOG_ERROR) {
|
||||
if (priority >= LOG_PANIC) {
|
||||
js_stacktrace();
|
||||
#ifdef __WIN32
|
||||
DebugBreak();
|
||||
|
|
Loading…
Reference in a new issue