Synchronized avatar images to be loaded correctly on first display of the opponent selection.
* changed how the avatar images are assigned since how they were before was incorrect. They are now assigned upon instantiation of the meta file. Not when the stats are calculated. * Added new image for "Evil Twin". This is a horizontally flipped image of the original player avatar with a red background. Please feel free to edit the image. * removed display of avatar image on menu items in deck selection that are not deck related. (ie "Cancel", "Back to Main Menu", etc) "New Deck" also does not have an image since no deck really exists yet so no avatar. Issue: 622
This commit is contained in:
BIN
projects/mtg/bin/Res/graphics/avatar_evil_twin.jpg
Normal file
BIN
projects/mtg/bin/Res/graphics/avatar_evil_twin.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
@@ -26,13 +26,14 @@ private:
|
||||
|
||||
// statistical information
|
||||
int mGamesPlayed, mVictories, mPercentVictories, mDifficulty;
|
||||
int getAvatarId();
|
||||
|
||||
DeckMetaData();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
DeckMetaData(const string& filename);
|
||||
DeckMetaData(const string& filename, bool isAI = false);
|
||||
void LoadDeck();
|
||||
void LoadStats();
|
||||
|
||||
@@ -42,7 +43,6 @@ public:
|
||||
string getName();
|
||||
string getAvatarFilename();
|
||||
string getColorIndex();
|
||||
int getAvatarId(int deckId);
|
||||
string getStatsSummary();
|
||||
|
||||
int getDeckId();
|
||||
|
||||
@@ -65,10 +65,10 @@ public:
|
||||
{
|
||||
MENUITEM_CANCEL = kCancelMenuID,
|
||||
MENUITEM_NEW_DECK = -10,
|
||||
MENUITEM_RANDOM_PLAYER = -11,
|
||||
MENUITEM_RANDOM_AI = -12,
|
||||
MENUITEM_RANDOM_PLAYER = kRandomPlayerMenuID,
|
||||
MENUITEM_RANDOM_AI = kRandomAIPlayerMenuID,
|
||||
MENUITEM_MAIN_MENU = -13,
|
||||
MENUITEM_EVIL_TWIN = -14,
|
||||
MENUITEM_EVIL_TWIN = kEvilTwinMenuID,
|
||||
MENUITEM_MULLIGAN = -15,
|
||||
#ifdef NETWORK_SUPPORT
|
||||
MENUITEM_REMOTE_CLIENT = -16,
|
||||
|
||||
@@ -109,12 +109,12 @@ void DeckManager::AddMetaData( const string& filename, bool isAI )
|
||||
{
|
||||
if (isAI)
|
||||
{
|
||||
aiDeckOrderList.push_back ( NEW DeckMetaData( filename ) );
|
||||
aiDeckOrderList.push_back ( NEW DeckMetaData( filename, isAI ) );
|
||||
aiDeckStatsMap.insert( make_pair( filename.c_str(), new StatsWrapper( aiDeckOrderList.back()->getDeckId()) ));
|
||||
}
|
||||
else
|
||||
{
|
||||
playerDeckOrderList.push_back ( NEW DeckMetaData( filename ) );
|
||||
playerDeckOrderList.push_back ( NEW DeckMetaData( filename, isAI ) );
|
||||
playerDeckStatsMap.insert( make_pair( filename.c_str(), new StatsWrapper( playerDeckOrderList.back()->getDeckId()) ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +247,7 @@ void DeckMenu::Render()
|
||||
if (quad.get())
|
||||
renderer->RenderQuad(quad.get(), avatarX, avatarY);
|
||||
}
|
||||
|
||||
// fill in the description part of the screen
|
||||
string text = wordWrap(_(currentMenuItem->desc), descWidth, mainFont->mFontID );
|
||||
mainFont->DrawString(text.c_str(), descX, descY);
|
||||
|
||||
@@ -41,9 +41,28 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
|
||||
|
||||
if (meta && meta->getAvatarFilename().size() > 0)
|
||||
this->imageFilename = meta->getAvatarFilename();
|
||||
else
|
||||
this->imageFilename = "avatar.jpg";
|
||||
|
||||
else
|
||||
{
|
||||
// this is a non-deck menu item (ie "Random", "Cancel", etc
|
||||
switch(id)
|
||||
{
|
||||
case kRandomPlayerMenuID:
|
||||
this->imageFilename = "avatar.jpg";
|
||||
break;
|
||||
case kRandomAIPlayerMenuID:
|
||||
this->imageFilename = "avatar.jpg";
|
||||
break;
|
||||
case kEvilTwinMenuID:
|
||||
this->imageFilename = "avatar_evil_twin.jpg";
|
||||
break;
|
||||
default:
|
||||
// do nothing.
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
mDisplayInitialized = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
//Merge this with DeckStats
|
||||
//Have this class handle all the Meta Data rather than relying on MTGDeck. Then MTGDeck would have a MetaData object...
|
||||
|
||||
DeckMetaData::DeckMetaData(const string& filename)
|
||||
DeckMetaData::DeckMetaData(const string& filename, bool isAI)
|
||||
: mFilename(filename), mGamesPlayed(0), mVictories(0), mPercentVictories(0), mDifficulty(0),
|
||||
mDeckLoaded(false), mStatsLoaded(false)
|
||||
mDeckLoaded(false), mStatsLoaded(false), mIsAI(isAI)
|
||||
{
|
||||
// TODO, figure out how we can defer this to later - currently,
|
||||
// there's a catch 22, as we sort the deck list alphabetically, so we need to open the deck file
|
||||
@@ -36,12 +36,7 @@ void DeckMetaData::LoadStats()
|
||||
mVictories = opponentDeckStats->victories;
|
||||
mGamesPlayed = opponentDeckStats->nbgames;
|
||||
mColorIndex = opponentDeckStats->manaColorIndex;
|
||||
ostringstream oss;
|
||||
int deckFilenameOffset = mStatsFilename.find("deck") + 4;
|
||||
int oppDeckId = atoi(mStatsFilename.substr(deckFilenameOffset, mStatsFilename.find_last_of(".")).c_str());
|
||||
int avatarId = getAvatarId(oppDeckId);
|
||||
oss << "avatar" << avatarId << ".jpg";
|
||||
mAvatarFilename = oss.str();
|
||||
|
||||
if (mPercentVictories < 34)
|
||||
{
|
||||
mDifficulty = HARD;
|
||||
@@ -55,12 +50,6 @@ void DeckMetaData::LoadStats()
|
||||
mDifficulty = EASY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "avatar" << getAvatarId(mDeckId) << ".jpg";
|
||||
mAvatarFilename = oss.str();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -79,10 +68,14 @@ void DeckMetaData::LoadStats()
|
||||
}
|
||||
|
||||
// since we only have 100 stock avatar images, we need to recycle the images for deck numbers > 99
|
||||
int DeckMetaData::getAvatarId(int deckId)
|
||||
int DeckMetaData::getAvatarId()
|
||||
{
|
||||
int avatarId = deckId % 100;
|
||||
if (deckId >= 100 && avatarId == 0)
|
||||
if ( mDeckId < 101 )
|
||||
return mDeckId;
|
||||
|
||||
int avatarId = mDeckId % 100;
|
||||
|
||||
if (avatarId == 0)
|
||||
return 100;
|
||||
|
||||
return avatarId;
|
||||
@@ -97,6 +90,14 @@ void DeckMetaData::LoadDeck()
|
||||
mDescription = trim(deck.meta_desc);
|
||||
mDeckId = atoi((mFilename.substr(mFilename.find("deck") + 4, mFilename.find(".txt"))).c_str());
|
||||
mDeckLoaded = true;
|
||||
if (!mIsAI)
|
||||
mAvatarFilename = "avatar.jpg";
|
||||
else
|
||||
{
|
||||
ostringstream avatarFilename;
|
||||
avatarFilename << "avatar" << getAvatarId() << ".jpg";
|
||||
mAvatarFilename = avatarFilename.str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user