예제 #1
0
static void init_gmx(t_x11 *x11, char *program, int nfile, t_filenm fnm[],
                     const output_env_t oenv)
{
    Pixmap                pm;
    t_gmx                *gmx;
    XSizeHints            hints;
    int                   w0, h0;
    int                   natom, natom_trx;
    t_topology            top;
    int                   ePBC;
    matrix                box;
    t_trxframe            fr;
    t_trxstatus          *status;
    char                  quote[256];

    snew(gmx, 1);
    snew(gmx->wd, 1);

    ePBC = read_tpx_top(ftp2fn(efTPR, nfile, fnm),
                        NULL, box, &natom, NULL, NULL, &top);

    read_first_frame(oenv, &status, ftp2fn(efTRX, nfile, fnm), &fr, TRX_DONT_SKIP);
    close_trx(status);
    natom_trx = fr.natoms;

    /* Creates a simple window */
    w0 = DisplayWidth(x11->disp, x11->screen)-132;
    h0 = DisplayHeight(x11->disp, x11->screen)-140;
    bromacs(quote, 255);
    InitWin(gmx->wd, 0, 0, w0, h0, 3, quote);
    gmx->wd->self = XCreateSimpleWindow(x11->disp, x11->root,
                                        gmx->wd->x, gmx->wd->y,
                                        gmx->wd->width, gmx->wd->height,
                                        gmx->wd->bwidth, WHITE, BLACK);
    pm = XCreatePixmapFromBitmapData(x11->disp, x11->root,
                                     (char *)gromacs_bits, gromacs_width,
                                     gromacs_height,
                                     WHITE, BLACK, 1);
    hints.flags      = PMinSize;
    hints.min_width  = 2*EWIDTH+40;
    hints.min_height = EHEIGHT+LDHEIGHT+LEGHEIGHT+40;
    XSetStandardProperties(x11->disp, gmx->wd->self, gmx->wd->text, program,
                           pm, NULL, 0, &hints);

    x11->RegisterCallback(x11, gmx->wd->self, x11->root, MainCallBack, gmx);
    x11->SetInputMask(x11, gmx->wd->self,
                      ButtonPressMask     | ButtonReleaseMask |
                      OwnerGrabButtonMask | ExposureMask      |
                      StructureNotifyMask);

    /* The order of creating windows is important here! */
    /* Manager */
    gmx->man  = init_man(x11, gmx->wd->self, 0, 0, 1, 1, WHITE, BLACK, ePBC, box, oenv);
    gmx->logo = init_logo(x11, gmx->wd->self, false);

    /* Now put all windows in the proper place */
    move_gmx(x11, gmx, w0, h0, false);

    XMapWindow(x11->disp, gmx->wd->self);
    map_man(x11, gmx->man);

    /* Pull Down menu */
    gmx->pd = init_pd(x11, gmx->wd->self, gmx->wd->width,
                      x11->fg, x11->bg,
                      MSIZE, gmx_pd_size, gmx_pd, MenuTitle);

    /* Dialogs & Filters */

    gmx->filter = init_filter(&(top.atoms), ftp2fn_null(efNDX, nfile, fnm),
                              natom_trx);

    init_dlgs(x11, gmx);

    /* Now do file operations */
    set_file(x11, gmx->man, ftp2fn(efTRX, nfile, fnm), ftp2fn(efTPR, nfile, fnm));

    ShowDlg(gmx->dlgs[edFilter]);
}
예제 #2
0
// exported extern windows callback routine (doet alle belangrijke stuff)
MRESULT EXPENTRY ClientWndProc(HWND hwnd,ULONG messg,MPARAM mp1,MPARAM mp2)
{
HPS         hps;
static HWND hMenu;
RECTL       rc;
static INT xView, yView;
int count,zoom,tel;
float tmpangle;
BOOL stat;
SIZEL sizel;
POINTL ptl;
switch (messg)
			 {
			 case DM_CHECKSCORE:
					count = check_hiscores(mp1);
					if (count != 10)
						{
						WinDlgBox(HWND_DESKTOP,hwnd,EnterHiScore,NULLHANDLE,DRIFT_HISCORE,NULL);
						if (glb_name[0] == 0)
							strcpy(HiTable[count].name,"Cthulhu");
						else
							strcpy(HiTable[count].name,glb_name);
						}
						break;
		 case WM_SIZE:
						xView = SHORT1FROMMP(mp2);
						yView = SHORT2FROMMP(mp2);
						break;
		 case WM_CREATE:
						init_logo();
						load_hiscores();
						// initialize the settings
            //hMenu=WinQueryWindow(hwnd,QW_PARENT);
						hMenu=WinWindowFromID(WinQueryWindow(hwnd,QW_PARENT),FID_MENU);
						// uncheck detaillevel
						stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
            // uncheck save on exit
            stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
						load_settings();
						// check to correct menu item detaillevel
						stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
            if (saveonexit)
            	stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
						switch (detaillevel)
							{
							case IDM_HIGHDET:
											game_bigex = 36;
											game_mediumex = 18;
											game_smallex = 9;
											maxthrustpixels = 9;
											break;
							case IDM_MEDIUMDET:
											game_bigex = 18;
											game_mediumex = 18;
											game_smallex = 9;
											maxthrustpixels = 5;
											break;
							case IDM_LOWDET:
											game_bigex = 9;
											game_mediumex = 9;
											game_smallex = 9;
											maxthrustpixels = 3;
											break;
							}
						if (saveonexit == TRUE)
								stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
						else
								stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
						break;
		 case WM_TIMER:
						hps = WinGetPS(hwnd) ;
            sizel.cx = 2000 ;
            sizel.cy = 2000 ;
            GpiSetPS (hps, &sizel, PU_PELS) ;

						GpiQueryPageViewport(hps,&rc);
						rc.xLeft   = 0;//xView / 2 ;
            rc.xRight  = xView ;
            rc.yBottom = 0;//yView / 2 ;
            rc.yTop    = yView;

            GpiSetPageViewport (hps, &rc) ;

						 switch (game_status)
							{
							case GAME_INTRO :
												stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE);
												stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE);
												stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE);
												zoom = (game_duration - 100)/3;
												if (zoom < 5)
													zoom = 5;
												D->angle += 10;
												D->zoom = zoom;
												R->angle += 10;
												R->zoom = zoom;
												I->angle += 10;
												I->zoom = zoom;
												F->angle += 10;
												F->zoom = zoom;
												T->angle += 10;
												T->zoom = zoom;
												game_duration --;
												if (game_duration == 0)
													{
                          game_status = GAME_HISCORE;
                          game_duration = 200;                          if (random(2) == 0)
                            {
                            // insert the hiscore table
													  insert_message(1800,0,"D R I F T  F O R  O S / 2  H I S C O R E S");
													  insert_message(1600,0,"Rank    Name          Score  Level");
													  for (tel = 0; tel < 10; tel++)
														  insert_message(1460-(tel*100),0,"%2d     %-12s %5d    %2d",tel+1,HiTable[tel].name,HiTable[tel].score,HiTable[tel].level);
                            }
                          else
                            {
                            // insert help message
                            insert_message(1800,0,"DRIFT WARPSPEED FOR OS/2 WARP");
                            insert_message(1600,0,"By Dirk Vandenheuvel /c/ 1995");
                            insert_message(1400,0,"Keys");
                            insert_message(1200,0,"UP                     Thrust");
                            insert_message(1100,0,"LEFT                Turn left");
                            insert_message(1000,0,"RIGHT              Turn right");
                            insert_message(900,0, "SPACE            Fire missile");
                            }
                          WinInvalidateRect(hwnd,NULL,TRUE);
													}
												else
													intro(hps);
												break;
							case GAME_HISCORE:
												game_duration --;
												if (game_duration == 0)
													{
													// free the effekts list
													free_all();
													game_status = GAME_INTRO;
													game_duration = 200;
													WinInvalidateRect(hwnd,NULL,TRUE);
													}
												break;
							case GAME_PLAYING: // play
												check_keys();
												if (game_shooting)
													game_shooting--;
												game(hps);
												break;
							}
               WinReleasePS(hps);
               break;
		 case WM_SYSCOMMAND:
							/*switch(mp1)
								{
								case SC_MINIMIZE:
											if (!game_pauze)
												SendMessage(hwnd,WM_COMMAND,IDM_PAUZE,0);
											break;
											}
								return(DefWindowProc(hwnd,messg,mp1,mp2));*/
								break;
		 case WM_COMMAND:
								switch (COMMANDMSG(&messg)->cmd)
									{
									case IDM_SAVEONEXIT:
															if (saveonexit == TRUE) // already checked
																{
																stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,FALSE);
																saveonexit = FALSE;
																save_settings(); // save the "do not save on exit" setting
																}
															else
																{
																stat = WinCheckMenuItem(hMenu,IDM_SAVEONEXIT,TRUE);
																saveonexit = TRUE;
																}
															break;
									case IDM_HIGHDET : // set to high
															game_bigex = 36;
															game_mediumex = 18;
															game_smallex = 9;
															maxthrustpixels = 9;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_MEDIUMDET:
															game_bigex = 18;
															game_mediumex = 18;
															game_smallex = 9;
															maxthrustpixels = 5;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_LOWDET:
															game_bigex = 9;
															game_mediumex = 9;
															game_smallex = 9;
															maxthrustpixels = 3;
															stat = WinCheckMenuItem(hMenu,detaillevel,FALSE);
															detaillevel=SHORT1FROMMP(mp1);
															stat = WinCheckMenuItem(hMenu,detaillevel,TRUE);
															break;
									case IDM_ABOUT:
															WinDlgBox(HWND_DESKTOP,hwnd,AboutDiaProc,NULLHANDLE,IDD_ABOUT,NULL);
															break;
									case IDM_HELP :
															//WinHelp (hwnd,"drift.hlp",HELP_INDEX,0);
															break;
									case IDVK_ESCAPE: // escape key pressed
															//SendMessage (hwnd, WM_SYSCOMMAND,SC_MINIMIZE,0);
															break;
									case IDM_PAUZE:
															if (game_status != GAME_PLAYING)
																break;
															if (game_pauze != TRUE)
																{
                                WinStopTimer(hab,hwndClient,idTimer);
                                stat = WinCheckMenuItem(hMenu,IDM_PAUZE,TRUE);
																game_pauze = TRUE;
																}
															else
																{
																game_pauze = FALSE;
																// gets a timer
																idTimer = WinStartTimer(hab,hwndClient,ID_TIMER,30);
																stat = WinCheckMenuItem(hMenu,IDM_PAUZE,FALSE);
																WinInvalidateRect(hwnd, NULL, TRUE);
																}
															break;
									case IDM_QUIT:
															stat = WinEnableMenuItem(hMenu,IDM_PLAY,TRUE);
															stat = WinEnableMenuItem(hMenu,IDM_QUIT,FALSE);
															stat = WinEnableMenuItem(hMenu,IDM_PAUZE,FALSE);
															free_all();
															game_status = GAME_INTRO;
															if (game_pauze)
																{
																game_pauze = FALSE;
																//while (!SetTimer(hwnd,ID_TIMER,10,NULL))
																//if (IDCANCEL == MessageBox (hwnd, "Cannot get timer handle!", szProgName,MB_ICONEXCLAMATION | MB_RETRYCANCEL))
																//exit(0); // add a better shutdown here
																//CheckMenuItem(hmenu,IDM_PAUZE,MF_UNCHECKED);
																}
															game_duration = 200;
															WinInvalidateRect(hwnd, NULL, TRUE);
															break;
									case IDM_PLAY:
															free_all();
															stat = WinEnableMenuItem(hMenu,IDM_PLAY,FALSE);
															stat = WinEnableMenuItem(hMenu,IDM_QUIT,TRUE);
															stat = WinEnableMenuItem(hMenu,IDM_PAUZE,TRUE);
															init_objekts();
															game_level = 1;
															// init powerups to default
															game_pauze = FALSE;
															game_maxshots = MAXSHOT;
															game_shots = 1;
															game_turning = 10;
															game_shotlife = 20;
															game_rearshot = FALSE;
															game_shieldduration = 0;
															init_game();
															game_status = GAME_PLAYING;
															game_score = 0;
															game_duration = 25;
                              game_life = 3;
															WinInvalidateRect(hwnd, NULL, TRUE);
															break;
									default:    break;
									}
									break;
			 case WM_PAINT:
									hps = WinBeginPaint(hwnd,NULLHANDLE,&rc);
									WinQueryWindowRect(hps,&rc);
            			WinFillRect(hps,&rc,CLR_BLACK);
                  sizel.cx = 2000 ;
                  sizel.cy = 2000 ;
            			GpiSetPS (hps, &sizel, PU_PELS) ;

									GpiQueryPageViewport(hps,&rc);
									rc.xLeft   = 0;//xView / 2 ;
            			rc.xRight  = xView ;
            			rc.yBottom = 0;//yView / 2 ;
            			rc.yTop    = yView;

            			GpiSetPageViewport (hps, &rc) ;
                  if (game_status == GAME_HISCORE)
                    hiscore(hps);
                  if (game_status == GAME_PLAYING && game_pauze)
										game(hps);
									WinEndPaint(hps);
									break;
        default:   return(WinDefWindowProc(hwnd,messg,mp1,mp2));
			 }
return(MRESULT)0L;
}