Commit 748cd19c authored by Gerhard Stein's avatar Gerhard Stein

Obsolete Class removed

parent 3bd3d4bb
/*
* CTextBox.cpp
*
* Created on: 30.07.2009
* Author: gerstrong
*
* TODO: Explain, what that function does.
*/
#include "CTextBox.h"
#include "graphics/CGfxEngine.h"
#include "sdl/CVideoDriver.h"
#include "sdl/CTimer.h"
#include "sdl/input/CInput.h"
CTextBox::CTextBox(int y, int h, const std::string& message) :
m_tw_waittime(0)
{
setup(y, h, message);
m_surface = g_pVideoDriver->mp_VideoEngine->getBlitSurface();
}
CTextBox::CTextBox(SDL_Surface *surface, int y, int h, const std::string& message) :
m_tw_waittime(0)
{
setup(y, h, message);
m_surface = surface;
}
void CTextBox::setup(int y, int h, const std::string& message)
{
int width = message.length()*8;
if(width>280) width = 280;
m_border = false; m_numchars = 0;
m_timer = 0;
m_rect.w = width+2; m_rect.h = h;
m_rect.x = (300/2)-(m_rect.w/2)-2; m_rect.y = y;
m_String = message;
m_textdelay = 0;
g_pInput->flushAll();
resetTimer();
}
void CTextBox::resetTimer()
{
m_time_start = g_pTimer->getTicks();
m_time_passed = 0;
}
void CTextBox::setAttribs(Uint8 tw_waittime, bool highlight )
{
m_tw_waittime = tw_waittime;
m_highlighted = highlight;
}
void CTextBox::process()
{
m_time_passed = g_pTimer->getTicks() - m_time_start;
CFont &Font = g_pGfxEngine->getFont(1);
if(m_border) SDL_FillRect(m_surface, &m_rect, SDL_MapRGB(m_surface->format, 0,0,0));
if( m_tw_waittime == 0) // means no typewritting mode!
{
Font.drawFont(m_surface, m_String, m_rect.x+1, m_rect.y+1, m_highlighted);
}
else
{
std::string text;
if( m_timer>=m_tw_waittime && m_numchars < m_String.size() )
{
m_numchars++;
m_timer = 0;
} else m_timer++;
text = m_String.substr(0, m_numchars);
Font.drawFont(m_surface, text, m_rect.x+1, m_rect.y+1, m_highlighted);
// Process Input here!
if( g_pInput->getPressedCommand(IC_STATUS) || g_pInput->getPressedCommand(IC_JUMP) )
{
if(m_numchars != m_String.size())
m_numchars = m_String.size();
else
m_textdelay = m_time_passed;
}
}
}
bool CTextBox::hasFinished()
{
if( m_time_passed >= m_textdelay && m_tw_waittime!=0 ) return true;
if( m_tw_waittime==0 && g_pInput->getPressedAnyCommand() ) return true;
return false;
}
/*
* CTextBox.h
*
* Created on: 30.07.2009
* Author: gerstrong
*/
#ifndef CTEXTBOX_H_
#define CTEXTBOX_H_
#include <string>
#include <vector>
#include "../graphics/CFont.h"
#include <SDL.h>
class CTextBox {
public:
CTextBox(int y, int h, const std::string& message);
CTextBox(SDL_Surface *surface, int y, int h, const std::string& message);
void resetTimer();
void setDelay(Uint32 msecs) { m_textdelay = msecs; }
void setAttribs(Uint8 typewriterspeed, bool highlight=false );
void enableBorders(bool border){ m_border = border; }
bool hasFinished();
void process();
private:
void setup(int y, int h, const std::string& message);
std::string m_String;
int m_fontwidth, m_fontheight;
bool m_border;
SDL_Rect m_rect;
Uint8 m_tw_waittime;
bool m_highlighted;
SDL_Surface *m_surface;
Uint32 m_numchars;
Uint32 m_textdelay, m_time_passed, m_time_start;
int m_timer;
};
#endif /* CTEXTBOX_H_ */
......@@ -15,7 +15,6 @@
#define CPASSIVE_H_
#include "CTitle.h"
#include "dialog/CTextBox.h"
#include "common/CMap.h"
#include "common/CObject.h"
#include "gui/CGUIDialog.h"
......
......@@ -23,7 +23,6 @@ m_RestartVideo(false)
{
mp_IntroScreen = NULL;
mp_TitleScreen = NULL;
mp_PressAnyBox=NULL;
m_GoDemo = false;
m_textsize = 0;
}
......@@ -109,11 +108,6 @@ void CPassiveVort::process()
cleanup();
init(TITLE);
}
// If Menu is not open show "Press Any Key"
/*if(mp_PressAnyBox != NULL)
mp_PressAnyBox->process();*/
}
void CPassiveVort::cleanup()
......
......@@ -33,7 +33,6 @@ public:
private:
CIntro *mp_IntroScreen;
CTitle *mp_TitleScreen;
CTextBox *mp_PressAnyBox;
CTilemap *mp_Tilemap;
SmartPointer<CMap> mpMap;
stOption *mp_Option;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment