New descriptive text popup feature for deck selection

http://wololo.net/forum/viewtopic.php?f=13&t=2423
This commit is contained in:
techdragon.nguyen@gmail.com
2010-11-18 15:48:48 +00:00
parent f7bcbb42dc
commit 2a8f8074e6
17 changed files with 5715 additions and 5198 deletions

View File

@@ -1,123 +1,124 @@
//-------------------------------------------------------------------------------------
//
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//-------------------------------------------------------------------------------------
#ifndef _JGUI_H
#define _JGUI_H
#include <ostream>
#include "JGE.h"
#include "JSprite.h"
#define MAX_GUIOBJECT 64
#define JGUI_STYLE_LEFTRIGHT 0x01
#define JGUI_STYLE_UPDOWN 0x02
#define JGUI_STYLE_WRAPPING 0x04
#define JGUI_INITIAL_DELAY 0.4
#define JGUI_REPEAT_DELAY 0.2
const int kCancelMenuID = -1;
class JGuiListener
{
public:
virtual ~JGuiListener() {}
virtual void ButtonPressed(int controllerId, int controlId) = 0;
};
class JGuiObject
{
protected:
static JGE* mEngine;
private:
int mId;
public:
JGuiObject(int id);
virtual ~JGuiObject();
virtual void Render() = 0;
virtual std::ostream& toString(std::ostream&) const = 0;
virtual void Update(float dt);
virtual void Entering(); // when focus is transferring to this obj
virtual bool Leaving(JButton key); // when focus is transferring away from this obj, true to go ahead
virtual bool ButtonPressed(); // action button pressed, return false to ignore
// Used for mouse support so that the GUI engine can found out which Object was selected
virtual bool getTopLeft(int& top, int& left) {return false;};
int GetId();
};
class JGuiController
{
protected:
static JGE* mEngine;
int mId;
bool mActive;
JButton mActionButton;
JButton mCancelButton;
int mCurr;
int mStyle;
JSprite* mCursor;
bool mShowCursor;
int mCursorX;
int mCursorY;
int mBgX;
int mBgY;
const JTexture* mBg;
PIXEL_TYPE mShadingColor;
Rect* mShadingBg;
JGuiListener* mListener;
//int mKeyHoldTime;
public:
vector<JGuiObject*> mObjects;
int mCount;
JGuiController(int id, JGuiListener* listener);
~JGuiController();
virtual void Render();
virtual void Update(float dt);
virtual bool CheckUserInput(JButton key);
void Add(JGuiObject* ctrl);
void RemoveAt(int i);
void Remove(int id);
void Remove(JGuiObject* ctrl);
void SetActionButton(JButton button);
void SetStyle(int style);
void SetCursor(JSprite* cursor);
bool IsActive();
void SetActive(bool flag);
//void SetImageBackground(const JTexture* tex, int x, int y);
//void SetShadingBackground(int x, int y, int width, int height, PIXEL_TYPE color);
};
ostream& operator<<(ostream &out, const JGuiObject &j);
#endif
//-------------------------------------------------------------------------------------
//
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//-------------------------------------------------------------------------------------
#ifndef _JGUI_H
#define _JGUI_H
#include <ostream>
#include "JGE.h"
#include "JSprite.h"
#define MAX_GUIOBJECT 64
#define JGUI_STYLE_LEFTRIGHT 0x01
#define JGUI_STYLE_UPDOWN 0x02
#define JGUI_STYLE_WRAPPING 0x04
#define JGUI_INITIAL_DELAY 0.4
#define JGUI_REPEAT_DELAY 0.2
const int kCancelMenuID = -1;
const int kInfoMenuID = -200;
class JGuiListener
{
public:
virtual ~JGuiListener()
{
}
virtual void ButtonPressed(int controllerId, int controlId) = 0;
};
class JGuiObject
{
protected:
static JGE* mEngine;
private:
int mId;
public:
JGuiObject(int id);
virtual ~JGuiObject();
virtual void Render() = 0;
virtual std::ostream& toString(std::ostream&) const = 0;
virtual void Update(float dt);
virtual void Entering(); // when focus is transferring to this obj
virtual bool Leaving(JButton key); // when focus is transferring away from this obj, true to go ahead
virtual bool ButtonPressed(); // action button pressed, return false to ignore
// Used for mouse support so that the GUI engine can found out which Object was selected
virtual bool getTopLeft(int& top, int& left)
{
return false;
}
;
int GetId();
};
class JGuiController
{
protected:
static JGE* mEngine;
int mId;
bool mActive;
JButton mActionButton;
JButton mCancelButton;
int mCurr;
int mStyle;
JSprite* mCursor;
bool mShowCursor;
int mCursorX;
int mCursorY;
int mBgX;
int mBgY;
const JTexture* mBg;
PIXEL_TYPE mShadingColor;
Rect* mShadingBg;
JGuiListener* mListener;
//int mKeyHoldTime;
public:
vector<JGuiObject*> mObjects;
int mCount;
JGuiController(int id, JGuiListener* listener);
~JGuiController();
virtual void Render();
virtual void Update(float dt);
virtual bool CheckUserInput(JButton key);
void Add(JGuiObject* ctrl);
void RemoveAt(int i);
void Remove(int id);
void Remove(JGuiObject* ctrl);
void SetActionButton(JButton button);
void SetStyle(int style);
void SetCursor(JSprite* cursor);
bool IsActive();
void SetActive(bool flag);
};
ostream& operator<<(ostream &out, const JGuiObject &j);
#endif

View File

