void NetPlayerInfoView::calc_view_width_height()
{
	view_width_ = 0;
	int height = 0;
	if (player_pic_)
	{
		view_width_ = max(view_width_, player_pic_->get_width());
		height += player_pic_->get_height() + margin_;
	}

	Gobang::set_font(Gobang::font_default, name_font_size_, true);
	if (player_name_.length() > 0)
	{
		view_width_ = max(view_width_, textwidth(player_name_.c_str()));
		height += textheight(player_name_.c_str()) + margin_;
	}

	Gobang::set_font(Gobang::font_default, ready_font_size_);
	if(is_ready_)
	{
		view_width_ = max(view_width_, textwidth("Ready!"));
		height += textheight("Ready!") + margin_;
		if (is_playing_)
		{
			view_width_ = max(view_width_, playing_indicator_->get_width());
			height += playing_indicator_->get_height() + margin_;
		}
	}
	else if (!is_opposite_)
	{
		view_width_ = max(view_width_, button_ready_->get_width());
		height += button_ready_->get_height() + margin_;
	}
	view_height_ = height;
}
Ejemplo n.º 2
0
void popup()
{
    int x1,x2,y1,y2, i,
        nRec = 13; // Numero de rectangulos
    x1 = x2 = (WIDTH/2);
    y1 = y2 = (HEIGHT/2);

    setfillstyle(1,0x00CCFF);
    for(i=0; i<nRec; x1-=15, y1-=10, x2+=15, y2+=10, i++)
    {
        bar(x1, y1, x2, y2);
        delay(15);
    }

    // ¡PERDISTE!
    setbkcolor(0x00CCFF);
    setcolor(0x0054D3);
    settextstyle(3, HORIZ_DIR, 6);
    outtextxy(WIDTH/2-textwidth("¡PERDISTE!")/2, y1+textheight("P")/2, "¡PERDISTE!");

    setcolor(0x4b78F2);
    settextstyle(3, HORIZ_DIR, 3);
    outtextxy(WIDTH/2-textwidth("Presiona cualquier tecla")/2, y1+textheight("P")*4, "Presiona cualquier tecla");

    settextstyle(3, HORIZ_DIR, 3);
    outtextxy(WIDTH/2-textwidth("para continuar")/2, y1+textheight("P")*5, "para continuar");
}
Ejemplo n.º 3
0
/*************************************************************************
 *
 *N  displaymessage
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays a list of text strings in a
 *     popup text window.  The list must be NULL-terminated.  Must be in
 *     graphics mode to call this function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    string <input> == (char *) first text string to be displayed.
 *    ... <input> == (char *) variable list of text strings to be displayed.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels    August 1991                        DOS Turbo C
 *E
 *************************************************************************/
