Erwan
- fix issue 215 - added test for purple screen (this is the small white square on top of the loading screen)
This commit is contained in:
@@ -42,6 +42,7 @@ public:
|
|||||||
bool LoadResource(const string& resourceName);
|
bool LoadResource(const string& resourceName);
|
||||||
|
|
||||||
virtual void RemoveAll();
|
virtual void RemoveAll();
|
||||||
|
virtual void RemoveJLBFonts();
|
||||||
|
|
||||||
virtual int CreateTexture(const string &textureName);
|
virtual int CreateTexture(const string &textureName);
|
||||||
virtual JTexture* GetTexture(const string &textureName);
|
virtual JTexture* GetTexture(const string &textureName);
|
||||||
@@ -51,36 +52,19 @@ public:
|
|||||||
virtual JQuad* GetQuad(const string &quadName);
|
virtual JQuad* GetQuad(const string &quadName);
|
||||||
virtual JQuad* GetQuad(int id);
|
virtual JQuad* GetQuad(int id);
|
||||||
|
|
||||||
virtual int LoadJLBFont(const string &fontName, int height);
|
virtual JLBFont * LoadJLBFont(const string &fontName, int height);
|
||||||
virtual JLBFont* GetJLBFont(const string &fontName);
|
virtual JLBFont* GetJLBFont(const string &fontName);
|
||||||
virtual JLBFont* GetJLBFont(int id);
|
virtual JLBFont* GetJLBFont(int id);
|
||||||
|
|
||||||
// int RegisterParticleEffect(const string &effectName);
|
|
||||||
// JParticleEffect* GetParticleEffect(const string &effectName);
|
|
||||||
// JParticleEffect* GetParticleEffect(int id);
|
|
||||||
//
|
|
||||||
// int RegisterMotionEmitter(const string &emitterName);
|
|
||||||
// JMotionEmitter* GetMotionEmitter(const string &emitterName);
|
|
||||||
// JMotionEmitter* GetMotionEmitter(int id);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//JRenderer *mRenderer;
|
|
||||||
|
|
||||||
//string mResourceRoot;
|
|
||||||
|
|
||||||
vector<JTexture *> mTextureList;
|
vector<JTexture *> mTextureList;
|
||||||
map<string, int> mTextureMap;
|
map<string, int> mTextureMap;
|
||||||
|
|
||||||
vector<JQuad *> mQuadList;
|
vector<JQuad *> mQuadList;
|
||||||
map<string, int> mQuadMap;
|
map<string, int> mQuadMap;
|
||||||
|
|
||||||
// vector<JParticleEffect *> mParticleEffectList;
|
|
||||||
// map<string, int> mParticleEffectMap;
|
|
||||||
//
|
|
||||||
// vector<JMotionEmitter *> mMotionEmitterList;
|
|
||||||
// map<string, int> mMotionEmitterMap;
|
|
||||||
|
|
||||||
vector<JLBFont *> mFontList;
|
vector<JLBFont *> mFontList;
|
||||||
map<string, int> mFontMap;
|
map<string, int> mFontMap;
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -55,6 +55,13 @@ JResourceManager::~JResourceManager()
|
|||||||
RemoveAll();
|
RemoveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JResourceManager::RemoveJLBFonts(){
|
||||||
|
for (vector<JLBFont *>::iterator font = mFontList.begin(); font != mFontList.end(); ++font)
|
||||||
|
delete *font;
|
||||||
|
|
||||||
|
mFontList.clear();
|
||||||
|
mFontMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void JResourceManager::RemoveAll()
|
void JResourceManager::RemoveAll()
|
||||||
{
|
{
|
||||||
@@ -70,11 +77,7 @@ void JResourceManager::RemoveAll()
|
|||||||
mQuadList.clear();
|
mQuadList.clear();
|
||||||
mQuadMap.clear();
|
mQuadMap.clear();
|
||||||
|
|
||||||
for (vector<JLBFont *>::iterator font = mFontList.begin(); font != mFontList.end(); ++font)
|
RemoveJLBFonts();
|
||||||
delete *font;
|
|
||||||
|
|
||||||
mFontList.clear();
|
|
||||||
mFontMap.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,10 +85,6 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
|||||||
{
|
{
|
||||||
string path = /*mResourceRoot + */resourceName;
|
string path = /*mResourceRoot + */resourceName;
|
||||||
|
|
||||||
// TiXmlDocument doc(path.c_str());
|
|
||||||
//
|
|
||||||
// if (!doc.LoadFile()) return false;
|
|
||||||
|
|
||||||
|
|
||||||
JGE *engine = JGE::GetInstance();
|
JGE *engine = JGE::GetInstance();
|
||||||
if (engine == NULL) return false;
|
if (engine == NULL) return false;
|
||||||
@@ -164,11 +163,6 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
|||||||
else
|
else
|
||||||
hotspotY = height/2;
|
hotspotY = height/2;
|
||||||
|
|
||||||
// if (element->QueryFloatAttribute("regx", &value) == TIXML_SUCCESS)
|
|
||||||
// hotspotX = width/2;
|
|
||||||
//
|
|
||||||
// if (element->QueryFloatAttribute("regy", &value) == TIXML_SUCCESS)
|
|
||||||
// hotspotY = height/2;
|
|
||||||
|
|
||||||
int id = CreateQuad(quadName, textureName, x, y, width, height);
|
int id = CreateQuad(quadName, textureName, x, y, width, height);
|
||||||
if (id != INVALID_ID)
|
if (id != INVALID_ID)
|
||||||
@@ -179,14 +173,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
|||||||
else if (strcmp(element->Value(), "font")==0)
|
else if (strcmp(element->Value(), "font")==0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
// else if (strcmp(element->Value(), "effect")==0)
|
|
||||||
// {
|
|
||||||
// RegisterParticleEffect(element->Attribute("name"));
|
|
||||||
// }
|
|
||||||
// else if (strcmp(element->Value(), "motion_emitter")==0)
|
|
||||||
// {
|
|
||||||
// RegisterMotionEmitter(element->Attribute("name"));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,26 +284,22 @@ JQuad *JResourceManager::GetQuad(int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int JResourceManager::LoadJLBFont(const string &fontName, int height)
|
JLBFont * JResourceManager::LoadJLBFont(const string &fontName, int height)
|
||||||
{
|
{
|
||||||
map<string, int>::iterator itr = mFontMap.find(fontName);
|
map<string, int>::iterator itr = mFontMap.find(fontName);
|
||||||
|
|
||||||
if (itr == mFontMap.end())
|
if (itr != mFontMap.end()) return mFontList[itr->second];
|
||||||
{
|
|
||||||
string path = /*mResourceRoot + */fontName;
|
|
||||||
|
|
||||||
printf("creating font:%s\n", path.c_str());
|
string path = fontName;
|
||||||
|
|
||||||
int id = mFontList.size();
|
int id = mFontList.size();
|
||||||
///////////////////////////////////////
|
|
||||||
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
|
|
||||||
|
|
||||||
mFontMap[fontName] = id;
|
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
|
||||||
|
|
||||||
|
mFontMap[fontName] = id;
|
||||||
|
|
||||||
|
return mFontList[id];
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return itr->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,22 +76,12 @@ void JQuad::GetTextureRect(float *x, float *y, float *w, float *h)
|
|||||||
*x=mX; *y=mY; *w=mWidth; *h=mHeight;
|
*x=mX; *y=mY; *w=mWidth; *h=mHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void JQuad::SetColor(JColor color)
|
|
||||||
// {
|
|
||||||
// for (int i=0;i<4;i++)
|
|
||||||
// mColor[i].color = color.color;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
void JQuad::SetColor(PIXEL_TYPE color)
|
void JQuad::SetColor(PIXEL_TYPE color)
|
||||||
{
|
{
|
||||||
for (int i=0;i<4;i++)
|
for (int i=0;i<4;i++)
|
||||||
mColor[i].color = color;
|
mColor[i].color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void JQuad::SetHotSpot(float x, float y)
|
void JQuad::SetHotSpot(float x, float y)
|
||||||
{
|
{
|
||||||
mHotSpotX = x;
|
mHotSpotX = x;
|
||||||
|
|||||||
@@ -104,9 +104,7 @@ private:
|
|||||||
JMusic * bgMusic;
|
JMusic * bgMusic;
|
||||||
JQuad * backQuad;
|
JQuad * backQuad;
|
||||||
SimpleMenu * welcome_menu;
|
SimpleMenu * welcome_menu;
|
||||||
JLBFont * mFont;
|
|
||||||
bool showing_user_deck;
|
bool showing_user_deck;
|
||||||
JLBFont * menuFont;
|
|
||||||
SimpleMenu * menu;
|
SimpleMenu * menu;
|
||||||
SimpleMenu * sellMenu;
|
SimpleMenu * sellMenu;
|
||||||
PriceList* pricelist;
|
PriceList* pricelist;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ class GameStateDuel: public GameState, public JGuiListener
|
|||||||
SimpleMenu * opponentMenu;
|
SimpleMenu * opponentMenu;
|
||||||
SimpleMenu * menu;
|
SimpleMenu * menu;
|
||||||
bool premadeDeck;
|
bool premadeDeck;
|
||||||
JLBFont* mFont, *opponentMenuFont;
|
|
||||||
|
|
||||||
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
||||||
void loadPlayerMomir(int playerId, int isAI);
|
void loadPlayerMomir(int playerId, int isAI);
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ class GameStateShop: public GameState, public JGuiListener
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
ShopItems * shop;
|
ShopItems * shop;
|
||||||
JLBFont * menuFont;
|
|
||||||
JLBFont * itemFont;
|
|
||||||
JTexture * altThumb[8];
|
JTexture * altThumb[8];
|
||||||
JQuad * mBack;
|
JQuad * mBack;
|
||||||
JQuad * mBg;
|
JQuad * mBg;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class SimpleMenu:public JGuiController{
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int mHeight, mWidth, mX, mY;
|
int mHeight, mWidth, mX, mY;
|
||||||
JLBFont* mFont;
|
int fontId;
|
||||||
std::string title;
|
std::string title;
|
||||||
int displaytitle;
|
int displaytitle;
|
||||||
int maxItems,startId;
|
int maxItems,startId;
|
||||||
@@ -40,7 +40,7 @@ class SimpleMenu:public JGuiController{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
bool autoTranslate;
|
bool autoTranslate;
|
||||||
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 7);
|
SimpleMenu(int id, JGuiListener* listener, int fontId, int x, int y, const char * _title = "", int _maxItems = 7);
|
||||||
void Render();
|
void Render();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
void Add(int id, const char * Text,string desc = "", bool forceFocus = false);
|
void Add(int id, const char * Text,string desc = "", bool forceFocus = false);
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ class SimpleMenuItem: public JGuiObject
|
|||||||
private:
|
private:
|
||||||
bool mHasFocus;
|
bool mHasFocus;
|
||||||
SimpleMenu* parent;
|
SimpleMenu* parent;
|
||||||
JLBFont *mFont;
|
int fontId;
|
||||||
string mText;
|
string mText;
|
||||||
float mScale;
|
float mScale;
|
||||||
float mTargetScale;
|
float mTargetScale;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string desc;
|
string desc;
|
||||||
SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus = false, bool autoTranslate = false);
|
SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, int x, int y, bool hasFocus = false, bool autoTranslate = false);
|
||||||
|
|
||||||
int mX;
|
int mX;
|
||||||
int mY;
|
int mY;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class TextScroller: public JGuiObject{
|
|||||||
protected:
|
protected:
|
||||||
string mText;
|
string mText;
|
||||||
string tempText;
|
string tempText;
|
||||||
JLBFont * mFont;
|
int fontId;
|
||||||
float mWidth;
|
float mWidth;
|
||||||
float mSpeed;
|
float mSpeed;
|
||||||
float mX;
|
float mX;
|
||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
void Add(string text);
|
void Add(string text);
|
||||||
void Reset();
|
void Reset();
|
||||||
void setRandom(int mode = 1);
|
void setRandom(int mode = 1);
|
||||||
TextScroller(JLBFont * font, float x, float y, float width, float speed = 30);
|
TextScroller(int fontId, float x, float y, float width, float speed = 30);
|
||||||
void Render();
|
void Render();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
|||||||
@@ -175,8 +175,9 @@ public:
|
|||||||
JTexture* GetTexture(const string &textureName);
|
JTexture* GetTexture(const string &textureName);
|
||||||
JTexture* GetTexture(int id);
|
JTexture* GetTexture(int id);
|
||||||
|
|
||||||
|
int reloadJLBFonts();
|
||||||
//Wrapped from JResourceManger. TODO: Privatize
|
//Wrapped from JResourceManger. TODO: Privatize
|
||||||
int LoadJLBFont(const string &fontName, int height);
|
JLBFont * LoadJLBFont(const string &fontName, int height);
|
||||||
|
|
||||||
//Wrapped from JSoundSystem. TODO: Privatize.
|
//Wrapped from JSoundSystem. TODO: Privatize.
|
||||||
JMusic * ssLoadMusic(const char *fileName);
|
JMusic * ssLoadMusic(const char *fileName);
|
||||||
|
|||||||
@@ -219,8 +219,7 @@ void ActionLayer::setMenuObject(Targetable * object){
|
|||||||
|
|
||||||
SAFE_DELETE(abilitiesMenu);
|
SAFE_DELETE(abilitiesMenu);
|
||||||
|
|
||||||
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
abilitiesMenu = NEW SimpleMenu(10, this, Constants::MAIN_FONT, 100, 100);
|
||||||
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100);
|
|
||||||
|
|
||||||
for (int i=0;i<mCount;i++){
|
for (int i=0;i<mCount;i++){
|
||||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ void GameApp::Create()
|
|||||||
resources.GetJLBFont("simon")->SetTracking(-1);
|
resources.GetJLBFont("simon")->SetTracking(-1);
|
||||||
resources.LoadJLBFont("f3",16);
|
resources.LoadJLBFont("f3",16);
|
||||||
resources.LoadJLBFont("magic",16);
|
resources.LoadJLBFont("magic",16);
|
||||||
|
resources.LoadJLBFont("smallface", 7);
|
||||||
|
|
||||||
|
|
||||||
resources.RetrieveTexture("phasebar.png",RETRIEVE_MANAGE);
|
resources.RetrieveTexture("phasebar.png",RETRIEVE_MANAGE);
|
||||||
@@ -277,6 +278,7 @@ void GameApp::Update()
|
|||||||
|
|
||||||
void GameApp::Render()
|
void GameApp::Render()
|
||||||
{
|
{
|
||||||
|
JRenderer::GetInstance()->FillRect(0,0,10,10,ARGB(255,255,255,255)); //This is an attempt at getting rif of the purple screen bug. If you ever get a purple screen while this line is here, just delete it.
|
||||||
if (systemError.size()){
|
if (systemError.size()){
|
||||||
fprintf(stderr, systemError.c_str());
|
fprintf(stderr, systemError.c_str());
|
||||||
JLBFont * mFont= resources.GetJLBFont("simon");
|
JLBFont * mFont= resources.GetJLBFont("simon");
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ void GameStateDeckViewer::switchDisplay(){
|
|||||||
void GameStateDeckViewer::updateDecks(){
|
void GameStateDeckViewer::updateDecks(){
|
||||||
SAFE_DELETE(welcome_menu);
|
SAFE_DELETE(welcome_menu);
|
||||||
|
|
||||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
welcome_menu = NEW SimpleMenu(10,this,Constants::MENU_FONT,20,20);
|
||||||
nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
||||||
deckNum = 0;
|
deckNum = 0;
|
||||||
newDeckname = "";
|
newDeckname = "";
|
||||||
@@ -106,10 +106,8 @@ void GameStateDeckViewer::Start()
|
|||||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
||||||
displayed_deck = myCollection;
|
displayed_deck = myCollection;
|
||||||
myDeck = NULL;
|
myDeck = NULL;
|
||||||
menuFont = resources.GetJLBFont(Constants::MENU_FONT);
|
|
||||||
mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
|
||||||
|
|
||||||
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-150,20);
|
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-150,20);
|
||||||
menu->Add(0,"Save");
|
menu->Add(0,"Save");
|
||||||
menu->Add(1,"Save & Rename");
|
menu->Add(1,"Save & Rename");
|
||||||
menu->Add(2,"Switch decks without saving");
|
menu->Add(2,"Switch decks without saving");
|
||||||
@@ -143,8 +141,7 @@ void GameStateDeckViewer::Start()
|
|||||||
|
|
||||||
backQuad = resources.GetQuad("back");
|
backQuad = resources.GetQuad("back");
|
||||||
|
|
||||||
menuFont = resources.GetJLBFont("f3");
|
welcome_menu = NEW SimpleMenu(10,this,Constants::MENU_FONT,20,20);
|
||||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
|
||||||
nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
||||||
deckNum = 0;
|
deckNum = 0;
|
||||||
welcome_menu->Add(nbDecks+1, "--NEW--");
|
welcome_menu->Add(nbDecks+1, "--NEW--");
|
||||||
@@ -293,7 +290,7 @@ void GameStateDeckViewer::Update(float dt)
|
|||||||
price = pricelist->getPrice(card->getMTGId()) / 2;
|
price = pricelist->getPrice(card->getMTGId()) / 2;
|
||||||
price = price - price * (rnd -10)/100;
|
price = price - price * (rnd -10)/100;
|
||||||
sprintf(buffer,"%s : %i %s",_(card->getName()).c_str(),price,_("credits").c_str());
|
sprintf(buffer,"%s : %i %s",_(card->getName()).c_str(),price,_("credits").c_str());
|
||||||
sellMenu = NEW SimpleMenu(2,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
sellMenu = NEW SimpleMenu(2,this,Constants::MAIN_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||||
sellMenu->Add(20,"Yes");
|
sellMenu->Add(20,"Yes");
|
||||||
sellMenu->Add(21,"No","",true);
|
sellMenu->Add(21,"No","",true);
|
||||||
}
|
}
|
||||||
@@ -401,6 +398,7 @@ void GameStateDeckViewer::Update(float dt)
|
|||||||
|
|
||||||
|
|
||||||
void GameStateDeckViewer::renderOnScreenBasicInfo(){
|
void GameStateDeckViewer::renderOnScreenBasicInfo(){
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
char buffer[30], buffer2[30];
|
char buffer[30], buffer2[30];
|
||||||
|
|
||||||
float y = 0;
|
float y = 0;
|
||||||
@@ -418,6 +416,8 @@ void GameStateDeckViewer::renderOnScreenBasicInfo(){
|
|||||||
|
|
||||||
|
|
||||||
void GameStateDeckViewer::renderSlideBar(){
|
void GameStateDeckViewer::renderSlideBar(){
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
|
|
||||||
int total = displayed_deck->getCount(colorFilter);
|
int total = displayed_deck->getCount(colorFilter);
|
||||||
float filler = 15;
|
float filler = 15;
|
||||||
float y = SCREEN_HEIGHT_F-25;
|
float y = SCREEN_HEIGHT_F-25;
|
||||||
@@ -627,36 +627,36 @@ void GameStateDeckViewer::renderOnScreenMenu(){
|
|||||||
|
|
||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
|
|
||||||
mFont->DrawString(_("Lands"), 20 + leftTransition, posY);
|
font->DrawString(_("Lands"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw.countLands);
|
sprintf(buffer, _("%i").c_str(), stw.countLands);
|
||||||
mFont->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 14;
|
posY += 14;
|
||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
mFont->DrawString( _("Creatures"), 20 + leftTransition, posY);
|
font->DrawString( _("Creatures"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw.countCreatures);
|
sprintf(buffer, _("%i").c_str(), stw.countCreatures);
|
||||||
mFont->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 14;
|
posY += 14;
|
||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
mFont->DrawString(_("Spells"), 20 + leftTransition, posY);
|
font->DrawString(_("Spells"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw.countSpells);
|
sprintf(buffer, _("%i").c_str(), stw.countSpells);
|
||||||
mFont->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
mFont->DrawString(_("Instants"), 30 + leftTransition, posY);
|
font->DrawString(_("Instants"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw.countInstants);
|
sprintf(buffer, _("%i").c_str(), stw.countInstants);
|
||||||
mFont->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
mFont->DrawString(_("Enchantments"), 30 + leftTransition, posY);
|
font->DrawString(_("Enchantments"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw.countEnchantments);
|
sprintf(buffer, _("%i").c_str(), stw.countEnchantments);
|
||||||
mFont->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
mFont->DrawString(_("Sorceries"), 30 + leftTransition, posY);
|
font->DrawString(_("Sorceries"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw.countSorceries);
|
sprintf(buffer, _("%i").c_str(), stw.countSorceries);
|
||||||
mFont->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
//sprintf(buffer, "Artifacts: %i", stw.countArtifacts);
|
//sprintf(buffer, "Artifacts: %i", stw.countArtifacts);
|
||||||
//mFont->DrawString(buffer, 20, 123);
|
//mFont->DrawString(buffer, 20, 123);
|
||||||
|
|
||||||
@@ -1176,9 +1176,9 @@ int GameStateDeckViewer::countCardsByType(const char * _type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::renderCard(int id, float rotation){
|
void GameStateDeckViewer::renderCard(int id, float rotation){
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
MTGCard * card = cardIndex[id];
|
MTGCard * card = cardIndex[id];
|
||||||
|
|
||||||
|
|
||||||
float max_scale = 0.96f;
|
float max_scale = 0.96f;
|
||||||
float x_center_0 = 180;
|
float x_center_0 = 180;
|
||||||
float right_border = SCREEN_WIDTH - 20 ;
|
float right_border = SCREEN_WIDTH - 20 ;
|
||||||
@@ -1256,9 +1256,10 @@ void GameStateDeckViewer::renderCard (int id){
|
|||||||
renderCard(id, 0);
|
renderCard(id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::Render()
|
void GameStateDeckViewer::Render() {
|
||||||
{
|
|
||||||
// void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);
|
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
|
|
||||||
JRenderer * r = JRenderer::GetInstance();
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
r->ClearScreen(ARGB(0,0,0,0));
|
r->ClearScreen(ARGB(0,0,0,0));
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ GameStateDuel::GameStateDuel(GameApp* parent): GameState(parent) {
|
|||||||
game = NULL;
|
game = NULL;
|
||||||
deckmenu = NULL;
|
deckmenu = NULL;
|
||||||
opponentMenu = NULL;
|
opponentMenu = NULL;
|
||||||
opponentMenuFont = NULL;
|
|
||||||
menu = NULL;
|
menu = NULL;
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
testSuite = NULL;
|
testSuite = NULL;
|
||||||
@@ -77,11 +76,8 @@ void GameStateDuel::Start()
|
|||||||
|
|
||||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
|
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
|
||||||
credits = NEW Credits();
|
credits = NEW Credits();
|
||||||
mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
|
||||||
mFont->SetBase(0);
|
|
||||||
opponentMenuFont = mFont;
|
|
||||||
|
|
||||||
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, mFont, SCREEN_WIDTH/2-100, 25);
|
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25);
|
||||||
menu->Add(12,"Back to main menu");
|
menu->Add(12,"Back to main menu");
|
||||||
menu->Add(13, "Cancel");
|
menu->Add(13, "Cancel");
|
||||||
|
|
||||||
@@ -91,7 +87,7 @@ void GameStateDuel::Start()
|
|||||||
for (int i = 0; i<2; i ++){
|
for (int i = 0; i<2; i ++){
|
||||||
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
|
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
|
||||||
decksneeded = 1;
|
decksneeded = 1;
|
||||||
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, mFont, 35, 25, "Choose a Deck");
|
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, Constants::MENU_FONT, 35, 25, "Choose a Deck");
|
||||||
int nbDecks = fillDeckMenu(deckmenu,options.profileFile());
|
int nbDecks = fillDeckMenu(deckmenu,options.profileFile());
|
||||||
if (nbDecks) decksneeded = 0;
|
if (nbDecks) decksneeded = 0;
|
||||||
break;
|
break;
|
||||||
@@ -306,7 +302,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
else{
|
else{
|
||||||
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
|
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
|
||||||
if (!opponentMenu){
|
if (!opponentMenu){
|
||||||
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, opponentMenuFont, 35, 25, "Choose Opponent");
|
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Constants::MENU_FONT, 35, 25, "Choose Opponent");
|
||||||
opponentMenu->Add(0,"Random");
|
opponentMenu->Add(0,"Random");
|
||||||
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
||||||
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
|
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
|
||||||
@@ -367,7 +363,6 @@ void GameStateDuel::Update(float dt)
|
|||||||
End();
|
End();
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
|
||||||
}
|
}
|
||||||
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
if (mEngine->GetButtonClick(PSP_CTRL_START)){
|
||||||
mGamePhase = DUEL_STATE_MENU;
|
mGamePhase = DUEL_STATE_MENU;
|
||||||
@@ -399,6 +394,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
|
|
||||||
void GameStateDuel::Render()
|
void GameStateDuel::Render()
|
||||||
{
|
{
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||||
//Erase
|
//Erase
|
||||||
LOG("Start Render\n");
|
LOG("Start Render\n");
|
||||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
||||||
|
|||||||
@@ -109,8 +109,9 @@ void GameStateMenu::Create()
|
|||||||
if (!langChosen){
|
if (!langChosen){
|
||||||
currentState = MENU_STATE_MAJOR_LANG | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_LANG | MENU_STATE_MINOR_NONE;
|
||||||
}
|
}
|
||||||
scroller = NEW TextScroller(resources.GetJLBFont(Constants::MAIN_FONT), SCREEN_WIDTH/2 - 90 , SCREEN_HEIGHT-17,180);
|
scroller = NEW TextScroller(Constants::MAIN_FONT, SCREEN_WIDTH/2 - 90 , SCREEN_HEIGHT-17,180);
|
||||||
scrollerSet = 0;
|
scrollerSet = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,8 +284,7 @@ void GameStateMenu::setLang(int id){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameStateMenu::loadLangMenu(){
|
void GameStateMenu::loadLangMenu(){
|
||||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
subMenuController = NEW SimpleMenu(103, this, Constants::MENU_FONT, 150,60);
|
||||||
subMenuController = NEW SimpleMenu(103, this, mFont, 150,60);
|
|
||||||
if (!subMenuController) return;
|
if (!subMenuController) return;
|
||||||
resetDirectory();
|
resetDirectory();
|
||||||
if (!mDip){
|
if (!mDip){
|
||||||
@@ -401,8 +401,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) {
|
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) {
|
||||||
if (!hasChosenGameType){
|
if (!hasChosenGameType){
|
||||||
currentState = MENU_STATE_MAJOR_SUBMENU;
|
currentState = MENU_STATE_MAJOR_SUBMENU;
|
||||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
subMenuController = NEW SimpleMenu(102, this, Constants::MENU_FONT, 150,60);
|
||||||
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
|
|
||||||
if (subMenuController){
|
if (subMenuController){
|
||||||
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
|
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
|
||||||
if (options[Options::MOMIR_MODE_UNLOCKED].number)
|
if (options[Options::MOMIR_MODE_UNLOCKED].number)
|
||||||
@@ -546,7 +545,7 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
|||||||
switch (controlId)
|
switch (controlId)
|
||||||
{
|
{
|
||||||
case MENUITEM_PLAY:
|
case MENUITEM_PLAY:
|
||||||
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
|
subMenuController = NEW SimpleMenu(102, this, Constants::MENU_FONT, 150,60);
|
||||||
if (subMenuController){
|
if (subMenuController){
|
||||||
subMenuController->Add(SUBMENUITEM_1PLAYER,"1 Player");
|
subMenuController->Add(SUBMENUITEM_1PLAYER,"1 Player");
|
||||||
// TODO Put 2 players mode back
|
// TODO Put 2 players mode back
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ void GameStateOptions::Start()
|
|||||||
optionsList->failMsg = "";
|
optionsList->failMsg = "";
|
||||||
optionsTabs->Add(optionsList);
|
optionsTabs->Add(optionsList);
|
||||||
|
|
||||||
JLBFont * mFont = resources.GetJLBFont("f3");
|
optionsMenu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170);
|
||||||
optionsMenu = NEW SimpleMenu(-102, this,mFont, 50,170);
|
|
||||||
optionsMenu->Add(1, "Save & Back to Main Menu");
|
optionsMenu->Add(1, "Save & Back to Main Menu");
|
||||||
optionsMenu->Add(2, "Back to Main Menu");
|
optionsMenu->Add(2, "Back to Main Menu");
|
||||||
optionsMenu->Add(3, "Cancel");
|
optionsMenu->Add(3, "Cancel");
|
||||||
|
|||||||
@@ -48,9 +48,6 @@ void GameStateShop::Start()
|
|||||||
else
|
else
|
||||||
mBg = NULL;
|
mBg = NULL;
|
||||||
|
|
||||||
menuFont = resources.GetJLBFont(Constants::MENU_FONT);
|
|
||||||
itemFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
|
||||||
|
|
||||||
JRenderer::GetInstance()->EnableVSync(true);
|
JRenderer::GetInstance()->EnableVSync(true);
|
||||||
|
|
||||||
shop = NULL;
|
shop = NULL;
|
||||||
@@ -109,7 +106,7 @@ void GameStateShop::load(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
shop = NEW ShopItems(10, this, resources.GetJLBFont(Constants::MAIN_FONT), 10, 0, mParent->collection, setIds);
|
||||||
MTGSetInfo * si = NULL;
|
MTGSetInfo * si = NULL;
|
||||||
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
si = setlist.getInfo(setIds[i]);
|
si = setlist.getInfo(setIds[i]);
|
||||||
@@ -157,7 +154,7 @@ void GameStateShop::Update(float dt)
|
|||||||
if (menu){
|
if (menu){
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
}else{
|
}else{
|
||||||
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20);
|
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20);
|
||||||
menu->Add(12,"Save & Back to Main Menu");
|
menu->Add(12,"Save & Back to Main Menu");
|
||||||
menu->Add(13, "Cancel");
|
menu->Add(13, "Cancel");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -867,8 +867,7 @@ void WDecoConfirm::Entering(u32 key){
|
|||||||
|
|
||||||
SAFE_DELETE(confirmMenu);
|
SAFE_DELETE(confirmMenu);
|
||||||
mState = OP_CONFIRMED;
|
mState = OP_CONFIRMED;
|
||||||
JLBFont * mFont = resources.GetJLBFont("f3");
|
confirmMenu = NEW SimpleMenu(444, listener,Constants::MENU_FONT, 50,170);
|
||||||
confirmMenu = NEW SimpleMenu(444, listener,mFont, 50,170);
|
|
||||||
confirmMenu->Add(1,confirm.c_str());
|
confirmMenu->Add(1,confirm.c_str());
|
||||||
confirmMenu->Add(2,cancel.c_str());
|
confirmMenu->Add(2,cancel.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ void ShopItems::Update(float dt){
|
|||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
||||||
if(!dialog){
|
if(!dialog){
|
||||||
dialog = NEW SimpleMenu(1,this,resources.GetJLBFont(Constants::MENU_FONT),SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
dialog = NEW SimpleMenu(1,this,Constants::MENU_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||||
dialog->Add(1,"Yes");
|
dialog->Add(1,"Yes");
|
||||||
dialog->Add(2,"No");
|
dialog->Add(2,"No");
|
||||||
if(options[Options::CHEATMODE].number) {
|
if(options[Options::CHEATMODE].number) {
|
||||||
|
|||||||
@@ -27,13 +27,12 @@ PIXEL_TYPE SimpleMenu::jewelGraphics[9] = {0x3FFFFFFF,0x63645AEA,0x610D0D98,
|
|||||||
0x610D0D98,0xFF110F67,0xFD030330};
|
0x610D0D98,0xFF110F67,0xFD030330};
|
||||||
|
|
||||||
|
|
||||||
SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title, int _maxItems): JGuiController(id, listener){
|
SimpleMenu::SimpleMenu(int id, JGuiListener* listener, int fontId, int x, int y, const char * _title, int _maxItems): JGuiController(id, listener), fontId(fontId){
|
||||||
autoTranslate = true;
|
autoTranslate = true;
|
||||||
mHeight = 2 * VMARGIN;
|
mHeight = 2 * VMARGIN;
|
||||||
mWidth = 0;
|
mWidth = 0;
|
||||||
mX = x;
|
mX = x;
|
||||||
mY = y;
|
mY = y;
|
||||||
mFont = font;
|
|
||||||
title = _(_title);
|
title = _(_title);
|
||||||
startId = 0;
|
startId = 0;
|
||||||
maxItems = _maxItems;
|
maxItems = _maxItems;
|
||||||
@@ -52,11 +51,6 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int
|
|||||||
if (NULL == spadeR) spadeR = resources.RetrieveQuad("spade_ur.png", 2, 1, 16, 13, "spade_ur", RETRIEVE_MANAGE);
|
if (NULL == spadeR) spadeR = resources.RetrieveQuad("spade_ur.png", 2, 1, 16, 13, "spade_ur", RETRIEVE_MANAGE);
|
||||||
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
|
||||||
if (NULL == side) side = resources.RetrieveQuad("menuside.png", 1, 1, 1, 7,"menuside", RETRIEVE_MANAGE);
|
if (NULL == side) side = resources.RetrieveQuad("menuside.png", 1, 1, 1, 7,"menuside", RETRIEVE_MANAGE);
|
||||||
|
|
||||||
if (NULL == titleFont) {
|
|
||||||
resources.LoadJLBFont("smallface", 7);
|
|
||||||
titleFont = resources.GetJLBFont("smallface");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL == stars) {
|
if (NULL == stars) {
|
||||||
JQuad * starQuad = resources.GetQuad("stars");
|
JQuad * starQuad = resources.GetQuad("stars");
|
||||||
@@ -94,6 +88,8 @@ void SimpleMenu::drawVertPole(int x, int y, int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Render() {
|
void SimpleMenu::Render() {
|
||||||
|
JLBFont * titleFont = resources.GetJLBFont("smallface");
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(fontId);
|
||||||
if (0 == mWidth) {
|
if (0 == mWidth) {
|
||||||
float sY = mY + VMARGIN;
|
float sY = mY + VMARGIN;
|
||||||
for (int i = startId; i < startId + mCount; ++i) {
|
for (int i = startId; i < startId + mCount; ++i) {
|
||||||
@@ -167,7 +163,7 @@ void SimpleMenu::Update(float dt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Add(int id, const char * text,string desc, bool forceFocus){
|
void SimpleMenu::Add(int id, const char * text,string desc, bool forceFocus){
|
||||||
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0),autoTranslate);
|
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0),autoTranslate);
|
||||||
smi->desc = desc;
|
smi->desc = desc;
|
||||||
JGuiController::Add(smi);
|
JGuiController::Add(smi);
|
||||||
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/SimpleMenuItem.h"
|
#include "../include/SimpleMenuItem.h"
|
||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
#include "../include/WResourceManager.h"
|
||||||
|
|
||||||
SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus, bool autoTranslate): JGuiObject(id), parent(_parent), mFont(font), mX(x), mY(y)
|
SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, int x, int y, bool hasFocus, bool autoTranslate): JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y)
|
||||||
{
|
{
|
||||||
if (autoTranslate) mText = _(text);
|
if (autoTranslate) mText = _(text);
|
||||||
else mText = text;
|
else mText = text;
|
||||||
@@ -18,6 +19,7 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, strin
|
|||||||
|
|
||||||
void SimpleMenuItem::RenderWithOffset(float yOffset)
|
void SimpleMenuItem::RenderWithOffset(float yOffset)
|
||||||
{
|
{
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(fontId);
|
||||||
//mFont->SetColor(ARGB(255,255,255,255));
|
//mFont->SetColor(ARGB(255,255,255,255));
|
||||||
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
||||||
}
|
}
|
||||||
@@ -71,6 +73,7 @@ void SimpleMenuItem::Relocate(int x, int y)
|
|||||||
|
|
||||||
int SimpleMenuItem::GetWidth()
|
int SimpleMenuItem::GetWidth()
|
||||||
{
|
{
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(fontId);
|
||||||
mFont->SetScale(1.0);
|
mFont->SetScale(1.0);
|
||||||
return mFont->GetStringWidth(mText.c_str());
|
return mFont->GetStringWidth(mText.c_str());
|
||||||
}
|
}
|
||||||
@@ -84,7 +87,6 @@ ostream& SimpleMenuItem::toString(ostream& out) const
|
|||||||
{
|
{
|
||||||
return out << "SimpleMenuItem ::: mHasFocus : " << mHasFocus
|
return out << "SimpleMenuItem ::: mHasFocus : " << mHasFocus
|
||||||
<< " ; parent : " << parent
|
<< " ; parent : " << parent
|
||||||
<< " ; mFont : " << mFont
|
|
||||||
<< " ; mText : " << mText
|
<< " ; mText : " << mText
|
||||||
<< " ; mScale : " << mScale
|
<< " ; mScale : " << mScale
|
||||||
<< " ; mTargetScale : " << mTargetScale
|
<< " ; mTargetScale : " << mTargetScale
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "../include/TextScroller.h"
|
#include "../include/TextScroller.h"
|
||||||
|
#include "../include/WResourceManager.h"
|
||||||
#include "../include/utils.h"
|
#include "../include/utils.h"
|
||||||
#include <JLBFont.h>
|
#include <JLBFont.h>
|
||||||
|
|
||||||
TextScroller::TextScroller(JLBFont * font, float x, float y, float width, float speed):JGuiObject(0){
|
TextScroller::TextScroller(int fontId, float x, float y, float width, float speed):JGuiObject(0),fontId(fontId){
|
||||||
mFont = font;
|
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mSpeed = speed;
|
mSpeed = speed;
|
||||||
mX = x;
|
mX = x;
|
||||||
@@ -35,6 +35,7 @@ void TextScroller::Update(float dt){
|
|||||||
if(!strings.size())
|
if(!strings.size())
|
||||||
return;
|
return;
|
||||||
start+=mSpeed*dt;
|
start+=mSpeed*dt;
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(fontId);
|
||||||
if (start > mFont->GetStringWidth(mText.c_str())){
|
if (start > mFont->GetStringWidth(mText.c_str())){
|
||||||
start = -mWidth;
|
start = -mWidth;
|
||||||
if (mRandom){
|
if (mRandom){
|
||||||
@@ -49,6 +50,7 @@ void TextScroller::Update(float dt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TextScroller::Render(){
|
void TextScroller::Render(){
|
||||||
|
JLBFont * mFont = resources.GetJLBFont(fontId);
|
||||||
mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth);
|
mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +58,6 @@ ostream& TextScroller::toString(ostream& out) const
|
|||||||
{
|
{
|
||||||
return out << "TextScroller ::: mText : " << mText
|
return out << "TextScroller ::: mText : " << mText
|
||||||
<< " ; tempText : " << tempText
|
<< " ; tempText : " << tempText
|
||||||
<< " ; mFont : " << mFont
|
|
||||||
<< " ; mWidth : " << mWidth
|
<< " ; mWidth : " << mWidth
|
||||||
<< " ; mSpeed : " << mSpeed
|
<< " ; mSpeed : " << mSpeed
|
||||||
<< " ; mX,mY : " << mX << "," << mY
|
<< " ; mX,mY : " << mX << "," << mY
|
||||||
|
|||||||
@@ -767,24 +767,38 @@ int WResourceManager::fileOK(string filename, bool relative){
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WResourceManager::LoadJLBFont(const string &fontName, int height){
|
int WResourceManager::reloadJLBFonts(){
|
||||||
|
vector<string> fontNames;
|
||||||
|
vector<float> fontSizes;
|
||||||
|
fontNames.resize(mFontList.size());
|
||||||
|
fontSizes.resize(mFontList.size());
|
||||||
|
for ( map<string, int>::iterator itr = mFontMap.begin(); itr != mFontMap.end(); ++itr){
|
||||||
|
fontNames[itr->second] = itr->first;
|
||||||
|
fontSizes[itr->second] = mFontList[itr->second]->GetHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveJLBFonts();
|
||||||
|
|
||||||
|
for(size_t i = 0; i < fontNames.size(); ++i){
|
||||||
|
LoadJLBFont(fontNames[i],fontSizes[i]);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JLBFont * WResourceManager::LoadJLBFont(const string &fontName, int height){
|
||||||
map<string, int>::iterator itr = mFontMap.find(fontName);
|
map<string, int>::iterator itr = mFontMap.find(fontName);
|
||||||
|
|
||||||
if (itr == mFontMap.end())
|
if (itr != mFontMap.end()) return mFontList[itr->second];
|
||||||
{
|
|
||||||
string path = graphicsFile(fontName);
|
|
||||||
|
|
||||||
printf("creating font:%s\n", path.c_str());
|
string mFontName = fontName + ".png";
|
||||||
|
string path = graphicsFile(mFontName);
|
||||||
|
if (path.size() > 4 ) path = path.substr(0, path.size() - 4); //some stupid manipulation because of the way JLBFont works in JGE
|
||||||
|
int id = mFontList.size();
|
||||||
|
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
|
||||||
|
mFontMap[fontName] = id;
|
||||||
|
|
||||||
int id = mFontList.size();
|
return mFontList[id];
|
||||||
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
|
|
||||||
|
|
||||||
mFontMap[fontName] = id;
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return itr->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -809,6 +823,7 @@ JMusic * WResourceManager::ssLoadMusic(const char *fileName){
|
|||||||
|
|
||||||
void WResourceManager::Refresh(){
|
void WResourceManager::Refresh(){
|
||||||
//Really easy cache relinking.
|
//Really easy cache relinking.
|
||||||
|
reloadJLBFonts();
|
||||||
sampleWCache.Refresh();
|
sampleWCache.Refresh();
|
||||||
textureWCache.Refresh();
|
textureWCache.Refresh();
|
||||||
psiWCache.Refresh();
|
psiWCache.Refresh();
|
||||||
|
|||||||
Reference in New Issue
Block a user