@@ -1,247 +1,256 @@
//-------------------------------------------------------------------------------------
//
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//-------------------------------------------------------------------------------------
#include "../include/JGE.h"
#include "../include/JGui.h"
JGE* JGuiObject::mEngine = NULL;
JGE* JGuiController::mEngine = NULL;
JGuiObject::JGuiObject(int id): mId(id)
{
mEngine = JGE::GetInstance();
}
JGuiObject::~JGuiObject()
{
// JGERelease();
}
bool JGuiObject::Leaving(JButton key __attribute__((unused)))
{
return true;
}
bool JGuiObject::ButtonPressed()
{
return false;
}
void JGuiObject::Entering()
{
}
int JGuiObject::GetId()
{
return mId;
}
void JGuiObject::Update(float dt __attribute__((unused)))
{
}
ostream& operator<<(ostream &out, const JGuiObject &j)
{
return j.toString(out);
}
JGuiController::JGuiController(int id, JGuiListener* listener) : mId(id), mListener(listener)
{
mEngine = JGE::GetInstance();
mBg = NULL;
mShadingBg = NULL;
mCount = 0;
mCurr = 0;
mCursorX = SCREEN_WIDTH/2;
mCursorY = SCREEN_HEIGHT/2;
mShowCursor = false;
mActionButton = JGE_BTN_OK;
mCancelButton = JGE_BTN_MENU;
mStyle = JGUI_STYLE_WRAPPING;
mActive = true;
}
JGuiController::~JGuiController()
{
for (int i=0;i<mCount;i++)
if (mObjects[i]!=NULL)
delete mObjects[i];
}
void JGuiController::Render()
{
for (int i=0;i<mCount;i++)
if (mObjects[i]!=NULL)
mObjects[i]->Render();
}
bool JGuiController::CheckUserInput(JButton key){
if (!mCount) return false;
if (key == mActionButton)
{
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
{
if (mListener != NULL)
mListener->ButtonPressed(mId, mObjects[mCurr]->GetId());
return true;
}
}
else if (key == mCancelButton)
{
if (mListener != NULL)
{
mListener->ButtonPressed(mId, kCancelMenuID);
}
}
else if ((JGE_BTN_LEFT == key) || (JGE_BTN_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
{
int n = mCurr;
n--;
if (n<0)
{
if ((mStyle&JGUI_STYLE_WRAPPING))
n = mCount-1;
else
n = 0;
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_UP))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
else if ((JGE_BTN_RIGHT == key) || (JGE_BTN_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
{
int n = mCurr;
n++;
if (n>mCount-1)
{
if ((mStyle&JGUI_STYLE_WRAPPING))
n = 0;
else
n = mCount-1;
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
else
{ // a dude may have clicked somewhere, we're gonna select the closest object from where he clicked
int x, y;
unsigned int distance2;
unsigned int minDistance2 = -1;
int n = mCurr;
if(mEngine->GetLeftClickCoordinates(x, y))
{
for(int i = 0; i < mCount; i++)
{
int top, left;
if(mObjects[i]->getTopLeft(top, left))
{
distance2 = (top-y)*(top-y) + (left-x)*(left-x);
if(distance2 < minDistance2)
{
minDistance2 = distance2;
n = i;
}
}
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
mEngine->LeftClickedProcessed();
return true;
}
}
return false;
}
void JGuiController::Update(float dt)
{
for (int i=0;i<mCount;i++)
if (mObjects[i]!=NULL)
mObjects[i]->Update(dt);
JButton key = mEngine->ReadButton();
CheckUserInput(key);
}
void JGuiController::Add(JGuiObject* ctrl)
{
mObjects.push_back(ctrl);
mCount++;
}
void JGuiController::RemoveAt(int i){
if (!mObjects[i]) return;
mObjects.erase(mObjects.begin()+i);
delete mObjects[i];
mCount--;
if (mCurr == mCount)
mCurr = 0;
return;
}
void JGuiController::Remove(int id)
{
for (int i=0;i<mCount;i++)
{
if (mObjects[i] != NULL && mObjects[i]->GetId()==id) {
RemoveAt(i);
return;
}
}
}
void JGuiController::Remove(JGuiObject* ctrl)
{
for (int i=0;i<mCount;i++)
{
if (mObjects[i] != NULL && mObjects[i]==ctrl) {
RemoveAt(i);
return;
}
}
}
void JGuiController::SetActionButton(JButton button) { mActionButton = button; }
void JGuiController::SetStyle(int style) { mStyle = style; }
void JGuiController::SetCursor(JSprite* cursor) { mCursor = cursor; }
bool JGuiController::IsActive() { return mActive; }
void JGuiController::SetActive(bool flag) { mActive = flag; }
//-------------------------------------------------------------------------------------
//
// JGE++ is a hardware accelerated 2D game SDK for PSP/Windows.
//
// Licensed under the BSD license, see LICENSE in JGE root for details.
//
// Copyright (c) 2007 James Hui (a.k.a. Dr.Watson) <jhkhui@gmail.com>
//
//-------------------------------------------------------------------------------------
#include "../include/JGE.h"
#include "../include/JGui.h"
JGE* JGuiObject::mEngine = NULL;
JGE* JGuiController::mEngine = NULL;
JGuiObject::JGuiObject(int id) :
mId(id)
{
mEngine = JGE::GetInstance();
}
JGuiObject::~JGuiObject()
{
// JGERelease();
}
bool JGuiObject::Leaving(JButton key __attribute__((unused)))
{
return true;
}
bool JGuiObject::ButtonPressed()
{
return false;
}
void JGuiObject::Entering()
{
}
int JGuiObject::GetId()
{
return mId;
}
void JGuiObject::Update(float dt __attribute__((unused)))
{
}
ostream& operator<<(ostream &out, const JGuiObject &j)
{
return j.toString(out);
}
JGuiController::JGuiController(int id, JGuiListener* listener) :
mId(id), mListener(listener)
{
mEngine = JGE::GetInstance();
mBg = NULL;
mShadingBg = NULL;
mCount = 0;
mCurr = 0;
mCursorX = SCREEN_WIDTH / 2;
mCursorY = SCREEN_HEIGHT / 2;
mShowCursor = false;
mActionButton = JGE_BTN_OK;
mCancelButton = JGE_BTN_MENU;
mStyle = JGUI_STYLE_WRAPPING;
mActive = true;
}
JGuiController::~JGuiController()
{
for (int i = 0; i < mCount; i++)
if (mObjects[i] != NULL) delete mObjects[i];
}
void JGuiController::Render()
{
for (int i = 0; i < mCount; i++)
if (mObjects[i] != NULL) mObjects[i]->Render();
}
bool JGuiController::CheckUserInput(JButton key)
{
if (!mCount) return false;
if (key == mActionButton)
{
if (!mObjects.empty() && mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
{
if (mListener != NULL) mListener->ButtonPressed(mId, mObjects[mCurr]->GetId());
return true;
}
}
else if (key == mCancelButton)
{
if (mListener != NULL)
{
mListener->ButtonPressed(mId, kCancelMenuID);
}
}
else if (JGE_BTN_CANCEL == key)
{
if (mListener != NULL) mListener->ButtonPressed(mId, kInfoMenuID);
}
else if ((JGE_BTN_LEFT == key) || (JGE_BTN_UP == key)) // || mEngine->GetAnalogY() < 64 || mEngine->GetAnalogX() < 64)
{
int n = mCurr;
n--;
if (n < 0)
{
if ((mStyle & JGUI_STYLE_WRAPPING))
n = mCount - 1;
else
n = 0;
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_UP))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
else if ((JGE_BTN_RIGHT == key) || (JGE_BTN_DOWN == key)) // || mEngine->GetAnalogY()>192 || mEngine->GetAnalogX()>192)
{
int n = mCurr;
n++;
if (n > mCount - 1)
{
if ((mStyle & JGUI_STYLE_WRAPPING))
n = 0;
else
n = mCount - 1;
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
else
{ // a dude may have clicked somewhere, we're gonna select the closest object from where he clicked
int x, y;
unsigned int distance2;
unsigned int minDistance2 = -1;
int n = mCurr;
if (mEngine->GetLeftClickCoordinates(x, y))
{
for (int i = 0; i < mCount; i++)
{
int top, left;
if (mObjects[i]->getTopLeft(top, left))
{
distance2 = (top - y) * (top - y) + (left - x) * (left - x);
if (distance2 < minDistance2)
{
minDistance2 = distance2;
n = i;
}
}
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
mEngine->LeftClickedProcessed();
return true;
}
}
return false;
}
void JGuiController::Update(float dt)
{
for (int i = 0; i < mCount; i++)
if (mObjects[i] != NULL) mObjects[i]->Update(dt);
JButton key = mEngine->ReadButton();
CheckUserInput(key);
}
void JGuiController::Add(JGuiObject* ctrl)
{
mObjects.push_back(ctrl);
mCount++;
}
void JGuiController::RemoveAt(int i)
{
if (!mObjects[i]) return;
mObjects.erase(mObjects.begin() + i);
delete mObjects[i];
mCount--;
if (mCurr == mCount) mCurr = 0;
return;
}
void JGuiController::Remove(int id)
{
for (int i = 0; i < mCount; i++)
{
if (mObjects[i] != NULL && mObjects[i]->GetId() == id)
{
RemoveAt(i);
return;
}
}
}
void JGuiController::Remove(JGuiObject* ctrl)
{
for (int i = 0; i < mCount; i++)
{
if (mObjects[i] != NULL && mObjects[i] == ctrl)
{
RemoveAt(i);
return;
}
}
}
void JGuiController::SetActionButton(JButton button)
{
mActionButton = button;
}
void JGuiController::SetStyle(int style)
{
mStyle = style;
}
void JGuiController::SetCursor(JSprite* cursor)
{
mCursor = cursor;
}
bool JGuiController::IsActive()
{
return mActive;
}
void JGuiController::SetActive(bool flag)
{
mActive = flag;
}

View File

@@ -1,4 +1,4 @@
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/AllAbilities.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/CardSelectorSingleton.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckEditorMenu.o objs/DeckMenu.o objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateStory.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.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/MTGPack.o objs/MTGRules.o objs/Navigator.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PrecompiledHeader.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/StoryFlow.o objs/StyleManager.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.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 = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/AllAbilities.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/CardSelectorSingleton.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckEditorMenu.o objs/DeckMenu.o objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateStory.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.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/MTGPack.o objs/MTGRules.o objs/Navigator.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PrecompiledHeader.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/SimplePopup.o objs/StoryFlow.o objs/StyleManager.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.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
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)

View File

@@ -1,63 +1,75 @@
/*
A class for very simple menus structure
*/
#ifndef _DeckMenu_H_
#define _DeckMenu_H_
#include <string>
#include "WFont.h"
#include "hge/hgeparticle.h"
#include "DeckMetaData.h"
#include "TextScroller.h"
class DeckMenu:public JGuiController{
protected:
float mHeight, mWidth, mX, mY;
float titleX, titleY, titleWidth;
float descX, descY, descHeight, descWidth;
float statsX, statsY, statsHeight, statsWidth;
float avatarX, avatarY;
float starsOffsetX;
bool menuInitialized;
string backgroundName;
int fontId;
string title;
string displayTitle;
WFont * mFont;
float menuFontScale;
float titleFontScale;
int maxItems, startId;
float selectionT, selectionY;
float timeOpen;
static hgeParticleSystem* stars;
void initMenuItems();
string getDescription();
string getMetaInformation();
public:
TextScroller * scroller;
bool autoTranslate;
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const float& mFontScale = 1.0f );
~DeckMenu();
void Render();
void Update(float dt);
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
void Close();
void updateScroller();
void RenderBackground();
float selectionTargetY;
bool closed;
static void destroy();
};
#endif
/*
A class for menus with a fixed layout
*/
#ifndef _DeckMenu_H_
#define _DeckMenu_H_
#include <string>
#include "WFont.h"
#include "hge/hgeparticle.h"
#include "DeckMetaData.h"
#include "TextScroller.h"
class DeckMenu: public JGuiController
{
protected:
float mHeight, mWidth, mX, mY;
float titleX, titleY, titleWidth;
float descX, descY, descHeight, descWidth;
float statsX, statsY, statsHeight, statsWidth;
float avatarX, avatarY;
float detailedInfoBoxX, detailedInfoBoxY;
float starsOffsetX;
bool menuInitialized;
string backgroundName;
int fontId;
string title;
string displayTitle;
WFont * mFont;
float menuFontScale;
float titleFontScale;
int maxItems, startId;
float selectionT, selectionY;
float timeOpen;
static hgeParticleSystem* stars;
void initMenuItems();
string getDescription();
string getMetaInformation();
DeckMetaData *selectedDeck;
public:
TextScroller * scroller;
bool autoTranslate;
//used for detailed info button
JQuad * pspIcons[8];
JTexture * pspIconsTexture;
DeckMetaData * getSelectedDeck();
bool selectedDeckHasDetails();
int selectedDeckId;
bool showDetailsScreen;
bool enableDetails;
float selectionTargetY;
bool closed;
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, const float& mFontScale = 1.0f);
~DeckMenu();
void Render();
void Update(float dt);
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
void Close();
void updateScroller();
void RenderBackground();
static void destroy();
};
#endif

View File

@@ -1,89 +1,101 @@
#ifndef _DECKSTATS_H_
#define _DECKSTATS_H_
#include <map>
#include <string>
#include <vector>
#include "MTGDefinitions.h"
#include <DeckDataWrapper.h>
using namespace std;
class Player;
class GameObserver;
class DeckStat{
class DeckStat
{
public:
int nbgames;
int victories;
DeckStat(int _nbgames = 0 , int _victories = 0):nbgames(_nbgames),victories(_victories){};
int percentVictories();
int nbgames;
int victories;
DeckStat(int _nbgames = 0, int _victories = 0);
int percentVictories();
};
class DeckStats{
class DeckStats
{
protected:
static DeckStats * mInstance;
static DeckStats * mInstance;
public:
map<string, DeckStat *>stats;
static DeckStats * GetInstance();
void saveStats(Player * player, Player * opponent, GameObserver * game);
void save(const char * filename);
void save(Player * player);
void load(const char * filename);
void load(Player * player);
void cleanStats();
~DeckStats();
int percentVictories(string opponentsDeckFile);
int percentVictories();
DeckStat * getDeckStat(string opponentsFile);
int nbGames();
map<string, DeckStat *> stats;
static DeckStats * GetInstance();
void saveStats(Player * player, Player * opponent, GameObserver * game);
void save(const char * filename);
void save(Player * player);
void load(const char * filename);
void load(Player * player);
void cleanStats();
~DeckStats();
int percentVictories(string opponentsDeckFile);
int percentVictories();
DeckStat * getDeckStat(string opponentsFile);
int nbGames();
};
class StatsWrapper
{
class StatsWrapper {
public:
StatsWrapper( int deckId );
~StatsWrapper();
// Stats parameters and status
int currentPage;
int pageCount;
bool needUpdate;
// Actual stats
int percentVictories;
int gamesPlayed;
int cardCount;
int countLands;
int totalPrice;
int totalManaCost;
float avgManaCost;
int totalCreatureCost;
float avgCreatureCost;
int totalSpellCost;
float avgSpellCost;
int countManaProducers;
int countCreatures, countSpells, countInstants, countEnchantments, countSorceries, countArtifacts;
float noLandsProbInTurn[Constants::STATS_FOR_TURNS];
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS];
int countCardsPerCost[Constants::STATS_MAX_MANA_COST+1];
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST+1][Constants::MTG_NB_COLORS+1];
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST+1];
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST+1][Constants::MTG_NB_COLORS+1];
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST+1];
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST+1][Constants::MTG_NB_COLORS+1];
int countLandsPerColor[Constants::MTG_NB_COLORS+1];
int countBasicLandsPerColor[Constants::MTG_NB_COLORS+1];
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS+1];
int totalCostPerColor[Constants::MTG_NB_COLORS+1];
int totalColoredSymbols;
vector<string> aiDeckNames;
vector<DeckStat*> aiDeckStats;
};
public:
StatsWrapper(int deckId);
StatsWrapper(string filename);
~StatsWrapper();
void initStatistics(string deckstats);
// Stats parameters and status
int mDeckId;
int currentPage;
int pageCount;
bool needUpdate;
// Actual stats
int percentVictories;
int gamesPlayed;
int cardCount;
int countLands;
int totalPrice;
int totalManaCost;
float avgManaCost;
int totalCreatureCost;
float avgCreatureCost;
int totalSpellCost;
float avgSpellCost;
int countManaProducers;
int countCreatures, countSpells, countInstants, countEnchantments, countSorceries, countArtifacts;
float noLandsProbInTurn[Constants::STATS_FOR_TURNS];
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS];
int countCardsPerCost[Constants::STATS_MAX_MANA_COST + 1];
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST + 1];
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST + 1];
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
int countLandsPerColor[Constants::MTG_NB_COLORS + 1];
int countBasicLandsPerColor[Constants::MTG_NB_COLORS + 1];
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS + 1];
int totalCostPerColor[Constants::MTG_NB_COLORS + 1];
int totalColoredSymbols;
void updateStats(string filename, MTGAllCards * collection);
void updateStats(DeckDataWrapper *mtgDeck);
int countCardsByType(const char * _type, DeckDataWrapper * myDeck);
float noLuck(int n, int a, int x);
vector<string> aiDeckNames;
vector<DeckStat*> aiDeckStats;
};
#endif

