Jeck - Daily build, deck renaming, small keypad bugfix, profileFile() fix, proposed new iconspsp.png.
* Decks now support naming and renaming. Also added a "Switch decks without saving" option. * Removed unused static const char * menuTexts, from old 6-deck limited system * Keypad didn't display correctly when not given a title, and was never destructed. Fixed. * profileFile() default behavior was to fall back to RESPATH/player. Fixed. * New iconspsp.png, updated look to seem like PSP buttons, added some extra (unused) button icons.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
@@ -116,7 +116,7 @@ public:
|
||||
//These return a filepath accurate to the current mode/profile/theme, and can
|
||||
//optionally fallback to a file within a certain directory.
|
||||
//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=false,bool relative=false);
|
||||
|
||||
void reloadProfile(bool images = true); //Reloads profile using current options[ACTIVE_PROFILE]
|
||||
void checkProfile(); //Confirms that a profile is loaded and contains a collection.
|
||||
|
||||
@@ -30,8 +30,6 @@ class GameState
|
||||
JGE* mEngine;
|
||||
|
||||
public:
|
||||
|
||||
static const char * const menuTexts[];
|
||||
GameState(GameApp* parent);
|
||||
virtual ~GameState() {}
|
||||
|
||||
|
||||
@@ -53,7 +53,8 @@ private:
|
||||
float mSlide;
|
||||
int mAlpha;
|
||||
int mStage;
|
||||
|
||||
int nbDecks;
|
||||
int deckNum;
|
||||
int colorFilter;
|
||||
JMusic * bgMusic;
|
||||
JQuad * backQuad;
|
||||
@@ -74,11 +75,12 @@ private:
|
||||
int hudAlpha;
|
||||
float scrollSpeed;
|
||||
int delSellMenu;
|
||||
string newDeckname;
|
||||
|
||||
public:
|
||||
GameStateDeckViewer(GameApp* parent);
|
||||
virtual ~GameStateDeckViewer();
|
||||
|
||||
void updateDecks();
|
||||
void rotateCards(int direction);
|
||||
void loadIndexes(MTGCard * current = NULL);
|
||||
void switchDisplay();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "../include/DeckStats.h"
|
||||
#include "../include/Translate.h"
|
||||
|
||||
const char * const GameState::menuTexts[]= {"--NEW--","Deck 1", "Deck 2", "Deck 3", "Deck 4", "Deck 5", "Deck 6"} ;
|
||||
hgeParticleSystem* GameApp::Particles[] = {NULL,NULL,NULL,NULL,NULL,NULL};
|
||||
int GameApp::HasMusic = 1;
|
||||
JMusic * GameApp::music = NULL;
|
||||
|
||||
@@ -203,6 +203,7 @@ GameSettings::~GameSettings(){
|
||||
SAFE_DELETE(globalOptions);
|
||||
SAFE_DELETE(profileOptions);
|
||||
SAFE_DELETE(themeOptions);
|
||||
SAFE_DELETE(keypad);
|
||||
}
|
||||
|
||||
GameOption& GameSettings::operator[](string option_name){
|
||||
@@ -223,11 +224,11 @@ int GameSettings::save(){
|
||||
if(profileOptions){
|
||||
//Force our directories to exist.
|
||||
MAKEDIR(RESPATH"/profiles");
|
||||
string temp = profileFile("","",false,false);
|
||||
string temp = profileFile();
|
||||
MAKEDIR(temp.c_str());
|
||||
temp+="/stats";
|
||||
MAKEDIR(temp.c_str());
|
||||
temp = profileFile(PLAYER_SETTINGS,"",false);
|
||||
temp = profileFile(PLAYER_SETTINGS);
|
||||
|
||||
profileOptions->save();
|
||||
}
|
||||
@@ -289,7 +290,7 @@ void GameSettings::checkProfile(){
|
||||
|
||||
//If it doesn't exist, load current profile.
|
||||
if(!profileOptions)
|
||||
profileOptions = NEW GameOptions(profileFile(PLAYER_SETTINGS,"",false));
|
||||
profileOptions = NEW GameOptions(profileFile(PLAYER_SETTINGS));
|
||||
|
||||
//Load theme options
|
||||
if(!themeOptions){
|
||||
@@ -343,7 +344,7 @@ void GameSettings::createUsersFirstDeck(int setId){
|
||||
if(theGame == NULL || theGame->collection == NULL)
|
||||
return;
|
||||
|
||||
MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), theGame->collection);
|
||||
MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), theGame->collection);
|
||||
//10 lands of each
|
||||
int sets[] = {setId};
|
||||
if (!mCollection->addRandomCards(10, sets,1, Constants::RARITY_L,"Forest")){
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
GameStateDeckViewer::GameStateDeckViewer(GameApp* parent): GameState(parent) {
|
||||
bgMusic = NULL;
|
||||
scrollSpeed = MED_SPEED;
|
||||
nbDecks = 0;
|
||||
deckNum = 0;
|
||||
}
|
||||
|
||||
GameStateDeckViewer::~GameStateDeckViewer() {
|
||||
@@ -67,14 +69,27 @@ void GameStateDeckViewer::switchDisplay(){
|
||||
loadIndexes();
|
||||
}
|
||||
|
||||
void GameStateDeckViewer::updateDecks(){
|
||||
SAFE_DELETE(welcome_menu);
|
||||
|
||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
||||
nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
||||
deckNum = 0;
|
||||
newDeckname = "";
|
||||
welcome_menu->Add(nbDecks+1, "--NEW--");
|
||||
welcome_menu->Add(-1, "Cancel");
|
||||
|
||||
}
|
||||
|
||||
void GameStateDeckViewer::Start()
|
||||
{
|
||||
newDeckname = "";
|
||||
hudAlpha = 0;
|
||||
delSellMenu = 0;
|
||||
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",mParent->collection);
|
||||
playerdata = NEW PlayerData(mParent->collection);
|
||||
sellMenu = NULL;
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), mParent->collection));
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
||||
displayed_deck = myCollection;
|
||||
myDeck = NULL;
|
||||
menuFont = resources.GetJLBFont(Constants::MENU_FONT);
|
||||
@@ -83,8 +98,10 @@ void GameStateDeckViewer::Start()
|
||||
|
||||
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20);
|
||||
menu->Add(11,"Save");
|
||||
menu->Add(12,"Back to main menu");
|
||||
menu->Add(13, "Cancel");
|
||||
menu->Add(12,"Rename deck");
|
||||
menu->Add(13,"Switch decks without saving");
|
||||
menu->Add(14,"Back to main menu");
|
||||
menu->Add(15,"Cancel");
|
||||
|
||||
|
||||
//icon images
|
||||
@@ -114,7 +131,8 @@ void GameStateDeckViewer::Start()
|
||||
//menuFont = NEW JLBFont("graphics/f3",16);
|
||||
menuFont = resources.GetJLBFont("f3");
|
||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
||||
int nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
||||
nbDecks = fillDeckMenu(welcome_menu,options.profileFile());
|
||||
deckNum = 0;
|
||||
welcome_menu->Add(nbDecks+1, "--NEW--");
|
||||
welcome_menu->Add(-1, "Cancel");
|
||||
|
||||
@@ -135,6 +153,7 @@ void GameStateDeckViewer::Start()
|
||||
mRotation = 0;
|
||||
mSlide = 0;
|
||||
mAlpha = 255;
|
||||
newDeckname = "";
|
||||
//mEngine->ResetPrivateVRAM();
|
||||
//mEngine->EnableVSync(true);
|
||||
currentCard = NULL;
|
||||
@@ -189,6 +208,22 @@ int GameStateDeckViewer::Remove(MTGCard * card){
|
||||
|
||||
void GameStateDeckViewer::Update(float dt)
|
||||
{
|
||||
if(options.keypadActive()){
|
||||
options.keypadUpdate(dt);
|
||||
|
||||
if(newDeckname != ""){
|
||||
newDeckname = options.keypadFinish();
|
||||
|
||||
if(newDeckname != ""){
|
||||
loadDeck(deckNum);
|
||||
if(myDeck && myDeck->parent)
|
||||
myDeck->parent->meta_name = newDeckname;
|
||||
}
|
||||
newDeckname = "";
|
||||
}
|
||||
//Prevent screen from updating.
|
||||
return;
|
||||
}
|
||||
// mParent->effect->UpdateBig(dt);
|
||||
hudAlpha = 255-(last_user_activity * 500);
|
||||
if (hudAlpha < 0) hudAlpha = 0;
|
||||
@@ -660,13 +695,15 @@ void GameStateDeckViewer::Render()
|
||||
}
|
||||
if (sellMenu) sellMenu->Render();
|
||||
|
||||
if(options.keypadActive())
|
||||
options.keypadRender();
|
||||
}
|
||||
|
||||
|
||||
int GameStateDeckViewer::loadDeck(int deckid){
|
||||
SAFE_DELETE(myCollection);
|
||||
string profile = options[Options::ACTIVE_PROFILE].str;
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), mParent->collection));
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
||||
displayed_deck = myCollection;
|
||||
char deckname[256];
|
||||
sprintf(deckname,"deck%i.txt",deckid);
|
||||
@@ -692,11 +729,20 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
case 10:
|
||||
if (controlId == -1){
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
else if(controlId == nbDecks+1){
|
||||
char buf[512];
|
||||
deckNum = controlId;
|
||||
sprintf(buf,"deck%i",deckNum);
|
||||
options.keypadStart(buf,&newDeckname);
|
||||
options.keypadTitle("Deck name");
|
||||
//Fallthrough to deck editing.
|
||||
}
|
||||
loadDeck(controlId);
|
||||
mStage = STAGE_WAITING;
|
||||
return;
|
||||
deckNum = controlId;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (controlId)
|
||||
@@ -709,9 +755,19 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
mStage = STAGE_WAITING;
|
||||
break;
|
||||
case 12:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
if(myDeck && myDeck->parent){
|
||||
options.keypadStart(myDeck->parent->meta_name,&newDeckname);
|
||||
options.keypadTitle("Rename deck");
|
||||
}
|
||||
break;
|
||||
case 13:
|
||||
updateDecks();
|
||||
mStage = STAGE_WELCOME;
|
||||
break;
|
||||
case 14:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
break;
|
||||
case 15:
|
||||
mStage = STAGE_WAITING;
|
||||
break;
|
||||
case 20:
|
||||
@@ -735,5 +791,4 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
||||
delSellMenu = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -139,12 +139,12 @@ void GameStateDuel::loadPlayerRandom(int playerId, int isAI, int mode){
|
||||
void GameStateDuel::loadPlayerMomir(int playerId, int isAI){
|
||||
string deckFileSmall = "momir";
|
||||
char empty[] = "";
|
||||
MTGDeck * tempDeck = NEW MTGDeck(options.profileFile("momir.txt").c_str(), mParent->collection);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(options.profileFile("momir.txt","",true).c_str(), mParent->collection);
|
||||
deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck);
|
||||
if (!isAI) // Human Player
|
||||
mPlayers[playerId] = NEW HumanPlayer(deck[playerId], options.profileFile("momir.txt").c_str(), deckFileSmall);
|
||||
mPlayers[playerId] = NEW HumanPlayer(deck[playerId], options.profileFile("momir.txt","",true).c_str(), deckFileSmall);
|
||||
else
|
||||
mPlayers[playerId] = NEW AIMomirPlayer(deck[playerId], options.profileFile("momir.txt").c_str(), deckFileSmall, empty);
|
||||
mPlayers[playerId] = NEW AIMomirPlayer(deck[playerId], options.profileFile("momir.txt","",true).c_str(), deckFileSmall, empty);
|
||||
delete tempDeck;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ void GameStateMenu::fillScroller(){
|
||||
sprintf(buff2, _("You have unlocked %i expansions out of %i").c_str(),nbunlocked, MtgSets::SetsList->nb_items);
|
||||
scroller->Add(buff2);
|
||||
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), mParent->collection));
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), mParent->collection));
|
||||
int totalCards = ddw->getCount();
|
||||
if (totalCards){
|
||||
sprintf(buff2, _("You have a total of %i cards in your collection").c_str(),totalCards);
|
||||
@@ -319,7 +319,7 @@ void GameStateMenu::Update(float dt)
|
||||
options[Options::ACTIVE_PROFILE].str = "Default";
|
||||
|
||||
//check for deleted collection / first-timer
|
||||
std::ifstream file(options.profileFile(PLAYER_COLLECTION,"",false).c_str());
|
||||
std::ifstream file(options.profileFile(PLAYER_COLLECTION).c_str());
|
||||
if(file){
|
||||
file.close();
|
||||
resources.Release(mSplash);
|
||||
|
||||
@@ -23,7 +23,6 @@ void GameStateShop::Create(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GameStateShop::Start()
|
||||
{
|
||||
menu = NULL;
|
||||
|
||||
@@ -9,7 +9,7 @@ PlayerData::PlayerData(MTGAllCards * allcards){
|
||||
//CREDITS
|
||||
credits = 3000; //Default value
|
||||
|
||||
std::ifstream file(options.profileFile(PLAYER_SAVEFILE,"",false).c_str());
|
||||
std::ifstream file(options.profileFile(PLAYER_SAVEFILE).c_str());
|
||||
std::string s;
|
||||
if(file){
|
||||
if(std::getline(file,s)){
|
||||
@@ -21,12 +21,12 @@ PlayerData::PlayerData(MTGAllCards * allcards){
|
||||
}
|
||||
|
||||
//COLLECTION
|
||||
collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), allcards);
|
||||
collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), allcards);
|
||||
}
|
||||
|
||||
|
||||
int PlayerData::save(){
|
||||
std::ofstream file(options.profileFile(PLAYER_SAVEFILE,"",false).c_str());
|
||||
std::ofstream file(options.profileFile(PLAYER_SAVEFILE).c_str());
|
||||
char writer[64];
|
||||
if (file){
|
||||
sprintf(writer,"%i\n", credits);
|
||||
|
||||
@@ -189,14 +189,16 @@ void SimplePad::MoveSelection(unsigned char moveto)
|
||||
void SimplePad::Update(float dt){
|
||||
JGE * mEngine = JGE::GetInstance();
|
||||
|
||||
//We can always confirm!
|
||||
//Start button changes capslock setting.
|
||||
if(mEngine->GetButtonClick(PSP_CTRL_START))
|
||||
{
|
||||
if(selected != KPD_OK)
|
||||
selected = KPD_OK;
|
||||
else
|
||||
Finish();
|
||||
return;
|
||||
}
|
||||
else if(mEngine->GetButtonClick(PSP_CTRL_SELECT)){
|
||||
bCapslock = !bCapslock;
|
||||
}
|
||||
|
||||
if(selected == KPD_SPACE){
|
||||
@@ -253,6 +255,8 @@ void SimplePad::Update(float dt){
|
||||
mX = 50;
|
||||
mY = 50;
|
||||
|
||||
//Clear input buffer.
|
||||
mEngine->ResetInput();
|
||||
}
|
||||
void SimplePad::Start(string value, string * _dest) {
|
||||
bActive = true;
|
||||
@@ -261,10 +265,19 @@ void SimplePad::Start(string value, string * _dest) {
|
||||
original = buffer;
|
||||
dest = _dest;
|
||||
cursor = buffer.size();
|
||||
//Clear input buffer.
|
||||
JGE * mEngine = JGE::GetInstance();
|
||||
mEngine->ResetInput();
|
||||
}
|
||||
|
||||
string SimplePad::Finish() {
|
||||
bActive = false;
|
||||
|
||||
//Clear input buffer.
|
||||
JGE * mEngine = JGE::GetInstance();
|
||||
mEngine->ResetInput();
|
||||
|
||||
//Return result.
|
||||
if(bCanceled){
|
||||
dest = NULL;
|
||||
return original;
|
||||
@@ -290,14 +303,12 @@ void SimplePad::Render(){
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
|
||||
if(title != "")
|
||||
vSpacing = kH+8;
|
||||
else
|
||||
vSpacing = 0;
|
||||
vSpacing = kH+8;
|
||||
|
||||
|
||||
offY = vSpacing;
|
||||
if(bShowNumpad)
|
||||
offY += kH+14;
|
||||
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)));
|
||||
offY = vSpacing;
|
||||
@@ -307,8 +318,8 @@ void SimplePad::Render(){
|
||||
//Draw text-entry title, if we've got one.
|
||||
if(title != ""){
|
||||
mFont->DrawString(title.c_str(),mX,mY);
|
||||
mY+=kH+12;
|
||||
}
|
||||
mY+=kH+12;
|
||||
|
||||
//Draw cursor.
|
||||
if(cursor < buffer.size())
|
||||
|
||||
Reference in New Issue
Block a user