void displaymessage( char *string, ... )
{
   int         i,maxw,height,x,y,pad, nlines;
   panel_type  panel;
   char **text;
   va_list arglist;

   va_start(arglist,string);
   nlines = 1;
   while (va_arg(arglist,char *)) nlines++;
   va_end(arglist);

   text = (char **)vpfmalloc((nlines+1)*sizeof(char *));
   text[0] = string;
   va_start(arglist,string);
   for (i=1;i<nlines;i++) {
      text[i] = va_arg(arglist,char *);
   }
   va_end(arglist);

   settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
   maxw = 0;
   height = 0;
   for (i=0;i<nlines;i++) {
      if (textwidth(text[i]) > maxw) maxw = textwidth(text[i]);
      height = height + textheight(text[i]) + 5;

   }
   if (maxw < (textwidth("Continue") + 10))
      maxw = textwidth("Continue") + 10;
   pad = (maxw*10)/100;
   maxw = maxw + (2*pad);
   if (maxw > getmaxx())
     maxw = getmaxx() - 8;
   height = height + 2*(textheight("Continue") + 5) + 5;

   create_panel( &panel, maxw, height, menucolor, menubordercolor );
   x = pad;
   y = 0;
   for (i=0;i<nlines;i++) {
      y = y + textheight(text[i]) + 5;
      create_label( text[i], x, y, SMALL_FONT, 4, menutextcolor, &panel );
   }
   y = height - (textheight("Continue") + 6);
   x = (maxw - (textwidth("Continue") + 10))/2;
   create_button( 27, "Continue", x, y, SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );

   get_display_position( &x, &y, panel.window );

   display_panel( &panel, x, y );
   i = process_panel( &panel, i );

   destroy_panel( &panel );
   close_panel( &panel );

   free(text);
}
Ejemplo n.º 4
0
help()
{
	char *menu[]={"How To Play","Selecting Option","Credits","About Me","Back"};
	int w=0,k,g=130,h=200;
	setbkcolor(0);
	settextstyle(3,0,3);
	setpos(0,0);
	viewport();
	settextstyle(7,0,5);
	setcolor(14);
	outtextxy(245,100,"HELP");
	settextstyle(1,0,2);
	setcolor(8);
	for(k=0;k<5;k++)
	{
		outtextxy(g,h,menu[k]);
		h+=textheight(menu[k])+10;
	}
	setpos(0,0);
	status("Select Any one using mouse pointer");

	while(1)
	{
		pos(&button,&n,&m);
		w=opt2(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<5;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;
			}
		}
		if(kbhit())
			goto pr;
	}
      //	getch();
	pr:
	return 0;
}
Ejemplo n.º 5
0
const char *drawtext(rect r, int alignment, const char *s)
{
    int h;
    int nlines;
    int line_height;
    int u = 0;
    rect clip;
    const char *remains;
    char line[256];

    initapp(0,0);
    if (! s) return (char *) NULL;
    if (! current->fnt)
	current->fnt = SystemFont;

    clip = getcliprect();
    setcliprect(r);

    line_height = getheight(current->fnt);

    if ((alignment & VCenter) == VCenter) {
	h = textheight(r.width, s);
	if (h < r.height)
	    r.y += (r.height-h)/2;
    }
    else if ((alignment & VJustify) == VJustify) {
	h = textheight(r.width, s);
	if (h < r.height) {
	    nlines = h / line_height;
	    if (nlines > 1)
		line_height += ((r.height-h) / (nlines-1));
	}
    }
    else if ((alignment & AlignBottom) == AlignBottom) {
	h = textheight(r.width, s);
	if (h < r.height)
	    r.y += (r.height-h);
    }

    u = (alignment & Underline);

    if ((alignment & Center) == Center)
	remains = draw_text_centered(line, r, line_height, u, s);
    else if ((alignment & Justify) == Justify)
	remains = draw_text_justified(line, r, line_height, u, s);
    else if ((alignment & AlignRight) == AlignRight)
	remains = draw_text_right(line, r, line_height, u, s);
    else
	remains = draw_text_left(line, r, line_height, u, s);

    setcliprect(clip);
    return remains;
}
Ejemplo n.º 6
0
/*************************************************************************
 *
 *N  yes_no
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays a panel asking the user a yes or no
 *     question and returns the response.  Must be in graphics mode to call
 *     this function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    text     <input>==(char *) question string.
 *    return  <output>==(int) yes (TRUE) or no (FALSE).
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels   May 1991                    DOS Turbo C
 *E
 *************************************************************************/
