* Add the rolling phasebar.
* This is a preview version. It shares most of the code with the definitive
  version, but when the real code is checked in, this will be deleted.
This commit is contained in:
jean.chalard
2009-06-22 14:45:27 +00:00
parent ed9c739963
commit 2f3259fd55
6 changed files with 135 additions and 10 deletions
+1 -1
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/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.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/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.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/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.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/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/GuiPhaseBar.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/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS)) DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache) RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
+1 -1
View File
@@ -1,7 +1,7 @@
#ifndef _GUI_LAYERS_H_ #ifndef _GUI_LAYERS_H_
#define _GUI_LAYERS_H_ #define _GUI_LAYERS_H_
#define MAX_GUI_LAYERS 6 #define MAX_GUI_LAYERS 7
#define DIR_DOWN 1 #define DIR_DOWN 1
#define DIR_UP 2 #define DIR_UP 2
+27
View File
@@ -0,0 +1,27 @@
#ifndef _GUIPHASEBAR_H_
#define _GUIPHASEBAR_H_
#include "GuiLayers.h"
#include "PhaseRing.h"
#include "WEvent.h"
class GuiPhaseBar : public GuiLayer
{
static const unsigned Width = 28;
static const unsigned Height = Width;
static const unsigned Phases = 12;
protected:
JQuad* quad;
Phase* phase;
float angle;
public:
GuiPhaseBar(GameObserver* game);
~GuiPhaseBar();
void Update(float dt);
virtual void Render();
virtual int receiveEvent(WEvent * e);
};
#endif // _GUIPHASEBAR_H_
+7 -8
View File
@@ -2,7 +2,7 @@
#include "../include/DuelLayers.h" #include "../include/DuelLayers.h"
#include "../include/MTGRules.h" #include "../include/MTGRules.h"
#include "../include/DamageResolverLayer.h" #include "../include/DamageResolverLayer.h"
#include "../include/GuiPhaseBar.h"
void DuelLayers::init(){ void DuelLayers::init(){
@@ -32,33 +32,32 @@ void DuelLayers::init(){
//3 Game //3 Game
MTGGuiPlay * play = NEW MTGGuiPlay(4, GameObserver::GetInstance()); MTGGuiPlay * play = NEW MTGGuiPlay(4, GameObserver::GetInstance());
Add(NEW GuiPhaseBar(GameObserver::GetInstance()));
Add(mActionStack); Add(mActionStack);
Add(mDamageResolver); Add(mDamageResolver);
Add(actionLayer); Add(actionLayer);
Add(mGuiHand); Add(mGuiHand);
Add(play); Add(play);
} }
ActionStack * DuelLayers::stackLayer(){ ActionStack * DuelLayers::stackLayer(){
return ((ActionStack *) (objects[0])); return ((ActionStack *) (objects[1]));
} }
DamageResolverLayer * DuelLayers::combatLayer(){ DamageResolverLayer * DuelLayers::combatLayer(){
return ((DamageResolverLayer *) (objects[1])); return ((DamageResolverLayer *) (objects[2]));
} }
ActionLayer * DuelLayers::actionLayer(){ ActionLayer * DuelLayers::actionLayer(){
return ((ActionLayer *) (objects[2])); return ((ActionLayer *) (objects[3]));
} }
MTGGuiHand * DuelLayers::handLayer(){ MTGGuiHand * DuelLayers::handLayer(){
return ((MTGGuiHand *) (objects[3])); return ((MTGGuiHand *) (objects[4]));
} }
MTGGuiPlay * DuelLayers::playLayer(){ MTGGuiPlay * DuelLayers::playLayer(){
return ((MTGGuiPlay *) (objects[4])); return ((MTGGuiPlay *) (objects[5]));
} }
+1
View File
@@ -110,6 +110,7 @@ void GameApp::Create()
CommonRes->CreateTexture("graphics/phasebar.png"); CommonRes->CreateTexture("graphics/phasebar.png");
CommonRes->CreateTexture("graphics/background.png"); CommonRes->CreateTexture("graphics/background.png");
CommonRes->CreateTexture("graphics/back.jpg"); CommonRes->CreateTexture("graphics/back.jpg");
CommonRes->CreateTexture("graphics/phasebar.png");
//CommonRes->CreateTexture("graphics/interrupt.png"); //CommonRes->CreateTexture("graphics/interrupt.png");
//CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128); //CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128);
+98
View File
@@ -0,0 +1,98 @@
#include "../include/config.h"
#include "../include/GameApp.h"
#include "../include/GuiPhaseBar.h"
static int colors[] =
{
ARGB(255, 255, 255, 255),
ARGB(255, 255, 000, 000),
ARGB(255, 000, 255, 000),
ARGB(255, 000, 000, 255),
ARGB(255, 255, 255, 000),
ARGB(255, 255, 000, 255),
ARGB(255, 000, 255, 255),
ARGB(255, 000, 000, 000),
ARGB(255, 255, 255, 255),
ARGB(255, 255, 255, 255),
ARGB(255, 255, 255, 255),
ARGB(255, 255, 255, 255)
};
GuiPhaseBar::GuiPhaseBar(GameObserver* game) : GuiLayer(0, game), phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
{
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
if (texture)
quad = NEW JQuad(texture, 0, 0, Width, Height);
else
{
quad = NULL;
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
}
}
GuiPhaseBar::~GuiPhaseBar()
{
delete(quad);
}
void GuiPhaseBar::Update(float dt)
{
if (angle > 0) angle -= 3*dt; else angle = 0;
}
void GuiPhaseBar::Render()
{
static const unsigned CENTER = SCREEN_HEIGHT / 2 - Height / 4;
JRenderer* renderer = JRenderer::GetInstance();
unsigned p = (phase->id + Phases - 4) * Width;
float scale;
float start = CENTER + (Width / 2) * angle / (M_PI / 6);
renderer->DrawLine(0, SCREEN_HEIGHT / 2, SCREEN_WIDTH, SCREEN_HEIGHT / 2, ARGB(255, 255, 255, 255));
scale = sinf(angle + 3 * M_PI / 6) / 2;
quad->SetTextureRect((p + 3 * Width) % (Phases * Width), 0, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale;
scale = sinf(angle + 4 * M_PI / 6) / 2;
quad->SetTextureRect((p + 4 * Width) % (Phases * Width), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale;
scale = sinf(angle + 5 * M_PI / 6) / 2;
quad->SetTextureRect((p + 5 * Width) % (Phases * Width), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale;
start = CENTER + (Width / 2) * angle / (M_PI / 6);
scale = sinf(angle + 2 * M_PI / 6) / 2;
start -= Width * scale;
quad->SetTextureRect((p + 2 * Width) % (Phases * Width), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
scale = sinf(angle + 1 * M_PI / 6) / 2;
start -= Width * scale;
quad->SetTextureRect((p + 1 * Width) % (Phases * Width), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
if (angle > 0)
{
scale = sinf(angle)/2;
start -= Width * scale;
quad->SetTextureRect(p % (Phases * Width), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
}
}
int GuiPhaseBar::receiveEvent(WEvent *e)
{
WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e);
if (event)
{
angle = M_PI / 6;
phase = event->to;
}
return 1;
}