Jeck - Some basic options handling rewrites, main menu update, example alternate theme (for testing). I'm closing issues 44 and 45, as hopefully this resolves them satisfactorily.
* The alternate theme is just useful for testing themes, but please comment on the changes to the main theme. * Options reading and initializing separated from UI. * Options UI abstracted a bit, made more easily extensible. * With some extension, the options UI could be used as the basis for more complicated themes, if we load a file and use it to do stuff like GameStateOptions::Start()
This commit is contained in:
@@ -16,12 +16,17 @@ using std::string;
|
||||
|
||||
#define INVALID_OPTION -1
|
||||
|
||||
//Note to self-- provide some form of options initialization.
|
||||
|
||||
class Options {
|
||||
public:
|
||||
friend class GameSettings;
|
||||
enum {
|
||||
//Global settings
|
||||
ACTIVE_PROFILE,
|
||||
DIFFICULTY_MODE_UNLOCKED,
|
||||
MOMIR_MODE_UNLOCKED,
|
||||
EVILTWIN_MODE_UNLOCKED,
|
||||
RANDOMDECK_MODE_UNLOCKED,
|
||||
LAST_GLOBAL = RANDOMDECK_MODE_UNLOCKED,
|
||||
//Values /must/ match ordering in optionNames, or everything loads wrong.
|
||||
//Profile settings
|
||||
ACTIVE_THEME,
|
||||
@@ -54,44 +59,6 @@ public:
|
||||
INTERRUPT_ENDTURN,
|
||||
INTERRUPT_CLEANUP,
|
||||
INTERRUPT_AFTEREND,
|
||||
//Global settings
|
||||
ACTIVE_PROFILE,
|
||||
DIFFICULTY_MODE_UNLOCKED,
|
||||
MOMIR_MODE_UNLOCKED,
|
||||
EVILTWIN_MODE_UNLOCKED,
|
||||
RANDOMDECK_MODE_UNLOCKED,
|
||||
//Theme metrics. These will be phased out fairly soon.
|
||||
THEME_METRICS, //Start of theme metrics.
|
||||
LOADING_TC = THEME_METRICS,
|
||||
STATS_TC,
|
||||
SCROLLER_TC,
|
||||
SCROLLER_FC,
|
||||
MAINMENU_TC,
|
||||
POPUP_MENU_FC,
|
||||
POPUP_MENU_TC,
|
||||
POPUP_MENU_TCH,
|
||||
MSG_FAIL_TC,
|
||||
OPTION_ITEM_FC,
|
||||
OPTION_ITEM_TC,
|
||||
OPTION_ITEM_TCH,
|
||||
OPTION_HEADER_FC,
|
||||
OPTION_HEADER_TC,
|
||||
OPTION_SCROLLBAR_FC,
|
||||
OPTION_SCROLLBAR_FCH,
|
||||
OPTION_TAB_FC,
|
||||
OPTION_TAB_FCH,
|
||||
OPTION_TAB_TC,
|
||||
OPTION_TAB_TCH,
|
||||
OPTION_TEXT_TC,
|
||||
OPTION_TEXT_FC,
|
||||
KEY_TC,
|
||||
KEY_TCH,
|
||||
KEY_FC,
|
||||
KEY_FCH,
|
||||
KEYPAD_FC,
|
||||
KEYPAD_FCH,
|
||||
KEYPAD_TC,
|
||||
|
||||
LAST_NAMED, //Any option after this does not look up in optionNames.
|
||||
SET_UNLOCKS = LAST_NAMED + 1, //For sets.
|
||||
};
|
||||
@@ -106,51 +73,19 @@ private:
|
||||
static const char* optionNames[];
|
||||
};
|
||||
|
||||
struct Metrics {
|
||||
//*_TC is text-color, *_TCH is highlighted text color
|
||||
//*_FC is fill-color, *_FCH is highlighted fill color
|
||||
//*_B and *_BH are for secondary text/fill colors, if needed
|
||||
//*_X, *_Y, *_W, *_H are x, y, width and height.
|
||||
enum {
|
||||
LOADING_TC = Options::THEME_METRICS,
|
||||
STATS_TC,
|
||||
SCROLLER_TC,
|
||||
SCROLLER_FC,
|
||||
MAINMENU_TC,
|
||||
POPUP_MENU_FC,
|
||||
POPUP_MENU_TC,
|
||||
POPUP_MENU_TCH,
|
||||
MSG_FAIL_TC,
|
||||
OPTION_ITEM_FC,
|
||||
OPTION_ITEM_TC,
|
||||
OPTION_ITEM_TCH,
|
||||
OPTION_HEADER_FC,
|
||||
OPTION_HEADER_TC,
|
||||
OPTION_SCROLLBAR_FC,
|
||||
OPTION_SCROLLBAR_FCH,
|
||||
OPTION_TAB_FC,
|
||||
OPTION_TAB_FCH,
|
||||
OPTION_TAB_TC,
|
||||
OPTION_TAB_TCH,
|
||||
OPTION_TEXT_TC,
|
||||
OPTION_TEXT_FC,
|
||||
KEY_TC,
|
||||
KEY_TCH,
|
||||
KEY_FC,
|
||||
KEY_FCH,
|
||||
KEYPAD_FC,
|
||||
KEYPAD_FCH,
|
||||
KEYPAD_TC,
|
||||
};
|
||||
};
|
||||
|
||||
class GameOption {
|
||||
public:
|
||||
virtual ~GameOption() {};
|
||||
int number;
|
||||
string str;
|
||||
//All calls to asColor should include a fallback color for people without a theme.
|
||||
PIXEL_TYPE asColor(PIXEL_TYPE fallback = ARGB(255,255,255,255));
|
||||
bool isDefault(); //Returns true when number is 0 abd string is "" or "Default"
|
||||
|
||||
virtual bool isDefault(); //Returns true when number is 0 and string is "" or "Default"
|
||||
virtual string menuStr(); //The string we'll use for GameStateOptions.
|
||||
virtual bool write(std::ofstream * file, string name);
|
||||
virtual bool read(string input);
|
||||
|
||||
GameOption(int value = 0);
|
||||
GameOption(string);
|
||||
GameOption(int, string);
|
||||
@@ -163,26 +98,68 @@ struct EnumDefinition {
|
||||
vector<assoc> values;
|
||||
};
|
||||
|
||||
class GameOptionEnum: public GameOption {
|
||||
public:
|
||||
virtual string menuStr();
|
||||
virtual bool write(std::ofstream * file, string name);
|
||||
virtual bool read(string input);
|
||||
EnumDefinition * def;
|
||||
};
|
||||
|
||||
class OptionVolume: public EnumDefinition{
|
||||
public:
|
||||
enum { MUTE = 0, MAX = 100 };
|
||||
static EnumDefinition * getInstance() {return &mDef;};
|
||||
private:
|
||||
OptionVolume();
|
||||
static OptionVolume mDef;
|
||||
};
|
||||
class OptionClosedHand: public EnumDefinition {
|
||||
public:
|
||||
enum { INVISIBLE = 0, VISIBLE = 1 };
|
||||
static EnumDefinition * getInstance() {return &mDef;};
|
||||
private:
|
||||
OptionClosedHand();
|
||||
static OptionClosedHand mDef;
|
||||
};
|
||||
class OptionHandDirection: public EnumDefinition {
|
||||
public:
|
||||
enum { VERTICAL = 0, HORIZONTAL = 1};
|
||||
static EnumDefinition * getInstance() {return &mDef;};
|
||||
private:
|
||||
OptionHandDirection();
|
||||
static OptionHandDirection mDef;
|
||||
};
|
||||
class OptionManaDisplay: public EnumDefinition {
|
||||
public:
|
||||
enum { DYNAMIC = 0, STATIC = 1, BOTH = 2};
|
||||
static EnumDefinition * getInstance() {return &mDef;};
|
||||
private:
|
||||
OptionManaDisplay();
|
||||
static OptionManaDisplay mDef;
|
||||
};
|
||||
class OptionDifficulty: public EnumDefinition {
|
||||
public:
|
||||
enum { NORMAL = 0, HARD = 1, HARDER = 2, EVIL = 3};
|
||||
static EnumDefinition * getInstance() {return &mDef;};
|
||||
private:
|
||||
OptionDifficulty();
|
||||
static OptionDifficulty mDef;
|
||||
};
|
||||
|
||||
class GameOptions {
|
||||
public:
|
||||
string mFilename;
|
||||
int save();
|
||||
int load();
|
||||
|
||||
GameOption * get(int);
|
||||
GameOption& operator[](int);
|
||||
GameOptions(string filename);
|
||||
~GameOptions();
|
||||
|
||||
private:
|
||||
bool load_option(int id, string input); //Sends an option to the proper reader.
|
||||
bool read_default(int id, string input);
|
||||
bool read_enum(int id, string input, EnumDefinition * def);
|
||||
|
||||
bool save_option(std::ofstream * file, int id, string name, GameOption * opt); //Sends an option to the proper writer.
|
||||
bool write_default(std::ofstream * file, string name, GameOption * opt);
|
||||
bool write_enum(std::ofstream * file, string name, GameOption * opt, EnumDefinition * def);
|
||||
|
||||
map<int,GameOption> values;
|
||||
vector<GameOption*> values;
|
||||
};
|
||||
|
||||
class GameSettings{
|
||||
@@ -210,10 +187,11 @@ public:
|
||||
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
|
||||
void createUsersFirstDeck(int setId);
|
||||
|
||||
GameOption * get(int);
|
||||
GameOption& operator[](int);
|
||||
|
||||
GameOptions* profileOptions;
|
||||
GameOptions* globalOptions;
|
||||
GameOptions* themeOptions;
|
||||
|
||||
static GameOption invalid_option;
|
||||
|
||||
@@ -224,4 +202,4 @@ private:
|
||||
|
||||
extern GameSettings options;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -18,10 +18,8 @@ class GameStateMenu: public GameState, public JGuiListener
|
||||
int hasChosenGameType;
|
||||
JQuad * mIcons[10];
|
||||
JTexture * bgTexture;
|
||||
JTexture * movingWTexture;
|
||||
JQuad * mBg;
|
||||
JQuad * mSplash;
|
||||
JQuad * mMovingW;
|
||||
float mCreditsYPos;
|
||||
int currentState;
|
||||
//JMusic * bgMusic;
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
|
||||
#define SHOW_OPTIONS 1
|
||||
#define SHOW_OPTIONS_MENU 2
|
||||
#define SHOW_OPTIONS_PROFILE 3
|
||||
|
||||
class GameApp;
|
||||
class OptionsMenu;
|
||||
class WGuiTabMenu;
|
||||
class SimpleMenu;
|
||||
class SimplePad;
|
||||
|
||||
@@ -17,13 +16,13 @@ class GameStateOptions: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
float timer;
|
||||
bool mReload;
|
||||
|
||||
public:
|
||||
SimpleMenu * optionsMenu;
|
||||
SimpleMenu * confirmMenu;
|
||||
OptionsMenu * optionsTabs;
|
||||
|
||||
WGuiTabMenu * optionsTabs;
|
||||
int mState;
|
||||
|
||||
GameStateOptions(GameApp* parent);
|
||||
virtual ~GameStateOptions();
|
||||
|
||||
@@ -33,8 +32,9 @@ private:
|
||||
virtual void Render();
|
||||
void ButtonPressed(int controllerId, int ControlId);
|
||||
|
||||
string newProfile;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+344
-173
@@ -14,37 +14,337 @@ using std::string;
|
||||
#define MAX_ONSCREEN_OPTIONS 8
|
||||
#define OPTION_CENTER 4
|
||||
|
||||
#define OPTIONS_SUBMODE_NORMAL 0
|
||||
#define OPTIONS_SUBMODE_RELOAD 1
|
||||
#define OPTIONS_SUBMODE_PROFILE 2
|
||||
#define OPTIONS_SUBMODE_MODE 3
|
||||
#define OPTIONS_SUBMODE_THEME 4
|
||||
|
||||
class OptionItem {
|
||||
class WGuiColor{
|
||||
public:
|
||||
string displayValue;
|
||||
int id;
|
||||
int hasFocus;
|
||||
bool canSelect;
|
||||
bool bHidden;
|
||||
enum {
|
||||
SCROLLBAR,
|
||||
SCROLLBUTTON,
|
||||
//Foregrounds only after this
|
||||
TEXT,
|
||||
TEXT_HEADER,
|
||||
TEXT_FAIL,
|
||||
TEXT_TAB,
|
||||
TEXT_BODY,
|
||||
//Backgrounds only after this
|
||||
BACK,
|
||||
BACK_HEADER,
|
||||
BACK_FAIL,
|
||||
BACK_TAB,
|
||||
};
|
||||
};
|
||||
|
||||
//Complete item interface
|
||||
class WGuiBase{
|
||||
public:
|
||||
WGuiBase() {};
|
||||
virtual ~WGuiBase() {};
|
||||
|
||||
virtual bool Selectable() {return true;};
|
||||
virtual bool isModal() {return false;};
|
||||
virtual bool Visible() {return true;};
|
||||
|
||||
virtual bool Changed() {return false;};
|
||||
virtual void confirmChange(bool confirmed) {};
|
||||
virtual PIXEL_TYPE getColor(int type)=0;
|
||||
|
||||
virtual void Entering(u32 key)=0;
|
||||
virtual bool Leaving(u32 key)=0;
|
||||
|
||||
virtual void Update(float dt)=0;
|
||||
virtual void updateValue(){};
|
||||
virtual void Render()=0;
|
||||
virtual void setData()=0;
|
||||
virtual void ButtonPressed(int controllerId, int controlId){};
|
||||
virtual void Reload(){};
|
||||
virtual void Overlay(){};
|
||||
|
||||
virtual bool hasFocus()=0;
|
||||
virtual void setFocus(bool bFocus)=0;
|
||||
virtual float getX()=0;
|
||||
virtual float getY()=0;
|
||||
virtual float getWidth()=0;
|
||||
virtual float getHeight()=0;
|
||||
virtual int getId() {return INVALID_ID;};
|
||||
virtual string getDisplay(){return "";};
|
||||
|
||||
virtual void setModal(bool val){};
|
||||
virtual void setDisplay(string s){};
|
||||
virtual void setX(float _x){};
|
||||
virtual void setY(float _y){};
|
||||
virtual void setWidth(float _w){};
|
||||
virtual void setHeight(float _h){};
|
||||
virtual void setId(int _id){};
|
||||
virtual void setHidden(bool bHidden) {};
|
||||
virtual void setVisible(bool bVisisble) {};
|
||||
};
|
||||
|
||||
//This is our base class for concrete items.
|
||||
class WGuiItem: public WGuiBase{
|
||||
public:
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
|
||||
WGuiItem(string _display);
|
||||
virtual ~WGuiItem() {};
|
||||
|
||||
|
||||
virtual PIXEL_TYPE getColor(int type);
|
||||
virtual void setData(){};
|
||||
|
||||
virtual bool hasFocus() {return mFocus;};
|
||||
virtual void setFocus(bool bFocus) {mFocus = bFocus;};
|
||||
|
||||
virtual string getDisplay(){return displayValue;};
|
||||
virtual void setDisplay(string s){displayValue=s;};
|
||||
|
||||
virtual int getId() {return INVALID_ID;};
|
||||
virtual float getX() {return x;};
|
||||
virtual float getY() {return y;};
|
||||
virtual float getWidth() {return width;};
|
||||
virtual float getHeight() {return height;};
|
||||
virtual void setId(int _id){};
|
||||
virtual void setX(float _x){x = _x;};
|
||||
virtual void setY(float _y){y = _y;};
|
||||
virtual void setWidth(float _w){width = _w;};
|
||||
virtual void setHeight(float _h){height = _h;};
|
||||
|
||||
protected:
|
||||
bool mFocus;
|
||||
float x, y;
|
||||
float width, height;
|
||||
virtual ostream& toString(ostream& out)const;
|
||||
string displayValue;
|
||||
};
|
||||
|
||||
class OptionItem: public WGuiItem{
|
||||
public:
|
||||
OptionItem( int _id, string _displayValue);
|
||||
virtual ~OptionItem() {};
|
||||
|
||||
virtual bool Selectable() {return (canSelect && !bHidden);};
|
||||
virtual void Entering();
|
||||
virtual bool Leaving();
|
||||
//Accessors
|
||||
virtual int getId() {return id;};
|
||||
virtual void setId(int _id){id = _id;};
|
||||
|
||||
protected:
|
||||
int id;
|
||||
};
|
||||
|
||||
//This is our base class for decorators. It wraps everything about WGuiBase.
|
||||
class WGuiDeco: public WGuiBase{
|
||||
public:
|
||||
WGuiDeco(WGuiBase* _it) {it = _it;};
|
||||
virtual ~WGuiDeco() {SAFE_DELETE(it);};
|
||||
|
||||
virtual bool Selectable() {return it->Selectable();};
|
||||
virtual bool Visible() {return it->Visible();};
|
||||
virtual bool Changed() {return it->Changed();};
|
||||
virtual void confirmChange(bool confirmed) {it->confirmChange(confirmed);};
|
||||
|
||||
virtual void Entering(u32 key) {it->Entering(key);};
|
||||
virtual bool Leaving(u32 key) {return it->Leaving(key);};
|
||||
virtual void Update(float dt) {it->Update(dt);};
|
||||
virtual void updateValue() {it->updateValue();};
|
||||
virtual void Reload() {it->Reload();};
|
||||
virtual void Overlay() {it->Overlay();};
|
||||
virtual void Render() {it->Render();};
|
||||
virtual void setData() {it->setData();};
|
||||
|
||||
virtual void ButtonPressed(int controllerId, int controlId) {it->ButtonPressed(controllerId, controlId);};
|
||||
|
||||
virtual bool hasFocus() {return it->hasFocus();};
|
||||
virtual string getDisplay() {return it->getDisplay();};
|
||||
virtual int getId() {return it->getId();};
|
||||
virtual float getX() {return it->getX();};
|
||||
virtual float getY() {return it->getY();};
|
||||
virtual float getWidth() {return it->getWidth();};
|
||||
virtual float getHeight() {return it->getHeight();};
|
||||
virtual PIXEL_TYPE getColor(int type) {return it->getColor(type);};
|
||||
|
||||
virtual void setFocus(bool bFocus) {it->setFocus(bFocus);};
|
||||
virtual void setDisplay(string s) {it->setDisplay(s);};
|
||||
virtual void setId(int _id) {it->setId(_id);};
|
||||
virtual void setX(float _x) {it->setX(_x);};
|
||||
virtual void setY(float _y) {it->setY(_y);};
|
||||
virtual void setWidth(float _w) {it->setWidth(_w);};
|
||||
virtual void setHeight(float _h) {it->setHeight(_h);};
|
||||
virtual void setHidden(bool bHidden) {it->setHidden(bHidden);};
|
||||
virtual void setVisible(bool bVisisble) {it->setVisible(bVisisble);};
|
||||
protected:
|
||||
WGuiBase * it;
|
||||
};
|
||||
|
||||
class WGuiSplit: public WGuiItem{
|
||||
public:
|
||||
WGuiSplit(WGuiBase* _left,WGuiBase* _right);
|
||||
~WGuiSplit();
|
||||
|
||||
virtual void Reload();
|
||||
virtual void Overlay();
|
||||
virtual void setData();
|
||||
virtual bool isModal();
|
||||
virtual void setModal(bool val);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual void updateValue()=0;
|
||||
virtual void Reload(){};
|
||||
virtual void Render()=0;
|
||||
virtual void setData()=0;
|
||||
virtual int Submode() {return OPTIONS_SUBMODE_NORMAL;};
|
||||
virtual void cancelSubmode() {};
|
||||
virtual void acceptSubmode() {};
|
||||
virtual void setX(float _x);
|
||||
virtual void setY(float _y);
|
||||
virtual void setWidth(float _w);
|
||||
virtual void setHeight(float _h);
|
||||
virtual float getHeight();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
virtual void confirmChange(bool confirmed);
|
||||
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(u32 key);
|
||||
|
||||
bool bRight;
|
||||
float percentRight;
|
||||
WGuiBase* right;
|
||||
WGuiBase* left;
|
||||
};
|
||||
|
||||
class WDecoConfirm: public WGuiDeco{
|
||||
public:
|
||||
WDecoConfirm(JGuiListener * _listener, WGuiBase * it);
|
||||
~WDecoConfirm();
|
||||
|
||||
virtual bool isModal();
|
||||
virtual void setData();
|
||||
virtual void setModal(bool val);
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual void Update(float dt);
|
||||
virtual void Overlay();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
|
||||
string confirm;
|
||||
string cancel;
|
||||
protected:
|
||||
enum {
|
||||
OP_UNCONFIRMED,
|
||||
OP_CONFIRMING,
|
||||
OP_CONFIRMED,
|
||||
} mState;
|
||||
SimpleMenu * confirmMenu;
|
||||
JGuiListener * listener;
|
||||
bool bModal;
|
||||
};
|
||||
|
||||
class WDecoEnum : public WGuiDeco {
|
||||
public:
|
||||
WDecoEnum(WGuiBase * _it,EnumDefinition *_edef = NULL);
|
||||
virtual void Render();
|
||||
string lookupVal(int value);
|
||||
protected:
|
||||
EnumDefinition * edef;
|
||||
};
|
||||
|
||||
class WGuiButton: public WGuiDeco{
|
||||
public:
|
||||
WGuiButton( WGuiBase* _it, int _controller, int _control, JGuiListener * jgl);
|
||||
virtual void updateValue();
|
||||
virtual void Update(float dt);
|
||||
virtual bool Selectable() {return Visible();};
|
||||
virtual PIXEL_TYPE getColor(int type);
|
||||
protected:
|
||||
int control, controller;
|
||||
JGuiListener * mListener;
|
||||
};
|
||||
|
||||
|
||||
class WGuiImage: public WGuiItem{
|
||||
public:
|
||||
WGuiImage(string _file, int _w, int _h, int _margin);
|
||||
virtual bool Selectable() {return false;};
|
||||
virtual JQuad * getImage();
|
||||
virtual void Render();
|
||||
virtual float getHeight();
|
||||
|
||||
protected:
|
||||
bool exact;
|
||||
int margin;
|
||||
int imgW, imgH;
|
||||
string filename;
|
||||
};
|
||||
|
||||
class WGuiText:public WGuiItem {
|
||||
public:
|
||||
WGuiText(string _displayValue): WGuiItem(_displayValue) {};
|
||||
virtual bool Selectable() {return false;};
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
class WGuiHeader:public WGuiItem{
|
||||
public:
|
||||
WGuiHeader(string _displayValue): WGuiItem(_displayValue) {};
|
||||
|
||||
virtual bool Selectable() {return false;};
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
|
||||
class WGuiList: public WGuiItem{
|
||||
public:
|
||||
WGuiList(string name);
|
||||
~WGuiList();
|
||||
|
||||
string failMsg;
|
||||
int nbitems;
|
||||
int current;
|
||||
|
||||
virtual bool hasFocus() {return mFocus;};
|
||||
virtual void setFocus(bool bFocus) {mFocus = bFocus;};
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual void Entering(u32 key);
|
||||
virtual void Render();
|
||||
virtual void renderBack(WGuiBase * it);
|
||||
virtual void Reload();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
virtual void Update(float dt);
|
||||
virtual void setData();
|
||||
virtual bool isModal();
|
||||
virtual void setModal(bool val);
|
||||
|
||||
void Add(WGuiBase * item);
|
||||
WGuiBase * Current();
|
||||
void nextOption();
|
||||
void prevOption();
|
||||
|
||||
WGuiBase * operator[](int);
|
||||
protected:
|
||||
bool mFocus;
|
||||
WGuiBase * listItems[MAX_OPTION_ITEMS];
|
||||
};
|
||||
|
||||
class WGuiMenu{
|
||||
public:
|
||||
|
||||
virtual ~WGuiMenu();
|
||||
WGuiMenu(u32 next, u32 prev);
|
||||
|
||||
virtual void Render();
|
||||
virtual void Reload();
|
||||
virtual void Update(float dt);
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
virtual void Add(WGuiBase* item);
|
||||
|
||||
WGuiBase * Current();
|
||||
void nextItem();
|
||||
void prevItem();
|
||||
void setData();
|
||||
|
||||
protected:
|
||||
u32 buttonNext, buttonPrev;
|
||||
vector<WGuiBase*> items;
|
||||
int currentItem;
|
||||
};
|
||||
|
||||
class WGuiTabMenu: public WGuiMenu {
|
||||
public:
|
||||
WGuiTabMenu() : WGuiMenu(PSP_CTRL_RTRIGGER,PSP_CTRL_LTRIGGER) {};
|
||||
virtual void Render();
|
||||
virtual void Add(WGuiBase * it);
|
||||
void save();
|
||||
};
|
||||
|
||||
class OptionInteger:public OptionItem{
|
||||
@@ -57,10 +357,10 @@ class OptionInteger:public OptionItem{
|
||||
OptionInteger(int _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "");
|
||||
|
||||
virtual void Reload() {if(id != INVALID_OPTION) value = options[id].number;};
|
||||
virtual bool Changed() {return value != options[id].number;};
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
class OptionString:public OptionItem{
|
||||
@@ -71,36 +371,11 @@ class OptionString:public OptionItem{
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
virtual void updateValue();
|
||||
virtual bool Changed() {return value != options[id].str;};
|
||||
virtual void Reload() {if(id != INVALID_OPTION) value = options[id].str;};
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
bool bShowValue;
|
||||
};
|
||||
|
||||
class OptionNewProfile:public OptionString{
|
||||
public:
|
||||
OptionNewProfile(string _displayValue) : OptionString(INVALID_OPTION, _displayValue) {bShowValue=false;};
|
||||
virtual void updateValue();
|
||||
virtual void Update(float dt);
|
||||
virtual int Submode();
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
class OptionHeader:public OptionItem{
|
||||
public:
|
||||
OptionHeader(string _displayValue): OptionItem(INVALID_OPTION, _displayValue) { canSelect=false;};
|
||||
virtual void Render();
|
||||
virtual void setData() {};
|
||||
virtual void updateValue() {};
|
||||
};
|
||||
|
||||
class OptionText:public OptionItem{
|
||||
public:
|
||||
OptionText(string _displayValue): OptionItem(INVALID_OPTION, _displayValue) { canSelect=false;};
|
||||
virtual void Render();
|
||||
virtual void setData() {};
|
||||
virtual void updateValue() {};
|
||||
};
|
||||
|
||||
class OptionSelect:public OptionItem{
|
||||
public:
|
||||
size_t value;
|
||||
@@ -110,13 +385,16 @@ class OptionSelect:public OptionItem{
|
||||
OptionSelect(int _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;};
|
||||
virtual void Reload(){initSelections();};
|
||||
virtual void Render();
|
||||
virtual bool Selectable();
|
||||
virtual void Entering(u32 key);
|
||||
virtual bool Changed() {return (value != prior_value);};
|
||||
virtual void setData();
|
||||
virtual void initSelections();
|
||||
virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;};
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
protected:
|
||||
size_t prior_value;
|
||||
};
|
||||
|
||||
|
||||
class OptionDirectory:public OptionSelect{
|
||||
public:
|
||||
virtual void Reload();
|
||||
@@ -128,138 +406,31 @@ private:
|
||||
class OptionTheme:public OptionDirectory{
|
||||
public:
|
||||
OptionTheme();
|
||||
};
|
||||
|
||||
class OptionVolume: public OptionInteger{
|
||||
public:
|
||||
OptionVolume(int _id, string _displayName, bool _bMusic = false);
|
||||
virtual void updateValue();
|
||||
private:
|
||||
bool bMusic;
|
||||
JQuad * getImage();
|
||||
virtual float getHeight();
|
||||
virtual void Render();
|
||||
virtual void confirmChange(bool confirmed);
|
||||
virtual bool Visible();
|
||||
};
|
||||
|
||||
class OptionProfile:public OptionDirectory{
|
||||
public:
|
||||
OptionProfile(GameApp * _app);
|
||||
~OptionProfile();
|
||||
OptionProfile(GameApp * _app, JGuiListener * jgl);
|
||||
virtual void addSelection(string s);
|
||||
virtual bool Leaving();
|
||||
virtual void Entering();
|
||||
virtual bool Selectable() {return canSelect;};
|
||||
virtual bool Changed() {return (initialValue != value);};
|
||||
virtual void Entering(u32 key);
|
||||
virtual void Reload();
|
||||
virtual void Render();
|
||||
virtual void confirmChange(bool confirmed);
|
||||
virtual void Update(float dt);
|
||||
virtual void updateValue();
|
||||
virtual int Submode();
|
||||
virtual void cancelSubmode();
|
||||
virtual void acceptSubmode();
|
||||
void populate();
|
||||
private:
|
||||
bool bCheck;
|
||||
JQuad * mAvatar;
|
||||
JTexture * mAvatarTex;
|
||||
GameApp * app;
|
||||
JGuiListener * listener;
|
||||
bool canSelect;
|
||||
string preview;
|
||||
size_t initialValue;
|
||||
};
|
||||
|
||||
class OptionsList{
|
||||
public:
|
||||
string sectionName;
|
||||
string failMsg;
|
||||
int nbitems;
|
||||
int current;
|
||||
OptionsList(string name);
|
||||
~OptionsList();
|
||||
bool Leaving();
|
||||
void Entering();
|
||||
void Render();
|
||||
void reloadValues();
|
||||
void Update(float dt);
|
||||
void Add(OptionItem * item);
|
||||
void save();
|
||||
int Submode();
|
||||
void acceptSubmode();
|
||||
void cancelSubmode();
|
||||
|
||||
OptionItem * operator[](int);
|
||||
private:
|
||||
OptionItem * listItems[MAX_OPTION_ITEMS];
|
||||
};
|
||||
|
||||
class OptionsMenu
|
||||
{
|
||||
public:
|
||||
JLBFont * mFont;
|
||||
OptionsList * tabs[MAX_OPTION_TABS];
|
||||
int nbitems;
|
||||
int current;
|
||||
|
||||
OptionsMenu();
|
||||
~OptionsMenu();
|
||||
|
||||
bool isTab(string name);
|
||||
int Submode();
|
||||
void acceptSubmode();
|
||||
void cancelSubmode();
|
||||
void Render();
|
||||
void reloadValues();
|
||||
void Update(float dt);
|
||||
void Add(OptionsList * tab);
|
||||
void save();
|
||||
|
||||
};
|
||||
|
||||
class OptionEnum : public OptionItem {
|
||||
protected:
|
||||
unsigned index;
|
||||
public:
|
||||
OptionEnum(int id, string displayValue);
|
||||
virtual void Reload();
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
virtual void updateValue();
|
||||
//ourDefined is a virtual wrapper for getDefinition()
|
||||
virtual EnumDefinition * ourDefined() const {return getDefinition();};
|
||||
|
||||
static EnumDefinition * getDefinition();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
class OptionClosedHand : public OptionEnum {
|
||||
public:
|
||||
friend class GameSettings;
|
||||
enum { INVISIBLE = 0, VISIBLE = 1 };
|
||||
OptionClosedHand(int id, string displayValue);
|
||||
|
||||
static EnumDefinition * getDefinition();
|
||||
EnumDefinition * ourDefined() const { return getDefinition();};
|
||||
|
||||
private:
|
||||
static EnumDefinition * definition;
|
||||
};
|
||||
class OptionHandDirection : public OptionEnum {
|
||||
public:
|
||||
friend class GameSettings;
|
||||
enum { VERTICAL = 0, HORIZONTAL = 1};
|
||||
OptionHandDirection(int id, string displayValue);
|
||||
|
||||
static EnumDefinition * getDefinition();
|
||||
EnumDefinition * ourDefined() const { return getDefinition();};
|
||||
|
||||
private:
|
||||
static EnumDefinition * definition;
|
||||
};
|
||||
|
||||
class OptionManaDisplay : public OptionEnum {
|
||||
public:
|
||||
friend class GameSettings;
|
||||
enum { DYNAMIC = 0, STATIC = 1, BOTH = 2};
|
||||
OptionManaDisplay(int id, string displayValue);
|
||||
|
||||
static EnumDefinition * getDefinition();
|
||||
EnumDefinition * ourDefined() const { return getDefinition();};
|
||||
|
||||
private:
|
||||
static EnumDefinition * definition;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -44,15 +44,16 @@ enum ENUM_RETRIEVE_STYLE{
|
||||
};
|
||||
|
||||
enum ENUM_CACHE_SUBTYPE{
|
||||
CACHE_NORMAL = (1<<0), //Use default values. Not really a flag.
|
||||
CACHE_NORMAL = (1<<0), //Use default values. Not really a flag.
|
||||
CACHE_EXISTING = (1<<1), //Retrieve it only if it already exists
|
||||
|
||||
//Because these bits only modify how a cached resource's Attempt() is called,
|
||||
//We can use them over and over for each resource type.
|
||||
TEXTURE_SUB_CARD = (1<<2), //Retrieve using cardFile, not graphicsFile.
|
||||
TEXTURE_SUB_AVATAR = (1<<5), //Retrieve using avatarFile, not graphicsFile.
|
||||
TEXTURE_SUB_THUMB = (1<<3),//Retrieve prepending "thumbnails\" to the filename.
|
||||
TEXTURE_SUB_5551 = (1<<4), //For textures. If we have to allocate, use RGBA5551.
|
||||
TEXTURE_SUB_EXACT = (1<<2), //Don't do any fiddling with the filename.
|
||||
TEXTURE_SUB_CARD = (1<<3), //Retrieve using cardFile, not graphicsFile.
|
||||
TEXTURE_SUB_AVATAR = (1<<4), //Retrieve using avatarFile, not graphicsFile.
|
||||
TEXTURE_SUB_THUMB = (1<<5),//Retrieve prepending "thumbnails\" to the filename.
|
||||
TEXTURE_SUB_5551 = (1<<6), //For textures. If we have to allocate, use RGBA5551.
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user