Exemplo n.º 1
0
void HandleWord (void)
{
    char    wword[WORDLIMIT];
    int     wordindex;
    word    wwidth,wheight,newpos;


    //
    // copy the next word into [word]
    //
    wword[0] = *text++;
    wordindex = 1;
    while (*text>32)
    {
        wword[wordindex] = *text++;
        if (++wordindex == WORDLIMIT)
            Quit ("PageLayout: Word limit exceeded");
    }
    wword[wordindex] = 0;            // stick a null at end for C

    //
    // see if it fits on this line
    //
    VW_MeasurePropString (SmallFont, wword,wwidth,wheight);

    while (px+wwidth > (int) rightmargin[rowon])
    {
        NewLine ();
        if (layoutdone)
            return;         // overflowed page
    }

    //
    // print it
    //
    newpos = px+wwidth;
    if(fontcolor == 255 || textcolor != CR_UNTRANSLATED)
        VWB_DrawPropString (SmallFont, wword, textcolor);
    else
        VWB_DrawPropString (SmallFont, wword, CR_UNTRANSLATED, true, fontcolor);
    px = newpos;

    //
    // suck up any extra spaces
    //
    while (*text == ' ')
    {
        px += SPACEWIDTH;
        text++;
    }
}
Exemplo n.º 2
0
void HandleWord (void)
{
	char	word[WORDLIMIT];
	int	wordindex,
	      wwidth,
         wheight,
         newpos;


	//
	// copy the next word into [word]
	//
	word[0] = *text++;
	wordindex = 1;
	while (*text>32)
	{
		word[wordindex] = *text++;
		if (++wordindex == WORDLIMIT)
			Error ("PageLayout: Word limit exceeded");
	}
	word[wordindex] = 0;		// stick a null at end for C

	//
	// see if it fits on this line
	//
	VW_MeasurePropString (word, &wwidth, &wheight);

	while (px+wwidth > rightmargin[rowon])
	{
		NewLine ();
		if (layoutdone)
			return;		// overflowed page
	}

	//
	// print it
	//
	newpos = px+wwidth;
	VWB_DrawPropString (word);
	px = newpos;

	//
	// suck up any extra spaces
	//
	while (*text == ' ')
	{
		px += SPACEWIDTH;
		text++;
	}
}
Exemplo n.º 3
0
void DrawMultiLineText(const FString str, FFont *font, EColorRange color, ETSAlignment align, ETSAnchor anchor)
{
    int oldpa = pa;
    pa = anchor;

    const int basepx = px;
    long pos = -1, oldpos;
    do
    {
        oldpos = pos+1;
        pos = str.IndexOf('\n', oldpos);
        const FString line = str.Mid(oldpos, pos - oldpos);

        word width, height;
        VW_MeasurePropString(font, line, width, height);

        switch(align)
        {
        default:
            px = basepx;
            break;
        case TS_Right:
            px = basepx - width;
            break;
        case TS_Center:
            px = basepx - width/2;
            break;
        }

        VWB_DrawPropString(font, line, color);

        py += font->GetHeight();
    }
    while(pos != -1);

    pa = oldpa;
}
Exemplo n.º 4
0
void PageLayout (boolean shownumber)
{
	int		i,oldfontcolor;
	char	ch;

	oldfontcolor = fontcolor;

	fontcolor = 0;

//
// clear the screen
//
	VWB_Bar (0,0,320,200,BACKCOLOR);
	VWB_DrawPic (0,0,H_TOPWINDOWPIC);
	VWB_DrawPic (0,8,H_LEFTWINDOWPIC);
	VWB_DrawPic (312,8,H_RIGHTWINDOWPIC);
	VWB_DrawPic (8,176,H_BOTTOMINFOPIC);


	for (i=0;i<TEXTROWS;i++)
	{
		leftmargin[i] = LEFTMARGIN;
		rightmargin[i] = SCREENPIXWIDTH-RIGHTMARGIN;
	}

	px = LEFTMARGIN;
	py = TOPMARGIN;
	rowon = 0;
	layoutdone = False;

//
// make sure we are starting layout text (^P first command)
//
	while (*text <= 32)
		text++;

	if (*text != '^' || toupper(*++text) != 'P')
		Quit ("PageLayout: Text not headed with ^P");

	while (*text++ != '\n')
	;


//
// process text stream
//
	do
	{
		ch = *text;

		if (ch == '^')
			HandleCommand ();
		else
		if (ch == 9)
		{
		 px = (px+8)&0xf8;
		 text++;
		}
		else if (ch <= 32)
			HandleCtrls ();
		else
			HandleWord ();

	} while (!layoutdone);

	pagenum++;

	if (shownumber)
	{
		#ifdef SPANISH
		strcpy (str,"Hoja ");
		itoa (pagenum,str2,10);
		strcat (str,str2);
		strcat (str," de ");
		py = 183;
		px = 208;
		#else
		strcpy (str,"pg ");
		_itoa (pagenum,str2,10);
		strcat (str,str2);
		strcat (str," of ");
		py = 183;
		px = 213;
		#endif
		_itoa (numpages,str2,10);
		strcat (str,str2);
		fontcolor = 0x4f; 			   //12^BACKCOLOR;

		VWB_DrawPropString (str);
	}

	fontcolor = oldfontcolor;
}
Exemplo n.º 5
0
void PageLayout (bool shownumber, bool helphack)
{
    int     i,oldfontcolor;
    char    ch;

    oldfontcolor = fontcolor;

    fontcolor = 0;

    //
    // clear the screen
    //
    int clearx = 0, cleary = 0, clearw = 320, clearh = 200;
    MenuToRealCoords(clearx, cleary, clearw, clearh, MENU_CENTER);
    VWB_DrawFill(backgroundFlat, clearx, cleary, clearx+clearw, cleary+clearh);
    VWB_DrawGraphic(TexMan("TOPWINDW"), 0, 0, MENU_CENTER);
    VWB_DrawGraphic(TexMan("LFTWINDW"), 0, 8, MENU_CENTER);
    VWB_DrawGraphic(TexMan("RGTWINDW"), 312, 8, MENU_CENTER);
    VWB_DrawGraphic(TexMan("BOTWINDW"), 8, 176, MENU_CENTER);

    for (i=0; i<TEXTROWS; i++)
    {
        leftmargin[i] = LEFTMARGIN;
        rightmargin[i] = SCREENPIXWIDTH-RIGHTMARGIN;
    }

    px = LEFTMARGIN;
    py = TOPMARGIN;
    rowon = 0;
    layoutdone = false;

    //
    // make sure we are starting layout text (^P first command)
    // [BL] Why? How about assuming ^P?
    //
    while (*text <= 32)
        text++;

    if (*text == '^' && toupper(*(text+1)) == 'P')
    {
        ++text;
        while (*text++ != '\n')
            ;
    }


    //
    // process text stream
    //
    do
    {
        ch = *text;

        if (ch == '^')
            HandleCommand (helphack);
        else if(ch == '\0')
        {
            // Simulate ^E if one does not exist.
            layoutdone = true;
        }
        else if (ch == 9)
        {
            px = (px+8)&0xf8;
            text++;
        }
        else if (ch <= 32)
            HandleCtrls ();
        else
            HandleWord ();

    } while (!layoutdone);

    pagenum++;

    if (shownumber)
    {
        FString str;
        str.Format("pg %d of %d", pagenum, numpages);
        px = 213;
        py = 183;

        VWB_DrawPropString (SmallFont, str, gameinfo.FontColors[GameInfo::PAGEINDEX]);
    }

    fontcolor = oldfontcolor;
}