games/galaxy: tweak pausing behavior
This commit is contained in:
parent
9ce9299d17
commit
0ab5d34be4
1 changed files with 16 additions and 8 deletions
|
@ -57,7 +57,7 @@ double
|
||||||
LIM = 10,
|
LIM = 10,
|
||||||
dt²;
|
dt²;
|
||||||
char *file;
|
char *file;
|
||||||
int showv, showa, throttle, paused;
|
int showv, showa, throttle, moving;
|
||||||
|
|
||||||
char *menustr[] = {
|
char *menustr[] = {
|
||||||
[SAVE] "save",
|
[SAVE] "save",
|
||||||
|
@ -106,26 +106,28 @@ randcol(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pause(int p, int pri)
|
pause(int p, int id)
|
||||||
{
|
{
|
||||||
static int paused, ppri;
|
static int paused, pid = -1;
|
||||||
|
|
||||||
switch(p) {
|
switch(p) {
|
||||||
default:
|
default:
|
||||||
sysfatal("invalid pause value %d:", p);
|
sysfatal("invalid pause value %d:", p);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
if(pri > ppri)
|
if(pid != -1 && pid != id)
|
||||||
ppri = pri;
|
break;
|
||||||
|
pid = id;
|
||||||
if(paused)
|
if(paused)
|
||||||
break;
|
break;
|
||||||
paused = 1;
|
paused = 1;
|
||||||
qlock(&glxy);
|
qlock(&glxy);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if(!paused || pri < ppri)
|
if(!paused || pid != id)
|
||||||
break;
|
break;
|
||||||
paused = ppri = 0;
|
pid = -1;
|
||||||
|
paused = 0;
|
||||||
qunlock(&glxy);
|
qunlock(&glxy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -321,10 +323,12 @@ move(void)
|
||||||
if(mc->buttons & 1)
|
if(mc->buttons & 1)
|
||||||
break;
|
break;
|
||||||
if(mc->buttons & 4) {
|
if(mc->buttons & 4) {
|
||||||
|
moving = 0;
|
||||||
setcursor(mc, cursor);
|
setcursor(mc, cursor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
moving = 1;
|
||||||
od = subpt(orig, mc->xy);
|
od = subpt(orig, mc->xy);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
readmouse(mc);
|
readmouse(mc);
|
||||||
|
@ -456,9 +460,11 @@ kbdthread(void*)
|
||||||
{
|
{
|
||||||
Keyboardctl *realkc;
|
Keyboardctl *realkc;
|
||||||
Rune r;
|
Rune r;
|
||||||
|
static int paused;
|
||||||
|
|
||||||
threadsetname("keyboard");
|
threadsetname("keyboard");
|
||||||
if(realkc = initkeyboard(nil), realkc == nil)
|
realkc = initkeyboard(nil);
|
||||||
|
if(realkc == nil)
|
||||||
sysfatal("kbdthread: could not initkeyboard: %r");
|
sysfatal("kbdthread: could not initkeyboard: %r");
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
@ -482,6 +488,8 @@ kbdthread(void*)
|
||||||
showa ^= 1;
|
showa ^= 1;
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
|
if(moving)
|
||||||
|
break;
|
||||||
paused ^= 1;
|
paused ^= 1;
|
||||||
if(paused) {
|
if(paused) {
|
||||||
cursor = &pausecursor;
|
cursor = &pausecursor;
|
||||||
|
|
Loading…
Reference in a new issue