int yes_no( char *text )
{
   panel_type  panel;
   int         no_id = 27;
   int         yes_id = 13;
   int         x,y,width,height,maxheight,id=0;

   settextstyle( SMALL_FONT, HORIZ_DIR, 4 );

   width = 0;
   maxheight = 0;
   width = textwidth(text);
   maxheight = textheight(text);

   width = width + 50;
   if (width > getmaxx())
      width = getmaxx()-10;
   height = maxheight * 5;

   create_panel( &panel,width,height,menucolor,menubordercolor );

   y = maxheight;
   create_label( text,CENTER,y,SMALL_FONT,4,menutextcolor,&panel );
   y += maxheight;

   create_button( yes_id, "Yes",
		  3, height-textheight("Y")-6,
		  SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );
   create_button( no_id, "No",
		  width-textwidth("No")-13,
		  height-textheight("No")-6,
		  SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );

   get_display_position( &x, &y, panel.window );

   display_panel( &panel, x,y );

   id = process_panel(&panel, id);

   destroy_panel( &panel );
   close_panel( &panel );

   if (id == yes_id)
      return TRUE;
   else
      return FALSE;
}
void NetPlayerInfoView::show()
{
	if (buffer_img_.img)
	{
		putimage(buffer_img_.x, buffer_img_.y, buffer_img_.img);
		delimage(buffer_img_.img);
		buffer_img_.img = NULL;
	}
	calc_view_width_height();
	buffer_img_.x = pos_x_;
	buffer_img_.y = pos_y_;
	int temp_viewport_left, temp_viewport_right, temp_viewport_top, temp_viewport_bottom;
	getviewport(&temp_viewport_left, &temp_viewport_top, &temp_viewport_right, &temp_viewport_bottom);
	setviewport(pos_x_, pos_y_, pos_x_ + view_width_, pos_y_ + view_height_);
	buffer_img_.img = newimage(view_width_, view_height_);
	putimage(buffer_img_.img, 0, 0, NULL);
	setviewport(temp_viewport_left, temp_viewport_top, temp_viewport_right, temp_viewport_bottom);

	int target_top = pos_y_;
	if (player_pic_)
	{
		player_pic_->show_image_with_alpha(pos_x_ + view_width_ / 2 - player_pic_->get_width() / 2, target_top, 1.0);
		target_top += player_pic_->get_width() + margin_;
	}

	setcolor(WHITE);
	if (player_name_.length() > 0)
	{
		Gobang::set_font(Gobang::font_default, name_font_size_, true);
		xyprintf(pos_x_ + view_width_ / 2 - textwidth(player_name_.c_str()) / 2, target_top, player_name_.c_str());
		target_top += textheight(player_name_.c_str()) + margin_;
	}

	if (is_ready_)
	{
		Gobang::set_font(Gobang::font_default, ready_font_size_);
		xyprintf(pos_x_ + view_width_ / 2 - textwidth("Ready!") / 2, target_top, "Ready!");
		target_top += textheight("Ready!") + margin_;
		if (is_playing_)
		{
			playing_indicator_->show_image_with_alpha(pos_x_ + view_width_ / 2 - playing_indicator_->get_width() / 2, target_top, 1.0);
			target_top += playing_indicator_->get_height() + margin_;
		}
	}
	else if (!is_opposite_)
	{
		button_ready_->set_position(pos_x_ + view_width_ / 2 - button_ready_->get_width() / 2, target_top);
		button_ready_->show();
		target_top += button_ready_->get_height() + margin_;
	}
}
Ejemplo n.º 8
0
main()
{
	int gd=DETECT, gm, x=10,y,i,j;
	char str[]="FONTS";
	char *demo[]={
					"DEFAULT FONT DEMO",
					"TRIPLEX FONT DEMO",
					"SMALL FONT DEMONSTRATION",
					"SANSSERIF FONT DEMO",
					"SCRIPT FONT DEMO"
				 };
	initgraph(&gd,&gm,"c:\\tc\\bgi");
	setcolor(WHITE);

	for(i=0;i<=5;i++)
	{
		rectangle(0,20,639,479);
		settextstyle(0,0,1);
		outtextxy(150,10,demo[i]);
		y=30;
		for(j=1;j<=4;j++)
		{
			settextstyle(i,HORIZ_DIR,j);
			outtextxy(10,y,str);
			y+=(textheight(str)+10);
		}
		settextstyle(i,VERT_DIR,0);
		setusercharsize(2,1,3,2);
		outtextxy(10,y,str);
		getch();
		clearviewport();
	}
	getch();
}
Ejemplo n.º 9
0
int main() {
	int x,y,i,j,n,unidad,modo;
	char sx[10],sy[10],sn[10];


	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	setpalette (3,YELLOW);
	setcolor (3);
	settextstyle (GOTHIC_FONT,HORIZ_DIR,3);
	i = textheight ("E");
	j = textwidth ("ESTRUCTURAS DE DATOS EN PASCAL");
	itoa(i,sx,10);
	itoa(j,sy,10);
	settextstyle (DEFAULT_FONT,HORIZ_DIR,1);
	char *p;
	int k = strlen (sx) +  strlen (sy) + 2;
	p = new char [k];
	strcpy (p,sx);
	strcat (p," ");
	strcat (p,sy);
	outtext (p);
	delete p;
	getch();
	closegraph();
	return 0;
}
Ejemplo n.º 10
0
static void storeline(textlabel_t * lp, char *line, char terminator,
		      graph_t * g)
{
    double width = 0.0;

    lp->u.txt.line =
	ALLOC(lp->u.txt.nlines + 2, lp->u.txt.line, textline_t);
    lp->u.txt.line[lp->u.txt.nlines].str = line;
    width =
	textwidth(&(lp->u.txt.line[lp->u.txt.nlines]), lp->fontname,
		  lp->fontsize);
    lp->u.txt.line[lp->u.txt.nlines].just = terminator;
    lp->u.txt.nlines++;
    /* total width = max line width */
    if (lp->dimen.x < width)
	lp->dimen.x = width;
    /* recalculate total height */
#if !defined(DISABLE_CODEGENS) && !defined(HAVE_GD_FREETYPE) && !defined(ONLY_PLAIN_GEN) //maks
    if (Output_codegen == &GD_CodeGen)
	lp->dimen.y = textheight(lp->u.txt.nlines, lp->fontsize);
    else
	lp->dimen.y =
	    lp->u.txt.nlines * (int) (lp->fontsize * LINESPACING);
#else
    lp->dimen.y = lp->u.txt.nlines * (int) (lp->fontsize * LINESPACING);
#endif

}
Ejemplo n.º 11
0
void _draw_node(node *p, int x1, int x2, int y)
    {
    char content[2];
    if (p != NULL)
	{
	_draw_node(p->left, x1, (x1+x2)/2, y+DY);
	content[0] = *((char*)(p+1));
	content[1] = NULL;
	fillellipse((x1+x2)/2, y,
		    textheight(content)/2+5, textheight(content)/2+5);
	outtextxy((x1+x2)/2, y-3, content);
	_draw_node(p->right, (x1+x2)/2, x2, y+DY);
	}
    else
	fillellipse((x1+x2)/2, y, 3, 3);
    }
