mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- fixed chat input.
This commit is contained in:
parent
a50a0c5b0d
commit
add10029b9
2 changed files with 13 additions and 18 deletions
|
@ -112,7 +112,6 @@ CVAR (Bool, chat_substitution, false, CVAR_ARCHIVE)
|
||||||
void CT_Init ()
|
void CT_Init ()
|
||||||
{
|
{
|
||||||
ChatQueue.Clear();
|
ChatQueue.Clear();
|
||||||
ChatQueue.Push(0);
|
|
||||||
CharLen = 0;
|
CharLen = 0;
|
||||||
chatmodeon = 0;
|
chatmodeon = 0;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +141,9 @@ bool CT_Responder (event_t *ev)
|
||||||
{
|
{
|
||||||
if (ev->data1 == '\r')
|
if (ev->data1 == '\r')
|
||||||
{
|
{
|
||||||
|
ChatQueue.Push(0);
|
||||||
ShoveChatStr ((char *)ChatQueue.Data(), chatmodeon - 1);
|
ShoveChatStr ((char *)ChatQueue.Data(), chatmodeon - 1);
|
||||||
|
ChatQueue.Pop();
|
||||||
CT_Stop ();
|
CT_Stop ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +163,9 @@ bool CT_Responder (event_t *ev)
|
||||||
else if (ev->data1 == 'C' && (ev->data3 & GKM_CTRL))
|
else if (ev->data1 == 'C' && (ev->data3 & GKM_CTRL))
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
{
|
{
|
||||||
|
ChatQueue.Push(0);
|
||||||
I_PutInClipboard ((char *)ChatQueue.Data());
|
I_PutInClipboard ((char *)ChatQueue.Data());
|
||||||
|
ChatQueue.Pop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
@ -249,25 +252,22 @@ void CT_Drawer (void)
|
||||||
promptwidth = displayfont->StringWidth (prompt) * scalex;
|
promptwidth = displayfont->StringWidth (prompt) * scalex;
|
||||||
x = displayfont->GetCharWidth (displayfont->GetCursor()) * scalex * 2 + promptwidth;
|
x = displayfont->GetCharWidth (displayfont->GetCursor()) * scalex * 2 + promptwidth;
|
||||||
|
|
||||||
|
FString printstr = ChatQueue;
|
||||||
// figure out if the text is wider than the screen
|
// figure out if the text is wider than the screen
|
||||||
// if so, only draw the right-most portion of it.
|
// if so, only draw the right-most portion of it.
|
||||||
const uint8_t *textp = ChatQueue.Data();
|
const uint8_t *textp = (const uint8_t*)printstr.GetChars();
|
||||||
while(*textp)
|
while(*textp)
|
||||||
{
|
{
|
||||||
auto textw = displayfont->StringWidth(textp);
|
auto textw = displayfont->StringWidth(textp);
|
||||||
if (x + textw * scalex < screen_width) break;
|
if (x + textw * scalex < screen_width) break;
|
||||||
GetCharFromString(textp);
|
GetCharFromString(textp);
|
||||||
}
|
}
|
||||||
|
printstr += displayfont->GetCursor();
|
||||||
|
|
||||||
// draw the prompt, text, and cursor
|
|
||||||
ChatQueue.Last() = displayfont->GetCursor();
|
|
||||||
ChatQueue.Push(0);
|
|
||||||
screen->DrawText (displayfont, CR_GREEN, 0, y, prompt,
|
screen->DrawText (displayfont, CR_GREEN, 0, y, prompt,
|
||||||
DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
|
DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
|
||||||
screen->DrawText (displayfont, CR_GREY, promptwidth, y, (const char *)textp,
|
screen->DrawText (displayfont, CR_GREY, promptwidth, y, printstr,
|
||||||
DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
|
DTA_VirtualWidth, screen_width, DTA_VirtualHeight, screen_height, DTA_KeepRatio, true, TAG_DONE);
|
||||||
ChatQueue.Pop();
|
|
||||||
ChatQueue.Last() = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (players[consoleplayer].camera != NULL &&
|
if (players[consoleplayer].camera != NULL &&
|
||||||
|
@ -301,7 +301,6 @@ static void CT_AddChar (int c)
|
||||||
}
|
}
|
||||||
CharLen++;
|
CharLen++;
|
||||||
}
|
}
|
||||||
ChatQueue.Push(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,10 +315,9 @@ static void CT_BackSpace ()
|
||||||
{
|
{
|
||||||
if (CharLen)
|
if (CharLen)
|
||||||
{
|
{
|
||||||
int endpos = ChatQueue.Size() - 2;
|
int endpos = ChatQueue.Size() - 1;
|
||||||
while (endpos > 0 && ChatQueue[endpos] >= 0x80 && ChatQueue[endpos] < 0xc0) endpos--;
|
while (endpos > 0 && ChatQueue[endpos] >= 0x80 && ChatQueue[endpos] < 0xc0) endpos--;
|
||||||
ChatQueue[endpos] = 0;
|
ChatQueue.Clamp(endpos);
|
||||||
ChatQueue.Clamp(endpos + 1);
|
|
||||||
CharLen--;
|
CharLen--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,12 +331,7 @@ static void CT_BackSpace ()
|
||||||
|
|
||||||
static void CT_ClearChatMessage ()
|
static void CT_ClearChatMessage ()
|
||||||
{
|
{
|
||||||
if (ChatQueue.Size() > 1)
|
ChatQueue.Clear();
|
||||||
{
|
|
||||||
ChatQueue.Clamp(1);
|
|
||||||
ChatQueue[0] = 0;
|
|
||||||
CharLen = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -131,6 +131,8 @@ public:
|
||||||
FString (const char *copyStr);
|
FString (const char *copyStr);
|
||||||
FString (const char *copyStr, size_t copyLen);
|
FString (const char *copyStr, size_t copyLen);
|
||||||
FString (char oneChar);
|
FString (char oneChar);
|
||||||
|
FString(const TArray<char> & source) : FString(source.Data(), source.Size()) {}
|
||||||
|
FString(const TArray<uint8_t> & source) : FString((char*)source.Data(), source.Size()) {}
|
||||||
// This is intentionally #ifdef'd. The only code which needs this is parts of the Windows backend that receive Unicode text from the system.
|
// This is intentionally #ifdef'd. The only code which needs this is parts of the Windows backend that receive Unicode text from the system.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
explicit FString(const wchar_t *copyStr);
|
explicit FString(const wchar_t *copyStr);
|
||||||
|
|
Loading…
Reference in a new issue