- Added a few "stats" to the main menu. This might slow down loading times on the PSP (needs testing). In that case I'll move it to the options, or optimize it if needed
51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
#include "../include/TextScroller.h"
|
|
|
|
#include <JLBFont.h>
|
|
|
|
TextScroller::TextScroller(JLBFont * font, float x, float y, float width, float speed):JGuiObject(0){
|
|
mFont = font;
|
|
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){
|
|
start+=mSpeed*dt;
|
|
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(){
|
|
mFont->DrawString(mText.c_str(),mX,mY,JGETEXT_LEFT,start,mWidth);
|
|
} |