Exemple #1
0
void initGLGui() {
  glShadeModel(GL_FLAT);
  glDisable(GL_BLEND);
  glDisable(GL_LIGHTING);
  glDisable(GL_DEPTH_TEST);
  SystemPostRedisplay();
}
Exemple #2
0
void idleGui(void) {
	Sound_idle();
	scripting_RunGC();
	SDL_Delay(10);
	Video_Idle();
	Input_Idle();
	SystemPostRedisplay(); /* animate menu */
}
Exemple #3
0
void keyboardGui(int key, int unicode, int x, int y) {
  int i;
  switch(key) {
  case 27:
#ifdef SOUND
    if(game->settings->playEffects)
      playMenuFX(fx_action);
#endif
    if(pCurrent->parent == NULL)
      restoreCallbacks();
    else
      pCurrent = pCurrent->parent;
    break;
  case 13: case ' ':
#ifdef SOUND
    if(game->settings->playEffects)
      playMenuFX(fx_action);
#endif
    menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_ACTION);
    break;
  case SYSTEM_KEY_LEFT:
    menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_LEFT);
    break;
  case SYSTEM_KEY_RIGHT:
    menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_RIGHT);
    break;
    /* case 'q': SystemExit(); break; */
  case SYSTEM_KEY_DOWN:
#ifdef SOUND
    if(game->settings->playEffects)
      playMenuFX(fx_highlight);
#endif
    pCurrent->iHighlight = (pCurrent->iHighlight + 1) % pCurrent->nEntries;
    break;
  case SYSTEM_KEY_UP:
#ifdef SOUND
    if(game->settings->playEffects)
      playMenuFX(fx_highlight);
