Erwan
- Added a few "stats" to the main menu. This might slow down loading times on the PSP (needs testing). In that case I'll move it to the options, or optimize it if needed
This commit is contained in:
@@ -53,7 +53,7 @@ public:
|
|||||||
/// @align - Text aligment.
|
/// @align - Text aligment.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void DrawString(const char *string, float x, float y, int align=JGETEXT_LEFT);
|
void DrawString(const char *string, float x, float y, int align=JGETEXT_LEFT, float leftOffset = 0, float width = 0);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Rendering text to screen with syntax similar to printf of C/C++.
|
/// Rendering text to screen with syntax similar to printf of C/C++.
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ JLBFont::~JLBFont()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JLBFont::DrawString(const char *string, float x, float y, int align)
|
void JLBFont::DrawString(const char *string, float x, float y, int align, float leftOffset, float displayWidth)
|
||||||
{
|
{
|
||||||
char *p = (char*)string;
|
char *p = (char*)string;
|
||||||
float dx = x, dy = y;
|
float dx = x, dy = y;
|
||||||
@@ -115,13 +115,41 @@ void JLBFont::DrawString(const char *string, float x, float y, int align)
|
|||||||
|
|
||||||
dx = floorf(dx);
|
dx = floorf(dx);
|
||||||
dy = floorf(dy);
|
dy = floorf(dy);
|
||||||
|
float x0 = dx;
|
||||||
int index;
|
int index;
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
index = (*p - 32)+mBase;
|
index = (*p - 32)+mBase;
|
||||||
mQuad->SetTextureRect(mXPos[index], mYPos[index], mCharWidth[index], mHeight);
|
float charWidth = mCharWidth[index];
|
||||||
|
float delta = (charWidth + mTracking) * mScale;
|
||||||
|
float xPos = mXPos[index];
|
||||||
|
if (leftOffset){
|
||||||
|
if (leftOffset < 0){
|
||||||
|
dx-=leftOffset;
|
||||||
|
leftOffset = 0;
|
||||||
|
continue;
|
||||||
|
}else if (leftOffset - delta > 0){
|
||||||
|
leftOffset -= delta;
|
||||||
|
p++;
|
||||||
|
continue;
|
||||||
|
}else{
|
||||||
|
xPos = mXPos[index] + (leftOffset);
|
||||||
|
delta -= leftOffset;
|
||||||
|
leftOffset = 0;
|
||||||
|
|
||||||
|
charWidth = (delta/mScale) - mTracking;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (displayWidth){
|
||||||
|
if (dx > x0+displayWidth) return;
|
||||||
|
if (dx+delta > x0+displayWidth) {
|
||||||
|
delta = x0 + displayWidth - dx;
|
||||||
|
charWidth = (delta/mScale) - mTracking;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mQuad->SetTextureRect(xPos, mYPos[index], charWidth , mHeight);
|
||||||
mRenderer->RenderQuad(mQuad, dx, dy, mRotation, mScale, mScale);
|
mRenderer->RenderQuad(mQuad, dx, dy, mRotation, mScale, mScale);
|
||||||
dx += (mCharWidth[index] + mTracking) * mScale;
|
dx += delta;
|
||||||
p++;
|
p++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
|
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
|
||||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||||
|
|
||||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||||
|
|||||||
@@ -344,6 +344,7 @@ mana={R}
|
|||||||
text=Pyroclasm deals 2 damage to each creature.
|
text=Pyroclasm deals 2 damage to each creature.
|
||||||
id=2650
|
id=2650
|
||||||
name=Pyroclasm
|
name=Pyroclasm
|
||||||
|
auto=damage:2 all(creature)
|
||||||
rarity=U
|
rarity=U
|
||||||
type=Sorcery
|
type=Sorcery
|
||||||
mana={1}{R}
|
mana={1}{R}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class DeckDataWrapper{
|
|||||||
void updateCounts(MTGCard * card = NULL, int removed = 0);
|
void updateCounts(MTGCard * card = NULL, int removed = 0);
|
||||||
void updateCurrentPosition(MTGCard * currentCard,int color = -1);
|
void updateCurrentPosition(MTGCard * currentCard,int color = -1);
|
||||||
int getCount(int color = -1);
|
int getCount(int color = -1);
|
||||||
|
int totalPrice();
|
||||||
void save();
|
void save();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ public:
|
|||||||
void cleanStats();
|
void cleanStats();
|
||||||
~DeckStats();
|
~DeckStats();
|
||||||
int percentVictories(string opponentsDeckFile);
|
int percentVictories(string opponentsDeckFile);
|
||||||
|
int percentVictories();
|
||||||
|
int nbGames();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "../include/GameState.h"
|
#include "../include/GameState.h"
|
||||||
#include "../include/SimpleMenu.h"
|
#include "../include/SimpleMenu.h"
|
||||||
|
#include "../include/TextScroller.h"
|
||||||
|
|
||||||
class GameStateMenu: public GameState, public JGuiListener
|
class GameStateMenu: public GameState, public JGuiListener
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
TextScroller * scroller;
|
||||||
|
int scrollerSet;
|
||||||
JGuiController* mGuiController;
|
JGuiController* mGuiController;
|
||||||
SimpleMenu* subMenuController;
|
SimpleMenu* subMenuController;
|
||||||
SimpleMenu* gameTypeMenu;
|
SimpleMenu* gameTypeMenu;
|
||||||
@@ -38,7 +40,7 @@ class GameStateMenu: public GameState, public JGuiListener
|
|||||||
float angleMultiplier;
|
float angleMultiplier;
|
||||||
float angleW;
|
float angleW;
|
||||||
float yW;
|
float yW;
|
||||||
|
void fillScroller();
|
||||||
public:
|
public:
|
||||||
GameStateMenu(GameApp* parent);
|
GameStateMenu(GameApp* parent);
|
||||||
virtual ~GameStateMenu();
|
virtual ~GameStateMenu();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/TexturesCache.h"
|
#include "../include/TexturesCache.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "../include/MTGDeck.h"
|
#include "../include/MTGDeck.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class MTGAllCards;
|
||||||
|
|
||||||
class Price{
|
class Price{
|
||||||
public:
|
public:
|
||||||
int cardid;
|
int cardid;
|
||||||
|
|||||||
33
projects/mtg/include/TextScroller.h
Normal file
33
projects/mtg/include/TextScroller.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef _TEXTSCROLLER_H_
|
||||||
|
#define _TEXTSCROLLER_H_
|
||||||
|
|
||||||
|
class JLBFont;
|
||||||
|
#include <JGui.h>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class TextScroller: public JGuiObject{
|
||||||
|
private:
|
||||||
|
string mText;
|
||||||
|
string tempText;
|
||||||
|
JLBFont * mFont;
|
||||||
|
float mWidth;
|
||||||
|
float mSpeed;
|
||||||
|
float mX;
|
||||||
|
float mY;
|
||||||
|
float start;
|
||||||
|
int timer;
|
||||||
|
vector<string> strings;
|
||||||
|
int currentId;
|
||||||
|
int mRandom;
|
||||||
|
public:
|
||||||
|
void Add(string text);
|
||||||
|
void Reset();
|
||||||
|
void setRandom(int mode = 1);
|
||||||
|
TextScroller(JLBFont * font, float x, float y, float width, float speed = 30);
|
||||||
|
void Render();
|
||||||
|
void Update(float dt);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
#include "../include/DeckDataWrapper.h"
|
#include "../include/DeckDataWrapper.h"
|
||||||
#include "../include/MTGDeck.h"
|
#include "../include/MTGDeck.h"
|
||||||
|
#include "../include/PriceList.h"
|
||||||
|
|
||||||
DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){
|
DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){
|
||||||
parent = deck;
|
parent = deck;
|
||||||
@@ -9,6 +11,7 @@ DeckDataWrapper::DeckDataWrapper(MTGDeck * deck){
|
|||||||
for (int i = 0; i < deck->totalCards(); i++){
|
for (int i = 0; i < deck->totalCards(); i++){
|
||||||
MTGCard * card = deck->_(i);
|
MTGCard * card = deck->_(i);
|
||||||
Add(card);
|
Add(card);
|
||||||
|
|
||||||
}
|
}
|
||||||
currentposition = 0;
|
currentposition = 0;
|
||||||
currentColor = -1;
|
currentColor = -1;
|
||||||
@@ -127,3 +130,16 @@ int DeckDataWrapper::getCount(int color){
|
|||||||
if (color == -1) return colors[Constants::MTG_NB_COLORS];
|
if (color == -1) return colors[Constants::MTG_NB_COLORS];
|
||||||
return colors[color];
|
return colors[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DeckDataWrapper::totalPrice(){
|
||||||
|
int total = 0;
|
||||||
|
PriceList * pricelist = NEW PriceList(RESPATH"/settings/prices.dat",this->parent);
|
||||||
|
map<MTGCard *,int,Cmp1>::iterator it;
|
||||||
|
for ( it=cards.begin() ; it != cards.end(); it++ ){
|
||||||
|
MTGCard * current = (*it).first;
|
||||||
|
int nb = (*it).second;
|
||||||
|
if (nb) total += pricelist->getPrice(current->getMTGId());
|
||||||
|
}
|
||||||
|
delete pricelist;
|
||||||
|
return total;
|
||||||
|
}
|
||||||
@@ -39,6 +39,32 @@ int DeckStats::percentVictories(string opponentsFile){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DeckStats::nbGames(){
|
||||||
|
int nbgames = 0;
|
||||||
|
map<string,DeckStat *>::iterator it;
|
||||||
|
for (it = stats.begin(); it != stats.end(); it++){
|
||||||
|
DeckStat * d = it->second;
|
||||||
|
nbgames+=d->nbgames;
|
||||||
|
}
|
||||||
|
return nbgames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int DeckStats::percentVictories(){
|
||||||
|
int victories = 0;
|
||||||
|
int nbgames = 0;
|
||||||
|
map<string,DeckStat *>::iterator it;
|
||||||
|
for (it = stats.begin(); it != stats.end(); it++){
|
||||||
|
DeckStat * d = it->second;
|
||||||
|
nbgames+=d->nbgames;
|
||||||
|
victories+=d->victories;
|
||||||
|
}
|
||||||
|
if (nbgames){
|
||||||
|
return (victories * 100)/nbgames;
|
||||||
|
}
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
void DeckStats::load(Player * player){
|
void DeckStats::load(Player * player){
|
||||||
char filename[512];
|
char filename[512];
|
||||||
sprintf(filename, RESPATH"/player/stats/%s.txt",player->deckFile.c_str());
|
sprintf(filename, RESPATH"/player/stats/%s.txt",player->deckFile.c_str());
|
||||||
|
|||||||
@@ -193,7 +193,6 @@ void GameApp::Destroy()
|
|||||||
SAFE_DELETE(music);
|
SAFE_DELETE(music);
|
||||||
Translator::EndInstance();
|
Translator::EndInstance();
|
||||||
|
|
||||||
|
|
||||||
SimpleMenu::destroy();
|
SimpleMenu::destroy();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/MTGCard.h"
|
#include "../include/MTGCard.h"
|
||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
#include "../include/DeckStats.h"
|
||||||
|
#include "../include/PlayerData.h"
|
||||||
|
#include "../include/utils.h"
|
||||||
|
#include "../include/DeckDataWrapper.h"
|
||||||
|
|
||||||
static const char* GAME_VERSION = "WTH?! 0.6.2 - by WilLoW";
|
static const char* GAME_VERSION = "WTH?! 0.6.2 - by WilLoW";
|
||||||
#define ALPHA_WARNING 0
|
#define ALPHA_WARNING 0
|
||||||
@@ -69,6 +72,7 @@ GameStateMenu::GameStateMenu(GameApp* parent): GameState(parent)
|
|||||||
mVolume = 0;
|
mVolume = 0;
|
||||||
splashTex = NULL;
|
splashTex = NULL;
|
||||||
splashQuad = NULL;
|
splashQuad = NULL;
|
||||||
|
scroller = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameStateMenu::~GameStateMenu() {}
|
GameStateMenu::~GameStateMenu() {}
|
||||||
@@ -118,6 +122,8 @@ void GameStateMenu::Create()
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_NONE;
|
||||||
|
scroller = NEW TextScroller(GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT), SCREEN_WIDTH/2 - 100 , SCREEN_HEIGHT-15,200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -137,6 +143,7 @@ void GameStateMenu::Destroy()
|
|||||||
SAFE_DELETE(mMovingW);
|
SAFE_DELETE(mMovingW);
|
||||||
SAFE_DELETE(movingWTexture);
|
SAFE_DELETE(movingWTexture);
|
||||||
SAFE_DELETE(bgTexture);
|
SAFE_DELETE(bgTexture);
|
||||||
|
SAFE_DELETE(scroller);
|
||||||
|
|
||||||
//SAFE_DELETE (bgMusic);
|
//SAFE_DELETE (bgMusic);
|
||||||
}
|
}
|
||||||
@@ -160,9 +167,73 @@ void GameStateMenu::Start(){
|
|||||||
|
|
||||||
hasChosenGameType = 1;
|
hasChosenGameType = 1;
|
||||||
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) hasChosenGameType =0;
|
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) hasChosenGameType =0;
|
||||||
|
|
||||||
|
scrollerSet = 0;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameStateMenu::fillScroller(){
|
||||||
|
scroller->Reset();
|
||||||
|
char buffer[4096];
|
||||||
|
char buff2[512];
|
||||||
|
|
||||||
|
DeckStats * stats = DeckStats::GetInstance();
|
||||||
|
int totalGames = 0;
|
||||||
|
for (int j=1; j<6; j++){
|
||||||
|
sprintf(buffer, RESPATH"/player/stats/player_deck%i.txt",j);
|
||||||
|
if(fileExists(buffer)){
|
||||||
|
stats->load(buffer);
|
||||||
|
int percentVictories = stats->percentVictories();
|
||||||
|
|
||||||
|
sprintf(buff2, "You have a %i%% victory ratio with Deck%i",percentVictories,j);
|
||||||
|
scroller->Add(buff2);
|
||||||
|
int nbGames = stats->nbGames();
|
||||||
|
totalGames+= nbGames;
|
||||||
|
sprintf(buff2, "You have played %i games with Deck%i",nbGames,j);
|
||||||
|
scroller->Add(buff2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (totalGames){
|
||||||
|
sprintf(buff2, "You have played a total of %i games",totalGames);
|
||||||
|
scroller->Add(buff2);
|
||||||
|
}
|
||||||
|
GameOptions * go = GameOptions::GetInstance();
|
||||||
|
|
||||||
|
if (!go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()){
|
||||||
|
scroller->Add("Unlock the difficult mode for more challenging duels!");
|
||||||
|
}
|
||||||
|
if (!go->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()){
|
||||||
|
scroller->Add("Interested in playing Momir Basic? You'll have to unlock it first :)");
|
||||||
|
}
|
||||||
|
|
||||||
|
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache,mParent->collection));
|
||||||
|
int totalCards = ddw->getCount();
|
||||||
|
if (totalCards){
|
||||||
|
sprintf(buff2, "You have a total of %i cards in your collection",totalCards);
|
||||||
|
scroller->Add(buff2);
|
||||||
|
|
||||||
|
int estimatedValue = ddw->totalPrice();
|
||||||
|
sprintf(buff2, "The shopkeeper would buy your entire collection for around %i credits",estimatedValue/2);
|
||||||
|
scroller->Add(buff2);
|
||||||
|
|
||||||
|
sprintf(buff2, "The cards in your collection have an average value of %i credits",estimatedValue/totalCards);
|
||||||
|
scroller->Add(buff2);
|
||||||
|
}
|
||||||
|
delete ddw;
|
||||||
|
|
||||||
|
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||||
|
sprintf(buff2, "You currently have %i credits",playerdata->credits);
|
||||||
|
delete playerdata;
|
||||||
|
scroller->Add(buff2);
|
||||||
|
|
||||||
|
scroller->Add("Need more cards? Go to http://wololo.net/wagic");
|
||||||
|
|
||||||
|
scrollerSet = 1;
|
||||||
|
scroller->setRandom();
|
||||||
|
}
|
||||||
|
|
||||||
int GameStateMenu::nextCardSet(){
|
int GameStateMenu::nextCardSet(){
|
||||||
int found = 0;
|
int found = 0;
|
||||||
if (!mDip){
|
if (!mDip){
|
||||||
@@ -245,6 +316,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_MAINMENU :
|
case MENU_STATE_MAJOR_MAINMENU :
|
||||||
|
if (!scrollerSet) fillScroller();
|
||||||
if (mGuiController!=NULL){
|
if (mGuiController!=NULL){
|
||||||
mGuiController->Update(dt);
|
mGuiController->Update(dt);
|
||||||
}
|
}
|
||||||
@@ -307,6 +379,8 @@ void GameStateMenu::Update(float dt)
|
|||||||
angleW += angleMultiplier * dt;
|
angleW += angleMultiplier * dt;
|
||||||
yW = yW + 5*dt + (yW - 55) *5*dt;
|
yW = yW + 5*dt + (yW - 55) *5*dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scroller->Update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -391,10 +465,13 @@ void GameStateMenu::Render()
|
|||||||
|
|
||||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
mFont->SetColor(ARGB(128,255,255,255));
|
mFont->SetColor(ARGB(128,255,255,255));
|
||||||
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
|
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,5,JGETEXT_RIGHT);
|
||||||
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
|
mFont->DrawString(nbcardsStr,10, 5);
|
||||||
mFont->SetScale(1.f);
|
mFont->SetScale(1.f);
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
|
|
||||||
|
scroller->Render();
|
||||||
|
|
||||||
if (subMenuController){
|
if (subMenuController){
|
||||||
subMenuController->Render();
|
subMenuController->Render();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -938,12 +938,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
|||||||
game->addObserver(NEW AConservator(_id,card));
|
game->addObserver(NEW AConservator(_id,card));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* case 1196: //Counterspell
|
|
||||||
{
|
|
||||||
Spell * starget = spell->getNextSpellTarget();
|
|
||||||
if (starget) game->mLayers->stackLayer()->Fizzle(starget);
|
|
||||||
break;
|
|
||||||
} */
|
|
||||||
case 1197: //Creature Bond
|
case 1197: //Creature Bond
|
||||||
{
|
{
|
||||||
game->addObserver(NEW ACreatureBond(_id,card, card->target));
|
game->addObserver(NEW ACreatureBond(_id,card, card->target));
|
||||||
@@ -1593,34 +1588,12 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
|
|||||||
}
|
}
|
||||||
//Addons ICE-AGE Cards
|
//Addons ICE-AGE Cards
|
||||||
|
|
||||||
case 2650: //Pyroclasm Need to be improved copied from hurricane with does 0 dammage to player and does 2 dammage to each creature
|
|
||||||
{
|
|
||||||
int x = 2;
|
|
||||||
for (int i = 0; i < 2 ; i++){
|
|
||||||
game->mLayers->stackLayer()->addDamage(card, game->players[i], 0);// To be removed ?
|
|
||||||
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
|
|
||||||
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
|
|
||||||
if (current->isACreature()){
|
|
||||||
game->mLayers->stackLayer()->addDamage(card, current, x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2660: //Word of Blasting
|
case 2660: //Word of Blasting
|
||||||
{
|
{
|
||||||
card->target->controller()->game->putInGraveyard(card->target);
|
card->target->controller()->game->putInGraveyard(card->target);
|
||||||
card->target->controller()->life-= card->target->getManaCost()->getConvertedCost();
|
card->target->controller()->life-= card->target->getManaCost()->getConvertedCost();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2443: //Dark Banishing
|
|
||||||
{
|
|
||||||
if (card->target->hasColor(Constants::MTG_COLOR_BLACK)){
|
|
||||||
}else{
|
|
||||||
card->target->controller()->game->putInGraveyard(card->target);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2593: //Thoughtleech
|
case 2593: //Thoughtleech
|
||||||
{
|
{
|
||||||
game->addObserver(NEW AGiveLifeForTappedType (_id, card, "island"));
|
game->addObserver(NEW AGiveLifeForTappedType (_id, card, "island"));
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ int MTGAllCards::totalCards(){
|
|||||||
return (total_cards);
|
return (total_cards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
|
||||||
|
|
||||||
string s;
|
string s;
|
||||||
|
|||||||
@@ -379,6 +379,7 @@ void MTGLibrary::shuffleTopToBottom(int nbcards){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * source,MTGCardInstance * target){
|
MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * source,MTGCardInstance * target){
|
||||||
Player *p, *p2;
|
Player *p, *p2;
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
|||||||
51
projects/mtg/src/TextScroller.cpp
Normal file
51
projects/mtg/src/TextScroller.cpp
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include "../include/TextScroller.h"
|
||||||
|
|
||||||
|
#include <JLBFont.h>
|
||||||
|
|
||||||
|
TextScroller::TextScroller(JLBFont * font, float x, float y, float width, float speed):JGuiObject(0){
|
||||||
|
mFont = font;
|
||||||
|
mWidth = width;
|
||||||
|
mSpeed = speed;
|
||||||
|
mX = x;
|
||||||
|
mY = y;
|
||||||
|
start = -width;
|
||||||
|
timer = 0;
|
||||||
|
currentId = 0;
|
||||||
|
mRandom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextScroller::setRandom(int mode){
|
||||||
|
mRandom = mode;
|
||||||
|
if (mRandom && strings.size()){
|
||||||
|
currentId = (rand() % strings.size());
|
||||||
|
mText = strings[currentId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextScroller::Add(string text){
|
||||||
|
if (!strings.size()) mText = text;
|
||||||
|
strings.push_back(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextScroller::Reset(){
|
||||||
|
strings.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextScroller::Update(float dt){
|
||||||
|
start+=mSpeed*dt;
|
||||||
|
if (start > mFont->GetStringWidth(mText.c_str())){
|
||||||
|
start = -mWidth;
|
||||||
|
if (mRandom){
|
||||||
|
currentId = (rand() % strings.size());
|
||||||
|
}else{
|
||||||
|
currentId++;
|
||||||
|
if (currentId > strings.size()-1)currentId = 0;
|
||||||
|
}
|
||||||
|
mText = strings[currentId];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextScroller::Render(){
|
||||||
|
mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth);
|
||||||
|
}
|
||||||
@@ -484,6 +484,10 @@
|
|||||||
RelativePath=".\src\TestSuiteAI.cpp"
|
RelativePath=".\src\TestSuiteAI.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TextScroller.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\TexturesCache.cpp"
|
RelativePath=".\src\TexturesCache.cpp"
|
||||||
>
|
>
|
||||||
@@ -781,6 +785,10 @@
|
|||||||
RelativePath=".\include\TestSuiteAI.h"
|
RelativePath=".\include\TestSuiteAI.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\TextScroller.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\TexturesCache.h"
|
RelativePath=".\include\TexturesCache.h"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user