mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
CConsole: modify input chars using the callback
Light preparation for when the lib gets updated to 1.88 to enable undo/redo again.
This commit is contained in:
parent
6881d1d823
commit
54fc85e1d3
@ -234,18 +234,18 @@ void CConsole::DrawSurface(void)
|
||||
if (m_nSuggestPos != -1)
|
||||
{
|
||||
// Remove the default value from ConVar before assigning it to the input buffer.
|
||||
string svConVar = m_vSuggest[m_nSuggestPos].m_svName.substr(0, m_vSuggest[m_nSuggestPos].m_svName.find(' ')) + ' ';
|
||||
memmove(m_szInputBuf, svConVar.data(), svConVar.size() + 1);
|
||||
m_svInputConVar = m_vSuggest[m_nSuggestPos].m_svName.substr(0, m_vSuggest[m_nSuggestPos].m_svName.find(' ')) + ' ';
|
||||
m_bModifyInput = true;
|
||||
|
||||
ResetAutoComplete();
|
||||
BuildSummary(svConVar);
|
||||
BuildSummary(m_svInputConVar);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_szInputBuf[0])
|
||||
{
|
||||
ProcessCommand(m_szInputBuf);
|
||||
memset(m_szInputBuf, '\0', 1);
|
||||
m_bModifyInput = true;
|
||||
}
|
||||
|
||||
ResetAutoComplete();
|
||||
@ -809,6 +809,21 @@ int CConsole::TextEditCallback(ImGuiInputTextCallbackData* iData)
|
||||
BuildSummary(iData->Buf);
|
||||
break;
|
||||
}
|
||||
case ImGuiInputTextFlags_CallbackAlways:
|
||||
{
|
||||
if (m_bModifyInput)
|
||||
{
|
||||
iData->DeleteChars(0, iData->BufTextLen);
|
||||
if (!m_svInputConVar.empty())
|
||||
{
|
||||
iData->InsertChars(0, m_svInputConVar.c_str());
|
||||
m_svInputConVar.clear();
|
||||
}
|
||||
m_bModifyInput = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ImGuiInputTextFlags_CallbackEdit:
|
||||
{
|
||||
for (size_t i = 0, n = strlen(iData->Buf); i < n; i++)
|
||||
|
@ -65,6 +65,7 @@ private:
|
||||
|
||||
vector<string> m_vCommands;
|
||||
vector<string> m_vHistory;
|
||||
string m_svInputConVar;
|
||||
ssize_t m_nHistoryPos = -1;
|
||||
int m_nScrollBack = 0;
|
||||
int m_nSelectBack = 0;
|
||||
@ -75,6 +76,7 @@ private:
|
||||
bool m_bInitialized = false;
|
||||
bool m_bReclaimFocus = false;
|
||||
bool m_bCopyToClipBoard = false;
|
||||
bool m_bModifyInput = false;
|
||||
|
||||
bool m_bCanAutoComplete = false;
|
||||
bool m_bSuggestActive = false;
|
||||
@ -97,7 +99,7 @@ private:
|
||||
ImGuiInputTextFlags_CallbackAlways |
|
||||
ImGuiInputTextFlags_CallbackEdit |
|
||||
ImGuiInputTextFlags_EnterReturnsTrue |
|
||||
ImGuiInputTextFlags_NoUndoRedo;
|
||||
ImGuiInputTextFlags_NoUndoRedo; // This flag will be removed when the ImGui lib is updated to v1.88 (see https://github.com/ocornut/imgui/issues/4947).
|
||||
|
||||
ImGuiWindowFlags m_nSuggestFlags =
|
||||
ImGuiWindowFlags_NoMove |
|
||||
|
Loading…
x
Reference in New Issue
Block a user