2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_LINEINPUT_H
|
|
|
|
#define GAME_CLIENT_LINEINPUT_H
|
|
|
|
|
|
|
|
#include <engine/input.h>
|
|
|
|
|
|
|
|
// line input helter
|
|
|
|
class CLineInput
|
|
|
|
{
|
2013-04-01 18:30:58 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_SIZE=512,
|
|
|
|
MAX_CHARS=MAX_SIZE/4,
|
|
|
|
};
|
|
|
|
char m_Str[MAX_SIZE];
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_Len;
|
|
|
|
int m_CursorPos;
|
2013-04-01 18:30:58 +00:00
|
|
|
int m_NumChars;
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
2013-04-01 18:30:58 +00:00
|
|
|
static bool Manipulate(IInput::CEvent e, char *pStr, int StrMaxSize, int StrMaxChars, int *pStrLenPtr, int *pCursorPosPtr, int *pNumCharsPtr);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
class CCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~CCallback() {}
|
|
|
|
virtual bool Event(IInput::CEvent e) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
CLineInput();
|
|
|
|
void Clear();
|
|
|
|
void ProcessInput(IInput::CEvent e);
|
|
|
|
void Set(const char *pString);
|
|
|
|
const char *GetString() const { return m_Str; }
|
|
|
|
int GetLength() const { return m_Len; }
|
2010-11-17 17:36:19 +00:00
|
|
|
int GetCursorOffset() const { return m_CursorPos; }
|
2010-12-16 01:31:12 +00:00
|
|
|
void SetCursorOffset(int Offset) { m_CursorPos = Offset > m_Len ? m_Len : Offset < 0 ? 0 : Offset; }
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|