Ejemplo n.º 12
0
void Style::normal_KEY_Shear() {
	setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
	setcolor(BLACK);
	int sx = Event::item_drawing_area->layer->startx, sy = MAXY - 75, ex = Event::item_drawing_area->layer->endx, ey = MAXY - 50;
	rectangle(sx, sy, ex, ey);
	setfillstyle(SOLID_FILL, WHITE);
	bar(sx + 1, sy + 1, ex, ey);
	int textw = 0, texth = textheight("a"), y = (sy + ey - texth) / 2, x = sx + y - sy,
		lx = x + textw;
	setbkcolor(WHITE);
	outtextxy(x + textw, y, "X shear = ");
	textw = textw + textwidth("X shear = ");
	outtextxy(x + textw, y, InputText);
	textw = textw + textwidth(InputText);
	if (POS < 85) {
		lx = x + textw;
	}
	outtextxy(x + textw, y, " Y shear = ");
	textw = textw + textwidth(" Y shear = ");
	outtextxy(x + textw, y, InputText + 85);
	textw = textw + textwidth(InputText + 85);
	if (POS >= 85 && POS < 170) {
		lx = x + textw;
	}
	line(lx, y, lx, y + texth);
	setfillstyle(EMPTY_FILL, WHITE);
}
Ejemplo n.º 13
0
void desenho_salvar(int x1, int y1, int x2, int y2)
{
  Acessorios a;
  setcolor(0);
  settextstyle(2, 0, 4);
  a.escreva(x1, x2, (y1 + y2) / 2 - textheight("H") + 2, "salva");
  settextstyle(0, 0, 1);
}
Ejemplo n.º 14
0
int menu()
{
	char *menu[]={"New Game","Option","Instruction","Exit"};
	int w=0,k,g=130,h=200;
	setbkcolor(0);
	initmouse();
	show();
	setcolor(8);
	settextstyle(1,0,2);
	for(k=0;k<4;k++)
	{
		outtextxy(g,h,menu[k]);
		h+=textheight(menu[k])+10;
	}
	settextstyle(4,0,5);
	setcolor(14);
	setpos(0,0);
	outtextxy(190,90,"SNAKE GAME");
	status("Select Any one using mouse pointer");
	while(1)
	{
		pos(&button,&n,&m);
		w=opt(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<4;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;
			}
		}
	}
}
void CGameControllerRalla3::DrawHUD()
{
    if (m_PlayerWin == PLAYER_NULL)
    {
        if (m_ActivePlayer == PLAYER_1)
        {
            circle(mousex(), mousey(), 10);
            outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: JUGADOR 1")/2, dimTY+60, "TURNO: JUGADOR 1");
        }
        else
        {
            moveto(mousex()-10, mousey()-10);
            lineto(mousex()+10, mousey()+10);
            moveto(mousex()+10, mousey()-10);
            lineto(mousex()-10, mousey()+10);

            if (m_CPU)
                outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: CPU")/2, dimTY+120, "TURNO: CPU");
            else
                outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: JUGADOR 2")/2, dimTY+60, "TURNO: JUGADOR 2");
        }
    }
    else
    {
        const char *sBuff;
        if (m_PlayerWin == PLAYER_1)
            sBuff = "Gana el JUGADOR 1";
        else if (m_PlayerWin == PLAYER_2)
            sBuff = "Gana el JUGADOR 2";
        else if (m_PlayerWin == PLAYER_CPU)
            sBuff = "Gana la CPU";
        else
            sBuff = "EMPATE!";

        int xt = g_Game.GetScreenW()/2 - textwidth(sBuff)/2;
        int yt = g_Game.GetScreenH()/2 - textheight(sBuff)/2;

        outtextxy(xt, yt, sBuff);

        xt = g_Game.GetScreenW()/2 - textwidth("pulsa INTRO para reiniciar")/2;
        yt = g_Game.GetScreenH()/2 - textheight("pulsa INTRO para reiniciar")/2;
        yt += textheight(sBuff) + 15;
        outtextxy(xt, yt, "pulsa INTRO para reiniciar");
        rectangle(-1, yt-2, g_Game.GetScreenW()+1, yt-1 + textheight("pulsa INTRO para reiniciar") + 2);
    }
}
    displaymenu(char **menu,int count,int x1,int y1)
    {
      int i,h;
      h=textheight(menu[0]) ;

      for(i=0;i<count;i++)
	  outtextxy(x1,y1+i*(h+5),menu[i]);
     return 0;
     }
