***Note***

please copy "DeckEditorMenuBackdrop.png" into your PSP folder.  Otherwise you will have a crash when you start up!

ChangesLog:
minor refactoring of DeckMenu
added a new DeckEditorMenu which is derived from DeckMenu.  This customizes the deck editor menus with the exception of the confirmation screens (yes/no)
Still more work to be done to round out some font issues.  
TODO:
put more information text in bottom row of menu.
reorganize statistical data to allow more info to be shown.
This commit is contained in:
techdragon.nguyen@gmail.com
2010-11-03 16:49:39 +00:00
parent b7a2196878
commit dd163c8807
10 changed files with 140 additions and 74 deletions

View File

@@ -1,4 +1,4 @@
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/CardSelectorSingleton.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMenu.o objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateStory.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGPack.o objs/MTGRules.o objs/Navigator.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PrecompiledHeader.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/StoryFlow.o objs/StyleManager.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o objs/WFont.o objs/AllAbilities.o
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/AllAbilities.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/CardSelectorSingleton.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckEditorMenu.o objs/DeckMenu.o objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GameStateStory.o objs/GameStateTransitions.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGPack.o objs/MTGRules.o objs/Navigator.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PrecompiledHeader.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/StoryFlow.o objs/StyleManager.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o objs/WFont.o
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -0,0 +1,11 @@
#pragma once
#include "DeckMenu.h"
class DeckEditorMenu :
public DeckMenu
{
public:
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "");
void Render();
~DeckEditorMenu();
};

View File

@@ -18,6 +18,7 @@ class DeckMenu:public JGuiController{
int descX, descY, descHeight, descWidth;
int statsX, statsY, statsHeight, statsWidth;
int avatarX, avatarY;
string backgroundName;
int fontId;
std::string title;
@@ -25,18 +26,21 @@ class DeckMenu:public JGuiController{
int maxItems, startId;
float selectionT, selectionY;
float timeOpen;
static unsigned int refCount;
static WFont* titleFont;
WFont* titleFont;
static hgeParticleSystem* stars;
// This works only because of no multithreading
static PIXEL_TYPE jewelGraphics[9];
void initMenuItems();
string getDescription();
string getMetaInformation();
public:
TextScroller * scroller;
bool autoTranslate;
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "");
bool autoTranslate;
JQuad * getBackground();
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "");
~DeckMenu();
void Render();

View File

@@ -7,8 +7,8 @@
#include <JGE.h>
#include "GameState.h"
#include "DeckEditorMenu.h"
#include "SimpleMenu.h"
#include "DeckMenu.h"
#include "WResourceManager.h"
#include "CardGui.h"
#include "GameOptions.h"
@@ -146,9 +146,9 @@ private:
WGuiFilters * filterMenu;
WSrcDeckViewer * source;
SimpleMenu * welcome_menu;
DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu;
SimpleMenu * menu;
DeckEditorMenu * menu;
PriceList* pricelist;
PlayerData * playerdata;
int price;

View File

@@ -0,0 +1,46 @@
#include "PrecompiledHeader.h"
#include "DeckEditorMenu.h"
#include "JTypes.h"
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title)
: DeckMenu( id, listener, fontId, _title )
{
backgroundName = "DeckEditorMenuBackdrop";
mX = 120;
mY = 70;
titleX = 110; // center point in title box
titleY = 34;
titleWidth = 180; // width of inner box of title
descX = 275;
descY = 80;
descHeight = 154;
descWidth = 175;
statsX = 282;
statsY = 12;
statsHeight = 40;
statsWidth = 180;
avatarX = 222;
avatarY = 8;
int scrollerWidth = 80;
SAFE_DELETE(scroller); // need to delete the scroller init in the base class
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40 , 230, scrollerWidth, 100, 1, 1);
}
void DeckEditorMenu::Render()
{
JRenderer *r = JRenderer::GetInstance();
r->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(200,0,0,0));
DeckMenu::Render();
}
DeckEditorMenu::~DeckEditorMenu()
{
SAFE_DELETE( scroller );
}

View File

