Also fixed the project includes so that we don't need to always use the indirect include path, ie: #include "../include/foo.h" -> #include "foo.h" I'm don't know much about make files - if I busted the linux build, mea culpa, but I think we're okay on that front too. For future reference, here's the most straightforward link on the topic of adding pch support to make files: http://www.mercs-eng.com/~hulud/index.php?2008/06/13/6-writing-a-good-makefile-for-a-c-project
72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
#include "PrecompiledHeader.h"
|
|
|
|
#include "TextScroller.h"
|
|
#include "WResourceManager.h"
|
|
#include "utils.h"
|
|
#include "WFont.h"
|
|
|
|
TextScroller::TextScroller(int fontId, float x, float y, float width, float speed):JGuiObject(0),fontId(fontId){
|
|
mWidth = width;
|
|
mSpeed = speed;
|
|
mX = x;
|
|
mY = y;
|
|
start = -width;
|
|
timer = 0;
|
|
currentId = 0;
|
|
mRandom = 0;
|
|
}
|
|
|
|
void TextScroller::setRandom(int mode){
|
|
mRandom = mode;
|
|
if (mRandom && strings.size()){
|
|
currentId = (rand() % strings.size());
|
|
mText = strings[currentId];
|
|
}
|
|
}
|
|
|
|
void TextScroller::Add(string text){
|
|
if (!strings.size()) mText = text;
|
|
strings.push_back(text);
|
|
}
|
|
|
|
void TextScroller::Reset(){
|
|
strings.clear();
|
|
}
|
|
|
|
void TextScroller::Update(float dt){
|
|
if(!strings.size())
|
|
return;
|
|
start+=mSpeed*dt;
|
|
WFont * mFont = resources.GetWFont(fontId);
|
|
if (start > mFont->GetStringWidth(mText.c_str())){
|
|
start = -mWidth;
|
|
if (mRandom){
|
|
currentId = (rand() % strings.size());
|
|
}else{
|
|
currentId++;
|
|
if (currentId > strings.size()-1)currentId = 0;
|
|
}
|
|
mText = strings[currentId];
|
|
}
|
|
|
|
}
|
|
|
|
void TextScroller::Render(){
|
|
WFont * mFont = resources.GetWFont(fontId);
|
|
mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth);
|
|
}
|
|
|
|
ostream& TextScroller::toString(ostream& out) const
|
|
{
|
|
return out << "TextScroller ::: mText : " << mText
|
|
<< " ; tempText : " << tempText
|
|
<< " ; mWidth : " << mWidth
|
|
<< " ; mSpeed : " << mSpeed
|
|
<< " ; mX,mY : " << mX << "," << mY
|
|
<< " ; start : " << start
|
|
<< " ; timer : " << timer
|
|
<< " ; strings : ?" // << strings
|
|
<< " ; currentId : " << currentId
|
|
<< " ; mRandom : " << mRandom;
|
|
}
|