Example #1
0
Ressource::Ressource()
{
  //Load Sounds
  //click_ = oslLoadSoundFileWAV("media/click.wav", OSL_FMT_NONE);
  //Load Images
  backgroundpic_ = oslLoadImageFileJPG((char*)"media/background.jpg", OSL_IN_RAM, OSL_PF_8888);
  bignumbers_ = oslLoadImageFilePNG((char*)"media/bignumbers.png", OSL_IN_RAM, OSL_PF_8888);
  oslSetImageFrameSize(bignumbers_, SU_CELL_SIZE, SU_CELL_SIZE);
  grid_ = oslLoadImageFilePNG((char*)"media/grid.png", OSL_IN_RAM, OSL_PF_8888);
  selected_ = oslLoadImageFilePNG((char*)"media/selected.png", OSL_IN_RAM, OSL_PF_8888);
  smallnumbers_ = oslLoadImageFilePNG((char*)"media/smallnumbers.png", OSL_IN_RAM, OSL_PF_8888);  
  oslSetImageFrameSize(smallnumbers_, SU_MINI_SIZE, SU_MINI_SIZE);
  //OSK Images
  osk_numbers_ = oslLoadImageFilePNG((char*)"media/osk_numbers.png", OSL_IN_RAM, OSL_PF_8888);  
  osk_back_ = oslLoadImageFilePNG((char*)"media/osk_back.png", OSL_IN_RAM, OSL_PF_8888);  
  osk_selected_ = oslLoadImageFilePNG((char*)"media/osk_selected.png", OSL_IN_RAM, OSL_PF_8888);  
  //Load font
  ltn_ = intraFontLoad("flash0:/font/ltn7.pgf",0);
}
Example #2
0
//Generic, includes support for all image types!
OSL_IMAGE *oslLoadImageFile(char *filename, int location, int pixelFormat)
{
    char *ext, extension[10];
    int i;
    ext = strrchr(filename, '.');
    if (!ext)
        return NULL;
    i = 0;
    while(ext[i] && i < sizeof(extension) - 2)
    {
        extension[i] = tolower((unsigned char) ext[i]);
        i++;
    }
    extension[i] = 0;
    if (!strcmp(extension, ".png"))
        return oslLoadImageFilePNG(filename, location, pixelFormat);
    else if (!strcmp(extension, ".jpg"))
        return oslLoadImageFileJPG(filename, location, pixelFormat);
    else if (!strcmp(extension, ".gif"))
        return oslLoadImageFileGIF(filename, location, pixelFormat);

    return NULL;
}
Example #3
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
    SetupCallbacks();
    oslSrand(1);
    //Init network (for net conf dialog):
    oslNetInit();
    int skip = 0;
    LedAnimFreq.f=2;
    const int calx1=-20,calx2=20,caly1=-20,caly2=20;
    //float fx,fy;
    float_or_int_t _movW,_movX,_movY,_movZ;

    DroneSck = oslNetSocketCreate();
    DroneUdp = make_udpsocket(AT_PORT);
    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);

    //Loads image:
    //OSL_IMAGE *bkg = oslLoadImageFileJPG("back1.jpg", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
    OSL_IMAGE *bkg = oslLoadImageFileJPG("back1.jpg", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5650);
   	OSL_IMAGE *img1 = oslCreateImage (130,130,OSL_IN_RAM,OSL_PF_8BIT);
   	FirePalette (img1,255);
    oslClearImage (img1,0);

    //Load font:
    OSL_FONT *font = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslSetFont(font);

    while(runningFlag && !osl_quit){
        if (!skip){
            oslStartDrawing();
            oslDrawImageXY(bkg, 0, 0);

            oslReadKeys();
            _movX.f = ((float)osl_pad.analogX/128)*mscale;
            _movY.f = ((float)osl_pad.analogY/128)*mscale;
            _movZ.f = 0;
            _movW.f = 0;
            if ((osl_pad.analogX > calx1) && (osl_pad.analogX < calx2)) _movX.f = 0; //Deadzone X
            if ((osl_pad.analogY > caly1) && (osl_pad.analogY < caly2)) _movY.f = 0; //Deadzone Y
			if (osl_pad.held.triangle) _movZ.f = delta; //Up
			if (osl_pad.held.cross) _movZ.f = -delta; //Down
			if (osl_pad.held.L) _movW.f = -delta; //CW
			if (osl_pad.held.R) _movW.f = delta; //CCW
            if (_movX.f==0 && _movY.f==0 && _movZ.f==0 && _movW.f==0) Hover=0; else Hover=1;

            oslDrawStringf(320, 10, "Tic#= %d",AT_SEQ);
            oslDrawStringf(10, 220, "x= %d  y= %d  z= %d  w= %d  !Hvr= %d",osl_pad.analogX,osl_pad.analogY,_movZ.i,_movW.i,Hover);
            oslDrawStringf(10, 240, "xf= %1.2f  yf= %1.2f  Scl= %1.2f",_movX.f,_movY.f,mscale);

            if (Connected==1) GameTic++;

            if (drawMenu==1) {
            	Menu();}
            else {
    			if (osl_pad.pressed.up) {
    				//Drone.AddCmd "AT*ANIM=", CStr(Seq) & "," & Anim_Time(Seq) vb anim code
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_AHEAD,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_AHEAD],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
    			if (osl_pad.pressed.down) {
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_BEHIND,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_BEHIND],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
    			if (osl_pad.pressed.right) {
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_RIGHT,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_RIGHT],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
    			if (osl_pad.pressed.left) {
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_LEFT,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_LEFT],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
                if (osl_pad.pressed.start) {
                	drawMenu=1;}
				if (osl_pad.pressed.circle){//Take off
					snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF|512,CR);//TAKE OFF
					sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
				if (osl_pad.pressed.square){//Land
					snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF,CR);
					sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
            }
            if (showjoypad) JoyPadGfx(img1);
            if (showfire) FireFx(img1);
        	if (showjoypad||showfire) oslDrawImageXY(img1, 345, 85);

        	oslEndDrawing();

		}

		if (GameTic >= TicRoof){
        	GameTic=0;
            //snprintf(netbuf,1024,"AT*COMWDG=%d%cAT*PCMD=%d,%d,%d,%d,%d,%d%c",AT_SEQ++,CR,AT_SEQ++,Hover,_movX.i,_movY.i,_movZ.i,_movW.i,CR);//XY
            snprintf(netbuf,1024,"AT*PCMD=%d,%d,%d,%d,%d,%d%c",AT_SEQ++,Hover,_movX.i,_movY.i,_movZ.i,_movW.i,CR);//XY
			sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}


        oslEndFrame();
        skip = oslSyncFrame();
    }
    //Quit OSL:
    oslNetTerm();
    oslEndGfx();
    oslQuit();

    sceKernelExitGame();
    return 0;

}
Example #4
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Draw info on selected item:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void drawMLinfo(){
	static u64 lastMenuChange = 0;
	static int lastSelected = -1;

	OSL_FONT *font = fontNormal;
	OSL_IMAGE *tmpCoverArt = NULL;

    if (mediaLibraryStatus != STATUS_QUERYMENU)
        return;

    skinGetPosition("POS_MEDIALIBRARY_INFO_BKG", tempPos);
    oslDrawImageXY(infoBkg, tempPos[0], tempPos[1]);
    oslSetFont(font);
    skinGetColor("RGBA_LABEL_TEXT", tempColor);
    skinGetColor("RGBA_LABEL_TEXT_SHADOW", tempColorShadow);
    setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);

	switch (mlQueryType)
	{
	case QUERY_COUNT:
	case QUERY_COUNT_RATING:
	case QUERY_COUNT_ARTIST:
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TRACKS_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("TOTAL_TRACKS"));
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TIME_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("TOTAL_TIME"));
        skinGetColor("RGBA_TEXT", tempColor);
        skinGetColor("RGBA_TEXT_SHADOW", tempColorShadow);
        setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);
        snprintf(buffer, sizeof(buffer), "%.f", MLresult[commonMenu.selected - mlBufferPosition]->intField01);
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TRACKS_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], buffer);

        formatHHMMSS(MLresult[commonMenu.selected - mlBufferPosition]->intField02, buffer, sizeof(buffer));
        skinGetPosition("POS_MEDIALIBRARY_TOTAL_TIME_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], buffer);
		break;
	case QUERY_SINGLE_ENTRY:
        skinGetPosition("POS_MEDIALIBRARY_GENRE_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("GENRE"));
        skinGetPosition("POS_MEDIALIBRARY_YEAR_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("YEAR"));
        skinGetPosition("POS_MEDIALIBRARY_TIME_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("TIME"));
        skinGetPosition("POS_MEDIALIBRARY_RATING_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("RATING"));
        skinGetPosition("POS_MEDIALIBRARY_PLAYED_LABEL", tempPos);
        oslDrawString(tempPos[0], tempPos[1], langGetString("PLAYED"));

        skinGetColor("RGBA_TEXT", tempColor);
        skinGetColor("RGBA_TEXT_SHADOW", tempColorShadow);
        setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT);
        skinGetPosition("POS_MEDIALIBRARY_GENRE_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], MLresult[commonMenu.selected - mlBufferPosition]->genre);
        skinGetPosition("POS_MEDIALIBRARY_YEAR_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], MLresult[commonMenu.selected - mlBufferPosition]->year);

        formatHHMMSS(MLresult[commonMenu.selected - mlBufferPosition]->seconds, buffer, sizeof(buffer));
        skinGetPosition("POS_MEDIALIBRARY_TIME_VALUE", tempPos);
        oslDrawString(tempPos[0], tempPos[1], buffer);

        skinGetPosition("POS_MEDIALIBRARY_RATING_VALUE", tempPos);
        drawRating(tempPos[0], tempPos[1], MLresult[commonMenu.selected - mlBufferPosition]->rating);

		skinGetPosition("POS_MEDIALIBRARY_PLAYED_VALUE", tempPos);
		snprintf(buffer, sizeof(buffer), "%i", MLresult[commonMenu.selected - mlBufferPosition]->played);
		oslDrawString(tempPos[0], tempPos[1], buffer);

		if (commonMenu.selected != lastSelected){
			sceRtcGetCurrentTick (&lastMenuChange);
			lastSelected = commonMenu.selected;
			if (coverArt){
				oslDeleteImage(coverArt);
				coverArt = NULL;
			}
			coverArtFailed = 0;
		}else if (!coverArt && !coverArtFailed){
			u64 currentTime;
			sceRtcGetCurrentTick(&currentTime);
			if (currentTime - lastMenuChange > COVERTART_DELAY){
				char dirName[264];
				int size = 0;

				cpuBoost();
				snprintf(dirName, sizeof(dirName), "%s", MLresult[commonMenu.selected - mlBufferPosition]->shortpath);
				directoryUp(dirName);
				//Look for folder.jpg in the same directory:
				snprintf(buffer, sizeof(buffer), "%s/%s", dirName, "folder.jpg");

				size = fileExists(buffer);
				if (size > 0 && size <= MAX_IMAGE_DIMENSION)
                {
					tmpCoverArt = oslLoadImageFileJPG(buffer, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
                }
				else
                {
					//Look for cover.jpg in same directory:
					snprintf(buffer, sizeof(buffer), "%s/%s", dirName, "cover.jpg");
					size = fileExists(buffer);
					if (size > 0 && size <= MAX_IMAGE_DIMENSION)
						tmpCoverArt = oslLoadImageFileJPG(buffer, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
				}
				if (tmpCoverArt){
    				int coverArtWidth  = skinGetParam("MEDIALIBRARY_COVERART_WIDTH");
    				int coverArtHeight = skinGetParam("MEDIALIBRARY_COVERART_HEIGHT");

					coverArt = oslScaleImageCreate(tmpCoverArt, OSL_IN_RAM | OSL_SWIZZLED, coverArtWidth, coverArtHeight, OSL_PF_8888);
					oslDeleteImage(tmpCoverArt);
					tmpCoverArt = NULL;

        			coverArt->stretchX = coverArtWidth;
        			coverArt->stretchY = coverArtHeight;
				}else{
					coverArtFailed = 1;
				}
				cpuRestore();
			}
		}

		if (coverArt){
			skinGetPosition("POS_MEDIALIBRARY_COVERART", tempPos);
			oslDrawImageXY(coverArt, tempPos[0], tempPos[1]);
		}
		break;
	}
}