* A number of adjustments about fonts.
This commit is contained in:
jean.chalard
2009-01-04 02:49:08 +00:00
parent 45e143dd0c
commit 0d14207247
14 changed files with 186 additions and 103 deletions
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

-11
View File
@@ -6,17 +6,6 @@
#include "_includeAll.h" #include "_includeAll.h"
#include "../include/SimpleMenu.h" #include "../include/SimpleMenu.h"
enum
{
DUEL_START,
DUEL_END,
DUEL_CHOOSE_DECK1,
DUEL_CHOOSE_DECK2,
ERROR_NO_DECK,
DUEL_PLAY,
DUEL_MENU
};
#define CHOOSE_OPPONENT 7 #define CHOOSE_OPPONENT 7
#ifdef TESTSUITE #ifdef TESTSUITE
+7 -2
View File
@@ -15,7 +15,7 @@ class SimpleMenu:public JGuiController{
static const unsigned SIDE_SIZE; static const unsigned SIDE_SIZE;
static const unsigned VMARGIN; static const unsigned VMARGIN;
static const unsigned HMARGIN; static const unsigned HMARGIN;
static const unsigned LINE_HEIGHT; static const signed LINE_HEIGHT;
static const char* spadeLPath; static const char* spadeLPath;
static const char* spadeRPath; static const char* spadeRPath;
static const char* jewelPath; static const char* jewelPath;
@@ -28,12 +28,17 @@ class SimpleMenu:public JGuiController{
std::string title; std::string title;
int displaytitle; int displaytitle;
int maxItems,startId; int maxItems,startId;
hgeParticleSystem* stars;
float selectionT, selectionY; float selectionT, selectionY;
float timeOpen; float timeOpen;
static unsigned int refCount;
static JQuad *spadeR, *spadeL, *jewel, *side; static JQuad *spadeR, *spadeL, *jewel, *side;
static JLBFont* titleFont; static JLBFont* titleFont;
static hgeParticleSystem* stars;
// This works only because of no multithreading
static PIXEL_TYPE jewelGraphics[9];
inline void MogrifyJewel();
void drawHorzPole(int x, int y, int width); void drawHorzPole(int x, int y, int width);
void drawVertPole(int x, int y, int height); void drawVertPole(int x, int y, int height);
+2
View File
@@ -99,6 +99,8 @@ void GameApp::Create()
CommonRes->CreateQuad("stars", "graphics/particles.png", 64, 0, 32, 32); CommonRes->CreateQuad("stars", "graphics/particles.png", 64, 0, 32, 32);
CommonRes->GetQuad("stars")->SetHotSpot(16,16); CommonRes->GetQuad("stars")->SetHotSpot(16,16);
CommonRes->LoadJLBFont("graphics/simon",11);
CommonRes->GetJLBFont("graphics/simon")->SetTracking(-1);
CommonRes->LoadJLBFont("graphics/f3",16); CommonRes->LoadJLBFont("graphics/f3",16);
CommonRes->LoadJLBFont("graphics/magic",16); CommonRes->LoadJLBFont("graphics/magic",16);
+98 -38
View File
@@ -10,6 +10,29 @@
#include "../include/TestSuiteAI.h" #include "../include/TestSuiteAI.h"
#endif #endif
enum ENUM_DUEL_STATE
{
DUEL_STATE_START,
DUEL_STATE_END,
DUEL_STATE_CHOOSE_DECK1,
DUEL_STATE_CHOOSE_DECK1_TO_2,
DUEL_STATE_CHOOSE_DECK2,
DUEL_STATE_CHOOSE_DECK2_TO_PLAY,
DUEL_STATE_ERROR_NO_DECK,
DUEL_STATE_CANCEL,
DUEL_STATE_PLAY,
DUEL_STATE_BACK_TO_MAIN_MENU,
DUEL_STATE_MENU
};
enum ENUM_DUEL_MENUS
{
DUEL_MENU_GAME_MENU,
DUEL_MENU_CHOOSE_DECK,
DUEL_MENU_CHOOSE_OPPONENT
};
GameStateDuel::GameStateDuel(GameApp* parent): GameState(parent) { GameStateDuel::GameStateDuel(GameApp* parent): GameState(parent) {
for (int i = 0; i<2; i ++){ for (int i = 0; i<2; i ++){
deck[i]=NULL; deck[i]=NULL;
@@ -43,14 +66,14 @@ void GameStateDuel::Start()
#endif #endif
mGamePhase = DUEL_CHOOSE_DECK1; mGamePhase = DUEL_STATE_CHOOSE_DECK1;
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); mFont = GameApp::CommonRes->GetJLBFont("graphics/simon");
mFont->SetBase(0); // using 2nd font mFont->SetBase(0); // using 2nd font
opponentMenuFont = NEW JLBFont("graphics/f3",16); opponentMenuFont = mFont; //NEW JLBFont("graphics/simon",11);
menu = NEW SimpleMenu(11,this,mFont,SCREEN_WIDTH/2-100,20); menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, mFont, SCREEN_WIDTH/2-100, 25);
menu->Add(12,"Back to main menu"); menu->Add(12,"Back to main menu");
menu->Add(13, "Cancel"); menu->Add(13, "Cancel");
@@ -61,7 +84,7 @@ void GameStateDuel::Start()
if (mParent->players[i] == PLAYER_TYPE_HUMAN){ if (mParent->players[i] == PLAYER_TYPE_HUMAN){
if (!deckmenu){ if (!deckmenu){
decksneeded = 1; decksneeded = 1;
deckmenu = NEW SimpleMenu(1,this,mFont, 10 , 10, "Choose a Deck"); deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, mFont, 35, 25, "Choose a Deck");
char buffer[100]; char buffer[100];
for (int j=1; j<6; j++){ for (int j=1; j<6; j++){
sprintf(buffer, RESPATH"/player/deck%i.txt",j); sprintf(buffer, RESPATH"/player/deck%i.txt",j);
@@ -77,10 +100,7 @@ void GameStateDuel::Start()
} }
if (decksneeded) if (decksneeded)
mGamePhase = ERROR_NO_DECK; mGamePhase = DUEL_STATE_ERROR_NO_DECK;
} }
@@ -152,7 +172,6 @@ void GameStateDuel::End()
SAFE_DELETE(menu); SAFE_DELETE(menu);
SAFE_DELETE(opponentMenu); SAFE_DELETE(opponentMenu);
SAFE_DELETE(opponentMenuFont);
#ifdef TESTSUITE #ifdef TESTSUITE
SAFE_DELETE(testSuite); SAFE_DELETE(testSuite);
#endif #endif
@@ -163,40 +182,44 @@ void GameStateDuel::Update(float dt)
{ {
switch (mGamePhase) switch (mGamePhase)
{ {
case ERROR_NO_DECK: case DUEL_STATE_ERROR_NO_DECK:
if (PSP_CTRL_CIRCLE == mEngine->ReadButton()) if (PSP_CTRL_CIRCLE == mEngine->ReadButton())
mParent->SetNextState(GAME_STATE_DECK_VIEWER); mParent->SetNextState(GAME_STATE_DECK_VIEWER);
break; break;
case DUEL_CHOOSE_DECK1: case DUEL_STATE_CHOOSE_DECK1:
if (mParent->players[0] == PLAYER_TYPE_HUMAN) if (mParent->players[0] == PLAYER_TYPE_HUMAN)
deckmenu->Update(dt); deckmenu->Update(dt);
#ifdef TESTSUITE #ifdef TESTSUITE
else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){ else if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
if (testSuite && testSuite->loadNext()){ if (testSuite && testSuite->loadNext()){
loadTestSuitePlayers(); loadTestSuitePlayers();
mGamePhase = DUEL_PLAY; mGamePhase = DUEL_STATE_PLAY;
testSuite->initGame(); testSuite->initGame();
char buf[4096]; char buf[4096];
sprintf(buf, "nb cards in player2's graveyard : %i\n",mPlayers[1]->game->graveyard->nb_cards); sprintf(buf, "nb cards in player2's graveyard : %i\n",mPlayers[1]->game->graveyard->nb_cards);
LOG(buf); LOG(buf);
}else{ }else{
mGamePhase = DUEL_END; mGamePhase = DUEL_STATE_END;
} }
} }
#endif #endif
else{ else{
loadPlayer(0); loadPlayer(0);
mGamePhase = DUEL_CHOOSE_DECK2; mGamePhase = DUEL_STATE_CHOOSE_DECK2;
} }
break; break;
case DUEL_CHOOSE_DECK2: case DUEL_STATE_CHOOSE_DECK1_TO_2:
if (deckmenu->closed) mGamePhase = DUEL_STATE_CHOOSE_DECK2;
else deckmenu->Update(dt);
break;
case DUEL_STATE_CHOOSE_DECK2:
if (mParent->players[1] == PLAYER_TYPE_HUMAN){ if (mParent->players[1] == PLAYER_TYPE_HUMAN){
deckmenu->Update(dt); deckmenu->Update(dt);
} }
else{ else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){ if (mParent->players[0] == PLAYER_TYPE_HUMAN){
if (!opponentMenu){ if (!opponentMenu){
opponentMenu = NEW SimpleMenu(13,this,opponentMenuFont,10,10,"Choose Opponent"); opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, opponentMenuFont, 35, 25, "Choose Opponent");
opponentMenu->Add(0,"Random"); opponentMenu->Add(0,"Random");
nbAIDecks = 0; nbAIDecks = 0;
int found = 1; int found = 1;
@@ -229,11 +252,22 @@ void GameStateDuel::Update(float dt)
opponentMenu->Update(dt); opponentMenu->Update(dt);
}else{ }else{
loadPlayer(1); loadPlayer(1);
mGamePhase = DUEL_PLAY; mGamePhase = DUEL_STATE_PLAY;
} }
} }
break; break;
case DUEL_PLAY: case DUEL_STATE_CHOOSE_DECK2_TO_PLAY:
if (mParent->players[1] == PLAYER_TYPE_HUMAN){
if (deckmenu->closed) mGamePhase = DUEL_STATE_PLAY;
else deckmenu->Update(dt);
}
else
{
if (opponentMenu->closed) mGamePhase = DUEL_STATE_PLAY;
else opponentMenu->Update(dt);
}
break;
case DUEL_STATE_PLAY:
//Stop the music before starting the game //Stop the music before starting the game
if (GameApp::music){ if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music); JSoundSystem::GetInstance()->StopMusic(GameApp::music);
@@ -257,15 +291,15 @@ void GameStateDuel::Update(float dt)
playerdata->save(); playerdata->save();
delete playerdata; delete playerdata;
} }
mGamePhase = DUEL_END; mGamePhase = DUEL_STATE_END;
#ifdef TESTSUITE #ifdef TESTSUITE
if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){ if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
if (testSuite->loadNext()){ if (testSuite->loadNext()){
loadTestSuitePlayers(); loadTestSuitePlayers();
mGamePhase = DUEL_PLAY; mGamePhase = DUEL_STATE_PLAY;
testSuite->initGame(); testSuite->initGame();
}else{ }else{
mGamePhase = DUEL_END; mGamePhase = DUEL_STATE_END;
} }
}else }else
#endif #endif
@@ -276,12 +310,22 @@ void GameStateDuel::Update(float dt)
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
} }
if (mEngine->GetButtonClick(PSP_CTRL_START)){ if (mEngine->GetButtonClick(PSP_CTRL_START)){
mGamePhase = DUEL_MENU; mGamePhase = DUEL_STATE_MENU;
} }
break; break;
case DUEL_MENU: case DUEL_STATE_MENU:
menu->Update(dt); menu->Update(dt);
break; break;
case DUEL_STATE_CANCEL:
menu->Update(dt);
if (menu->closed)
mGamePhase = DUEL_STATE_PLAY;
break;
case DUEL_STATE_BACK_TO_MAIN_MENU:
menu->Update(dt);
if (menu->closed)
mParent->SetNextState(GAME_STATE_MENU);
break;
default: default:
if (PSP_CTRL_CIRCLE == mEngine->ReadButton()){ if (PSP_CTRL_CIRCLE == mEngine->ReadButton()){
mParent->SetNextState(GAME_STATE_MENU); mParent->SetNextState(GAME_STATE_MENU);
@@ -295,10 +339,12 @@ void GameStateDuel::Render()
//Erase //Erase
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0)); JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
if (game) if (game)
game->Render(); game->Render();
if (mGamePhase == DUEL_END){ switch (mGamePhase)
{
case DUEL_STATE_END:
{
JRenderer::GetInstance()->ClearScreen(ARGB(200,0,0,0)); JRenderer::GetInstance()->ClearScreen(ARGB(200,0,0,0));
char buffer[50]; char buffer[50];
int p0life = mPlayers[0]->life; int p0life = mPlayers[0]->life;
@@ -316,34 +362,44 @@ void GameStateDuel::Render()
sprintf(buffer, "Player %i wins (%i)", winner, p0life ); sprintf(buffer, "Player %i wins (%i)", winner, p0life );
} }
mFont->DrawString(buffer, 10, 150); mFont->DrawString(buffer, 10, 150);
}else if (mGamePhase == DUEL_CHOOSE_DECK1 || mGamePhase == DUEL_CHOOSE_DECK2){ break;
}
case DUEL_STATE_CHOOSE_DECK1:
case DUEL_STATE_CHOOSE_DECK1_TO_2:
case DUEL_STATE_CHOOSE_DECK2:
case DUEL_STATE_CHOOSE_DECK2_TO_PLAY:
if (opponentMenu){ if (opponentMenu){
opponentMenu->Render(); opponentMenu->Render();
}else if (deckmenu){ }else if (deckmenu){
deckmenu->Render(); deckmenu->Render();
} }
}else if (mGamePhase == ERROR_NO_DECK){ break;
case DUEL_STATE_ERROR_NO_DECK:
mFont->DrawString("NO DECK AVAILABLE,",0,SCREEN_HEIGHT/2); mFont->DrawString("NO DECK AVAILABLE,",0,SCREEN_HEIGHT/2);
mFont->DrawString("PRESS CIRCLE TO GO TO THE DECK EDITOR!",0,SCREEN_HEIGHT/2 + 20); mFont->DrawString("PRESS CIRCLE TO GO TO THE DECK EDITOR!",0,SCREEN_HEIGHT/2 + 20);
}else if (mGamePhase == DUEL_MENU){ break;
case DUEL_STATE_MENU:
case DUEL_STATE_CANCEL:
case DUEL_STATE_BACK_TO_MAIN_MENU:
menu->Render(); menu->Render();
} }
} }
void GameStateDuel::ButtonPressed(int controllerId, int controlId) void GameStateDuel::ButtonPressed(int controllerId, int controlId)
{ {
switch (controllerId){ switch (controllerId){
case 13: case DUEL_MENU_CHOOSE_OPPONENT:
{ {
switch(controlId){ switch(controlId){
case 0: case 0:
loadPlayer(1); loadPlayer(1);
mGamePhase = DUEL_PLAY; opponentMenu->Close();
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
break; break;
default: default:
loadPlayer(1,controlId,1); loadPlayer(1,controlId,1);
mGamePhase = DUEL_PLAY; opponentMenu->Close();
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
break; break;
} }
@@ -359,20 +415,24 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
case 4: case 4:
case 5: case 5:
{ {
if (mGamePhase == DUEL_CHOOSE_DECK1){ if (mGamePhase == DUEL_STATE_CHOOSE_DECK1){
loadPlayer(0,controlId); loadPlayer(0,controlId);
mGamePhase = DUEL_CHOOSE_DECK2; deckmenu->Close();
mGamePhase = DUEL_STATE_CHOOSE_DECK1_TO_2;
}else{ }else{
loadPlayer(1,controlId); loadPlayer(1,controlId);
mGamePhase = DUEL_PLAY; deckmenu->Close();
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
} }
break; break;
} }
case 12: case 12:
mParent->SetNextState(GAME_STATE_MENU); menu->Close();
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
break; break;
case 13: case 13:
mGamePhase = DUEL_PLAY; menu->Close();
mGamePhase = DUEL_STATE_CANCEL;
break; break;
} }
} }
+2 -2
View File
@@ -90,7 +90,7 @@ void GameStateMenu::Create()
} }
} }
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); mFont = GameApp::CommonRes->GetJLBFont("graphics/simon");
//mFont->SetBase(0); // using 2nd font //mFont->SetBase(0); // using 2nd font
mGuiController = NEW JGuiController(100, this); mGuiController = NEW JGuiController(100, this);
//mGuiController->SetShadingBackground(10, 45, 80, 100, ARGB(255,0,0,0)); //mGuiController->SetShadingBackground(10, 45, 80, 100, ARGB(255,0,0,0));
@@ -366,7 +366,7 @@ void GameStateMenu::Render()
if (mGuiController!=NULL) if (mGuiController!=NULL)
mGuiController->Render(); mGuiController->Render();
mFont->SetScale(0.7); // mFont->SetScale(0.7);
mFont->SetColor(ARGB(128,255,255,255)); mFont->SetColor(ARGB(128,255,255,255));
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT); mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15); mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
+1 -2
View File
@@ -5,9 +5,8 @@
MTGGamePhase::MTGGamePhase(int id):ActionElement(id){ MTGGamePhase::MTGGamePhase(int id):ActionElement(id){
animation = 0; animation = 0;
currentState = -1; currentState = -1;
mFont= GameApp::CommonRes->GetJLBFont("graphics/f3"); mFont= GameApp::CommonRes->GetJLBFont("graphics/simon");
mFont->SetBase(0); // using 2nd font mFont->SetBase(0); // using 2nd font
} }
+1 -1
View File
@@ -6,7 +6,7 @@ MTGGuiHand::MTGGuiHand(int id, GameObserver * _game):GuiCardsController(id, _gam
mShowHand = HAND_HIDE; mShowHand = HAND_HIDE;
mAnimState = 0; mAnimState = 0;
currentPlayer = NULL; currentPlayer = NULL;
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); mFont = GameApp::CommonRes->GetJLBFont("graphics/simon");
for (int i = 0; i < 2; i++){ for (int i = 0; i < 2; i++){
currentId[i] = 0; currentId[i] = 0;
} }
+1 -4
View File
@@ -34,9 +34,7 @@ MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id,
mGlitter = NEW JQuad(mPhaseBarTexture, 392, 0, 5, 5); mGlitter = NEW JQuad(mPhaseBarTexture, 392, 0, 5, 5);
mGlitter->SetHotSpot(2.5,2.5); mGlitter->SetHotSpot(2.5,2.5);
mGlitterAlpha = -1; mGlitterAlpha = -1;
mFont= GameApp::CommonRes->GetJLBFont("graphics/f3"); mFont= GameApp::CommonRes->GetJLBFont("graphics/simon");
mFont->SetScale(0.75);
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM); mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
//load all the icon images //load all the icon images
@@ -308,7 +306,6 @@ void MTGGuiPlay::RenderPhaseBar(){
} }
renderer->RenderQuad(phaseIcons[index], 200 + 14*i,0,0,0.5,0.5); renderer->RenderQuad(phaseIcons[index], 200 + 14*i,0,0,0.5,0.5);
} }
mFont->SetScale(0.70);
if (game->currentlyActing()->isAI()){ if (game->currentlyActing()->isAI()){
mFont->SetColor(ARGB(255,128,128,128)); mFont->SetColor(ARGB(255,128,128,128));
}else{ }else{
+1 -5
View File
@@ -4,14 +4,10 @@
MenuItem::MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mText(text), mX(x), mY(y) MenuItem::MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mText(text), mX(x), mY(y)
{ {
updatedSinceLastRender = 1; updatedSinceLastRender = 1;
mParticleSys = NEW hgeParticleSystem(particle, particleTex); mParticleSys = NEW hgeParticleSystem(particle, particleTex);
mParticleSys->MoveTo(mX, mY); mParticleSys->MoveTo(mX, mY);
mHasFocus = hasFocus; mHasFocus = hasFocus;
lastDt = 0.001f; lastDt = 0.001f;
mScale = 1.0f; mScale = 1.0f;
@@ -22,7 +18,7 @@ MenuItem::MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad
if (hasFocus) if (hasFocus)
Entering(); Entering();
mFont->SetScale(1.2f); // mFont->SetScale(1.2f);
} }
+45 -10
View File
@@ -5,21 +5,27 @@
#include "../include/GameApp.h" #include "../include/GameApp.h"
const unsigned SimpleMenu::SIDE_SIZE = 7; const unsigned SimpleMenu::SIDE_SIZE = 7;
const unsigned SimpleMenu::VMARGIN = 8; const unsigned SimpleMenu::VMARGIN = 12;
const unsigned SimpleMenu::HMARGIN = 27; const unsigned SimpleMenu::HMARGIN = 27;
const unsigned SimpleMenu::LINE_HEIGHT = 20; const signed SimpleMenu::LINE_HEIGHT = 16;
const char* SimpleMenu::spadeLPath = "graphics/spade_ul.png"; const char* SimpleMenu::spadeLPath = "graphics/spade_ul.png";
const char* SimpleMenu::spadeRPath = "graphics/spade_ur.png"; const char* SimpleMenu::spadeRPath = "graphics/spade_ur.png";
const char* SimpleMenu::jewelPath = "graphics/jewel.png"; const char* SimpleMenu::jewelPath = "graphics/jewel.png";
const char* SimpleMenu::sidePath = "graphics/menuside.png"; const char* SimpleMenu::sidePath = "graphics/menuside.png";
const char* SimpleMenu::titleFontPath = "graphics/smallface"; const char* SimpleMenu::titleFontPath = "graphics/smallface";
JQuad* SimpleMenu::spadeR = NULL; JQuad* SimpleMenu::spadeR = NULL;
JQuad* SimpleMenu::spadeL = NULL; JQuad* SimpleMenu::spadeL = NULL;
JQuad* SimpleMenu::jewel = NULL; JQuad* SimpleMenu::jewel = NULL;
JQuad* SimpleMenu::side = NULL; JQuad* SimpleMenu::side = NULL;
JLBFont* SimpleMenu::titleFont = NULL; JLBFont* SimpleMenu::titleFont = NULL;
hgeParticleSystem* SimpleMenu::stars = NULL;
unsigned int SimpleMenu::refCount = 0;
// Here comes the magic of jewel graphics
PIXEL_TYPE SimpleMenu::jewelGraphics[9] = {0x3FFFFFFF,0x63645AEA,0x610D0D98,
0x63645AEA,0xFF635AD5,0xFF110F67,
0x610D0D98,0xFF110F67,0xFD030330};
SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title, int _maxItems): JGuiController(id, listener){ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title, int _maxItems): JGuiController(id, listener){
mHeight = 2 * VMARGIN; mHeight = 2 * VMARGIN;
@@ -34,26 +40,45 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int
selectionT = 0; selectionT = 0;
timeOpen = 0; timeOpen = 0;
closed = false; closed = false;
++refCount;
JRenderer* renderer = JRenderer::GetInstance(); JRenderer* renderer = JRenderer::GetInstance();
static JTexture* spadeLTex = renderer->LoadTexture(spadeLPath, TEX_TYPE_USE_VRAM); static JTexture* spadeLTex = renderer->LoadTexture(spadeLPath, TEX_TYPE_USE_VRAM);
static JTexture* spadeRTex = renderer->LoadTexture(spadeRPath, TEX_TYPE_USE_VRAM); static JTexture* spadeRTex = renderer->LoadTexture(spadeRPath, TEX_TYPE_USE_VRAM);
static JTexture* jewelTex = renderer->LoadTexture(jewelPath, TEX_TYPE_USE_VRAM); static JTexture* jewelTex = renderer->CreateTexture(5, 5, TEX_TYPE_USE_VRAM);
static JTexture* sideTex = renderer->LoadTexture(sidePath, TEX_TYPE_USE_VRAM); static JTexture* sideTex = renderer->LoadTexture(sidePath, TEX_TYPE_USE_VRAM);
if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 2, 1, 16, 13); if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 2, 1, 16, 13);
if (NULL == spadeR) spadeR = NEW JQuad(spadeRTex, 2, 1, 16, 13); if (NULL == spadeR) spadeR = NEW JQuad(spadeRTex, 2, 1, 16, 13);
if (NULL == jewel) jewel = NEW JQuad(jewelTex, 0, 0, 3, 3); if (NULL == jewel) jewel = NEW JQuad(jewelTex, 1, 1, 3, 3);
if (NULL == side) side = NEW JQuad(sideTex, 0, 1, 1, 7); if (NULL == side) side = NEW JQuad(sideTex, 0, 1, 1, 7);
if (NULL == titleFont) if (NULL == titleFont)
{ {
GameApp::CommonRes->LoadJLBFont(titleFontPath, 7); GameApp::CommonRes->LoadJLBFont(titleFontPath, 7);
titleFont = GameApp::CommonRes->GetJLBFont(titleFontPath); titleFont = GameApp::CommonRes->GetJLBFont(titleFontPath);
} }
if (NULL == stars) stars = NEW hgeParticleSystem("graphics/stars.psi", GameApp::CommonRes->GetQuad("stars"));
stars = NEW hgeParticleSystem("graphics/stars.psi", GameApp::CommonRes->GetQuad("stars"));
stars->MoveTo(mX, mY); stars->MoveTo(mX, mY);
} }
inline void SimpleMenu::MogrifyJewel()
{
PIXEL_TYPE tmpBuf[sizeof(jewelGraphics)/sizeof(jewelGraphics[0])];
if (!(random() & 0x7E))
for (int i = sizeof(jewelGraphics) / sizeof(jewelGraphics[0]) - 1; i >= 0; --i)
{
unsigned int v = jewelGraphics[i];
if (v & 0x80) tmpBuf[i] = 0xFF; else tmpBuf[i] = v & 0xFF;
if (v & 0x8000) tmpBuf[i] += 0xFF00; else tmpBuf[i] += (v & 0x7F00) << 1;
if (v & 0x800000) tmpBuf[i] += 0xFF0000; else tmpBuf[i] += (v & 0x7F0000) << 1;
tmpBuf[i] += v & 0xFF000000;
}
else
for (int i = sizeof(jewelGraphics) / sizeof(jewelGraphics[0]) - 1; i >= 0; --i)
tmpBuf[i] = jewelGraphics[i];
jewel->mTex->UpdateBits(1, 1, 3, 3, tmpBuf);
}
void SimpleMenu::drawHorzPole(int x, int y, int width) void SimpleMenu::drawHorzPole(int x, int y, int width)
{ {
JRenderer* renderer = JRenderer::GetInstance(); JRenderer* renderer = JRenderer::GetInstance();
@@ -64,7 +89,9 @@ void SimpleMenu::drawHorzPole(int x, int y, int width)
renderer->RenderQuad(spadeR, x - 9, y - 6); renderer->RenderQuad(spadeR, x - 9, y - 6);
renderer->RenderQuad(spadeL, x + width - 5, y - 6); renderer->RenderQuad(spadeL, x + width - 5, y - 6);
renderer->RenderQuad(jewel, x - 1, y - 1); MogrifyJewel();
renderer->RenderQuad(jewel, x, y - 1);
renderer->RenderQuad(jewel, x + width - 1, y - 1); renderer->RenderQuad(jewel, x + width - 1, y - 1);
} }
void SimpleMenu::drawVertPole(int x, int y, int height) void SimpleMenu::drawVertPole(int x, int y, int height)
@@ -77,6 +104,8 @@ void SimpleMenu::drawVertPole(int x, int y, int height)
renderer->RenderQuad(spadeR, x - 6, y + 7, -M_PI/2); renderer->RenderQuad(spadeR, x - 6, y + 7, -M_PI/2);
renderer->RenderQuad(spadeL, x - 6, y + height + 11, -M_PI/2); renderer->RenderQuad(spadeL, x - 6, y + height + 11, -M_PI/2);
MogrifyJewel();
renderer->RenderQuad(jewel, x - 1, y - 1); renderer->RenderQuad(jewel, x - 1, y - 1);
renderer->RenderQuad(jewel, x - 1, y + height - 1); renderer->RenderQuad(jewel, x - 1, y + height - 1);
} }
@@ -89,6 +118,7 @@ void SimpleMenu::Render(){
int width = (static_cast<SimpleMenuItem*>(mObjects[i]))->GetWidth(); int width = (static_cast<SimpleMenuItem*>(mObjects[i]))->GetWidth();
if (mWidth < width) mWidth = width; if (mWidth < width) mWidth = width;
} }
if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str()))) mWidth = titleFont->GetStringWidth(title.c_str());
mWidth += 2*HMARGIN; mWidth += 2*HMARGIN;
for (int i = startId; i < startId + mCount; ++i) for (int i = startId; i < startId + mCount; ++i)
static_cast<SimpleMenuItem*>(mObjects[i])->Relocate(mX + mWidth / 2, mY + VMARGIN + i * LINE_HEIGHT); static_cast<SimpleMenuItem*>(mObjects[i])->Relocate(mX + mWidth / 2, mY + VMARGIN + i * LINE_HEIGHT);
@@ -108,6 +138,12 @@ void SimpleMenu::Render(){
drawVertPole(mX, mY - 16, height + 32); drawVertPole(mX, mY - 16, height + 32);
drawVertPole(mX + mWidth, mY - 16, height + 32); drawVertPole(mX + mWidth, mY - 16, height + 32);
drawHorzPole(mX - 16, mY, mWidth + 32); drawHorzPole(mX - 16, mY, mWidth + 32);
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_DST_ALPHA);
stars->Render();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
mFont->SetScale(1.0f);
if (!title.empty()) if (!title.empty())
titleFont->DrawString(title.c_str(), mX+mWidth/2, mY - 3, JGETEXT_CENTER); titleFont->DrawString(title.c_str(), mX+mWidth/2, mY - 3, JGETEXT_CENTER);
for (int i = startId; i < startId + maxItems ; i++){ for (int i = startId; i < startId + maxItems ; i++){
@@ -115,9 +151,6 @@ void SimpleMenu::Render(){
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7) if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7)
(static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId); (static_cast<SimpleMenuItem*>(mObjects[i]))->RenderWithOffset(-LINE_HEIGHT*startId);
} }
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_DST_ALPHA);
stars->Render();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
drawHorzPole(mX - 25, mY + height, mWidth + 50); drawHorzPole(mX - 25, mY + height, mWidth + 50);
} }
@@ -140,6 +173,7 @@ void SimpleMenu::Update(float dt){
} }
else else
{ {
closed = false;
timeOpen += dt * 10; timeOpen += dt * 10;
} }
} }
@@ -152,4 +186,5 @@ void SimpleMenu::Add(int id, const char * text){
void SimpleMenu::Close() void SimpleMenu::Close()
{ {
timeOpen = -1.0; timeOpen = -1.0;
stars->Stop(true);
} }
+5 -5
View File
@@ -12,16 +12,16 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, const
if (hasFocus) if (hasFocus)
Entering(); Entering();
mFont->SetScale(1.2f); // mFont->SetScale(1.2f);
} }
void SimpleMenuItem::RenderWithOffset(float yOffset) void SimpleMenuItem::RenderWithOffset(float yOffset)
{ {
mFont->SetScale(mScale); // mFont->SetScale(mScale);
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER); mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
mFont->SetScale(1.0f); // mFont->SetScale(1.0f);
} }
void SimpleMenuItem::Render() void SimpleMenuItem::Render()
@@ -31,7 +31,7 @@ void SimpleMenuItem::Render()
void SimpleMenuItem::Update(float dt) void SimpleMenuItem::Update(float dt)
{ {
if (mScale < mTargetScale) /* if (mScale < mTargetScale)
{ {
mScale += 8.0f*dt; mScale += 8.0f*dt;
if (mScale > mTargetScale) if (mScale > mTargetScale)
@@ -42,7 +42,7 @@ void SimpleMenuItem::Update(float dt)
mScale -= 8.0f*dt; mScale -= 8.0f*dt;
if (mScale < mTargetScale) if (mScale < mTargetScale)
mScale = mTargetScale; mScale = mTargetScale;
} }*/
} }