Ejemplo n.º 17
0
void desenho_cor(int x1, int y1, int x2, int y2)
{
  Acessorios a;
  a.limpeza(x1 + 2, y1 + 2, x2 - 2, y2 - 1, cor_atual);
  settextstyle(0, 0, 1);
  setcolor(cor_atual ^ 6);
  a.escreva(x1, x2, (y1 + y2) / 2 - textheight("H") + 4, "COR");
  settextstyle(0, 0, 1);
}
Ejemplo n.º 18
0
int sivakumar()
{
	char men[][20]={"Mazes","Speed Level","Top Scorer List","Back"};
	int w=0,k,g=130,h=200;
	setpos(0,0);
	viewport();
	setcolor(8);
	settextstyle(1,0,2);
	for(k=0;k<4;k++)
	{
		outtextxy(g,h,men[k]);
		h+=textheight(men[k])+10;
	}
	settextstyle(7,0,5);
	setcolor(14);
	outtextxy(210,90,"OPTIONS");
	while(1)
	{
		pos(&button,&n,&m);
		w=opt1(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<4;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,men[k]);
				h+=textheight(men[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,men[k]);
				h+=textheight(men[k])+10;
			}
		}
	}
     //	getch();
}
Ejemplo n.º 19
0
/*************************************************************************
 *
 *N  displayinfo
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays an array of text strings in a
 *     popup text window.  Must be in graphics mode to call this function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    text[] <input> == (char *) array of text strings to be displayed.
 *    nlines <input> == (int) number of text lines.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels    June 1990    Original Version    DOS Turbo C
 *E
 *************************************************************************/
