- 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:
wagic.the.homebrew@gmail.com
2009-11-23 08:25:27 +00:00
parent e364b17117
commit 66a505969e
29 changed files with 110 additions and 151 deletions

View File

@@ -42,6 +42,7 @@ public:
bool LoadResource(const string& resourceName);
virtual void RemoveAll();
virtual void RemoveJLBFonts();
virtual int CreateTexture(const string &textureName);
virtual JTexture* GetTexture(const string &textureName);
@@ -51,36 +52,19 @@ public:
virtual JQuad* GetQuad(const string &quadName);
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(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:
//JRenderer *mRenderer;
//string mResourceRoot;
vector<JTexture *> mTextureList;
map<string, int> mTextureMap;
vector<JQuad *> mQuadList;
map<string, int> mQuadMap;
// vector<JParticleEffect *> mParticleEffectList;
// map<string, int> mParticleEffectMap;
//
// vector<JMotionEmitter *> mMotionEmitterList;
// map<string, int> mMotionEmitterMap;
vector<JLBFont *> mFontList;
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.

View File

@@ -55,6 +55,13 @@ JResourceManager::~JResourceManager()
RemoveAll();
}
void JResourceManager::RemoveJLBFonts(){
for (vector<JLBFont *>::iterator font = mFontList.begin(); font != mFontList.end(); ++font)
delete *font;
mFontList.clear();
mFontMap.clear();
}
void JResourceManager::RemoveAll()
{
@@ -70,11 +77,7 @@ void JResourceManager::RemoveAll()
mQuadList.clear();
mQuadMap.clear();
for (vector<JLBFont *>::iterator font = mFontList.begin(); font != mFontList.end(); ++font)
delete *font;
mFontList.clear();
mFontMap.clear();
RemoveJLBFonts();
}
@@ -82,10 +85,6 @@ bool JResourceManager::LoadResource(const string& resourceName)
{
string path = /*mResourceRoot + */resourceName;
// TiXmlDocument doc(path.c_str());
//
// if (!doc.LoadFile()) return false;
JGE *engine = JGE::GetInstance();
if (engine == NULL) return false;
@@ -164,11 +163,6 @@ bool JResourceManager::LoadResource(const string& resourceName)
else
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);
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(), "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);
if (itr == mFontMap.end())
{
string path = /*mResourceRoot + */fontName;
if (itr != mFontMap.end()) return mFontList[itr->second];
printf("creating font:%s\n", path.c_str());
string path = fontName;
int id = mFontList.size();
///////////////////////////////////////
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
int id = mFontList.size();
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;
}

View File

