Beispiel #1
0
static int
        handleWEvents(char *defname)
{
  int     do_redraw = 0;
  char    ch;
  W_Event event;

  while (W_EventsPending())
    {
      W_NextEvent(&event);
      switch ((int) event.type)
  {
  case W_EV_EXPOSE:
    if (event.Window == w)
      do_redraw = 1;
    break;
  case W_EV_KEY:
    ch = event.key;
    if (!autolog)
      loginproced(ch, defname);
  }
    }

  if (do_redraw)
    {
      displayStartup(defname);
      showreadme();
    }
}
Beispiel #2
0
void    metainput(void)
/* Wait for actions in the meta-server window.
 *
 * This is really the meta-server window's own little input() function. It is
 * needed so we don't have to use all the bull in the main input(). Plus to
 * use it I'd have to call mapAll() first and the client would read in the
 * default server and then call it up before I can select a server. */
{
  W_Event data;

  (void) SIGNAL(SIGCHLD, sigchld);
  while (W_IsMapped(metaWin)) {
    while (1) {
      W_Flush();
      if (W_EventsPending()) break;
      if (ReadMetasRecv(W_Socket()) || metareap_needed) {
        metareap();
        metaHeight = num_servers + N_OVERHEAD;
        metawindow();
        W_Flush();
      }
      refresh_cyclic();
    }
    W_NextEvent(&data);
    switch ((int) data.type) {
    case W_EV_KEY:
      if (data.Window == metaList || data.Window == metaWin)
        if (key(&data)) return;
      if (data.Window == metaHelpWin) hide_help();
      break;
    case W_EV_BUTTON:
      if (data.Window == metaList)
        if (button(&data)) return;
      if (data.Window == metaHelpWin) hide_help();
      if (data.Window == metaWin && data.y < 200)
        W_NextScreenShot(metaWin, 0, 0);
      break;
    case W_EV_EXPOSE:
      if (data.Window == metaHelpWin) expo_help();
      if (data.Window == metaWin) {
        W_DrawScreenShot(metaWin, 0, 0);
        W_DrawImage(200, 9, logo);
      }
      break;
    case W_EV_CLOSED:
      if (data.Window == metaWin) {
        fprintf(stderr, "you quit, by closing the server list window\n");
        terminate(0);
      }
      break;
    default:
      break;
    }
  }
}
void
get_N_dispatch_outfit_event(int *team, int *s_type, int *lastplayercount)
{
    W_Event event;
    int     validshipletter = 0;
    static int resetting = 0;
    int     oldresetting;
    int     i;

    oldresetting = resetting;

    W_NextEvent(&event);
    switch ((int) event.type) {
    case W_EV_KEY:
	{
	    struct shiplist *shipscan;
	    validshipletter = 0;
	    shipscan = shiptypes;
	    while (shipscan) {
		if (shipscan->ship->s_letter == event.key) {
		    *s_type = shipscan->ship->s_type;
		    validshipletter = 1;
		    break;
		}
		shipscan = shipscan->next;
	    }
	}

	if (me->p_status == PTQUEUE) {
	    for (i = 0; i < WNUM; i++) {
		if (event.Window == messWin[i].window) {
		    messageWinEvent(&event);
		    break;
		}
	    }
	    if (i != WNUM)
		break;
	    if (event.Window == messagew ||
		event.Window == tstatw ||
		event.Window == warnw)
		smessage(event.key);
	}
	if (event.Window == motdWin) {
	    motdWinEvent(&event);
	    break;
	} else if (event.Window == playerw || event.Window == infow) {
	    /* allow 'i' 'I' and '^i' in playerw [BDyess] */
	    playerwEvent(&event);
	    break;
	} else if (event.Window == w || event.Window == mapw) {
	    switch (event.key) {
#ifdef Q_OUTFITTING
	    case 'q':
		*team = number_of_teams;
		me->p_status = PFREE;
		break;
#endif				/* Q_OUTFITTING */
	    case 'R':
		warning("Are you sure you want to reset your stats?");
		resetting = 1;
		break;
	    case 'y':
		if (resetting) {
		    sendResetStatsReq('Y');
		    warning("OK, your stats have been reset.");
		    resetting = 0;
		}
		break;
	    case 'n':
		if (resetting) {
		    warning("I didn't think so.");
		    resetting = 0;
		}
		break;

	    case 'f':		/* Scroll motd forward */
		if (currpage == NULL)
		    currpage = motddata;
		if (currpage == NULL || currpage->next == NULL)
		    break;
		currpage->next->prev = currpage;
		currpage = currpage->next;
		showMotd(w);
		resetting = 0;
		break;
	    case 'b':		/* Scroll motd backward */
		if (currpage == NULL || currpage->prev == NULL)
		    break;
		currpage = currpage->prev;
		showMotd(w);
		resetting = 0;
		break;
		/* ok, let's have some info windows available on the TQ */

	    default:		/* hmm, something that doesn't have to do
				   with the MOTD, maybe it's an info window
				   request */
		switch (doKeymap(&event)) {
		case 'U':	/* U = Rank list */
		    if (W_IsMapped(rankw)) {
			W_UnmapWindow(rankw);
		    } else {
			W_MapWindow(rankw);
		    }
		    break;
		case 'P':	/* P = Planet list */
		    if (W_IsMapped(planetw)) {
			W_UnmapWindow(planetw);
			W_UnmapWindow(planetw2);
		    } else {
			W_MapWindow(planetw);
			W_MapWindow(planetw2);
		    }
		    break;
		case 'h':	/* h = Map help window */
		    if (W_IsMapped(helpWin)) {
			W_UnmapWindow(helpWin);
		    } else {
			W_MapWindow(helpWin);
		    }
		    if (optionWin)
			optionredrawtarget(helpWin);
		    break;
		case 'O':	/* O = options Window */
		    if (optionWin != NULL && W_IsMapped(optionWin))
			optiondone();
		    else
			optionwindow();
		    break;
		case 'w':	/* w = map war stuff */
		    if (W_IsMapped(war))
			W_UnmapWindow(war);
		    else
			warwindow();
		    break;
		case '&':
		    if (defaultsFile) {
			char    buf[150];
			sprintf(buf, "Reading defaults from %s", defaultsFile);
			warning(buf);
			freeDefaults();
			defaultsFile = initDefaults(defaultsFile);
			resetDefaults();
		    } else {
			warning("No defaults file to read from!");
		    }
		}
		break;
	    }

	    break;		/* switch event type */
	}
	if (event.Window == qwin)
	    return;		/* normal keypresses can't make you quit */

	if (event.Window == optionWin) {
	    optionaction(&event);
	    return;
	}
	if (!validshipletter)
	    break;
	/*
	   it wasn't the main window, see if they hit the key in a team
	   window to choose their ship... falling through
	*/
    case W_EV_BUTTON:

	for (i = 0; i < number_of_teams; i++)
	    if (event.Window == teamWin[i]) {
		*team = i;
		break;
	    }
	if (event.Window == qwin) {
	    *team = number_of_teams;
	    me->p_status = PFREE;
	    break;
	}
	/* allow message scrollback [BDyess] */
	for (i = 0; i < WNUM; i++) {
	    if (event.Window == messWin[i].window) {
		messageWinEvent(&event);
		break;
	    }
	}
	/* allow bozo selection in playerw [BDyess] */
	if (event.Window == playerw) {
	    playerwEvent(&event);
	    break;
	} else if (event.Window == war)
	    waraction(&event);
	else if (event.Window == optionWin)
	    optionaction(&event);
	else if (event.Window == motdWin)
	    motdWinEvent(&event);
	else if (event.Window == w) {
	    W_Window tmp = motdWin;
	    motdWin = w;
	    motdWinEvent(&event);
	    motdWin = tmp;
	}
	if (*team != -1 && !teamRequest(*team, *s_type)) {
	    *team = -1;
	}
	break;
    case W_EV_EXPOSE:
	for (i = 0; i < number_of_teams; i++)
	    if (event.Window == teamWin[i]) {
		lastplayercount[i] = -1;	/* force update */
		redrawTeam(teamWin[i], i, &lastplayercount[i]);
		break;
	    }
	if (event.Window == qwin)
	    redrawQuit();
	else if (event.Window == w)
	    showMotd(w);
	else if (event.Window == mapw) {
		showValues(mapw);
	    redraw_death_messages();
	} else
	    /* let the normal expose handler figure out who to redraw */
	    dispatch_W_expose_event(&event);
	break;
    case W_EV_KILL_WINDOW:	/* WM_DESTROY_WINDOW support [BDyess] */
        if(event.Window == baseWin) exit(0);
	else W_UnmapWindow(event.Window);
	break;
    }

    if (oldresetting && resetting) {
	resetting = 0;
	warning("Resetting of stats cancelled");
    }
}
Beispiel #4
0
findslot(void)
{
  int     oldcount = -1;
  W_Window waitWin, qwin, countWin, motdButtonWin;

  W_Window motdWin;
  extern int MaxMotdLine;
  int     WaitMotdLine = 0;
  int     mapMotd = booleanDefault("showMotd", 1);
  W_Event event;


  /* Wait for some kind of indication about in/not in */
  while (queuePos == -1)
    {
      socketPause();
      if (isServerDead())
  {

#if defined(SOUND) && !defined(HAVE_SDL)
    Exit_Sound();
#endif

    printf("Shit!  Ghostbusted!\n");
    terminate(0);
  }
      readFromServer(NULL);
      if (me != NULL)
  {
    /* We are in! */
    ANNOUNCESOCKET;
    return (me->p_no);
  }
    }

  /* We have to wait.  Make appropriate windows, etc... */

  waitWin = W_MakeWindow("wait", 0, 0, WAITWIDTH, WAITHEIGHT, NULL, 2,
       foreColor);
  countWin = W_MakeWindow("count", WAITWIDTH / 3, WAITTITLE, WAITWIDTH / 3,
        WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor);
  qwin = W_MakeWindow("waitquit", 0, WAITTITLE, WAITWIDTH / 3,
          WAITHEIGHT - WAITTITLE, waitWin, 1, foreColor);
  motdButtonWin = W_MakeWindow("motdbutton", 2 * WAITWIDTH / 3, WAITTITLE,
           WAITWIDTH / 3, WAITHEIGHT - WAITTITLE, waitWin,
             1, foreColor);
  W_MapWindow(waitWin);
  W_MapWindow(countWin);
  W_MapWindow(motdButtonWin);
  W_MapWindow(qwin);
  if (mapMotd)
    {
      motdWin = W_MakeWindow("waitmotd", 1, WAITWIDTH + 1, TWINSIDE,
           TWINSIDE, 0, 2, foreColor);
      W_MapWindow(motdWin);
      showMotd(motdWin, WaitMotdLine);
    }

  for (;;)
    {
      socketPause();
      readFromServer(NULL);
      if (isServerDead())
  {

#if defined(SOUND) && !defined(HAVE_SDL)
    Exit_Sound();
#endif

    printf("Damn, We've been ghostbusted!\n");
    terminate(0);
  }
      while (W_EventsPending())
  {
    W_NextEvent(&event);
    switch ((int) event.type)
      {
      case W_EV_BUTTON:
      case W_EV_KEY:
        if (mapMotd && event.Window == motdWin)
    {
      if (event.key == ' ' || event.key == 'q')
        {
          W_DestroyWindow(motdWin);
          mapMotd = !mapMotd;
        }
      else
        {
          if (event.key == 'b')
      {
        WaitMotdLine -= 28;
        WaitMotdLine = MAX(WaitMotdLine, 0);
      }
          else
      {
        WaitMotdLine += 28;
        /* scroll to start if it goes over */
        if (WaitMotdLine > MaxMotdLine)
          WaitMotdLine = 0;
      }
          W_ClearWindow(motdWin);
          showMotd(motdWin, WaitMotdLine);
          break;
        }
    }
        else if (event.Window == motdButtonWin)
    {
      if (mapMotd)
        {
          W_DestroyWindow(motdWin);
        }
      else
        {
          motdWin = W_MakeWindow("waitmotd", 1, WAITWIDTH + 1,
               TWINSIDE, TWINSIDE, 0, 2,
               foreColor);
          W_MapWindow(motdWin);
          showMotd(motdWin, WaitMotdLine);
        }
      mapMotd = !mapMotd;
    }
        else if (event.Window == qwin)
    {

#if defined(SOUND) && !defined(HAVE_SDL)
      Exit_Sound();
#endif

      printf("OK, bye!\n");
      terminate(0);
    }
        break;
      case W_EV_EXPOSE:
        if (event.Window == waitWin)
    {
      mapWaitWin(waitWin);
    }
        else if (event.Window == motdWin)
    {
      showMotd(motdWin, WaitMotdLine);
    }
        else if (event.Window == qwin)
    {
      mapWaitQuit(qwin);
    }
        else if (event.Window == countWin)
    {
      mapWaitCount(waitWin, countWin, queuePos);
    }
        else if (event.Window == motdButtonWin)
    {
      mapWaitMotdButton(motdButtonWin);
    }
        break;
      default:
        break;
      }
  }
      if (queuePos != oldcount)
  {
    mapWaitCount(waitWin, countWin, queuePos);
    oldcount = queuePos;
  }
      if (me != NULL)
  {
    W_DestroyWindow(waitWin);
    if (mapMotd)
      {
        W_DestroyWindow(motdWin);
      }
    ANNOUNCESOCKET;
    W_Beep();
    W_Beep();
    return (me->p_no);
  }
    }
}