#endif
    pCurrent->iHighlight = (pCurrent->iHighlight - 1) % pCurrent->nEntries;
    if(pCurrent->iHighlight < 0)
      pCurrent->iHighlight = pCurrent->nEntries - 1;
    break;
  case SYSTEM_KEY_F11: doBmpScreenShot(); break;
  case SYSTEM_KEY_F12: doScreenShot(); break;
    /* debug code follows */
  case 'l':
    printf("%d entries:\n", pCurrent->nEntries);
    for(i = 0; i < pCurrent->nEntries; i++)
      printf("printing '%s' - %d entries\n",
	     ((Menu*)*(pCurrent->pEntries + i))->szName,
	     ((Menu*)*(pCurrent->pEntries + i))->nEntries);
    break;
  default: printf("got key %d\n", key);
  }
  SystemPostRedisplay();
}
Exemple #4
0
void GameMode_Idle(void) {
    Sound_idle();
    Time_Idle();
    if(game2->time.dt == 0)
        return;
    Game_Idle();
    Video_Idle();
    Input_Idle();
    Scripting_Idle();
    SystemPostRedisplay();
}
Exemple #5
0
void guiMouse(int buttons, int state, int x, int y) {
  fprintf(stderr, "Mouse buttons: %d, State %d, Position (%d, %d)\n",
	  buttons, state, x, y); 

  /* fprintf(stderr, "testing for state == %d\n", SYSTEM_MOUSEPRESSED); */
  if (state == SYSTEM_MOUSEPRESSED) {	
#ifdef SOUND
    if(game->settings->playEffects)
      playMenuFX(fx_action);
#endif	
    menuAction(*(pCurrent->pEntries + pCurrent->iHighlight), MENU_ACTION);
    SystemPostRedisplay();
  }
}
void
idleTracker()
{
  int sockstat = socksnotready;
  int i;
  //float pingf;
  //short *ping=malloc(sizeof(short));
  int ping;
  //char str[255];

  sockstat = Net_checksocket(Net_gettrackersock());

  while(  ready_ping() )
    {
      handle_ping(servers);


      for(i=0; i<nbservers; ++i)
	{
	  printf("%d %d\n", servers[i].ping, servers[i].packets);
	  if( servers[i].packets > 0 )
	    {
	      printf("new ping is %d ( %d )\n", servers[i].ping, servers[i].packets);
	      
	      //sprintf(str, "%d", servers[i].ping/servers[i].packets);
	      ping = (servers[i].ping/servers[i].packets)*1;
	      //*ping = (int)(pingf);
	      //(*ping)=(int)(pingf)*1;
	      printf("ping is %d\n", ping);
	      /*********************************************************v****/
	      setCell_wlist ( tracker.serverlist, (char *)&ping, sizeof(int), i, 3 );
	      rebuildindex_wlist(tracker.serverlist);
	    }
	}	  
    }
  //free(ping);

  if( sockstat != socksnotready )
    {
      if( sockstat & tcpsockready )
	{
	  tracker_handle();
	}
    }

  
  SystemPostRedisplay();
}
Exemple #7
0
void idlePause() {
#ifdef SOUND
  soundIdle();
#endif
  /* 
  if(SystemGetElapsedTime() - lasttime < 10) return;
  timediff();
  */
  doCameraMovement();
  if(game->settings->screenSaver && stoptime != 0 &&
     SystemGetElapsedTime() - stoptime > 2000) {
    initData();
    stoptime = 0;
    switchCallbacks(&gameCallbacks);
  }
  SystemPostRedisplay();
}
Exemple #8
0
void idlePause() {
#ifdef __NETWORK__
  int sockstat;
#endif


#ifdef SOUND
  soundIdle();
#endif

#ifdef __NETWORK__
  if( game2->mode == GAME_NETWORK_PLAY && serverstate == gameState )
    {
      initTurnList();
      stoptime = 0;
      switchCallbacks(&gameCallbacks);
    } else {
      if( game2->mode == GAME_NETWORK_PLAY && isConnected )
	{
	  sockstat = Net_checksocks();
	  if( sockstat != socksnotready ) 
	    {
	      if( sockstat & tcpsockready )
		handleServer();
	    }
	}
    }
#endif

  /* 
  if(SystemGetElapsedTime() - lasttime < 10) return;
  timediff();
  */
  doCameraMovement();
  if(game->settings->screenSaver && stoptime != 0 &&
     SystemGetElapsedTime() - stoptime > 2000) {
    initData();
    stoptime = 0;
    switchCallbacks(&gameCallbacks);
  }
  SystemPostRedisplay();
}
void idleNetwait() {
    SystemPostRedisplay();
}
Exemple #10
0
void idleGame( void ) {
  list *l;
  list *p;
  int i;
  int dt;
  int t;

#ifdef SOUND
  // Audio_Idle();
  soundIdle();
#endif

  if(updateTime() == 0) return;
  switch(game2->mode) {
  case GAME_NETWORK_RECORD:
#ifdef NETWORK
    updateNet();
#endif
    /* fall through */
  case GAME_SINGLE:
  case GAME_SINGLE_RECORD:
    /* check for fast finish */
    if(game->settings->fast_finish == 1) {
      int factor = 4;
      for(i = 0; i < game->players; i++) {
	if(game->player[i].ai->active != 1 &&
	   game->player[i].data->exp_radius < EXP_RADIUS_MAX)
	  factor = 1;
      }
      dt = game2->time.dt * factor;
    } else  
      dt = game2->time.dt;

    while(dt > 0) {
      if(dt > PHYSICS_RATE) t = PHYSICS_RATE;
      else t = dt;

      /* run AI */
      for(i = 0; i < game->players; i++)
	if(game->player[i].ai != NULL)
	  if(game->player[i].ai->active == 1 &&
	     game->player[i].data->speed > 0) {
	    if(game->settings->ai_level < 2)
	      doComputer(i, 0);
	    else 
	      doComputer2(i, 0);
	  }

      /* process any outstanding events (turns, etc) */
      for(p = &(game2->events); p->next != NULL; p = p->next) {
	if(processEvent((GameEvent*) p->data)) return;
      }

      /* free events */
      p = game2->events.next;
      while(p != NULL) {
	l = p;
	p = p->next;
	free(l);
      }
      game2->events.next = NULL;

      l = doMovement(1, t); /* this can generate new events */
      if(l != NULL) {
	for(p = l; p->next != NULL; p = p->next) {
	  if(processEvent((GameEvent*) p->data));
	}

      }
      /* free list  */
      p = l;
      while(p != NULL) {
	l = p;
	p = p->next;
	free(l);
      }
      dt -= PHYSICS_RATE;
    }
    break;
  case GAME_PLAY_NETWORK:
#ifdef NETWORK
    updateNet();
    /* broadCast any outstanding events (turns, etc) */
    for(p = &(game2->events); p->next != NULL; p = p->next) {
      sendNetEvent((GameEvent*) p->data);
    }
#endif
    /* fall through to GAME_PLAY */
  case GAME_PLAY:
    getEvents(); 
    l = doMovement(0, game2->time.dt); /* this won't generate new events */
    if(l != NULL) {
      fprintf(stderr, "something is seriously wrong - ignoring events\n");
    }
    break;
  }
    
  doCameraMovement();
  recognizerMovement();

  SystemPostRedisplay();
  /* fprintf(stderr, "game time: %.3f\n", game2->time.current / 1000.0); */
}
Exemple #11
0
void idleCredits() {
  SystemPostRedisplay();
}
Exemple #12
0
void guiMouseMotion(int mx, int my) {
  /* fprintf(stderr, "Mouse motion at (%d, %d)\n", x, y); */
 
  /* I am using the calculation in drawMenu, perhaps
     these values should be bound to Menu structure in the future. */

  /* TODO: this is cut-and-paste from menu.c: VERY UGLY */
  int i;
  int x, y, size, lineheight;
  int hsize, vsize;
  int maxw = 0;

#define MENU_TEXT_START_X 0.08
#define MENU_TEXT_START_Y 0.40

#define MENU_WIDTH 0.80
#define MENU_HEIGHT 0.40

#define MENU_TEXT_LINEHEIGHT 1.5
	
  gDisplay *d = game->screen; 
	
  x = (int) (d->vp_w * MENU_TEXT_START_X);
  y = (int) (d->vp_h * MENU_TEXT_START_Y);

  /* transform mouse y-coordinate */

  my = d->vp_h - my;

  /* new stuff: calculate menu dimensions */
  for(i = 0; i < pCurrent->nEntries; i++) {
    int len;
    len =  strlen(((Menu*)*(pCurrent->pEntries + i))->display.szCaption);
    if(len > maxw)
      maxw = len;
}
  /* adjust size so menu fits into MENU_WIDTH/HEIGHT */

  hsize = (int) ((float)d->vp_w * MENU_WIDTH / (float)maxw );
  vsize = (int) ((float)d->vp_h * MENU_HEIGHT / 
		 ( (float)pCurrent->nEntries * MENU_TEXT_LINEHEIGHT));

  size = (hsize < vsize) ? hsize : vsize;

  lineheight = (int)( (float) size * MENU_TEXT_LINEHEIGHT);  

  for (i = 0; i < pCurrent->nEntries; i++) {
    if (current_highlight != i)
      if (my < y + lineheight && my > y ) {
	current_highlight = i;

#ifdef SOUND
	if(game->settings->playEffects)
	  playMenuFX(fx_highlight);
#endif
	pCurrent->iHighlight = i;
	SystemPostRedisplay ();
	break;	
      }
 		
    y -= lineheight;
  }
}
Exemple #13
0
void idleGui() {
#ifdef SOUND
  soundIdle();
#endif
  SystemPostRedisplay(); /* animate menu */
}
Exemple #14
0
void idleCredits() {
  scripting_RunGC();
  SystemPostRedisplay();
}