Jeck - Simplistic solution to issue 131. Reads only the first line of themeinfo.txt and uses the first 16 characters as the author name, if present. The rest of the file is completely ignored. Not exactly the most elegant solution, but I don't think we really need much metadata beyond who the theme's author is. My suggestion would be to let the authors use the rest of the file as a "Readme.txt" with whatever details they want to put in it. (Art credits, etc.).
The next version of Wagic will use XML-like themes, so I think it's alright to use such a non-extensible format.
This commit is contained in:
@@ -408,11 +408,16 @@ private:
|
|||||||
class OptionTheme:public OptionDirectory{
|
class OptionTheme:public OptionDirectory{
|
||||||
public:
|
public:
|
||||||
OptionTheme();
|
OptionTheme();
|
||||||
JQuad * getImage();
|
JQuad * getImage();
|
||||||
|
virtual void updateValue();
|
||||||
virtual float getHeight();
|
virtual float getHeight();
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void confirmChange(bool confirmed);
|
virtual void confirmChange(bool confirmed);
|
||||||
virtual bool Visible();
|
virtual bool Visible();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
string author;
|
||||||
|
bool bChecked;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionProfile:public OptionDirectory{
|
class OptionProfile:public OptionDirectory{
|
||||||
|
|||||||
@@ -646,7 +646,8 @@ OptionTheme::OptionTheme(): OptionDirectory(RESPATH"/themes",Options::ACTIVE_THE
|
|||||||
addSelection("Default");
|
addSelection("Default");
|
||||||
sort(selections.begin(),selections.end());
|
sort(selections.begin(),selections.end());
|
||||||
initSelections();
|
initSelections();
|
||||||
mFocus=false;
|
mFocus=false;
|
||||||
|
bChecked = false;
|
||||||
}
|
}
|
||||||
JQuad * OptionTheme::getImage(){
|
JQuad * OptionTheme::getImage(){
|
||||||
char buf[512];
|
char buf[512];
|
||||||
@@ -662,12 +663,31 @@ JQuad * OptionTheme::getImage(){
|
|||||||
float OptionTheme::getHeight(){
|
float OptionTheme::getHeight(){
|
||||||
return 130;
|
return 130;
|
||||||
};
|
};
|
||||||
|
void OptionTheme::updateValue(){
|
||||||
|
OptionDirectory::updateValue();
|
||||||
|
bChecked = false;
|
||||||
|
}
|
||||||
|
|
||||||
void OptionTheme::Render(){
|
void OptionTheme::Render(){
|
||||||
JRenderer * renderer = JRenderer::GetInstance();
|
JRenderer * renderer = JRenderer::GetInstance();
|
||||||
JQuad * q = getImage();
|
JQuad * q = getImage();
|
||||||
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
|
JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT);
|
||||||
mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
|
mFont->SetColor(getColor(WGuiColor::TEXT_HEADER));
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
if(!bChecked){
|
||||||
|
author = "";
|
||||||
|
bChecked = true;
|
||||||
|
sprintf(buf,RESPATH"/themes/%s/themeinfo.txt",selections[value].c_str());
|
||||||
|
std::ifstream file(buf);
|
||||||
|
if(file){
|
||||||
|
string temp;
|
||||||
|
std::getline(file,temp);
|
||||||
|
for(unsigned int x=0;x<17,x<temp.size();x++){
|
||||||
|
if(isprint(temp[x])) //Clear stuff that breaks mFont->DrawString, cuts to 16 chars.
|
||||||
|
author += temp[x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
sprintf(buf,"Theme: %s",selections[value].c_str());
|
sprintf(buf,"Theme: %s",selections[value].c_str());
|
||||||
|
|
||||||
if(q){
|
if(q){
|
||||||
@@ -676,6 +696,14 @@ void OptionTheme::Render(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
mFont->DrawString(buf,x,y);
|
mFont->DrawString(buf,x,y);
|
||||||
|
if(bChecked && author.size()){
|
||||||
|
mFont->SetColor(getColor(WGuiColor::TEXT_BODY));
|
||||||
|
mFont->SetScale(.8);
|
||||||
|
float hi = mFont->GetHeight();
|
||||||
|
sprintf(buf,"Artist: %s",author.c_str());
|
||||||
|
mFont->DrawString(buf,x,y+getHeight()-hi);
|
||||||
|
mFont->SetScale(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OptionTheme::Visible(){
|
bool OptionTheme::Visible(){
|
||||||
@@ -686,6 +714,7 @@ bool OptionTheme::Visible(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OptionTheme::confirmChange(bool confirmed){
|
void OptionTheme::confirmChange(bool confirmed){
|
||||||
|
bChecked = false;
|
||||||
if(!confirmed)
|
if(!confirmed)
|
||||||
value = prior_value;
|
value = prior_value;
|
||||||
else{
|
else{
|
||||||
|
|||||||
Reference in New Issue
Block a user