From c87343a7f23a4214b589b433b7e93377c496295f Mon Sep 17 00:00:00 2001 From: "wagic.jeck" Date: Fri, 23 Oct 2009 07:16:58 +0000 Subject: [PATCH] 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. --- projects/mtg/include/OptionItem.h | 7 ++++++- projects/mtg/src/OptionItem.cpp | 31 ++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/projects/mtg/include/OptionItem.h b/projects/mtg/include/OptionItem.h index 533307f71..ab822bc00 100644 --- a/projects/mtg/include/OptionItem.h +++ b/projects/mtg/include/OptionItem.h @@ -408,11 +408,16 @@ private: class OptionTheme:public OptionDirectory{ public: OptionTheme(); - JQuad * getImage(); + JQuad * getImage(); + virtual void updateValue(); virtual float getHeight(); virtual void Render(); virtual void confirmChange(bool confirmed); virtual bool Visible(); + +protected: + string author; + bool bChecked; }; class OptionProfile:public OptionDirectory{ diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index 4afdb77e4..9bec25824 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -646,7 +646,8 @@ OptionTheme::OptionTheme(): OptionDirectory(RESPATH"/themes",Options::ACTIVE_THE addSelection("Default"); sort(selections.begin(),selections.end()); initSelections(); - mFocus=false; + mFocus=false; + bChecked = false; } JQuad * OptionTheme::getImage(){ char buf[512]; @@ -662,12 +663,31 @@ JQuad * OptionTheme::getImage(){ float OptionTheme::getHeight(){ return 130; }; +void OptionTheme::updateValue(){ + OptionDirectory::updateValue(); + bChecked = false; +} + void OptionTheme::Render(){ JRenderer * renderer = JRenderer::GetInstance(); JQuad * q = getImage(); JLBFont * mFont = resources.GetJLBFont(Constants::OPTION_FONT); mFont->SetColor(getColor(WGuiColor::TEXT_HEADER)); 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,xDrawString, cuts to 16 chars. + author += temp[x]; + } + } + } sprintf(buf,"Theme: %s",selections[value].c_str()); if(q){ @@ -676,6 +696,14 @@ void OptionTheme::Render(){ } 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(){ @@ -686,6 +714,7 @@ bool OptionTheme::Visible(){ } void OptionTheme::confirmChange(bool confirmed){ + bChecked = false; if(!confirmed) value = prior_value; else{