void displayinfo( char *text[],
		  int  nlines )
{
   int         i,maxw,height,x,y,pad;
   panel_type  panel;

   arrow_cursor();
   settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
   maxw = 0;
   height = 0;
   for (i=0;i<nlines;i++) {
      if (textwidth(text[i]) > maxw) maxw = textwidth(text[i]);
      height = height + textheight(text[i]) + 5;
   }
   if (maxw < (textwidth("Continue") + 10))
      maxw = textwidth("Continue") + 10;
   pad = (maxw*10)/100;
   maxw = maxw + (2*pad);
   if (maxw > getmaxx())
     maxw = getmaxx() - 8;
   height = height + 2*(textheight("Continue") + 10);

   create_panel( &panel, maxw, height, menucolor, menubordercolor );
   x = pad;
   y = 0;
   for (i=0;i<nlines;i++) {
      y = y + textheight(text[i]) + 3;
      create_label( text[i], x, y, SMALL_FONT, 4, menutextcolor, &panel );
   }
   y = height - (textheight("Continue") + 6);
   x = (maxw - (textwidth("Continue") + 10))/2;
   create_button( 27, "Continue", x, y, SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );

   get_display_position( &x, &y, panel.window );

   display_panel( &panel, x, y );
   i = process_panel( &panel, i );

   destroy_panel( &panel );
   close_panel( &panel );
}
Ejemplo n.º 20
0
//----------------------------------------------------------------------------------------------------------//
    void Human::setCurrentPlayer()
    {
        string details;
        int textPositionX, textPositionY;

        details = "The current player is ";
        details += myName;

        settextstyle(EUROPEAN_FONT, HORIZ_DIR, 1);

        textPositionX = (1024 - textwidth(details.c_str())) / 2;
        textPositionY = (124 - textheight(details.c_str())) / 2;

        setfillstyle(SOLID_FILL, BLUE);
        bar(0, textPositionY, 1023, textPositionY + textheight(details.c_str()));
        outtextxy(textPositionX, textPositionY, details.c_str());

        theInterface->showMyBoard(*myBoard);
        theInterface->showFleet(*myBoard);
    }
Ejemplo n.º 21
0
ActionButton::ActionButton(char text[20], int x1, int y1, int x2, int y2,
	int borderColor, Command *leftClickCommand, Command *rightClickCommand,
	int normalTextColor, int selectedTextColor,
	int normalBackgroundColor, int selectedBackgroundColor)
: Button(x1, y1, x2, y2, borderColor, leftClickCommand, rightClickCommand),
	col(normalTextColor), bgCol(normalBackgroundColor),
	selCol(selectedTextColor), selBgCol(selectedBackgroundColor)
{
	strcpy(this->text, text);
	x = x1+(x2-x1-textwidth(text))/2;
	y = y1+(y2-y1-textheight(text))/2;
}
Ejemplo n.º 22
0
/*************************************************************************
 *
 *N  info_window
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays a temporary window to the screen with a
 *     single string of text.  Must be in graphics mode to call this
 *     function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    text    <input> == (char *)message to display.
 *    return <output> == (window_type) window created and displayed.
 *                       [Will need to be deleted]
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels   July 1990   Original Version   DOS Turbo C
 *E
 *************************************************************************/
