Merge branch 'master' into ci_upload_binaries
Fixed Windows compilation.
This commit is contained in:
@@ -136,6 +136,9 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
|
||||
$(MTG_PATH)/src/WFont.cpp \
|
||||
$(MTG_PATH)/src/WGui.cpp \
|
||||
$(MTG_PATH)/src/WResourceManager.cpp \
|
||||
$(MTG_PATH)/src/DeckView.cpp \
|
||||
$(MTG_PATH)/src/CarouselDeckView.cpp \
|
||||
$(MTG_PATH)/src/GridDeckView.cpp \
|
||||
$(JGE_PATH)/src/SDLmain.cpp \
|
||||
$(JGE_PATH)/src/Encoding.cpp \
|
||||
$(JGE_PATH)/src/JAnimator.cpp \
|
||||
|
||||
@@ -27,7 +27,7 @@ OBJS = objs/InteractiveButton.o objs/AbilityParser.o objs/ActionElement.o\
|
||||
objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o\
|
||||
objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o\
|
||||
objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o\
|
||||
objs/WFont.o
|
||||
objs/WFont.o objs/CarouselDeckView.o objs/GridDeckView.o objs/DeckView.o
|
||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||
|
||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||
|
||||
@@ -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
projects/mtg/include/CarouselDeckView.h
Normal file
42
projects/mtg/include/CarouselDeckView.h
Normal 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
projects/mtg/include/DeckView.h
Normal file
63
projects/mtg/include/DeckView.h
Normal 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
projects/mtg/include/Easing.h
Normal file
201
projects/mtg/include/Easing.h
Normal 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_
|
||||
@@ -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
projects/mtg/include/GridDeckView.h
Normal file
38
projects/mtg/include/GridDeckView.h
Normal 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
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#define MTG_ERROR -1
|
||||
|
||||
#include "MTGDefinitions.h"
|
||||
#include "GameApp.h"
|
||||
#include "WResourceManager.h"
|
||||
#include <dirent.h>
|
||||
#include <Threading.h>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef OBJECTANALYTICS_H
|
||||
#define OBJECTANALYTICS_H
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define TRACK_OBJECT_USAGE
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <JGui.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "GameApp.h"
|
||||
#include "GameStateOptions.h"
|
||||
#include "WFilter.h"
|
||||
#include "WDataSrc.h"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class GameObserver;
|
||||
|
||||
// Task type constant
|
||||
|
||||
#define TASK_BASIC 'B'
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "MTGDeck.h"
|
||||
|
||||
#ifndef _WFILTER_H_
|
||||
#define _WFILTER_H_
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
class hgeDistortionMesh;
|
||||
class GameStateOptions;
|
||||
class SimpleMenu;
|
||||
|
||||
/**
|
||||
@defgroup WGui Basic Gui
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
#include <list>
|
||||
|
||||
#include "DebugRoutines.h"
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Counters.h"
|
||||
#include "ModRules.h"
|
||||
#include "CardDescriptor.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
const float CardGui::Width = 28.0;
|
||||
const float CardGui::Height = 40.0;
|
||||
@@ -110,17 +111,17 @@ void CardGui::Update(float dt)
|
||||
PlayGuiObject::Update(dt);
|
||||
}
|
||||
|
||||
void CardGui::DrawCard(const Pos& inPosition, int inMode)
|
||||
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb)
|
||||
{
|
||||
DrawCard(card, inPosition, inMode);
|
||||
DrawCard(card, inPosition, inMode, thumb);
|
||||
}
|
||||
|
||||
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode)
|
||||
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb)
|
||||
{
|
||||
switch (inMode)
|
||||
{
|
||||
case DrawMode::kNormal:
|
||||
RenderBig(inCard, inPosition);
|
||||
RenderBig(inCard, inPosition, thumb);
|
||||
break;
|
||||
case DrawMode::kText:
|
||||
AlternateRender(inCard, inPosition);
|
||||
@@ -957,7 +958,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad)
|
||||
}
|
||||
|
||||
//Renders a big card on screen. Defaults to the "alternate" rendering if no image is found
|
||||
void CardGui::RenderBig(MTGCard* card, const Pos& pos)
|
||||
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb)
|
||||
{
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
//GameObserver * game = GameObserver::GetInstance();
|
||||
@@ -966,7 +967,8 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos)
|
||||
//i want this but ai targets cards so quickly that it can crash the game.
|
||||
float x = pos.actX;
|
||||
|
||||
JQuadPtr quad = WResourceManager::Instance()->RetrieveCard(card);
|
||||
JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB)
|
||||
: WResourceManager::Instance()->RetrieveCard(card);
|
||||
MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card);
|
||||
if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "MTGDeck.h"
|
||||
#include "Subtypes.h"
|
||||
#include "Translate.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
166
projects/mtg/src/CarouselDeckView.cpp
Normal file
166
projects/mtg/src/CarouselDeckView.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
#include "CarouselDeckView.h"
|
||||
|
||||
const float CarouselDeckView::max_scale = 0.96f;
|
||||
const float CarouselDeckView::x_center = 180;
|
||||
const float CarouselDeckView::right_border = SCREEN_WIDTH + 180;
|
||||
const float CarouselDeckView::slide_animation_duration = 0.6f;
|
||||
|
||||
CarouselDeckView::CarouselDeckView() :
|
||||
DeckView(10), mScrollOffset(0), mSlideOffset(0), mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset)
|
||||
{
|
||||
}
|
||||
|
||||
CarouselDeckView::~CarouselDeckView()
|
||||
{}
|
||||
|
||||
void CarouselDeckView::UpdateViewState(float dt)
|
||||
{
|
||||
if(!mScrollEasing.finished())
|
||||
{
|
||||
mScrollEasing.update(dt);
|
||||
|
||||
if(mScrollOffset <= -1.0f)
|
||||
{
|
||||
SwitchPosition(-1);
|
||||
mScrollEasing.translate(1.0f);
|
||||
}
|
||||
else if(mScrollOffset >= 1.0f)
|
||||
{
|
||||
SwitchPosition(1);
|
||||
mScrollEasing.translate(-1.0f);
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
|
||||
if(!mSlideEasing.finished())
|
||||
{
|
||||
mSlideEasing.update(dt);
|
||||
|
||||
if(mSlideOffset < mSlideEasing.start_value)
|
||||
{
|
||||
//going downwards
|
||||
if(mSlideOffset < -1.0f)
|
||||
{
|
||||
mSlideEasing.translate(2.0f);
|
||||
SwitchFilter(1);
|
||||
}
|
||||
}
|
||||
else if(mSlideOffset > mSlideEasing.start_value)
|
||||
{
|
||||
//upwards
|
||||
if(mSlideOffset > 1.0f)
|
||||
{
|
||||
mSlideEasing.translate(-2.0f);
|
||||
SwitchFilter(-1);
|
||||
}
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CarouselDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
{
|
||||
float rotation = mScrollOffset + 8 - index;
|
||||
|
||||
rep.x = x_center + cos((rotation) * M_PI / 12) * (right_border - x_center);
|
||||
rep.scale = max_scale / 1.12f * cos((rep.x - x_center) * 1.5f / (right_border - x_center)) + 0.2f * max_scale * cos(
|
||||
cos((rep.x - x_center) * 0.15f / (right_border - x_center)));
|
||||
rep.y = (SCREEN_HEIGHT_F) / 2.0f + SCREEN_HEIGHT_F * mSlideOffset * (rep.scale + 0.2f);
|
||||
}
|
||||
|
||||
void CarouselDeckView::Reset()
|
||||
{
|
||||
mSlideEasing.finish();
|
||||
mScrollEasing.finish();
|
||||
|
||||
DeckView::Reset();
|
||||
}
|
||||
|
||||
void CarouselDeckView::Render()
|
||||
{
|
||||
// even though we want to draw the cards in a particular z order for layering, we want to prefetch them
|
||||
// in a different order, ie the center card should appear first, then the adjacent ones
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(0).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(3).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(4).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(2).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(5).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(1).card);
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(6).card);
|
||||
}
|
||||
|
||||
renderCard(6);
|
||||
renderCard(5);
|
||||
renderCard(4);
|
||||
renderCard(0);
|
||||
|
||||
if (mScrollOffset < 0.5 && mScrollOffset > -0.5)
|
||||
{
|
||||
renderCard(1);
|
||||
renderCard(3);
|
||||
renderCard(2);
|
||||
}
|
||||
else if (mScrollOffset < -0.5)
|
||||
{
|
||||
renderCard(3);
|
||||
renderCard(2);
|
||||
renderCard(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderCard(1);
|
||||
renderCard(2);
|
||||
renderCard(3);
|
||||
}
|
||||
}
|
||||
|
||||
MTGCard * CarouselDeckView::Click(int x, int y)
|
||||
{
|
||||
int n = getCardIndexNextTo(x, y);
|
||||
last_user_activity = 0;
|
||||
|
||||
//clicked active card, and no animation is running
|
||||
if(mSlideEasing.finished() && mScrollEasing.finished())
|
||||
{
|
||||
if(n == 2)
|
||||
{
|
||||
return getActiveCard();
|
||||
}
|
||||
else
|
||||
{
|
||||
changePosition(n - 2);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changePosition(int offset)
|
||||
{
|
||||
mScrollEasing.start((float)offset, (float)(0.3f*abs(offset)));
|
||||
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changeFilter(int offset)
|
||||
{
|
||||
if(offset < 0)
|
||||
{
|
||||
mSlideEasing.start(-2.0f, slide_animation_duration);
|
||||
}
|
||||
else if(offset > 0)
|
||||
{
|
||||
mSlideEasing.start(2.0f, slide_animation_duration);
|
||||
}
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard *CarouselDeckView::getActiveCard()
|
||||
{
|
||||
return getCardRep(2).card;
|
||||
}
|
||||
|
||||
242
projects/mtg/src/DeckView.cpp
Normal file
242
projects/mtg/src/DeckView.cpp
Normal file
@@ -0,0 +1,242 @@
|
||||
#include "DeckView.h"
|
||||
|
||||
#include "GameOptions.h"
|
||||
#include "CardGui.h"
|
||||
|
||||
const float DeckView::no_user_activity_show_card_delay = 0.1f;
|
||||
|
||||
DeckView::DeckView(int numberOfCards)
|
||||
: dirtyFilters(true), dirtyCardPos(true), last_user_activity(0.0f), mFilter(0), mCurrentDeck(NULL)
|
||||
{
|
||||
mCards.resize(numberOfCards);
|
||||
}
|
||||
|
||||
DeckView::~DeckView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DeckView::Reset()
|
||||
{
|
||||
dirtyFilters = true;
|
||||
dirtyCardPos = true;
|
||||
last_user_activity = 0;
|
||||
mFilter = 0;
|
||||
mCurrentDeck = NULL;
|
||||
}
|
||||
|
||||
void DeckView::Update(float dt)
|
||||
{
|
||||
last_user_activity += dt;
|
||||
|
||||
UpdateViewState(dt);
|
||||
|
||||
if(dirtyCardPos)
|
||||
{
|
||||
for(unsigned int i = 0; i < mCards.size(); ++i)
|
||||
{
|
||||
UpdateCardPosition(mCards[i], i);
|
||||
}
|
||||
dirtyCardPos = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DeckView::ButtonPressed(Buttons button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
changePosition(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
changePosition(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
changeFilter(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
changeFilter(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeckView::SetDeck(DeckDataWrapper *toShow)
|
||||
{
|
||||
mCurrentDeck = toShow;
|
||||
reloadIndexes();
|
||||
}
|
||||
|
||||
DeckDataWrapper* DeckView::deck()
|
||||
{
|
||||
return mCurrentDeck;
|
||||
}
|
||||
|
||||
void DeckView::SwitchFilter(int delta)
|
||||
{
|
||||
unsigned int FilterCount = Constants::NB_Colors + 1;
|
||||
mFilter = (FilterCount + mFilter + delta) % FilterCount;
|
||||
dirtyFilters = true;
|
||||
}
|
||||
|
||||
void DeckView::SwitchPosition(int delta)
|
||||
{
|
||||
for(int i = 0; i < delta; ++i)
|
||||
{
|
||||
mCurrentDeck->next();
|
||||
}
|
||||
|
||||
for(int i = 0; i > delta; --i)
|
||||
{
|
||||
mCurrentDeck->prev();
|
||||
}
|
||||
|
||||
reloadIndexes();
|
||||
}
|
||||
|
||||
int DeckView::filter()
|
||||
{
|
||||
return mFilter;
|
||||
}
|
||||
|
||||
void DeckView::reloadIndexes()
|
||||
{
|
||||
if(mCurrentDeck != NULL)
|
||||
{
|
||||
for (unsigned int i = 0; i < mCards.size(); i++)
|
||||
{
|
||||
mCards[i].card = deck()->getCard(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DeckView::CardRep& DeckView::getCardRep(unsigned int index)
|
||||
{
|
||||
return mCards[index];
|
||||
}
|
||||
|
||||
void DeckView::renderCard(int index, int alpha, bool asThumbnail)
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
|
||||
const CardRep& cardPosition = getCardRep(index);
|
||||
|
||||
if (!cardPosition.card) return;
|
||||
|
||||
if (!WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
JQuadPtr backQuad = WResourceManager::Instance()->GetQuad(kGenericCardID);
|
||||
JQuadPtr quad;
|
||||
|
||||
int cacheError = CACHE_ERROR_NONE;
|
||||
|
||||
if (!options[Options::DISABLECARDS].number)
|
||||
{
|
||||
quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card, RETRIEVE_EXISTING);
|
||||
cacheError = WResourceManager::Instance()->RetrieveError();
|
||||
if (!quad.get() && cacheError != CACHE_ERROR_404)
|
||||
{
|
||||
if (last_user_activity > (abs(2 - index) + 1) * no_user_activity_show_card_delay)
|
||||
quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card);
|
||||
else
|
||||
{
|
||||
quad = backQuad;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (quad.get())
|
||||
{
|
||||
if (quad == backQuad)
|
||||
{
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
float _scale = cardPosition.scale * (285 / quad->mHeight);
|
||||
JRenderer::GetInstance()->RenderQuad(quad.get(), cardPosition.x, cardPosition.y, 0.0f, _scale, _scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, asThumbnail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText, asThumbnail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
|
||||
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, mode, asThumbnail);
|
||||
}
|
||||
|
||||
int quadAlpha = alpha;
|
||||
if (!deck()->count(cardPosition.card)) quadAlpha /= 2;
|
||||
quadAlpha = 255 - quadAlpha;
|
||||
if (quadAlpha > 0)
|
||||
{
|
||||
JRenderer::GetInstance()->FillRect(cardPosition.x - cardPosition.scale * 100.0f, cardPosition.y - cardPosition.scale * 142.5f, cardPosition.scale * 200.0f, cardPosition.scale * 285.0f,
|
||||
ARGB(quadAlpha,0,0,0));
|
||||
}
|
||||
if (last_user_activity < 3)
|
||||
{
|
||||
int fontAlpha = alpha;
|
||||
float qtY = cardPosition.y - 135 * cardPosition.scale;
|
||||
float qtX = cardPosition.x + 40 * cardPosition.scale;
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "x%i", deck()->count(cardPosition.card));
|
||||
WFont * font = mFont;
|
||||
font->SetColor(ARGB(fontAlpha/2,0,0,0));
|
||||
JRenderer::GetInstance()->FillRect(qtX, qtY, font->GetStringWidth(buffer) + 6, 16, ARGB(fontAlpha/2,0,0,0));
|
||||
font->DrawString(buffer, qtX + 4, qtY + 4);
|
||||
font->SetColor(ARGB(fontAlpha,255,255,255));
|
||||
font->DrawString(buffer, qtX + 2, qtY + 2);
|
||||
font->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
}
|
||||
|
||||
int DeckView::getCardIndexNextTo(int x, int y)
|
||||
{
|
||||
int bestCardIndex = -1;
|
||||
float bestDistance = 0;
|
||||
|
||||
for(unsigned int i = 0; i < mCards.size(); i++)
|
||||
{
|
||||
const CardRep& cardPosition = getCardRep(i);
|
||||
|
||||
float dx = (x - cardPosition.x);
|
||||
float dy = (y - cardPosition.y);
|
||||
float dist = dx*dx + dy*dy;
|
||||
|
||||
if(dist < bestDistance || bestCardIndex == -1)
|
||||
{
|
||||
bestDistance = dist;
|
||||
bestCardIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
return bestCardIndex;
|
||||
}
|
||||
|
||||
int DeckView::getPosition()
|
||||
{
|
||||
if(!mCurrentDeck)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int total = mCurrentDeck->Size();
|
||||
int currentPos = (mCurrentDeck->getOffset() + 3) % total;
|
||||
|
||||
while (currentPos <= 0) currentPos += total;
|
||||
return currentPos;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,6 +14,7 @@
|
||||
#include "Translate.h"
|
||||
#include "Rules.h"
|
||||
#include "ModRules.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
#ifdef TESTSUITE
|
||||
#include "TestSuiteAI.h"
|
||||
|
||||
@@ -259,8 +259,8 @@ void GameStateShop::cancelCard(int controlId)
|
||||
break;
|
||||
}
|
||||
price = price - (rnd * price) / 100;
|
||||
if (price < pricelist->getPrice(c->getMTGId())) //filters have a tendancy to increase the price instead of lowering it!
|
||||
pricelist->setPrice(c->getMTGId(), price);
|
||||
if (price < pricelist->getPrice(c)) //filters have a tendancy to increase the price instead of lowering it!
|
||||
pricelist->setPrice(c, price);
|
||||
//Prices do not immediately go down when you ignore something.
|
||||
return;
|
||||
}
|
||||
|
||||
199
projects/mtg/src/GridDeckView.cpp
Normal file
199
projects/mtg/src/GridDeckView.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
#include "GridDeckView.h"
|
||||
|
||||
const float GridDeckView::scroll_animation_duration = 0.3f;
|
||||
const float GridDeckView::slide_animation_duration = 0.6f;
|
||||
const float GridDeckView::card_scale_small = 0.48f;
|
||||
const float GridDeckView::card_scale_big = 0.7f;
|
||||
|
||||
GridDeckView::GridDeckView()
|
||||
: DeckView(16), mCols(8), mRows(2), mScrollOffset(0), mSlideOffset(0),
|
||||
mScrollEasing(mScrollOffset), mSlideEasing(mSlideOffset), mCurrentSelection(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
GridDeckView::~GridDeckView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GridDeckView::Reset()
|
||||
{
|
||||
mSlideEasing.finish();
|
||||
mScrollEasing.finish();
|
||||
|
||||
mCurrentSelection = 0;
|
||||
|
||||
DeckView::Reset();
|
||||
}
|
||||
|
||||
void GridDeckView::UpdateViewState(float dt)
|
||||
{
|
||||
if(!mScrollEasing.finished())
|
||||
{
|
||||
mScrollEasing.update(dt);
|
||||
|
||||
if(mScrollOffset <= -1.0f)
|
||||
{
|
||||
SwitchPosition(2);
|
||||
mScrollEasing.translate(1.0f);
|
||||
mCurrentSelection = (mCurrentSelection >= 6) ? mCurrentSelection - 2 : -1;
|
||||
}
|
||||
else if(mScrollOffset >= 1.0f)
|
||||
{
|
||||
SwitchPosition(-2);
|
||||
mScrollEasing.translate(-1.0f);
|
||||
mCurrentSelection = (mCurrentSelection >= 0 && mCurrentSelection < 10) ? mCurrentSelection + 2 : -1;
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
|
||||
if(!mSlideEasing.finished())
|
||||
{
|
||||
mSlideEasing.update(dt);
|
||||
|
||||
if(mSlideOffset < -1.0f)
|
||||
{
|
||||
mSlideEasing.translate(2.0f);
|
||||
SwitchFilter(1);
|
||||
}
|
||||
else if(mSlideOffset > 1.0f)
|
||||
{
|
||||
mSlideEasing.translate(-2.0f);
|
||||
SwitchFilter(-1);
|
||||
}
|
||||
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GridDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
{
|
||||
int col = index / mRows;
|
||||
int row = index % mRows;
|
||||
float colWidth = SCREEN_WIDTH_F / (mCols - 3);
|
||||
float rowHeight = SCREEN_HEIGHT_F / mRows;
|
||||
|
||||
rep.x = (col + mScrollOffset) * colWidth - colWidth;
|
||||
rep.y = row * rowHeight + mSlideOffset*SCREEN_HEIGHT + rowHeight/2;
|
||||
|
||||
if(mCurrentSelection == index)
|
||||
{
|
||||
rep.scale = card_scale_big;
|
||||
if(row == 0)
|
||||
{
|
||||
rep.y += rowHeight * (card_scale_big - card_scale_small);
|
||||
}
|
||||
else
|
||||
{
|
||||
rep.y -= rowHeight * (card_scale_big - card_scale_small);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rep.scale = card_scale_small;
|
||||
}
|
||||
}
|
||||
|
||||
void GridDeckView::Render()
|
||||
{
|
||||
int firstVisibleCard = 2;
|
||||
int lastVisibleCard = mCards.size() - 2;
|
||||
|
||||
if(!mScrollEasing.finished())
|
||||
{
|
||||
if(mScrollEasing.delta_value > 0){
|
||||
firstVisibleCard = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastVisibleCard = mCards.size();
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = firstVisibleCard; i < lastVisibleCard; ++i)
|
||||
{
|
||||
|
||||
if(mCurrentSelection != i)
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card, RETRIEVE_THUMB);
|
||||
}
|
||||
renderCard(i, 255, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(2 <= mCurrentSelection && mCurrentSelection < 12)
|
||||
{
|
||||
renderCard(mCurrentSelection, 255, false);
|
||||
}
|
||||
}
|
||||
|
||||
MTGCard * GridDeckView::Click(int x, int y)
|
||||
{
|
||||
int n = getCardIndexNextTo(x, y);
|
||||
last_user_activity = 0;
|
||||
|
||||
if(mScrollEasing.finished() && mSlideEasing.finished())
|
||||
{ //clicked and no animations running
|
||||
if(n == mCurrentSelection)
|
||||
{
|
||||
return getActiveCard();
|
||||
}
|
||||
else if(n < 4)
|
||||
{
|
||||
changePosition(-1);
|
||||
}
|
||||
else if(n >= 12)
|
||||
{
|
||||
changePosition(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentSelection = n;
|
||||
dirtyCardPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GridDeckView::changePosition(int offset)
|
||||
{
|
||||
mScrollEasing.start(-1.0f * offset, scroll_animation_duration * abs(offset));
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void GridDeckView::changeFilter(int offset)
|
||||
{
|
||||
if(offset < 0)
|
||||
{
|
||||
mSlideEasing.start(-2.0f, slide_animation_duration);
|
||||
}
|
||||
else if(offset > 0)
|
||||
{
|
||||
mSlideEasing.start(2.0f, slide_animation_duration);
|
||||
}
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard* GridDeckView::getActiveCard()
|
||||
{
|
||||
if(mCurrentSelection >= 0 && mCurrentSelection < int(mCards.size()))
|
||||
{
|
||||
return mCards[mCurrentSelection].card;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "GuiMana.h"
|
||||
#include "OptionItem.h"
|
||||
#include "Player.h"
|
||||
#include "GameApp.h"
|
||||
|
||||
//using std::cout;
|
||||
using std::endl;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "TranslateKeys.h"
|
||||
#include "StyleManager.h"
|
||||
#include <dirent.h>
|
||||
#include "SimpleMenu.h"
|
||||
|
||||
//OptionItem
|
||||
OptionItem::OptionItem(int _id, string _displayValue) :
|
||||
|
||||
@@ -47,12 +47,12 @@ int PriceList::save()
|
||||
|
||||
return 1;
|
||||
}
|
||||
int PriceList::getPrice(int cardId)
|
||||
int PriceList::getPrice(MTGCard * card)
|
||||
{
|
||||
map<int, int>::iterator it = prices.find(cardId);
|
||||
map<int, int>::iterator it = prices.find(card->getId());
|
||||
if (it != prices.end()) return (*it).second;
|
||||
|
||||
char rarity = collection->getCardById(cardId)->getRarity();
|
||||
char rarity = card->getRarity();
|
||||
switch (rarity)
|
||||
{
|
||||
case Constants::RARITY_M:
|
||||
@@ -77,7 +77,11 @@ int PriceList::getPrice(int cardId)
|
||||
return Constants::PRICE_1C;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int PriceList::getPrice(int cardId)
|
||||
{
|
||||
return getPrice(collection->getCardById(cardId));
|
||||
}
|
||||
|
||||
int PriceList::setPrice(int cardId, int price)
|
||||
@@ -85,10 +89,23 @@ int PriceList::setPrice(int cardId, int price)
|
||||
prices[cardId] = price;
|
||||
return price;
|
||||
}
|
||||
|
||||
int PriceList::setPrice(MTGCard * card, int price)
|
||||
{
|
||||
prices[card->getId()] = price;
|
||||
return price;
|
||||
}
|
||||
|
||||
int PriceList::getSellPrice(int cardid)
|
||||
{
|
||||
return getPrice(cardid);
|
||||
return getPrice(collection->getCardById(cardid));
|
||||
}
|
||||
|
||||
int PriceList::getSellPrice(MTGCard *card)
|
||||
{
|
||||
return getPrice(card);
|
||||
}
|
||||
|
||||
float PriceList::difficultyScalar(float price, int cardid)
|
||||
{
|
||||
float badluck = (float) (abs(cardid + randomKey) % 201) / 100; //Float between 0 and 2.
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Player.h"
|
||||
#include "AIMomirPlayer.h"
|
||||
|
||||
#include "GameApp.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "MTGAbility.h"
|
||||
#include "AllAbilities.h"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "PlayerData.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "WFont.h"
|
||||
#include "GameApp.h"
|
||||
#include <JFileSystem.h>
|
||||
|
||||
#define LINE_SPACE 2
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include "Subtypes.h"
|
||||
#include "TranslateKeys.h"
|
||||
#include <hge/hgedistort.h>
|
||||
#include "SimpleMenu.h"
|
||||
#include "Pos.h"
|
||||
#include "CardGui.h"
|
||||
|
||||
/**
|
||||
Provides an interface to retrieve some standardized colors. The idea here is that a child of WGuiBase
|
||||
|
||||
@@ -318,6 +318,12 @@
|
||||
<ClCompile Include="src\CardPrimitive.cpp" />
|
||||
<ClCompile Include="src\CardSelector.cpp" />
|
||||
<ClCompile Include="src\CardSelectorSingleton.cpp" />
|
||||
<ClCompile Include="src\CarouselDeckView.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='HQ Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Counters.cpp" />
|
||||
<ClCompile Include="src\Credits.cpp" />
|
||||
<ClCompile Include="src\Damage.cpp" />
|
||||
@@ -329,6 +335,12 @@
|
||||
<ClCompile Include="src\DeckMenuItem.cpp" />
|
||||
<ClCompile Include="src\DeckMetaData.cpp" />
|
||||
<ClCompile Include="src\DeckStats.cpp" />
|
||||
<ClCompile Include="src\DeckView.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='HQ Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DuelLayers.cpp" />
|
||||
<ClCompile Include="src\ExtraCost.cpp" />
|
||||
<ClCompile Include="src\GameApp.cpp">
|
||||
@@ -362,6 +374,12 @@
|
||||
<ClCompile Include="src\GameStateShop.cpp" />
|
||||
<ClCompile Include="src\GameStateStory.cpp" />
|
||||
<ClCompile Include="src\GameStateTransitions.cpp" />
|
||||
<ClCompile Include="src\GridDeckView.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='HQ Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GuiAvatars.cpp" />
|
||||
<ClCompile Include="src\GuiBackground.cpp" />
|
||||
<ClCompile Include="src\GuiCardsController.cpp" />
|
||||
@@ -459,6 +477,7 @@
|
||||
<ClInclude Include="include\CardPrimitive.h" />
|
||||
<ClInclude Include="include\CardSelector.h" />
|
||||
<ClInclude Include="include\CardSelectorSingleton.h" />
|
||||
<ClInclude Include="include\CarouselDeckView.h" />
|
||||
<ClInclude Include="include\config.h" />
|
||||
<ClInclude Include="include\Counters.h" />
|
||||
<ClInclude Include="include\Credits.h" />
|
||||
@@ -471,7 +490,9 @@
|
||||
<ClInclude Include="include\DeckMenuItem.h" />
|
||||
<ClInclude Include="include\DeckMetaData.h" />
|
||||
<ClInclude Include="include\DeckStats.h" />
|
||||
<ClInclude Include="include\DeckView.h" />
|
||||
<ClInclude Include="include\DuelLayers.h" />
|
||||
<ClInclude Include="include\Easing.h" />
|
||||
<ClInclude Include="include\Effects.h" />
|
||||
<ClInclude Include="include\ExtraCost.h" />
|
||||
<ClInclude Include="include\GameApp.h" />
|
||||
@@ -486,6 +507,7 @@
|
||||
<ClInclude Include="include\GameStateShop.h" />
|
||||
<ClInclude Include="include\GameStateStory.h" />
|
||||
<ClInclude Include="include\GameStateTransitions.h" />
|
||||
<ClInclude Include="include\GridDeckView.h" />
|
||||
<ClInclude Include="include\GuiAvatars.h" />
|
||||
<ClInclude Include="include\GuiBackground.h" />
|
||||
<ClInclude Include="include\GuiCardsController.h" />
|
||||
|
||||
@@ -331,6 +331,15 @@
|
||||
<ClCompile Include="src\NetworkPlayer.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CarouselDeckView.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\DeckView.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GridDeckView.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\ActionElement.h">
|
||||
@@ -681,6 +690,18 @@
|
||||
<ClInclude Include="include\NetworkPlayer.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\CarouselDeckView.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\DeckView.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Easing.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GridDeckView.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Makefile" />
|
||||
|
||||
@@ -9,7 +9,7 @@ DEFINES += SDL_CONFIG
|
||||
#
|
||||
QT -= core gui opengl network declarative
|
||||
|
||||
unix|windows:QMAKE_CXXFLAGS += -std=c++11
|
||||
#unix|windows:QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
INCLUDEPATH += ../../JGE/Dependencies/SDL/include
|
||||
unix:INCLUDEPATH += /usr/include/GL
|
||||
|
||||
@@ -49,9 +49,13 @@ CONFIG(graphics, graphics|console){
|
||||
../../JGE/src/pc/JGfx.cpp
|
||||
}
|
||||
else:CONFIG(console, graphics|console){
|
||||
HEADERS += \
|
||||
../../JGE/include/OutputCapturer.h
|
||||
|
||||
SOURCES += \
|
||||
../../JGE/src/OutputCapturer.cpp\
|
||||
../../JGE/src/JGfx-fake.cpp\
|
||||
../../JGE/src/Qtconsole.cpp
|
||||
../../JGE/src/Qtconsole.cpp\
|
||||
}
|
||||
|
||||
# maemo 5 packaging
|
||||
|
||||
@@ -64,6 +64,7 @@ SOURCES += \
|
||||
src/CardGui.cpp\
|
||||
src/CardPrimitive.cpp\
|
||||
src/CardSelector.cpp\
|
||||
src/CarouselDeckView.cpp\
|
||||
src/Closest.cpp\
|
||||
src/Counters.cpp\
|
||||
src/Credits.cpp\
|
||||
@@ -76,6 +77,7 @@ SOURCES += \
|
||||
src/DeckMenuItem.cpp\
|
||||
src/DeckMetaData.cpp\
|
||||
src/DeckStats.cpp\
|
||||
src/DeckView.cpp\
|
||||
src/DuelLayers.cpp\
|
||||
src/Effects.cpp\
|
||||
src/ExtraCost.cpp\
|
||||
@@ -92,6 +94,7 @@ SOURCES += \
|
||||
src/GameStateShop.cpp\
|
||||
src/GameStateStory.cpp\
|
||||
src/GameStateTransitions.cpp\
|
||||
src/GridDeckView.cpp\
|
||||
src/GuiAvatars.cpp\
|
||||
src/GuiBackground.cpp\
|
||||
src/GuiCardsController.cpp\
|
||||
@@ -159,6 +162,10 @@ SOURCES += \
|
||||
src/TestSuiteAI.cpp
|
||||
|
||||
HEADERS += \
|
||||
include/CarouselDeckView.h\
|
||||
include/DeckView.h\
|
||||
include/Easing.h\
|
||||
include/GridDeckView.h\
|
||||
include/CacheEngine.h\
|
||||
include/AllAbilities.h\
|
||||
include/AbilityParser.h\
|
||||
@@ -296,7 +303,6 @@ SOURCES += \
|
||||
../../JGE/src/pc/JSocket.cpp\
|
||||
../../JGE/src/pc/JSfx.cpp\
|
||||
../../JGE/src/JSprite.cpp\
|
||||
../../JGE/src/OutputCapturer.cpp\
|
||||
../../JGE/src/Vector2D.cpp\
|
||||
../../JGE/src/tinyxml/tinystr.cpp\
|
||||
../../JGE/src/tinyxml/tinyxml.cpp\
|
||||
@@ -344,7 +350,6 @@ HEADERS += \
|
||||
../../JGE/include/JSpline.h\
|
||||
../../JGE/include/JSprite.h\
|
||||
../../JGE/include/JTypes.h\
|
||||
../../JGE/include/OutputCapturer.h\
|
||||
../../JGE/include/Vector2D.h\
|
||||
../../JGE/include/Vector3D.h\
|
||||
../../JGE/include/vram.h\
|
||||
|
||||
Reference in New Issue
Block a user