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()
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
BIN
projects/mtg/bin/Res/graphics/preview.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
projects/mtg/bin/Res/themes/Inverted/menuicons.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
projects/mtg/bin/Res/themes/Inverted/menutitle.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
projects/mtg/bin/Res/themes/Inverted/particle1.psi
Normal file
BIN
projects/mtg/bin/Res/themes/Inverted/particle2.psi
Normal file
BIN
projects/mtg/bin/Res/themes/Inverted/particle3.psi
Normal file
BIN
projects/mtg/bin/Res/themes/Inverted/particle4.psi
Normal file
BIN
projects/mtg/bin/Res/themes/Inverted/particle5.psi
Normal file
BIN
projects/mtg/bin/Res/themes/Inverted/preview.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
@@ -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
|
||||
@@ -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.
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ GameApp::GameApp(): JApp()
|
||||
nbUpdates = 0;
|
||||
totalFPS = 0;
|
||||
#endif
|
||||
|
||||
mScreenShotCount = 0;
|
||||
|
||||
for (int i=0; i < MAX_STATE ; i++)
|
||||
|
||||
@@ -10,6 +10,12 @@
|
||||
#include <JGE.h>
|
||||
|
||||
const char * Options::optionNames[] = {
|
||||
//Global options
|
||||
"Profile",
|
||||
"prx_handler",
|
||||
"prx_rimom",
|
||||
"prx_eviltwin",
|
||||
"prx_rnddeck",
|
||||
//Options set on a per-profile basis
|
||||
"Theme",
|
||||
"Mode",
|
||||
@@ -40,42 +46,6 @@ const char * Options::optionNames[] = {
|
||||
"interruptEndTurn",
|
||||
"interruptCleanup",
|
||||
"interruptAfterEnd",
|
||||
//Global options
|
||||
"_gProfile",
|
||||
"_gprx_handler",
|
||||
"_gprx_rimom",
|
||||
"_gprx_eviltwin",
|
||||
"_gprx_rnddeck",
|
||||
//Theme metrics
|
||||
"_tLoadingTC",
|
||||
"_tStatsTC",
|
||||
"_tScrollerTC",
|
||||
"_tScrollerFC",
|
||||
"_tMainMenuTC",
|
||||
"_tPopupMenuFC",
|
||||
"_tPopupMenuTC",
|
||||
"_tPopupMenuTCH",
|
||||
"_tMsgFailTC",
|
||||
"_tOptionItemFC",
|
||||
"_tOptionItemTC",
|
||||
"_tOptionItemTCH",
|
||||
"_tOptionHeaderFC",
|
||||
"_tOptionHeaderTC",
|
||||
"_tOptionScrollbarFC",
|
||||
"_tOptionScrollbarFCH",
|
||||
"_tOptionHeaderFC",
|
||||
"_tOptionHeaderFCH",
|
||||
"_tOptionTabTC",
|
||||
"_tOptionHeaderTCH",
|
||||
"_tOptionTextTC",
|
||||
"_tOptionTextFC",
|
||||
"_tKeyTC",
|
||||
"_tKeyTCH",
|
||||
"_tKeyFC",
|
||||
"_tKeyFCH",
|
||||
"_tKeypadFC",
|
||||
"_tKeypadFCH",
|
||||
"_tKeypadTC"
|
||||
};
|
||||
int Options::getID(string name){
|
||||
if(!name.size())
|
||||
@@ -184,39 +154,6 @@ int Options::optionInterrupt(int gamePhase){
|
||||
return INVALID_OPTION;
|
||||
}
|
||||
|
||||
//Theme metrics
|
||||
/*
|
||||
const string Metrics::LOADING_TC = "_tLoadingTC";
|
||||
const string Metrics::STATS_TC = "_tStatsTC";
|
||||
const string Metrics::SCROLLER_TC = "_tScrollerTC";
|
||||
const string Metrics::SCROLLER_FC = "_tScrollerFC";
|
||||
const string Metrics::MAINMENU_TC = "_tMainMenuTC";
|
||||
const string Metrics::POPUP_MENU_FC = "_tPopupMenuFC";
|
||||
const string Metrics::POPUP_MENU_TC = "_tPopupMenuTC";
|
||||
const string Metrics::POPUP_MENU_TCH = "_tPopupMenuTCH";
|
||||
const string Metrics::MSG_FAIL_TC = "_tMsgFailTC";
|
||||
const string Metrics::OPTION_ITEM_FC = "_tOptionItemFC";
|
||||
const string Metrics::OPTION_ITEM_TC = "_tOptionItemTC";
|
||||
const string Metrics::OPTION_ITEM_TCH = "_tOptionItemTCH";
|
||||
const string Metrics::OPTION_HEADER_FC = "_tOptionHeaderFC";
|
||||
const string Metrics::OPTION_HEADER_TC = "_tOptionHeaderTC";
|
||||
const string Metrics::OPTION_SCROLLBAR_FC = "_tOptionScrollbarFC";
|
||||
const string Metrics::OPTION_SCROLLBAR_FCH = "_tOptionScrollbarFCH";
|
||||
const string Metrics::OPTION_TAB_FC = "_tOptionHeaderFC";
|
||||
const string Metrics::OPTION_TAB_FCH = "_tOptionHeaderFCH";
|
||||
const string Metrics::OPTION_TAB_TC = "_tOptionTabTC";
|
||||
const string Metrics::OPTION_TAB_TCH = "_tOptionHeaderTCH";
|
||||
const string Metrics::OPTION_TEXT_TC = "_tOptionTextTC";
|
||||
const string Metrics::OPTION_TEXT_FC = "_tOptionTextFC";
|
||||
const string Metrics::KEY_TC = "_tKeyTC";
|
||||
const string Metrics::KEY_TCH = "_tKeyTCH";
|
||||
const string Metrics::KEY_FC = "_tKeyFC";
|
||||
const string Metrics::KEY_FCH = "_tKeyFCH";
|
||||
const string Metrics::KEYPAD_FC = "_tKeypadFC";
|
||||
const string Metrics::KEYPAD_FCH = "_tKeypadFCH";
|
||||
const string Metrics::KEYPAD_TC = "_tKeypadTC"; */
|
||||
|
||||
|
||||
GameOption::GameOption(int value) : number(value){}
|
||||
GameOption::GameOption(string value) : number(0), str(value) {}
|
||||
GameOption::GameOption(int num, string str) : number(num), str(str) {}
|
||||
@@ -267,16 +204,10 @@ PIXEL_TYPE GameOption::asColor(PIXEL_TYPE fallback)
|
||||
return ARGB(color[3],color[0],color[1],color[2]);
|
||||
}
|
||||
|
||||
GameOptions::GameOptions(string filename){
|
||||
mFilename = filename;
|
||||
load();
|
||||
}
|
||||
|
||||
bool GameOptions::read_default(int id, string input){
|
||||
bool GameOption::read(string input){
|
||||
bool bNumeric = true;
|
||||
|
||||
if(!input.size()){
|
||||
values[id] = GameOption(0);
|
||||
return true; //Default reader doesn't care about invalid formatting.
|
||||
}
|
||||
|
||||
@@ -289,41 +220,47 @@ bool GameOptions::read_default(int id, string input){
|
||||
}
|
||||
|
||||
if(bNumeric)
|
||||
values[id] = GameOption(atoi(input.c_str()));
|
||||
number = atoi(input.c_str());
|
||||
else
|
||||
values[id] = GameOption(input);
|
||||
|
||||
str = input;
|
||||
return true;
|
||||
}
|
||||
bool GameOptions::read_enum(int id, string input, EnumDefinition * def){
|
||||
if(!def)
|
||||
string GameOption::menuStr(){
|
||||
if(number){
|
||||
char buf[12];
|
||||
sprintf(buf,"%d",number);
|
||||
}
|
||||
|
||||
if(str.size())
|
||||
return str;
|
||||
|
||||
return "0";
|
||||
}
|
||||
bool GameOption::write(std::ofstream * file, string name){
|
||||
char writer[1024];
|
||||
|
||||
if(!file)
|
||||
return false;
|
||||
|
||||
std::transform(input.begin(),input.end(),input.begin(),::tolower);
|
||||
if(str ==""){
|
||||
if(number == 0) //This is absolutely default. No need to write it.
|
||||
return true;
|
||||
|
||||
vector<EnumDefinition::assoc>::iterator it;
|
||||
for(it=def->values.begin();it != def->values.end();it++){
|
||||
if(it->second == input){
|
||||
values[id] = GameOption(it->first);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//It's a number!
|
||||
sprintf(writer,"%s=%d\n", name.c_str(), number);
|
||||
}
|
||||
else
|
||||
sprintf(writer,"%s=%s\n", name.c_str(), str.c_str());
|
||||
|
||||
return false;
|
||||
(*file)<<writer;
|
||||
return true;
|
||||
}
|
||||
bool GameOptions::load_option(int id, string input){
|
||||
switch(id){
|
||||
case Options::HANDDIRECTION:
|
||||
return read_enum(id, input, OptionHandDirection::getDefinition());
|
||||
case Options::CLOSEDHAND:
|
||||
return read_enum(id, input, OptionClosedHand::getDefinition());
|
||||
case Options::MANADISPLAY:
|
||||
return read_enum(id, input, OptionManaDisplay::getDefinition());
|
||||
default:
|
||||
return read_default(id, input);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
GameOptions::GameOptions(string filename){
|
||||
mFilename = filename;
|
||||
values.reserve(Options::LAST_NAMED); //Reserve space for all named options.
|
||||
load();
|
||||
}
|
||||
|
||||
int GameOptions::load(){
|
||||
@@ -341,79 +278,25 @@ int GameOptions::load(){
|
||||
if(id == INVALID_OPTION)
|
||||
continue;
|
||||
|
||||
load_option(id,val);
|
||||
(*this)[id].read(val);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool GameOptions::save_option(std::ofstream * file, int id, string name, GameOption * opt){
|
||||
if(!opt)
|
||||
return false;
|
||||
|
||||
switch(id){
|
||||
case Options::HANDDIRECTION:
|
||||
return write_enum(file, name, opt, OptionHandDirection::getDefinition());
|
||||
case Options::CLOSEDHAND:
|
||||
return write_enum(file, name, opt, OptionClosedHand::getDefinition());
|
||||
case Options::MANADISPLAY:
|
||||
return write_enum(file, name, opt, OptionManaDisplay::getDefinition());
|
||||
default:
|
||||
return write_default(file, name, opt);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GameOptions::write_default(std::ofstream * file, string name, GameOption * opt){
|
||||
char writer[1024];
|
||||
|
||||
if(!file || !opt)
|
||||
return false;
|
||||
|
||||
if(opt->str ==""){
|
||||
if(opt->number == 0) //This is absolutely default. No need to write it.
|
||||
return true;
|
||||
|
||||
//It's a number!
|
||||
sprintf(writer,"%s=%d\n", name.c_str(), opt->number);
|
||||
}
|
||||
else
|
||||
sprintf(writer,"%s=%s\n", name.c_str(), opt->str.c_str());
|
||||
|
||||
(*file)<<writer;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameOptions::write_enum(std::ofstream * file, string name, GameOption * opt, EnumDefinition * def){
|
||||
|
||||
if(!file || !def || !opt)
|
||||
return false;
|
||||
|
||||
if(opt->number < 0 || opt->number >= (int) def->values.size())
|
||||
return false;
|
||||
|
||||
char writer[1024];
|
||||
sprintf(writer,"%s=%s\n", name.c_str(), def->values[opt->number].second.c_str());
|
||||
|
||||
(*file)<<writer;
|
||||
return true;
|
||||
}
|
||||
|
||||
int GameOptions::save(){
|
||||
std::ofstream file(mFilename.c_str());
|
||||
if (file){
|
||||
map<int, GameOption>::iterator it;
|
||||
for ( it=values.begin() ; it != values.end(); it++ ){
|
||||
for ( int x=0; x < (int) values.size(); x++ ){
|
||||
|
||||
//Check that this is a valid option.
|
||||
string name = Options::getName(it->first);
|
||||
if(!name.size())
|
||||
string name = Options::getName(x);
|
||||
GameOption * opt = get(x);
|
||||
if(!name.size() || !opt)
|
||||
continue;
|
||||
|
||||
//Save it.
|
||||
save_option(&file, it->first, name, &it->second);
|
||||
opt->write(&file, name);
|
||||
}
|
||||
|
||||
file.close();
|
||||
@@ -421,11 +304,58 @@ int GameOptions::save(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
GameOption& GameOptions::operator[](int optionID) {
|
||||
GameOption& GameOptions::operator[](int optionID){
|
||||
GameOption * go = get(optionID);
|
||||
if(!go)
|
||||
return GameSettings::invalid_option;
|
||||
|
||||
return *go;
|
||||
}
|
||||
|
||||
GameOption * GameOptions::get(int optionID) {
|
||||
GameOption * go = NULL;
|
||||
GameOptionEnum * goEnum = NULL;
|
||||
|
||||
//Invalid options!
|
||||
if(optionID < 0)
|
||||
return NULL;
|
||||
|
||||
//Option doesn't exist, so build it
|
||||
int x = (int) values.size();
|
||||
values.reserve(optionID);
|
||||
|
||||
while(x <= optionID){
|
||||
switch(optionID){
|
||||
case Options::HANDDIRECTION:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionHandDirection::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::CLOSEDHAND:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionClosedHand::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
case Options::MANADISPLAY:
|
||||
goEnum = NEW GameOptionEnum();
|
||||
goEnum->def = OptionManaDisplay::getInstance();
|
||||
go = goEnum;
|
||||
break;
|
||||
default:
|
||||
go = NEW GameOption();
|
||||
break;
|
||||
}
|
||||
values.push_back(go);
|
||||
x++;
|
||||
}
|
||||
|
||||
return values[optionID];
|
||||
}
|
||||
|
||||
GameOptions::~GameOptions(){
|
||||
for(vector<GameOption*>::iterator it=values.begin();it!=values.end();it++)
|
||||
SAFE_DELETE(*it);
|
||||
values.clear();
|
||||
}
|
||||
|
||||
GameSettings options;
|
||||
@@ -435,7 +365,6 @@ GameSettings::GameSettings()
|
||||
globalOptions = NULL;
|
||||
theGame = NULL;
|
||||
profileOptions = NULL;
|
||||
themeOptions = NULL;
|
||||
//reloadProfile should be before using options.
|
||||
}
|
||||
|
||||
@@ -443,41 +372,30 @@ GameSettings::~GameSettings(){
|
||||
//Destructor no longer saves, to prevent conflicts when MtgSets::SetsList == NULL
|
||||
SAFE_DELETE(globalOptions);
|
||||
SAFE_DELETE(profileOptions);
|
||||
SAFE_DELETE(themeOptions);
|
||||
SAFE_DELETE(keypad);
|
||||
SAFE_DELETE(OptionHandDirection::definition);
|
||||
SAFE_DELETE(OptionClosedHand::definition);
|
||||
SAFE_DELETE(OptionManaDisplay::definition);
|
||||
}
|
||||
|
||||
GameOption GameSettings::invalid_option = GameOption(0);
|
||||
|
||||
GameOption& GameSettings::operator[](int optionID){
|
||||
GameOption * go = get(optionID);
|
||||
if(!go)
|
||||
return invalid_option;
|
||||
|
||||
return *go;
|
||||
}
|
||||
|
||||
GameOption* GameSettings::get(int optionID){
|
||||
string option_name = Options::getName(optionID);
|
||||
|
||||
//Last chance sanity checking.
|
||||
if(!option_name.size()){
|
||||
OutputDebugString("Error: Accessing invalid option.\n");
|
||||
invalid_option.number = 0;
|
||||
invalid_option.str = "";
|
||||
return invalid_option;
|
||||
}
|
||||
if(optionID < 0)
|
||||
return &invalid_option;
|
||||
else if(globalOptions && optionID <= Options::LAST_GLOBAL)
|
||||
return globalOptions->get(optionID);
|
||||
else if(profileOptions)
|
||||
return profileOptions->get(optionID);
|
||||
|
||||
if(option_name.size() > 2){
|
||||
if(option_name[0] == '_' && option_name[1] == 't'){
|
||||
if(themeOptions)
|
||||
return (*themeOptions)[optionID];
|
||||
}
|
||||
else if(option_name[0] == '_' && option_name[1] == 'g'){
|
||||
if(globalOptions)
|
||||
return (*globalOptions)[optionID];
|
||||
}
|
||||
}
|
||||
|
||||
if(profileOptions)
|
||||
return (*profileOptions)[optionID];
|
||||
|
||||
return invalid_option;
|
||||
return &invalid_option;
|
||||
}
|
||||
|
||||
|
||||
@@ -543,31 +461,18 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
|
||||
|
||||
void GameSettings::reloadProfile(bool images){
|
||||
SAFE_DELETE(profileOptions);
|
||||
SAFE_DELETE(themeOptions);
|
||||
checkProfile();
|
||||
if(images)
|
||||
resources.Refresh(); //Update images
|
||||
}
|
||||
|
||||
void GameSettings::checkProfile(){
|
||||
char buf[512];
|
||||
|
||||
if(!globalOptions)
|
||||
globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
|
||||
|
||||
//If it doesn't exist, load current profile.
|
||||
if(!profileOptions)
|
||||
profileOptions = NEW GameOptions(profileFile(PLAYER_SETTINGS,"",false));
|
||||
|
||||
//Load theme options
|
||||
if(!themeOptions){
|
||||
if(!profileOptions || (*profileOptions)[Options::ACTIVE_THEME].isDefault())
|
||||
sprintf(buf,RESPATH"/graphics/metrics.txt");
|
||||
else
|
||||
sprintf(buf,RESPATH"/themes/%s/metrics.txt",(*profileOptions)[Options::ACTIVE_THEME].str.c_str());
|
||||
|
||||
themeOptions = NEW GameOptions(buf);
|
||||
}
|
||||
|
||||
//Validation of collection, etc, only happens if the game is up.
|
||||
if(theGame == NULL || theGame->collection == NULL)
|
||||
@@ -694,5 +599,74 @@ int EnumDefinition::findIndex(int value){
|
||||
return it - values.begin();
|
||||
}
|
||||
|
||||
return 0; //Default!
|
||||
return INVALID_ID; //Failed!
|
||||
}
|
||||
|
||||
string GameOptionEnum::menuStr(){
|
||||
if(def){
|
||||
int idx = def->findIndex(number);
|
||||
if(idx != INVALID_ID)
|
||||
return def->values[idx].second;
|
||||
}
|
||||
|
||||
char buf[32];
|
||||
sprintf(buf,"%d",number);
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool GameOptionEnum::write(std::ofstream * file, string name){
|
||||
if(!file || !def || number < 0 || number >= (int) def->values.size())
|
||||
return false;
|
||||
|
||||
char writer[1024];
|
||||
sprintf(writer,"%s=%s\n", name.c_str(), menuStr().c_str());
|
||||
|
||||
(*file)<<writer;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameOptionEnum::read(string input){
|
||||
if(!def)
|
||||
return false;
|
||||
|
||||
std::transform(input.begin(),input.end(),input.begin(),::tolower);
|
||||
|
||||
vector<EnumDefinition::assoc>::iterator it;
|
||||
for(it=def->values.begin();it != def->values.end();it++){
|
||||
if(it->second == input){
|
||||
number = it->first;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
OptionClosedHand OptionClosedHand::mDef;
|
||||
OptionClosedHand::OptionClosedHand(){
|
||||
mDef.values.push_back(EnumDefinition::assoc(INVISIBLE, "invisible"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(VISIBLE, "visible"));
|
||||
};
|
||||
|
||||
OptionHandDirection OptionHandDirection::mDef;
|
||||
OptionHandDirection::OptionHandDirection(){
|
||||
mDef.values.push_back(EnumDefinition::assoc(VERTICAL, "vertical"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(HORIZONTAL, "horizontal"));
|
||||
};
|
||||
OptionManaDisplay OptionManaDisplay::mDef;
|
||||
OptionManaDisplay::OptionManaDisplay(){
|
||||
mDef.values.push_back(EnumDefinition::assoc(STATIC, "Simple"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(DYNAMIC, "Eye candy"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(BOTH, "Both"));
|
||||
};
|
||||
OptionVolume OptionVolume::mDef;
|
||||
OptionVolume::OptionVolume(){
|
||||
mDef.values.push_back(EnumDefinition::assoc(MUTE, "Mute"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(MAX, "Max"));
|
||||
};
|
||||
OptionDifficulty OptionDifficulty::mDef;
|
||||
OptionDifficulty::OptionDifficulty(){
|
||||
mDef.values.push_back(EnumDefinition::assoc(NORMAL, "Normal"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(HARDER, "Harder"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(HARD, "Hard"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(EVIL, "Evil"));
|
||||
};
|
||||
@@ -66,7 +66,6 @@ GameStateMenu::GameStateMenu(GameApp* parent): GameState(parent)
|
||||
gameTypeMenu = NULL;
|
||||
mSplash = NULL;
|
||||
mBg = NULL;
|
||||
mMovingW = NULL;
|
||||
//bgMusic = NULL;
|
||||
timeIndex = 0;
|
||||
angleMultiplier = MIN_ANGLE_MULTIPLIER;
|
||||
@@ -81,6 +80,7 @@ GameStateMenu::~GameStateMenu() {}
|
||||
void GameStateMenu::Create()
|
||||
{
|
||||
mDip = NULL;
|
||||
mGuiController = NULL;
|
||||
mReadConf = 0;
|
||||
mCurrentSetName[0] = 0;
|
||||
|
||||
@@ -97,18 +97,6 @@ void GameStateMenu::Create()
|
||||
}
|
||||
}
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||
mFont->SetColor(options[Metrics::LOADING_TC].asColor());
|
||||
mGuiController = NEW JGuiController(100, this);
|
||||
if (mGuiController)
|
||||
{
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"graphics/particle1.psi",resources.GetQuad("particles"), true));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"graphics/particle2.psi",resources.GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"graphics/particle3.psi",resources.GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"graphics/particle4.psi",resources.GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"graphics/particle5.psi",resources.GetQuad("particles")));
|
||||
}
|
||||
|
||||
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_NONE;
|
||||
scroller = NEW TextScroller(resources.GetJLBFont(Constants::MAIN_FONT), SCREEN_WIDTH/2 - 90 , SCREEN_HEIGHT-17,180);
|
||||
scrollerSet = 0;
|
||||
@@ -122,13 +110,25 @@ void GameStateMenu::Destroy()
|
||||
SAFE_DELETE(subMenuController);
|
||||
SAFE_DELETE(gameTypeMenu);
|
||||
resources.Release(bgTexture);
|
||||
resources.Release(movingWTexture);
|
||||
SAFE_DELETE(scroller);
|
||||
}
|
||||
|
||||
void GameStateMenu::Start(){
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
subMenuController = NULL;
|
||||
SAFE_DELETE(mGuiController);
|
||||
mGuiController = NEW JGuiController(100, this);
|
||||
if (mGuiController)
|
||||
{
|
||||
JLBFont * mFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"particle1.psi",resources.GetQuad("particles"), true));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"particle2.psi",resources.GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"particle3.psi",resources.GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"particle4.psi",resources.GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"particle5.psi",resources.GetQuad("particles")));
|
||||
}
|
||||
|
||||
|
||||
if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
|
||||
GameApp::music = resources.ssLoadMusic("Track0.mp3");
|
||||
@@ -145,13 +145,9 @@ void GameStateMenu::Start(){
|
||||
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number) hasChosenGameType = 0;
|
||||
|
||||
bgTexture = resources.RetrieveTexture("menutitle.png", RETRIEVE_LOCK);
|
||||
movingWTexture = resources.RetrieveTexture("movingW.png", RETRIEVE_LOCK);
|
||||
mBg = resources.RetrieveQuad("menutitle.png", 0, 0, 256, 166); // Create background quad for rendering.
|
||||
mMovingW = resources.RetrieveQuad("movingW.png", 2, 2, 84, 62);
|
||||
|
||||
mBg->SetHotSpot(105,50);
|
||||
mMovingW->SetHotSpot(72,16);
|
||||
|
||||
mBg->SetHotSpot(128,50);
|
||||
|
||||
//How many cards total ?
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
@@ -274,18 +270,14 @@ void GameStateMenu::End()
|
||||
JRenderer::GetInstance()->EnableVSync(false);
|
||||
|
||||
resources.Release(bgTexture);
|
||||
resources.Release(movingWTexture);
|
||||
|
||||
|
||||
resources.Release(mBg);
|
||||
resources.Release(mMovingW);
|
||||
SAFE_DELETE(mGuiController);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GameStateMenu::Update(float dt)
|
||||
{
|
||||
|
||||
timeIndex += dt * 2;
|
||||
switch (MENU_STATE_MAJOR & currentState)
|
||||
{
|
||||
@@ -376,6 +368,13 @@ void GameStateMenu::Update(float dt)
|
||||
case MENU_STATE_MINOR_NONE :
|
||||
;// Nothing to do.
|
||||
}
|
||||
|
||||
if(mEngine->GetButtonState(PSP_CTRL_LTRIGGER)) {
|
||||
//Reset deck of cards
|
||||
angleMultiplier = MIN_ANGLE_MULTIPLIER;
|
||||
yW = 55;
|
||||
}
|
||||
|
||||
if (yW <= 55)
|
||||
{
|
||||
if (mEngine->GetButtonState(PSP_CTRL_SQUARE)) angleMultiplier += STEP_ANGLE_MULTIPLIER;
|
||||
@@ -386,7 +385,7 @@ void GameStateMenu::Update(float dt)
|
||||
if (mEngine->GetButtonState(PSP_CTRL_TRIANGLE) && (dt != 0))
|
||||
{
|
||||
angleMultiplier = (cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1 - angleW) / dt;
|
||||
yW = yW + 5*dt + (yW - 55) *5* dt;
|
||||
yW = yW + 5*dt + (yW - 45) *5* dt;
|
||||
}
|
||||
else
|
||||
angleW = cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1;
|
||||
@@ -422,29 +421,29 @@ void GameStateMenu::Render()
|
||||
}else{
|
||||
mFont = resources.GetJLBFont(Constants::MAIN_FONT);
|
||||
PIXEL_TYPE colors[] =
|
||||
{
|
||||
ARGB(255, 3, 2, 0),
|
||||
ARGB(255, 8, 3, 0),
|
||||
ARGB(255,21,12, 0),
|
||||
ARGB(255,50,34, 0)
|
||||
};
|
||||
{
|
||||
|
||||
ARGB(255,3,3,0),
|
||||
ARGB(255,8,8,0),
|
||||
ARGB(255,21,21,10),
|
||||
ARGB(255,50,50,30),
|
||||
};
|
||||
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
|
||||
|
||||
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
|
||||
renderer->RenderQuad(mBg, SCREEN_WIDTH/2, 50);
|
||||
if (yW < 2*SCREEN_HEIGHT) renderer->RenderQuad(mMovingW, SCREEN_WIDTH/2 - 10, yW, angleW);
|
||||
if (mGuiController!=NULL)
|
||||
mGuiController->Render();
|
||||
|
||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||
mFont->SetColor(options[Metrics::STATS_TC].asColor(ARGB(128,255,255,255)));
|
||||
mFont->SetColor(ARGB(128,255,255,255));
|
||||
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,5,JGETEXT_RIGHT);
|
||||
mFont->DrawString(nbcardsStr,10, 5);
|
||||
mFont->SetScale(1.f);
|
||||
mFont->SetColor(options[Metrics::SCROLLER_TC].asColor());
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
|
||||
renderer->FillRoundRect(SCREEN_WIDTH/2 - 100,SCREEN_HEIGHT-20, 191,6,5,options[Metrics::SCROLLER_FC].asColor(ARGB(100,10,5,0)));
|
||||
renderer->FillRoundRect(SCREEN_WIDTH/2 - 100,SCREEN_HEIGHT-20, 191,6,5,ARGB(100,10,5,0));
|
||||
scroller->Render();
|
||||
|
||||
renderer->RenderQuad(mBg, SCREEN_WIDTH/2, 50);
|
||||
if (subMenuController){
|
||||
subMenuController->Render();
|
||||
}
|
||||
@@ -569,9 +568,7 @@ ostream& GameStateMenu::toString(ostream& out) const
|
||||
<< " ; hasChosenGameType : " << hasChosenGameType
|
||||
<< " ; mIcons : " << mIcons
|
||||
<< " ; bgTexture : " << bgTexture
|
||||
<< " ; movingWTexture : " << movingWTexture
|
||||
<< " ; mBg : " << mBg
|
||||
<< " ; mMovingW : " << mMovingW
|
||||
<< " ; mCreditsYPos : " << mCreditsYPos
|
||||
<< " ; currentState : " << currentState
|
||||
<< " ; mVolume : " << mVolume
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent) {
|
||||
optionsTabs = NULL;
|
||||
optionsMenu = NULL;
|
||||
confirmMenu = NULL;
|
||||
mReload = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,57 +20,61 @@ GameStateOptions::~GameStateOptions() {
|
||||
|
||||
void GameStateOptions::Start()
|
||||
{
|
||||
newProfile = "";
|
||||
timer = 0;
|
||||
mState = SHOW_OPTIONS;
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
|
||||
OptionsList * optionsList;
|
||||
WGuiList * optionsList;
|
||||
|
||||
optionsList = NEW OptionsList("Settings");
|
||||
optionsList = NEW WGuiList("Settings");
|
||||
|
||||
optionsList->Add(NEW OptionHeader("General Options"));
|
||||
if (GameApp::HasMusic) optionsList->Add(NEW OptionVolume(Options::MUSICVOLUME, "Music volume", true));
|
||||
optionsList->Add(NEW OptionVolume(Options::SFXVOLUME, "SFX volume"));
|
||||
optionsList->Add(NEW WGuiHeader("General Options"));
|
||||
if (GameApp::HasMusic)
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::MUSICVOLUME,"Music volume",100,10,100),OptionVolume::getInstance()));
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::SFXVOLUME,"SFX volume",100,10,100),OptionVolume::getInstance()));
|
||||
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
|
||||
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
|
||||
optionsList->Add(NEW OptionInteger(Options::DIFFICULTY, "Difficulty", 3, 1));
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::DIFFICULTY,"Difficulty",3,1,0),OptionDifficulty::getInstance()));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYSPELLS, "Interrupt my spells"));
|
||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
|
||||
optionsTabs = NEW OptionsMenu();
|
||||
optionsTabs = NEW WGuiTabMenu();
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW OptionsList("Game");
|
||||
optionsList->Add(NEW OptionClosedHand(Options::CLOSEDHAND, "Closed hand"));
|
||||
optionsList->Add(NEW OptionHandDirection(Options::HANDDIRECTION, "Hand direction"));
|
||||
optionsList->Add(NEW OptionManaDisplay(Options::MANADISPLAY, "Mana display"));
|
||||
optionsList = NEW WGuiList("Game");
|
||||
optionsList->Add(NEW WGuiHeader("Interface Options"));
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::CLOSEDHAND,"Closed hand",2,1,0)));
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::CLOSEDHAND,"Hand direction",2,1,0)));
|
||||
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::MANADISPLAY,"Mana display",3,1,0)));
|
||||
optionsList->Add(NEW OptionInteger(Options::REVERSETRIGGERS, "Reverse left and right triggers"));
|
||||
optionsList->Add(NEW OptionInteger(Options::DISABLECARDS,"Disable card image loading"));
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsList = NEW OptionsList("Profiles");
|
||||
OptionNewProfile * key = NEW OptionNewProfile("New Profile");
|
||||
key->bShowValue = false;
|
||||
optionsList->Add(key);
|
||||
OptionProfile * pickProf = NEW OptionProfile(mParent);
|
||||
optionsList->Add(pickProf);
|
||||
OptionTheme * theme = NEW OptionTheme();
|
||||
optionsList->Add(theme);
|
||||
optionsList = NEW WGuiList("User");
|
||||
optionsList->Add(NEW WGuiHeader("User Options"));
|
||||
|
||||
WDecoConfirm * cPrf = NEW WDecoConfirm(this,NEW OptionProfile(mParent,this));
|
||||
cPrf->confirm = "Use this Profile";
|
||||
OptionDirectory * od = NEW OptionTheme();
|
||||
WDecoConfirm * cThm = NEW WDecoConfirm(this,od);
|
||||
cThm->confirm = "Use this Theme";
|
||||
|
||||
optionsList->Add(NEW WGuiSplit(cPrf,cThm));
|
||||
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"),-102,4,this));
|
||||
optionsTabs->Add(optionsList);
|
||||
optionsList = NEW OptionsList("Credits");
|
||||
|
||||
optionsList = NEW WGuiList("Credits");
|
||||
optionsList->failMsg = "";
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont("f3");
|
||||
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170);
|
||||
optionsMenu = NEW SimpleMenu(-102, this,mFont, 50,170);
|
||||
optionsMenu->Add(1, "Save & Back to Main Menu");
|
||||
optionsMenu->Add(2, "Back to Main Menu");
|
||||
optionsMenu->Add(3, "Cancel");
|
||||
|
||||
confirmMenu = NEW SimpleMenu(103, this,mFont, 50,170);
|
||||
confirmMenu->Add(1, "Use this profile");
|
||||
confirmMenu->Add(2, "Cancel");
|
||||
optionsTabs->Current()->Entering(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +83,6 @@ void GameStateOptions::End()
|
||||
JRenderer::GetInstance()->EnableVSync(false);
|
||||
SAFE_DELETE(optionsTabs);
|
||||
SAFE_DELETE(optionsMenu);
|
||||
SAFE_DELETE(confirmMenu);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,30 +92,29 @@ void GameStateOptions::Update(float dt)
|
||||
|
||||
if(options.keypadActive()){
|
||||
options.keypadUpdate(dt);
|
||||
}
|
||||
else if (mState == SHOW_OPTIONS){
|
||||
|
||||
switch(optionsTabs->Submode()){
|
||||
case OPTIONS_SUBMODE_RELOAD:
|
||||
optionsTabs->acceptSubmode();
|
||||
optionsTabs->reloadValues();
|
||||
mState = SHOW_OPTIONS;
|
||||
break;
|
||||
case OPTIONS_SUBMODE_PROFILE:
|
||||
mState = SHOW_OPTIONS_PROFILE;
|
||||
break;
|
||||
default:
|
||||
if (PSP_CTRL_START == mEngine->ReadButton() )
|
||||
mState = SHOW_OPTIONS_MENU;
|
||||
|
||||
optionsTabs->Update(dt);
|
||||
break;
|
||||
}
|
||||
|
||||
}else if(mState == SHOW_OPTIONS_MENU){
|
||||
optionsMenu->Update(dt);
|
||||
}else if(mState == SHOW_OPTIONS_PROFILE){
|
||||
confirmMenu->Update(dt);
|
||||
if(newProfile != ""){
|
||||
newProfile = options.keypadFinish();
|
||||
if(newProfile != ""){
|
||||
options[Options::ACTIVE_PROFILE] = newProfile;
|
||||
options.reloadProfile(false);
|
||||
optionsTabs->Reload();
|
||||
}
|
||||
newProfile = "";
|
||||
}
|
||||
}
|
||||
else switch(mState){
|
||||
default:
|
||||
case SHOW_OPTIONS:
|
||||
optionsTabs->Update(dt);
|
||||
|
||||
if (mEngine->ReadButton() == PSP_CTRL_START){
|
||||
mState = SHOW_OPTIONS_MENU;
|
||||
}
|
||||
break;
|
||||
case SHOW_OPTIONS_MENU:
|
||||
optionsMenu->Update(dt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,24 +163,22 @@ void GameStateOptions::Render()
|
||||
|
||||
optionsTabs->Render();
|
||||
|
||||
switch(mState){
|
||||
case SHOW_OPTIONS_MENU:
|
||||
optionsMenu->Render();
|
||||
break;
|
||||
case SHOW_OPTIONS_PROFILE:
|
||||
confirmMenu->Render();
|
||||
break;
|
||||
if(mReload){
|
||||
optionsTabs->Reload();
|
||||
mReload = false;
|
||||
}
|
||||
|
||||
if(mState == SHOW_OPTIONS_MENU)
|
||||
optionsMenu->Render();
|
||||
|
||||
if(options.keypadActive())
|
||||
options.keypadRender();
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
//Exit menu?
|
||||
if(controllerId == 102)
|
||||
if(controllerId == -102)
|
||||
switch (controlId){
|
||||
case 1:
|
||||
optionsTabs->save();
|
||||
@@ -188,22 +188,14 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
case 3:
|
||||
mState = SHOW_OPTIONS;
|
||||
break;
|
||||
}
|
||||
//Profile confirmation?
|
||||
else if(controllerId == 103)
|
||||
switch (controlId){
|
||||
case 1:
|
||||
//Load the New profile.
|
||||
optionsTabs->acceptSubmode();
|
||||
optionsTabs->reloadValues();
|
||||
//Reset the current settings to those of the profile...
|
||||
mState = SHOW_OPTIONS;
|
||||
case 4:
|
||||
options.keypadStart("",&newProfile);
|
||||
options.keypadTitle("New Profile");
|
||||
break;
|
||||
case 2:
|
||||
optionsTabs->cancelSubmode();
|
||||
mState = SHOW_OPTIONS;
|
||||
case 5:
|
||||
mReload = true;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
else
|
||||
optionsTabs->ButtonPressed(controllerId, controlId);
|
||||
};
|
||||
@@ -7,7 +7,7 @@ MenuItem::MenuItem(int id, JLBFont *font, string text, int x, int y, JQuad * _of
|
||||
{
|
||||
mText = _(text);
|
||||
updatedSinceLastRender = 1;
|
||||
mParticleSys = NEW hgeParticleSystem(particle, particleTex);
|
||||
mParticleSys = NEW hgeParticleSystem(resources.RetrievePSI(particle, particleTex));
|
||||
mParticleSys->MoveTo(mX, mY);
|
||||
|
||||
mHasFocus = hasFocus;
|
||||
@@ -27,14 +27,27 @@ void MenuItem::Render()
|
||||
{
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
|
||||
if (mHasFocus)
|
||||
{
|
||||
PIXEL_TYPE start = ARGB(46,255,255,200);
|
||||
if(mParticleSys)
|
||||
start = mParticleSys->info.colColorStart.GetHWColor();
|
||||
|
||||
PIXEL_TYPE colors[] =
|
||||
{
|
||||
ARGB(0,0,0,0),
|
||||
start,
|
||||
ARGB(0,0,0,0),
|
||||
start,
|
||||
};
|
||||
renderer->FillRect(255,0,SCREEN_WIDTH-155,SCREEN_HEIGHT,colors);
|
||||
// set additive blending
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
||||
mParticleSys->Render();
|
||||
// set normal blending
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||
mFont->SetColor(options[Metrics::MAINMENU_TC].asColor());
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
onQuad->SetColor(ARGB(70,255,255,255));
|
||||
renderer->RenderQuad(onQuad, SCREEN_WIDTH , SCREEN_HEIGHT/2 , 0,8,8);
|
||||
onQuad->SetColor(ARGB(255,255,255,255));
|
||||
|
||||
@@ -117,7 +117,7 @@ void SimpleMenu::Render() {
|
||||
float height = mHeight;
|
||||
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
|
||||
|
||||
renderer->FillRect(mX, mY, mWidth, height, options[Metrics::POPUP_MENU_FC].asColor(ARGB(180,0,0,0)));
|
||||
renderer->FillRect(mX, mY, mWidth, height, ARGB(180,0,0,0));
|
||||
|
||||
drawVertPole(mX, mY - 16, height + 32);
|
||||
drawVertPole(mX + mWidth, mY - 16, height + 32);
|
||||
@@ -135,9 +135,9 @@ void SimpleMenu::Render() {
|
||||
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7) {
|
||||
if (static_cast<SimpleMenuItem*>(mObjects[i])->hasFocus()){
|
||||
resources.GetJLBFont(Constants::MAIN_FONT)->DrawString(static_cast<SimpleMenuItem*>(mObjects[i])->desc.c_str(),mX+mWidth+10,mY+15);
|
||||
mFont->SetColor(options[Metrics::POPUP_MENU_TCH].asColor(ARGB(255,255,255,0)));
|
||||
mFont->SetColor(ARGB(255,255,255,0));
|
||||
} else {
|
||||
mFont->SetColor(options[Metrics::POPUP_MENU_TC].asColor(ARGB(150,255,255,255)));
|
||||
mFont->SetColor(ARGB(150,255,255,255));
|
||||
}
|
||||
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
|
||||
}
|
||||
|
||||
@@ -319,10 +319,10 @@ void SimplePad::Render(){
|
||||
if(bShowNumpad)
|
||||
offY += kH+14;
|
||||
//Draw Keypad Background.
|
||||
renderer->FillRoundRect(mX-kW,mY-kH,(kW+12)*11,(kH+14)*5+offY,2,options[Metrics::POPUP_MENU_FC].asColor(ARGB(180,0,0,0)));
|
||||
renderer->FillRoundRect(mX-kW,mY-kH,(kW+12)*11,(kH+14)*5+offY,2,ARGB(180,0,0,0));
|
||||
offY = vSpacing;
|
||||
//Draw text entry bubble
|
||||
renderer->FillRoundRect(mX-kW/2,mY+offY,(kW+12)*9+kW/2,kH,2,options[Metrics::KEYPAD_FCH].asColor(ARGB(255,255,255,255)));
|
||||
renderer->FillRoundRect(mX-kW/2,mY+offY,(kW+12)*9+kW/2,kH,2,ARGB(255,255,255,255));
|
||||
|
||||
//Draw text-entry title, if we've got one.
|
||||
if(title != ""){
|
||||
@@ -335,16 +335,16 @@ void SimplePad::Render(){
|
||||
{
|
||||
kW = mFont->GetStringWidth(buffer.substr(cursor,1).c_str());
|
||||
renderer->FillRoundRect(mX+mFont->GetStringWidth(buffer.substr(0,cursor).c_str()),mY+kH-4,
|
||||
kW,4,2,options[Metrics::KEY_FCH].asColor(ARGB(150,150,150,0)));
|
||||
kW,4,2,ARGB(150,150,150,0));
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor = buffer.size();
|
||||
renderer->FillRoundRect(mX+mFont->GetStringWidth(buffer.substr(0,cursor).c_str()),mY+kH-4,
|
||||
kW,4,2,options[Metrics::KEY_FCH].asColor(ARGB(150,150,150,0)));
|
||||
kW,4,2,ARGB(150,150,150,0));
|
||||
}
|
||||
|
||||
mFont->SetColor(options[Metrics::KEYPAD_TC].asColor(ARGB(255,0,0,0)));
|
||||
mFont->SetColor(ARGB(255,0,0,0));
|
||||
mFont->DrawString(buffer.c_str(),mX,mY);
|
||||
offY += kH + 12;
|
||||
|
||||
@@ -399,12 +399,12 @@ void SimplePad::Render(){
|
||||
kW = mFont->GetStringWidth(keys[x]->displayValue.c_str());
|
||||
//Render a key.
|
||||
if(x != selected){
|
||||
renderer->FillRoundRect(mX+offX-4,mY+offY-4,kW+8,kH+4,2,options[Metrics::POPUP_MENU_FC].asColor(ARGB(180,50,50,50)));
|
||||
mFont->SetColor(options[Metrics::POPUP_MENU_TCH].asColor(ARGB(255,255,255,0)));
|
||||
renderer->FillRoundRect(mX+offX-4,mY+offY-4,kW+8,kH+4,2,ARGB(180,50,50,50));
|
||||
mFont->SetColor(ARGB(255,255,255,0));
|
||||
}
|
||||
else{
|
||||
renderer->FillRoundRect(mX+offX-4,mY+offY-4,kW+8,kH+4,2,options[Metrics::POPUP_MENU_FC].asColor(ARGB(255,100,100,100)));
|
||||
mFont->SetColor(options[Metrics::POPUP_MENU_TC].asColor(ARGB(255,255,255,255)));
|
||||
renderer->FillRoundRect(mX+offX-4,mY+offY-4,kW+8,kH+4,2,ARGB(255,100,100,100));
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
|
||||
char vkey[2];
|
||||
|
||||
@@ -253,7 +253,9 @@ bool WCachedTexture::Attempt(string filename, int submode, int & error){
|
||||
string realname;
|
||||
|
||||
//Form correct filename.
|
||||
if(submode & TEXTURE_SUB_CARD){
|
||||
if(submode & TEXTURE_SUB_EXACT)
|
||||
realname = filename;
|
||||
else if(submode & TEXTURE_SUB_CARD){
|
||||
if(submode & TEXTURE_SUB_THUMB){
|
||||
for(string::size_type i= 0;i < filename.size();i++){
|
||||
if(filename[i] == '\\' || filename[i] == '/'){
|
||||
|
||||