- Added a way to name and describe AI Decks. Let's find cool names and descriptions :)
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-05-25 12:43:58 +00:00
parent fc2ae93367
commit ee58109449
12 changed files with 100 additions and 36 deletions

View File

@@ -102,23 +102,31 @@ JLBFont::~JLBFont()
void JLBFont::DrawString(const char *string, float x, float y, int align, float leftOffset, float displayWidth)
{
char *p = (char*)string;
float dx = x, dy = y;
float dx0 = x, dy = y;
if (mQuad == NULL) return;
float width = GetStringWidth(string);
if (align == JGETEXT_RIGHT)
dx -= width;
dx0 -= width;
else if (align == JGETEXT_CENTER)
dx -= width/2;
dx0 -= width/2;
dx = floorf(dx);
float dx = floorf(dx0);
dy = floorf(dy);
float x0 = dx;
int index;
while (*p)
{
if (*p == '\n') {
p++;
dy += (mHeight * 1.1 * mScale);
dy = floorf(dy);
dx = dx0;
continue;
}
index = (*p - 32)+mBase;
float charWidth = mCharWidth[index];
float delta = (charWidth + mTracking) * mScale;

View File

@@ -1,3 +1,14 @@
#NAME:Rats!
#DESC:"They fought the dogs, and killed the cats,
#DESC:And bit the babies in the cradles,
#DESC:And ate the cheeses out of the vats
#DESC:And licked the soup from the cook's own ladles,
#DESC:Split open the kegs of salted sprats,
#DESC:Made nests inside men's Sunday hats,
#DESC:And even spoiled the women's chats,
#DESC:By drowning their speaking
#DESC:With shrieking and squeaking
#DESC:In fifty different sharps and flats."
#Black Deck, Rats
#26 Swamps
157886

View File

@@ -1,3 +1,6 @@
#NAME:Faeries
#DESC:Be warned, those are not butterflies...
#DESC:Or the dangerous kind.
#Plain blue deck
#4 x Control Magic, {2}{U}{U}, Enchant creature
1194

View File

@@ -1,4 +1,8 @@
#Plain Green Elf deck
#NAME:Elves
#DESC:And here you thought you would enjoy
#DESC:a little trip in the forest...
#DESC:
#DESC:Who said only Goblins were nasty?
#4x Elvish Archers,{1}{G},2/1,Creature Elf,first strike
1242
1242

View File

@@ -79,8 +79,11 @@ class MTGDeck:public MTGAllCards{
protected:
string filename;
MTGAllCards * allcards;
public:
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards);
string meta_desc;
string meta_name;
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only = 0);
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
int add(int cardid);
int remove(int cardid);

View File

@@ -47,7 +47,7 @@ class SimpleMenu:public JGuiController{
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 7);
void Render();
void Update(float dt);
void Add(int id, const char * Text);
void Add(int id, const char * Text,string desc = "");
void Close();
float selectionTargetY;

View File

@@ -24,6 +24,7 @@ class SimpleMenuItem: public JGuiObject
float mTargetScale;
public:
string desc;
SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, string text, int x, int y, bool hasFocus = false);
int mX;

View File

@@ -272,6 +272,7 @@ void GameStateDuel::Update(float dt)
char deckDesc[512];
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
if(fileExists(buffer)){
MTGDeck * mtgd = NEW MTGDeck(buffer,NULL,NULL,1);
found = 1;
nbAIDecks++;
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
@@ -286,8 +287,9 @@ void GameStateDuel::Update(float dt)
}else{
difficulty = "(easy)";
}
sprintf(deckDesc, "Deck %i %s",nbAIDecks, _(difficulty).c_str());
opponentMenu->Add(nbAIDecks,deckDesc);
sprintf(deckDesc, "%s %s",mtgd->meta_name.c_str(), _(difficulty).c_str());
opponentMenu->Add(nbAIDecks,deckDesc,mtgd->meta_desc);
delete mtgd;
}
}
}

View File

@@ -327,16 +327,35 @@ MTGCard * MTGAllCards::getCardByName(string name){
MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards){
MTGDeck::MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards, int meta_only){
mCache = cache;
total_cards = 0;
allcards = _allcards;
filename = config_file;
size_t slash = filename.find_last_of("/");
size_t dot = filename.find(".");
meta_name = filename.substr(slash+1,dot-slash-1);
std::ifstream file(config_file);
std::string s;
if(file){
while(std::getline(file,s)){
if (!s.size()) continue;
if (s[0] == '#'){
size_t found = s.find("NAME:");
if ( found != string::npos){
meta_name = s.substr(found+5);
continue;
}
found = s.find("DESC:");
if ( found != string::npos){
if (meta_desc.size()) meta_desc.append("\n");
meta_desc.append(s.substr(found+5));
continue;
}
continue;
}
if (meta_only) break;
int cardnb = atoi(s.c_str());
if (cardnb){
add(cardnb);

View File

@@ -134,8 +134,10 @@ void SimpleMenu::Render(){
if (i > mCount-1) break;
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7)
{
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus())
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+20,mY+15);
mFont->SetColor(ARGB(255,255,255,0));
}
else
mFont->SetColor(ARGB(255,255,255,255));
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
@@ -168,8 +170,10 @@ void SimpleMenu::Update(float dt){
}
}
void SimpleMenu::Add(int id, const char * text){
JGuiController::Add(NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0)));
void SimpleMenu::Add(int id, const char * text,string desc){
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0));
smi->desc = desc;
JGuiController::Add(smi);
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
}

View File

@@ -19,7 +19,7 @@ import os
import os.path
from mtgCommon import *
setinfo=sets['OD']
setinfo=sets['UZ']
stripReminderText = False
conffile = open(setinfo['dir'] + ".conf", 'w')

View File

@@ -16,6 +16,13 @@ sets ={'BE':{'name':'Beta',
'gathabbrev': '3E',
'gathname':'RevisedEdition'
},
'ARB':{'name':'Alara Reborn',
'dir':'ARB',
'abbrev':'ARB',
'gathdirs':['ARB/en-us'],
'gathabbrev': 'ARB',
'gathname':'Alara%20Reborn'
},
'4E':{'name':'4th Edition',
'dir':'4E',
'abbrev':'4E',
@@ -229,10 +236,11 @@ sets ={'BE':{'name':'Beta',
'gathabbrev': 'EX',
'gathname':'Exodus',
},
'US':{'name':'Urza\'s Saga',
'dir':'US',
'abbrev':'US',
'UZ':{'name':'Urza\'s Saga',
'dir':'UZ',
'abbrev':'UZ',
'gathabbrev': 'UZ',
'gathdirs':['UZ/en-us'],
'gathname':'UrzasSaga',
},
'UL':{'name':'Urza\'s Legacy',
@@ -360,10 +368,11 @@ sets ={'BE':{'name':'Beta',
'gathabbrev': 'SOK',
'gathname':'SaviorsofKamigawa',
},
'RA':{'name':'Ravnica: City of Guilds',
'dir':'RA',
'abbrev':'RA',
'RAV':{'name':'Ravnica: City of Guilds',
'dir':'RAV',
'abbrev':'RAV',
'gathabbrev': 'RAV',
'gathdirs':['RAV/en-us'],
'gathname':'RavnicaCityofGuilds',
},
'GP':{'name':'Guildpact',