Welcome! Log In Create A New Profile

Advanced

Picture Placement Problem

Posted by g_man 
Picture Placement Problem
August 01, 2009 08:08AM
Ok, I'm using libWiiSprite, and im trying to load a picture for each app in the apps folder, but what ends up happening is that in prints in the right locations, but it only shows one picture, the last one.
For Example:
if the files were in this order:
homebrew browser
ftpii
quake

it would only show the quake picture.
So, I checked my path to the picture and it is all the same path
here is the code that is causing the problem:
DIR *dp;
struct dirent *ep;
if(opendir("SD:/apps")){ //If the apps folder exists
	dp = opendir("SD:/apps");
	while((ep = readdir(dp))){
		dircounter++;
		strcpy(path,"SD:/apps/");
		strcat(path,(ep->d_name));
		applist[dircounter].setDir(path);
	}	
	closedir(dp);
}
another weird thing that is happening is that, i think my code tells it to save the correct path to setPngDir(), but it ends up saving the path to setDir()(The path is the path to the icon.png)
here is the code:
for(i=3;i<=dircounter;i++){
	if(opendir(applist.getDir())){ // Good practice
		dp = opendir(applist.getDir());
		while((ep = readdir(dp))){ //While there is a directory to read
			if (strcmp(strlower(ep->d_name), "icon.png") == 0){
				
				strcpy(path,applist.getDir());
				strcat(path,"/icon.png");
				applist.setPngDir(path);
			}
		}
	}
}	

and my object code:
//App object
class appobj {
	public:
	
	//Accessor methods appname
	
	string getName() {return appname;}
	void setName(string name) { appname = name;}
	//hasdol
	bool getDol() {return hasdol;}
	void setDol(bool dol) { hasdol = dol;}
	//appdir
	string getDir() {return appdir;}
	void setDir(string dir) { appdir = dir;}
	//pngdir
	string getPngDir() {return pngdir;}
	void setPngDir(string pdir) { pngdir = pdir;}
	//coder
	string getCoder() {return coder;}
	void setCoder(string cod) { coder = cod;}
	//v_info
	string getVInfo() {return v_info;}
	void setVInfo(string vin) { v_info = vin;}
	//date
	string getDate() {return date;}
	void setDate(string dat) { date = dat;}
	//s_desc
	string getShortD() {return s_desc;}
	void setShortD(string sdes) { s_desc = sdes;}
	//l_desc
	string getLongD() {return l_desc;}
	void setLongD(string ldes) { l_desc = ldes;}
	//appnmbr
	int getNumber() {return appnmbr;}
	void setNumber(int nmbr) { appnmbr = nmbr;}

	
	Image appimg;
	Sprite appspr;
	
	private:
	string appname;
	bool hasdol;
	string appdir;
	string pngdir;
	string coder;
	string v_info;
	string date;
	string s_desc;//Short description
	string l_desc;//Long description
	int appnmbr;

};



Edited 1 time(s). Last edit at 08/01/2009 06:22PM by g_man.
Re: Picture Placement Problem
August 02, 2009 10:05PM
The problem sounds like your app is drawing all of the icon.png images on top of each other. Increase the X and/or Y value of your sprite after every render.
Re: Picture Placement Problem
August 16, 2009 06:48PM
Sorry this is taking so long to reply, i've been gone for 2 weeks, but anyway, I still have the same problem, even with the code you told me to add
Here it is:
i = 3;//Replace the pictues
tester = 3;
for(y=30;y<480;y+=(48+30)){
	for(x=28;x<640;x+=(128+25)){	
		if(applist.getOver() == false){ // If the mouse is not of the picture
			applist.appspr.SetStretchWidth(1); // Set Strech to normal
			applist.appspr.SetStretchHeight(1);
			applist.appspr.SetPosition(x,y); //Set Position to normal
			tester++; // If tester is the same as i, then no picture is selected
		}	
		i++;
	}
}
test, getOver, and the stretch stuff is only used for zooming on an icon when i select it
Re: Picture Placement Problem
August 29, 2009 05:57AM
Anybody?
Re: Picture Placement Problem
August 31, 2009 05:10AM
Ok, I finally found where my problem is. It is somewhere in these 10 lines of code.
if(opendir("SD:/apps")){ //If the apps folder exists
	dp = opendir("SD:/apps");
	while((ep = readdir(dp))){
		dircounter++;
		strcpy(path,"SD:/apps/");
		strcat(path,(ep->d_name));
		applist[dircounter].setDir(path);
	}	
	closedir(dp);
}
the same value is in every applist[dircounter].setDir(). That value is also the last value that is read by ep = readdir(dp)

EDIT: sorry about the triple post :(



Edited 1 time(s). Last edit at 08/31/2009 05:10AM by g_man.
Sorry, only registered users may post in this forum.

Click here to login