|
#include "AI/Dwarfs.h"
#include "GUI/WindowScroll.h"
//#include "DateTime.h"
std::list<Indicator*> Indicator::m_Indicators;
Indicator::Indicator(float _xLeft, float _yDown, float _xRight, float _yUp, GLuint _textureID)
: Sprite(_xLeft, _yDown, _xRight, _yUp, _textureID)
{
m_Indicators.push_back(this);
};
Indicator::~Indicator(void)
{
m_Indicators.remove(this);
};
bool Indicator::Update(float _dt)
{
Sprite::Update(_dt);
return false;
};
IndicatorDayNightTime::IndicatorDayNightTime(float _xLeft, float _yDown, float _xRight, float _yUp)
: Indicator(_xLeft, _yDown, _xRight, _yUp, Texture::m_TextureIDSun)
{
glActiveTexture(GL_TEXTURE0);
};
IndicatorDayNightTime::~IndicatorDayNightTime(void)
{
};
bool IndicatorDayNightTime::Update(float _dt)
{
float dXRel = 2.0f / DateTime::m_DayTime;
float dYRel = 2.0f / DateTime::m_DayTime;
float xlRel = dXRel * (DateTime::m_Time - DateTime::m_NightTime) * (1.0f + 0.5f * Sprite::m_ButtonSize / (float)Sprite::m_ScreenWidth);
xlRel -= (0.5f * Sprite::m_ButtonSize / (float)Sprite::m_ScreenWidth);
float xrRel = xlRel + Sprite::m_ButtonSize / (float)Sprite::m_ScreenWidth;
m_TextureID = Texture::m_TextureIDSun;
if (DateTime::m_Time > DateTime::m_DayTime)
{
dXRel = 2.0f / DateTime::m_NightTime;
dYRel = 2.0f / DateTime::m_NightTime;
xlRel = (-1.0f + dXRel * (DateTime::m_Time - DateTime::m_DayTime)) * (1.0f + 0.5f * Sprite::m_ButtonSize / (float)Sprite::m_ScreenWidth);
xlRel -= (0.5f * Sprite::m_ButtonSize / (float)Sprite::m_ScreenWidth);
xrRel = xlRel + Sprite::m_ButtonSize / (float)Sprite::m_ScreenWidth;
m_TextureID = Texture::m_TextureIDMoon;
}
m_Vertices[0] = xlRel;
m_Vertices[2] = xlRel;
m_Vertices[4] = xrRel;
m_Vertices[6] = xrRel;
Indicator::Update(_dt);
return false;
};
bool IndicatorDayNightTime::ProcessPress(float _x, float _y)
{
// printf("IndicatorDayNightTime::ProcessPress: %f, %f\n", _x, _y);
if ((_x > m_Vertices[0]) && (_x < m_Vertices[4]) &&
(_y > m_Vertices[1]) && (_y < m_Vertices[3]))
{
printf("IndicatorDayNightTime::ProcessPress() Pressed\n");
if (NULL == Window::m_CurrentWindow)
{
std::wstring strDate;
DateTime::DayToString(strDate);
std::wstring strTime;
DateTime::TimeToString(strTime);
strDate += strTime;
Window::m_CurrentWindow = new WindowScroll(L"Date & Time", strDate.c_str(), ButtonWindow::eButtonStyleOk);
Window::m_NeedUpdateDayTime = true;
}
return true;
}
else return false;
};
IndicatorHappyness::IndicatorHappyness(float _xLeft, float _yDown, float _xRight, float _yUp, unsigned char _grade)
: Indicator(_xLeft, _yDown, _xRight, _yUp, Texture::m_TextureIDNone)
{
m_HappynessGrade = _grade;
// float xTextLeft = _xRight;
float xTextLeft = _xRight - (_xRight - _xLeft) / 2.0f;
float yTextDown = _yDown;
float xTextRight = _xRight + (_xRight - _xLeft);
float yTextUp = _yUp;
m_TextSprite = new TextSprite(xTextLeft, yTextDown, xTextRight, yTextUp);
m_TextSprite->SetMultiText(L"x 0\\", TextSprite::m_FontCommon);
glActiveTexture(GL_TEXTURE0);
};
IndicatorHappyness::~IndicatorHappyness(void)
{
delete m_TextSprite;
};
void IndicatorHappyness::Recreate(void)
{
char buffer[128];
sprintf(buffer, ": %d\\", Dwarf::m_DwarfsHappyGrades[m_HappynessGrade]);
m_TextSprite->SetMultiText(Utilities::string_to_wstring(buffer).c_str(), TextSprite::m_FontFPS, TextSprite::m_ColorFG);
};
bool IndicatorHappyness::Update(float _dt)
{
if (0 == Dwarf::m_DwarfsHappyGrades[m_HappynessGrade])
return false;
if (Sprite::m_NeedRecreateHappynessIndicator) Recreate();
Indicator::Update(_dt);
m_TextSprite->Update(_dt);
return false;
};
bool IndicatorHappyness::ProcessPress(float _x, float _y)
{
// printf("IndicatorHappyness::ProcessPress: %f, %f\n", _x, _y);
if ((_x > m_Vertices[0]) && (_x < m_Vertices[4]) &&
(_y > m_Vertices[1]) && (_y < m_Vertices[3]))
{
printf("IndicatorHappyness::ProcessPress() Pressed\n");
return true;
}
else return false;
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.