Revamped Deck Selection Screen using abrasax's design as a template.
TODO:
change literals to use constants,
refactor the rendering code for the menu to have be leaner.
add text scroller to list all the tasks.
* 1st implementation will list all the tasks.dat
* 2nd round will try to get the scroller to only display relevant tasks to ai
Special thanks to wololo and MootPoint for helping me hammer this out. To abrasax, for the initial design of the layout.
This commit is contained in:
53
projects/mtg/include/DeckMenu.h
Normal file
53
projects/mtg/include/DeckMenu.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
A class for very simple menus structure
|
||||
*/
|
||||
#ifndef _DeckMenu_H_
|
||||
#define _DeckMenu_H_
|
||||
|
||||
#include <string>
|
||||
#include <JGui.h>
|
||||
#include "WFont.h"
|
||||
#include "hge/hgeparticle.h"
|
||||
#include "DeckMetaData.h"
|
||||
|
||||
|
||||
class DeckMenu:public JGuiController{
|
||||
private:
|
||||
int mHeight, mWidth, mX, mY;
|
||||
int titleX, titleY, titleWidth;
|
||||
int descX, descY, descHeight, descWidth;
|
||||
int statsX, statsY, statsHeight, statsWidth;
|
||||
|
||||
int fontId;
|
||||
std::string title;
|
||||
int displaytitle;
|
||||
int maxItems, startId;
|
||||
float selectionT, selectionY;
|
||||
float timeOpen;
|
||||
static unsigned int refCount;
|
||||
|
||||
JQuad *background;
|
||||
JTexture *backgroundTexture;
|
||||
static WFont* titleFont;
|
||||
static hgeParticleSystem* stars;
|
||||
// This works only because of no multithreading
|
||||
static PIXEL_TYPE jewelGraphics[9];
|
||||
|
||||
inline void MogrifyJewel();
|
||||
|
||||
public:
|
||||
|
||||
bool autoTranslate;
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const char * _title = "");
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
void Close();
|
||||
|
||||
float selectionTargetY;
|
||||
bool closed;
|
||||
static void destroy();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
50
projects/mtg/include/DeckMenuItem.h
Normal file
50
projects/mtg/include/DeckMenuItem.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _DECKMENU_ITEM_H
|
||||
#define _DECKMENU_ITEM_H
|
||||
|
||||
#include <string>
|
||||
#include <JLBFont.h>
|
||||
#include <JGui.h>
|
||||
#include "DeckMenu.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
|
||||
|
||||
class DeckMenuItem: public JGuiObject
|
||||
{
|
||||
private:
|
||||
bool mHasFocus;
|
||||
DeckMenu* parent;
|
||||
int fontId;
|
||||
string mText;
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
|
||||
public:
|
||||
string imageFilename;
|
||||
string desc;
|
||||
DeckMetaData *meta;
|
||||
|
||||
DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, int x, int y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL);
|
||||
~DeckMenuItem();
|
||||
int mX;
|
||||
int mY;
|
||||
|
||||
void Relocate(int x, int y);
|
||||
int GetWidth();
|
||||
bool hasFocus();
|
||||
|
||||
void RenderWithOffset(float yOffset);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool ButtonPressed();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual bool getTopLeft(int& top, int& left) {top = mY; left = mX; return true;};
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,7 @@ private:
|
||||
string _desc;
|
||||
string _name;
|
||||
int _deckid;
|
||||
string _avatarFilename;
|
||||
|
||||
// statistical information
|
||||
|
||||
@@ -37,11 +38,15 @@ public:
|
||||
string getFilename();
|
||||
string getDescription();
|
||||
string getName();
|
||||
string getAvatarFilename();
|
||||
string getStatsSummary();
|
||||
|
||||
int getDeckId();
|
||||
int getGamesPlayed();
|
||||
int getVictories();
|
||||
int getVictoryPercentage();
|
||||
int getDifficulty();
|
||||
string getDifficultyString();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class JGE;
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "DeckMetaData.h"
|
||||
#include "DeckMenu.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -66,13 +67,19 @@ class GameState
|
||||
|
||||
// generate the Deck Meta Data and build the menu items of the menu given
|
||||
static vector<DeckMetaData *> fillDeckMenu(SimpleMenu * _menu, string path, string smallDeckPrefix = "", Player * statsPlayer = NULL);
|
||||
|
||||
// generate the Deck Meta Data and build the menu items of the menu given
|
||||
static vector<DeckMetaData *> fillDeckMenu(DeckMenu * _menu, string path, string smallDeckPrefix = "", Player * statsPlayer = NULL);
|
||||
|
||||
// build a vector of decks with the information passsed in.
|
||||
static vector<DeckMetaData *> getValidDeckMetaData(string path, string smallDeckPrefix = "", Player * statsPlayer = NULL);
|
||||
|
||||
// build menu items based on the vector<DeckMetaData *>
|
||||
static void renderDeckMenu(SimpleMenu * _menu, vector<DeckMetaData *> deckMetaDataList);
|
||||
|
||||
|
||||
// build menu items based on the vector<DeckMetaData *>
|
||||
static void renderDeckMenu(DeckMenu * _menu, vector<DeckMetaData *> deckMetaDataList);
|
||||
|
||||
};
|
||||
bool sortByName( DeckMetaData * d1, DeckMetaData * d2 );
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "DeckMenu.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "CardGui.h"
|
||||
#include "GameOptions.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "DeckMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
@@ -28,8 +29,8 @@ class GameStateDuel: public GameState, public JGuiListener
|
||||
Player * mPlayers[2];
|
||||
MTGPlayerCards * deck[2];
|
||||
GameObserver * game;
|
||||
SimpleMenu * deckmenu;
|
||||
SimpleMenu * opponentMenu;
|
||||
DeckMenu * deckmenu;
|
||||
DeckMenu * opponentMenu;
|
||||
SimpleMenu * menu;
|
||||
bool premadeDeck;
|
||||
int OpponentsDeckid;
|
||||
|
||||
Reference in New Issue
Block a user