Jeck - Profile loading fix, minor options menu improvements, minor cleanup.
This commit is contained in:
@@ -117,7 +117,8 @@ public:
|
|||||||
//The sanity=false option returns the adjusted path even if the file doesn't exist.
|
//The sanity=false option returns the adjusted path even if the file doesn't exist.
|
||||||
string profileFile(string filename="", string fallback="", bool sanity=true,bool relative=false);
|
string profileFile(string filename="", string fallback="", bool sanity=true,bool relative=false);
|
||||||
|
|
||||||
void checkProfile();
|
void reloadProfile(bool images = true); //Reloads profile using current options[ACTIVE_PROFILE]
|
||||||
|
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
|
||||||
void createUsersFirstDeck(int setId);
|
void createUsersFirstDeck(int setId);
|
||||||
|
|
||||||
GameOption& operator[](string);
|
GameOption& operator[](string);
|
||||||
|
|||||||
+209
-199
@@ -1,199 +1,209 @@
|
|||||||
#ifndef _OPTION_ITEM_H_
|
#ifndef _OPTION_ITEM_H_
|
||||||
#define _OPTION_ITEM_H_
|
#define _OPTION_ITEM_H_
|
||||||
|
|
||||||
#include <JGui.h>
|
#include <JGui.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
#define MAX_OPTION_TABS 5
|
#define MAX_OPTION_TABS 5
|
||||||
#define MAX_OPTION_ITEMS 20
|
#define MAX_OPTION_ITEMS 20
|
||||||
#define MAX_ONSCREEN_OPTIONS 8
|
#define MAX_ONSCREEN_OPTIONS 8
|
||||||
#define OPTION_CENTER 4
|
#define OPTION_CENTER 4
|
||||||
|
|
||||||
#define OPTIONS_SUBMODE_NORMAL 0
|
#define OPTIONS_SUBMODE_NORMAL 0
|
||||||
#define OPTIONS_SUBMODE_RELOAD 1
|
#define OPTIONS_SUBMODE_RELOAD 1
|
||||||
#define OPTIONS_SUBMODE_PROFILE 2
|
#define OPTIONS_SUBMODE_PROFILE 2
|
||||||
#define OPTIONS_SUBMODE_MODE 3
|
#define OPTIONS_SUBMODE_MODE 3
|
||||||
#define OPTIONS_SUBMODE_THEME 4
|
#define OPTIONS_SUBMODE_THEME 4
|
||||||
|
|
||||||
class OptionItem {
|
class OptionItem {
|
||||||
public:
|
public:
|
||||||
string displayValue, id;
|
string displayValue, id;
|
||||||
int hasFocus;
|
int hasFocus;
|
||||||
bool canSelect;
|
bool canSelect;
|
||||||
bool bHidden;
|
bool bHidden;
|
||||||
float x, y;
|
float x, y;
|
||||||
float width, height;
|
float width, height;
|
||||||
virtual ostream& toString(ostream& out)const;
|
virtual ostream& toString(ostream& out)const;
|
||||||
|
|
||||||
OptionItem( string _id, string _displayValue);
|
OptionItem( string _id, string _displayValue);
|
||||||
virtual ~OptionItem() {};
|
virtual ~OptionItem() {};
|
||||||
|
|
||||||
virtual bool Selectable() {return (canSelect && !bHidden);};
|
virtual bool Selectable() {return (canSelect && !bHidden);};
|
||||||
virtual void Entering();
|
virtual void Entering();
|
||||||
virtual bool Leaving();
|
virtual bool Leaving();
|
||||||
virtual void Update(float dt);
|
virtual void Update(float dt);
|
||||||
virtual void updateValue()=0;
|
virtual void updateValue()=0;
|
||||||
virtual void Reload(){};
|
virtual void Reload(){};
|
||||||
virtual void Render()=0;
|
virtual void Render()=0;
|
||||||
virtual void setData()=0;
|
virtual void setData()=0;
|
||||||
virtual int Submode() {return OPTIONS_SUBMODE_NORMAL;};
|
virtual int Submode() {return OPTIONS_SUBMODE_NORMAL;};
|
||||||
virtual void cancelSubmode() {};
|
virtual void cancelSubmode() {};
|
||||||
virtual void acceptSubmode() {};
|
virtual void acceptSubmode() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class OptionInteger:public OptionItem{
|
class OptionInteger:public OptionItem{
|
||||||
public:
|
public:
|
||||||
int value;
|
int value; //Current value.
|
||||||
int maxValue, increment;
|
int defValue; //Default value.
|
||||||
|
string strDefault; //What to call the default value.
|
||||||
OptionInteger(string _id, string _displayValue, int _maxValue = 1, int _increment = 1);
|
int maxValue, increment;
|
||||||
|
|
||||||
virtual void Reload() {if(id != "") value = options[id].number;};
|
OptionInteger(string _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "");
|
||||||
virtual void Render();
|
|
||||||
virtual void setData();
|
virtual void Reload() {if(id != "") value = options[id].number;};
|
||||||
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
|
virtual void Render();
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual void setData();
|
||||||
};
|
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
class OptionString:public OptionItem{
|
};
|
||||||
public:
|
|
||||||
string value;
|
class OptionString:public OptionItem{
|
||||||
OptionString(string _id, string _displayValue);
|
public:
|
||||||
|
string value;
|
||||||
virtual void Render();
|
OptionString(string _id, string _displayValue);
|
||||||
virtual void setData();
|
|
||||||
virtual void updateValue();
|
virtual void Render();
|
||||||
virtual void Reload() {if(id != "") value = options[id].str;};
|
virtual void setData();
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual void updateValue();
|
||||||
bool bShowValue;
|
virtual void Reload() {if(id != "") value = options[id].str;};
|
||||||
};
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
bool bShowValue;
|
||||||
class OptionNewProfile:public OptionString{
|
};
|
||||||
public:
|
|
||||||
OptionNewProfile(string _id, string _displayValue) : OptionString(_id, _displayValue) {bShowValue=false;};
|
class OptionNewProfile:public OptionString{
|
||||||
virtual void updateValue();
|
public:
|
||||||
virtual void Update(float dt);
|
OptionNewProfile(string _id, string _displayValue) : OptionString(_id, _displayValue) {bShowValue=false;};
|
||||||
virtual int Submode();
|
virtual void updateValue();
|
||||||
bool bChanged;
|
virtual void Update(float dt);
|
||||||
};
|
virtual int Submode();
|
||||||
|
bool bChanged;
|
||||||
class OptionHeader:public OptionItem{
|
};
|
||||||
public:
|
|
||||||
OptionHeader(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
class OptionHeader:public OptionItem{
|
||||||
virtual void Render();
|
public:
|
||||||
virtual void setData() {};
|
OptionHeader(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
||||||
virtual void updateValue() {};
|
virtual void Render();
|
||||||
};
|
virtual void setData() {};
|
||||||
|
virtual void updateValue() {};
|
||||||
class OptionText:public OptionItem{
|
};
|
||||||
public:
|
|
||||||
OptionText(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
class OptionText:public OptionItem{
|
||||||
virtual void Render();
|
public:
|
||||||
virtual void setData() {};
|
OptionText(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
||||||
virtual void updateValue() {};
|
virtual void Render();
|
||||||
};
|
virtual void setData() {};
|
||||||
|
virtual void updateValue() {};
|
||||||
class OptionSelect:public OptionItem{
|
};
|
||||||
public:
|
|
||||||
size_t value;
|
class OptionSelect:public OptionItem{
|
||||||
vector<string> selections;
|
public:
|
||||||
|
size_t value;
|
||||||
virtual void addSelection(string s);
|
vector<string> selections;
|
||||||
OptionSelect(string _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;};
|
|
||||||
virtual void Reload() {initSelections();};
|
virtual void addSelection(string s);
|
||||||
virtual void Render();
|
OptionSelect(string _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;};
|
||||||
virtual void setData();
|
virtual void Reload() {initSelections();};
|
||||||
virtual void initSelections();
|
virtual void Render();
|
||||||
virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;};
|
virtual void setData();
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual void initSelections();
|
||||||
};
|
virtual void updateValue(){value++; if (value > selections.size() - 1) value=0;};
|
||||||
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
};
|
||||||
class OptionDirectory:public OptionSelect{
|
|
||||||
public:
|
|
||||||
virtual void Reload();
|
class OptionDirectory:public OptionSelect{
|
||||||
OptionDirectory(string _root, string _id, string _displayValue);
|
public:
|
||||||
private:
|
virtual void Reload();
|
||||||
string root;
|
OptionDirectory(string _root, string _id, string _displayValue);
|
||||||
};
|
private:
|
||||||
|
string root;
|
||||||
class OptionTheme:public OptionDirectory{
|
};
|
||||||
public:
|
|
||||||
OptionTheme();
|
class OptionTheme:public OptionDirectory{
|
||||||
};
|
public:
|
||||||
|
OptionTheme();
|
||||||
class OptionProfile:public OptionDirectory{
|
};
|
||||||
public:
|
|
||||||
OptionProfile(GameApp * _app);
|
class OptionVolume: public OptionInteger{
|
||||||
~OptionProfile();
|
public:
|
||||||
virtual void addSelection(string s);
|
OptionVolume(string _id, string _displayName, bool _bMusic = false);
|
||||||
virtual bool Leaving();
|
virtual void updateValue();
|
||||||
virtual void Entering();
|
private:
|
||||||
virtual void Render();
|
bool bMusic;
|
||||||
virtual void Update(float dt);
|
};
|
||||||
virtual void updateValue();
|
|
||||||
virtual int Submode();
|
class OptionProfile:public OptionDirectory{
|
||||||
virtual void cancelSubmode();
|
public:
|
||||||
virtual void acceptSubmode();
|
OptionProfile(GameApp * _app);
|
||||||
void populate();
|
~OptionProfile();
|
||||||
private:
|
virtual void addSelection(string s);
|
||||||
bool bCheck;
|
virtual bool Leaving();
|
||||||
JQuad * mAvatar;
|
virtual void Entering();
|
||||||
JTexture * mAvatarTex;
|
virtual void Render();
|
||||||
GameApp * app;
|
virtual void Update(float dt);
|
||||||
string preview;
|
virtual void updateValue();
|
||||||
size_t initialValue;
|
virtual int Submode();
|
||||||
};
|
virtual void cancelSubmode();
|
||||||
|
virtual void acceptSubmode();
|
||||||
class OptionsList{
|
void populate();
|
||||||
public:
|
private:
|
||||||
string sectionName;
|
bool bCheck;
|
||||||
string failMsg;
|
JQuad * mAvatar;
|
||||||
int nbitems;
|
JTexture * mAvatarTex;
|
||||||
int current;
|
GameApp * app;
|
||||||
OptionsList(string name);
|
string preview;
|
||||||
~OptionsList();
|
size_t initialValue;
|
||||||
bool Leaving();
|
};
|
||||||
void Entering();
|
|
||||||
void Render();
|
class OptionsList{
|
||||||
void reloadValues();
|
public:
|
||||||
void Update(float dt);
|
string sectionName;
|
||||||
void Add(OptionItem * item);
|
string failMsg;
|
||||||
void save();
|
int nbitems;
|
||||||
int Submode();
|
int current;
|
||||||
void acceptSubmode();
|
OptionsList(string name);
|
||||||
void cancelSubmode();
|
~OptionsList();
|
||||||
|
bool Leaving();
|
||||||
OptionItem * operator[](int);
|
void Entering();
|
||||||
private:
|
void Render();
|
||||||
OptionItem * listItems[MAX_OPTION_ITEMS];
|
void reloadValues();
|
||||||
};
|
void Update(float dt);
|
||||||
|
void Add(OptionItem * item);
|
||||||
class OptionsMenu
|
void save();
|
||||||
{
|
int Submode();
|
||||||
public:
|
void acceptSubmode();
|
||||||
JLBFont * mFont;
|
void cancelSubmode();
|
||||||
OptionsList * tabs[MAX_OPTION_TABS];
|
|
||||||
int nbitems;
|
OptionItem * operator[](int);
|
||||||
int current;
|
private:
|
||||||
|
OptionItem * listItems[MAX_OPTION_ITEMS];
|
||||||
OptionsMenu();
|
};
|
||||||
~OptionsMenu();
|
|
||||||
|
class OptionsMenu
|
||||||
bool isTab(string name);
|
{
|
||||||
int Submode();
|
public:
|
||||||
void acceptSubmode();
|
JLBFont * mFont;
|
||||||
void cancelSubmode();
|
OptionsList * tabs[MAX_OPTION_TABS];
|
||||||
void Render();
|
int nbitems;
|
||||||
void reloadValues();
|
int current;
|
||||||
void Update(float dt);
|
|
||||||
void Add(OptionsList * tab);
|
OptionsMenu();
|
||||||
void save();
|
~OptionsMenu();
|
||||||
|
|
||||||
};
|
bool isTab(string name);
|
||||||
|
int Submode();
|
||||||
#endif
|
void acceptSubmode();
|
||||||
|
void cancelSubmode();
|
||||||
|
void Render();
|
||||||
|
void reloadValues();
|
||||||
|
void Update(float dt);
|
||||||
|
void Add(OptionsList * tab);
|
||||||
|
void save();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -43,6 +43,15 @@ GameApp::GameApp(): JApp()
|
|||||||
players[1] = 0;
|
players[1] = 0;
|
||||||
gameType = GAME_TYPE_CLASSIC;
|
gameType = GAME_TYPE_CLASSIC;
|
||||||
|
|
||||||
|
|
||||||
|
mCurrentState = NULL;
|
||||||
|
mNextState = NULL;
|
||||||
|
collection = NULL;
|
||||||
|
|
||||||
|
for(int i=0;i<6;i++)
|
||||||
|
Particles[i] = NULL;
|
||||||
|
|
||||||
|
music = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,6 +73,9 @@ void GameApp::Create()
|
|||||||
//Link this to our settings manager.
|
//Link this to our settings manager.
|
||||||
options.theGame = this;
|
options.theGame = this;
|
||||||
|
|
||||||
|
//Ensure that options are properly loaded before loading files.
|
||||||
|
options.reloadProfile();
|
||||||
|
|
||||||
//Test for Music files presence
|
//Test for Music files presence
|
||||||
string filepath = RESPATH;
|
string filepath = RESPATH;
|
||||||
filepath = filepath + "/" + resources.musicFile("Track0.mp3");
|
filepath = filepath + "/" + resources.musicFile("Track0.mp3");
|
||||||
@@ -200,7 +212,7 @@ void GameApp::Destroy()
|
|||||||
|
|
||||||
SimpleMenu::destroy();
|
SimpleMenu::destroy();
|
||||||
|
|
||||||
|
options.theGame = NULL;
|
||||||
LOG("==Destroying GameApp Successful==");
|
LOG("==Destroying GameApp Successful==");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,10 +187,10 @@ GameSettings::GameSettings()
|
|||||||
//Load global options
|
//Load global options
|
||||||
globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
|
globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
|
||||||
|
|
||||||
|
//reloadProfile should be called for the rest.
|
||||||
|
theGame = NULL;
|
||||||
profileOptions = NULL;
|
profileOptions = NULL;
|
||||||
themeOptions = NULL;
|
themeOptions = NULL;
|
||||||
|
|
||||||
checkProfile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSettings::~GameSettings(){
|
GameSettings::~GameSettings(){
|
||||||
@@ -220,8 +220,17 @@ int GameSettings::save(){
|
|||||||
if(globalOptions)
|
if(globalOptions)
|
||||||
globalOptions->save();
|
globalOptions->save();
|
||||||
|
|
||||||
if(profileOptions)
|
if(profileOptions){
|
||||||
|
//Force our directories to exist.
|
||||||
|
MAKEDIR(RESPATH"/profiles");
|
||||||
|
string temp = profileFile("","",false,false);
|
||||||
|
MAKEDIR(temp.c_str());
|
||||||
|
temp+="/stats";
|
||||||
|
MAKEDIR(temp.c_str());
|
||||||
|
temp = profileFile(PLAYER_SETTINGS,"",false);
|
||||||
|
|
||||||
profileOptions->save();
|
profileOptions->save();
|
||||||
|
}
|
||||||
|
|
||||||
checkProfile();
|
checkProfile();
|
||||||
|
|
||||||
@@ -267,39 +276,31 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameSettings::reloadProfile(bool images){
|
||||||
|
SAFE_DELETE(profileOptions);
|
||||||
|
SAFE_DELETE(themeOptions);
|
||||||
|
checkProfile();
|
||||||
|
if(images)
|
||||||
|
resources.Refresh(); //Update images
|
||||||
|
}
|
||||||
|
|
||||||
void GameSettings::checkProfile(){
|
void GameSettings::checkProfile(){
|
||||||
//Load current profile's options. Doesn't save prior set.
|
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
|
||||||
//Force our directories to exist.
|
//If it doesn't exist, load current profile.
|
||||||
MAKEDIR(RESPATH"/profiles");
|
if(!profileOptions)
|
||||||
string temp = profileFile("","",false,false);
|
profileOptions = NEW GameOptions(profileFile(PLAYER_SETTINGS,"",false));
|
||||||
MAKEDIR(temp.c_str());
|
|
||||||
temp+="/stats";
|
|
||||||
MAKEDIR(temp.c_str());
|
|
||||||
temp = profileFile(PLAYER_SETTINGS,"",false);
|
|
||||||
|
|
||||||
SAFE_DELETE(profileOptions);
|
|
||||||
profileOptions = NEW GameOptions(temp);
|
|
||||||
|
|
||||||
//Force a profile.
|
|
||||||
if((*profileOptions)[Options::ACTIVE_THEME].isDefault()){
|
|
||||||
temp = "Default";
|
|
||||||
(*profileOptions)[Options::ACTIVE_THEME].str = "Default";
|
|
||||||
}else{
|
|
||||||
temp = (*profileOptions)[Options::ACTIVE_THEME].str;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Load theme options
|
//Load theme options
|
||||||
if(temp == "Default")
|
if(!themeOptions){
|
||||||
sprintf(buf,RESPATH"/graphics/metrics.txt");
|
if(!profileOptions || (*profileOptions)[Options::ACTIVE_THEME].isDefault())
|
||||||
else{
|
sprintf(buf,RESPATH"/graphics/metrics.txt");
|
||||||
sprintf(buf,RESPATH"/themes/%s/metrics.txt",temp.c_str());
|
else
|
||||||
|
sprintf(buf,RESPATH"/themes/%s/metrics.txt",(*profileOptions)[Options::ACTIVE_THEME].str.c_str());
|
||||||
|
|
||||||
|
themeOptions = NEW GameOptions(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_DELETE(themeOptions);
|
|
||||||
themeOptions = NEW GameOptions(buf);
|
|
||||||
|
|
||||||
//Validation of collection, etc, only happens if the game is up.
|
//Validation of collection, etc, only happens if the game is up.
|
||||||
if(theGame == NULL || theGame->collection == NULL)
|
if(theGame == NULL || theGame->collection == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -309,7 +310,7 @@ void GameSettings::checkProfile(){
|
|||||||
{
|
{
|
||||||
//If we had any default settings, we'd set them here.
|
//If we had any default settings, we'd set them here.
|
||||||
|
|
||||||
//Give the player cards from the set for which we have the most variety
|
//Find the set for which we have the most variety
|
||||||
int setId = 0;
|
int setId = 0;
|
||||||
int maxcards = 0;
|
int maxcards = 0;
|
||||||
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
||||||
@@ -319,15 +320,17 @@ void GameSettings::checkProfile(){
|
|||||||
setId = i;
|
setId = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save this set as "unlocked"
|
//Save this set as "unlocked"
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
string s = MtgSets::SetsList->values[setId];
|
string s = MtgSets::SetsList->values[setId];
|
||||||
sprintf(buffer,"unlocked_%s", s.c_str());
|
sprintf(buffer,"unlocked_%s", s.c_str());
|
||||||
(*profileOptions)[buffer]=1;
|
(*profileOptions)[buffer]=1;
|
||||||
profileOptions->save();
|
profileOptions->save();
|
||||||
|
|
||||||
|
//Give the player their first deck
|
||||||
createUsersFirstDeck(setId);
|
createUsersFirstDeck(setId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSettings::createUsersFirstDeck(int setId){
|
void GameSettings::createUsersFirstDeck(int setId){
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
mReadConf = 1;
|
mReadConf = 1;
|
||||||
}
|
}
|
||||||
if (!nextDirectory(RESPATH"/sets/","_cards.dat")){
|
if (!nextDirectory(RESPATH"/sets/","_cards.dat")){
|
||||||
|
|
||||||
//Force default, if necessary.
|
//Force default, if necessary.
|
||||||
if(options[Options::ACTIVE_PROFILE].str == "")
|
if(options[Options::ACTIVE_PROFILE].str == "")
|
||||||
options[Options::ACTIVE_PROFILE].str = "Default";
|
options[Options::ACTIVE_PROFILE].str = "Default";
|
||||||
@@ -300,15 +301,8 @@ void GameStateMenu::Update(float dt)
|
|||||||
file.close();
|
file.close();
|
||||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
}else{
|
}else{
|
||||||
//check for first time player!
|
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
|
||||||
file.open(options.profileFile(PLAYER_COLLECTION,"",false).c_str());
|
}
|
||||||
if(file){
|
|
||||||
file.close();
|
|
||||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
|
||||||
}else{
|
|
||||||
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//List active profile and database size.
|
//List active profile and database size.
|
||||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||||
@@ -321,8 +315,8 @@ void GameStateMenu::Update(float dt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_FIRST_TIME :
|
case MENU_STATE_MAJOR_FIRST_TIME :
|
||||||
options.checkProfile();
|
|
||||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
|
options.checkProfile(); //Handles building a new deck, if needed.
|
||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_MAINMENU :
|
case MENU_STATE_MAJOR_MAINMENU :
|
||||||
if (!scrollerSet) fillScroller();
|
if (!scrollerSet) fillScroller();
|
||||||
|
|||||||
@@ -1,203 +1,203 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/GameStateOptions.h"
|
#include "../include/GameStateOptions.h"
|
||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/OptionItem.h"
|
#include "../include/OptionItem.h"
|
||||||
#include "../include/SimpleMenu.h"
|
#include "../include/SimpleMenu.h"
|
||||||
#include "../include/SimplePad.h"
|
#include "../include/SimplePad.h"
|
||||||
#include "../include/GameOptions.h"
|
#include "../include/GameOptions.h"
|
||||||
#include "../include/Translate.h"
|
#include "../include/Translate.h"
|
||||||
|
|
||||||
GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent) {
|
GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent) {
|
||||||
optionsTabs = NULL;
|
optionsTabs = NULL;
|
||||||
optionsMenu = NULL;
|
optionsMenu = NULL;
|
||||||
confirmMenu = NULL;
|
confirmMenu = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameStateOptions::~GameStateOptions() {
|
GameStateOptions::~GameStateOptions() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateOptions::Start()
|
void GameStateOptions::Start()
|
||||||
{
|
{
|
||||||
|
timer = 0;
|
||||||
timer = 0;
|
mState = SHOW_OPTIONS;
|
||||||
mState = SHOW_OPTIONS;
|
JRenderer::GetInstance()->ResetPrivateVRAM();
|
||||||
JRenderer::GetInstance()->ResetPrivateVRAM();
|
JRenderer::GetInstance()->EnableVSync(true);
|
||||||
JRenderer::GetInstance()->EnableVSync(true);
|
|
||||||
|
OptionsList * optionsList;
|
||||||
OptionsList * optionsList;
|
|
||||||
|
optionsList = NEW OptionsList("Settings");
|
||||||
optionsList = NEW OptionsList("Settings");
|
|
||||||
optionsList->Add(NEW OptionHeader("General Options"));
|
optionsList->Add(NEW OptionHeader("General Options"));
|
||||||
if (GameApp::HasMusic) optionsList->Add(NEW OptionInteger(Options::MUSICVOLUME, "Music volume", 100, 10));
|
if (GameApp::HasMusic) optionsList->Add(NEW OptionVolume(Options::MUSICVOLUME, "Music volume", true));
|
||||||
optionsList->Add(NEW OptionInteger(Options::SFXVOLUME, "SFX volume", 100, 10));
|
optionsList->Add(NEW OptionVolume(Options::SFXVOLUME, "SFX volume"));
|
||||||
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
|
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
|
||||||
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
|
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
|
||||||
optionsList->Add(NEW OptionInteger(Options::DIFFICULTY, "Difficulty", 3, 1));
|
optionsList->Add(NEW OptionInteger(Options::DIFFICULTY, "Difficulty", 3, 1));
|
||||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
|
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::INTERRUPTMYSPELLS, "Interrupt my spells"));
|
||||||
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
|
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
|
||||||
optionsList->Add(NEW OptionInteger(Options::CACHESIZE, "Image Cache Size", 60, 5));
|
optionsList->Add(NEW OptionInteger(Options::CACHESIZE, "Image Cache Size", 60, 5,0,"Default"));
|
||||||
optionsTabs = NEW OptionsMenu();
|
optionsTabs = NEW OptionsMenu();
|
||||||
optionsTabs->Add(optionsList);
|
optionsTabs->Add(optionsList);
|
||||||
|
|
||||||
optionsList = NEW OptionsList("Profiles");
|
optionsList = NEW OptionsList("Profiles");
|
||||||
OptionNewProfile * key = NEW OptionNewProfile("","New Profile");
|
OptionNewProfile * key = NEW OptionNewProfile("","New Profile");
|
||||||
key->bShowValue = false;
|
key->bShowValue = false;
|
||||||
optionsList->Add(key);
|
optionsList->Add(key);
|
||||||
OptionProfile * pickProf = NEW OptionProfile(mParent);
|
OptionProfile * pickProf = NEW OptionProfile(mParent);
|
||||||
optionsList->Add(pickProf);
|
optionsList->Add(pickProf);
|
||||||
OptionTheme * theme = NEW OptionTheme();
|
OptionTheme * theme = NEW OptionTheme();
|
||||||
optionsList->Add(theme);
|
optionsList->Add(theme);
|
||||||
|
|
||||||
optionsTabs->Add(optionsList);
|
optionsTabs->Add(optionsList);
|
||||||
optionsList = NEW OptionsList("Credits");
|
optionsList = NEW OptionsList("Credits");
|
||||||
optionsList->failMsg = "";
|
optionsList->failMsg = "";
|
||||||
optionsTabs->Add(optionsList);
|
optionsTabs->Add(optionsList);
|
||||||
|
|
||||||
JLBFont * mFont = resources.GetJLBFont("f3");
|
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(1, "Save & Back to Main Menu");
|
||||||
optionsMenu->Add(2, "Back to Main Menu");
|
optionsMenu->Add(2, "Back to Main Menu");
|
||||||
optionsMenu->Add(3, "Cancel");
|
optionsMenu->Add(3, "Cancel");
|
||||||
|
|
||||||
confirmMenu = NEW SimpleMenu(103, this,mFont, 50,170);
|
confirmMenu = NEW SimpleMenu(103, this,mFont, 50,170);
|
||||||
confirmMenu->Add(1, "Use this profile");
|
confirmMenu->Add(1, "Use this profile");
|
||||||
confirmMenu->Add(2, "Cancel");
|
confirmMenu->Add(2, "Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameStateOptions::End()
|
void GameStateOptions::End()
|
||||||
{
|
{
|
||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
SAFE_DELETE(optionsTabs);
|
SAFE_DELETE(optionsTabs);
|
||||||
SAFE_DELETE(optionsMenu);
|
SAFE_DELETE(optionsMenu);
|
||||||
SAFE_DELETE(confirmMenu);
|
SAFE_DELETE(confirmMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameStateOptions::Update(float dt)
|
void GameStateOptions::Update(float dt)
|
||||||
{
|
{
|
||||||
timer += dt;
|
timer += dt;
|
||||||
|
|
||||||
if(options.keypadActive()){
|
if(options.keypadActive()){
|
||||||
options.keypadUpdate(dt);
|
options.keypadUpdate(dt);
|
||||||
}
|
}
|
||||||
else if (mState == SHOW_OPTIONS){
|
else if (mState == SHOW_OPTIONS){
|
||||||
|
|
||||||
switch(optionsTabs->Submode()){
|
switch(optionsTabs->Submode()){
|
||||||
case OPTIONS_SUBMODE_RELOAD:
|
case OPTIONS_SUBMODE_RELOAD:
|
||||||
optionsTabs->acceptSubmode();
|
optionsTabs->acceptSubmode();
|
||||||
optionsTabs->reloadValues();
|
optionsTabs->reloadValues();
|
||||||
mState = SHOW_OPTIONS;
|
mState = SHOW_OPTIONS;
|
||||||
break;
|
break;
|
||||||
case OPTIONS_SUBMODE_PROFILE:
|
case OPTIONS_SUBMODE_PROFILE:
|
||||||
mState = SHOW_OPTIONS_PROFILE;
|
mState = SHOW_OPTIONS_PROFILE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (PSP_CTRL_START == mEngine->ReadButton() )
|
if (PSP_CTRL_START == mEngine->ReadButton() )
|
||||||
mState = SHOW_OPTIONS_MENU;
|
mState = SHOW_OPTIONS_MENU;
|
||||||
|
|
||||||
optionsTabs->Update(dt);
|
optionsTabs->Update(dt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(mState == SHOW_OPTIONS_MENU){
|
}else if(mState == SHOW_OPTIONS_MENU){
|
||||||
optionsMenu->Update(dt);
|
optionsMenu->Update(dt);
|
||||||
}else if(mState == SHOW_OPTIONS_PROFILE){
|
}else if(mState == SHOW_OPTIONS_PROFILE){
|
||||||
confirmMenu->Update(dt);
|
confirmMenu->Update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateOptions::Render()
|
void GameStateOptions::Render()
|
||||||
{
|
{
|
||||||
//Erase
|
//Erase
|
||||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
||||||
|
|
||||||
const char * const CreditsText[] = {
|
const char * const CreditsText[] = {
|
||||||
"Wagic, The Homebrew?! by WilLoW",
|
"Wagic, The Homebrew?! by WilLoW",
|
||||||
"",
|
"",
|
||||||
"updates, new cards, and more on http://wololo.net/wagic",
|
"updates, new cards, and more on http://wololo.net/wagic",
|
||||||
"Many thanks to the devs and card creators who help this project",
|
"Many thanks to the devs and card creators who help this project",
|
||||||
"",
|
"",
|
||||||
"Developped with the JGE++ Library (http://jge.khors.com)",
|
"Developped with the JGE++ Library (http://jge.khors.com)",
|
||||||
"Player's avatar from http://mathieuchoinet.blogspot.com, under CC License",
|
"Player's avatar from http://mathieuchoinet.blogspot.com, under CC License",
|
||||||
"Background picture and some art from the KDE project, www.kde.org",
|
"Background picture and some art from the KDE project, www.kde.org",
|
||||||
"SFX From www.soundsnap.com",
|
"SFX From www.soundsnap.com",
|
||||||
"",
|
"",
|
||||||
"Music by Celestial Aeon Project, http://www.jamendo.com",
|
"Music by Celestial Aeon Project, http://www.jamendo.com",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"This work is not related to or endorsed by Wizards of the Coast, Inc",
|
"This work is not related to or endorsed by Wizards of the Coast, Inc",
|
||||||
"",
|
"",
|
||||||
"Please support this project with donations at http://wololo.net/wagic",
|
"Please support this project with donations at http://wololo.net/wagic",
|
||||||
};
|
};
|
||||||
|
|
||||||
JLBFont * mFont = resources.GetJLBFont("magic");
|
JLBFont * mFont = resources.GetJLBFont("magic");
|
||||||
mFont->SetColor(ARGB(255,200,200,200));
|
mFont->SetColor(ARGB(255,200,200,200));
|
||||||
mFont->SetScale(1.0);
|
mFont->SetScale(1.0);
|
||||||
float startpos = 272 - timer * 10;
|
float startpos = 272 - timer * 10;
|
||||||
float pos = startpos;
|
float pos = startpos;
|
||||||
int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
|
int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
|
||||||
|
|
||||||
for (int i = 0; i < size; i++){
|
for (int i = 0; i < size; i++){
|
||||||
pos = startpos +20*i;
|
pos = startpos +20*i;
|
||||||
if (pos > -20){
|
if (pos > -20){
|
||||||
mFont->DrawString(_(CreditsText[i]).c_str(),SCREEN_WIDTH/2,pos ,JGETEXT_CENTER);
|
mFont->DrawString(_(CreditsText[i]).c_str(),SCREEN_WIDTH/2,pos ,JGETEXT_CENTER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos < -20)
|
if (pos < -20)
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
|
||||||
mFont->SetScale(1.f);
|
mFont->SetScale(1.f);
|
||||||
|
|
||||||
optionsTabs->Render();
|
optionsTabs->Render();
|
||||||
|
|
||||||
switch(mState){
|
switch(mState){
|
||||||
case SHOW_OPTIONS_MENU:
|
case SHOW_OPTIONS_MENU:
|
||||||
optionsMenu->Render();
|
optionsMenu->Render();
|
||||||
break;
|
break;
|
||||||
case SHOW_OPTIONS_PROFILE:
|
case SHOW_OPTIONS_PROFILE:
|
||||||
confirmMenu->Render();
|
confirmMenu->Render();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.keypadActive())
|
if(options.keypadActive())
|
||||||
options.keypadRender();
|
options.keypadRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||||
{
|
{
|
||||||
//Exit menu?
|
//Exit menu?
|
||||||
if(controllerId == 102)
|
if(controllerId == 102)
|
||||||
switch (controlId){
|
switch (controlId){
|
||||||
case 1:
|
case 1:
|
||||||
optionsTabs->save();
|
optionsTabs->save();
|
||||||
case 2:
|
case 2:
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
mParent->SetNextState(GAME_STATE_MENU);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mState = SHOW_OPTIONS;
|
mState = SHOW_OPTIONS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Profile confirmation?
|
//Profile confirmation?
|
||||||
else if(controllerId == 103)
|
else if(controllerId == 103)
|
||||||
switch (controlId){
|
switch (controlId){
|
||||||
case 1:
|
case 1:
|
||||||
//Load the New profile.
|
//Load the New profile.
|
||||||
optionsTabs->acceptSubmode();
|
optionsTabs->acceptSubmode();
|
||||||
optionsTabs->reloadValues();
|
optionsTabs->reloadValues();
|
||||||
//Reset the current settings to those of the profile...
|
//Reset the current settings to those of the profile...
|
||||||
mState = SHOW_OPTIONS;
|
mState = SHOW_OPTIONS;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
optionsTabs->cancelSubmode();
|
optionsTabs->cancelSubmode();
|
||||||
mState = SHOW_OPTIONS;
|
mState = SHOW_OPTIONS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+812
-799
File diff suppressed because it is too large
Load Diff
@@ -935,10 +935,6 @@ int WResourceManager::CreateTexture(const string &textureName) {
|
|||||||
mTextureList.push_back(tex);
|
mTextureList.push_back(tex);
|
||||||
mTextureMap[textureName] = id;
|
mTextureMap[textureName] = id;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user