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.
|
||||
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);
|
||||
|
||||
GameOption& operator[](string);
|
||||
|
||||
@@ -1,199 +1,209 @@
|
||||
#ifndef _OPTION_ITEM_H_
|
||||
#define _OPTION_ITEM_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "../include/GameApp.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
#define MAX_OPTION_TABS 5
|
||||
#define MAX_OPTION_ITEMS 20
|
||||
#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 {
|
||||
public:
|
||||
string displayValue, id;
|
||||
int hasFocus;
|
||||
bool canSelect;
|
||||
bool bHidden;
|
||||
float x, y;
|
||||
float width, height;
|
||||
virtual ostream& toString(ostream& out)const;
|
||||
|
||||
OptionItem( string _id, string _displayValue);
|
||||
virtual ~OptionItem() {};
|
||||
|
||||
virtual bool Selectable() {return (canSelect && !bHidden);};
|
||||
virtual void Entering();
|
||||
virtual bool Leaving();
|
||||
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() {};
|
||||
};
|
||||
|
||||
class OptionInteger:public OptionItem{
|
||||
public:
|
||||
int value;
|
||||
int maxValue, increment;
|
||||
|
||||
OptionInteger(string _id, string _displayValue, int _maxValue = 1, int _increment = 1);
|
||||
|
||||
virtual void Reload() {if(id != "") 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{
|
||||
public:
|
||||
string value;
|
||||
OptionString(string _id, string _displayValue);
|
||||
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
virtual void updateValue();
|
||||
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;};
|
||||
virtual void updateValue();
|
||||
virtual void Update(float dt);
|
||||
virtual int Submode();
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
class OptionHeader:public OptionItem{
|
||||
public:
|
||||
OptionHeader(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
||||
virtual void Render();
|
||||
virtual void setData() {};
|
||||
virtual void updateValue() {};
|
||||
};
|
||||
|
||||
class OptionText:public OptionItem{
|
||||
public:
|
||||
OptionText(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
||||
virtual void Render();
|
||||
virtual void setData() {};
|
||||
virtual void updateValue() {};
|
||||
};
|
||||
|
||||
class OptionSelect:public OptionItem{
|
||||
public:
|
||||
size_t value;
|
||||
vector<string> selections;
|
||||
|
||||
virtual void addSelection(string s);
|
||||
OptionSelect(string _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;};
|
||||
virtual void Reload() {initSelections();};
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
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();
|
||||
OptionDirectory(string _root, string _id, string _displayValue);
|
||||
private:
|
||||
string root;
|
||||
};
|
||||
|
||||
class OptionTheme:public OptionDirectory{
|
||||
public:
|
||||
OptionTheme();
|
||||
};
|
||||
|
||||
class OptionProfile:public OptionDirectory{
|
||||
public:
|
||||
OptionProfile(GameApp * _app);
|
||||
~OptionProfile();
|
||||
virtual void addSelection(string s);
|
||||
virtual bool Leaving();
|
||||
virtual void Entering();
|
||||
virtual void Render();
|
||||
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;
|
||||
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();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _OPTION_ITEM_H_
|
||||
#define _OPTION_ITEM_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "../include/GameApp.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
#define MAX_OPTION_TABS 5
|
||||
#define MAX_OPTION_ITEMS 20
|
||||
#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 {
|
||||
public:
|
||||
string displayValue, id;
|
||||
int hasFocus;
|
||||
bool canSelect;
|
||||
bool bHidden;
|
||||
float x, y;
|
||||
float width, height;
|
||||
virtual ostream& toString(ostream& out)const;
|
||||
|
||||
OptionItem( string _id, string _displayValue);
|
||||
virtual ~OptionItem() {};
|
||||
|
||||
virtual bool Selectable() {return (canSelect && !bHidden);};
|
||||
virtual void Entering();
|
||||
virtual bool Leaving();
|
||||
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() {};
|
||||
};
|
||||
|
||||
class OptionInteger:public OptionItem{
|
||||
public:
|
||||
int value; //Current value.
|
||||
int defValue; //Default value.
|
||||
string strDefault; //What to call the default value.
|
||||
int maxValue, increment;
|
||||
|
||||
OptionInteger(string _id, string _displayValue, int _maxValue = 1, int _increment = 1, int _defV = 0, string _sDef = "");
|
||||
|
||||
virtual void Reload() {if(id != "") 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{
|
||||
public:
|
||||
string value;
|
||||
OptionString(string _id, string _displayValue);
|
||||
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
virtual void updateValue();
|
||||
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;};
|
||||
virtual void updateValue();
|
||||
virtual void Update(float dt);
|
||||
virtual int Submode();
|
||||
bool bChanged;
|
||||
};
|
||||
|
||||
class OptionHeader:public OptionItem{
|
||||
public:
|
||||
OptionHeader(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
||||
virtual void Render();
|
||||
virtual void setData() {};
|
||||
virtual void updateValue() {};
|
||||
};
|
||||
|
||||
class OptionText:public OptionItem{
|
||||
public:
|
||||
OptionText(string _displayValue): OptionItem("", _displayValue) { canSelect=false;};
|
||||
virtual void Render();
|
||||
virtual void setData() {};
|
||||
virtual void updateValue() {};
|
||||
};
|
||||
|
||||
class OptionSelect:public OptionItem{
|
||||
public:
|
||||
size_t value;
|
||||
vector<string> selections;
|
||||
|
||||
virtual void addSelection(string s);
|
||||
OptionSelect(string _id, string _displayValue): OptionItem(_id, _displayValue) {value = 0;};
|
||||
virtual void Reload() {initSelections();};
|
||||
virtual void Render();
|
||||
virtual void setData();
|
||||
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();
|
||||
OptionDirectory(string _root, string _id, string _displayValue);
|
||||
private:
|
||||
string root;
|
||||
};
|
||||
|
||||
class OptionTheme:public OptionDirectory{
|
||||
public:
|
||||
OptionTheme();
|
||||
};
|
||||
|
||||
class OptionVolume: public OptionInteger{
|
||||
public:
|
||||
OptionVolume(string _id, string _displayName, bool _bMusic = false);
|
||||
virtual void updateValue();
|
||||
private:
|
||||
bool bMusic;
|
||||
};
|
||||
|
||||
class OptionProfile:public OptionDirectory{
|
||||
public:
|
||||
OptionProfile(GameApp * _app);
|
||||
~OptionProfile();
|
||||
virtual void addSelection(string s);
|
||||
virtual bool Leaving();
|
||||
virtual void Entering();
|
||||
virtual void Render();
|
||||
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;
|
||||
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();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,15 @@ GameApp::GameApp(): JApp()
|
||||
players[1] = 0;
|
||||
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.
|
||||
options.theGame = this;
|
||||
|
||||
//Ensure that options are properly loaded before loading files.
|
||||
options.reloadProfile();
|
||||
|
||||
//Test for Music files presence
|
||||
string filepath = RESPATH;
|
||||
filepath = filepath + "/" + resources.musicFile("Track0.mp3");
|
||||
@@ -200,7 +212,7 @@ void GameApp::Destroy()
|
||||
|
||||
SimpleMenu::destroy();
|
||||
|
||||
|
||||
options.theGame = NULL;
|
||||
LOG("==Destroying GameApp Successful==");
|
||||
|
||||
}
|
||||
|
||||
@@ -187,10 +187,10 @@ GameSettings::GameSettings()
|
||||
//Load global options
|
||||
globalOptions = NEW GameOptions(GLOBAL_SETTINGS);
|
||||
|
||||
//reloadProfile should be called for the rest.
|
||||
theGame = NULL;
|
||||
profileOptions = NULL;
|
||||
themeOptions = NULL;
|
||||
|
||||
checkProfile();
|
||||
}
|
||||
|
||||
GameSettings::~GameSettings(){
|
||||
@@ -220,8 +220,17 @@ int GameSettings::save(){
|
||||
if(globalOptions)
|
||||
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();
|
||||
}
|
||||
|
||||
checkProfile();
|
||||
|
||||
@@ -267,39 +276,31 @@ string GameSettings::profileFile(string filename, string fallback,bool sanity, b
|
||||
return buf;
|
||||
}
|
||||
|
||||
void GameSettings::reloadProfile(bool images){
|
||||
SAFE_DELETE(profileOptions);
|
||||
SAFE_DELETE(themeOptions);
|
||||
checkProfile();
|
||||
if(images)
|
||||
resources.Refresh(); //Update images
|
||||
}
|
||||
|
||||
void GameSettings::checkProfile(){
|
||||
//Load current profile's options. Doesn't save prior set.
|
||||
char buf[512];
|
||||
|
||||
//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);
|
||||
//If it doesn't exist, load current profile.
|
||||
if(!profileOptions)
|
||||
profileOptions = NEW GameOptions(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
|
||||
if(temp == "Default")
|
||||
sprintf(buf,RESPATH"/graphics/metrics.txt");
|
||||
else{
|
||||
sprintf(buf,RESPATH"/themes/%s/metrics.txt",temp.c_str());
|
||||
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);
|
||||
}
|
||||
|
||||
SAFE_DELETE(themeOptions);
|
||||
themeOptions = NEW GameOptions(buf);
|
||||
|
||||
//Validation of collection, etc, only happens if the game is up.
|
||||
if(theGame == NULL || theGame->collection == NULL)
|
||||
return;
|
||||
@@ -309,7 +310,7 @@ void GameSettings::checkProfile(){
|
||||
{
|
||||
//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 maxcards = 0;
|
||||
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
||||
@@ -319,15 +320,17 @@ void GameSettings::checkProfile(){
|
||||
setId = i;
|
||||
}
|
||||
}
|
||||
|
||||
//Save this set as "unlocked"
|
||||
char buffer[4096];
|
||||
string s = MtgSets::SetsList->values[setId];
|
||||
sprintf(buffer,"unlocked_%s", s.c_str());
|
||||
(*profileOptions)[buffer]=1;
|
||||
profileOptions->save();
|
||||
|
||||
//Give the player their first deck
|
||||
createUsersFirstDeck(setId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GameSettings::createUsersFirstDeck(int setId){
|
||||
|
||||
@@ -290,6 +290,7 @@ void GameStateMenu::Update(float dt)
|
||||
mReadConf = 1;
|
||||
}
|
||||
if (!nextDirectory(RESPATH"/sets/","_cards.dat")){
|
||||
|
||||
//Force default, if necessary.
|
||||
if(options[Options::ACTIVE_PROFILE].str == "")
|
||||
options[Options::ACTIVE_PROFILE].str = "Default";
|
||||
@@ -300,15 +301,8 @@ void GameStateMenu::Update(float dt)
|
||||
file.close();
|
||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||
}else{
|
||||
//check for first time player!
|
||||
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;
|
||||
}
|
||||
}
|
||||
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
|
||||
}
|
||||
|
||||
//List active profile and database size.
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
@@ -321,8 +315,8 @@ void GameStateMenu::Update(float dt)
|
||||
}
|
||||
break;
|
||||
case MENU_STATE_MAJOR_FIRST_TIME :
|
||||
options.checkProfile();
|
||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||
options.checkProfile(); //Handles building a new deck, if needed.
|
||||
break;
|
||||
case MENU_STATE_MAJOR_MAINMENU :
|
||||
if (!scrollerSet) fillScroller();
|
||||
|
||||
@@ -1,203 +1,203 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/GameStateOptions.h"
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/OptionItem.h"
|
||||
#include "../include/SimpleMenu.h"
|
||||
#include "../include/SimplePad.h"
|
||||
#include "../include/GameOptions.h"
|
||||
#include "../include/Translate.h"
|
||||
|
||||
GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent) {
|
||||
optionsTabs = NULL;
|
||||
optionsMenu = NULL;
|
||||
confirmMenu = NULL;
|
||||
}
|
||||
|
||||
|
||||
GameStateOptions::~GameStateOptions() {
|
||||
|
||||
}
|
||||
|
||||
void GameStateOptions::Start()
|
||||
{
|
||||
|
||||
timer = 0;
|
||||
mState = SHOW_OPTIONS;
|
||||
JRenderer::GetInstance()->ResetPrivateVRAM();
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
|
||||
OptionsList * optionsList;
|
||||
|
||||
optionsList = NEW OptionsList("Settings");
|
||||
optionsList->Add(NEW OptionHeader("General Options"));
|
||||
if (GameApp::HasMusic) optionsList->Add(NEW OptionInteger(Options::MUSICVOLUME, "Music volume", 100, 10));
|
||||
optionsList->Add(NEW OptionInteger(Options::SFXVOLUME, "SFX volume", 100, 10));
|
||||
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 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"));
|
||||
optionsList->Add(NEW OptionInteger(Options::CACHESIZE, "Image Cache Size", 60, 5));
|
||||
optionsTabs = NEW OptionsMenu();
|
||||
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);
|
||||
|
||||
optionsTabs->Add(optionsList);
|
||||
optionsList = NEW OptionsList("Credits");
|
||||
optionsList->failMsg = "";
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont("f3");
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::End()
|
||||
{
|
||||
JRenderer::GetInstance()->EnableVSync(false);
|
||||
SAFE_DELETE(optionsTabs);
|
||||
SAFE_DELETE(optionsMenu);
|
||||
SAFE_DELETE(confirmMenu);
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::Update(float dt)
|
||||
{
|
||||
timer += 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);
|
||||
}
|
||||
}
|
||||
|
||||
void GameStateOptions::Render()
|
||||
{
|
||||
//Erase
|
||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
||||
|
||||
const char * const CreditsText[] = {
|
||||
"Wagic, The Homebrew?! by WilLoW",
|
||||
"",
|
||||
"updates, new cards, and more on http://wololo.net/wagic",
|
||||
"Many thanks to the devs and card creators who help this project",
|
||||
"",
|
||||
"Developped with the JGE++ Library (http://jge.khors.com)",
|
||||
"Player's avatar from http://mathieuchoinet.blogspot.com, under CC License",
|
||||
"Background picture and some art from the KDE project, www.kde.org",
|
||||
"SFX From www.soundsnap.com",
|
||||
"",
|
||||
"Music by Celestial Aeon Project, http://www.jamendo.com",
|
||||
"",
|
||||
"",
|
||||
"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",
|
||||
};
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont("magic");
|
||||
mFont->SetColor(ARGB(255,200,200,200));
|
||||
mFont->SetScale(1.0);
|
||||
float startpos = 272 - timer * 10;
|
||||
float pos = startpos;
|
||||
int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
pos = startpos +20*i;
|
||||
if (pos > -20){
|
||||
mFont->DrawString(_(CreditsText[i]).c_str(),SCREEN_WIDTH/2,pos ,JGETEXT_CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (pos < -20)
|
||||
timer = 0;
|
||||
|
||||
mFont->SetScale(1.f);
|
||||
|
||||
optionsTabs->Render();
|
||||
|
||||
switch(mState){
|
||||
case SHOW_OPTIONS_MENU:
|
||||
optionsMenu->Render();
|
||||
break;
|
||||
case SHOW_OPTIONS_PROFILE:
|
||||
confirmMenu->Render();
|
||||
break;
|
||||
}
|
||||
|
||||
if(options.keypadActive())
|
||||
options.keypadRender();
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
//Exit menu?
|
||||
if(controllerId == 102)
|
||||
switch (controlId){
|
||||
case 1:
|
||||
optionsTabs->save();
|
||||
case 2:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
case 2:
|
||||
optionsTabs->cancelSubmode();
|
||||
mState = SHOW_OPTIONS;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#include "../include/config.h"
|
||||
#include "../include/GameStateOptions.h"
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/OptionItem.h"
|
||||
#include "../include/SimpleMenu.h"
|
||||
#include "../include/SimplePad.h"
|
||||
#include "../include/GameOptions.h"
|
||||
#include "../include/Translate.h"
|
||||
|
||||
GameStateOptions::GameStateOptions(GameApp* parent): GameState(parent) {
|
||||
optionsTabs = NULL;
|
||||
optionsMenu = NULL;
|
||||
confirmMenu = NULL;
|
||||
}
|
||||
|
||||
|
||||
GameStateOptions::~GameStateOptions() {
|
||||
|
||||
}
|
||||
|
||||
void GameStateOptions::Start()
|
||||
{
|
||||
timer = 0;
|
||||
mState = SHOW_OPTIONS;
|
||||
JRenderer::GetInstance()->ResetPrivateVRAM();
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
|
||||
OptionsList * optionsList;
|
||||
|
||||
optionsList = NEW OptionsList("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 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 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"));
|
||||
optionsList->Add(NEW OptionInteger(Options::CACHESIZE, "Image Cache Size", 60, 5,0,"Default"));
|
||||
optionsTabs = NEW OptionsMenu();
|
||||
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);
|
||||
|
||||
optionsTabs->Add(optionsList);
|
||||
optionsList = NEW OptionsList("Credits");
|
||||
optionsList->failMsg = "";
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont("f3");
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::End()
|
||||
{
|
||||
JRenderer::GetInstance()->EnableVSync(false);
|
||||
SAFE_DELETE(optionsTabs);
|
||||
SAFE_DELETE(optionsMenu);
|
||||
SAFE_DELETE(confirmMenu);
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::Update(float dt)
|
||||
{
|
||||
timer += 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);
|
||||
}
|
||||
}
|
||||
|
||||
void GameStateOptions::Render()
|
||||
{
|
||||
//Erase
|
||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
||||
|
||||
const char * const CreditsText[] = {
|
||||
"Wagic, The Homebrew?! by WilLoW",
|
||||
"",
|
||||
"updates, new cards, and more on http://wololo.net/wagic",
|
||||
"Many thanks to the devs and card creators who help this project",
|
||||
"",
|
||||
"Developped with the JGE++ Library (http://jge.khors.com)",
|
||||
"Player's avatar from http://mathieuchoinet.blogspot.com, under CC License",
|
||||
"Background picture and some art from the KDE project, www.kde.org",
|
||||
"SFX From www.soundsnap.com",
|
||||
"",
|
||||
"Music by Celestial Aeon Project, http://www.jamendo.com",
|
||||
"",
|
||||
"",
|
||||
"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",
|
||||
};
|
||||
|
||||
JLBFont * mFont = resources.GetJLBFont("magic");
|
||||
mFont->SetColor(ARGB(255,200,200,200));
|
||||
mFont->SetScale(1.0);
|
||||
float startpos = 272 - timer * 10;
|
||||
float pos = startpos;
|
||||
int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
|
||||
|
||||
for (int i = 0; i < size; i++){
|
||||
pos = startpos +20*i;
|
||||
if (pos > -20){
|
||||
mFont->DrawString(_(CreditsText[i]).c_str(),SCREEN_WIDTH/2,pos ,JGETEXT_CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (pos < -20)
|
||||
timer = 0;
|
||||
|
||||
mFont->SetScale(1.f);
|
||||
|
||||
optionsTabs->Render();
|
||||
|
||||
switch(mState){
|
||||
case SHOW_OPTIONS_MENU:
|
||||
optionsMenu->Render();
|
||||
break;
|
||||
case SHOW_OPTIONS_PROFILE:
|
||||
confirmMenu->Render();
|
||||
break;
|
||||
}
|
||||
|
||||
if(options.keypadActive())
|
||||
options.keypadRender();
|
||||
}
|
||||
|
||||
|
||||
void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
//Exit menu?
|
||||
if(controllerId == 102)
|
||||
switch (controlId){
|
||||
case 1:
|
||||
optionsTabs->save();
|
||||
case 2:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
break;
|
||||
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;
|
||||
break;
|
||||
case 2:
|
||||
optionsTabs->cancelSubmode();
|
||||
mState = SHOW_OPTIONS;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -935,10 +935,6 @@ int WResourceManager::CreateTexture(const string &textureName) {
|
||||
mTextureList.push_back(tex);
|
||||
mTextureMap[textureName] = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user