@@ -18,9 +18,7 @@ namespace
const signed int kDescriptionHorizontalBoxPadding = 5;
}
WFont* DeckMenu::titleFont = NULL;
hgeParticleSystem* DeckMenu::stars = NULL;
unsigned int DeckMenu::refCount = 0;
hgeParticleSystem* DeckMenu::stars = NULL;
// Here comes the magic of jewel graphics
PIXEL_TYPE DeckMenu::jewelGraphics[9] = {0x3FFFFFFF,0x63645AEA,0x610D0D98,
0x63645AEA,0xFF635AD5,0xFF110F67,
@@ -39,8 +37,9 @@ DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _tit
: JGuiController(id, listener),
fontId(fontId) {
mX = 120;
backgroundName = "DeckMenuBackdrop";
mX = 125;
mY = 55;
titleX = 125; // center point in title box
@@ -74,11 +73,11 @@ fontId(fontId) {
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
title = _(_title);
titleFont = resources.GetWFont(Fonts::MAGIC_FONT);
startId = 0;
selectionT = 0;
timeOpen = 0;
closed = false;
++refCount;
selectionTargetY = selectionY = kVerticalMargin;
@@ -90,48 +89,51 @@ fontId(fontId) {
}
// TODO: Make this configurable, perhaps by user as part of the theme options.
JQuad* getBackground()
JQuad* DeckMenu::getBackground()
{
resources.RetrieveTexture("DeckMenuBackdrop.png", RETRIEVE_MANAGE );
return resources.RetrieveQuad("DeckMenuBackdrop.png", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, "DualPaneBG" );
ostringstream bgFilename;
bgFilename << backgroundName << ".png";
resources.RetrieveTexture( bgFilename.str(), RETRIEVE_MANAGE );
return resources.RetrieveQuad(bgFilename.str(), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, backgroundName );
}
void DeckMenu::initMenuItems()
{
float sY = mY + kVerticalMargin;
for (int i = startId; i < startId + mCount; ++i) {
DeckMenuItem *menuItem = static_cast<DeckMenuItem *> (mObjects[i]);
int width = menuItem->GetWidth();
if (mWidth < width) mWidth = width;
}
titleWidth = titleFont->GetStringWidth(title.c_str());
if ((!title.empty()) && (mWidth < titleWidth))
mWidth = titleWidth;
mWidth += 2*kHorizontalMargin;
for (int i = startId; i < startId + mCount; ++i) {
float y = mY + kVerticalMargin + i * kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*>(mObjects[i]);
currentMenuItem->Relocate( mX, y);
if (currentMenuItem->hasFocus())
sY = y;
}
selectionTargetY = selectionY = sY;
}
void DeckMenu::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
WFont * titleFont = resources.GetWFont(Fonts::MAGIC_FONT);
WFont * mFont = resources.GetWFont(fontId);
float height = mHeight;
// figure out where to place the stars initially
if (0 == mWidth) {
float sY = mY + kVerticalMargin;
for (int i = startId; i < startId + mCount; ++i) {
DeckMenuItem *menuItem = static_cast<DeckMenuItem *> (mObjects[i]);
int width = menuItem->GetWidth();
if (mWidth < width) mWidth = width;
}
if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str())))
mWidth = titleFont->GetStringWidth(title.c_str());
mWidth += 2*kHorizontalMargin;
for (int i = startId; i < startId + mCount; ++i) {
float y = mY + kVerticalMargin + i * kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*>(mObjects[i]);
currentMenuItem->Relocate( mX, y);
if (currentMenuItem->hasFocus()) sY = y;
}
initMenuItems();
stars->Fire();
selectionTargetY = selectionY = sY;
timeOpen = 0;
}
renderer->RenderQuad(getBackground(), 0, 0 );
float height = mHeight;
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
@@ -149,9 +151,8 @@ void DeckMenu::Render()
if ( currentMenuItem->imageFilename.size() > 0 )
{
JQuad * quad = resources.RetrieveTempQuad( currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR );
if (quad) {
renderer->RenderQuad(quad, avatarX, avatarY);
}
if (quad)
renderer->RenderQuad(quad, avatarX, avatarY);
}
// fill in the description part of the screen
string text = currentMenuItem->desc;
@@ -174,13 +175,13 @@ void DeckMenu::Render()
}
currentMenuItem->RenderWithOffset(-kLineHeight*startId);
}
renderer->RenderQuad(getBackground(), 0, 0 );
if (!title.empty())
titleFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
scroller->Render();
renderer->RenderQuad(getBackground(), 0, 0 );
}
}
@@ -243,9 +244,10 @@ void DeckMenu::Close()
void DeckMenu::destroy(){
SAFE_DELETE(DeckMenu::stars);
}
}
DeckMenu::~DeckMenu()
{
SAFE_DELETE(scroller);
}

