22 #include "precompiled.h"
85 float height = h * 0.6f;
86 SetSize(0, 0, (
float)w, height);
123 size_t L = (size_t)wcslen(szMessage);
127 if (iSize && iSize < L) L = iSize;
129 for(
size_t i = 0; i < L; i++)
130 szMessage[i] = towlower(szMessage[i]);
136 size_t L = wcslen(szMessage);
140 if (iSize && iSize < L) L = iSize;
142 wchar_t szChar[2] = { cChar, 0 };
146 size_t ofs = wcsspn(szMessage, szChar);
152 memmove(szMessage, szMessage+ofs, L*
sizeof(
wchar_t));
157 if (szMessage[i - 1] != cChar)
break;
166 const float AnimateTime = .30f;
167 const float Delta = deltaRealTime / AnimateTime;
197 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
200 solidTech->BeginPass();
208 solidShader->Uniform(str_transform, transform);
212 solidTech->EndPass();
215 textTech->BeginPass();
218 textRenderer.SetTransform(transform);
223 textRenderer.Render();
240 shader->VertexPointer(2, GL_FLOAT, 0, boxVerts);
244 shader->Uniform(str_color, 0.0f, 0.0f, 0.5f, 0.6f);
245 shader->AssertPointersBound();
246 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
250 shader->Uniform(str_color, 0.5f, 0.5f, 0.0f, 0.6f);
251 shader->AssertPointersBound();
252 glDrawArrays(GL_LINE_LOOP, 0, 4);
256 float lineVerts[] = {
260 shader->VertexPointer(2, GL_FLOAT, 0, lineVerts);
261 shader->AssertPointersBound();
262 glDrawArrays(GL_LINES, 0, 2);
271 std::deque<std::wstring>::iterator Iter;
275 textRenderer.
Color(1.0f, 1.0f, 1.0f);
299 textRenderer.
Color(1.0f, 1.0f, 0.0f);
302 textRenderer.
Color(1.0f, 1.0f, 1.0f);
338 textRenderer.
Color(1.0f, 1.0f, 0.0f, 0.8f);
341 textRenderer.
Put(0.0f, 0.0f, L
"_");
344 textRenderer.
Color(1.0f, 1.0f, 1.0f);
352 static int iHistoryPos = -1;
464 else if (iHistoryPos == 0)
489 if (cooked == 0)
return;
513 va_start(args, szMessage);
516 debug_printf(L
"Error printfing console message (buffer size exceeded?)\n");
532 CStrW wrapAround(message);
533 CStrW newline(L
"\n");
542 distance = wrapAround.find(newline, oldNewline) - oldNewline;
546 wrapAround.insert( oldNewline++, newline );
549 oldNewline += distance+1;
558 while ( (distance = wrapAround.find(newline, oldNewline)) != wrapAround.npos)
560 distance -= oldNewline;
562 oldNewline += distance+1;
596 if (szLine == NULL)
return;
597 if (wcslen(szLine) <= 0)
return;
608 if (!JSVAL_IS_VOID(rval))
621 shared_ptr<u8> buf;
size_t buflen;
625 CStr bytes ((
char*)buf.get(), buflen);
627 CStrW str (bytes.FromUTF8());
629 while (pos != CStrW::npos)
631 pos = str.find(
'\n');
632 if (pos != CStrW::npos)
635 m_deqBufHistory.push_front(str.Left(str[pos-1] ==
'\r' ? pos - 1 : pos));
636 str = str.substr(pos + 1);
638 else if (str.length() > 0)
647 std::deque<std::wstring>::reverse_iterator it =
m_deqBufHistory.rbegin();
649 std::advance(it, linesToSkip);
652 CStr8 line = CStrW(*it).ToUTF8();
653 buffer.
Append(line.data(), line.length());
654 static const char newline =
'\n';
655 buffer.
Append(&newline, 1);
665 #if SDL_VERSION_ATLEAST(2, 0, 0)
677 case SDLK_RETURN:
case SDLK_TAB:
678 case SDLK_BACKSPACE:
case SDLK_DELETE:
679 case SDLK_HOME:
case SDLK_END:
680 case SDLK_LEFT:
case SDLK_RIGHT:
681 case SDLK_UP:
case SDLK_DOWN:
682 case SDLK_PAGEUP:
case SDLK_PAGEDOWN:
698 std::string hotkey =
static_cast<const char*
>(ev->
ev.
user.
data1);
700 if (hotkey ==
"console.toggle")
705 else if (g_Console->
IsActive() && hotkey ==
"copy")
710 else if (g_Console->
IsActive() && hotkey ==
"paste")
715 for (
wchar_t* c = text; *c; c++)
void Translate(float x, float y, float z)
std::deque< std::wstring > m_deqBufHistory
CMatrix3D GetDefaultGuiMatrix()
void Append(const void *data, size_t size)
void ReceivedChatMessage(const wchar_t *pSender, const wchar_t *szMessage)
Status sys_clipboard_set(const wchar_t *text)
void PutAdvance(const wchar_t *buf)
Print text at (0,0) under the current transform, and advance the transform by the width of the text...
Locks a CMutex over this object's lifetime.
void DrawHistory(CTextRenderer &textRenderer)
shared_ptr< CShaderTechnique > CShaderTechniquePtr
void DrawCursor(CTextRenderer &textRenderer)
Status sys_clipboard_free(wchar_t *copy)
const wchar_t * GetBuffer()
void SetCursorBlinkRate(double rate)
void PostTranslate(float x, float y, float z)
void SetSize(float X=300, float Y=0, float W=800, float H=600)
static bool isUnprintableChar(SDL_keysym key)
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
void Put(float x, float y, const wchar_t *buf)
Print text at (x,y) under the current transform, and advance the transform by the width of the text...
void Color(const CColor &color)
Set the color for subsequent print calls.
void PrintfAdvance(const wchar_t *fmt,...)
Print formatted text at (0,0) under the current transform, and advance the transform by the width of ...
shared_ptr< u8 > Data() const
void UseHistoryFile(const VfsPath &filename, int historysize)
void SetTransform(const CMatrix3D &transform)
void InsertMessageRaw(const CStrW &message)
std::deque< std::wstring > m_deqMsgHistory
wchar_t * sys_clipboard_get()
void DrawWindow(CShaderProgramPtr &shader)
void ProcessBuffer(const wchar_t *szLine)
void Trim(wchar_t *szMessage, const wchar_t cChar=32, size_t iSize=0)
void Update(const float deltaRealTime)
void SetBuffer(const wchar_t *szMessage)
#define CONSOLE_BUFFER_SIZE
void Font(const CStrW &font)
Set the font for subsequent print calls.
bool VfsFileExists(const VfsPath &pathname)
void DrawBuffer(CTextRenderer &textRenderer)
#define CONSOLE_MESSAGE_SIZE
bool HotkeyIsPressed(const CStr &keyname)
#define PROFILE3_GPU(name)
void ToLower(wchar_t *szMessage, size_t iSize=0)
void SetVisible(bool visible)
shared_ptr< CShaderProgram > CShaderProgramPtr
void UpdateScreenSize(int w, int h)
void InsertMessage(const wchar_t *szMessage,...) WPRINTF_ARGS(2)
T clamp(T value, T min, T max)
void InsertChar(const int szChar, const wchar_t cooked)
void debug_printf(const wchar_t *fmt,...)
write a formatted string to the debug channel, subject to filtering (see below).
std::map< int32_t, bool > g_keys
g_keys: Key states, indexed by SDLK* constants.
InReaction conInputHandler(const SDL_Event_ *ev)