Add easing to task list and fix a bug where
opening the task list a second time was not possible
This commit is contained in:
@@ -2,8 +2,15 @@
|
|||||||
#define TASK_H
|
#define TASK_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Easing.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class GameObserver;
|
class GameObserver;
|
||||||
|
class JQuad;
|
||||||
|
class JTexture;
|
||||||
|
|
||||||
// Task type constant
|
// Task type constant
|
||||||
|
|
||||||
@@ -72,8 +79,11 @@ class TaskList
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
string fileName;
|
string fileName;
|
||||||
|
|
||||||
float vPos;
|
float vPos;
|
||||||
float mElapsed;
|
InOutQuadEasing vPosInEasing;
|
||||||
|
InOutQuadEasing vPosOutEasing;
|
||||||
|
|
||||||
int mState;
|
int mState;
|
||||||
JQuad * mBg[9];
|
JQuad * mBg[9];
|
||||||
JTexture * mBgTex;
|
JTexture * mBgTex;
|
||||||
@@ -97,7 +107,6 @@ public:
|
|||||||
{
|
{
|
||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
;
|
|
||||||
void addTask(string params, bool rand = false);
|
void addTask(string params, bool rand = false);
|
||||||
void addTask(Task *task);
|
void addTask(Task *task);
|
||||||
void addRandomTask(int diff = 100);
|
void addRandomTask(int diff = 100);
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ void GameStateShop::Update(float dt)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STAGE_SHOP_TASKS:
|
case STAGE_SHOP_TASKS:
|
||||||
if (menu)
|
if (menu && !menu->isClosed())
|
||||||
{
|
{
|
||||||
menu->Update(dt);
|
menu->Update(dt);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -258,9 +258,10 @@ Task* Task::createFromStr(const string params, bool rand)
|
|||||||
|
|
||||||
/*---------------- TaskList -----------------*/
|
/*---------------- TaskList -----------------*/
|
||||||
|
|
||||||
TaskList::TaskList(string _fileName)
|
TaskList::TaskList(string _fileName):
|
||||||
|
fileName(_fileName), vPos(-SCREEN_HEIGHT), vPosInEasing(vPos), vPosOutEasing(vPos)
|
||||||
{
|
{
|
||||||
fileName = _fileName;
|
|
||||||
if (fileName == "")
|
if (fileName == "")
|
||||||
{
|
{
|
||||||
fileName = options.profileFile(PLAYER_TASKS).c_str();
|
fileName = options.profileFile(PLAYER_TASKS).c_str();
|
||||||
@@ -378,9 +379,10 @@ void TaskList::removeTask(Task *task)
|
|||||||
|
|
||||||
void TaskList::Start()
|
void TaskList::Start()
|
||||||
{
|
{
|
||||||
vPos = -SCREEN_HEIGHT; //Offscreen
|
|
||||||
mElapsed = 0;
|
|
||||||
mState = TASKS_IN;
|
mState = TASKS_IN;
|
||||||
|
vPos = -SCREEN_HEIGHT; //Offscreen
|
||||||
|
vPosInEasing.start(0.0f, 2.0f);
|
||||||
|
|
||||||
if (!mBgTex)
|
if (!mBgTex)
|
||||||
{
|
{
|
||||||
mBgTex = WResourceManager::Instance()->RetrieveTexture("taskboard.png", RETRIEVE_LOCK);
|
mBgTex = WResourceManager::Instance()->RetrieveTexture("taskboard.png", RETRIEVE_LOCK);
|
||||||
@@ -410,7 +412,7 @@ void TaskList::Start()
|
|||||||
void TaskList::End()
|
void TaskList::End()
|
||||||
{
|
{
|
||||||
mState = TASKS_OUT;
|
mState = TASKS_OUT;
|
||||||
mElapsed = 0;
|
vPosOutEasing.start(float(-SCREEN_HEIGHT), 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskList::passOneDay()
|
void TaskList::passOneDay()
|
||||||
@@ -451,21 +453,23 @@ int TaskList::getTaskCount()
|
|||||||
|
|
||||||
void TaskList::Update(float dt)
|
void TaskList::Update(float dt)
|
||||||
{
|
{
|
||||||
mElapsed += dt;
|
if(!vPosInEasing.finished())
|
||||||
|
|
||||||
if (mState == TASKS_IN && vPos < 0)
|
|
||||||
{
|
{
|
||||||
vPos = -SCREEN_HEIGHT + (SCREEN_HEIGHT * mElapsed / 0.75f); //Todo: more physical drop-in.
|
vPosInEasing.update(dt);
|
||||||
if (vPos >= 0)
|
|
||||||
|
if(vPosInEasing.finished())
|
||||||
{
|
{
|
||||||
vPos = 0;
|
|
||||||
mState = TaskList::TASKS_ACTIVE;
|
mState = TaskList::TASKS_ACTIVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mState == TASKS_OUT && vPos > -SCREEN_HEIGHT)
|
else if(!vPosOutEasing.finished())
|
||||||
{
|
{
|
||||||
vPos = -(SCREEN_HEIGHT * mElapsed / 0.75f);
|
vPosOutEasing.update(dt);
|
||||||
if (vPos <= -SCREEN_HEIGHT) mState = TASKS_INACTIVE;
|
|
||||||
|
if(vPosOutEasing.finished())
|
||||||
|
{
|
||||||
|
mState = TASKS_INACTIVE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user