Beispiel #1
0
static int playagain_menu(const char **menu, int x, int y)
{
	int ret = openmenu(menu, 2, 0, x, y, NULL);
	if (ret==2)
		exit(0);
	return ret;
}
Beispiel #2
0
void options_menu(const char **items, int n, menuhandler f, int x, int y)
{
	const char *menu[8] = {"Input Setup", "-"};
	char tetr_colors[18] = "Tetromino Colours";
	menuhandler handlers[8] = {rarrow_menuitem};
	int i = 1;
	memcpy(&menu[2], items, n*sizeof(char *));
	while (i <= n)
		handlers[++i] = f;
#if !NO_BLOCKSTYLES
	menu[++i] = "Block Style";
	handlers[i] = f;
	n++;
#endif
	menu[++i] = "Board BG";
	handlers[i] = op_bgdot;
	spellword(tetr_colors+10);
	menu[++i] = tetr_colors;
	handlers[i] = rarrow_menuitem;
	n += 4;
	i = 0;
	while (i = openmenu(menu, n, i, x, y, handlers)) {
		i--;
		if (!i) {
			f(op_inputsetup_select(x, y), &i);
			inputdevs_player[0] = 0;
		} else if (i == n-1)
			tetrom_colors_menu(x, y+i+1);
		else if (!handlers[i](STARTBTN, &i))
			break;
	}
	clearbox(x, y, 0, n);
}
Beispiel #3
0
int openmenu(const char **menu, int n, int i, int x, int y,
	     menuhandler *handlers)
{
	drawmenu(menu, n, i, x, y, handlers);
	while (1) {
		setcurs(x, y+i);
		refreshwin(-1);		/* refresh active window */

		switch (handle_menuitem(menu, n, &i, x, y+i, handlers,
					getkeypress_block(SINGLE_PL))) {
		case 0:
			return 0;
		case 2:
			return i+1;
#if !NO_MENU
		case 3:
			return openmenu(menu, n, i, x, y, handlers);
#endif
		}
	}
}
Beispiel #4
0
int startup_menu(int i, int x, int y)
{
	union val v;
	const char *menu[7] = {
		"1-Player Game",
		"2-Player Game",
#ifdef INET
		"Netplay",
#endif
		"Mode",
		"-------------",
		"Options",
		"Highscores"
	};
	menuhandler handlers[7] = {0, 0,
#ifdef INET
		0,
#endif
		gm_mode};
	i = openmenu(menu,
#ifdef INET
				1 +
#endif
				6, i, x, y, handlers);
	if (i && i <= 3) {
#ifdef INET
		if (i==3)
			v.integ = MODE_2PLAYER | MODE_NETWORK;
		else
#endif
		v.integ = i;
		v.integ |= getopt_int("", "mode") & MODE_BTYPE;
		setoption("", "mode", v, 0);
	}
	return i;
}
Beispiel #5
0
static int initudm (char *filename, char *scale)
{
	register n;
	register char *p;
	int fd;
	char buf [BUFSZ];

	fd = openmenu (filename);
	if (fd < 0) {
		error ("Menu not found");
		return (0);
	}
	nm = 0;
	bufp = buf;
	n = read (fd, buf, sizeof (buf) - 1);
	close (fd);
	if (n <= 0) {
		error ("Cannot read menu");
		return (0);
	}
	buf [n] = 0;
	bufp = buf;
	if (*bufp == '#')
		skipln ();

	for (n=0; n<128; ++n)
		scale [n] = MENUSZ+1;

	menuwid = 1;
	for (nm=0; nm<MENUSZ && (n = getkey ()); ++nm) {
		scale [n] = nm;
		um[nm].key = n;
		um[nm].wait = um[nm].hist = 1;
		um[nm].menu = 0;
		um[nm].str = getstr ();
		if (um[nm].str && (n = strlen (um[nm].str)) > menuwid)
			menuwid = n;
		um[nm].cmd = getcmd ();
		if (um[nm].cmd) {
			p = um[nm].cmd;
			/* if ((n = strlen (um[nm].cmd)) > menuwid) */
				/* menuwid = n; */
			if (*p == '!') {
				um[nm].menu = 1;
				++p;
			}
			if (*p == '-') {
				um[nm].wait = 0;
				++p;
			}
			if (*p == '@') {
				um[nm].hist = 0;
				++p;
			}
			um[nm].cex = p;
		}
	}
	if (! nm) {
		error ("Menu is empty");
		return (0);
	}
	menuwid += 6;
	if (menuwid > 70)
		menuwid = 70;
	menurow = (LINES-nm) / 2;
	menucol = (79-menuwid) / 2;
	return (1);
}
Beispiel #6
0
static void manualcheck(char skip)
  {
  static unsigned char encodedat[1510]="Put the copy protection here! ";
  unsigned char count=0;
  unsigned char lin,wor;
  unsigned int head,count2=0;
  unsigned char answer[14] = "",answeren[14]= "",temp[10] = "";
  register int i;
  char str[25];
  FILE *fp;
  
  count=(random(87)+91);
  if (skip)
    {
    gmmain();
    return;
    }
// Why chmodded?
/*  if (chmod("playgame.exe",S_IREAD|S_IWRITE))
    {
    if (errno == ENOENT) errorbox("Please run this application in the GM directory","                 (E)xit");
    else errorbox("Cannot Run PLAYGAME.EXE","     (E)xit");
    return;
    }
*/
  if ((fp = fopen ("playgame.exe","r+b")) == NULL)
    {
    errorbox("This application must be run from","the GM directory!     (E)xit");
    return;
    }
  fseek(fp,PLAYBYTE,SEEK_SET);
  count = fgetc(fp);
  count-=90;
  if ( (count<1) || (count>88) ) count=(random(87)+1);
  fseek(fp,PLAYBYTE,SEEK_SET);
  count2=(random(87)+91);
  if (fputc(count2,fp) == EOF)
    {
    errorbox("Cannot Find PLAYGAME.EXE","     (E)xit");
    fclose(fp);
    return;
    }
  fclose(fp);
  SetDate();
  count2=0;
  while ( (encodedat[count2] != count) && (count2<970) )
    {
    if (encodedat[count2] < 88)
      {                    /* eliminate possibility of head(int) bytes */
      count2+=5;
      }
    else count2++;  
    }
  if (count2>=970)
    {
    errorbox("Data Corrupted!","Reinstall from original disks.");
    return;
    }
  lin=encodedat[count2+1]-101;
  wor=encodedat[count2+2]-150;
  head=(*(unsigned int *) (&encodedat[count2+3]))/10;
  count2+=5; i=0;
  while(encodedat[count2+i]!=(count+1))
    {
    answer[i] = (encodedat[count2+i]-11-(count%57))/2;
    i++;
    }
  answer[i]=0;
  sprintf((char far *)temp,"%d",head);
  i=0;
  while (temp[i] != 0) i++;
  temp[2*i-1]=0;
  while (i != 0)
    {
    i--;
    temp[2*i]=temp[i];
    temp[2*i-1]='.';
    }
  count2 = openmenu(14,3,50,10,(char far *)encodedat);
  for (i=0;i<3;i++)
    {
    writestr(15,3,count2+15,"   Please enter the following informantion.");
    writestr(15,4,count2+14,"       OR send in your registration card");
    writestr(15,5,count2+14,"             to skip this hassle!");
    writestr(15,7,count2+15,"Count every line with text, not including");
    writestr(15,8,count2+15,"numbered headings. (\"Game-maker\" is one word).");
    sprintf(str,"Section: %s",temp);
    writestr(15,10,count2+14,str);
    sprintf(str,"Line: %d",lin);
    writestr(15,11,count2+14,str);
    sprintf(str,"Word: %d",wor);
    writestr(15,12,count2+14,str);
    qwindow(24,15,15,"Word Found: ",(char far *)answeren);
    if (stricmp((char far *)answeren,(char far *)answer) != 0)
      {
      if (i<2) 
        {
        errorbox("THAT IS INCORRECT","(R)etry");
        answeren[0]=0;
        }
      else
        {
        closemenu(14,3,50,10,(char far *)encodedat);
        errorbox("THAT IS INCORRECT","(E)xit");
        if ((fp = fopen ("playgame.exe","r+b")) == NULL)
          {
          errorbox("This application must be run from","the GM directory!     (E)xit");
          return;
          }
        fseek(fp,PLAYBYTE,SEEK_SET);
        count+=90;
        if (fputc(count,fp) == EOF)
          errorbox("Cannot Find PLAYGAME.EXE","     (E)xit");
        fclose(fp);
        SetDate();
        return;
        }
      }
    else i=3;
    }
  closemenu(14,3,50,10,(char far *)encodedat);
  gmmain();
  }