- updated pt translation (thanks to almosthumane)
- Added/updated some Themes by Ilya B
- Added a random wallpaper loading at loading screen (see wallpapers.txt in Res/graphics)
- Saving decks and collection should now be a bit more secure (attempt at minimizing issue 393)
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-05-02 12:49:36 +00:00
parent c26f453b16
commit 755bb04475
54 changed files with 304 additions and 176 deletions
+10 -2
View File
@@ -46,6 +46,11 @@ GameApp::GameApp(): JApp()
nbUpdates = 0;
totalFPS = 0;
#endif
#ifdef DOLOG
remove(LOG_FILE);
#endif
mScreenShotCount = 0;
for (int i=0; i < GAME_STATE_MAX ; i++)
@@ -112,7 +117,7 @@ void GameApp::Create()
LOG("Loading Textures");
LOG("--Loading menuicons.png");
resources.RetrieveTexture("menuicons.png",RETRIEVE_MANAGE);
LOG("---Gettings menuicons.png quads");
//Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id
manaIcons[Constants::MTG_COLOR_GREEN] = resources.RetrieveQuad("menuicons.png", 2 + 0*36, 38, 32, 32, "c_green",RETRIEVE_MANAGE);
manaIcons[Constants::MTG_COLOR_BLUE] = resources.RetrieveQuad("menuicons.png", 2 + 1*36, 38, 32, 32, "c_blue",RETRIEVE_MANAGE);
@@ -125,7 +130,7 @@ void GameApp::Create()
for (int i = sizeof(manaIcons)/sizeof(manaIcons[0]) - 1; i >= 0; --i) manaIcons[i]->SetHotSpot(16,16);
LOG("--Loading Other Textures");
LOG("--Loading back.jpg");
resources.RetrieveTexture("back.jpg",RETRIEVE_MANAGE);
JQuad * jq = resources.RetrieveQuad("back.jpg", 0, 0, 0, 0, "back",RETRIEVE_MANAGE);
if (jq) jq->SetHotSpot(jq->mWidth/2, jq->mHeight/2);
@@ -133,12 +138,14 @@ void GameApp::Create()
resources.RetrieveTexture("back_thumb.jpg",RETRIEVE_MANAGE);
resources.RetrieveQuad("back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT, "back_thumb",RETRIEVE_MANAGE);
LOG("--Loading particles.png");
resources.RetrieveTexture("particles.png",RETRIEVE_MANAGE);
jq = resources.RetrieveQuad("particles.png", 0, 0, 32, 32, "particles",RETRIEVE_MANAGE);
jq->SetHotSpot(16,16);
jq = resources.RetrieveQuad("particles.png", 64, 0, 32, 32, "stars",RETRIEVE_MANAGE);
jq->SetHotSpot(16,16);
LOG("--Loading fonts");
resources.LoadJLBFont("simon",11);
resources.GetJLBFont("simon")->SetTracking(-1);
resources.LoadJLBFont("f3",16);
@@ -146,6 +153,7 @@ void GameApp::Create()
resources.LoadJLBFont("smallface", 7);
LOG("--Loading various textures");
resources.RetrieveTexture("phasebar.png",RETRIEVE_MANAGE);
resources.RetrieveTexture("wood.png",RETRIEVE_MANAGE);
resources.RetrieveTexture("gold.png",RETRIEVE_MANAGE);
-3
View File
@@ -362,13 +362,10 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
int result;
if (card) {
if (card == cardWaitingForTargets){
LOG("attempt to close targetting");
int _result = targetChooser->ForceTargetListReady();
if (_result){
result = TARGET_OK_FULL;
}else{
LOG("...but we cant!\n");
result = targetChooser->targetsReadyCheck();
}
}else{
-5
View File
@@ -249,9 +249,6 @@ void GameStateDuel::Update(float dt)
loadTestSuitePlayers();
mGamePhase = DUEL_STATE_PLAY;
testSuite->initGame();
char buf[4096];
sprintf(buf, "nb cards in player2's graveyard : %i\n",mPlayers[1]->game->graveyard->nb_cards);
LOG(buf);
}else{
if (!game){
mGamePhase = DUEL_STATE_ERROR;
@@ -391,7 +388,6 @@ void GameStateDuel::Update(float dt)
void GameStateDuel::Render()
{
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
LOG("Start Render\n");
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));
@@ -466,7 +462,6 @@ void GameStateDuel::Render()
if(menu)
menu->Render();
}
LOG("End Render\n");
}
void GameStateDuel::ButtonPressed(int controllerId, int controlId)
+38 -2
View File
@@ -160,6 +160,8 @@ void GameStateMenu::Start(){
if(currentState == MENU_STATE_MAJOR_MAINMENU){
currentState = currentState | MENU_STATE_MINOR_FADEIN;
}
wallpaper = "";
}
void GameStateMenu::genNbCardsStr(){
@@ -280,6 +282,28 @@ void GameStateMenu::End()
SAFE_DELETE(mGuiController);
}
string GameStateMenu::loadRandomWallpaper() {
if (wallpaper.size())
return wallpaper;
vector<string> wallpapers;
std::ifstream file("Res/graphics/wallpapers.txt");
if (!file) return wallpaper;
string s;
while (std::getline(file,s)) {
if (!s.size()) continue;
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
wallpapers.push_back(s);
}
int rnd = rand() % (wallpapers.size());
wallpaper = wallpapers[rnd];
return wallpaper;
}
string GameStateMenu::getLang(string s){
if (!s.size()) return "";
if (s[s.size()-1] == '\r') s.erase(s.size()-1); //Handle DOS files
@@ -530,8 +554,17 @@ void GameStateMenu::Render()
}
if (mSplash)
renderer->RenderQuad(mSplash,0,0);
else {
string wp = loadRandomWallpaper();
if (wp.size()) {
JTexture * wpTex = resources.RetrieveTexture(wp);
if (wpTex) {
JQuad * wpQuad = resources.RetrieveTempQuad(wp);
renderer->RenderQuad(wpQuad,0,0,0,SCREEN_WIDTH_F / wpQuad->mWidth, SCREEN_HEIGHT_F / wpQuad->mHeight);
}
}
}
char text[512];
mFont->SetColor(ARGB(255,255,255,255));
if (mCurrentSetName[0]) {
sprintf(text, _("LOADING SET: %s").c_str(), mCurrentSetName);
}else{
@@ -540,7 +573,10 @@ void GameStateMenu::Render()
else
sprintf(text,"LOADING...");
}
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
mFont->SetColor(ARGB(170,0,0,0));
mFont->DrawString(text,SCREEN_WIDTH/2 + 2 ,SCREEN_HEIGHT - 50 + 2,JGETEXT_CENTER);
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT - 50,JGETEXT_CENTER);
}else{
mFont = resources.GetJLBFont(Constants::MAIN_FONT);
PIXEL_TYPE colors[] =
+4
View File
@@ -1,5 +1,7 @@
#include "../include/config.h"
#include "../include/Logger.h"
#ifdef DOLOG
#include <iostream>
#include <fstream>
using namespace std;
@@ -21,3 +23,5 @@ void Logger::Log(const char * text){
#endif
}
#endif
-7
View File
@@ -2350,16 +2350,11 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost , int doTap, int who):ActivatedAbilityTP(id, card,t,_cost,doTap,who){
LOG("==Creating ManaProducer Object");
aType = MTGAbility::MANA_PRODUCER;
cost = _cost;
output = _output;
menutext = "";
LOG("==ManaProducer Object Creation successful !");
}
int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana){
@@ -2446,10 +2441,8 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, Man
AManaProducer::~AManaProducer(){
LOG("==Destroying ManaProducer Object");
SAFE_DELETE(cost);
SAFE_DELETE(output);
LOG("==Destroying ManaProducer Object Successful!");
}
AManaProducer * AManaProducer::clone() const{
-7
View File
@@ -20,12 +20,9 @@ MTGCardInstance MTGCardInstance::ExtraRules[] = {MTGCardInstance(), MTGCardInsta
MTGCardInstance::MTGCardInstance(): CardPrimitive(), MTGCard(), Damageable(0), view(NULL){
LOG("==Creating MTGCardInstance==");
initMTGCI();
LOG("==Creating MTGCardInstance Successful==");
}
MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to): CardPrimitive(card->data),MTGCard(card), Damageable(card->data->getToughness()), view(NULL){
LOG("==Creating MTGCardInstance==");
initMTGCI();
model = card;
attacker = 0;
@@ -37,8 +34,6 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
defenser = NULL;
banding = NULL;
life = toughness;
LOG("==Creating MTGCardInstance Successful==");
}
void MTGCardInstance::copy(MTGCardInstance * card){
@@ -80,10 +75,8 @@ void MTGCardInstance::copy(MTGCardInstance * card){
}
MTGCardInstance::~MTGCardInstance(){
LOG("==Deleting MTGCardInstance==");
SAFE_DELETE(counters);
SAFE_DELETE(previous);
LOG("==Deleting MTGCardInstance Succesfull==");
}
int MTGCardInstance::init(){
+5 -1
View File
@@ -687,7 +687,9 @@ int MTGDeck::remove(MTGCard * card){
}
int MTGDeck::save(){
std::ofstream file(filename.c_str());
string tmp = filename;
tmp.append(".tmp"); //not thread safe
std::ofstream file(tmp.c_str());
char writer[512];
if (file){
#if defined (WIN32) || defined (LINUX)
@@ -716,6 +718,8 @@ int MTGDeck::save(){
}
}
file.close();
std::remove(filename.c_str());
rename(tmp.c_str(),filename.c_str());
}
DeckMetaDataList::decksMetaData->invalidate(filename);
return 1;
-10
View File
@@ -11,24 +11,18 @@ MTGPutInPlayRule::MTGPutInPlayRule(int _id):MTGAbility(_id, NULL){
int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer;
LOG("CANPUTINPLAY- check if card belongs to current player\n");
if (!player->game->hand->hasCard(card)) return 0;
LOG("CANPUTINPLAY- check if card is land or can be played\n");
if (card->hasType("land")){
LOG("CANPUTINPLAY- card is land - check if can be played\n");
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)){
LOG("CANPUTINPLAY- Land, ok\n");
return 1;
}
}else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))){
LOG("CANPUTINPLAY- correct time to play\n");
ManaCost * playerMana = player->getManaPool();
ManaCost * cost = card->getManaCost();
#ifdef WIN32
cost->Dump();
#endif
if (playerMana->canAfford(cost)){
LOG("CANPUTINPLAY- ManaCost ok\n");
return 1;
}
}
@@ -41,7 +35,6 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
ManaCost * cost = card->getManaCost();
if (cost->isExtraPaymentSet()){
if (!game->targetListIsSet(card)){
LOG("CANPUTINPLAY- Targets not chosen yet\n");
return 0;
}
}else{
@@ -279,11 +272,8 @@ int MTGMomirRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
if (alreadyplayed) return 0;
Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer;
LOG("CANPUTINPLAY- check if card belongs to current player\n");
if (!player->game->hand->hasCard(card)) return 0;
LOG("CANPUTINPLAY- check if card is land or can be played\n");
if (player == currentPlayer && !game->isInterrupting && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)){
LOG("CANPUTINPLAY- correct time to play\n");
return 1;
}
return 0;