View File

@@ -1,157 +1,156 @@
#ifndef _GAME_STATE_DECK_VIEWER_H_
#define _GAME_STATE_DECK_VIEWER_H_
#include <math.h>
#include <iostream>
#include <JGE.h>
#include "GameState.h"
#include "DeckEditorMenu.h"
#include "SimpleMenu.h"
#include "WResourceManager.h"
#include "CardGui.h"
#include "GameOptions.h"
#include "PriceList.h"
#include "PlayerData.h"
#include "DeckDataWrapper.h"
#include "DeckStats.h"
#include "WDataSrc.h"
#include "WGui.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
};
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
// available options in the duel menu
enum
{
MENU_CARD_PURCHASE = 2,
MENU_DECK_SELECTION = 10,
MENU_DECK_BUILDER = 11,
MENU_FIRST_DUEL_SUBMENU = 102,
MENU_LANGUAGE_SELECTION = 103,
};
// enums for menu options
// TODO: make these enums a little more descriptive. (ie should reflect what menu they are attached to )
enum DECK_VIEWER_MENU_ITEMS
{
MENU_ITEM_NEW_DECK = -30,
MENU_ITEM_CHEAT_MODE = -12,
MENU_ITEM_CANCEL = kCancelMenuID,
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
MENU_ITEM_SAVE_RENAME = 1,
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
MENU_ITEM_MAIN_MENU = 3,
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
MENU_ITEM_SAVE_AS_AI_DECK = 5,
MENU_ITEM_YES = 20,
MENU_ITEM_NO = 21,
MENU_ITEM_FILTER_BY = 22
};
#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 8
class GameStateDeckViewer: public GameState, public JGuiListener
{
private:
JQuad * mIcons[7];
JQuad * pspIcons[8];
JTexture * pspIconsTexture;
float last_user_activity;
float onScreenTransition;
float mRotation;
float mSlide;
int mAlpha;
int mStage;
int nbDecks;
int deckNum;
int useFilter;
JMusic * bgMusic;
JQuad * backQuad;
int lastPos;
int lastTotal;
WGuiFilters * filterMenu;
WSrcDeckViewer * source;
DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu;
DeckEditorMenu * menu;
PriceList* pricelist;
PlayerData * playerdata;
int price;
DeckDataWrapper * displayed_deck;
DeckDataWrapper * myDeck;
DeckDataWrapper * myCollection;
MTGCard * cardIndex[7];
StatsWrapper *stw;
int hudAlpha;
string newDeckname;
bool isAIDeckSave;
bool mSwitching;
void saveDeck(); //Saves the deck and additional necessary information
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
int getCurrentPos();
public:
GameStateDeckViewer(GameApp* parent);
virtual ~GameStateDeckViewer();
void updateDecks();
void rotateCards(int direction);
void loadIndexes();
void updateFilters();
void rebuildFilters();
void switchDisplay();
void Start();
virtual void End();
void addRemove(MTGCard * card);
virtual void Update(float dt);
void renderOnScreenBasicInfo();
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 buildEditorMenu();
virtual void ButtonPressed(int controllerId, int controlId);
void updateStats();
int countCardsByType(const char * _type);
};
// n cards total, a of them are desired, x drawn
// returns probability of no A's
float noLuck(int n, int a, int x);
#endif
#ifndef _GAME_STATE_DECK_VIEWER_H_
#define _GAME_STATE_DECK_VIEWER_H_
#include <math.h>
#include <iostream>
#include <JGE.h>
#include "GameState.h"
#include "DeckEditorMenu.h"
#include "SimpleMenu.h"
#include "WResourceManager.h"
#include "CardGui.h"
#include "GameOptions.h"
#include "PriceList.h"
#include "PlayerData.h"
#include "DeckDataWrapper.h"
#include "DeckStats.h"
#include "WDataSrc.h"
#include "WGui.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
};
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
// available options in the duel menu
enum
{
MENU_CARD_PURCHASE = 2,
MENU_DECK_SELECTION = 10,
MENU_DECK_BUILDER = 11,
MENU_FIRST_DUEL_SUBMENU = 102,
MENU_LANGUAGE_SELECTION = 103,
};
// enums for menu options
// TODO: make these enums a little more descriptive. (ie should reflect what menu they are attached to )
enum DECK_VIEWER_MENU_ITEMS
{
MENU_ITEM_NEW_DECK = -30,
MENU_ITEM_CHEAT_MODE = -12,
MENU_ITEM_CANCEL = kCancelMenuID,
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
MENU_ITEM_SAVE_RENAME = 1,
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
MENU_ITEM_MAIN_MENU = 3,
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
MENU_ITEM_SAVE_AS_AI_DECK = 5,
MENU_ITEM_YES = 20,
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 8
class GameStateDeckViewer: public GameState, public JGuiListener
{
private:
JQuad * mIcons[7];
JQuad * pspIcons[8];
JTexture * pspIconsTexture;
float last_user_activity;
float onScreenTransition;
float mRotation;
float mSlide;
int mAlpha;
int mStage;
int nbDecks;
int deckNum;
int useFilter;
JMusic * bgMusic;
JQuad * backQuad;
int lastPos;
int lastTotal;
WGuiFilters * filterMenu;
WSrcDeckViewer * source;
DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu;
DeckEditorMenu * menu;
PriceList* pricelist;
PlayerData * playerdata;
int price;
DeckDataWrapper * displayed_deck;
DeckDataWrapper * myDeck;
DeckDataWrapper * myCollection;
MTGCard * cardIndex[7];
StatsWrapper *stw;
int hudAlpha;
string newDeckname;
bool isAIDeckSave;
bool mSwitching;
void saveDeck(); //Saves the deck and additional necessary information
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
int getCurrentPos();
public:
GameStateDeckViewer(GameApp* parent);
virtual ~GameStateDeckViewer();
void updateDecks();
void rotateCards(int direction);
void loadIndexes();
void updateFilters();
void rebuildFilters();
void switchDisplay();
void Start();
virtual void End();
void addRemove(MTGCard * card);
virtual void Update(float dt);
void renderOnScreenBasicInfo();
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 buildEditorMenu();
virtual void ButtonPressed(int controllerId, int controlId);
void updateStats();
int countCardsByType(const char * _type);
};
// n cards total, a of them are desired, x drawn
// returns probability of no A's
float noLuck(int n, int a, int x);
#endif

View File

@@ -1,73 +1,76 @@
#ifndef _GAME_STATE_DUEL_H_
#define _GAME_STATE_DUEL_H_
#include "GameState.h"
#include "SimpleMenu.h"
#include "DeckMenu.h"
#include "MTGDeck.h"
#include "GameObserver.h"
#define CHOOSE_OPPONENT 7
#ifdef TESTSUITE
class TestSuite;
#endif
class Credits;
class Rules;
class GameStateDuel: public GameState, public JGuiListener
{
private:
#ifdef TESTSUITE
TestSuite * testSuite;
#endif
Credits * credits;
int mGamePhase;
Player * mCurrentPlayer;
Player * mPlayers[2];
MTGPlayerCards * deck[2];
GameObserver * game;
DeckMenu * deckmenu;
DeckMenu * opponentMenu;
SimpleMenu * menu;
bool premadeDeck;
int OpponentsDeckid;
string musictrack;
Rules * rules;
bool MusicExist(string FileName);
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
void ensureOpponentMenu(); //loads the opponentMenu if it doesn't exist
void initScroller();
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();
#ifdef TESTSUITE
void loadTestSuitePlayers();
#endif
virtual void ButtonPressed(int ControllerId, int ControlId);
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
void initRand (unsigned seed = 0);
enum ENUM_DUEL_STATE_MENU_ITEM
{
MENUITEM_CANCEL = kCancelMenuID,
MENUITEM_NEW_DECK = -10,
MENUITEM_RANDOM_PLAYER = -11,
MENUITEM_RANDOM_AI = -12,
MENUITEM_MAIN_MENU = -13,
MENUITEM_EVIL_TWIN = -14,
MENUITEM_MULLIGAN = -15
};
};
#endif
#ifndef _GAME_STATE_DUEL_H_
#define _GAME_STATE_DUEL_H_
#include "GameState.h"
#include "SimpleMenu.h"
#include "SimplePopup.h"
#include "DeckMenu.h"
#include "MTGDeck.h"
#include "GameObserver.h"
#define CHOOSE_OPPONENT 7
#ifdef TESTSUITE
class TestSuite;
#endif
class Credits;
class Rules;
class GameStateDuel: public GameState, public JGuiListener
{
private:
#ifdef TESTSUITE
TestSuite * testSuite;
#endif
Credits * credits;
int mGamePhase;
Player * mCurrentPlayer;
Player * mPlayers[2];
MTGPlayerCards * deck[2];
GameObserver * game;
DeckMenu * deckmenu;
DeckMenu * opponentMenu;
SimpleMenu * menu;
SimplePopup * popupScreen; // used for informational screens, modal
static int selectedPlayerDeckId;
static int selectedAIDeckId;
bool premadeDeck;
int OpponentsDeckid;
string musictrack;
Rules * rules;
bool MusicExist(string FileName);
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
void ensureOpponentMenu(); //loads the opponentMenu if it doesn't exist
void initScroller();
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();
#ifdef TESTSUITE
void loadTestSuitePlayers();
#endif
virtual void ButtonPressed(int ControllerId, int ControlId);
virtual void Start();
virtual void End();
virtual void Update(float dt);
virtual void Render();
void initRand(unsigned seed = 0);
enum ENUM_DUEL_STATE_MENU_ITEM
{
MENUITEM_CANCEL = kCancelMenuID,
MENUITEM_NEW_DECK = -10,
MENUITEM_RANDOM_PLAYER = -11,
MENUITEM_RANDOM_AI = -12,
MENUITEM_MAIN_MENU = -13,
MENUITEM_EVIL_TWIN = -14,
MENUITEM_MULLIGAN = -15,
MENUITEM_MORE_INFO = kInfoMenuID
};
};
#endif

View File

@@ -1,78 +1,102 @@
#ifndef _PLAYER_H_
#define _PLAYER_H_
#include "JGE.h"
#include "MTGGameZones.h"
#include "Damage.h"
#include "Targetable.h"
class MTGDeck;
class MTGPlayerCards;
class MTGInPlay;
class ManaPool;
class Player: public Damageable{
protected:
ManaPool * manaPool;
public:
enum ENUM_PLAY_MODE
{
MODE_TEST_SUITE,
MODE_HUMAN,
MODE_AI,
};
virtual void End();
int typeAsTarget(){return TARGET_PLAYER;}
const string getDisplayName() const;
virtual int displayStack(){return 1;}
JTexture * mAvatarTex;
JQuad * mAvatar;
int playMode;
int canPutLandsIntoPlay;
int nomaxhandsize;
int castedspellsthisturn;
int onlyonecast;
int castcount;
int nocreatureinstant;
int nospellinstant;
int onlyoneinstant;
int castrestrictedcreature;
int castrestrictedspell;
MTGPlayerCards * game;
int afterDamage();
int poisoned();
int damaged();
int prevented();
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
virtual ~Player();
void unTapPhase();
MTGInPlay * inPlay();
ManaPool * getManaPool();
void cleanupPhase();
virtual int Act(float dt){return 0;};
virtual int isAI(){return 0;};
Player * opponent();
int getId();
JQuad * getIcon();
string deckFile;
string deckFileSmall;
string deckName;
virtual int receiveEvent(WEvent * event){return 0;};
virtual void Render(){};
void loadAvatar(string file);
};
class HumanPlayer: public Player{
public:
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
HumanPlayer(string deckFile);
};
ostream& operator<<(ostream&, const Player&);
#endif
#ifndef _PLAYER_H_
#define _PLAYER_H_
#include "JGE.h"
#include "MTGGameZones.h"
#include "Damage.h"
#include "Targetable.h"
class MTGDeck;
class MTGPlayerCards;
class MTGInPlay;
class ManaPool;
class Player: public Damageable
{
protected:
ManaPool * manaPool;
public:
enum ENUM_PLAY_MODE
{
MODE_TEST_SUITE, MODE_HUMAN, MODE_AI,
};
JTexture * mAvatarTex;
JQuad * mAvatar;
int playMode;
int canPutLandsIntoPlay;
int nomaxhandsize;
int castedspellsthisturn;
int onlyonecast;
int castcount;
int nocreatureinstant;
int nospellinstant;
int onlyoneinstant;
int castrestrictedcreature;
int castrestrictedspell;
MTGPlayerCards * game;
string deckFile;
string deckFileSmall;
string deckName;
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
virtual ~Player();
virtual void End();
virtual int displayStack()
{
return 1;
}
const string getDisplayName() const;
int typeAsTarget()
{
return TARGET_PLAYER;
}
int afterDamage();
int poisoned();
int damaged();
int prevented();
void unTapPhase();
MTGInPlay * inPlay();
ManaPool * getManaPool();
void cleanupPhase();
virtual int Act(float dt)
{
return 0;
}
virtual int isAI()
{
return 0;
}
Player * opponent();
int getId();
JQuad * getIcon();
virtual int receiveEvent(WEvent * event)
{
return 0;
}
virtual void Render()
{
}
void loadAvatar(string file);
};
class HumanPlayer: public Player
{
public:
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
HumanPlayer(string deckFile);
};
ostream& operator<<(ostream&, const Player&);
#endif

View File

@@ -0,0 +1,48 @@
/*
* SimplePopup.h
* Created on: Nov 18, 2010
*
* Simple popup dialog box for displaying information only.
*/
#ifndef SIMPLEPOPUP_H_
#define SIMPLEPOPUP_H_
#pragma once
#include <JGui.h>
#include <JTypes.h>
#include <WFont.h>
#include <DeckMetaData.h>
class SimplePopup: public JGuiController
{
private:
float mHeight, mWidth, mX, mY;
int mMaxLines;
int mFontId;
DeckMetaData * mDeckInformation;
string mTitle;
WFont *mTextFont;
StatsWrapper *stw;
void drawHorzPole(float x, float y, float width);
void drawVertPole(float x, float y, float height);
public:
MTGAllCards * mCollection;
bool autoTranslate;
bool closed;
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
~SimplePopup(void);
void Render();
void Update(DeckMetaData* deckMetaData);
string getDetailedInformation(string deckFilename);
void Update(float dt);
void Close();
};
#endif /* SIMPLEPOPUP_H_ */

View File

@@ -1,103 +1,102 @@
#include "PrecompiledHeader.h"
#include "DeckEditorMenu.h"
#include "DeckDataWrapper.h"
#include "DeckStats.h"
#include "JTypes.h"
#include "GameApp.h"
#include <iomanip>
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck,
StatsWrapper *stats) :
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
{
backgroundName = "DeckEditorMenuBackdrop";
deckTitle = selectedDeck ? selectedDeck->parent->meta_name : "";
mX = 123;
mY = 70;
starsOffsetX = 50;
titleX = 110; // center point in title box
titleY = 25;
titleWidth = 180; // width of inner box of title
descX = 275;
descY = 80;
descHeight = 154;
descWidth = 175;
statsHeight = 50;
statsWidth = 185;
statsX = 280;
statsY = 12;
avatarX = 222;
avatarY = 8;
float scrollerWidth = 80;
SAFE_DELETE(scroller); // need to delete the scroller init in the base class
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
}
void DeckEditorMenu::Render()
{
JRenderer *r = JRenderer::GetInstance();
r->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(200,0,0,0));
DeckMenu::Render();
if (deckTitle.size() > 0)
{
WFont *mainFont = resources.GetWFont(Fonts::OPTION_FONT);
DWORD currentColor = mainFont->GetColor();
mainFont->SetColor(ARGB(255,255,255,255));
mainFont->DrawString(deckTitle.c_str(), statsX + (statsWidth / 2), statsHeight / 2, JGETEXT_CENTER);
mainFont->SetColor(currentColor);
}
if (stw && selectedDeck)
drawDeckStatistics();
}
void DeckEditorMenu::drawDeckStatistics()
{
ostringstream deckStatsString;
deckStatsString
<< "------- Deck Summary -----" << endl
<< "Cards: "<< selectedDeck->getCount() << endl
<< "Creatures: "<< setw(2) << stw->countCreatures
<< " Enchantments: " << stw->countEnchantments << endl
<< "Instants: " << setw(4) << stw->countInstants
<< " Sorceries: " << setw(2) << stw->countSorceries << endl
<< "Lands: "
<< "A: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] << " "
<< "G: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] + stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] << " "
<< "R: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_RED ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_RED ] << " "
<< "U: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLUE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLUE ] << " "
<< "B: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLACK ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLACK ] << " "
<< "W: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_WHITE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_WHITE ] << endl
<< " --- Card color count --- " << endl
<< "A: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_ARTIFACT) << " "
<< "G: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_GREEN) << " "
<< "U: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLUE) << " "
<< "R: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_RED) << " "
<< "B: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLACK) << " "
<< "W: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_WHITE) << endl
<< " --- Average Cost --- " << endl
<< "Creature: "<< setprecision(2) << stw->avgCreatureCost << endl
<< "Mana: " << setprecision(2) << stw->avgManaCost << " "
<< "Spell: " << setprecision(2) << stw->avgSpellCost << endl;
WFont *mainFont = resources.GetWFont( Fonts::MAIN_FONT );
mainFont->DrawString( deckStatsString.str().c_str(), descX, descY + 25 );
}
DeckEditorMenu::~DeckEditorMenu()
{
SAFE_DELETE( scroller );
}
#include "PrecompiledHeader.h"
#include "DeckEditorMenu.h"
#include "DeckDataWrapper.h"
#include "DeckStats.h"
#include "JTypes.h"
#include "GameApp.h"
#include <iomanip>
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
{
backgroundName = "DeckEditorMenuBackdrop";
deckTitle = selectedDeck ? selectedDeck->parent->meta_name : "";
enableDetails = false;
mX = 123;
mY = 70;
starsOffsetX = 50;
titleX = 110; // center point in title box
titleY = 25;
titleWidth = 180; // width of inner box of title
descX = 275;
descY = 80;
descHeight = 154;
descWidth = 175;
statsHeight = 50;
statsWidth = 185;
statsX = 280;
statsY = 12;
avatarX = 222;
avatarY = 8;
float scrollerWidth = 80;
SAFE_DELETE(scroller); // need to delete the scroller init in the base class
this->showDetailsScreen = false;
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
}
void DeckEditorMenu::Render()
{
JRenderer *r = JRenderer::GetInstance();
r->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(200,0,0,0));
DeckMenu::Render();
if (deckTitle.size() > 0)
{
WFont *mainFont = resources.GetWFont(Fonts::OPTION_FONT);
DWORD currentColor = mainFont->GetColor();
mainFont->SetColor(ARGB(255,255,255,255));
mainFont->DrawString(deckTitle.c_str(), statsX + (statsWidth / 2), statsHeight / 2, JGETEXT_CENTER);
mainFont->SetColor(currentColor);
}
if (stw && selectedDeck) drawDeckStatistics();
}
void DeckEditorMenu::drawDeckStatistics()
{
ostringstream deckStatsString;
deckStatsString
<< "------- Deck Summary -----" << endl
<< "Cards: "<< stw->cardCount << endl
<< "Creatures: "<< setw(2) << stw->countCreatures
<< " Enchantments: " << stw->countEnchantments << endl
<< "Instants: " << setw(4) << stw->countInstants
<< " Sorceries: " << setw(2) << stw->countSorceries << endl
<< "Lands: "
<< "A: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] << " "
<< "G: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] + stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] << " "
<< "R: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_RED ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_RED ] << " "
<< "U: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLUE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLUE ] << " "
<< "B: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLACK ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLACK ] << " "
<< "W: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_WHITE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_WHITE ] << endl
<< " --- Card color count --- " << endl
<< "A: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_ARTIFACT) << " "
<< "G: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_GREEN) << " "
<< "U: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLUE) << " "
<< "R: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_RED) << " "
<< "B: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLACK) << " "
<< "W: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_WHITE) << endl
<< " --- Average Cost --- " << endl
<< "Creature: "<< setprecision(2) << stw->avgCreatureCost << endl
<< "Mana: " << setprecision(2) << stw->avgManaCost << " "
<< "Spell: " << setprecision(2) << stw->avgSpellCost << endl;
WFont *mainFont = resources.GetWFont(Fonts::MAIN_FONT);
mainFont->DrawString(deckStatsString.str().c_str(), descX, descY + 25);
}
DeckEditorMenu::~DeckEditorMenu()
{
SAFE_DELETE( scroller );
}