View File

@@ -243,6 +243,7 @@ void GameApp::Destroy()
WCFilterFactory::Destroy();
SimpleMenu::destroy();
DeckMenu::destroy();
DeckEditorMenu::destroy();
options.theGame = NULL;
LOG("==Destroying GameApp Successful==");
@@ -314,9 +315,6 @@ void GameApp::Update()
mCurrentState->Start();
mNextState = NULL;
}
}

View File

@@ -16,7 +16,8 @@
#include "MTGCardInstance.h"
#include "WFilter.h"
#include "WDataSrc.h"
#include "DeckEditorMenu.h"
#include "SimpleMenu.h"
//!! helper function; this is probably handled somewhere in the code already.
@@ -135,7 +136,7 @@ void GameStateDeckViewer::switchDisplay(){
void GameStateDeckViewer::updateDecks(){
SAFE_DELETE(welcome_menu);
welcome_menu = NEW SimpleMenu( MENU_DECK_SELECTION, this, Fonts::MENU_FONT, 20, 20);
welcome_menu = NEW DeckEditorMenu( MENU_DECK_SELECTION, this, Fonts::MAGIC_FONT, "Choose Deck To Edit");
DeckManager * deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> playerDeckList = fillDeckMenu( welcome_menu,options.profileFile());
@@ -160,7 +161,6 @@ void GameStateDeckViewer::buildEditorMenu()
if ( myDeck ) {
aiDeckMsg
<< "**** All changes are final ****" << endl << endl
<< "------- Deck Summary -----" << endl
<< "# Cards: "<< myDeck->getCount() << endl
<< "# Lands: "<< myDeck->getCount(Constants::MTG_COLOR_LAND ) << endl
@@ -185,17 +185,17 @@ void GameStateDeckViewer::buildEditorMenu()
if ( menu )
SAFE_DELETE( menu );
//Build menu.
menu = NEW SimpleMenu( MENU_DECK_BUILDER, this, Fonts::MENU_FONT, 20, 40, "Deck Editor");
JRenderer::GetInstance()->FillRoundRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 100, ARGB(0, 0, 0, 0) );
menu = NEW DeckEditorMenu( MENU_DECK_BUILDER, this, Fonts::MAGIC_FONT, "Deck Editor");
menu->Add( MENU_ITEM_FILTER_BY, "Filter By...", "Narrow down the list of cards. ");
menu->Add( MENU_ITEM_SWITCH_DECKS_NO_SAVE, "Switch Decks", "Do not make any changes\nView another deck.");
menu->Add( MENU_ITEM_SWITCH_DECKS_NO_SAVE, "Switch Decks", "Do not make any changes.\nView another deck.");
menu->Add( MENU_ITEM_SAVE_RENAME, "Rename Deck", "Change the name of the deck");
menu->Add( MENU_ITEM_SAVE_RETURN_MAIN_MENU, "Save & Quit Editor", "Save the changes and return to the main menu");
menu->Add( MENU_ITEM_SAVE_RETURN_MAIN_MENU, "Save & Quit Editor", "Save changes.\nReturn to the main menu");
menu->Add( MENU_ITEM_SAVE_AS_AI_DECK, "Save As AI Deck", aiDeckMsg.str() );
menu->Add( MENU_ITEM_MAIN_MENU, "Main Menu", "Go back to the main menu.\nDo not make any changes to deck");
menu->Add( MENU_ITEM_EDITOR_CANCEL, "Cancel");
menu->Add( MENU_ITEM_MAIN_MENU, "Quit Editor", "Do not make any changes to deck.\nReturn to the main menu.");
menu->Add( MENU_ITEM_EDITOR_CANCEL, "Cancel", "Close menu.");
}
void GameStateDeckViewer::Start()
@@ -220,9 +220,7 @@ void GameStateDeckViewer::Start()
myCollection->Sort(WSrcCards::SORT_ALPHA);
displayed_deck = myCollection;
buildEditorMenu();
//Icons
//Icons
mIcons[Constants::MTG_COLOR_ARTIFACT] = resources.GetQuad("c_artifact");
mIcons[Constants::MTG_COLOR_LAND] = resources.GetQuad("c_land");
mIcons[Constants::MTG_COLOR_WHITE] = resources.GetQuad("c_white");
@@ -254,7 +252,7 @@ void GameStateDeckViewer::Start()
loadIndexes();
mEngine->ResetInput();
JRenderer::GetInstance()->EnableVSync(true);
}
}
void GameStateDeckViewer::End()
@@ -413,7 +411,7 @@ void GameStateDeckViewer::Update(float dt)
if (card && displayed_deck->count(card)){
price = pricelist->getSellPrice(card->getMTGId());
sprintf(buffer,"%s : %i %s",_(card->data->getName()).c_str(),price,_("credits").c_str());
subMenu = NEW SimpleMenu( MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
subMenu = NEW SimpleMenu( MENU_CARD_PURCHASE, this, Fonts::MAIN_FONT, SCREEN_WIDTH-300, SCREEN_HEIGHT/2, buffer);
subMenu->Add( MENU_ITEM_YES,"Yes");
subMenu->Add( MENU_ITEM_NO,"No","",true);
}
@@ -534,12 +532,11 @@ void GameStateDeckViewer::Update(float dt)
}
}
}
}
void GameStateDeckViewer::renderOnScreenBasicInfo(){
JRenderer *renderer = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Fonts::MAIN_FONT);
char buffer[256];
int myD = (displayed_deck == myDeck);
@@ -555,10 +552,11 @@ void GameStateDeckViewer::renderOnScreenBasicInfo(){
else
sprintf(buffer, "%s%i cards (%i unique)", (displayed_deck == myDeck) ? "DECK: " : " " , allCopies, displayed_deck->getCount(WSrcDeck::UNFILTERED_UNIQUE));
float w = mFont->GetStringWidth(buffer);
JRenderer::GetInstance()->FillRoundRect(SCREEN_WIDTH-(w+27),y-5,w+10,15,5,ARGB(128,0,0,0));
mFont->DrawString(buffer, SCREEN_WIDTH-22, y+5,JGETEXT_RIGHT);
renderer->FillRoundRect(SCREEN_WIDTH-(w+27),y+5,w+10,15,5,ARGB(128,0,0,0));
mFont->DrawString(buffer, SCREEN_WIDTH-22, y+15, JGETEXT_RIGHT);
if (useFilter != 0)
JRenderer::GetInstance()->RenderQuad(mIcons[useFilter-1], SCREEN_WIDTH-10 , y + 10 , 0.0f,0.5,0.5);
renderer->RenderQuad(mIcons[useFilter-1], SCREEN_WIDTH-10 , y + 15, 0.0f,0.5,0.5);
}
//returns position of the current card (cusor) in the currently viewed color/filter
@@ -600,7 +598,7 @@ void GameStateDeckViewer::renderSlideBar(){
}
sprintf(buffer,"%s - %i/%i", deckname.c_str(),currentPos, total);
mFont->SetColor(ARGB(hudAlpha,255,255,255));
mFont->DrawString(buffer,SCREEN_WIDTH/2, y+5,JGETEXT_CENTER);
mFont->DrawString(buffer, SCREEN_WIDTH/2, y, JGETEXT_CENTER);
mFont->SetColor(ARGB(255,255,255,255));
@@ -1388,7 +1386,7 @@ void GameStateDeckViewer::Render() {
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));
if(displayed_deck == myDeck)
if(displayed_deck == myDeck && mStage != STAGE_MENU)
renderDeckBackground();
int order[3] = {1,2,3};
if (mRotation < 0.5 && mRotation > -0.5){
@@ -1416,7 +1414,6 @@ void GameStateDeckViewer::Render() {
if (mStage == STAGE_ONSCREEN_MENU){
renderOnScreenMenu();
}else if (mStage == STAGE_WELCOME){
r->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(200,0,0,0));
welcome_menu->Render();
}else{
renderOnScreenBasicInfo();

View File

@@ -493,6 +493,10 @@
RelativePath=".\src\DeckDataWrapper.cpp"
>
</File>
<File
RelativePath=".\src\DeckEditorMenu.cpp"
>
</File>
<File
RelativePath=".\src\DeckManager.cpp"
>
@@ -1026,6 +1030,10 @@
RelativePath=".\include\DeckDataWrapper.h"
>
</File>
<File
RelativePath=".\include\DeckEditorMenu.h"
>
</File>
<File
RelativePath=".\include\DeckManager.h"
>