@@ -76,22 +76,12 @@ void JQuad::GetTextureRect(float *x, float *y, float *w, float *h)
*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)
{
for (int i=0;i<4;i++)
mColor[i].color = color;
}
void JQuad::SetHotSpot(float x, float y)
{
mHotSpotX = x;

View File

@@ -104,9 +104,7 @@ private:
JMusic * bgMusic;
JQuad * backQuad;
SimpleMenu * welcome_menu;
JLBFont * mFont;
bool showing_user_deck;
JLBFont * menuFont;
SimpleMenu * menu;
SimpleMenu * sellMenu;
PriceList* pricelist;

View File

@@ -31,7 +31,6 @@ class GameStateDuel: public GameState, public JGuiListener
SimpleMenu * opponentMenu;
SimpleMenu * menu;
bool premadeDeck;
JLBFont* mFont, *opponentMenuFont;
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
void loadPlayerMomir(int playerId, int isAI);

View File

@@ -19,8 +19,6 @@ class GameStateShop: public GameState, public JGuiListener
private:
ShopItems * shop;
JLBFont * menuFont;
JLBFont * itemFont;
JTexture * altThumb[8];
JQuad * mBack;
JQuad * mBg;

View File

@@ -19,7 +19,7 @@ class SimpleMenu:public JGuiController{
private:
int mHeight, mWidth, mX, mY;
JLBFont* mFont;
int fontId;
std::string title;
int displaytitle;
int maxItems,startId;
@@ -40,7 +40,7 @@ class SimpleMenu:public JGuiController{
public:
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 Update(float dt);
void Add(int id, const char * Text,string desc = "", bool forceFocus = false);

View File

@@ -18,14 +18,14 @@ class SimpleMenuItem: public JGuiObject
private:
bool mHasFocus;
SimpleMenu* parent;
JLBFont *mFont;
int fontId;
string mText;
float mScale;
float mTargetScale;
public:
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 mY;

View File

@@ -11,7 +11,7 @@ class TextScroller: public JGuiObject{
protected:
string mText;
string tempText;
JLBFont * mFont;
int fontId;
float mWidth;
float mSpeed;
float mX;
@@ -25,7 +25,7 @@ public:
void Add(string text);
void Reset();
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 Update(float dt);
virtual ostream& toString(ostream& out) const;

View File

@@ -175,8 +175,9 @@ public:
JTexture* GetTexture(const string &textureName);
JTexture* GetTexture(int id);
int reloadJLBFonts();
//Wrapped from JResourceManger. TODO: Privatize
int LoadJLBFont(const string &fontName, int height);
JLBFont * LoadJLBFont(const string &fontName, int height);
//Wrapped from JSoundSystem. TODO: Privatize.
JMusic * ssLoadMusic(const char *fileName);

View File

@@ -219,8 +219,7 @@ void ActionLayer::setMenuObject(Targetable * object){
SAFE_DELETE(abilitiesMenu);
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100);
abilitiesMenu = NEW SimpleMenu(10, this, Constants::MAIN_FONT, 100, 100);
for (int i=0;i<mCount;i++){
ActionElement * currentAction = (ActionElement *)mObjects[i];

View File

@@ -128,6 +128,7 @@ void GameApp::Create()
resources.GetJLBFont("simon")->SetTracking(-1);
resources.LoadJLBFont("f3",16);
resources.LoadJLBFont("magic",16);
resources.LoadJLBFont("smallface", 7);
resources.RetrieveTexture("phasebar.png",RETRIEVE_MANAGE);
@@ -277,6 +278,7 @@ void GameApp::Update()
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()){
fprintf(stderr, systemError.c_str());
JLBFont * mFont= resources.GetJLBFont("simon");

View File

@@ -85,7 +85,7 @@ void GameStateDeckViewer::switchDisplay(){
void GameStateDeckViewer::updateDecks(){
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());
deckNum = 0;
newDeckname = "";
@@ -106,10 +106,8 @@ void GameStateDeckViewer::Start()
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
displayed_deck = myCollection;
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(1,"Save & Rename");
menu->Add(2,"Switch decks without saving");
@@ -143,8 +141,7 @@ void GameStateDeckViewer::Start()
backQuad = resources.GetQuad("back");
menuFont = resources.GetJLBFont("f3");
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());
deckNum = 0;
welcome_menu->Add(nbDecks+1, "--NEW--");
@@ -293,7 +290,7 @@ void GameStateDeckViewer::Update(float dt)
price = pricelist->getPrice(card->getMTGId()) / 2;
price = price - price * (rnd -10)/100;
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(21,"No","",true);
}
@@ -401,6 +398,7 @@ void GameStateDeckViewer::Update(float dt)
void GameStateDeckViewer::renderOnScreenBasicInfo(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
char buffer[30], buffer2[30];
float y = 0;
@@ -418,6 +416,8 @@ void GameStateDeckViewer::renderOnScreenBasicInfo(){
void GameStateDeckViewer::renderSlideBar(){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
int total = displayed_deck->getCount(colorFilter);
float filler = 15;
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));
mFont->DrawString(_("Lands"), 20 + leftTransition, posY);
font->DrawString(_("Lands"), 20 + leftTransition, posY);
sprintf(buffer, _("%i").c_str(), stw.countLands);
mFont->DrawString(buffer, posX + leftTransition, posY);
font->DrawString(buffer, posX + leftTransition, posY);
posY += 14;
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);
mFont->DrawString(buffer, posX + leftTransition, posY);
font->DrawString(buffer, posX + leftTransition, posY);
posY += 14;
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);
mFont->DrawString(buffer, posX + leftTransition, posY);
font->DrawString(buffer, posX + leftTransition, posY);
posY += 10;
mFont->DrawString(_("Instants"), 30 + leftTransition, posY);
font->DrawString(_("Instants"), 30 + leftTransition, posY);
sprintf(buffer, _("%i").c_str(), stw.countInstants);
mFont->DrawString(buffer, posX + leftTransition, posY);
font->DrawString(buffer, posX + leftTransition, posY);
posY += 10;
mFont->DrawString(_("Enchantments"), 30 + leftTransition, posY);
font->DrawString(_("Enchantments"), 30 + leftTransition, posY);
sprintf(buffer, _("%i").c_str(), stw.countEnchantments);
mFont->DrawString(buffer, posX + leftTransition, posY);
font->DrawString(buffer, posX + leftTransition, posY);
posY += 10;
mFont->DrawString(_("Sorceries"), 30 + leftTransition, posY);
font->DrawString(_("Sorceries"), 30 + leftTransition, posY);
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);
//mFont->DrawString(buffer, 20, 123);
@@ -1176,9 +1176,9 @@ int GameStateDeckViewer::countCardsByType(const char * _type) {
}
void GameStateDeckViewer::renderCard(int id, float rotation){
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
MTGCard * card = cardIndex[id];
float max_scale = 0.96f;
float x_center_0 = 180;
float right_border = SCREEN_WIDTH - 20 ;
@@ -1256,9 +1256,10 @@ void GameStateDeckViewer::renderCard (int id){
renderCard(id, 0);
}
void GameStateDeckViewer::Render()
{
// void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);
void GameStateDeckViewer::Render() {
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));

View File

@@ -51,7 +51,6 @@ GameStateDuel::GameStateDuel(GameApp* parent): GameState(parent) {
game = NULL;
deckmenu = NULL;
opponentMenu = NULL;
opponentMenuFont = NULL;
menu = NULL;
#ifdef TESTSUITE
testSuite = NULL;
@@ -77,11 +76,8 @@ void GameStateDuel::Start()
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
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(13, "Cancel");
@@ -91,7 +87,7 @@ void GameStateDuel::Start()
for (int i = 0; i<2; i ++){
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
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());
if (nbDecks) decksneeded = 0;
break;
@@ -306,7 +302,7 @@ void GameStateDuel::Update(float dt)
else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
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");
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
@@ -367,7 +363,6 @@ void GameStateDuel::Update(float dt)
End();
Start();
}
mFont->SetColor(ARGB(255,255,255,255));
}
if (mEngine->GetButtonClick(PSP_CTRL_START)){
mGamePhase = DUEL_STATE_MENU;
@@ -399,6 +394,7 @@ void GameStateDuel::Update(float dt)
void GameStateDuel::Render()
{
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
//Erase
LOG("Start Render\n");
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));

View File

@@ -109,8 +109,9 @@ void GameStateMenu::Create()
if (!langChosen){
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;
}
@@ -283,8 +284,7 @@ void GameStateMenu::setLang(int id){
}
void GameStateMenu::loadLangMenu(){
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(103, this, mFont, 150,60);
subMenuController = NEW SimpleMenu(103, this, Constants::MENU_FONT, 150,60);
if (!subMenuController) return;
resetDirectory();
if (!mDip){
@@ -401,8 +401,7 @@ void GameStateMenu::Update(float dt)
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR)) {
if (!hasChosenGameType){
currentState = MENU_STATE_MAJOR_SUBMENU;
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
subMenuController = NEW SimpleMenu(102, this, Constants::MENU_FONT, 150,60);
if (subMenuController){
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (options[Options::MOMIR_MODE_UNLOCKED].number)
@@ -546,7 +545,7 @@ JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
switch (controlId)
{
case MENUITEM_PLAY:
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
subMenuController = NEW SimpleMenu(102, this, Constants::MENU_FONT, 150,60);
if (subMenuController){
subMenuController->Add(SUBMENUITEM_1PLAYER,"1 Player");
// TODO Put 2 players mode back

View File

@@ -73,8 +73,7 @@ void GameStateOptions::Start()
optionsList->failMsg = "";
optionsTabs->Add(optionsList);
JLBFont * mFont = resources.GetJLBFont("f3");
optionsMenu = NEW SimpleMenu(-102, this,mFont, 50,170);
optionsMenu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170);
optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(2, "Back to Main Menu");
optionsMenu->Add(3, "Cancel");

View File

@@ -48,9 +48,6 @@ void GameStateShop::Start()
else
mBg = NULL;
menuFont = resources.GetJLBFont(Constants::MENU_FONT);
itemFont = resources.GetJLBFont(Constants::MAIN_FONT);
JRenderer::GetInstance()->EnableVSync(true);
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;
for (int i = 0; i < SHOP_BOOSTERS; i++){
si = setlist.getInfo(setIds[i]);
@@ -157,7 +154,7 @@ void GameStateShop::Update(float dt)
if (menu){
menu->Update(dt);
}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(13, "Cancel");
}

View File

@@ -867,8 +867,7 @@ void WDecoConfirm::Entering(u32 key){
SAFE_DELETE(confirmMenu);
mState = OP_CONFIRMED;
JLBFont * mFont = resources.GetJLBFont("f3");
confirmMenu = NEW SimpleMenu(444, listener,mFont, 50,170);
confirmMenu = NEW SimpleMenu(444, listener,Constants::MENU_FONT, 50,170);
confirmMenu->Add(1,confirm.c_str());
confirmMenu->Add(2,cancel.c_str());
}

View File

@@ -257,7 +257,7 @@ void ShopItems::Update(float dt){
char buffer[4096];
sprintf(buffer,"%s : %i credits",item->getText(),price);
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(2,"No");
if(options[Options::CHEATMODE].number) {

View File

@@ -27,13 +27,12 @@ PIXEL_TYPE SimpleMenu::jewelGraphics[9] = {0x3FFFFFFF,0x63645AEA,0x610D0D98,
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;
mHeight = 2 * VMARGIN;
mWidth = 0;
mX = x;
mY = y;
mFont = font;
title = _(_title);
startId = 0;
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 == 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 == titleFont) {
resources.LoadJLBFont("smallface", 7);
titleFont = resources.GetJLBFont("smallface");
}
if (NULL == stars) {
JQuad * starQuad = resources.GetQuad("stars");
@@ -94,6 +88,8 @@ void SimpleMenu::drawVertPole(int x, int y, int height) {
}
void SimpleMenu::Render() {
JLBFont * titleFont = resources.GetJLBFont("smallface");
JLBFont * mFont = resources.GetJLBFont(fontId);
if (0 == mWidth) {
float sY = mY + VMARGIN;
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){
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;
JGuiController::Add(smi);
if (mCount <= maxItems) mHeight += LINE_HEIGHT;

View File

@@ -1,8 +1,9 @@
#include "../include/config.h"
#include "../include/SimpleMenuItem.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);
else mText = text;
@@ -18,6 +19,7 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, strin
void SimpleMenuItem::RenderWithOffset(float yOffset)
{
JLBFont * mFont = resources.GetJLBFont(fontId);
//mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
}
@@ -71,6 +73,7 @@ void SimpleMenuItem::Relocate(int x, int y)
int SimpleMenuItem::GetWidth()
{
JLBFont * mFont = resources.GetJLBFont(fontId);
mFont->SetScale(1.0);
return mFont->GetStringWidth(mText.c_str());
}
@@ -84,7 +87,6 @@ ostream& SimpleMenuItem::toString(ostream& out) const
{
return out << "SimpleMenuItem ::: mHasFocus : " << mHasFocus
<< " ; parent : " << parent
<< " ; mFont : " << mFont
<< " ; mText : " << mText
<< " ; mScale : " << mScale
<< " ; mTargetScale : " << mTargetScale

View File

@@ -1,9 +1,9 @@
#include "../include/TextScroller.h"
#include "../include/WResourceManager.h"
#include "../include/utils.h"
#include <JLBFont.h>
TextScroller::TextScroller(JLBFont * font, float x, float y, float width, float speed):JGuiObject(0){
mFont = font;
TextScroller::TextScroller(int fontId, float x, float y, float width, float speed):JGuiObject(0),fontId(fontId){
mWidth = width;
mSpeed = speed;
mX = x;
@@ -35,6 +35,7 @@ void TextScroller::Update(float dt){
if(!strings.size())
return;
start+=mSpeed*dt;
JLBFont * mFont = resources.GetJLBFont(fontId);
if (start > mFont->GetStringWidth(mText.c_str())){
start = -mWidth;
if (mRandom){
@@ -49,6 +50,7 @@ void TextScroller::Update(float dt){
}
void TextScroller::Render(){
JLBFont * mFont = resources.GetJLBFont(fontId);
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
<< " ; tempText : " << tempText
<< " ; mFont : " << mFont
<< " ; mWidth : " << mWidth
<< " ; mSpeed : " << mSpeed
<< " ; mX,mY : " << mX << "," << mY

View File

@@ -767,24 +767,38 @@ int WResourceManager::fileOK(string filename, bool relative){
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);
if (itr == mFontMap.end())
{
string path = graphicsFile(fontName);
if (itr != mFontMap.end()) return mFontList[itr->second];
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();
mFontList.push_back(NEW JLBFont(path.c_str(), height, true));
mFontMap[fontName] = id;
return id;
}
else
return itr->second;
return mFontList[id];
}
@@ -809,6 +823,7 @@ JMusic * WResourceManager::ssLoadMusic(const char *fileName){
void WResourceManager::Refresh(){
//Really easy cache relinking.
reloadJLBFonts();
sampleWCache.Refresh();
textureWCache.Refresh();
psiWCache.Refresh();