View File

@@ -1,281 +1,328 @@
#include "PrecompiledHeader.h"
#include "DeckMenu.h"
#include "DeckMenuItem.h"
#include "DeckMetaData.h"
#include "JTypes.h"
#include "GameApp.h"
#include "Translate.h"
#include "TextScroller.h"
#include "Tasks.h"
#include <iomanip>
namespace
{
const float kVerticalMargin = 16;
const float kHorizontalMargin = 20;
const float kLineHeight = 20;
const float kDescriptionVerticalBoxPadding = 5;
const float kDescriptionHorizontalBoxPadding = 5;
}
hgeParticleSystem* DeckMenu::stars = NULL;
//
// For the additional info window, maximum characters per line is roughly 30 characters across.
// TODO: figure a way to get incoming text to wrap.
//
// used fixed locations where the menu, title and descriptive text are located.
// * menu at (125, 60 )
// * descriptive information 125
// *** Need to make this configurable in a file somewhere to allow for class reuse
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const float& mFontScale) :
JGuiController(id, listener), fontId(fontId), menuFontScale(mFontScale)
{
backgroundName = "DeckMenuBackdrop";
mY = 55;
mWidth = 176;
mX = 125;
titleX = 130; // center point in title box
titleY = 28;
titleWidth = 180; // width of inner box of title
descX = 230 + kDescriptionVerticalBoxPadding;
descY = 65 + kDescriptionHorizontalBoxPadding;
descHeight = 145;
descWidth = 220;
starsOffsetX = 50;
statsX = 280;
statsY = 8;
statsHeight = 50;
statsWidth = 227;
avatarX = 230;
avatarY = 8;
menuInitialized = false;
float scrollerWidth = 80;
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
autoTranslate = true;
maxItems = 7;
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
title = _(_title);
displayTitle = title;
mFont = resources.GetWFont(fontId);
startId = 0;
selectionT = 0;
timeOpen = 0;
closed = false;
if (mFont->GetStringWidth(title.c_str()) > titleWidth)
titleFontScale = 0.75f;
else
titleFontScale = 1.0f;
selectionTargetY = selectionY = kVerticalMargin;
if (NULL == stars)
stars = NEW hgeParticleSystem(resources.RetrievePSI("stars.psi", resources.GetQuad("stars")));
stars->FireAt(mX, mY);
updateScroller();
}
void DeckMenu::RenderBackground()
{
ostringstream bgFilename;
bgFilename << backgroundName << ".png";
static bool loadBackground = true;
if (loadBackground)
{
JQuad *background = resources.RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551);
if (background)
JRenderer::GetInstance()->RenderQuad(background, 0, 0);
else
loadBackground = false;
}
}
void DeckMenu::initMenuItems()
{
float sY = mY + kVerticalMargin;
for (int i = startId; i < startId + mCount; ++i)
{
float y = mY + kVerticalMargin + i * kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
currentMenuItem->Relocate(mX, y);
if (currentMenuItem->hasFocus())
sY = y;
}
selectionTargetY = selectionY = sY;
}
void DeckMenu::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
float height = mHeight;
if (!menuInitialized)
{
initMenuItems();
stars->Fire();
timeOpen = 0;
menuInitialized = true;
}
if (timeOpen < 1)
height *= timeOpen > 0 ? timeOpen : -timeOpen;
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
stars->Render();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
for (int i = startId; i < startId + maxItems; i++)
{
if (i > mCount - 1)
break;
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
if (currentMenuItem->mY - kLineHeight * startId < mY + height - kLineHeight + 7)
{
if (currentMenuItem->hasFocus())
{
// display the avatar image
if (currentMenuItem->imageFilename.size() > 0)
{
JQuad * quad = resources.RetrieveTempQuad(currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR);
if (quad)
renderer->RenderQuad(quad, avatarX, avatarY);
}
// fill in the description part of the screen
string text = currentMenuItem->desc;
WFont *mainFont = resources.GetWFont(Fonts::MAIN_FONT);
mainFont->DrawString(text.c_str(), descX, descY);
mFont->SetColor(ARGB(255,255,255,255));
// fill in the statistical portion
if (currentMenuItem->meta)
{
ostringstream oss;
oss << "Deck: " << currentMenuItem->meta->getName() << endl;
oss << currentMenuItem->meta->getStatsSummary();
mainFont->DrawString(oss.str(), statsX, statsY);
}
}
else
{
mFont->SetColor(ARGB(150,255,255,255));
}
mFont->SetScale(menuFontScale);
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
}
}
RenderBackground();
if (!title.empty())
{
mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(titleFontScale);
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
}
mFont->SetScale(1.0f);
scroller->Render();
}
void DeckMenu::Update(float dt)
{
JGuiController::Update(dt);
if (mCurr > startId + maxItems - 1)
startId = mCurr - maxItems + 1;
else if (mCurr < startId)
startId = mCurr;
stars->Update(dt);
selectionT += 3 * dt;
selectionY += (selectionTargetY - selectionY) * 8 * dt;
float starsX = starsOffsetX + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2);
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId;
stars->MoveTo(starsX, starsY);
if (timeOpen < 0)
{
timeOpen += dt * 10;
if (timeOpen >= 0)
{
timeOpen = 0;
closed = true;
stars->FireAt(mX, mY);
}
}
else
{
closed = false;
timeOpen += dt * 10;
}
scroller->Update(dt);
}
void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, DeckMetaData * deckMetaData)
{
DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0, mY + kVerticalMargin + mCount * kLineHeight,
(mCount == 0), autoTranslate, deckMetaData);
Translator * t = Translator::GetInstance();
map<string, string>::iterator it = t->deckValues.find(text);
if (it != t->deckValues.end()) //translate decks desc
menuItem->desc = it->second;
else
menuItem->desc = deckMetaData ? deckMetaData->getDescription() : desc;
JGuiController::Add(menuItem);
if (mCount <= maxItems)
mHeight += kLineHeight;
if (forceFocus)
{
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);
mCurr = mCount - 1;
menuItem->Entering();
}
}
void DeckMenu::updateScroller()
{
// add all the items from the Tasks db.
TaskList taskList;
scroller->Reset();
for (vector<Task*>::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++)
{
ostringstream taskDescription;
taskDescription << "[ " << setw(4) << (*it)->getReward() << " / " << (*it)->getExpiration() << " ] "
<< (*it)->getDesc() << endl;
scroller->Add(taskDescription.str());
}
}
void DeckMenu::Close()
{
timeOpen = -1.0;
stars->Stop(true);
}
void DeckMenu::destroy()
{
SAFE_DELETE(DeckMenu::stars);
}
DeckMenu::~DeckMenu()
{
SAFE_DELETE(scroller);
}
#include "PrecompiledHeader.h"
#include "DeckMenu.h"
#include "DeckMenuItem.h"
#include "DeckMetaData.h"
#include "JTypes.h"
#include "GameApp.h"
#include "Translate.h"
#include "TextScroller.h"
#include "Tasks.h"
#include <iomanip>
namespace
{
const float kVerticalMargin = 16;
const float kHorizontalMargin = 20;
const float kLineHeight = 20;
const float kDescriptionVerticalBoxPadding = 5;
const float kDescriptionHorizontalBoxPadding = 5;
const int DETAILED_INFO_THRESHOLD = 4;
}
hgeParticleSystem* DeckMenu::stars = NULL;
//
// For the additional info window, maximum characters per line is roughly 30 characters across.
// TODO: figure a way to get incoming text to wrap.
//
// used fixed locations where the menu, title and descriptive text are located.
// * menu at (125, 60 )
// * descriptive information 125
// *** Need to make this configurable in a file somewhere to allow for class reuse
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const int& startIndex, const float& mFontScale) :
JGuiController(id, listener), fontId(fontId), menuFontScale(mFontScale)
{
backgroundName = "DeckMenuBackdrop";
selectedDeck = NULL;
enableDetails = true;
mY = 55;
mWidth = 176;
mX = 125;
titleX = 130; // center point in title box
titleY = 28;
titleWidth = 180; // width of inner box of title
descX = 230 + kDescriptionVerticalBoxPadding;
descY = 65 + kDescriptionHorizontalBoxPadding;
descHeight = 145;
descWidth = 220;
detailedInfoBoxX = 400;
detailedInfoBoxY = 235;
starsOffsetX = 50;
statsX = 280;
statsY = 8;
statsHeight = 50;
statsWidth = 227;
selectedDeckId = startIndex;
avatarX = 230;
avatarY = 8;
menuInitialized = false;
float scrollerWidth = 80;
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
autoTranslate = true;
maxItems = 7;
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
title = _(_title);
displayTitle = title;
mFont = resources.GetWFont(fontId);
startId = 0;
selectionT = 0;
timeOpen = 0;
closed = false;
if (mFont->GetStringWidth(title.c_str()) > titleWidth)
titleFontScale = 0.75f;
else
titleFontScale = 1.0f;
selectionTargetY = selectionY = kVerticalMargin;
if (NULL == stars) stars = NEW hgeParticleSystem(resources.RetrievePSI("stars.psi", resources.GetQuad("stars")));
stars->FireAt(mX, mY);
updateScroller();
}
void DeckMenu::RenderBackground()
{
ostringstream bgFilename;
bgFilename << backgroundName << ".png";
static bool loadBackground = true;
if (loadBackground)
{
JQuad *background = resources.RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551);
if (background)
JRenderer::GetInstance()->RenderQuad(background, 0, 0);
else
loadBackground = false;
}
}
DeckMetaData * DeckMenu::getSelectedDeck()
{
if (selectedDeck) return selectedDeck;
return NULL;
}
bool DeckMenu::selectedDeckHasDetails()
{
DeckMetaData * currentMenuItem = getSelectedDeck();
if (currentMenuItem) return (enableDetails && currentMenuItem->getGamesPlayed() > DETAILED_INFO_THRESHOLD);
return false;
}
void DeckMenu::initMenuItems()
{
float sY = mY + kVerticalMargin;
for (int i = startId; i < startId + mCount; ++i)
{
float y = mY + kVerticalMargin + i * kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
currentMenuItem->Relocate(mX, y);
if (currentMenuItem->hasFocus()) sY = y;
}
selectionTargetY = selectionY = sY;
//Grab a texture in VRAM.
pspIconsTexture = resources.RetrieveTexture("iconspsp.png", RETRIEVE_LOCK);
char buf[512];
for (int i = 0; i < 8; i++)
{
sprintf(buf, "iconspsp%d", i);
pspIcons[i] = resources.RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf);
pspIcons[i]->SetHotSpot(16, 16);
}
}
void DeckMenu::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
float height = mHeight;
if (!menuInitialized)
{
initMenuItems();
stars->Fire();
timeOpen = 0;
menuInitialized = true;
}
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
for (int i = startId; i < startId + maxItems; i++)
{
if (i > mCount - 1) break;
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
if (currentMenuItem->mY - kLineHeight * startId < mY + height - kLineHeight + 7)
{
if (currentMenuItem->hasFocus())
{
selectedDeckId = i;
selectedDeck = currentMenuItem->meta;
WFont *mainFont = resources.GetWFont(Fonts::MAIN_FONT);
// display the "more info" button if special condition is met
if (selectedDeckHasDetails())
{
showDetailsScreen = true;
float pspIconsSize = 0.5;
const string detailedInfoString = "Detailed Info";
float stringWidth = mainFont->GetStringWidth(detailedInfoString.c_str());
float boxStartX = detailedInfoBoxX - stringWidth / 2;
DWORD currentColor = mainFont->GetColor();
renderer->FillRoundRect( boxStartX, detailedInfoBoxY - 5, stringWidth,
mainFont->GetHeight() + 15, .5, ARGB( 125, 0, 255, 255) );
renderer->RenderQuad(pspIcons[5], detailedInfoBoxX, detailedInfoBoxY + 2, 0, pspIconsSize, pspIconsSize);
mainFont->SetColor(currentColor);
mainFont->DrawString(detailedInfoString, boxStartX, detailedInfoBoxY + 10);
}
else
showDetailsScreen = false;
// display the avatar image
if (currentMenuItem->imageFilename.size() > 0)
{
JQuad * quad = resources.RetrieveTempQuad(currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR);
if (quad) renderer->RenderQuad(quad, avatarX, avatarY);
}
// fill in the description part of the screen
string text = currentMenuItem->desc;
mainFont->DrawString(text.c_str(), descX, descY);
mFont->SetColor(ARGB(255,255,255,255));
// fill in the statistical portion
if (currentMenuItem->meta)
{
ostringstream oss;
oss << "Deck: " << currentMenuItem->meta->getName() << endl;
oss << currentMenuItem->meta->getStatsSummary();
mainFont->DrawString(oss.str(), statsX, statsY);
}
}
else
{
mFont->SetColor(ARGB(150,255,255,255));
}
mFont->SetScale(menuFontScale);
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
}
}
RenderBackground();
if (!title.empty())
{
mFont->SetColor(ARGB(255,255,255,255));
mFont->SetScale(titleFontScale);
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
}
mFont->SetScale(1.0f);
scroller->Render();
}
void DeckMenu::Update(float dt)
{
JGuiController::Update(dt);
if (mCurr > startId + maxItems - 1)
startId = mCurr - maxItems + 1;
else if (mCurr < startId) startId = mCurr;
stars->Update(dt);
selectionT += 3 * dt;
selectionY += (selectionTargetY - selectionY) * 8 * dt;
float starsX = starsOffsetX + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2);
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId;
stars->MoveTo(starsX, starsY);
if (timeOpen < 0)
{
timeOpen += dt * 10;
if (timeOpen >= 0)
{
timeOpen = 0;
closed = true;
stars->FireAt(mX, mY);
}
}
else
{
closed = false;
timeOpen += dt * 10;
}
if (scroller) scroller->Update(dt);
}
void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, DeckMetaData * deckMetaData)
{
DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0, mY + kVerticalMargin + mCount * kLineHeight,
(mCount == 0), autoTranslate, deckMetaData);
Translator * t = Translator::GetInstance();
map<string, string>::iterator it = t->deckValues.find(text);
if (it != t->deckValues.end()) //translate decks desc
menuItem->desc = it->second;
else
menuItem->desc = deckMetaData ? deckMetaData->getDescription() : desc;
JGuiController::Add(menuItem);
if (mCount <= maxItems) mHeight += kLineHeight;
if (forceFocus)
{
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);
mCurr = mCount - 1;
menuItem->Entering();
}
}
void DeckMenu::updateScroller()
{
// add all the items from the Tasks db.
TaskList taskList;
scroller->Reset();
for (vector<Task*>::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++)
{
ostringstream taskDescription;
taskDescription << "[ " << setw(4) << (*it)->getReward() << " / " << (*it)->getExpiration() << " ] "
<< (*it)->getDesc() << endl;
scroller->Add(taskDescription.str());
}
}
void DeckMenu::Close()
{
timeOpen = -1.0;
stars->Stop(true);
}
void DeckMenu::destroy()
{
SAFE_DELETE(DeckMenu::stars);
}
DeckMenu::~DeckMenu()
{
resources.Release(pspIconsTexture);
SAFE_DELETE(scroller);
scroller = NULL;
}

