J :
* New menu style - step one. More improvements are to come, but this should be stable and have a good portion of what is to be done.
This commit is contained in:
@@ -13,6 +13,10 @@ PSPSDK = $(shell psp-config --pspsdk-path)
|
|||||||
PSPDIR = $(shell psp-config --psp-prefix)
|
PSPDIR = $(shell psp-config --psp-prefix)
|
||||||
TARGET = template
|
TARGET = template
|
||||||
endif
|
endif
|
||||||
|
ifeq ($(MAKECMDGOALS),debug)
|
||||||
|
DEFAULT_RULE = debug
|
||||||
|
TARGET_ARCHITECTURE = linux
|
||||||
|
endif
|
||||||
ifeq ($(MAKECMDGOALS),linux)
|
ifeq ($(MAKECMDGOALS),linux)
|
||||||
DEFAULT_RULE = linux
|
DEFAULT_RULE = linux
|
||||||
TARGET_ARCHITECTURE = linux
|
TARGET_ARCHITECTURE = linux
|
||||||
@@ -52,9 +56,12 @@ CXXFLAGS := $(INCDIR) $(CXXFLAGS)
|
|||||||
LDFLAGS := $(LIBS)
|
LDFLAGS := $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: $(DEFAULT_RULE)
|
all: $(DEFAULT_RULE)
|
||||||
|
|
||||||
debug: CXXFLAGS += -ggdb3 -D_DEBUG -DDEBUG
|
debug: CXXFLAGS = -Wall -W -Werror -Wno-unused -DDEVHOOK -DPSPFW3XX -fno-exceptions -fno-rtti -ggdb3 -D_DEBUG -DDEBUG -DLINUX $(INCDIR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(TARGET_ARCHITECTURE),psp)
|
ifeq ($(TARGET_ARCHITECTURE),psp)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.3 KiB |
@@ -7,16 +7,15 @@ class JGE;
|
|||||||
|
|
||||||
#include <JSoundSystem.h>
|
#include <JSoundSystem.h>
|
||||||
|
|
||||||
enum _gameSates
|
enum ENUM_GAME_STATE
|
||||||
{
|
{
|
||||||
GAME_STATE_MENU,
|
GAME_STATE_MENU = 0x01,
|
||||||
GAME_STATE_DUEL,
|
GAME_STATE_DUEL = 0x02,
|
||||||
GAME_STATE_DECK_VIEWER,
|
GAME_STATE_DECK_VIEWER = 0x03,
|
||||||
GAME_STATE_SHOP,
|
GAME_STATE_SHOP = 0x04,
|
||||||
GAME_STATE_OPTIONS
|
GAME_STATE_OPTIONS = 0x05,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GameApp;
|
class GameApp;
|
||||||
|
|
||||||
class GameState
|
class GameState
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20,200);
|
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20);
|
||||||
menu->Add(11,"Save");
|
menu->Add(11,"Save");
|
||||||
menu->Add(12,"Back to main menu");
|
menu->Add(12,"Back to main menu");
|
||||||
menu->Add(13, "Cancel");
|
menu->Add(13, "Cancel");
|
||||||
@@ -185,7 +185,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
|
|
||||||
//menuFont = NEW JLBFont("graphics/f3",16);
|
//menuFont = NEW JLBFont("graphics/f3",16);
|
||||||
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20,200);
|
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
for (int i=1; i < 6; i++){
|
for (int i=1; i < 6; i++){
|
||||||
sprintf(buffer, RESPATH"/player/deck%i.txt",i);
|
sprintf(buffer, RESPATH"/player/deck%i.txt",i);
|
||||||
@@ -325,7 +325,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
price = pricelist->getPrice(card->getMTGId()) / 2;
|
price = pricelist->getPrice(card->getMTGId()) / 2;
|
||||||
price = price - price * (rnd -10)/100;
|
price = price - price * (rnd -10)/100;
|
||||||
sprintf(buffer,"%s : %i credits",card->getName(),price);
|
sprintf(buffer,"%s : %i credits",card->getName(),price);
|
||||||
sellMenu = NEW SimpleMenu(2,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,270,buffer);
|
sellMenu = NEW SimpleMenu(2,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||||
sellMenu->Add(20,"Yes");
|
sellMenu->Add(20,"Yes");
|
||||||
sellMenu->Add(21,"No");
|
sellMenu->Add(21,"No");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,21 +12,51 @@
|
|||||||
#include "../include/GameOptions.h"
|
#include "../include/GameOptions.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const char* GAME_VERSION = "WTH?! 0.3.1 - by WilLoW";
|
||||||
#define STATE_MENU 0
|
|
||||||
#define STATE_SUBMENU 1
|
|
||||||
#define STATE_LOADING_MENU 2
|
|
||||||
#define STATE_LOADING_CARDS 3
|
|
||||||
#define STATE_FIRST_TIME 4
|
|
||||||
#define STATE_WARNING 5
|
|
||||||
|
|
||||||
#define GAME_VERSION "WTH?! 0.3.1 - by WilLoW"
|
|
||||||
#define ALPHA_WARNING 0
|
#define ALPHA_WARNING 0
|
||||||
|
|
||||||
#define DEFAULT_ANGLE_MULTIPLIER 0.4
|
#define DEFAULT_ANGLE_MULTIPLIER 0.4
|
||||||
#define MAX_ANGLE_MULTIPLIER (3*M_PI)
|
#define MAX_ANGLE_MULTIPLIER (3*M_PI)
|
||||||
#define MIN_ANGLE_MULTIPLIER 0.4
|
#define MIN_ANGLE_MULTIPLIER 0.4
|
||||||
#define STEP_ANGLE_MULTIPLIER 0.0002
|
static const double STEP_ANGLE_MULTIPLIER = 0.0002;
|
||||||
|
|
||||||
|
|
||||||
|
enum ENUM_MENU_STATE_MAJOR
|
||||||
|
{
|
||||||
|
MENU_STATE_MAJOR_MAINMENU = 0x01,
|
||||||
|
MENU_STATE_MAJOR_SUBMENU = 0x02,
|
||||||
|
MENU_STATE_MAJOR_LOADING_MENU = 0x03,
|
||||||
|
MENU_STATE_MAJOR_LOADING_CARDS = 0x04,
|
||||||
|
MENU_STATE_MAJOR_FIRST_TIME = 0x05,
|
||||||
|
MENU_STATE_MAJOR_WARNING = 0x06,
|
||||||
|
MENU_STATE_MAJOR_DUEL = 0x07,
|
||||||
|
|
||||||
|
MENU_STATE_MAJOR = 0xFF
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ENUM_MENU_STATE_MINOR
|
||||||
|
{
|
||||||
|
MENU_STATE_MINOR_NONE = 0,
|
||||||
|
MENU_STATE_MINOR_SUBMENU_CLOSING = 0x100,
|
||||||
|
|
||||||
|
MENU_STATE_MINOR = 0xF00
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MENUITEM_PLAY,
|
||||||
|
MENUITEM_DECKEDITOR,
|
||||||
|
MENUITEM_SHOP,
|
||||||
|
MENUITEM_OPTIONS,
|
||||||
|
MENUITEM_EXIT,
|
||||||
|
SUBMENUITEM_1PLAYER,
|
||||||
|
SUBMENUITEM_2PLAYER,
|
||||||
|
SUBMENUITEM_DEMO,
|
||||||
|
SUBMENUITEM_CANCEL,
|
||||||
|
SUBMENUITEM_TESTSUITE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class GameStateMenu: public GameState, public JGuiListener
|
class GameStateMenu: public GameState, public JGuiListener
|
||||||
|
|
||||||
@@ -107,28 +137,21 @@ class GameStateMenu: public GameState, public JGuiListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||||
//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));
|
||||||
if (mGuiController)
|
if (mGuiController)
|
||||||
{
|
{
|
||||||
mGuiController->Add(NEW MenuItem(1, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"graphics/particle1.psi",GameApp::CommonRes->GetQuad("particles"), true));
|
mGuiController->Add(NEW MenuItem(MENUITEM_PLAY, mFont, "Play", 80, 50 + SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"graphics/particle1.psi",GameApp::CommonRes->GetQuad("particles"), true));
|
||||||
mGuiController->Add(NEW MenuItem(2, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"graphics/particle2.psi",GameApp::CommonRes->GetQuad("particles")));
|
mGuiController->Add(NEW MenuItem(MENUITEM_DECKEDITOR, mFont, "Deck Editor", 160, 50 + SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"graphics/particle2.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||||
mGuiController->Add(NEW MenuItem(3, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"graphics/particle3.psi",GameApp::CommonRes->GetQuad("particles")));
|
mGuiController->Add(NEW MenuItem(MENUITEM_SHOP, mFont, "Shop", 240, 50 + SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"graphics/particle3.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||||
mGuiController->Add(NEW MenuItem(4, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"graphics/particle4.psi",GameApp::CommonRes->GetQuad("particles")));
|
mGuiController->Add(NEW MenuItem(MENUITEM_OPTIONS, mFont, "Options", 320, 50 + SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"graphics/particle4.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||||
mGuiController->Add(NEW MenuItem(5, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"graphics/particle5.psi",GameApp::CommonRes->GetQuad("particles")));
|
mGuiController->Add(NEW MenuItem(MENUITEM_EXIT, mFont, "Exit", 400, 50 + SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"graphics/particle5.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
currentState = STATE_LOADING_CARDS;
|
currentState = MENU_STATE_MAJOR_LOADING_CARDS | MENU_STATE_MINOR_NONE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +183,7 @@ class GameStateMenu: public GameState, public JGuiListener
|
|||||||
virtual void Start(){
|
virtual void Start(){
|
||||||
JRenderer::GetInstance()->ResetPrivateVRAM();
|
JRenderer::GetInstance()->ResetPrivateVRAM();
|
||||||
JRenderer::GetInstance()->EnableVSync(true);
|
JRenderer::GetInstance()->EnableVSync(true);
|
||||||
subMenuController = NULL;
|
subMenuController = NULL;
|
||||||
|
|
||||||
if (GameApp::HasMusic && !GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
|
if (GameApp::HasMusic && !GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
|
||||||
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3");
|
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3");
|
||||||
@@ -224,69 +247,80 @@ subMenuController = NULL;
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeIndex += dt * 2;
|
timeIndex += dt * 2;
|
||||||
if (currentState == STATE_LOADING_CARDS){
|
switch (MENU_STATE_MAJOR & currentState)
|
||||||
if (mReadConf){
|
{
|
||||||
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
|
case MENU_STATE_MAJOR_LOADING_CARDS :
|
||||||
}else{
|
if (mReadConf){
|
||||||
mReadConf = 1;
|
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
|
||||||
}
|
|
||||||
if (!nextCardSet()){
|
|
||||||
//How many cards total ?
|
|
||||||
sprintf(nbcardsStr, "Database: %i cards", mParent->collection->totalCards());
|
|
||||||
//Check for first time comer
|
|
||||||
std::ifstream file(RESPATH"/player/collection.dat");
|
|
||||||
if(file){
|
|
||||||
file.close();
|
|
||||||
currentState = STATE_WARNING;
|
|
||||||
}else{
|
}else{
|
||||||
currentState = STATE_FIRST_TIME;
|
mReadConf = 1;
|
||||||
}
|
}
|
||||||
}
|
if (!nextCardSet()){
|
||||||
}else if (currentState == STATE_FIRST_TIME){
|
//How many cards total ?
|
||||||
//Give the player cards from the set for which we have the most variety
|
sprintf(nbcardsStr, "Database: %i cards", mParent->collection->totalCards());
|
||||||
int setId = 0;
|
//Check for first time comer
|
||||||
int maxcards = 0;
|
std::ifstream file(RESPATH"/player/collection.dat");
|
||||||
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
if(file){
|
||||||
int value = mParent->collection->countBySet(i);
|
file.close();
|
||||||
if (value > maxcards){
|
currentState = MENU_STATE_MAJOR_WARNING | MENU_STATE_MINOR_NONE;
|
||||||
maxcards = value;
|
}else{
|
||||||
setId = i;
|
currentState = MENU_STATE_MAJOR_FIRST_TIME | MENU_STATE_MINOR_NONE;
|
||||||
}
|
|
||||||
}
|
|
||||||
createUsersFirstDeck(setId);
|
|
||||||
currentState = STATE_WARNING;
|
|
||||||
}else if (currentState == STATE_WARNING){
|
|
||||||
if (!ALPHA_WARNING){
|
|
||||||
currentState = STATE_MENU;
|
|
||||||
}else{
|
|
||||||
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) currentState = STATE_MENU;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (currentState == STATE_MENU && mGuiController!=NULL){
|
|
||||||
mGuiController->Update(dt);
|
|
||||||
SAFE_DELETE(subMenuController);
|
|
||||||
}
|
|
||||||
if (currentState == STATE_SUBMENU){
|
|
||||||
if( subMenuController){
|
|
||||||
subMenuController->Update(dt);
|
|
||||||
}else{
|
|
||||||
|
|
||||||
subMenuController = NEW SimpleMenu(102, this,mFont, 50,170,SCREEN_WIDTH-120);
|
|
||||||
|
|
||||||
if (subMenuController){
|
|
||||||
subMenuController->Add(11,"1 Player");
|
|
||||||
subMenuController->Add(12, "2 Players");
|
|
||||||
subMenuController->Add(13,"Demo");
|
|
||||||
subMenuController->Add(14, "Cancel");
|
|
||||||
#ifdef TESTSUITE
|
|
||||||
subMenuController->Add(666, "Test Suite");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case MENU_STATE_MAJOR_FIRST_TIME :
|
||||||
|
{
|
||||||
|
//Give the player cards from 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++){
|
||||||
|
int value = mParent->collection->countBySet(i);
|
||||||
|
if (value > maxcards){
|
||||||
|
maxcards = value;
|
||||||
|
setId = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createUsersFirstDeck(setId);
|
||||||
|
}
|
||||||
|
currentState = MENU_STATE_MAJOR_WARNING | MENU_STATE_MINOR_NONE;
|
||||||
|
break;
|
||||||
|
case MENU_STATE_MAJOR_WARNING :
|
||||||
|
if (!ALPHA_WARNING){
|
||||||
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
|
}else{
|
||||||
|
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MENU_STATE_MAJOR_MAINMENU :
|
||||||
|
if (mGuiController!=NULL){
|
||||||
|
mGuiController->Update(dt);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MENU_STATE_MAJOR_SUBMENU :
|
||||||
|
subMenuController->Update(dt);
|
||||||
|
mGuiController->Update(dt);
|
||||||
|
break;
|
||||||
|
case MENU_STATE_MAJOR_DUEL :
|
||||||
|
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
|
||||||
|
{
|
||||||
|
mParent->SetNextState(GAME_STATE_DUEL);
|
||||||
|
currentState = MENU_STATE_MAJOR_MAINMENU;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (MENU_STATE_MINOR & currentState)
|
||||||
|
{
|
||||||
|
case MENU_STATE_MINOR_SUBMENU_CLOSING :
|
||||||
|
if (subMenuController->closed)
|
||||||
|
{
|
||||||
|
SAFE_DELETE(subMenuController);
|
||||||
|
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
subMenuController->Update(dt);
|
||||||
|
break;
|
||||||
|
case MENU_STATE_MINOR_NONE :
|
||||||
|
;// Nothing to do.
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (currentState == STATE_WARNING && !ALPHA_WARNING) currentState = STATE_MENU;
|
|
||||||
if (yW <= 55)
|
if (yW <= 55)
|
||||||
{
|
{
|
||||||
if (mEngine->GetButtonState(PSP_CTRL_SQUARE)) angleMultiplier += STEP_ANGLE_MULTIPLIER;
|
if (mEngine->GetButtonState(PSP_CTRL_SQUARE)) angleMultiplier += STEP_ANGLE_MULTIPLIER;
|
||||||
@@ -362,7 +396,7 @@ subMenuController = NULL;
|
|||||||
JRenderer * renderer = JRenderer::GetInstance();
|
JRenderer * renderer = JRenderer::GetInstance();
|
||||||
renderer->ClearScreen(ARGB(0,0,0,0));
|
renderer->ClearScreen(ARGB(0,0,0,0));
|
||||||
|
|
||||||
if (currentState == STATE_LOADING_CARDS){
|
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_LOADING_CARDS){
|
||||||
char text[512];
|
char text[512];
|
||||||
sprintf(text, "LOADING SET: %s", mCurrentSetName);
|
sprintf(text, "LOADING SET: %s", mCurrentSetName);
|
||||||
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
|
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
|
||||||
@@ -391,11 +425,11 @@ subMenuController = NULL;
|
|||||||
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
|
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
|
||||||
mFont->SetScale(1.f);
|
mFont->SetScale(1.f);
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
if (currentState == STATE_SUBMENU && subMenuController){
|
if (subMenuController){
|
||||||
subMenuController->Render();
|
subMenuController->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentState == STATE_WARNING){
|
if ((currentState & MENU_STATE_MAJOR) == MENU_STATE_MAJOR_WARNING){
|
||||||
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(128,0,0,0));
|
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(128,0,0,0));
|
||||||
|
|
||||||
mFont->DrawString("IMPORTANT NOTE" ,SCREEN_WIDTH/2,10,JGETEXT_CENTER);
|
mFont->DrawString("IMPORTANT NOTE" ,SCREEN_WIDTH/2,10,JGETEXT_CENTER);
|
||||||
@@ -426,49 +460,68 @@ subMenuController = NULL;
|
|||||||
switch (controllerId){
|
switch (controllerId){
|
||||||
case 101:
|
case 101:
|
||||||
createUsersFirstDeck(controlId);
|
createUsersFirstDeck(controlId);
|
||||||
currentState = STATE_MENU;
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
switch (controlId)
|
switch (controlId)
|
||||||
{
|
{
|
||||||
case 1:
|
case MENUITEM_PLAY:
|
||||||
currentState = STATE_SUBMENU;
|
#ifdef TESTSUITE
|
||||||
|
subMenuController = NEW SimpleMenu(102, this, mFont, 180,110);
|
||||||
|
#else
|
||||||
|
subMenuController = NEW SimpleMenu(102, this, mFont, 180,110);
|
||||||
|
#endif
|
||||||
|
if (subMenuController){
|
||||||
|
subMenuController->Add(SUBMENUITEM_1PLAYER,"1 Player");
|
||||||
|
subMenuController->Add(SUBMENUITEM_2PLAYER, "2 Players");
|
||||||
|
subMenuController->Add(SUBMENUITEM_DEMO,"Demo");
|
||||||
|
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||||
|
#ifdef TESTSUITE
|
||||||
|
subMenuController->Add(SUBMENUITEM_TESTSUITE, "Test Suite");
|
||||||
|
#endif
|
||||||
|
currentState = MENU_STATE_MAJOR_SUBMENU | MENU_STATE_MINOR_NONE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case MENUITEM_DECKEDITOR:
|
||||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case MENUITEM_SHOP:
|
||||||
mParent->SetNextState(GAME_STATE_SHOP);
|
mParent->SetNextState(GAME_STATE_SHOP);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case MENUITEM_OPTIONS:
|
||||||
mParent->SetNextState(GAME_STATE_OPTIONS);
|
mParent->SetNextState(GAME_STATE_OPTIONS);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case MENUITEM_EXIT:
|
||||||
mEngine->End();
|
mEngine->End();
|
||||||
break;
|
break;
|
||||||
case 11:
|
case SUBMENUITEM_1PLAYER:
|
||||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||||
mParent->SetNextState(GAME_STATE_DUEL);
|
subMenuController->Close();
|
||||||
|
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case SUBMENUITEM_2PLAYER:
|
||||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||||
mParent->SetNextState(GAME_STATE_DUEL);
|
subMenuController->Close();
|
||||||
|
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case SUBMENUITEM_DEMO:
|
||||||
mParent->players[0] = PLAYER_TYPE_CPU;
|
mParent->players[0] = PLAYER_TYPE_CPU;
|
||||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||||
mParent->SetNextState(GAME_STATE_DUEL);
|
subMenuController->Close();
|
||||||
|
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
break;
|
break;
|
||||||
case 14:
|
case SUBMENUITEM_CANCEL:
|
||||||
currentState = STATE_MENU;
|
subMenuController->Close();
|
||||||
|
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
break;
|
break;
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
case 666:
|
case SUBMENUITEM_TESTSUITE:
|
||||||
mParent->players[0] = PLAYER_TYPE_TESTSUITE;
|
mParent->players[0] = PLAYER_TYPE_TESTSUITE;
|
||||||
mParent->players[1] = PLAYER_TYPE_TESTSUITE;
|
mParent->players[1] = PLAYER_TYPE_TESTSUITE;
|
||||||
mParent->SetNextState(GAME_STATE_DUEL);
|
subMenuController->Close();
|
||||||
|
currentState = MENU_STATE_MAJOR_DUEL | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -481,4 +534,3 @@ subMenuController = NULL;
|
|||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -4,22 +4,48 @@
|
|||||||
#ifndef _SIMPLEMENU_H_
|
#ifndef _SIMPLEMENU_H_
|
||||||
#define _SIMPLEMENU_H_
|
#define _SIMPLEMENU_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <JGui.h>
|
#include <JGui.h>
|
||||||
#include <JLBFont.h>
|
#include <JLBFont.h>
|
||||||
#include <string>
|
#include "hge/hgeparticle.h"
|
||||||
|
|
||||||
class SimpleMenu:public JGuiController{
|
class SimpleMenu:public JGuiController{
|
||||||
|
private:
|
||||||
|
// See SimpleMenu.cpp for values
|
||||||
|
static const unsigned SIDE_SIZE;
|
||||||
|
static const unsigned VMARGIN;
|
||||||
|
static const unsigned HMARGIN;
|
||||||
|
static const unsigned LINE_HEIGHT;
|
||||||
|
static const char* spadeLPath;
|
||||||
|
static const char* spadeRPath;
|
||||||
|
static const char* jewelPath;
|
||||||
|
static const char* sidePath;
|
||||||
|
static const char* titleFontPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int mHeight, mWidth, mX, mY;
|
int mHeight, mWidth, mX, mY;
|
||||||
JLBFont* mFont;
|
JLBFont* mFont;
|
||||||
std::string title;
|
std::string title;
|
||||||
int displaytitle;
|
int displaytitle;
|
||||||
int maxItems,startId;
|
int maxItems,startId;
|
||||||
|
hgeParticleSystem* stars;
|
||||||
|
float selectionT, selectionY;
|
||||||
|
float timeOpen;
|
||||||
|
|
||||||
|
static JQuad *spadeR, *spadeL, *jewel, *side;
|
||||||
|
static JLBFont* titleFont;
|
||||||
|
void drawHorzPole(int x, int y, int width);
|
||||||
|
void drawVertPole(int x, int y, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, int width, const char * _title = NULL, int _maxItems = 10);
|
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title = "", int _maxItems = 10);
|
||||||
void Render();
|
void Render();
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
void Add(int id, const char * Text);
|
void Add(int id, const char * Text);
|
||||||
|
void Close();
|
||||||
|
|
||||||
|
float selectionTargetY;
|
||||||
|
bool closed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <JLBFont.h>
|
#include <JLBFont.h>
|
||||||
#include <JGui.h>
|
#include <JGui.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "SimpleMenu.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
@@ -16,18 +17,20 @@ class SimpleMenuItem: public JGuiObject
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool mHasFocus;
|
bool mHasFocus;
|
||||||
|
SimpleMenu* parent;
|
||||||
JLBFont *mFont;
|
JLBFont *mFont;
|
||||||
string mText;
|
string mText;
|
||||||
int mX;
|
|
||||||
int mY;
|
|
||||||
|
|
||||||
float mScale;
|
float mScale;
|
||||||
float mTargetScale;
|
float mTargetScale;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleMenuItem(int id, JLBFont *font, const char* text, int x, int y, bool hasFocus = false);
|
SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, const char* text, int x, int y, bool hasFocus = false);
|
||||||
|
|
||||||
|
int mX;
|
||||||
|
int mY;
|
||||||
|
|
||||||
|
void Relocate(int x, int y);
|
||||||
|
int GetWidth();
|
||||||
|
|
||||||
void RenderWithOffset(float yOffset);
|
void RenderWithOffset(float yOffset);
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
@@ -39,4 +42,3 @@ class SimpleMenuItem: public JGuiObject
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@
|
|||||||
#define TESTSUITE 1
|
#define TESTSUITE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#if defined (_DEBUG) && defined (WIN32)
|
||||||
//if you get the following error :'_NORMAL_BLOCK' : undeclared identifier,
|
#include "crtdbg.h"
|
||||||
// try to add #include "crtdbg.h" somewhere in your code before including this file
|
|
||||||
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
#define NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||||
#else
|
#else
|
||||||
#define NEW new
|
#define NEW new
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ void ActionLayer::setMenuObject(Targetable * object){
|
|||||||
SAFE_DELETE(abilitiesMenu);
|
SAFE_DELETE(abilitiesMenu);
|
||||||
|
|
||||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
|
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(MAIN_FONT);
|
||||||
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100, 200);
|
abilitiesMenu = NEW SimpleMenu(10, this, mFont, 100, 100);
|
||||||
|
|
||||||
for (int i=0;i<mCount;i++){
|
for (int i=0;i<mCount;i++){
|
||||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include <JGE.h>
|
#include <JGE.h>
|
||||||
#include <JRenderer.h>
|
#include <JRenderer.h>
|
||||||
@@ -97,6 +96,9 @@ void GameApp::Create()
|
|||||||
CommonRes->CreateQuad("particles", "graphics/particles.png", 0, 0, 32, 32);
|
CommonRes->CreateQuad("particles", "graphics/particles.png", 0, 0, 32, 32);
|
||||||
CommonRes->GetQuad("particles")->SetHotSpot(16,16);
|
CommonRes->GetQuad("particles")->SetHotSpot(16,16);
|
||||||
|
|
||||||
|
CommonRes->CreateQuad("stars", "graphics/particles.png", 64, 0, 32, 32);
|
||||||
|
CommonRes->GetQuad("stars")->SetHotSpot(16,16);
|
||||||
|
|
||||||
CommonRes->LoadJLBFont("graphics/f3",16);
|
CommonRes->LoadJLBFont("graphics/f3",16);
|
||||||
CommonRes->LoadJLBFont("graphics/magic",16);
|
CommonRes->LoadJLBFont("graphics/magic",16);
|
||||||
|
|
||||||
@@ -121,7 +123,6 @@ void GameApp::Create()
|
|||||||
mGameStates[GAME_STATE_MENU] = NEW GameStateMenu(this);
|
mGameStates[GAME_STATE_MENU] = NEW GameStateMenu(this);
|
||||||
mGameStates[GAME_STATE_MENU]->Create();
|
mGameStates[GAME_STATE_MENU]->Create();
|
||||||
|
|
||||||
|
|
||||||
mGameStates[GAME_STATE_DUEL] = NEW GameStateDuel(this);
|
mGameStates[GAME_STATE_DUEL] = NEW GameStateDuel(this);
|
||||||
mGameStates[GAME_STATE_DUEL]->Create();
|
mGameStates[GAME_STATE_DUEL]->Create();
|
||||||
|
|
||||||
@@ -131,15 +132,10 @@ void GameApp::Create()
|
|||||||
mGameStates[GAME_STATE_OPTIONS] = NEW GameStateOptions(this);
|
mGameStates[GAME_STATE_OPTIONS] = NEW GameStateOptions(this);
|
||||||
mGameStates[GAME_STATE_OPTIONS]->Create();
|
mGameStates[GAME_STATE_OPTIONS]->Create();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//mGameStates[GAME_STATE_GAME] = NEW GameStateGAME(this);
|
//mGameStates[GAME_STATE_GAME] = NEW GameStateGAME(this);
|
||||||
|
|
||||||
mCurrentState = NULL;
|
mCurrentState = NULL;
|
||||||
mNextState = mGameStates[GAME_STATE_MENU];
|
mNextState = mGameStates[GAME_STATE_MENU];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void GameStateDuel::Start()
|
|||||||
opponentMenuFont = NEW JLBFont("graphics/f3",16);
|
opponentMenuFont = NEW JLBFont("graphics/f3",16);
|
||||||
|
|
||||||
|
|
||||||
menu = NEW SimpleMenu(11,this,mFont,SCREEN_WIDTH/2-100,20,200);
|
menu = NEW SimpleMenu(11,this,mFont,SCREEN_WIDTH/2-100,20);
|
||||||
menu->Add(12,"Back to main menu");
|
menu->Add(12,"Back to main menu");
|
||||||
menu->Add(13, "Cancel");
|
menu->Add(13, "Cancel");
|
||||||
|
|
||||||
@@ -61,7 +61,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, 100, "Choose a Deck");
|
deckmenu = NEW SimpleMenu(1,this,mFont, 10 , 10, "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);
|
||||||
@@ -196,7 +196,7 @@ void GameStateDuel::Update(float 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,SCREEN_WIDTH/2,"choose Opponent");
|
opponentMenu = NEW SimpleMenu(13,this,opponentMenuFont,10,10,"Choose Opponent");
|
||||||
opponentMenu->Add(0,"Random");
|
opponentMenu->Add(0,"Random");
|
||||||
nbAIDecks = 0;
|
nbAIDecks = 0;
|
||||||
int found = 1;
|
int found = 1;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ void GameStateOptions::Start()
|
|||||||
if (GameApp::HasMusic) optionsList->Add(NEW OptionItem(OPTIONS_MUSICVOLUME, "Music volume", 100, 10));
|
if (GameApp::HasMusic) optionsList->Add(NEW OptionItem(OPTIONS_MUSICVOLUME, "Music volume", 100, 10));
|
||||||
optionsList->Add(NEW OptionItem(OPTIONS_SFXVOLUME, "SFX volume", 100, 10));
|
optionsList->Add(NEW OptionItem(OPTIONS_SFXVOLUME, "SFX volume", 100, 10));
|
||||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||||
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170,SCREEN_WIDTH-120);
|
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");
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void GameStateShop::Update(float dt)
|
|||||||
if (menu){
|
if (menu){
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
}else{
|
}else{
|
||||||
menu = NEW SimpleMenu(11,this,mFont,SCREEN_WIDTH/2-100,20,200);
|
menu = NEW SimpleMenu(11,this,mFont,SCREEN_WIDTH/2-100,20);
|
||||||
menu->Add(12,"Save & Back to main menu");
|
menu->Add(12,"Save & Back to main menu");
|
||||||
menu->Add(13, "Cancel");
|
menu->Add(13, "Cancel");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,13 +356,6 @@ void MTGGuiPlay::Render(){
|
|||||||
RenderPlayerInfo(0);
|
RenderPlayerInfo(0);
|
||||||
RenderPlayerInfo(1);
|
RenderPlayerInfo(1);
|
||||||
|
|
||||||
if (mCount && mObjects[mCurr] != NULL){
|
|
||||||
mObjects[mCurr]->Render();
|
|
||||||
if (hasFocus && mCurr >= offset && showBigCards){
|
|
||||||
((CardGui *)mObjects[mCurr])->RenderBig(-1,-1,showBigCards-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mGlitterAlpha < 0){
|
if (mGlitterAlpha < 0){
|
||||||
mGlitterAlpha = 510;
|
mGlitterAlpha = 510;
|
||||||
int position = rand() % 2;
|
int position = rand() % 2;
|
||||||
@@ -378,6 +371,12 @@ void MTGGuiPlay::Render(){
|
|||||||
renderer->RenderQuad(mGlitter,mGlitterX,mGlitterY, (float)(mGlitterAlpha)/(float)255, 1.2*float(mGlitterAlpha)/float(255),1.2*float(mGlitterAlpha)/float(255));
|
renderer->RenderQuad(mGlitter,mGlitterX,mGlitterY, (float)(mGlitterAlpha)/(float)255, 1.2*float(mGlitterAlpha)/float(255),1.2*float(mGlitterAlpha)/float(255));
|
||||||
mGlitterAlpha-=10;
|
mGlitterAlpha-=10;
|
||||||
|
|
||||||
|
if (mCount && mObjects[mCurr] != NULL){
|
||||||
|
mObjects[mCurr]->Render();
|
||||||
|
if (hasFocus && mCurr >= offset && showBigCards){
|
||||||
|
((CardGui *)mObjects[mCurr])->RenderBig(-1,-1,showBigCards-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGGuiPlay::~MTGGuiPlay(){
|
MTGGuiPlay::~MTGGuiPlay(){
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ void MenuItem::Render()
|
|||||||
|
|
||||||
if (mHasFocus)
|
if (mHasFocus)
|
||||||
{
|
{
|
||||||
if (!updatedSinceLastRender){
|
/* if (!updatedSinceLastRender){
|
||||||
mParticleSys->Update(lastDt);
|
mParticleSys->Update(lastDt);
|
||||||
}
|
}*/
|
||||||
// set additive blending
|
// set additive blending
|
||||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
||||||
mParticleSys->Render();
|
mParticleSys->Render();
|
||||||
@@ -75,10 +75,7 @@ void MenuItem::Update(float dt)
|
|||||||
mScale = mTargetScale;
|
mScale = mTargetScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHasFocus){
|
|
||||||
mParticleSys->Update(dt);
|
mParticleSys->Update(dt);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ void ShopItems::Update(float dt){
|
|||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
sprintf(buffer,"%s : %i credits",item->getText(),price);
|
||||||
if(!dialog){
|
if(!dialog){
|
||||||
dialog = NEW SimpleMenu(1,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,270,buffer);
|
dialog = NEW SimpleMenu(1,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,buffer);
|
||||||
dialog->Add(1,"Yes");
|
dialog->Add(1,"Yes");
|
||||||
dialog->Add(2,"No");
|
dialog->Add(2,"No");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,125 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/SimpleMenu.h"
|
#include "../include/SimpleMenu.h"
|
||||||
#include "../include/SimpleMenuItem.h"
|
#include "../include/SimpleMenuItem.h"
|
||||||
|
#include "JTypes.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
|
||||||
SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, int width, const char * _title, int _maxItems): JGuiController(id, listener){
|
const unsigned SimpleMenu::SIDE_SIZE = 7;
|
||||||
mHeight = 0;
|
const unsigned SimpleMenu::VMARGIN = 8;
|
||||||
mWidth = width;
|
const unsigned SimpleMenu::HMARGIN = 27;
|
||||||
|
const unsigned SimpleMenu::LINE_HEIGHT = 20;
|
||||||
|
const char* SimpleMenu::spadeLPath = "graphics/spade_ul.png";
|
||||||
|
const char* SimpleMenu::spadeRPath = "graphics/spade_ur.png";
|
||||||
|
const char* SimpleMenu::jewelPath = "graphics/jewel.png";
|
||||||
|
const char* SimpleMenu::sidePath = "graphics/menuside.png";
|
||||||
|
const char* SimpleMenu::titleFontPath = "graphics/smallface";
|
||||||
|
|
||||||
|
|
||||||
|
JQuad* SimpleMenu::spadeR = NULL;
|
||||||
|
JQuad* SimpleMenu::spadeL = NULL;
|
||||||
|
JQuad* SimpleMenu::jewel = NULL;
|
||||||
|
JQuad* SimpleMenu::side = NULL;
|
||||||
|
JLBFont* SimpleMenu::titleFont = NULL;
|
||||||
|
|
||||||
|
SimpleMenu::SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, const char * _title, int _maxItems): JGuiController(id, listener){
|
||||||
|
mHeight = 2 * VMARGIN;
|
||||||
|
mWidth = 0;
|
||||||
mX = x;
|
mX = x;
|
||||||
mY = y;
|
mY = y;
|
||||||
mFont = font;
|
mFont = font;
|
||||||
if (_title){
|
title = _title;
|
||||||
displaytitle = 1;
|
|
||||||
title = _title;
|
|
||||||
mHeight = 20;
|
|
||||||
}else{
|
|
||||||
displaytitle = 0;
|
|
||||||
}
|
|
||||||
startId = 0;
|
startId = 0;
|
||||||
maxItems = _maxItems;
|
maxItems = _maxItems;
|
||||||
|
side = NULL;
|
||||||
|
selectionT = 0;
|
||||||
|
timeOpen = 0;
|
||||||
|
closed = false;
|
||||||
|
|
||||||
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
static JTexture* spadeLTex = renderer->LoadTexture(spadeLPath, 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* sideTex = renderer->LoadTexture(sidePath, TEX_TYPE_USE_VRAM);
|
||||||
|
if (NULL == spadeL) spadeL = NEW JQuad(spadeLTex, 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 == side) side = NEW JQuad(sideTex, 0, 1, 1, 7);
|
||||||
|
if (NULL == titleFont)
|
||||||
|
{
|
||||||
|
GameApp::CommonRes->LoadJLBFont(titleFontPath, 7);
|
||||||
|
titleFont = GameApp::CommonRes->GetJLBFont(titleFontPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
stars = NEW hgeParticleSystem("graphics/stars.psi", GameApp::CommonRes->GetQuad("stars"));
|
||||||
|
stars->MoveTo(mX, mY);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimpleMenu::drawHorzPole(int x, int y, int width)
|
||||||
|
{
|
||||||
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
|
||||||
|
renderer->RenderQuad(side, x + 5, y - SIDE_SIZE / 2, 0, width - 10);
|
||||||
|
spadeR->SetHFlip(true);
|
||||||
|
spadeL->SetHFlip(false);
|
||||||
|
renderer->RenderQuad(spadeR, x - 9, y - 6);
|
||||||
|
renderer->RenderQuad(spadeL, x + width - 5, y - 6);
|
||||||
|
|
||||||
|
renderer->RenderQuad(jewel, x - 1, y - 1);
|
||||||
|
renderer->RenderQuad(jewel, x + width - 1, y - 1);
|
||||||
|
}
|
||||||
|
void SimpleMenu::drawVertPole(int x, int y, int height)
|
||||||
|
{
|
||||||
|
JRenderer* renderer = JRenderer::GetInstance();
|
||||||
|
|
||||||
|
renderer->RenderQuad(side, x - SIDE_SIZE / 2, y + height - 5, -M_PI/2, height - 10);
|
||||||
|
spadeR->SetHFlip(false);
|
||||||
|
spadeL->SetHFlip(true);
|
||||||
|
renderer->RenderQuad(spadeR, x - 6, y + 7, -M_PI/2);
|
||||||
|
renderer->RenderQuad(spadeL, x - 6, y + height + 11, -M_PI/2);
|
||||||
|
|
||||||
|
renderer->RenderQuad(jewel, x - 1, y - 1);
|
||||||
|
renderer->RenderQuad(jewel, x - 1, y + height - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Render(){
|
void SimpleMenu::Render(){
|
||||||
|
if (0 == mWidth)
|
||||||
|
{
|
||||||
|
for (int i = startId; i < startId + mCount; ++i)
|
||||||
|
{
|
||||||
|
int width = (static_cast<SimpleMenuItem*>(mObjects[i]))->GetWidth();
|
||||||
|
if (mWidth < width) mWidth = width;
|
||||||
|
}
|
||||||
|
mWidth += 2*HMARGIN;
|
||||||
|
for (int i = startId; i < startId + mCount; ++i)
|
||||||
|
static_cast<SimpleMenuItem*>(mObjects[i])->Relocate(mX + mWidth / 2, mY + VMARGIN + i * LINE_HEIGHT);
|
||||||
|
stars->Fire();
|
||||||
|
selectionTargetY = selectionY = mY + VMARGIN;
|
||||||
|
timeOpen = 0;
|
||||||
|
}
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
JRenderer * renderer = JRenderer::GetInstance();
|
JRenderer * renderer = JRenderer::GetInstance();
|
||||||
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(70,0,0,0));
|
|
||||||
renderer->FillRoundRect(mX,mY,mWidth,mHeight,10,ARGB(255,17,17,17));
|
float height = mHeight;
|
||||||
renderer->FillRoundRect(mX+2,mY+2,mWidth - 4,mHeight-4,10,ARGB(255,62,62,62));
|
if (timeOpen < 1)
|
||||||
if (displaytitle){
|
height *= timeOpen > 0 ? timeOpen : -timeOpen;
|
||||||
mFont->DrawString(title.c_str(), mX+10, mY+10);
|
|
||||||
}
|
renderer->FillRect(mX, mY, mWidth, height, ARGB(180,0,0,0));
|
||||||
|
|
||||||
|
drawVertPole(mX, mY - 16, height + 32);
|
||||||
|
drawVertPole(mX + mWidth, mY - 16, height + 32);
|
||||||
|
drawHorzPole(mX - 16, mY, mWidth + 32);
|
||||||
|
if (!title.empty())
|
||||||
|
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++){
|
||||||
if (i > mCount-1) break;
|
if (i > mCount-1) break;
|
||||||
((SimpleMenuItem * )mObjects[i])->RenderWithOffset(-20*startId);
|
if ((static_cast<SimpleMenuItem*>(mObjects[i]))->mY - LINE_HEIGHT * startId < mY + height - LINE_HEIGHT + 7)
|
||||||
|
(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Update(float dt){
|
void SimpleMenu::Update(float dt){
|
||||||
@@ -41,13 +129,27 @@ void SimpleMenu::Update(float dt){
|
|||||||
}else if (mCurr < startId){
|
}else if (mCurr < startId){
|
||||||
startId = mCurr;
|
startId = mCurr;
|
||||||
}
|
}
|
||||||
|
stars->Update(dt);
|
||||||
|
selectionT += 3*dt;
|
||||||
|
selectionY += (selectionTargetY - selectionY) * 8 * dt;
|
||||||
|
stars->MoveTo(mX + HMARGIN + ((mWidth-2*HMARGIN)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35) + LINE_HEIGHT / 2 - LINE_HEIGHT * startId);
|
||||||
|
if (timeOpen < 0)
|
||||||
|
{
|
||||||
|
timeOpen += dt * 10;
|
||||||
|
if (timeOpen >= 0) { timeOpen = 0; closed = true; }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeOpen += dt * 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenu::Add(int id, const char * text){
|
void SimpleMenu::Add(int id, const char * text){
|
||||||
int y = mCount*20;
|
JGuiController::Add(NEW SimpleMenuItem(this, id, mFont, text, 0, mY + VMARGIN + mCount*LINE_HEIGHT, (mCount == 0)));
|
||||||
if (displaytitle) y+=20;
|
if (mCount <= maxItems) mHeight += LINE_HEIGHT;
|
||||||
JGuiController::Add(NEW SimpleMenuItem(id, mFont, text, mWidth/2 + mX + 10, mY + 10 + y, (mCount == 0)));
|
|
||||||
if (mCount <= maxItems) mHeight += 20;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleMenu::Close()
|
||||||
|
{
|
||||||
|
timeOpen = -1.0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,41 +2,31 @@
|
|||||||
#include "../include/SimpleMenuItem.h"
|
#include "../include/SimpleMenuItem.h"
|
||||||
|
|
||||||
|
|
||||||
SimpleMenuItem::SimpleMenuItem(int id, JLBFont *font, const char* text, int x, int y, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y)
|
SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, const char* text, int x, int y, bool hasFocus): JGuiObject(id), parent(_parent), mFont(font), mX(x), mY(y)
|
||||||
{
|
{
|
||||||
|
|
||||||
mText = text;
|
mText = text;
|
||||||
mHasFocus = hasFocus;
|
mHasFocus = hasFocus;
|
||||||
|
|
||||||
mScale = 1.0f;
|
mScale = 1.0f;
|
||||||
mTargetScale = 1.0f;
|
mTargetScale = 1.0f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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));
|
||||||
if (mHasFocus)
|
|
||||||
{
|
|
||||||
mFont->SetColor(ARGB(255,255,255,0));
|
|
||||||
}
|
|
||||||
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()
|
||||||
{
|
{
|
||||||
|
RenderWithOffset(0);
|
||||||
RenderWithOffset(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleMenuItem::Update(float dt)
|
void SimpleMenuItem::Update(float dt)
|
||||||
@@ -56,20 +46,16 @@ void SimpleMenuItem::Update(float dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SimpleMenuItem::Entering()
|
void SimpleMenuItem::Entering()
|
||||||
{
|
{
|
||||||
|
|
||||||
mHasFocus = true;
|
mHasFocus = true;
|
||||||
mTargetScale = 1.2f;
|
parent->selectionTargetY = mY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SimpleMenuItem::Leaving(u32 key)
|
bool SimpleMenuItem::Leaving(u32 key)
|
||||||
{
|
{
|
||||||
mHasFocus = false;
|
mHasFocus = false;
|
||||||
mTargetScale = 1.0f;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,3 +65,13 @@ bool SimpleMenuItem::ButtonPressed()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleMenuItem::Relocate(int x, int y)
|
||||||
|
{
|
||||||
|
mX = x;
|
||||||
|
mY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SimpleMenuItem::GetWidth()
|
||||||
|
{
|
||||||
|
return mFont->GetStringWidth(mText.c_str());
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Subtypes::Subtypes(){
|
|||||||
int Subtypes::Add(string value){
|
int Subtypes::Add(string value){
|
||||||
int result = find(value);
|
int result = find(value);
|
||||||
if (result) return result;
|
if (result) return result;
|
||||||
#if defined (WIN32) || defined (LINUX)
|
#if defined (WIN32)
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
sprintf(buf, "Adding new type: *%s*\n",value.c_str());
|
sprintf(buf, "Adding new type: *%s*\n",value.c_str());
|
||||||
OutputDebugString(buf);
|
OutputDebugString(buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user