コード例 #1
0
ファイル: Category.cpp プロジェクト: j-burgos/mpsp3
Category::Category(string label, string imgpath) {
    int location = OSL_IN_RAM|OSL_SWIZZLED;
    int pxlfmt = OSL_PF_8888;
    this->label = label;
    this->imgDisabled = oslLoadImageFilePNG((char*)(imgpath+"normal.png").c_str(),location,pxlfmt);
    this->imgEnabled = oslLoadImageFilePNG((char*)(imgpath+"selected.png").c_str(),location,pxlfmt);
}
コード例 #2
0
ファイル: appDrawer.c プロジェクト: omarmc9203/CyanogenPSP
void appdrawer_loadImages()
{
	if (DARK == 0)
		backdrop = oslLoadImageFilePNG(backdropPath, OSL_IN_RAM, OSL_PF_8888);
	else 
		backdrop = oslLoadImageFilePNG("system/home/icons/backdropDark.png", OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_clock = oslLoadImageFilePNG(clockPath, OSL_IN_RAM, OSL_PF_8888);
}
コード例 #3
0
ファイル: PBPParse.cpp プロジェクト: smgx360420/Mentro
void PBPParse::Parse(const char *file){
	fid = sceIoOpen(file, PSP_O_RDONLY, 0777);

	sceIoMkdir("ms0:/TMP", 0777);
	if (fid >= 0)
	{
		if (sceIoRead(fid, &header, sizeof(PBPHeader)) == sizeof(PBPHeader)){

			char *temp = (char*)malloc(header.icon0 - header.sfo);
			sceIoLseek(fid, header.sfo, PSP_SEEK_SET);
			sceIoRead(fid, temp, header.icon0 - header.sfo);
			SceUID sfoFile = sceIoOpen("ms0:/TMP/PARAM.SFO", PSP_O_CREAT | PSP_O_WRONLY, 0777);
			sceIoWrite(sfoFile, temp, header.icon0 - header.sfo);
			sceIoClose(sfoFile);
			free(temp);
			sfo.Parse("ms0:/TMP/PARAM.SFO");

			temp = (char*)malloc(header.icon1 - header.icon0);
			sceIoLseek(fid, header.icon0, PSP_SEEK_SET);
			sceIoRead(fid, temp, header.icon1 - header.icon0);
			SceUID icoFile = sceIoOpen("ms0:/TMP/ICON0.PNG", PSP_O_CREAT | PSP_O_WRONLY, 0777);
			sceIoWrite(icoFile, temp, header.icon1 - header.icon0);
			sceIoClose(icoFile);
			if (header.icon1 - header.icon0 > 0){
				OSL_IMAGE *ico = oslLoadImageFilePNG("ms0:/TMP/ICON0.PNG", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5650);
				icon = oslScaleImageCreate(ico, OSL_IN_RAM, 64, 64, OSL_PF_5650);
				oslDeleteImage(ico);
				oslWriteImageFilePNG(icon, "ms0:/TMP/ICON0.PNG", 0);
			}
			else{
				icon = oslCreateImageCopy(defaultUNKN, OSL_IN_RAM);
			}
			free(temp);

			temp = (char*)malloc(header.snd - header.pic1);
			sceIoLseek(fid, header.pic1, PSP_SEEK_SET);
			sceIoRead(fid, temp, header.snd - header.pic1);
			SceUID picFile = sceIoOpen("ms0:/TMP/PIC1.PNG", PSP_O_CREAT | PSP_O_WRONLY, 0777);
			sceIoWrite(picFile, temp, header.snd - header.pic1);
			sceIoClose(picFile);
			if (header.snd - header.pic1 > 0){
				pic = oslLoadImageFilePNG("ms0:/TMP/PIC1.PNG", OSL_IN_RAM, OSL_PF_8888);

				OSL_IMAGE *tmpPic = oslScaleImageCreate(pic, OSL_IN_RAM, 128, 128, OSL_PF_8888);
				oslUnswizzleImage(tmpPic);
				oslWriteImageFilePNG(tmpPic, "ms0:/TMP/PIC1SC.PNG", 0);
				oslDeleteImage(tmpPic);
				oslDeleteImage(pic);	//Get rid of the pic file for now, we don't need it
			}
			free(temp);

			sceIoClose(fid);
		}
	}
}
コード例 #4
0
ファイル: main.c プロジェクト: omarmc9203/CyanogenPSP
void displayLangSelection(char * browseDirectory)
{	
	langSelection = oslLoadImageFilePNG("system/settings/langSelection.png", OSL_IN_RAM, OSL_PF_8888);

	oslSetFont(Roboto);
	
	browseDirectory = langBrowse("system/settings/language"); //For language

	if (!langSelection)
		debugDisplay();
	
	while (!osl_quit)
	{
		LowMemExit();
	
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		centerText(480/2, 272/2, browseDirectory, 50);
		
		oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();	
	}
}
コード例 #5
0
ファイル: MainMenuScreen.cpp プロジェクト: dogo/gods-defense
MainMenuScreen::MainMenuScreen()
{
	gIsMultiplayer = false;
	menubg = oslLoadImageFilePNG(Resource::IMG_MAIN_MENU_BG, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

	if (!menubg)
		oslFatalError("At least one file is missing. Please copy all the file in the game directory.");
}
コード例 #6
0
ファイル: musicPlayer.c プロジェクト: omarmc9203/CyanogenPSP
int mp3View(char * browseDirectory)
{	
	mp3bg = oslLoadImageFilePNG(apolloBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3_select = oslLoadImageFilePNG(apolloSelectorPath, OSL_IN_RAM, OSL_PF_8888);

	oslSetFont(Roboto);

	char * Directory = mp3Browse(browseDirectory);

	while (!osl_quit)
	{		
		LowMemExit();
	
		oslStartDrawing();
		oslClearScreen(RGB(0,0,0));	
		
		centerText(480/2, 272/2, Directory, 50);	// Shows the path that 'Directory' was supposed to receive from mp3Browse();
	 
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
	}	
	return 0;
}
コード例 #7
0
ファイル: Ressource.cpp プロジェクト: Ryp/PSPgames
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);
}
コード例 #8
0
ファイル: oslLoadImageFile.c プロジェクト: dogo/oslibmodv2
//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;
}
コード例 #9
0
ファイル: messenger.c プロジェクト: omarmc9203/CyanogenPSP
int messenger()
{	
	messengerbg = oslLoadImageFilePNG("system/app/messenger/messengerbg.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!messengerbg)
		debugDisplay();
	
	oslSetFont(Roboto);
		
	while (!osl_quit)
	{
		LowMemExit();

		oslStartDrawing();	
		
		oslClearScreen(RGB(0,0,0));
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
		
		controls();	

		oslDrawImageXY(messengerbg, 0, 0);

		navbarButtons(2);
		battery(330,2,0);
		digitaltime(381,4,0,hrTime);
		androidQuickSettings();
		volumeController();
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(messengerbg);
			appdrawer();
		}
	
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			appdrawer();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			home();
		}
		
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			multitask();
		}
		
		captureScreenshot();
		
		if (cursor->x >= 385 && cursor->x <= 428 && cursor->y >= 210 && cursor->y <= 258 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			newMessage();
		}
		
		/*
		if (cursor->x >= 378 && cursor->x <= 434 && cursor->y >= 20 && cursor->y <= 52 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			doClient();
		}
		*/
		
		oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();
	}
	return 0;
}
コード例 #10
0
ファイル: messenger.c プロジェクト: omarmc9203/CyanogenPSP
void newMessage()
{	
	new_message = oslLoadImageFilePNG("system/app/messenger/new_message.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!new_message)
		debugDisplay();
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();
		
		oslClearScreen(RGB(0,0,0));
		
		controls();	

		oslDrawImageXY(new_message, 0, 0);
		
		navbarButtons(2);
		battery(330,2,0);
		digitaltime(381,4,0,hrTime);
		androidQuickSettings();
		volumeController();
		oslDrawImage(cursor);
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(new_message);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 157 && cursor->y <= 213) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			messenger();
		}

		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 76 && cursor->y <= 155) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(messengerbg);
			home();
		}
		
		if ((cursor->x  >= 444 && cursor->x  <= 480) && (cursor->y >= 19 && cursor->y <= 75) && (osl_keys->pressed.cross))
		{
			oslPlaySound(KeypressStandard, 1);  
			multitask();
		}
		
		captureScreenshot();
		
		if (cursor->x >= 7 && cursor->x <= 435 && cursor->y >= 55 && cursor->y <= 86 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			doServer();
		}
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT);
		oslDrawString(14, 245, tempMessage);
		
		if (cursor->x >= 10 && cursor->x <= 362 && cursor->y >= 228 && cursor->y <= 270 && osl_keys->pressed.cross)
		{
			oslPlaySound(KeypressStandard, 1);  
			openOSK("Enter Message", "", 128, -1);
		}
		
		if ((cursor->x >= 10 && cursor->x <= 405 && cursor->y >= 88 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doClient();
        else if ((cursor->x >= 410 && cursor->x <= 442 && cursor->y >= 92 && cursor->y <= 118 && osl_keys->pressed.cross) && oslIsWlanPowerOn())
			doServer();
		
        oslEndDrawing(); 
		oslEndFrame(); 
        oslSyncFrame();
	}
}
コード例 #11
0
ファイル: TitleScreen.cpp プロジェクト: dogo/gods-defense
TitleScreen::TitleScreen()
{
	GDSplash = oslLoadImageFilePNG(Resource::IMG_GAME_TITLE, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
}
コード例 #12
0
ファイル: main.c プロジェクト: omarmc9203/CyanogenPSP
int main()
{
	initOSLib(); //Initializes OsLib
	oslIntraFontInit(INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8); //Initializes OSL fonts

	//Loads our audio tones
	camera_click = oslLoadSoundFile("system/media/audio/ui/camera_click.wav", OSL_FMT_NONE);
	KeypressStandard = oslLoadSoundFile("system/media/audio/ui/KeypressStandard.wav", OSL_FMT_NONE);
	Lock = oslLoadSoundFile("system/media/audio/ui/Lock.wav", OSL_FMT_NONE);
	Unlock = oslLoadSoundFile("system/media/audio/ui/Unlock.wav", OSL_FMT_NONE);
	
	strcpy(backgroundPath, setFileDefaultsChar("system/settings/background.bin", "system/framework/framework-res/res/background1.png", backgroundPath));
	strcpy(fontPath, setFileDefaultsChar("system/settings/font.bin", "system/fonts/Roboto.pgf", fontPath));
	
	hrTime = setFileDefaultsInt("system/app/clock/timeSet.bin", 0, hrTime);
	language = setFileDefaultsInt("system/settings/language.bin", 0, language);
	batteryM = setFileDefaultsInt("system/settings/battery.bin", 1, batteryM);
	experimentalF = setFileDefaultsInt("system/settings/experimentalFeatures.bin", 0, experimentalF);
	DARK = setFileDefaultsInt("system/settings/darkTheme.bin", 0, DARK);
	fontSize = setFileDefaultsFloat("system/settings/fontSize.bin", 0.5, fontSize);
	
	checkGBootActivation();
	createDirs();
	themesLoad();
	
	FILE *temp;
	 
	if (!(fileExists(rgbValuesPath)))
	{
		temp = fopen(rgbValuesPath, "w");
		fprintf(temp, "0\n149\n135");
		fclose(temp);
	}
	
	temp = fopen(rgbValuesPath, "r");
	fscanf(temp, "%d %d %d", &r, &g, &b);
	fclose(temp);
	
	quickSettings = oslLoadImageFile(quickSettingsBgPath, OSL_IN_VRAM, OSL_PF_8888);
	batt100 = oslLoadImageFile("system/home/icons/100.png", OSL_IN_VRAM, OSL_PF_8888);
	batt80 = oslLoadImageFile("system/home/icons/80.png", OSL_IN_VRAM, OSL_PF_8888);
	batt60 = oslLoadImageFile("system/home/icons/60.png", OSL_IN_VRAM, OSL_PF_8888);
	batt40 = oslLoadImageFile("system/home/icons/40.png", OSL_IN_VRAM, OSL_PF_8888);
	batt20 = oslLoadImageFile("system/home/icons/20.png", OSL_IN_VRAM, OSL_PF_8888);
	batt10 = oslLoadImageFile("system/home/icons/10.png", OSL_IN_VRAM, OSL_PF_8888);
	batt0 = oslLoadImageFile("system/home/icons/0.png", OSL_IN_VRAM, OSL_PF_8888);
	battcharge = oslLoadImageFile("system/home/icons/charge.png", OSL_IN_VRAM, OSL_PF_8888);
	volumeBar = oslLoadImageFilePNG("system/home/menu/volumeBar.png", OSL_IN_RAM, OSL_PF_8888);
	volumeControl = oslLoadImageFile(volumeControlPath, OSL_IN_RAM, OSL_PF_8888);
	layerA = oslLoadImageFilePNG("system/home/icons/layerA.png", OSL_IN_RAM, OSL_PF_8888);
	layerB = oslLoadImageFilePNG("system/home/icons/layerB.png", OSL_IN_RAM, OSL_PF_8888);
	navbarHighlight = oslLoadImageFilePNG(navbarHighlightPath, OSL_IN_RAM, OSL_PF_8888);
	navbarHighlight2 = oslLoadImageFilePNG(navbarHighlight2Path, OSL_IN_RAM, OSL_PF_8888);
	
	Roboto = oslLoadIntraFontFile(fontPath, INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8);
	oslSetFont(Roboto); //Load and set font
	
	SceUID kModule[3];
	
	kModule[0] = pspSdkLoadStartModule("modules/display.prx", PSP_MEMORY_PARTITION_KERNEL);
	kModule[1] = pspSdkLoadStartModule("modules/control.prx", PSP_MEMORY_PARTITION_KERNEL);
	kModule[2] = pspSdkLoadStartModule("modules/impose.prx", PSP_MEMORY_PARTITION_KERNEL);
	
	int i;
	
	for (i = 0; i < 3; i++)
	{
		if (kModule[i] < 0)
		{
			pspDebugScreenPrintf("Error 0x%08X starting module.\n", kModule[i]);
			break;
		}
	}
	
	deleteUpdateFile(); //Delete update.zip
	
	setCpuBoot(); //Set default CPU or load pre-existing value
	setPowerManagement(); //Set default power save settings or load pre-existing values.
	
	getPSPNickname(); //Get PSP name before hand
	strcpy (pspname, nickname);
	
	//Main loop to run the program
	while (!osl_quit)
	{		
		bootAnimation();
		
		//Ends Printing and Drawing
		oslEndDrawing(); 

		//End's Frame
        oslEndFrame(); 
		
		//Synchronizes the screen 
		oslSyncFrame();	
	}
	
	//Terminates/Ends the program
	oslQuit();
	return 0;
}
コード例 #13
0
ファイル: WarningScreen.cpp プロジェクト: dogo/gods-defense
WarningScreen::WarningScreen()
{
	mBack = oslLoadImageFilePNG(Resource::IMG_BACK, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	mCover = oslLoadImageFilePNG(Resource::IMG_COVER, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
}
コード例 #14
0
ファイル: musicPlayer.c プロジェクト: omarmc9203/CyanogenPSP
int mp3player() 
{
	mp3bg = oslLoadImageFilePNG(apolloBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3_select = oslLoadImageFilePNG(apolloSelectorPath, OSL_IN_RAM, OSL_PF_8888);
	
	if (!mp3bg || !mp3_select)
		debugDisplay();

	oslSetFont(Roboto);
	
	int MenuSelection = 1; // Pretty obvious
	int selector_x = 8; //The x position of the first selection
	int selector_y = 43; //The y position of the first selection
	int selector_image_x; //Determines the starting x position of the selection
	int selector_image_y = 55; //Determines the starting y position of the selection
	int numMenuItems = 3; //Amount of items in the menu
	int selection = 0;

	while (!osl_quit)
	{		
		LowMemExit();
		
		selector_image_x = selector_x+(mp3XSelection*MenuSelection); //Determines where the selection image is drawn for each selection
        selector_image_y = selector_y+(mp3YSelection*MenuSelection); //Determines where the selection image is drawn for each selection
	
		oslStartDrawing();
		oslReadKeys();
		oslClearScreen(RGB(0,0,0));	
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);
		
		oslDrawImageXY(mp3bg, 0, 0);
		oslDrawImageXY(mp3_select, selector_image_x, selector_image_y);
		
		oslDrawStringf(20,108,"MUSIC");
		oslDrawStringf(20,163,"PSP/MUSIC");
		oslDrawStringf(20,218,"PSP/GAME/CyanogenPSP/Downloads");
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
        if (osl_keys->pressed.down) MenuSelection++; //Moves the selector down
        if (osl_keys->pressed.up) MenuSelection--; //Moves the selector up
        
        if (MenuSelection > numMenuItems) MenuSelection = 1; //Sets the selection to the first
        if (MenuSelection < 1) MenuSelection = numMenuItems; //Sets the selection back to last
		
		if (MenuSelection == 1 && osl_keys->pressed.cross)
        {	
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			mp3View("ms0:/MUSIC");
        }
		else if (MenuSelection == 2 && osl_keys->pressed.cross)
        {		
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			mp3View("ms0:/PSP/MUSIC");
        }
		else if (MenuSelection == 3 && osl_keys->pressed.cross)
        {	
			oslPlaySound(KeypressStandard, 1);  
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			mp3View("ms0:/PSP/GAME/CyanogenPSP/downloads");
        }
		
		if (osl_keys->pressed.circle)
		{
			oslDeleteImage(mp3bg);
			oslDeleteImage(mp3_select);
			appdrawer();
		}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
	
		captureScreenshot();
		
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
	}	
	return selection;
}
コード例 #15
0
ファイル: PBPParse.cpp プロジェクト: smgx360420/Mentro
void PBPParse::setDefaultUNKN()
{
	defaultUNKN = oslLoadImageFilePNG("UNKN.PNG", OSL_IN_RAM, OSL_PF_5650);
}
コード例 #16
0
ファイル: main.c プロジェクト: Arcanixus/PVZ-PSP-Game
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
	int skip = 0;
    int enabled = 1;
    int selectedConfig = 0;
    SetupCallbacks();

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);
    oslNetInit();

    //Loads image:
    bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

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

    if (!oslIsWlanPowerOn())
        sprintf(message, "Please turn on the WLAN.");

    //Get connections list:
    struct oslNetConfig configs[OSL_MAX_NET_CONFIGS];
    int numconfigs = oslGetNetConfigs(configs);
    if (!numconfigs){
        sprintf(message, "No configuration found!");
        enabled = 0;
    }

    while(runningFlag && !osl_quit){
        if (!skip){
			oslStartDrawing();
			oslDrawImageXY(bkg, 0, 0);
            if (enabled){
                sprintf(buffer, "Press X to connect to %s.", configs[selectedConfig].name);
    			oslDrawString(30, 50, buffer);
    			oslDrawString(30, 80, "Press UP and DOWN to change settings.");
            }
            oslDrawString(30, 150, "Press /\\ to quit.");
			oslDrawString(30, 200, message);

			oslEndDrawing();
		}
        oslEndFrame();
        skip = oslSyncFrame();

        oslReadKeys();
        if (osl_keys->released.triangle)
            runningFlag = 0;

        if (osl_keys->released.cross){
            connectToAP(selectedConfig + 1);
        }else if (osl_keys->released.up){
            if (++selectedConfig >= numconfigs)
                selectedConfig = numconfigs - 1;
        }else if (osl_keys->released.down){
            if (--selectedConfig < 0)
                selectedConfig = 0;
        }
    }
    //Quit OSL:
    oslNetTerm();
    oslEndGfx();
    sceKernelExitGame();
    return 0;

}
コード例 #17
0
ファイル: powerMenu.c プロジェクト: omarmc9203/CyanogenPSP
void powermenu()
{	
	power = oslLoadImageFilePNG("system/home/menu/powerMenu.png", OSL_IN_RAM, OSL_PF_8888);
	powerSelection = oslLoadImageFilePNG("system/home/menu/powerSelection.png", OSL_IN_RAM, OSL_PF_8888);
	recoverySelection = oslLoadImageFilePNG("system/home/menu/recoverySelection.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!power || !powerSelection || !recoverySelection)
		debugDisplay();

	while (!osl_quit)
	{
		LowMemExit();
	
		oslStartDrawing();

		controls();	

		oslClearScreen(RGB(0,0,0));	
		oslDrawImage(background);
		oslDrawImageXY(ic_launcher_apollo, 105, 190);
		oslDrawImageXY(ic_launcher_browser, 276, 190);
		oslDrawImageXY(ic_launcher_settings, 331, 190);
		oslDrawImageXY(ic_launcher_messenger, 160, 190);
		navbarButtons(0);
		oslDrawImageXY(power, 100, 61);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		
		oslIntraFontSetStyle(Roboto, 0.75f, BLACK, 0, 0);
		oslDrawStringf(165, 100, "Power off");
		oslDrawStringf(165, 165, "Recovery");
		
		if (cursor->x >= 116 && cursor->x <= 364 && cursor->y >= 55 && cursor->y <= 125) 
		{
			oslDrawImageXY(powerSelection, 100, 60);
			oslDrawStringf(165, 100, "Power off");
			oslDrawStringf(165, 165, "Recovery");
			
			if (osl_keys->pressed.cross)
			{	
				oslPlaySound(KeypressStandard, 1);  
				sceKernelExitGame();
			}
			/*else if (osl_pad.held.cross)
			{
				scePowerRequestColdReset(0);
				scePowerRequestColdReset(50000);
			}*/
		}
		if (cursor->x >= 116 && cursor->x <= 364 && cursor->y >= 126 && cursor->y <= 200) 
		{
			oslDrawImageXY(recoverySelection, 100, 60);
			oslDrawStringf(165, 100, "Power off");
			oslDrawStringf(165, 165, "Recovery");
			if (osl_keys->pressed.cross)
			{	
				oslPlaySound(KeypressStandard, 1);  
				oslSyncFrame();
				sceKernelDelayThread(3*1000000);
				oslDeleteImage(power);
				oslDeleteImage(powerSelection);
				oslDeleteImage(recoverySelection);
				mainRecoveryMenu();
			}
		}
		
		oslDrawImage(cursor);
	
		if (osl_keys->pressed.circle)
		{	
			oslDeleteImage(power);
			oslDeleteImage(powerSelection);
			oslDeleteImage(recoverySelection);
			return;
		}
		
		captureScreenshot();
		
		oslEndDrawing(); 
		oslEndFrame(); 
		oslSyncFrame();
	}
}
コード例 #18
0
ファイル: main.c プロジェクト: DavisDev/oslib-mod
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int skip = 0;
    SetupCallbacks();

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);

    //Loads image:
    OSL_IMAGE *bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
    OSL_IMAGE *rect_01 = oslLoadImageFilePNG("rect_01.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

    //Load fonts:
    OSL_FONT *pgfFont = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslIntraFontSetStyle(pgfFont, 0.5, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);

    OSL_FONT *oftFont = oslLoadFontFile("font.oft");
    oslSetTextColor(RGBA(255,255,255,255));
    oslSetBkColor(RGBA(0,0,0,0));

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

            oslDrawImageXY(rect_01, 50, 50);
            oslSetFont(pgfFont);
            oslDrawString(55, 55, "pgf on alpha image");
            oslSetFont(oftFont);
            oslDrawString(55, 70, "oft on alpha image");

            oslDrawFillRect(30, 150, 200, 250, RGB(150, 150, 150));
            oslSetFont(pgfFont);
            oslDrawString(35, 155, "pgf on rect");
            oslSetFont(oftFont);
            oslDrawString(35, 170, "oft on rect");

            oslDrawFillRect(300, 150, 400, 250, RGB(100, 100, 100));
            oslSetFont(pgfFont);
            oslDrawString(305, 155, "pgf on rect");
            oslSetFont(oftFont);
            oslDrawString(305, 170, "oft on rect");

            oslDrawGradientRect(300, 20, 430, 120, RGBA(100, 100, 100, 100),RGBA(100, 100, 100, 100), RGBA(200, 200, 200, 100), RGBA(200, 200, 200, 100));
            oslSetFont(pgfFont);
            oslDrawString(305, 25, "pgf on gradient rect");
            oslSetFont(oftFont);
            oslDrawString(305, 40, "oft on gradient rect");

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

    sceKernelExitGame();
    return 0;

}
コード例 #19
0
ファイル: musicPlayer.c プロジェクト: omarmc9203/CyanogenPSP
int soundPlay(char * path)
{	
	nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888);
	mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888);
	
	OSL_SOUND * sound = oslLoadSoundFile(path, OSL_FMT_NONE);

	if (!nowplaying)
		debugDisplay();
	
	oslInitAudioME(3);
	
	oslPlaySound(sound,0);
	
	isPlaying = 1;
	
	int Play = 1;
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();		
		
		oslClearScreen(RGB(0,0,0));

		oslReadKeys();
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);
		
		oslDrawImageXY(nowplaying, 0, 0);
		
		if (Play == 1)
			oslDrawImageXY(mp3Play, 230, 224);
		else if (Play == 0)
			oslDrawImageXY(mp3Pause, 230, 224);
		
		oslDrawStringf(240,76, "%.28s", folderIcons[current].name);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
		if(osl_keys->pressed.select) 
		{
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			return 1;
		}
		
		if(osl_keys->pressed.cross && Play == 1) 
		{
			Play = 0;
			oslPlaySound(KeypressStandard, 1); 
			oslPauseSound(sound,-1);
		}
		else if(osl_keys->pressed.cross && Play == 0) 
		{
			Play = 1;
			oslPlaySound(KeypressStandard, 1); 
			oslPauseSound(sound,-1);
		}
		
		if(osl_keys->pressed.circle)
		{
			isPlaying = 0;
			oslStopSound(sound);
			oslDeleteSound(sound);
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			return 1;
		}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
	
		captureScreenshot();
		
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
		}
	oslStopSound(sound);
	oslDeleteSound(sound);
	oslDeleteImage(nowplaying);
	oslDeleteImage(mp3Play);
	oslDeleteImage(mp3Pause);
	return 0;
}
コード例 #20
0
ファイル: main.c プロジェクト: omarmc9203/CyanogenPSP
//First Boot Message
void firstBootInitiation()
{	
	firstBoot = setFileDefaultsInt("system/settings/boot.bin", 1, firstBoot);

	iconPackLoad();

	//Loads our images into memory
	loadIcons();
	background = oslLoadImageFile(backgroundPath, OSL_IN_RAM, OSL_PF_8888);
	cursor = oslLoadImageFilePNG(cursorPath, OSL_IN_VRAM, OSL_PF_8888);
	navbar = oslLoadImageFile(navbarPath, OSL_IN_RAM, OSL_PF_8888);
	navbar2 = oslLoadImageFile(navbar2Path, OSL_IN_RAM, OSL_PF_8888);
	//notif = oslLoadImageFile("system/home/menu/notif.png", OSL_IN_RAM, OSL_PF_8888);
	welcome = oslLoadImageFilePNG("system/home/icons/welcome.png", OSL_IN_RAM, OSL_PF_8888);
	transbackground = oslLoadImageFilePNG("system/home/icons/transbackground.png", OSL_IN_RAM, OSL_PF_8888);
	control = oslLoadImageFilePNG("system/home/menu/brightnesscontrol.png", OSL_IN_VRAM, OSL_PF_8888);
	ic_launcher_apollo = oslLoadImageFilePNG(apolloPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_browser = oslLoadImageFile(browserPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_calculator = oslLoadImageFilePNG(calcPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_filemanager = oslLoadImageFilePNG(fmPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_gallery = oslLoadImageFilePNG(galleryPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_game = oslLoadImageFilePNG(gamePath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_messenger = oslLoadImageFilePNG(messagesPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_settings = oslLoadImageFilePNG(settingsPath, OSL_IN_RAM, OSL_PF_8888);
	ic_launcher_umd = oslLoadImageFilePNG(umdPath, OSL_IN_RAM, OSL_PF_8888);
	usbdebug = oslLoadImageFilePNG("system/home/icons/usbdebug.png", OSL_IN_RAM, OSL_PF_8888);
	music = oslLoadImageFilePNG("system/home/icons/music.png", OSL_IN_RAM, OSL_PF_8888);
	
	
	//Debugger - Displays an error message if the following resources are missing.
	if (!background || !cursor || !ic_allapps || !ic_allapps_pressed || !navbar || !ic_launcher_apollo || !ic_launcher_settings || !ic_launcher_messenger || !ic_launcher_browser || !batt100 || !batt80 || !batt60 || !batt40 || !batt20 || !batt10 || !batt0 || !battcharge || !navbar2 || !usbdebug  || !music)
		debugDisplay();
		
	//Sets the cursor's original position on the screen
	cursor->x = 240;
	cursor->y = 136;	
	
	if (firstBoot!= 0)
	{
		while (!osl_quit)
		{		
			oslStartDrawing();

			controls();

			oslDrawImage(background);		
			oslDrawImageXY(ic_launcher_apollo, 105, 190);
			oslDrawImageXY(ic_launcher_browser, 276, 190);
			oslDrawImageXY(ic_launcher_settings, 331, 190);
			oslDrawImageXY(ic_launcher_messenger, 160, 190);
			oslSetTransparentColor(RGB(0,0,0));
			appDrawerIcon();
			oslDisableTransparentColor();
		
			oslIntraFontSetStyle(Roboto, 0.5f, WHITE, 0, INTRAFONT_ALIGN_LEFT);
			
			digitaltime(420,4,0,hrTime);
			volumeController();
			battery(370,2,1);
			navbarButtons(0);
			
			oslDrawImageXY(transbackground, 0, 0);
			oslDrawImageXY(welcome, 0, 0);
			
			oslIntraFontSetStyle(Roboto, 0.8f,BLACK,0,INTRAFONT_ALIGN_LEFT);
			oslDrawStringf(20,30, "%s", lang_welcome[language][0]);
			
			oslIntraFontSetStyle(Roboto, 0.6f,DARKGRAY,0,INTRAFONT_ALIGN_LEFT);
			oslDrawStringf(20,60, "%s", lang_welcome[language][1]);
			
			oslDrawStringf(20,80, "%s", lang_welcome[language][2]);
			
			oslIntraFontSetStyle(Roboto, 0.6f,WHITE,0,INTRAFONT_ALIGN_LEFT);
			oslDrawStringf(385,110, "%s", lang_welcome[language][3]);
			
			oslDrawImage(cursor);
	
			if (cursor->x >= 388 && cursor->x <= 464 && cursor->y >= 98 && cursor->y <= 132 && osl_keys->pressed.cross)
			{
				FILE * firstBootTxt = fopen("system/settings/boot.bin", "w"); 
				fprintf(firstBootTxt, "0");
				fclose(firstBootTxt);
				oslPlaySound(KeypressStandard, 1); 
				oslDeleteImage(welcome);
				oslDeleteImage(transbackground);
				unloadIcons();
				home();
			}
			
			captureScreenshot();
			
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
		}
	}
		
	if (firstBoot == 0)
	{
		oslDeleteImage(welcome);
		oslDeleteImage(transbackground);
		unloadIcons();
		lockscreen();
		home();
	}
}
コード例 #21
0
ファイル: main.c プロジェクト: omarmc9203/CyanogenPSP
int bootAnimation()
{
	int currentFrame = 0, i = 0;
	
	bootAnimActivator = setFileDefaultsInt("system/boot/bootAnimActivator.bin", 0, bootAnimActivator);
	firstBoot = setFileDefaultsInt("system/settings/boot.bin", 1, firstBoot);
	
	if (bootAnimActivator != 1)
	{
		if (firstBoot == 1)
			displayLangSelection("system/settings/language");
		else 
			firstBootInitiation();
	}
	
	bootAnim[0] = oslLoadImageFilePNG("system/boot/part1/boot0.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[1] = oslLoadImageFilePNG("system/boot/part1/boot1.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[2] = oslLoadImageFilePNG("system/boot/part1/boot2.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[3] = oslLoadImageFilePNG("system/boot/part1/boot3.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[4] = oslLoadImageFilePNG("system/boot/part1/boot4.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[5] = oslLoadImageFilePNG("system/boot/part1/boot5.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[6] = oslLoadImageFilePNG("system/boot/part1/boot6.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[7] = oslLoadImageFilePNG("system/boot/part1/boot7.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[8] = oslLoadImageFilePNG("system/boot/part1/boot8.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[9] = oslLoadImageFilePNG("system/boot/part1/boot9.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[10] = oslLoadImageFilePNG("system/boot/part1/boot10.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[11] = oslLoadImageFilePNG("system/boot/part1/boot11.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	bootAnim[12] = oslLoadImageFilePNG("system/boot/part1/boot12.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
	
	while(!osl_quit)
	{
		oslStartDrawing();
		oslDrawImageXY(bootAnim[currentFrame], 80, -25); 
		sceDisplayWaitVblankStart();
		oslEndDrawing();
		oslEndFrame();
		oslSyncFrame();
		sceKernelDelayThread(10000 * 2);
   
		currentFrame++;
		if(currentFrame > 12)
		{
			currentFrame = 0;
			i++;
		}
		
		if (i > 21)
		{
			for (i = 0; i <=12; i++)
			{
				oslDeleteImage(bootAnim[i]);
			}
			if (firstBoot == 1)
				displayLangSelection("system/settings/language");
			else 
				firstBootInitiation();
		}
    }
	oslEndDrawing(); 
    oslEndFrame(); 
	oslSyncFrame();	
	return 0;
}
コード例 #22
0
ファイル: musicPlayer.c プロジェクト: omarmc9203/CyanogenPSP
void MP3Play(char * path)
{	
	struct ID3Tag ID3;

	nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888);
	mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888);
	mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888);
	
	if (!nowplaying)
		debugDisplay();
	
	scePowerSetClockFrequency(333, 333, 166);
	
	pspAudioInit();
	
	int i, mp3Min = 0;
	MP3ME_Init(1);
	ParseID3(path, &ID3);
	MP3ME_Load(path);
	MP3ME_Play();
	
	isPlaying = 1;
	
	while (!osl_quit)
	{
		LowMemExit();
		
		oslStartDrawing();		
		
		oslClearScreen(RGB(0,0,0));

		oslReadKeys();
		
		oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0);
		
		if (MP3ME_playingTime > 59)
		{
			mp3Min += 1;
			MP3ME_playingTime = 0;
		}
		oslDrawImageXY(nowplaying, 0, 0);
		oslDrawStringf(240,76, "Playing: %.19s", folderIcons[current].name);
		oslDrawStringf(240,96, "Title: %.21s", ID3.ID3Title);
		
		oslDrawStringf(240,116, "Artist: %.20s", ID3.ID3Artist);
		oslDrawStringf(240,136, "Album: %.21s", ID3.ID3Album);
		oslDrawStringf(240,156, "Year: %.22s", ID3.ID3Year);
		oslDrawStringf(240,176, "Genre: %.21s", ID3.ID3GenreText);
		oslDrawStringf(435,206, "0%d:%.f", mp3Min, MP3ME_playingTime);
		
		if (MP3ME_isPlaying == 1)
			oslDrawImageXY(mp3Play, 230, 224);
		if (MP3ME_isPlaying == 0)
			oslDrawImageXY(mp3Pause, 230, 224);
		
		battery(370,2,1);
		digitaltime(420,4,0,hrTime);
		volumeController();
		
		if(osl_keys->pressed.select) 
		{
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			return;
		}
		
		if(MP3ME_isPlaying == 1 && osl_keys->pressed.cross) 
		{
			oslPlaySound(KeypressStandard, 1); 
			MP3ME_Pause();
			for(i=0; i<10; i++) 
			{
				sceDisplayWaitVblankStart();
			}
		}
		
		else if (MP3ME_isPlaying == 0 && osl_keys->pressed.cross)
		{
			MP3ME_Play();
		}
			
		if (MP3ME_EndOfStream() == 1) 
		{
			isPlaying = 0;
			endAudioLib();
			MP3ME_Stop();
			releaseAudio();
			MP3ME_Play();
		}
		
		if(osl_keys->pressed.circle)
		{
			endAudioLib();
			MP3ME_Stop();
			releaseAudio();
			oslDeleteImage(nowplaying);
			oslDeleteImage(mp3Play);
			oslDeleteImage(mp3Pause);
			isPlaying = 0;
			setCpuBoot(); //Restore previous CPU state
			return;
		}
		
		if (osl_keys->pressed.square)
		{
			powermenu();
		}
		
		if (osl_keys->pressed.L)
		{
			oslPlaySound(Lock, 1);  
			lockscreen();
		}
	
		captureScreenshot();
		
		oslEndDrawing(); 
        oslEndFrame(); 
		oslSyncFrame();	
		}
}
コード例 #23
0
ファイル: Tower.cpp プロジェクト: dogo/gods-defense
Tower::Tower(const string &towerName)
{
	//Default Initializers
	mTowerDirName = towerName;
	PspIO::lowerCase(mTowerDirName);

	mIsBuildable = true;
	mTowerName = NULL;
	mTowerDescription = NULL;
	mProjectileType = PT_Arrow;
	mHitsLand = false;
	mHitsFlyer = false;
	mTowerLength = 0;
	mMenuIcon = NULL;
	mTowerImg = NULL;
	mProjectileImg = NULL;
	mFireSound = NULL;
	mHitSound = NULL;

	char temp[256];
	sprintf(temp, "%s/Res/towers/%s/tower.xml", PspIO::getCurrentDirectory().c_str(), mTowerDirName.c_str());

	TiXmlDocument TowerXMLInput;
	TowerXMLInput.LoadFile(temp);

	if (TowerXMLInput.Error())
	{
		oslFatalError("Cannot open: %s", TowerXMLInput.ErrorDesc());
		return;
	}

	TiXmlElement *node = NULL;
	node = TowerXMLInput.FirstChildElement(); //head

	if (!node)
	{
		oslFatalError("No head node in: %s", temp);
		return;
	}

	node = node->FirstChildElement();

	while (node != NULL) //Read all XML file
	{
		string mCurrentLine = node->ValueStr();
		/*
		A função strdup() é usada em situações onde temos que alocar um espaço na memória para copiar determinada string.
		Sem utiliza-lá, teríamos que alocar o espaço antes com malloc(), para em seguida usar strncpy(), por exemplo, para copiar a string.
		A função retorna um ponteiro com a string já alocada (podendo ser liberado com free() depois de seu uso) em caso de sucesso,
		ou ENOMEM como erro caso a memória não tenha sida alocada por insuficiência.		
		*/
		if (mCurrentLine == "Name")
		{
			mTowerName = strdup(node->GetText());
		}
		else if (mCurrentLine == "Description")
		{
			mTowerDescription = strdup(node->GetText());
		}
		/*
		A função atoi() é usada para converter strings em números inteiros.
		*/
		else if (mCurrentLine == "TowerLength")
		{
			mTowerLength = atoi(node->GetText());
		}
		else if (mCurrentLine == "Capability")
		{
			const char* mAttributeText;

			mAttributeText = node->Attribute("HitsLand");
			if (mAttributeText != NULL && !strcmp(mAttributeText,"True")) //strcmp() return 0 if both string be the same.
			{
				mHitsLand = true;
			}

			mAttributeText = node->Attribute("HitsFlyers");
			if (mAttributeText != NULL && !strcmp(mAttributeText,"True")) //strcmp() return 0 if both string be the same.
			{
				mHitsFlyer = true;
			}
		}
		else if (mCurrentLine == "Projectile")
		{
			const char* ProjectileType = node->Attribute("Type");
			if (ProjectileType == NULL)
			{
				oslFatalError("No ProjectileType.");
				return;
			}
			//More Projectile Types goes here.
			if (!strcmp(ProjectileType, "Arrow"))
			{
				mProjectileType = PT_Arrow;
			}
			else if (!strcmp(ProjectileType, "Ice"))
			{
				mProjectileType = PT_Ice;
			}
			else if (!strcmp(ProjectileType, "Fire"))
			{
				mProjectileType = PT_Fire;
			}
			else if (!strcmp(ProjectileType, "Lightning"))
			{
				mProjectileType = PT_Lightning;
			}

			sprintf(temp, "/Res/towers/%s/%s", mTowerDirName.c_str(), node->Attribute("Sprite"));
			mProjectileImg = ProjectileInstance::LoadProjectileImage(mProjectileType, temp);
		}
		else if (mCurrentLine == "TowersLevels")
		{
			TiXmlElement *TowerLevelNode = node->FirstChildElement();
			while (TowerLevelNode != NULL) //read all Towers Levels
			{
				if (TowerLevelNode->ValueStr() != "TowersLevel")
				{
					oslFatalError("TowersLevel Error: %s",TowerLevelNode->Value());
					return;
				}
				mTowerVector.push_back(TowerInfo(TowerLevelNode)); //Insert a element in the end

				TowerLevelNode = TowerLevelNode->NextSiblingElement();
			}
		}
		else if (mCurrentLine == "TowerImg")
		{
			sprintf(temp, "/Res/towers/%s/%s", mTowerDirName.c_str(), node->Attribute("File"));
			mTowerImg = oslLoadImageFilePNG(temp, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

			mTowerImg->centerX = (mTowerImg->sizeX/2); //hotspot
			mTowerImg->centerY = (mTowerImg->sizeY/2); //hotspot

			node->QueryIntAttribute("Width", &mTowerWidth);
			node->QueryIntAttribute("Height", &mTowerHeight);
		}
		else if (mCurrentLine == "MenuIcon")
		{
			sprintf(temp, "/Res/towers/%s/%s", mTowerDirName.c_str(), node->Attribute("File"));
			mMenuIcon = oslLoadImageFilePNG(temp, OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
		}
		else if (mCurrentLine == "FireSound")
		{
			sprintf(temp, "/Res/towers/%s/%s", mTowerDirName.c_str(), node->Attribute("File"));
			mFireSound = oslLoadSoundFileWAV (temp, OSL_FMT_NONE);
		}
		else if (mCurrentLine == "HitSound")
		{
			sprintf(temp, "/Res/towers/%s/%s", mTowerDirName.c_str(), node->Attribute("File"));
			mHitSound = oslLoadSoundFileWAV (temp, OSL_FMT_NONE);
		}
		else
		{
			oslFatalError("Bad node, not donout for you: %s",mCurrentLine.c_str());
			return;
		}
		node = node->NextSiblingElement();
	}
}