Merge branch 'master' into wp8

This commit is contained in:
xawotihs
2013-12-08 14:17:42 +01:00
59 changed files with 2368 additions and 1486 deletions
+9 -8
View File
@@ -2524,13 +2524,13 @@ public:
ALord(GameObserver* observer, int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, MTGAbility * a) :
ListMaintainerAbility(observer, _id, card), NestedAbility(a)
{
tc = _tc;
tc->targetter = NULL;
includeSelf = _includeSelf;
if(ability->aType == MTGAbility::STANDARD_PREVENT)
aType = MTGAbility::STANDARD_PREVENT;
}
{
tc = _tc;
tc->targetter = NULL;
includeSelf = _includeSelf;
if(ability->aType == MTGAbility::STANDARD_PREVENT)
aType = MTGAbility::STANDARD_PREVENT;
}
//returns true if it is me who created ability a attached to Damageable d
bool isParentOf(Damageable * d, MTGAbility * a)
@@ -2608,7 +2608,8 @@ public:
int removed(MTGCardInstance * card)
{
if (abilities.find(card) != abilities.end() && !(forceDestroy == -1 && forcedAlive == 1))//only embelms have forcedestroy = -1 and forcedalive = 1
if (abilities.find(card) != abilities.end()
&& !(forceDestroy == -1 && forcedAlive == 1)) //only embelms have forcedestroy = -1 and forcedalive = 1
{
game->removeObserver(abilities[card]);
abilities.erase(card);
+3 -3
View File
@@ -33,7 +33,7 @@ protected:
/*
** Tries to render the Big version of a card picture, backups to text version in case of failure
*/
static void RenderBig(MTGCard * card, const Pos& pos);
static void RenderBig(MTGCard * card, const Pos& pos, bool thumb = false);
static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal);
static void AlternateRender(MTGCard * card, const Pos& pos);
@@ -55,8 +55,8 @@ public:
virtual void Render();
virtual void Update(float dt);
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal);
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal);
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false);
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false);
static JQuadPtr AlternateThumbQuad(MTGCard * card);
virtual ostream& toString(ostream&) const;
+42
View File
@@ -0,0 +1,42 @@
#ifndef _CAROUSEL_DECK_VIEW_H_
#define _CAROUSEL_DECK_VIEW_H_
#include "DeckView.h"
#include "Easing.h"
class CarouselDeckView : public DeckView
{
private:
static const float max_scale;
static const float x_center;
static const float right_border;
static const float slide_animation_duration;
public:
CarouselDeckView();
virtual ~CarouselDeckView();
void Reset();
void UpdateViewState(float dt);
void UpdateCardPosition(CardRep &rep, int index);
void renderCard(int index)
{
int alpha = (int) (255 * (getCardRep(index).scale + 1.0 - max_scale));
DeckView::renderCard(index, alpha);
}
void Render();
MTGCard * Click(int x, int y);
void changePosition(int offset);
void changeFilter(int offset);
MTGCard *getActiveCard();
private:
float mScrollOffset, mSlideOffset;
InOutQuadEasing mScrollEasing;
InOutQuadEasing mSlideEasing;
};
#endif //_CAROUSEL_DECK_VIEW_H_
+63
View File
@@ -0,0 +1,63 @@
#ifndef _DECK_VIEW_H_
#define _DECK_VIEW_H_
#include <vector>
#include "MTGCard.h"
#include "DeckDataWrapper.h"
#include "WFont.h"
#include "WResourceManager.h"
#include "Pos.h"
class DeckView
{
protected:
static const float no_user_activity_show_card_delay;
public:
struct CardRep{
float x;
float y;
float scale;
MTGCard * card;
};
bool dirtyFilters;
bool dirtyCardPos;
DeckView(int numberOfCards);
virtual ~DeckView();
virtual void Reset();
//advances the view and card representations
void Update(float dt);
virtual void SetDeck(DeckDataWrapper *toShow);
DeckDataWrapper *deck();
void SwitchFilter(int delta);
void SwitchPosition(int delta);
int filter();
void reloadIndexes();
int getPosition();
virtual void Render() = 0;
virtual MTGCard * Click(int x, int y) = 0;
bool ButtonPressed(Buttons button);
virtual MTGCard *getActiveCard() = 0;
virtual void changePosition(int offset) = 0;
virtual void changeFilter(int offset) = 0;
protected:
float last_user_activity;
int mFilter;
DeckDataWrapper *mCurrentDeck;
vector<CardRep> mCards;
CardRep& getCardRep(unsigned int index);
void renderCard(int index, int alpha, bool asThumbnail = false);
int getCardIndexNextTo(int x, int y);
private:
virtual void UpdateViewState(float dt) = 0;
virtual void UpdateCardPosition(CardRep& rep, int index) = 0;
};
#endif // _DECK_VIEW_H_
+201
View File
@@ -0,0 +1,201 @@
#ifndef _EASING_H_
#define _EASING_H_
/*! \brief A class for eased floats for use in animations
*
* Animations often defines values a floating point variable
* should have at given times and interpolates between them to
* calculate the value of that variable at any given intermediate
* time step.
*
* The simplest case would be linear interpolation:
* Suppose a float "position" should be a at time = 0 and
* b at time = x. If the current time is y, the value of
* "position" is then a + (b-a)*y/x.
*
* This class defines the interface needed to implement different
* kind of interpolations with a common interface. See
* http://www.gizma.com/easing/ for more information for a few
* examples.
*/
class Easing
{
public:
/*! \brief The value at the start of an animation.
*
* start_value is undefined if no animation is running.
*/
float start_value;
/*! \brief The amount the value should change during the animation.
*
* delta_value is undefined if no animation is running.
*/
float delta_value;
/*! \brief The current value.
*
* Use this member to read the value or to write the value without
* to animate intermediate values and. Make sure that the easing
* is not used once value is deleted.
*/
float& value;
/*! \brief The duration the animation should take
*
* It is not relevant which unit is used. This value is undefined
* if no animation is running.
*/
float duration;
/*! \brief The accumulated time the animation did run until now.
*
* It is not relevant which unit is used. This values is undefined
* if no animation is running.
*/
float time_acc;
/*! \brief Sets Easing::float to val and sets the animation as not running.
*
* Make sure that the easing is not used once value is deleted.
*
* \param val The value to ease
*/
Easing(float& val): start_value(val), delta_value(0), value(val), duration(0), time_acc(0)
{
}
/*! \brief Resets the animation to its initial value
*
* This method does set the value to the start value and sets the passed time to 0.
* If there is no animation animation running, the resulting value is undefined.
*/
void reset()
{
value = start_value;
time_acc = 0;
}
/*! \brief Finishes the animation immediately
*
* Sets the value to the animations target value and the passed time to the
* animations duration. If there is no animation running, the behaviour is undefined.
*/
void finish()
{
value = start_value + delta_value;
time_acc = duration;
}
/*! \brief Lets dt time pass
*
* Advances the animation by dt time units and updates the value accordingly.
*
* \val dt The amount of time to jump forward
*/
void update(float dt)
{
if(duration > 0)
{
time_acc += dt;
if(time_acc > duration)
{
time_acc = duration;
value = start_value + delta_value;
}
else
{
updateValue();
}
}
}
/*! \brief Calculates the value from all other members.
*
* This method gets implemented by all specific easing classes.
*/
virtual void updateValue() = 0;
/*! \brief Starts the animation.
*
* Starts the interpolation from the current value (now) to
* targetValue (in now + _duration).
*
* If the animation is currently running, it gets replaced.
*
* \param targetValue The value to interpolate to
* \param _duration The duration the interpolation should take
*/
void start(float targetValue, float _duration)
{
start_value = value;
delta_value = targetValue - start_value;
time_acc = 0;
duration = _duration;
}
/*! \brief Translates the current value and the target value by delta_value
*
* This method is mainly used for trickery. Suppose there is one object in the
* middle of the screen that should move to the top until it is outside of the
* screen and gets replaced by a second one entering the screen from the lower
* side once the first one disappeared. This method can be used to simulate this
* effect with one animation by translating (i.e. moving) the animation from the
* top to the bottom:
*
* Object1 and object2 are the same object: object1 whose y position is bound to value
* To start the transition, use start(SCREEN_HEIGHT, desired time); Once the first
* object left the screen (i.e. object.y < 0), change objects appearance to object2
* and translate the easing by (SCREEN_HEIGHT).
*
* \param delta_value The change in start_value and value
*/
void translate(float delta_value)
{
start_value += delta_value;
value += delta_value;
}
/*! \brief Returns if the passed time exceeds duration.
*
* If ther is no animation running, it is ensured that this is true.
*/
bool finished()
{
return time_acc >= duration;
}
};
/*! \brief This class defines an easing with quadratic acceleration and decceleration.
*/
class InOutQuadEasing : public Easing
{
public:
/*! \brief Calls Easing::Easing(val).
*
* \see Easing::Easing(float& val)
*/
InOutQuadEasing(float& val): Easing(val) {}
/*! \brief Implements the value calculation.
*
* \see Easing::updateValue()
*/
void updateValue()
{
float time_tmp = (time_acc * 2) / duration;
if (time_tmp < 1)
{
value = (float)(delta_value * 0.5 * time_tmp * time_tmp + start_value);
}
else
{
time_tmp -= 1;
value = (float)(- delta_value * 0.5 * (time_tmp * (time_tmp - 2) - 1) + start_value);
}
}
};
#endif //_EASING_H_
+26 -54
View File
@@ -19,22 +19,7 @@
#include "WGui.h"
#include "InteractiveButton.h"
#define NO_USER_ACTIVITY_HELP_DELAY 10
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
enum
{
STAGE_TRANSITION_RIGHT = 0,
STAGE_TRANSITION_LEFT = 1,
STAGE_WAITING = 2,
STAGE_TRANSITION_UP = 3,
STAGE_TRANSITION_DOWN = 4,
STAGE_ONSCREEN_MENU = 5,
STAGE_WELCOME = 6,
STAGE_MENU = 7,
STAGE_FILTERS = 8,
STAGE_TRANSITION_SELECTED = 9
};
class DeckView;
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
// available options in the duel menu
@@ -44,7 +29,7 @@ enum
MENU_DECK_SELECTION = 10,
MENU_DECK_BUILDER = 11,
MENU_FIRST_DUEL_SUBMENU = 102,
MENU_LANGUAGE_SELECTION = 103,
MENU_LANGUAGE_SELECTION = 103
};
// enums for menu options
@@ -64,79 +49,69 @@ enum DECK_VIEWER_MENU_ITEMS
MENU_ITEM_NO = 21,
MENU_ITEM_FILTER_BY = 22,
MENUITEM_MORE_INFO = kInfoMenuID
};
#define ALL_COLORS -1
#define ROTATE_LEFT 1;
#define ROTATE_RIGHT 0;
#define HIGH_SPEED 15.0
#define MED_SPEED 5.0f
#define LOW_SPEED 1.5
#define MAX_SAVED_FILTERS Constants::NB_Colors + 1
#define CARDS_DISPLAYED 10
class GameStateDeckViewer: public GameState, public JGuiListener
{
private:
enum DeckViewerStages
{
STAGE_WAITING = 0,
STAGE_ONSCREEN_MENU,
STAGE_WELCOME,
STAGE_MENU,
STAGE_FILTERS
};
vector<JQuadPtr> mIcons;
JQuadPtr pspIcons[8];
JTexture * pspIconsTexture;
float last_user_activity;
float onScreenTransition;
float mRotation;
float mSlide;
int mAlpha;
int mStage;
int useFilter;
DeckViewerStages mStage;
JMusic * bgMusic;
int lastPos;
int lastTotal;
int mSelected;
InteractiveButton *toggleDeckButton, *sellCardButton, *statsPrevButton, *filterButton;
InteractiveButton *toggleDeckButton, *sellCardButton, *statsPrevButton, *filterButton, *toggleViewButton;
WGuiFilters * filterMenu;
WSrcDeckViewer * source;
DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu;
DeckEditorMenu * menu;
DeckEditorMenu * deckMenu;
PriceList* pricelist;
PlayerData * playerdata;
int price;
DeckDataWrapper * displayed_deck;
DeckDataWrapper * myDeck;
DeckDataWrapper * myCollection;
MTGCard * cardIndex[CARDS_DISPLAYED];
StatsWrapper *stw;
StatsWrapper * mStatsWrapper;
int hudAlpha;
string newDeckname;
bool isAIDeckSave;
bool mSwitching;
enum AvailableView{
CAROUSEL_VIEW,
GRID_VIEW
};
DeckView* mView;
AvailableView mCurrentView;
void saveDeck(); //Saves the deck and additional necessary information
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
int getCurrentPos();
void sellCard();
void setButtonState(bool state);
bool userPressedButton();
void RenderButtons();
pair<float, float> cardsCoordinates[CARDS_DISPLAYED];
void setupView(AvailableView view, DeckDataWrapper *deck);
void toggleView();
public:
GameStateDeckViewer(GameApp* parent);
virtual ~GameStateDeckViewer();
void updateDecks();
void rotateCards(int direction);
void loadIndexes();
void updateFilters();
void rebuildFilters();
void switchDisplay();
void toggleCollection();
void Start();
virtual void End();
void addRemove(MTGCard * card);
@@ -145,11 +120,8 @@ public:
void renderSlideBar();
void renderDeckBackground();
void renderOnScreenMenu();
virtual void renderCard(int id, float rotation);
virtual void renderCard(int id);
virtual void Render();
int loadDeck(int deckid);
void LoadDeckStatistics(int deckId);
void OnScroll(int inXVelocity, int inYVelocity);
+38
View File
@@ -0,0 +1,38 @@
#ifndef _GRID_DECK_VIEW_H
#define _GRID_DECK_VIEW_H
#include "DeckView.h"
#include "Easing.h"
class GridDeckView : public DeckView
{
private:
static const float scroll_animation_duration;
static const float slide_animation_duration;
static const float card_scale_small;
static const float card_scale_big;
public:
GridDeckView();
virtual ~GridDeckView();
void Reset();
void UpdateViewState(float dt);
void UpdateCardPosition(CardRep &rep, int index);
void Render();
MTGCard * Click(int x, int y);
void changePosition(int offset);
void changeFilter(int offset);
MTGCard *getActiveCard();
private:
int mCols;
int mRows;
float mScrollOffset, mSlideOffset;
InOutQuadEasing mScrollEasing;
InOutQuadEasing mSlideEasing;
int mCurrentSelection;
};
#endif //_GRID_DECK_VIEW_H
+2 -1
View File
@@ -6,8 +6,9 @@
#include <hge/hgeparticle.h>
#include "JGE.h"
#include "MTGDefinitions.h"
#include "GameApp.h"
#include "Pos.h"
#include "GuiLayers.h"
#include "WResource_Fwd.h"
class ManaIcon : public Pos
{
+1
View File
@@ -28,6 +28,7 @@ const int kNextStatsButtonId = 10005;
const int kPrevStatsButtonId = 10006;
const int kCycleCardsButtonId = 10007;
const int kShowCardListButtonId = 10008;
const int kSwitchViewButton = 10009;
class InteractiveButton: public SimpleButton
{
+1 -2
View File
@@ -4,7 +4,6 @@
#define MTG_ERROR -1
#include "MTGDefinitions.h"
#include "GameApp.h"
#include "WResourceManager.h"
#include <dirent.h>
#include <Threading.h>
@@ -138,7 +137,7 @@ public:
static int findType(string subtype, bool forceAdd = true) {
boost::mutex::scoped_lock lock(instance->mMutex);
int result = instance->subtypesList.find(subtype, forceAdd);
int result = instance->subtypesList.find(subtype, forceAdd);
return result;
};
static int add(string value, unsigned int parentType) {
+2 -1
View File
@@ -218,7 +218,8 @@ class Constants
soulbond = 100,
LURE = 101,
NOLEGEND = 102,
NB_BASIC_ABILITIES = 103,
CANPLAYFROMGRAVEYARD = 103,
NB_BASIC_ABILITIES = 104,
RARITY_S = 'S', //Special Rarity
+16
View File
@@ -66,6 +66,7 @@ public:
MTGEventBonus(GameObserver* observer, int _id);
virtual MTGEventBonus * clone() const;
};
class MTGPutInPlayRule: public PermanentAbility
{
public:
@@ -172,6 +173,21 @@ public:
virtual MTGMorphCostRule * clone() const;
};
class MTGPlayFromGraveyardRule: public MTGAlternativeCostRule
{
public:
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const;
MTGPlayFromGraveyardRule(GameObserver* observer, int _id);
const string getMenuText()
{
return "cast card from graveyard";
}
virtual MTGPlayFromGraveyardRule * clone() const;
};
class MTGSuspendRule: public MTGAlternativeCostRule
{
public:
+3
View File
@@ -1,6 +1,9 @@
#ifndef OBJECTANALYTICS_H
#define OBJECTANALYTICS_H
//#include <boost/cstdint.hpp>
#include "JTypes.h"
#ifdef _DEBUG
#define TRACK_OBJECT_USAGE
#endif
-1
View File
@@ -7,7 +7,6 @@
#include <JGui.h>
#include <vector>
#include <string>
#include "GameApp.h"
#include "GameStateOptions.h"
#include "WFilter.h"
#include "WDataSrc.h"
+3 -1
View File
@@ -20,16 +20,18 @@ public:
~PriceList();
int save();
int getSellPrice(int cardid);
int getSellPrice(MTGCard* card);
int getPurchasePrice(int cardid);
int getPrice(MTGCard *card);
int getPrice(int cardId);
int setPrice(int cardId, int price);
int setPrice(MTGCard *card, int price);
int getOtherPrice(int amt);
static float difficultyScalar(float price, int cardid = 0);
static void updateKey()
{
randomKey = rand();
}
;
};
#endif
+2
View File
@@ -3,6 +3,8 @@
#include <vector>
class GameObserver;
// Task type constant
#define TASK_BASIC 'B'
+2
View File
@@ -1,3 +1,5 @@
#include "MTGDeck.h"
#ifndef _WFILTER_H_
#define _WFILTER_H_
/**
+1
View File
@@ -8,6 +8,7 @@
class hgeDistortionMesh;
class GameStateOptions;
class SimpleMenu;
/**
@defgroup WGui Basic Gui
+1
View File
@@ -26,6 +26,7 @@
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <list>
#include "DebugRoutines.h"