Esempio n. 1
0
void oslIntraFontSetStyle(OSL_FONT *f, float size, unsigned int color, unsigned int shadowColor, unsigned int options){
    if (f->intra){
        intraFontSetStyle(f->intra, size, color, shadowColor, 0.f, options);
        updateIntraFontCharWidth(f, f->intra);
        if(f->intra->altFont)
            intraFontSetStyle(f->intra->altFont, size, color, shadowColor, 0.f, options);
    }
}
Esempio n. 2
0
float AlphaDegrade(int x, int y, intraFont *font, const char *text, g2dColor colorText, g2dColor colorMark, float size, float angle, int center, dMode side)
{
    colorMark = G2D_RGBA(G2D_GET_R(colorMark), G2D_GET_G(colorMark), G2D_GET_B(colorMark), 180);
    int i, y_Mark = y, x_Mark = x;
	
    for (i = 0; i < ALPHA_LONG_MARK; i++)    
	{
        switch(side)
        {
            case GRAD_UP: 
				y_Mark--; 
				break;
            case GRAD_DOWN: 
				y_Mark++; 
				break;
            case GRAD_LEFT: 
				x_Mark--; 
				break;
            case GRAD_RIGHT: 
				x_Mark++; 
				break;
            case GRAD_UP_LEFT: 
				x_Mark--; 
				y_Mark--; 
				break;
            case GRAD_UP_RIGHT: 
				x_Mark++; 
				y_Mark--;
				break;
            case GRAD_DOWN_LEFT:
				x_Mark--; 
				y_Mark++; 
				break;
            case GRAD_DOWN_RIGHT: 
				x_Mark++; 
				y_Mark++; 
				break;
            default: 
				break;
				
        }
		
		intraFontSetStyle(font, size, G2D_RGBA(G2D_GET_R(colorMark), G2D_GET_G(colorMark), G2D_GET_B(colorMark), G2D_GET_A(colorMark) - 2*i*ALPHA_LONG_MARK), 0, angle, center);
        intraFontPrint(font, x_Mark, y_Mark, text);
    }
	
	intraFontSetStyle(font, size, colorText, 0, angle, center);
    return intraFontPrint(font, x, y,text);
}
Esempio n. 3
0
float ContouredText(int x, int y, intraFont *font, const char *text, float size, float angle, g2dColor colorText, g2dColor colorContour, int center)
{
    int i, j;
	
	intraFontSetStyle(font, size, colorContour, 0, angle, center);
	
    for (i = 0; i <= 2; i++)
    {
        for (j = 0; j <= 2; j++)
			intraFontPrint(font, x-i, y-j, text);
    }
	
	intraFontSetStyle(font, size, colorText, 0, angle, center);
    return intraFontPrint(font, x-1, y-1, text);
}
Esempio n. 4
0
float ShadowedText(int x, int y, intraFont *font, const char *text, float size, float angle, g2dColor colorText, g2dColor colorShadow, int center, char Intensity)
{
    colorShadow = G2D_RGBA(G2D_GET_R(colorShadow), G2D_GET_G(colorShadow), G2D_GET_B(colorShadow), Intensity);
	
	intraFontSetStyle(font, size, colorShadow, 0, angle, center);
	
	intraFontPrint(font, x+2, y+2, text);
	intraFontPrint(font, x+3, y+3, text);
	intraFontPrint(font, x+1, y+1, text);
	intraFontPrint(font, x+4, y+4, text);
	intraFontPrint(font, x+2, y+2, text);
	
	intraFontSetStyle(font, size, colorText, 0, angle, center);
    return intraFontPrint(font, x, y, text);
}
Esempio n. 5
0
int intraFont_print(lua_State *L) //intraFont.print(x,y, font, text, size, color, shadowColor, angle, centered)
{
	int argc = lua_gettop(L);
	if (argc < 4 || argc > 9) return luaL_error(L, "font:print(x, y, text [,size, color, shadowColor, angle, alignMode]) must be called with 3, 4, 5, 6, 7 or 8 arguments and must be called with a colon.");
	
	intraFont *font = *getintraFont(L, 1);
	if (font == NULL) return luaL_error(L, "intraFont.print: font error has occured");
	
	const char *text = luaL_checkstring(L, 4);
	
	float size = (argc >= 5) ? luaL_checknumber(L, 5) : 1.f;
	
	g2dColor color = (argc >= 6) ? luaL_checknumber(L, 6) : 0xFFFFFFFF;
	g2dColor shadowColor = (argc >= 7) ? luaL_checknumber(L, 7) : 0;
	
	float angle = (argc >= 8) ? luaL_checknumber(L, 8) : 0.f;
	
	int mode = (argc == 9) ? luaL_checknumber(L, 9) : 0; 
	
	intraFontSetStyle(font, size, color, shadowColor, angle, mode);
	
	lua_pushnumber(L, intraFontPrint(font, luaL_checknumber(L, 2), luaL_checknumber(L, 3), text));
	
	return 1;
}
Esempio n. 6
0
void GradientText(int x, int y, intraFont *font, const char *text, g2dColor colorBegin, g2dColor colorEnd, float size, float angle, int center)
{
    int i, textSize = strlen(text);
    int posX = x;
    int posY = y;
	
    int Rc =  (G2D_GET_R(colorEnd) - G2D_GET_R(colorBegin))/(textSize-1);
    int Gc =  (G2D_GET_G(colorEnd) - G2D_GET_G(colorBegin))/(textSize-1);
    int Bc =  (G2D_GET_B(colorEnd) - G2D_GET_B(colorBegin))/(textSize-1);
	
    g2dColor ColorJ = 0;
	char help[2] = {0};
	
	intraFontSetStyle(font, size, ColorJ, 0, angle, center);
	
    for(i = 0; i < textSize; i++)
    {
        ColorJ = G2D_RGBA(i * Rc+G2D_GET_R(colorBegin), i * Gc+G2D_GET_G(colorBegin), i * Bc+G2D_GET_B(colorBegin), 255);
		
        help[0] = text[i];
		
        intraFontPrint(font, posX, posY, help);
		
        posX += intraFontMeasureText(font, help);
    }
}
Esempio n. 7
0
float BackgroundColorText(int x, int y, intraFont *font, const char *text, float size, g2dColor colorText, g2dColor colorBackground, int center)
{
    int width = intraFontMeasureText(font, text);

	g2dBeginRects(NULL);
		g2dSetColor(colorBackground);
		g2dSetCoordMode(G2D_UP_LEFT);
		g2dSetScaleWH(width+4, intraFontTextHeight(font, text) + 3);
	
		switch(center)
		{
			case INTRAFONT_ALIGN_LEFT:
				g2dSetCoordXY(x-2, y-intraFontTextHeight(font, text));
				break;
				
			case INTRAFONT_ALIGN_CENTER:
				g2dSetCoordXY(x - 2 - width/2, y-intraFontTextHeight(font, text));
				break;
				
			case INTRAFONT_ALIGN_RIGHT:
				g2dSetCoordXY(x-width-2, y-intraFontTextHeight(font, text));
				break;
				
			default:
				g2dSetCoordXY(x-2, y-intraFontTextHeight(font, text));
				break;
			}
	
		g2dAdd();
	g2dEnd();
	
	intraFontSetStyle(font, size, colorText, 0, 0.0f, center);
    return intraFontPrint(font, x, y, text);
}
Esempio n. 8
0
int dispThread(SceSize args, void *argp)
{
  sceIoChdir(cwd);
  initBackground();
  
  while (exit_state != EXCEPTION)
  {
    if (exit_state)
    {
      setFadeMode(&main_fade,FADE_IN,0);
      if (getFadeState(&main_fade) == FADE_DONE) break;
    }
 
    if (checkGameState(GSQUARE))
    {
      g2dClear(BLACK);
      dispgSquare();
    }
    if (checkGameState(BANNER))
    {
      g2dClear(BLACK);
      dispBanner();
    }
    if (checkGameState(MENU))
    {
      drawMovingBackground();
      dispMenu();
    }
    if (checkGameState(INGAME))
    {
      drawMovingBackground();
      camera();
      drawLevel();
      drawUI();
    }
    if (checkGameState(LEVEL_TITLE))
    {
      g2dClear(WHITE);
      intraFontSetStyle(seriffont,1.f,BLACK,0,0,INTRAFONT_ALIGN_CENTER);
      intraFontPrint(seriffont,G2D_SCR_W/2,G2D_SCR_H/2,lvl.title);
    }
    if (checkGameState(END))
    {
      g2dClear(WHITE);
      g2dBeginRects(img.end);
      {
        g2dAdd();
      }
      g2dEnd();
    }
    
    drawFade(&main_fade);
    g2dFlip(G2D_VSYNC);
  }
  
  if (exit_state == EXCEPTION) dispException();
  
  return 0;
}
Esempio n. 9
0
float InversedText(int x, int y, intraFont *font, const char *text, float fontSize, float angle, g2dColor color, g2dColor shadowColor, int center)
{
    int i, size = strlen(text);
    char textInverse[size];
	
    for (i = size-1; i >= 0; i--)
        textInverse[size-i-1] = text[i];
	
    textInverse[size] = '\0';
	
	intraFontSetStyle(font, fontSize, color, shadowColor, angle, center);
   
	return intraFontPrint(font, x, y, textInverse);
}
Esempio n. 10
0
float StrikedText(int x, int y, intraFont *font, const char *text, float size, float angle, g2dColor colorText, g2dColor colorLine, int center)
{
	int width = intraFontMeasureText(font, text);
	int height = intraFontTextHeight(font, text);
	
	intraFontSetStyle(font, size, colorText, 0, 0.0f, center);
	
	g2dBeginLines(G2D_VOID);
		g2dSetColor(colorLine);
	
		switch(center)
		{
			case INTRAFONT_ALIGN_LEFT:
				g2dSetCoordXY(x, y-height/2);
				g2dAdd();
				
				g2dSetCoordXY(x+width, y-height/2);
				g2dAdd();
				break;
				
			case INTRAFONT_ALIGN_CENTER:
				g2dSetCoordXY(x - width/2, y-height/2);
				g2dAdd();
				
				g2dSetCoordXY(x+width/2, y-height/2);
				g2dAdd();
				break;
				
			case INTRAFONT_ALIGN_RIGHT:
				g2dSetCoordXY(x-width, y-height/2);
				g2dAdd();
				
				g2dSetCoordXY(x, y-height/2);
				g2dAdd();
				break;
				
			default:
				g2dSetCoordXY(x, y-height/2);
				g2dAdd();
				
				g2dSetCoordXY(x+width, y-height/2);
				g2dAdd();
				break;
		}
	
	g2dEnd();
	
	return intraFontPrint(font, x, y, text);
}
Esempio n. 11
0
void oslLoadAltIntraFontFile(OSL_FONT *font, const char *filename)		{
	if (!font || font->fontType != OSL_FONT_INTRA) return;

    intraFont* alt = intraFontLoad(filename, font->intra->options&~INTRAFONT_CACHE_ALL);
    if (!alt)
    {
        oslHandleLoadNoFailError(filename);
    }else{
        intraFontSetStyle(alt, 1.0f, 0xFFFFFFFF, 0xFF000000, 0.0f, INTRAFONT_ALIGN_LEFT);
		if ( font->charHeight < alt->texYSize )
			font->charHeight = alt->texYSize;
        intraFontSetAltFont(font->intra, alt);
    }
	return;
}
Esempio n. 12
0
void Red3dInitScreen()
{
	
	intraFontInit();
    
	ltn = intraFontLoad("flash0:/font/ltn8.pgf", 0);
	if(!ltn) sceKernelExitGame();
	intraFontSetStyle(ltn, 1.0f, 0xFFFFFFFF, 0xBFBFBFBF, 0);
	
	void *fbp0 = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned int))   * SCREEN_HEIGHT));
	void *fbp1 = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned int))   * SCREEN_HEIGHT));
	void *zbp  = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned short)) * SCREEN_HEIGHT));
	
	pspDebugScreenInit();
	sceGuInit();
	sceGuStart(GU_DIRECT,list);

	sceGuDrawBuffer(GU_PSM_8888, fbp0, FRAMEBUFFER_WIDTH);
	sceGuDispBuffer(SCREEN_WIDTH, SCREEN_HEIGHT, fbp1, FRAMEBUFFER_WIDTH);
	sceGuDepthBuffer(zbp, FRAMEBUFFER_WIDTH);
	sceGuOffset(2048 - (SCREEN_WIDTH/2),2048 - (SCREEN_HEIGHT/2));
	sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);
	sceGuDepthRange(65535, 0);
    sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    
    sceGuDepthFunc(GU_GEQUAL);
    sceGuEnable(GU_DEPTH_TEST);
	sceGuEnable(GU_SCISSOR_TEST);
	
	sceGuFrontFace(GU_CCW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuEnable(GU_CULL_FACE);
	sceGuEnable(GU_CLIP_PLANES);
	
	sceGuEnable(GU_BLEND);
	sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
	
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGBA);
	sceGuTexFilter(GU_LINEAR,GU_LINEAR);
	
	sceGuFinish();
	sceGuSync(0,0);
	
	Red3dSetupScreen();
	
}
Esempio n. 13
0
void dispgSquare()
{
  gsquare_size /= 1.0002f;
  
  g2dBeginRects(img.gsquare);
  {
    g2dSetCoordMode(G2D_CENTER);
    g2dSetCoordXY(G2D_SCR_W/2,G2D_SCR_H/2-20);
    g2dSetScale(gsquare_size,gsquare_size);
    g2dAdd();
  }
  g2dEnd();
  
  intraFontSetStyle(font,1.f,WHITE,0,0.f,INTRAFONT_ALIGN_CENTER);
  intraFontPrint(font,480/2,240,text.authors);
  intraFontPrint(font,480/2,262,text.website);
}
Esempio n. 14
0
void Red3dPrintf(const char *message, float font_size, int x, int y, u32 fg_color, u32 bg_color, ...)
{
	sceGuEnable(GU_TEXTURE_2D);
	sceGuEnable(GU_BLEND);
	char buffer[256];
	va_list ap;
	
	va_start(ap, message);
	vsnprintf(buffer, 256, message, ap);
	va_end(ap);
	buffer[255] = 0;
	
	intraFontSetStyle(ltn, font_size, fg_color, bg_color, 0);
	intraFontPrint(ltn, x, y, buffer);
	sceGuDisable(GU_BLEND);
	sceGuDisable(GU_TEXTURE_2D);
}
Esempio n. 15
0
OSL_FONT *oslLoadIntraFontFile(const char *filename, unsigned int options)		{
	OSL_FONT *font = NULL;

    font = (OSL_FONT*)malloc(sizeof(OSL_FONT));
    if (!font)
        return NULL;
	memset(font, 0, sizeof(OSL_FONT));					//<-- STAS: Initialize the OSL_FONT structure
    font->fontType = OSL_FONT_INTRA;
    font->intra = intraFontLoad(filename, options);
    if (!font->intra){
        free(font);
        font = NULL;
        oslHandleLoadNoFailError(filename);
    }else{
        intraFontSetStyle(font->intra, 1.0f, 0xFFFFFFFF, 0xFF000000, 0.0f, INTRAFONT_ALIGN_LEFT);
        font->charWidths = NULL;
        updateIntraFontCharWidth(font, font->intra);
        font->charHeight = font->intra->texYSize;
    }
    return font;
}
Esempio n. 16
0
int main() {
	pspDebugScreenInit();
	SetupCallbacks();

	// Colors
	enum colors {
		RED =	0xFF0000FF,
		GREEN =	0xFF00FF00,
		BLUE =	0xFFFF0000,
		WHITE =	0xFFFFFFFF,
		LITEGRAY = 0xFFBFBFBF,
		GRAY =  0xFF7F7F7F,
		DARKGRAY = 0xFF3F3F3F,		
		BLACK = 0xFF000000,
	};
    
    pspDebugScreenPrintf("intraFont 0.31 - 2009 by BenHur\n\nLoading fonts: 0%%");
        
    // Init intraFont library
    intraFontInit();
    
     // Load fonts
    intraFont* ltn[16];                                         //latin fonts (large/small, with/without serif, regular/italic/bold/italic&bold)
    char file[40];
    int i;
    for (i = 0; i < 16; i++) {
        sprintf(file, "flash0:/font/ltn%d.pgf", i); 
        ltn[i] = intraFontLoad(file,0);                                             //<- this is where the actual loading happens 
		intraFontSetStyle(ltn[i], 1.0f, WHITE, DARKGRAY, 0);
		pspDebugScreenSetXY(15,2);
        pspDebugScreenPrintf("%d%%",(i+1)*100/20);
    }

    intraFont* jpn0 = intraFontLoad("flash0:/font/jpn0.pgf",INTRAFONT_STRING_SJIS); //japanese font with SJIS text string encoding
	intraFontSetStyle(jpn0, 0.8f, WHITE, DARKGRAY, 0);                              //scale to 80%
    pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("%d%%",17*100/20);
        
	intraFont* kr0 = intraFontLoad("flash0:/font/kr0.pgf", INTRAFONT_STRING_UTF8);  //Korean font (not available on all systems) with UTF-8 encoding
	intraFontSetStyle(kr0, 0.8f, WHITE, DARKGRAY, 0);                               //scale to 80%
	pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("%d%%",18*100/20);
           
	intraFont* arib = intraFontLoad("flash0:/font/arib.pgf",0);                     //Symbols (not available on all systems)
	intraFontSetStyle(arib, 0.8f, WHITE, DARKGRAY, 0);                              //scale to 80%
	pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("%d%%",19*100/20);

	intraFont* chn = intraFontLoad("flash0:/font/gb3s1518.bwfon", 0);               //chinese font
	intraFontSetStyle(chn, 0.8f, WHITE, DARKGRAY, 0);                               //scale to 80%
	pspDebugScreenSetXY(15,2);
    pspDebugScreenPrintf("done\n");

	// Make sure the important fonts for this application are loaded
	if(!ltn[0] || !ltn[4] || !ltn[8]) sceKernelExitGame();

	// Set alternative fonts that are used in case a certain char does not exist in the main font
	intraFontSetAltFont(ltn[8], jpn0);                     //japanese font is used for chars that don't exist in latin
	intraFontSetAltFont(jpn0, chn);                        //chinese font (bwfon) is used for chars that don't exist in japanese (and latin)
	intraFontSetAltFont(chn, kr0);                         //korean font is used for chars that don't exist in chinese (and jap and ltn)
	intraFontSetAltFont(kr0, arib);                        //symbol font is used for chars that don't exist in korean (and chn, jap & ltn)
	// NB: This is an extreme case - usually you need only one alternative font (e.g. japanese & chinese)
	// Also: if one of the fonts failed to load (e.g. chn) the chain breaks and all subequent fonts are not used (e.g. kr0 and arib)
	
	initGraphics();
	float x_scroll1 = 80, x_scroll2 = 225, x_scroll3 = 370,  x_scroll4 = 385;

	while(running)	{
		clearScreen(GRAY);

		// Must be called before any of the intraFont functions
		guStart();

		// Draw various text
        float x,y = 20;
		intraFontSetStyle(ltn[4], 1.0f,BLACK,WHITE,INTRAFONT_ALIGN_CENTER);
		intraFontPrint(ltn[4], 240, y, "intraFont 0.31 - 2009 by BenHur");
        intraFontSetStyle(ltn[4], 1.0f,WHITE,DARKGRAY,0);
		        
		y += 21;
		intraFontPrint(ltn[8],  10, y, "Latin Sans-Serif:");
		intraFontPrint(ltn[0], 180, y, "regular,");
        intraFontPrint(ltn[2], 270, y, "italic,");
        intraFontPrint(ltn[4], 330, y, "bold,");
        intraFontPrint(ltn[6], 390, y, "both");
        
        y += 17;
        intraFontPrint(ltn[8],  10, y, "Latin Sans-Serif small:");
		intraFontPrint(ltn[8], 180, y, "regular,");
        intraFontPrint(ltn[10], 270, y, "italic,");
        intraFontPrint(ltn[12], 330, y, "bold,");
        intraFontPrint(ltn[14], 390, y, "both");
        
        y += 17;
        intraFontPrint(ltn[8],  10, y, "Latin with Serif:");
		intraFontPrint(ltn[1], 180, y, "regular,");
        intraFontPrint(ltn[3], 270, y, "italic,");
        intraFontPrint(ltn[5], 330, y, "bold,");
        intraFontPrint(ltn[7], 390, y, "both");
        
        y += 17;
        intraFontPrint(ltn[8],  10, y, "Latin with Serif small:");
		intraFontPrint(ltn[9], 180, y, "regular,");
        intraFontPrint(ltn[11], 270, y, "italic,");
        intraFontPrint(ltn[13], 330, y, "bold,");
        intraFontPrint(ltn[15], 390, y, "both");
		
        y += 17;
		intraFontSetEncoding(ltn[8], INTRAFONT_STRING_UTF8);   //set text string encoding to UTF-8
		intraFontPrint(ltn[8], 10, y, "LTN (UTF8):");          //(has no effect on std ascii)
		intraFontPrint(ltn[8], 110, y, "\xC3\xA5 \xC3\xA8 \xC3\xAD \xC3\xB4 \xC3\xBC \xC3\xB1"); //UTF-8 encoded chars with accents on top of them
		
		intraFontPrint(ltn[8], 250, y, "Symbols: ");
        unsigned short ucs2_arib[] = { 57786, 57787, 57788, 57789, 57790, 0 };
        x = intraFontPrintUCS2(arib, 350, y, ucs2_arib);
		if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]");

		y += 17;
        intraFontPrint(ltn[8], 10, y, "JPN (UTF8):");
        char utf8_jpn[] = {0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0xAB, 0xE3, 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0x20, 0xE4, 0xB8, 0x96, 0xE7, 0x95, 0x8C, 0};
		intraFontSetEncoding(jpn0, INTRAFONT_STRING_UTF8);     //temporarely switch to UTF-8 (INTRAFONT_STRING_SJIS was set in intraFontLoad call)
        x = intraFontPrint(jpn0, 110, y, utf8_jpn);            //print UTF-8 encoded string
		if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]");
		intraFontSetEncoding(jpn0, INTRAFONT_STRING_SJIS);     //switch back to S-JIS
        
		intraFontPrint(ltn[8], 250, y, "JPN (S-JIS):");
        x = intraFontPrint(jpn0, 350, y, "イントラフォント");  //S-JIS encoded text string (flag INTRAFONT_STRING_SJIS set in intraFontLoad call)
		if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]");

		y += 17;
		intraFontPrint(ltn[8], 10, y, "CHN (GBK):");
        char gbk_chn[] = { 0xbc,0xf2, 0xcc,0xe5, 0xd6,0xd0, 0xce,0xc4, 0};
        intraFontSetEncoding(chn, INTRAFONT_STRING_GBK);
        x = intraFontPrint(chn, 110, y, gbk_chn);              //print GBK-encoded string (simplified chinese)
		if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]");
        intraFontPrint(ltn[8], 250, y, "CHN (BIG5):");
        char big5_chn[] = { 0xc1,0x63, 0xc5,0xe9, 0xa4,0xa4, 0xa4,0xe5, 0};
        intraFontSetEncoding(chn, INTRAFONT_STRING_BIG5);
        x = intraFontPrint(chn, 350, y, big5_chn);             //print BIG5-encoded string (trad. chinese)
		if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]");

		y += 17;   
		intraFontPrint(ltn[8], 10, y, "KOR (UTF8):");
		char utf8_kr[] = {0xed, 0x99, 0x98, 0xec, 0x98, 0x81, 0x20, 0xeb, 0x8c, 0x80, 0xed, 0x95, 0x9c, 0xeb, 0xaf, 0xbc, 0xea, 0xb5, 0xad, 0};
        x = intraFontPrint(kr0, 110, y, utf8_kr);              //print UTF-8 string (flag INTRAFONT_STRING_UTF8 set in intraFontLoad call)
		if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]");

		intraFontPrint(ltn[8], 250, y, "MIX (UCS2):");
		unsigned short ucs2_all[] = { 0x0041, 0x0192, 0x3401, 0x3402, 0x4E01, 0x4E02, 0xAC01, 0xAC02, 0xE1BE, 0};
        x = intraFontPrintUCS2(ltn[8], 350, y, ucs2_all);      //print chars from all fonts (using alternative fonts, which were set after font loading)
		

        y += 17;
		intraFontPrint(ltn[8], 10, y, "Colors: ");
        intraFontSetStyle(ltn[8], 1.0f,RED,BLUE,0);
		x = intraFontPrint(ltn[8], 80, y, "colorful, ");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,0,0);
        x = intraFontPrint(ltn[8], x, y, "no shadow, ");
        intraFontSetStyle(ltn[8], 1.0f,0,DARKGRAY,0);
        x = intraFontPrint(ltn[8], x, y, "no text, ");
        intraFontSetStyle(ltn[8], 1.0f,0x7FFFFFFF,DARKGRAY,0);
        x = intraFontPrint(ltn[8], x, y, "transparent, ");		
        intraFontSetStyle(ltn[8], 1.0f,GRAY,WHITE,0);
        x = intraFontPrint(ltn[8], x, y, "glowing, ");
		float t = ((float)(clock() % CLOCKS_PER_SEC)) / ((float)CLOCKS_PER_SEC);
		int val = (t < 0.5f) ? t*511 : (1.0f-t)*511;
		intraFontSetStyle(ltn[8], 1.0f,LITEGRAY,(0xFF<<24)+(val<<16)+(val<<8)+(val),0);
		x = intraFontPrint(ltn[8], x, y, "flashing");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);
        
        y += 17;
        intraFontPrint(ltn[8], 10, y, "Spacing: ");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_WIDTH_FIX);
		x = intraFontPrint(ltn[8], 80, y, "fixed (default), ");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_WIDTH_FIX | 12);
        x = intraFontPrint(ltn[8], x, y, "fixed (12), ");		
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);
        x = intraFontPrint(ltn[8], x, y, "variable width");
        
        y += 22;
        intraFontPrint(ltn[8], 10, y, "Scaling: ");
		intraFontSetStyle(ltn[0], 0.5f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], 80, y, "tiny, ");
        intraFontSetStyle(ltn[0], 0.75f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "small, ");
        intraFontSetStyle(ltn[0], 1.0f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "regular, ");
        intraFontSetStyle(ltn[0], 1.25f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "large, ");
        intraFontSetStyle(ltn[0], 1.5f,WHITE,DARKGRAY,0);
		x = intraFontPrint(ltn[0], x, y, "huge"); 
		intraFontSetStyle(ltn[0], 1.0f,WHITE,DARKGRAY,0);
		
        y += 17;
        intraFontPrint(ltn[8], 10, y, "Align: ");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_LEFT);
		t = ((float)(clock() % (CLOCKS_PER_SEC*10))) / ((float)CLOCKS_PER_SEC);
		int length = (t < 5.0f) ? t*5.8f : (10.0f-t)*5.8f;
		intraFontPrintColumnEx(ltn[8],  80, y,  90, "left aligned w. linebreaks  ", length);
		//NB: intraFontPrintColumnEx() is used to print a sub-string of a given length (last parameter)
		//    if you want to print the whole string, simply use intraFontPrintColumn() and omit the length parameter
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_CENTER);
		intraFontPrintColumnEx(ltn[8], 225, y, 110, "center aligned w. linebreaks", length);
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_RIGHT);
        intraFontPrintColumnEx(ltn[8], 370, y,  90, "right aligned w. linebreaks ", length);
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_FULL);
        intraFontPrintColumnEx(ltn[8], 380, y,  90, "full justified w. linebreaks", length);
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);

		y += 28;
        intraFontPrint(ltn[8], 10, y, "Scrolling: ");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_LEFT);
		x_scroll1 = intraFontPrintColumn(ltn[8], x_scroll1, y, 80, "This text is scrolled to the left.");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_SEESAW);
        x_scroll2 = intraFontPrintColumn(ltn[8], x_scroll2, y, 90, "Back & forth like a seesaw.");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_RIGHT);
		x_scroll3 = intraFontPrintColumn(ltn[8], x_scroll3, y, 80, "Scrolling to the right...");
        intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_THROUGH);
        x_scroll4 = intraFontPrintColumn(ltn[8], x_scroll4, y, 80, "This text is scrolled through.");
		intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0);

		// End drawing
		sceGuFinish();
		sceGuSync(0,0);
		
		// Swap buffers (waiting for vsync)
		sceDisplayWaitVblankStart();
		flipScreen();
	}
    
    //create screenshot (optional)
    //saveImage("scrshot.png", getVramDisplayBuffer(), SCREEN_WIDTH, SCREEN_HEIGHT, PSP_LINE_SIZE, 0);

	// Unload our fonts
    for (i = 0; i < 16; i++) {
        intraFontUnload(ltn[i]);
    }
    intraFontUnload(jpn0);
	intraFontUnload(kr0);
    intraFontUnload(arib);
	intraFontUnload(chn);
	
	// Shutdown font library
	intraFontShutdown();

	sceKernelExitGame();

	return 0;
}
Esempio n. 17
0
void dispMenu()
{
  if (menu.state == 0)
  {
    menu.square_y_target = 370.f;
    menu.logo_y_target = 70.f; 
  }
  else if (menu.state == 1)
  {
    menu.square_y_target = 190.f;
    menu.logo_y_target = -30.f; 
  }
  else
  {
    menu.square_y_target = -250.f;
    menu.logo_y_target = -100.f; 
  }

  menu.rot += (menu.rot_target-menu.rot) * CAM_ROT_SPEED;
  menu.logo_y += (menu.logo_y_target-menu.logo_y) * CAM_POS_SPEED;
  menu.square_y += (menu.square_y_target-menu.square_y) * CAM_POS_SPEED;

  int i;
  float title_x[4], title_y[4];

  // Background shade
  g2dBeginQuads(NULL);
  {
    g2dSetColor(YELLOW);
    g2dSetAlpha(0);
    g2dSetCoordXY(0,0);
    g2dAdd();
    g2dSetCoordXY(G2D_SCR_W,0);
    g2dAdd();
    g2dSetAlpha(127);
    g2dSetCoordXY(G2D_SCR_W,G2D_SCR_H);
    g2dAdd();
    g2dSetCoordXY(0,G2D_SCR_H);
    g2dAdd();
  }
  g2dEnd();

  // Logo
  g2dBeginRects(img.gsquare);
  {
    g2dSetCoordMode(G2D_CENTER);
    g2dSetCoordXY(G2D_SCR_W/2,menu.logo_y);
    g2dSetScale(0.8f,0.8f);
    g2dAdd();
  }
  g2dEnd();

  // L/R indicator
  if (menu.state == 0)
  {
    intraFontSetStyle(bigfont,1.f,BLACK,
                      (buttonPressed(PSP_CTRL_LTRIGGER) ? RED : 0),0.f,
                      INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,25,G2D_SCR_H-25,"<L");
    intraFontSetStyle(bigfont,1.f,BLACK,
                      (buttonPressed(PSP_CTRL_RTRIGGER) ? RED : 0),0.f,
                      INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,G2D_SCR_W-25,G2D_SCR_H-25,"R>");
  }

  g2dBeginRects(img.tileset);
  {
    // Draw Bluz
    g2dSetTexLinear(false);
    g2dSetCoordMode(G2D_CENTER);
    g2dSetCropWH(12,12);
    g2dSetScaleWH(350,350);
    g2dSetCoordXY(G2D_SCR_W/2,menu.square_y);
    g2dSetRotation(menu.rot);
    g2dAdd();
    
    // Get title coords
    for (i=0; i!=MENU_TITLE_NBR; i++)
    {
      g2dPush();
      g2dSetRotationRelative(i*90);
      g2dSetCoordXYRelative(0,-155);
      g2dGetCoordXYZ(&title_x[i],&title_y[i],NULL);
      g2dPop();
    }
  }
  g2dEnd();
  
  // Draw section title
  for (i=0; i!=MENU_TITLE_NBR; i++)
  {
    if (i == menu.mod_i)
    {
      intraFontSetStyle(bigfont,1.f,WHITE,BLACK,menu.rot+menu.mod_i*90,
                        INTRAFONT_ALIGN_CENTER);
      intraFontPrint(bigfont,title_x[i],title_y[i],text.menu.title[i]);
    }
  }
  
  // Draw section text
  if (menu.state != 0)
  {
    float text_x = title_x[menu.mod_i],
          text_y = title_y[menu.mod_i] + 70.f;
    if (menu.mod_i == 0) // Story
    {
      for (i=0; i<3; i++)
      {
        intraFontSetStyle(font,1.f,WHITE,(i == menu.sub_i ? 0 : BLACK),
                          menu.rot+menu.mod_i*90,INTRAFONT_ALIGN_CENTER);
        intraFontPrintf(font,text_x,text_y+i*30,
                        (i==menu.sub_i ? "> %s <" : "%s"),text.menu.story[i]);
      }
    }
    else if (menu.mod_i == 1) // Config
    {
      for (i=0; i<3; i++)
      {
        intraFontSetStyle(font,1.f,WHITE,(i == menu.sub_i ? 0 : BLACK),
                          menu.rot+menu.mod_i*90,INTRAFONT_ALIGN_CENTER);
        intraFontPrintf(font,text_x,text_y+i*30,
                        (i==menu.sub_i ? "< %s %s >" : "%s %s"),
                        text.menu.config[i],text.menu.config_setting[i]);
      }
    }
    else if (menu.mod_i == 2) // Credits
    {
      intraFontSetStyle(font,1.f,WHITE,0,
                        menu.rot+menu.mod_i*90,INTRAFONT_ALIGN_CENTER);
      intraFontPrint(font,text_x,text_y-40.f,text.credits);
    }
  }
}
Esempio n. 18
0
int main()
{
	sf2d_init();
	sf2d_set_clear_color(RGBA8(0x40, 0x40, 0x40, 0xFF));

	consoleInit(GFX_BOTTOM, NULL);
	printf("intraFont test sinusoid\n");

	intraFontInit();
	intraFont *font = intraFontLoad("/ltn8.pgf", INTRAFONT_CACHE_ASCII);
	intraFontSetStyle(font, 1.0f, 0, 0, 0.0f, INTRAFONT_ALIGN_CENTER);

	struct Sinusoid {
		float angle; // In degrees
		float amplitude;
		float step;
		float speed;
		float speed_inc;
		char str[64];
	} sinus = {0.f,35.f,10.f,0.f,0.007f,"intraFont 0.31 - 2009 by BenHur"};

	float x = 0.0f;
	float y = 0.0f;
	float size = 0.65f;
	float tmp_angle;
	int i;
	u32 held;

	while (aptMainLoop()) {

		hidScanInput();
		held = hidKeysHeld();
		if (held & KEY_START) {
			break;
		} else if (held & KEY_L) {
			size += 0.1f;
		} else if (held & KEY_R) {
			size -= 0.1f;
		}
		if (held & KEY_UP) {
			y -= 3.0f;
		} else if (held & KEY_DOWN) {
			y += 3.0f;
		}
		if (held & KEY_RIGHT) {
			x += 3.0f;
		} else if (held & KEY_LEFT) {
			x -= 3.0f;
		}

		sf2d_start_frame(GFX_TOP, GFX_LEFT);

			//sf2d_draw_rectangle(50, 60, 50, 50, RGBA8(0,255,0,255));

			intraFontSetStyle(font, size, RGBA8(255,0,0,255), RGBA8(0,255,0,255), 0.0f, INTRAFONT_ALIGN_LEFT);
			intraFontPrint(font, x, y, "ola k ase");

			// * Draw the sinusoid *
			/*float draw_x = x - intraFontMeasureText(font,sinus.str)/2;
			// Get the x position of the 1st char
			// Increment the speed
			if (fabsf(sinus.speed += sinus.speed_inc) > 10.f)
				sinus.speed_inc = -sinus.speed_inc;
			// Increment the angle
			tmp_angle = (sinus.angle += sinus.speed);
			if (sinus.angle > 360.f) sinus.angle -= 360.f;

			// Draw one by one
			for (i = 0; i != strlen(sinus.str); i++, tmp_angle += sinus.step) {
				intraFontSetStyle(font, 1.0f, WHITE, BLACK, 45.f*cosf(tmp_angle*M_PI/180.f),
					INTRAFONT_ALIGN_LEFT);
				draw_x = intraFontPrintEx(font, draw_x, y + sinus.amplitude*sinf(tmp_angle*M_PI/180.f),
					sinus.str+i,1);
			}*/

		sf2d_end_frame();

		sf2d_swapbuffers();
	}

	intraFontUnload(font);
	intraFontShutdown();
	sf2d_fini();

	return 0;
}
Esempio n. 19
0
void drawUI()
{
  if (dcount++ > DCOUNT_MAX) dcount = 0;

  drawFade(&ui_fade);

  // Timer
  timer_size += (1.f-timer_size) * TIMER_SIZE_SPEED;
  timer_back_color = G2D_RGBA(G2D_GET_R(timer_back_color) +
                              (int)((255-G2D_GET_R(timer_back_color))*TIMER_SIZE_SPEED),
                              G2D_GET_G(timer_back_color) +
                              (int)((255-G2D_GET_G(timer_back_color))*TIMER_SIZE_SPEED),
                              G2D_GET_B(timer_back_color) +
                              (int)((255-G2D_GET_B(timer_back_color))*TIMER_SIZE_SPEED),
                              255);

  if (getGameState() == INGAME)
  {
    ui_fade.mode = FADE_OUT;
    cam.zoom_target = 1.6f;
    // Timer
    intraFontSetStyle(bigfont,timer_size,BLACK,timer_back_color,0.f,
                      INTRAFONT_ALIGN_CENTER);
    intraFontPrintf(bigfont,G2D_SCR_W/2,20,"%.2d:%.2d",
                    game.time_elapsed/60,game.time_elapsed%60);
    // L/R indicator
    short l = buttonPressed(PSP_CTRL_LTRIGGER) && !game.g_lock,
          r = buttonPressed(PSP_CTRL_RTRIGGER) && !game.g_lock;
    intraFontSetStyle(font,1.1f,(game.g_lock ? GRAY : BLACK),
                      (l ? RED : 0),0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(font,15,15,"<L");
    intraFontSetStyle(font,1.1f,(game.g_lock ? GRAY : BLACK),
                      (r ? RED : 0),0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(font,G2D_SCR_W-15,15,"R>");
    // Flying text     
    if (game.flying_text != NULL)
    {
      intraFontSetStyle(font,0.9f,BLACK,AZURE,0.f,INTRAFONT_ALIGN_CENTER);
      intraFontPrintf(font,G2D_SCR_W/2,260,"%s",game.flying_text);
    }
  }
  else if (getGameState() == WIN)
  {
    ui_fade.color = WHITE;
    ui_fade.max = 255;
    ui_fade.mode = FADE_IN;
    cam.zoom_target = 3.f;
    intraFontSetStyle(bigfont,0.9f,BLACK,0,0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,G2D_SCR_W/2,G2D_SCR_H/2,text.game.win);
    if (dcount < DCOUNT_MAX * 5 / 6)
    {
      intraFontSetStyle(font,1.f,G2D_MODULATE(BLACK,255,255*dcount/DCOUNT_MAX),0,
                        0.f,INTRAFONT_ALIGN_RIGHT);
      intraFontPrint(font,G2D_SCR_W-5,G2D_SCR_H-5,text.game.next_level);
    }
  }
  else if (getGameState() == TIME_OVER)
  {
    ui_fade.color = BLACK;
    ui_fade.max = 255;
    ui_fade.mode = FADE_IN;
    cam.zoom_target = 1.f;
    intraFontSetStyle(bigfont,0.9f,WHITE,0,0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,G2D_SCR_W/2,G2D_SCR_H/2,text.game.time_over);
    if (dcount < DCOUNT_MAX * 5 / 6)
    {
      intraFontSetStyle(font,1.f,G2D_MODULATE(WHITE,255,255*dcount/DCOUNT_MAX),0,
                        0.f,INTRAFONT_ALIGN_RIGHT);
      intraFontPrint(font,G2D_SCR_W-5,G2D_SCR_H-5,text.game.respawn);
    }
  }
  else if (getGameState() == OUT_OF_BOUNDS)
  {
    ui_fade.color = BLACK;
    ui_fade.max = 127;
    ui_fade.mode = FADE_IN;
    cam.zoom_target = 1.f;
    intraFontSetStyle(bigfont,0.9f,WHITE,BLACK,0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,G2D_SCR_W/2,G2D_SCR_H/2,text.game.out_bounds);
    if (dcount < DCOUNT_MAX * 5 / 6)
    {
      intraFontSetStyle(font,1.f,G2D_MODULATE(WHITE,255,255*dcount/DCOUNT_MAX),0,
                        0.f,INTRAFONT_ALIGN_RIGHT);
      intraFontPrint(font,G2D_SCR_W-5,G2D_SCR_H-5,text.game.respawn);
    }
  }
  else if (getGameState() == DEATH)
  {
    ui_fade.color = BLACK;
    ui_fade.max = 127;
    ui_fade.mode = FADE_IN;
    cam.zoom_target = 1.f;
    intraFontSetStyle(bigfont,0.9f,WHITE,BLACK,0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,G2D_SCR_W/2,G2D_SCR_H/2,text.game.death);
    if (dcount < DCOUNT_MAX * 5 / 6)
    {
      intraFontSetStyle(font,1.f,G2D_MODULATE(WHITE,255,255*dcount/DCOUNT_MAX),0,
                        0.f,INTRAFONT_ALIGN_RIGHT);
      intraFontPrint(font,G2D_SCR_W-5,G2D_SCR_H-5,text.game.respawn);
    }
  }
  else if (getGameState() == PAUSE)
  {
    ui_fade.color = BLACK;
    ui_fade.max = 127;
    ui_fade.mode = FADE_IN;
    cam.zoom_target = 0.85f;
    intraFontSetStyle(bigfont,0.9f,WHITE,BLACK,0.f,INTRAFONT_ALIGN_CENTER);
    intraFontPrint(bigfont,G2D_SCR_W/2,G2D_SCR_H/2,text.game.pause);
    
    int i;
    for (i=0; i!=PAUSE_CHOICE_NBR; i++)
    {
      intraFontSetStyle(font,1.f,WHITE,(pause.i == i ? 0 : BLACK),
                        0.f,INTRAFONT_ALIGN_RIGHT);
      intraFontPrintf(font,G2D_SCR_W-15,G2D_SCR_H-5-15*i,
                      text.game.pause_choice[i]);
      if (pause.i == i && dcount < DCOUNT_MAX * 5 / 6)
      {
        intraFontSetStyle(font,1.f,G2D_MODULATE(WHITE,255,255*dcount/DCOUNT_MAX),
                          0,0.f,INTRAFONT_ALIGN_RIGHT);
        intraFontPrintf(font,G2D_SCR_W-5,G2D_SCR_H-5-15*i,"<");
      }
    }
  }
}