/* OK w95 */ void mainEventLoop() { short sVal, sXCurrent, sYCurrent; long lDevice; int i=0; int state = FALSE; short attached = 1; short value; int dev; int pupval; // make_all(); //init_menu(); nCurrentDir = DIR_NONE; czclear(0x404040, getgdesc(GD_ZMAX)); while (TRUE) { if (qtest()) { lDevice = qread(&sVal); switch (lDevice) { case INPUTCHANGE: #ifdef DOFF printf(" %d, %d, %d\n", Win_ids[0], Win_ids[1], sVal); #endif if ( sVal != 0 ) Input_win = sVal; else Input_win = -1; break; case REDRAW: if ( sVal == Win_ids[1] && Win_ids[1] != -1 ) vDrawHelpScene(); else if ( sVal == Win_ids[0] ) { reshapeviewport(); getsize(&nWinWidth, &nWinHeight); getorigin(&nXWinOrigin, &nYWinOrigin); } break; case RIGHTMOUSE: pupval = dopup(mainmenu); break; case SPACEKEY: state = TRUE; i++; if ( i == 4 ) subEventLoop(); break; case RKEY: if ( Last_Actions[FIRE] == TRUE ) vEventLoop(&vDrawTitle); break; case QKEY: if ( Input_win == Win_ids[1] ) { winclose(Input_win); Win_ids[1] != -1; } else if ( Input_win == Win_ids[0] ) { winclose(Win_ids[0]); if ( Win_ids[1] != -1 ) winclose(Win_ids[1]); exit(0); } break; default: break; } } getdev(DR_NUM_BUT, Devs, Last_Actions); vDrawTitle(state); } }
void main() { short val; int menu, pres; float p, mx, my; curmass = 0.5; curdrag = 0.15; prefsize(800,640); initbuzz(); winopen("dynadraw"); glcompat(GLC_OLDPOLYGON,1); subpixel(1); shademodel(FLAT); gconfig(); qdevice(LEFTMOUSE); qdevice(MIDDLEMOUSE); qdevice(MENUBUTTON); qdevice(RIGHTSHIFTKEY); qdevice(UPARROWKEY); qdevice(DOWNARROWKEY); qdevice(RIGHTSHIFTKEY); makeframe(); menu = defpup("dynadraw %t|toggle line style|save PostScript"); width = initwidth; mouse.fixedangle = 1; while(1) { switch(qread(&val)) { case REDRAW: makeframe(); break; case MIDDLEMOUSE: if(val) clearscreen(); break; case UPARROWKEY: if(val) initwidth *= 1.414213; width = initwidth; break; case DOWNARROWKEY: if(val) initwidth /= 1.414213; width = initwidth; break; case MENUBUTTON: if(val) { switch(dopup(menu)) { case 1: mouse.fixedangle = 1-mouse.fixedangle; break; case 2: savepolys(); break; } } break; case LEFTMOUSE: if(val) { my = getmousey(); if(my>0*SLIDERHIGH && my<2*SLIDERHIGH) { if(my>SLIDERHIGH) { while(getbutton(LEFTMOUSE)) { p = paramval(); if(p != curmass) { curmass = p; showsettings(); } } } else { while(getbutton(LEFTMOUSE)) { p = paramval(); if(p != curdrag) { curdrag = p; showsettings(); } } } } else { mx = 1.25*fgetmousex(); my = fgetmousey(); filtersetpos(&mouse,mx,my); odelx = 0.0; odely = 0.0; while(getbutton(LEFTMOUSE)) { mx = 1.25*fgetmousex(); my = fgetmousey(); if(filterapply(&mouse,mx,my)) { drawsegment(&mouse); color(0); buzz(); } } } } break; } } }
/* half OK w95 */ void subEventLoop() { short sVal, sXCurrent, sYCurrent; long lDevice; float tmp; nCurrentDir = DIR_NONE; czclear(0x404040, getgdesc(GD_ZMAX)); strcpy(Message, ReadyMesg); vDrawScene(); qreset(); while (TRUE) { if (qtest()) { lDevice = qread(&sVal); switch (lDevice) { case INPUTCHANGE: #ifdef DOFF printf(" %d, %d, %d\n", Win_ids[0], Win_ids[1], sVal); #endif if ( sVal != 0 ) Input_win = sVal; else Input_win = -1; break; case REDRAW: if ( sVal == Win_ids[1] && Win_ids[1] != -1 ) vDrawHelpScene(); else if ( sVal == Win_ids[0] ) { winset(Win_ids[0]); reshapeviewport(); getsize(&nWinWidth, &nWinHeight); getorigin(&nXWinOrigin, &nYWinOrigin); tmp = Speed; Speed = 0.0; vDrawScene(); Speed = tmp; } break; case RIGHTMOUSE: dopup(mainmenu); break; case SPACEKEY: if ( EMode == FALSE ) { p1EventLoop(); strcpy(Message, ""); } if ( EMode == TRUE ) /* game over */ { vDrawOverScene(); } break; case RKEY: if ( Last_Actions[FIRE] == TRUE ) vEventLoop((&vDrawScene)); break; case QKEY: if ( Input_win == Win_ids[1] ) { winclose(Input_win); Win_ids[1] != -1; } else if ( Input_win == Win_ids[0] ) { winclose(Win_ids[0]); if ( Win_ids[1] != -1 ) winclose(Win_ids[1]); exit(0); } break; default: break; } } else getdev(DR_NUM_BUT, Devs, Last_Actions); } }