window_type info_window( char *text )
{
   window_type w;
   int x,y;

   settextstyle(SMALL_FONT,HORIZ_DIR,4);
   settextjustify(LEFT_TEXT,BOTTOM_TEXT);
   if (textwidth(text) > getmaxx())
     x = getmaxx()-20;
    else
     x = textwidth(text) + 20;
   create_window( &w, x, textheight(text)+10,
		  menucolor,menubordercolor );
   get_display_position( &x, &y, w );
   open_window( &w, x,y );
   setcolor(menutextcolor);
   hidemousecursor();
   outtextxy( 10,textheight(text)+5,text );
   showmousecursor();
   return w;
}
Ejemplo n.º 23
0
void desenho_grossura(int x1, int y1, int x2, int y2)
{
  Acessorios a;
  settextstyle(2, 0, 4);
  setcolor(0);
  a.escreva(x1, x2, (y1 + y2) / 2 - textheight("H") + 2, "gross.");
  settextstyle(0, 0, 1);
  setlinestyle(0, 0, grossura);
  line (x1 + 2, y1 + 6, x2 - 2, y1 + 6);
  line (x1 + 2, y2 - 6, x2 - 2, y2 - 6);
  setlinestyle(0, 0, 0);
}
Ejemplo n.º 24
0
A::A(char *cad,int e, int d, int t) {
		int i;
		cadena = new char [strlen (cad) + 1];
		strcpy (cadena,cad);
		for (i=0; i < 5; i++)
			datos [i] = new int;
		*datos [0] = e;
		*datos [1] = d;
		*datos [2] = t;
		*datos [3] = textheight(cadena); // Altura Original
		*datos [4] = textwidth(cadena);  // Largo Original
}
Ejemplo n.º 25
0
Archivo: csort.c Proyecto: eposts/Rich
void print_menu( char *mysorts[] )
{
 int x, y;   /* 屏幕的坐标 */
 int i;
 x = 240;
 y = 10;

 for ( i = 0; i < MAXPICKS; i++ )
   {
    gprintf( &x, &y, "%d. %s", i+1, mysorts[i] );
    y += textheight ( "H" ) + 1;
   }
}
Ejemplo n.º 26
0
void menu()
{
    int op=-1, xm, ym, i, margin = 70;
    String opciones[] = {"Jugar", "Tienda", "Ayuda", "Créditos"};
    setbkcolor(0x0066F4);
    setfillstyle(1, 0x0066F4);
    setcolor(0x003988);
    settextstyle(2, HORIZ_DIR, 8);

    for(i=0; i<4; i++, margin+=50)
    {
        bar(WIDTH/2-textwidth(opciones[3])/2-5, HEIGHT/2+margin-10, WIDTH/2+textwidth(opciones[3])/2+5, HEIGHT/2+margin+textheight(opciones[3])+10);
        outtextxy(WIDTH/2-textwidth(opciones[i])/2, HEIGHT/2+margin, opciones[i]);
    }

    do
    {
        while(!ismouseclick(WM_LBUTTONDOWN));
        getmouseclick(WM_LBUTTONDOWN, xm, ym);
        margin = 70;
        for(i=0; i<4; i++, margin+=50)
            if(xm>WIDTH/2-textwidth(opciones[3])/2-5
               && xm<WIDTH/2+textwidth(opciones[0])/2-10
               && ym>HEIGHT/2+margin-10
               && ym<HEIGHT/2+margin+textheight(opciones[3])+10)
                {
                    op = i;
                    i=5;
                    break;
                }
    }while(op==-1);

    fflush(stdin);
    switch(op)
    {
        case 0:
            juego(3);
            break;
        case 1:
            tienda();
            break;
        case 2:
            ayuda();
            break;
        case 3:
            creditos();
            break;
    }
}
Ejemplo n.º 27
0
main()
{
    int gd = DETECT, gm, height;
    char array[100];

    initgraph(&gd, &gm, "C:\\TC\\BGI");

    height = textheight("C programming");

    sprintf(array,"Textheight = %d",height);
    outtext(array);

    getch();
    closegraph();
    return 0;
}
     savemenu(char **menu,char **buffer,int width, int count,int x1,int y1)
     {
       int i,x2,yy1,yy2,area,h;
       h=textheight(menu[0]);

       for(i=0;i<count;i++)
       {
	 x2=x1+width;
	 yy1=y1+i*(h+5);
	 yy2=y1+(i+1)*(h+5);

	 area=imagesize(x1,yy1,x2,yy2);
	 buffer[i]=malloc(area);
	 getimage(x1,yy1,x2,yy2,buffer[i]);
	}
	return 0;
     }
Ejemplo n.º 29
0
void MainWindow( char *header )
{
  int height;

  cleardevice();			/* Clear graphics screen	*/
  setcolor( MaxColors - 1 );		/* Set current color to white	*/
  setviewport( 0, 0, MaxXX, MaxYY, 1 );	/* Open port to full screen	*/

  height = textheight( "H" );           /* Get basic text height        */

  changetextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );
  settextjustify( CENTER_TEXT, TOP_TEXT );
  outtextxy( MaxXX/2, 2, header );
  setviewport( 0, height+4, MaxXX, MaxYY-(height+4), 1 );
  DrawBorder();
  setviewport( 1, height+5, MaxXX-1, MaxYY-(height+5), 1 );

}
Ejemplo n.º 30
0
void score(long sc){
	char buf[8];
	int x,y,i;
	static int flag = 1;
	if(flag){
		settextstyle(0, HORIZ_DIR, 4);
		flag = 0;
	}
	
	sprintf(buf,"%7d",sc);
	for(i = 0;i < 7;i++){
		if(buf[i] == 32)
			buf[i] = '0';
	}
	x = textwidth(buf);
	y = textheight(buf);
	outtextxy(getmaxx() - x ,y/2,buf);
	setbkcolor(BLACK);
}