View File

@@ -1,242 +1,466 @@
#include "PrecompiledHeader.h"
#include "DeckStats.h"
#include "Player.h"
#include "GameObserver.h"
DeckStats * DeckStats::mInstance = NULL;
int DeckStat::percentVictories()
{
if (nbgames == 0)
return 50;
return (100 * victories / nbgames);
}
DeckStats * DeckStats::GetInstance()
{
if (!mInstance)
{
mInstance = NEW DeckStats();
}
return mInstance;
}
void DeckStats::cleanStats()
{
map<string, DeckStat *>::iterator it;
for (it = stats.begin(); it != stats.end(); it++)
{
SAFE_DELETE(it->second);
}
stats.clear();
}
DeckStats::~DeckStats()
{
cleanStats();
}
int DeckStats::percentVictories(string opponentsFile)
{
map<string, DeckStat *>::iterator it = stats.find(opponentsFile);
if (it == stats.end())
{
return 50;
}
else
{
return (it->second->percentVictories());
}
}
DeckStat* DeckStats::getDeckStat(string opponentsFile)
{
map<string, DeckStat *>::iterator it = stats.find(opponentsFile);
if (it == stats.end())
{
return NULL;
}
else
{
return it->second;
}
}
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)
{
char filename[512];
sprintf(filename, "stats/%s.txt", player->deckFileSmall.c_str());
load(options.profileFile(filename).c_str());
}
void DeckStats::load(const char * filename)
{
cleanStats();
std::ifstream file(filename);
std::string s;
if (file)
{
while (std::getline(file, s))
{
string deckfile = s;
std::getline(file, s);
int games = atoi(s.c_str());
std::getline(file, s);
int victories = atoi(s.c_str());
map<string, DeckStat *>::iterator it = stats.find(deckfile);
if (it == stats.end())
{
stats[deckfile] = NEW DeckStat(games, victories);
}
}
file.close();
}
}
void DeckStats::save(Player * player)
{
char filename[512];
sprintf(filename, "stats/%s.txt", player->deckFileSmall.c_str());
save(options.profileFile(filename).c_str());
}
void DeckStats::save(const char * filename)
{
std::ofstream file(filename);
char writer[512];
if (file)
{
map<string, DeckStat *>::iterator it;
for (it = stats.begin(); it != stats.end(); it++)
{
sprintf(writer, "%s\n", it->first.c_str());
file << writer;
sprintf(writer, "%i\n", it->second->nbgames);
file << writer;
sprintf(writer, "%i\n", it->second->victories);
file << writer;
}
file.close();
}
}
void DeckStats::saveStats(Player *player, Player *opponent, GameObserver * game)
{
int victory = 1;
if (!game->gameOver)
{
if (player->life == opponent->life)
return;
if (player->life < opponent->life)
victory = 0;
}
else if (game->gameOver == player)
{
victory = 0;
}
load(player);
map<string, DeckStat *>::iterator it = stats.find(opponent->deckFileSmall);
if (it == stats.end())
{
stats[opponent->deckFileSmall] = NEW DeckStat(1, victory);
}
else
{
it->second->victories += victory;
it->second->nbgames += 1;
}
save(player);
}
StatsWrapper::StatsWrapper(int deckId)
{
// Load deck statistics
char buffer[512];
DeckStats * stats = DeckStats::GetInstance();
aiDeckNames.clear();
aiDeckStats.clear();
sprintf(buffer, "stats/player_deck%i.txt", deckId);
string deckstats = options.profileFile(buffer);
if (fileExists(deckstats.c_str()))
{
stats->load(deckstats.c_str());
percentVictories = stats->percentVictories();
gamesPlayed = stats->nbGames();
// Detailed deck statistics against AI
int found = 1;
int nbDecks = 0;
while (found)
{
found = 0;
char buffer[512];
char smallDeckName[512];
sprintf(buffer, "%s/deck%i.txt", RESPATH"/ai/baka", nbDecks + 1);
if (fileExists(buffer))
{
MTGDeck * mtgd = NEW MTGDeck(buffer, NULL, 1);
found = 1;
nbDecks++;
sprintf(smallDeckName, "%s_deck%i", "ai_baka", nbDecks);
DeckStat* deckStat = stats->getDeckStat(string(smallDeckName));
if ((deckStat != NULL) && (deckStat->nbgames > 0))
{
int percentVictories = stats->percentVictories(string(smallDeckName));
aiDeckNames.push_back(string(mtgd->meta_name));
aiDeckStats.push_back(deckStat);
}
delete mtgd;
}
}
}
else
{
gamesPlayed = 0;
percentVictories = 0;
}
}
StatsWrapper::~StatsWrapper()
{
aiDeckNames.clear();
aiDeckStats.clear();
}
#include "PrecompiledHeader.h"
#include "DeckStats.h"
#include "Player.h"
#include "GameObserver.h"
#include "MTGDeck.h"
#include "ManaCostHybrid.h"
DeckStats * DeckStats::mInstance = NULL;
DeckStat::DeckStat(int _nbgames, int _victories) : nbgames(_nbgames), victories(_victories)
{
}
int DeckStat::percentVictories()
{
if (nbgames == 0) return 50;
return (100 * victories / nbgames);
}
DeckStats * DeckStats::GetInstance()
{
if (!mInstance)
{
mInstance = NEW DeckStats();
}
return mInstance;
}
void DeckStats::cleanStats()
{
map<string, DeckStat *>::iterator it;
for (it = stats.begin(); it != stats.end(); it++)
{
SAFE_DELETE(it->second);
}
stats.clear();
}
DeckStats::~DeckStats()
{
cleanStats();
}
int DeckStats::percentVictories(string opponentsFile)
{
map<string, DeckStat *>::iterator it = stats.find(opponentsFile);
if (it == stats.end())
{
return 50;
}
else
{
return (it->second->percentVictories());
}
}
DeckStat* DeckStats::getDeckStat(string opponentsFile)
{
map<string, DeckStat *>::iterator it = stats.find(opponentsFile);
if (it == stats.end())
{
return NULL;
}
else
{
return it->second;
}
}
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)
{
char filename[512];
sprintf(filename, "stats/%s.txt", player->deckFileSmall.c_str());
load(options.profileFile(filename).c_str());
}
void DeckStats::load(const char * filename)
{
cleanStats();
std::ifstream file(filename);
std::string s;
if (file)
{
while (std::getline(file, s))
{
string deckfile = s;
std::getline(file, s);
int games = atoi(s.c_str());
std::getline(file, s);
int victories = atoi(s.c_str());
map<string, DeckStat *>::iterator it = stats.find(deckfile);
if (it == stats.end())
{
stats[deckfile] = NEW DeckStat(games, victories);
}
}
file.close();
}
}
void DeckStats::save(Player * player)
{
char filename[512];
sprintf(filename, "stats/%s.txt", player->deckFileSmall.c_str());
save(options.profileFile(filename).c_str());
}
void DeckStats::save(const char * filename)
{
std::ofstream file(filename);
char writer[512];
if (file)
{
map<string, DeckStat *>::iterator it;
for (it = stats.begin(); it != stats.end(); it++)
{
sprintf(writer, "%s\n", it->first.c_str());
file << writer;
sprintf(writer, "%i\n", it->second->nbgames);
file << writer;
sprintf(writer, "%i\n", it->second->victories);
file << writer;
}
file.close();
}
}
void DeckStats::saveStats(Player *player, Player *opponent, GameObserver * game)
{
int victory = 1;
if (!game->gameOver)
{
if (player->life == opponent->life) return;
if (player->life < opponent->life) victory = 0;
}
else if (game->gameOver == player)
{
victory = 0;
}
load(player);
map<string, DeckStat *>::iterator it = stats.find(opponent->deckFileSmall);
if (it == stats.end())
{
stats[opponent->deckFileSmall] = NEW DeckStat(1, victory);
}
else
{
it->second->victories += victory;
it->second->nbgames += 1;
}
save(player);
}
StatsWrapper::StatsWrapper(int deckId)
{
mDeckId = deckId;
char buffer[512];
sprintf(buffer, "stats/player_deck%i.txt", deckId);
string deckstats = options.profileFile(buffer);
initStatistics(deckstats);
}
StatsWrapper::StatsWrapper(string deckstats)
{
initStatistics(deckstats);
}
void StatsWrapper::initStatistics(string deckstats)
{
// Load deck statistics
DeckStats * stats = DeckStats::GetInstance();
aiDeckNames.clear();
aiDeckStats.clear();
if (fileExists(deckstats.c_str()))
{
stats->load(deckstats.c_str());
percentVictories = stats->percentVictories();
gamesPlayed = stats->nbGames();
// Detailed deck statistics against AI
int found = 1;
int nbDecks = 0;
found = 0;
char buffer[512];
char smallDeckName[512];
sprintf(buffer, "%s/deck%i.txt", RESPATH"/ai/baka", nbDecks + 1);
if (fileExists(buffer))
{
MTGDeck * mtgd = NEW MTGDeck(buffer, NULL, 1);
found = 1;
nbDecks++;
sprintf(smallDeckName, "%s_deck%i", "ai_baka", nbDecks);
DeckStat* deckStat = stats->getDeckStat(string(smallDeckName));
if ((deckStat != NULL) && (deckStat->nbgames > 0))
{
int percentVictories = stats->percentVictories(string(smallDeckName));
aiDeckNames.push_back(string(mtgd->meta_name));
aiDeckStats.push_back(deckStat);
}
delete mtgd;
}
}
else
{
gamesPlayed = 0;
percentVictories = 0;
}
}
void StatsWrapper::updateStats(string filename, MTGAllCards *collection)
{
if (fileExists(filename.c_str()))
{
MTGDeck * mtgd = NEW MTGDeck(filename.c_str(), collection);
DeckDataWrapper *deckDataWrapper = NEW DeckDataWrapper(mtgd);
updateStats(deckDataWrapper);
SAFE_DELETE( mtgd );
SAFE_DELETE( deckDataWrapper );
}
}
void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
{
if (!this->needUpdate || !myDeck) return;
this->needUpdate = false;
this->cardCount = myDeck->getCount(WSrcDeck::UNFILTERED_COPIES);
this->countLands = myDeck->getCount(Constants::MTG_COLOR_LAND);
this->totalPrice = myDeck->totalPrice();
this->countManaProducers = 0;
// Mana cost
int currentCount, convertedCost;
ManaCost * currentCost;
this->totalManaCost = 0;
this->totalCreatureCost = 0;
this->totalSpellCost = 0;
MTGCard * current = myDeck->getCard();
// Clearing arrays
for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++)
{
this->countCardsPerCost[i] = 0;
this->countCreaturesPerCost[i] = 0;
this->countSpellsPerCost[i] = 0;
}
for (int i = 0; i <= Constants::MTG_NB_COLORS; i++)
{
this->totalCostPerColor[i] = 0;
this->countLandsPerColor[i] = 0;
this->countBasicLandsPerColor[i] = 0;
this->countNonLandProducersPerColor[i] = 0;
}
for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++)
{
for (int k = 0; k <= Constants::MTG_NB_COLORS; k++)
{
this->countCardsPerCostAndColor[i][k] = 0;
this->countCreaturesPerCostAndColor[i][k] = 0;
this->countSpellsPerCostAndColor[i][k] = 0;
}
}
for (int ic = 0; ic < myDeck->Size(true); ic++)
{
current = myDeck->getCard(ic, true);
currentCost = current->data->getManaCost();
convertedCost = currentCost->getConvertedCost();
currentCount = myDeck->count(current);
// Add to the cards per cost counters
this->totalManaCost += convertedCost * currentCount;
if (convertedCost > Constants::STATS_MAX_MANA_COST)
{
convertedCost = Constants::STATS_MAX_MANA_COST;
}
this->countCardsPerCost[convertedCost] += currentCount;
if (current->data->isCreature())
{
this->countCreaturesPerCost[convertedCost] += currentCount;
this->totalCreatureCost += convertedCost * currentCount;
}
else if (current->data->isSpell())
{
this->countSpellsPerCost[convertedCost] += currentCount;
this->totalSpellCost += convertedCost * currentCount;
}
// Lets look for mana producing abilities
vector<string> abilitiesVector;
string thisstring = current->data->magicText;
abilitiesVector = split(thisstring, '\n');
for (int v = 0; v < (int) abilitiesVector.size(); v++)
{
string s = abilitiesVector[v];
size_t t = s.find("add");
if (t != string::npos)
{
s = s.substr(t + 3);
ManaCost * mc = ManaCost::parseManaCost(s);
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
{
if (mc->hasColor(j))
{
if (current->data->isLand())
{
if (current->data->hasType("Basic"))
{
this->countBasicLandsPerColor[j] += currentCount;
}
else
{
this->countLandsPerColor[j] += currentCount;
}
}
else
{
this->countNonLandProducersPerColor[j] += currentCount;
}
}
}
SAFE_DELETE(mc);
}
}
// Add to the per color counters
// a. regular costs
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
{
this->totalCostPerColor[j] += currentCost->getCost(j) * currentCount;
if (current->data->hasColor(j))
{
// Add to the per cost and color counter
this->countCardsPerCostAndColor[convertedCost][j] += currentCount;
if (current->data->isCreature())
{
this->countCreaturesPerCostAndColor[convertedCost][j] += currentCount;
}
else if (current->data->isSpell())
{
this->countSpellsPerCostAndColor[convertedCost][j] += currentCount;
}
}
}
// b. Hybrid costs
ManaCostHybrid * hybridCost;
int i;
i = 0;
while ((hybridCost = currentCost->getHybridCost(i++)) != NULL)
{
this->totalCostPerColor[hybridCost->color1] += hybridCost->value1 * currentCount;
this->totalCostPerColor[hybridCost->color2] += hybridCost->value2 * currentCount;
}
}
this->totalColoredSymbols = 0;
for (int j = 1; j < Constants::MTG_NB_COLORS; j++)
{
this->totalColoredSymbols += this->totalCostPerColor[j];
}
this->countCardsPerCost[0] -= this->countLands;
// Counts by type
this->countCreatures = countCardsByType("Creature", myDeck);
this->countInstants = countCardsByType("Instant", myDeck);
this->countEnchantments = countCardsByType("Enchantment", myDeck);
this->countSorceries = countCardsByType("Sorcery", myDeck);
this->countSpells = this->countInstants + this->countEnchantments + this->countSorceries;
//this->countArtifacts = countCardsByType("Artifact", myDeck);
// Average mana costs
this->avgManaCost = ((this->cardCount - this->countLands) <= 0) ? 0 : (float) this->totalManaCost / (this->cardCount
- this->countLands);
this->avgCreatureCost = (this->countCreatures <= 0) ? 0 : (float) this->totalCreatureCost / this->countCreatures;
this->avgSpellCost = (this->countSpells <= 0) ? 0 : (float) this->totalSpellCost / this->countSpells;
// Probabilities
// TODO: this could be optimized by reusing results
for (int i = 0; i < Constants::STATS_FOR_TURNS; i++)
{
this->noLandsProbInTurn[i] = noLuck(this->cardCount, this->countLands, 7 + i) * 100;
this->noCreaturesProbInTurn[i] = noLuck(this->cardCount, this->countCreatures, 7 + i) * 100;
}
}
// This should probably be cached in DeckDataWrapper
// or at least be calculated for all common types in one go
int StatsWrapper::countCardsByType(const char * _type, DeckDataWrapper * myDeck)
{
int result = 0;
for (int i = 0; i < myDeck->Size(true); i++)
{
MTGCard * current = myDeck->getCard(i, true);
if (current->data->hasType(_type))
{
result += myDeck->count(current);
}
}
return result;
}
// n cards total, a of them are of desired type (A), x drawn
// returns probability of no A's
float StatsWrapper::noLuck(int n, int a, int x)
{
if ((a >= n) || (a == 0)) return 1;
if ((n == 0) || (x == 0) || (x > n) || (n - a < x)) return 0;
a = n - a;
float result = 1;
for (int i = 0; i < x; i++)
result *= (float) (a - i) / (n - i);
return result;
}
StatsWrapper::~StatsWrapper()
{
aiDeckNames.clear();
aiDeckStats.clear();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,115 @@
/*
* SimplePopup.cpp
*
* Created on: Nov 18, 2010
* Author: Michael
*/
#include "PrecompiledHeader.h"
#include "SimplePopup.h"
#include "JTypes.h"
#include "GameApp.h"
#include "DeckStats.h"
#include "DeckManager.h"
#include <iomanip>
SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title, DeckMetaData* deckMetaData, MTGAllCards * collection) :
JGuiController(id, listener), mFontId(fontId), mCollection(collection)
{
mX = 35;
mY = 50;
mTitle = _title;
mMaxLines = 10;
mTextFont = resources.GetWFont(fontId);
this->mCount = 1;
stw = NULL;
Update(deckMetaData);
}
void SimplePopup::Render()
{
closed = false;
JRenderer *r = JRenderer::GetInstance();
string detailedInformation = getDetailedInformation(mDeckInformation->getFilename());
mTextFont->SetScale(0.85f);
const float textWidth = 183.0f;
const float textHeight = mTextFont->GetHeight() * 10;
r->DrawRoundRect(mX, mY, textWidth, textHeight, 2.0f, ARGB( 255, 125, 255, 0) );
r->FillRoundRect(mX, mY, textWidth, textHeight, 2.0f, ARGB( 255, 0, 0, 0 ) );
mTextFont->DrawString(detailedInformation.c_str(), mX + 20 , mY + 10);
}
void SimplePopup::Update(DeckMetaData* selectedDeck)
{
mDeckInformation = selectedDeck;
SAFE_DELETE(stw);
stw = NEW StatsWrapper(mDeckInformation->getDeckId());
stw->updateStats(mDeckInformation->getFilename(), mCollection);
}
string SimplePopup::getDetailedInformation(string filename)
{
ostringstream oss;
oss
<< "------- Deck Summary -----" << endl
<< "Cards: "<< stw->cardCount << endl
<< "Creatures: "<< setw(2) << stw->countCreatures
<< " Enchantments: " << stw->countEnchantments << endl
<< "Instants: " << setw(4) << stw->countInstants
<< " Sorceries: " << setw(2) << stw->countSorceries << endl
<< "Lands: "
<< "A: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] << " "
<< "G: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] + stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] << " "
<< "R: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_RED ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_RED ] << " "
<< "U: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLUE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLUE ] << " "
<< "B: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLACK ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLACK ] << " "
<< "W: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_WHITE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_WHITE ] << endl
<< " --- Mana Curve --- " << endl;
for ( int costIdx = 0; costIdx < 15; ++costIdx )
if ( stw->countCardsPerCost[ costIdx ] > 0 )
oss << costIdx << ": " << setw(2) << left << stw->countCardsPerCost[ costIdx ] << " ";
oss << endl;
oss
<< " --- Average Cost --- " << endl
<< "Creature: "<< setprecision(2) << stw->avgCreatureCost << endl
<< "Mana: " << setprecision(2) << stw->avgManaCost << " "
<< "Spell: " << setprecision(2) << stw->avgSpellCost << endl;
return oss.str();
}
void SimplePopup::Update(float dt)
{
JButton key = mEngine->ReadButton();
CheckUserInput(key);
}
void SimplePopup::Close()
{
closed = true;
mCount = 0;
}
SimplePopup::~SimplePopup(void)
{
mTextFont = NULL;
mDeckInformation = NULL;
SAFE_DELETE(stw);
}
void SimplePopup::drawHorzPole(float x, float y, float width)
{
}
void SimplePopup::drawVertPole(float x, float y, float height)
{
}

View File

@@ -837,6 +837,10 @@
RelativePath=".\src\SimplePad.cpp"
>
</File>
<File
RelativePath=".\src\SimplePopup.cpp"
>
</File>
<File
RelativePath=".\src\StoryFlow.cpp"
>
@@ -1254,6 +1258,10 @@
RelativePath=".\include\Rules.h"
>
</File>
<File
RelativePath=".\include\ShopItem.h"
>
</File>
<File
RelativePath=".\include\SimpleMenu.h"
>
@@ -1266,6 +1274,10 @@
RelativePath=".\include\SimplePad.h"
>
</File>
<File
RelativePath=".\include\SimplePopup.h"
>
</File>
<File
RelativePath=".\include\StoryFlow.h"
>