fixed minor bug with Ai deck saving routine.

fixed psp compilation, changed use of char* to ostringstream for menu text.
This commit is contained in:
techdragon.nguyen@gmail.com
2010-10-27 17:26:32 +00:00
parent 7a13f562c7
commit 98627d96ba
2 changed files with 26 additions and 21 deletions

View File

@@ -6,6 +6,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include <math.h> #include <math.h>
#include <iomanip>
#include "DeckManager.h" #include "DeckManager.h"
#include "GameStateDuel.h" #include "GameStateDuel.h"
@@ -154,38 +155,42 @@ void GameStateDeckViewer::updateDecks(){
void GameStateDeckViewer::buildEditorMenu() void GameStateDeckViewer::buildEditorMenu()
{ {
char aiDeckMsg[512]; ostringstream aiDeckMsg;
if ( myDeck ) { if ( myDeck ) {
sprintf_s( aiDeckMsg, "%s\n\t--- Deck Summary ---\nNum Cards: %i\nLands: %i\nAvg Creature Cost: %2.2f\nAvg Mana Cost: %2.2f\nAvg Spell Cost: %2.2f\n--- Card color count ---\nA: %i G: %i U: %i \nR: %i B: %i W: %i\n", aiDeckMsg
"****WARNING*****\nAll changes are final.\n", << "****WARNING*****"<< endl
myDeck->getCount(), << "All changes are final." << endl << endl
myDeck->getCount(Constants::MTG_COLOR_LAND ), << "------- Deck Summary -----" << endl
stw.avgCreatureCost, << "# Cards: "<< myDeck->getCount() << endl
stw.avgManaCost, << "# Lands: "<< myDeck->getCount(Constants::MTG_COLOR_LAND ) << endl
stw.avgSpellCost, << "Avg. Creature Cost: " << setprecision(2) << stw.avgCreatureCost << endl
myDeck->getCount(Constants::MTG_COLOR_ARTIFACT), << "Avg. Mana Cost: " << setprecision(2) << stw.avgManaCost << endl
myDeck->getCount(Constants::MTG_COLOR_GREEN), << "Avg. Spell Cost: " << setprecision(2) << stw.avgSpellCost << endl
myDeck->getCount(Constants::MTG_COLOR_BLUE), << " --- Card color count --- " << endl
myDeck->getCount(Constants::MTG_COLOR_RED), << "A: " << myDeck->getCount(Constants::MTG_COLOR_ARTIFACT)
myDeck->getCount(Constants::MTG_COLOR_BLACK), << " G: " << myDeck->getCount(Constants::MTG_COLOR_GREEN)
myDeck->getCount(Constants::MTG_COLOR_WHITE) << " U: " << myDeck->getCount(Constants::MTG_COLOR_BLUE) << endl
); << "R: " << myDeck->getCount(Constants::MTG_COLOR_RED)
<< " B: " << myDeck->getCount(Constants::MTG_COLOR_BLACK)
<< " W: " << myDeck->getCount(Constants::MTG_COLOR_WHITE) << endl;
} }
else else
sprintf_s( aiDeckMsg, "%s", "****WARNING*****\nAll changes are final.\n"); aiDeckMsg << "****WARNING*****" << endl << "All changes are final." << endl;
if ( menu ) if ( menu )
SAFE_DELETE( menu ); SAFE_DELETE( menu );
//Build menu. //Build menu.
menu = NEW SimpleMenu( MENU_DECK_BUILDER, this, Fonts::MENU_FONT, SCREEN_WIDTH/2-150, 20); menu = NEW SimpleMenu( MENU_DECK_BUILDER, this, Fonts::MENU_FONT, SCREEN_WIDTH/2-150, 20);
menu->Add( MENU_ITEM_FILTER_BY, "Filter by..."); menu->Add( MENU_ITEM_FILTER_BY, "Filter By...");
menu->Add( MENU_ITEM_SWITCH_DECKS_NO_SAVE, "Switch decks"); menu->Add( MENU_ITEM_SWITCH_DECKS_NO_SAVE, "Switch Decks");
menu->Add( MENU_ITEM_SAVE_RENAME, "Rename deck"); menu->Add( MENU_ITEM_SAVE_RENAME, "Rename Deck");
menu->Add( MENU_ITEM_SAVE_RETURN_MAIN_MENU, "Save & Quit Editor"); menu->Add( MENU_ITEM_SAVE_RETURN_MAIN_MENU, "Save & Quit Editor");
menu->Add( MENU_ITEM_SAVE_AS_AI_DECK, "Save as AI deck", _(aiDeckMsg) ); menu->Add( MENU_ITEM_SAVE_AS_AI_DECK, "Save As AI Deck", aiDeckMsg.str() );
menu->Add( MENU_ITEM_MAIN_MENU, "Main Menu"); menu->Add( MENU_ITEM_MAIN_MENU, "Main Menu");
menu->Add( MENU_ITEM_EDITOR_CANCEL, "Cancel"); menu->Add( MENU_ITEM_EDITOR_CANCEL, "Cancel");
aiDeckMsg.str(""); // clear the stream
} }
void GameStateDeckViewer::Start() void GameStateDeckViewer::Start()

View File

@@ -778,7 +778,7 @@ int MTGDeck::save(string destFileName, bool useExpandedDescriptions, string &dec
continue; continue;
} }
MTGSetInfo *setInfo = setlist.getInfo( card->setId ); MTGSetInfo *setInfo = setlist.getInfo( card->setId );
string setName = setInfo->getName(); string setName = setInfo->id;
string cardName = card->data->getName(); string cardName = card->data->getName();
file<< cardName << "\t " << "(" << setName << ") *" << nbCards << endl; file<< cardName << "\t " << "(" << setName << ") *" << nbCards << endl;
setInfo = NULL; setInfo = NULL;