Cleaned up my phasebar code and merged it into the overall item selection code

This commit is contained in:
Xawotihs
2011-08-04 05:57:10 +00:00
parent 46dfe03099
commit eac5a35b43
6 changed files with 61 additions and 49 deletions

View File

@@ -4,6 +4,7 @@
#include "GuiPhaseBar.h"
#include "GameObserver.h"
#include "Translate.h"
#include "CardSelectorSingleton.h"
/*
static int colors[] =
@@ -40,21 +41,9 @@ namespace
}
}
GuiPhaseBar* GuiPhaseBar::instance = NULL;
GuiPhaseBar* GuiPhaseBar::GetInstance()
{
return GuiPhaseBar::instance;
}
void GuiPhaseBar::Zoom(float zoom)
{
zoomTarget = zoom*ICONSCALE;
}
GuiPhaseBar::GuiPhaseBar() :
phase(NULL), angle(0.0f), zoomTarget(ICONSCALE), zoomFactor(ICONSCALE)
PlayGuiObject(0, 0, 106, 0, false),
phase(NULL), angle(0.0f), zoomFactor(ICONSCALE)
{
JQuadPtr quad = WResourceManager::Instance()->GetQuad("phasebar");
if (quad.get() != NULL)
@@ -65,7 +54,9 @@ GuiPhaseBar::GuiPhaseBar() :
else
GameApp::systemError = "Error loading phasebar texture : " __FILE__;
instance = this;
zoom = ICONSCALE;
CardSelectorSingleton::Instance()->Add(this);
}
GuiPhaseBar::~GuiPhaseBar()
@@ -79,16 +70,30 @@ void GuiPhaseBar::Update(float dt)
else
angle = 0;
if(zoomFactor + 0.05 < zoomTarget)
if (dt > 0.05f) dt = 0.05f;
if(zoomFactor + 0.05f < zoom)
{
zoomFactor += (float)0.05;
zoomFactor += dt;
}
else if (zoomFactor - 0.05 > zoomTarget)
else if (zoomFactor - 0.05f > zoom)
{
zoomFactor -= (float)0.05;
zoomFactor -= dt;
}
}
void GuiPhaseBar::Entering()
{
mHasFocus = true;
zoom = 1.4f*ICONSCALE;
}
bool GuiPhaseBar::Leaving(JButton key)
{
mHasFocus = false;
zoom = ICONSCALE;
return true;
}
void GuiPhaseBar::Render()
{
GameObserver * g = GameObserver::GetInstance();
@@ -164,3 +169,8 @@ int GuiPhaseBar::receiveEventMinus(WEvent *e)
}
return 1;
}
ostream& GuiPhaseBar::toString(ostream& out) const
{
return out << "GuiPhaseBar";
}