From 9f8ecc2433522095eefffe06d78a77f0335cd967 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Mon, 16 Dec 2024 03:02:21 +0500 Subject: [PATCH 1/4] Disable SDL2 text input mode by default --- src/xrEngine/x_ray.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xrEngine/x_ray.cpp b/src/xrEngine/x_ray.cpp index b4301ea2952..6234230f59b 100644 --- a/src/xrEngine/x_ray.cpp +++ b/src/xrEngine/x_ray.cpp @@ -228,6 +228,7 @@ CApplication::CApplication(pcstr commandLine, GameModule* game) ShowSplash(topmost); } + SDL_StopTextInput(); // It's enabled by default for some reason, we don't want it const auto& inputTask = TaskManager::AddTask([] { const bool captureInput = !strstr(Core.Params, "-i"); From 89635953b2cb028a1a412acee1c352e7a9a6f6f8 Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Mon, 16 Dec 2024 03:22:19 +0500 Subject: [PATCH 2/4] TaskManager: allow optional system events update during task waiting --- src/xrCore/Threading/TaskManager.cpp | 4 ++-- src/xrCore/Threading/TaskManager.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xrCore/Threading/TaskManager.cpp b/src/xrCore/Threading/TaskManager.cpp index 4746f70e886..a8c729857ba 100644 --- a/src/xrCore/Threading/TaskManager.cpp +++ b/src/xrCore/Threading/TaskManager.cpp @@ -304,13 +304,13 @@ void TaskManager::RunTask(Task& task) ExecuteTask(task); } -void TaskManager::Wait(const Task& task) const +void TaskManager::Wait(const Task& task, bool updateSystemEvents /*= false*/) const { ZoneScoped; while (!task.IsFinished()) { ExecuteOneTask(); - if (s_tl_worker.id == 0 && xrDebug::ProcessingFailure()) + if (s_tl_worker.id == 0 && (xrDebug::ProcessingFailure() || updateSystemEvents)) SDL_PumpEvents(); // Necessary to prevent dead locks } } diff --git a/src/xrCore/Threading/TaskManager.hpp b/src/xrCore/Threading/TaskManager.hpp index 8e2c18b1aed..60780220ed0 100644 --- a/src/xrCore/Threading/TaskManager.hpp +++ b/src/xrCore/Threading/TaskManager.hpp @@ -96,7 +96,7 @@ class XRCORE_API TaskManager final } public: - void Wait(const Task& task) const; + void Wait(const Task& task, bool updateSystemEvents = false) const; bool ExecuteOneTask() const; void Pause(bool pause) { shouldPause.store(pause, std::memory_order_release); } From 5baff2b1e7b138b1f4398496a8b69cc211d8cb4b Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Mon, 16 Dec 2024 05:10:36 +0500 Subject: [PATCH 3/4] Rewrite console rendering code to use ImGui Much better UX, fonts, looks (it's fancy!), etc. --- src/xrEngine/IGame_Persistent.cpp | 7 +- src/xrEngine/Text_Console.cpp | 6 +- src/xrEngine/XR_IOConsole.cpp | 581 ++++++++++--------------- src/xrEngine/XR_IOConsole.h | 42 +- src/xrEngine/XR_IOConsole_callback.cpp | 202 ++++----- src/xrEngine/editor_base.cpp | 12 + src/xrEngine/editor_base.h | 3 +- src/xrEngine/editor_base_input.cpp | 12 + 8 files changed, 347 insertions(+), 518 deletions(-) diff --git a/src/xrEngine/IGame_Persistent.cpp b/src/xrEngine/IGame_Persistent.cpp index bf17012c70f..ab6705dcc81 100644 --- a/src/xrEngine/IGame_Persistent.cpp +++ b/src/xrEngine/IGame_Persistent.cpp @@ -540,9 +540,10 @@ void IGame_Persistent::LoadDraw() const if (!Device.RenderBegin()) return; - if (GEnv.isDedicatedServer) - Console->OnRender(); - else + // XXX: fix dedicated server + //if (GEnv.isDedicatedServer) + // Console->OnRender(); + //else load_draw_internal(); Device.RenderEnd(); diff --git a/src/xrEngine/Text_Console.cpp b/src/xrEngine/Text_Console.cpp index 0784f1e91a7..136902ddbe3 100644 --- a/src/xrEngine/Text_Console.cpp +++ b/src/xrEngine/Text_Console.cpp @@ -5,7 +5,7 @@ #include extern char const* const ioc_prompt; -extern char const* const ch_cursor; +constexpr pcstr ch_cursor = "_"; int g_svTextConsoleUpdateRate = 1; CTextConsole::CTextConsole() @@ -213,6 +213,8 @@ void CTextConsole::OnPaint() void CTextConsole::DrawLog(HDC hDC, RECT* pRect) { + // XXX: fix dedicated server + /* TEXTMETRIC tm; GetTextMetrics(hDC, &tm); @@ -309,7 +311,7 @@ void CTextConsole::DrawLog(HDC hDC, RECT* pRect) { break; } - } + }*/ } /* void CTextConsole::IR_OnKeyboardPress( int dik ) !!!!!!!!!!!!!!!!!!!!! diff --git a/src/xrEngine/XR_IOConsole.cpp b/src/xrEngine/XR_IOConsole.cpp index d3e03741f02..b31235f907d 100644 --- a/src/xrEngine/XR_IOConsole.cpp +++ b/src/xrEngine/XR_IOConsole.cpp @@ -10,40 +10,30 @@ #include "xr_input.h" #include "xr_ioc_cmd.h" -#include "GameFont.h" -#include "Include/xrRender/UIRender.h" -#include "xrUICore/ui_defs.h" +#include -static float const LDIST = 0.05f; static u32 const cmd_history_max = 64; -static u32 const prompt_font_color = color_rgba(228, 228, 255, 255); -static u32 const tips_font_color = color_rgba(230, 250, 230, 255); -static u32 const cmd_font_color = color_rgba(138, 138, 245, 255); -static u32 const cursor_font_color = color_rgba(255, 255, 255, 255); -static u32 const total_font_color = color_rgba(250, 250, 15, 180); -static u32 const default_font_color = color_rgba(250, 250, 250, 250); +static Fcolor const prompt_font_color = color_rgba(228, 228, 255, 255); +static Fcolor const tips_font_color = color_rgba(230, 250, 230, 255); +static Fcolor const cmd_font_color = color_rgba(138, 138, 245, 255); +static Fcolor const total_font_color = color_rgba(250, 250, 15, 180); +static Fcolor const default_font_color = color_rgba(250, 250, 250, 250); -static u32 const back_color = color_rgba(20, 20, 20, 200); -static u32 const tips_back_color = color_rgba(20, 20, 20, 200); -static u32 const tips_select_color = color_rgba(90, 90, 140, 230); -static u32 const tips_word_color = color_rgba(5, 100, 56, 200); -static u32 const tips_scroll_back_color = color_rgba(15, 15, 15, 230); -static u32 const tips_scroll_pos_color = color_rgba(70, 70, 70, 240); +static Fcolor const back_color = color_rgba(20, 20, 20, 200); +static Fcolor const tips_back_color = color_rgba(20, 20, 20, 200); +static Fcolor const tips_select_color = color_rgba(90, 90, 140, 230); +static Fcolor const tips_word_color = color_rgba(5, 100, 56, 200); ENGINE_API CConsole* Console = NULL; extern char const* const ioc_prompt; -char const* const ioc_prompt = ">>> "; +char const* const ioc_prompt = ">>>"; -extern char const* const ch_cursor; -char const* const ch_cursor = "_"; - -text_editor::line_edit_control& CConsole::ec() { return m_editor->control(); } -u32 CConsole::get_mark_color(Console_mark type) +Fcolor CConsole::get_mark_color(Console_mark type) { - u32 color = default_font_color; + Fcolor color = default_font_color; switch (type) { case no_mark: break; @@ -91,10 +81,8 @@ bool CConsole::is_mark(Console_mark type) CConsole::CConsole() { - m_editor = xr_new(CONSOLE_BUF_SIZE); m_cmd_history_max = cmd_history_max; m_disable_tips = false; - Register_callbacks(); xrDebug::SetUserConfigHandler(this); } @@ -122,8 +110,6 @@ void CConsole::Initialize() CConsole::~CConsole() { - xr_delete(m_hShader_back); - xr_delete(m_editor); Destroy(); xrDebug::SetUserConfigHandler(nullptr); } @@ -132,8 +118,6 @@ void CConsole::Destroy() { ZoneScoped; - xr_delete(pFont); - xr_delete(pFont2); Commands.clear(); Engine.Event.Handler_Detach(eConsole, this); } @@ -152,94 +136,22 @@ void CConsole::OnFrame() { ZoneScoped; - m_editor->on_frame(); - if (Device.dwFrame % 10 == 0) { update_tips(); } -} - -void CConsole::OnEvent(EVENT E, u64 P1, u64 P2) -{ - pstr command = (pstr)P1; - ExecuteCommand(command, false); - xr_free(command); -} - -void CConsole::OutFont(pcstr text, float& pos_y) -{ - float str_length = pFont->SizeOf_(text); - float scr_width = 1.98f * Device.fWidth_2; - if (str_length > scr_width) // 1024.0f - { - // XXX: do something with 'f' after its assignment in while loop? - [[maybe_unused]] float f = 0.0f; - int sz = 0; - int ln = 0; - PSTR one_line = (PSTR)xr_alloca((CONSOLE_BUF_SIZE + 1) * sizeof(char)); - - while (text[sz] && (ln + sz < CONSOLE_BUF_SIZE - 5)) // перенос строк - { - one_line[ln + sz] = text[sz]; - one_line[ln + sz + 1] = 0; - - float t = pFont->SizeOf_(one_line + ln); - if (t > scr_width) - { - OutFont(text + sz + 1, pos_y); - pos_y -= LDIST; - pFont->OutI(-1.0f, pos_y, "%s", one_line + ln); - ln = sz + 1; - f = 0.0f; - } - else - { - f = t; - } - - ++sz; - } - } - else - { - pFont->OutI(-1.0f, pos_y, "%s", text); - } -} - -void CConsole::OnUIReset() -{ - xr_delete(pFont); - xr_delete(pFont2); -} - -void CConsole::OnRender() -{ - ZoneScoped; if (!bVisible) - { return; - } - if (!m_hShader_back) + if (!Device.editor().IsActiveState()) { - m_hShader_back = xr_new>(); - (*m_hShader_back)->create("hud" DELIMITER "default", "ui" DELIMITER "ui_console"); // "ui/ui_empty" - } + Device.editor().UpdateTextInput(); - if (!pFont) - { - pFont = xr_new("hud_font_di", CGameFont::fsDeviceIndependent); - pFont->SetHeightI(0.025f); - } - if (!pFont2) - { - pcstr fontSection = "hud_font_di2"; - if (!pSettings->section_exist(fontSection)) - fontSection = "hud_font_di"; - pFont2 = xr_new(fontSection, CGameFont::fsDeviceIndependent); - pFont2->SetHeightI(0.025f); + // Activate console input after hiding the editor + // XXX: not really great I'd say + if (pInput->CurrentIR() != this) + IR_Capture(); } bool bGame = false; @@ -253,271 +165,251 @@ void CConsole::OnRender() bGame = false; } - DrawBackgrounds(bGame); + const ImGuiViewport* viewport = ImGui::GetMainViewport(); - float fMaxY; - float dwMaxY = (float)Device.dwHeight; - // float dwMaxX=float(Device.dwWidth/2); + auto size = viewport->WorkSize; if (bGame) - { - fMaxY = 0.0f; - dwMaxY /= 2; - } - else - { - fMaxY = 1.0f; - } + size.y /= 2; - float ypos = fMaxY - LDIST * 1.1f; - float scr_x = 1.0f / Device.fWidth_2; + ImVec2 pos{}; + const auto padding = ImGui::GetStyle().WindowPadding; + ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f); - //--------------------------------------------------------------------------------- - float scr_width = 1.9f * Device.fWidth_2; - float ioc_d = pFont->SizeOf_(ioc_prompt); - float d1 = pFont->SizeOf_("_"); + // Console window + ImGui::SetNextWindowSize(size); + ImGui::SetNextWindowPos(viewport->WorkPos); + ImGui::SetNextWindowViewport(viewport->ID); + ImGui::PushStyleColor(ImGuiCol_WindowBg, reinterpret_cast(back_color)); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { padding.x, 0.0f }); // we want to disable padding for window bottom - pcstr s_cursor = ec().str_before_cursor(); - pcstr s_b_mark = ec().str_before_mark(); - pcstr s_mark = ec().str_mark(); - pcstr s_mark_a = ec().str_after_mark(); + constexpr ImGuiWindowFlags console_window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | + ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; //| ImGuiWindowFlags_NoMove; - // strncpy_s( buf1, cur_pos, editor, MAX_LEN ); - float str_length = ioc_d + pFont->SizeOf_(s_cursor); - float out_pos = 0.0f; - if (str_length > scr_width) + if (ImGui::Begin("Console", nullptr, console_window_flags)) { - out_pos -= (str_length - scr_width); - str_length = scr_width; - } - - pFont->SetColor(prompt_font_color); - pFont->OutI(-1.0f + out_pos * scr_x, ypos, "%s", ioc_prompt); - out_pos += ioc_d; + ImGui::SetCursorPosY(padding.y); // since we have disabled padding - if (bGame && !m_disable_tips && m_tips.size()) - { - pFont->SetColor(tips_font_color); + const size_t amount = LogFile.size(); + const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); - float shift_x = 0.0f; - switch (m_tips_mode) + // Log subwindow + if (ImGui::BeginChild("Log", { 0, -footer_height_to_reserve })) { - case 0: shift_x = scr_x * 1.0f; break; - case 1: shift_x = scr_x * out_pos; break; - case 2: shift_x = scr_x * (ioc_d + pFont->SizeOf_(m_cur_cmd.c_str()) + d1); break; - case 3: shift_x = scr_x * str_length; break; - } - - vecTipsEx::iterator itb = m_tips.begin() + m_start_tip; - vecTipsEx::iterator ite = m_tips.end(); - for (u32 i = 0; itb != ite; ++itb, ++i) // tips - { - pFont->OutI(-1.0f + shift_x, fMaxY + i * LDIST, "%s", (*itb).text.c_str()); - if (i >= VIEW_TIPS_COUNT - 1) + ImGuiListClipper clipper; + clipper.Begin(static_cast(amount)); + while (clipper.Step()) { - break; // for + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + { + const auto& line = LogFile[i]; + if (!line.c_str()) + continue; + const auto& color = get_mark_color((Console_mark)line[0]); + ImGui::PushStyleColor(ImGuiCol_Text, reinterpret_cast(color)); + ImGui::TextUnformatted(line.c_str(), line.data() + line.size()); + ImGui::PopStyleColor(); + } } + ImGui::SetScrollHereY(); } - } + ImGui::EndChild(); - // ===== ============================================== - pFont->SetColor(cmd_font_color); - pFont2->SetColor(cmd_font_color); + // Command input + ImGui::AlignTextToFramePadding(); + ImGui::TextColored(reinterpret_cast(prompt_font_color), "%s", ioc_prompt); - pFont->OutI(-1.0f + out_pos * scr_x, ypos, "%s", s_b_mark); - out_pos += pFont->SizeOf_(s_b_mark); - pFont2->OutI(-1.0f + out_pos * scr_x, ypos, "%s", s_mark); - out_pos += pFont2->SizeOf_(s_mark); - pFont->OutI(-1.0f + out_pos * scr_x, ypos, "%s", s_mark_a); + ImGui::SameLine(); + pos = ImGui::GetCursorScreenPos(); - // pFont2->OutI( -1.0f + ioc_d * scr_x, ypos, "%s", editor=all ); + ImGui::PushStyleColor(ImGuiCol_FrameBg, {}); + ImGui::PushStyleColor(ImGuiCol_Text, reinterpret_cast(cmd_font_color)); + ImGui::SetNextItemWidth(-100); - if (ec().cursor_view()) - { - pFont->SetColor(cursor_font_color); - pFont->OutI(-1.0f + str_length * scr_x, ypos, "%s", ch_cursor); - } - - // --------------------- - u32 log_line = LogFile.size() - 1; - ypos -= LDIST; - for (int i = log_line - scroll_delta; i >= 0; --i) - { - ypos -= LDIST; - if (ypos < -1.0f) - { - break; - } - pcstr ls = LogFile[i].c_str(); + constexpr ImGuiInputTextFlags input_text_flags = + ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | + ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EscapeClearsAll; - if (!ls) + constexpr auto callback = [](ImGuiInputTextCallbackData* data) { - continue; - } - Console_mark cm = (Console_mark)ls[0]; - pFont->SetColor(get_mark_color(cm)); - // u8 b = (is_mark( cm ))? 2 : 0; - // OutFont( ls + b, ypos ); - OutFont(ls, ypos); - } + return static_cast(data->UserData)->InputCallback(data); + }; - string16 q; - xr_itoa(log_line, q, 10); - u32 qn = xr_strlen(q); - pFont->SetColor(total_font_color); - pFont->OutI(0.95f - 0.03f * qn, fMaxY - 2.0f * LDIST, "[%d]", log_line); - - pFont->OnRender(); - pFont2->OnRender(); -} - -void CConsole::DrawBackgrounds(bool bGame) -{ - float ky = (bGame) ? 0.5f : 1.0f; + if (Device.editor().GetState() != xray::editor::ide::visible_state::full) + ImGui::SetKeyboardFocusHere(0); - Frect r; - r.set(0.0f, 0.0f, float(Device.dwWidth), ky* float(Device.dwHeight)); - - GEnv.UIRender->SetShader(**m_hShader_back); - // 6 = back, 12 = tips, (VIEW_TIPS_COUNT+1)*6 = highlight_words, 12 = scroll - const u32 numVertices = 6 + (bGame ? 12 + (VIEW_TIPS_COUNT + 1) * 6 + 12 : 0); - GEnv.UIRender->StartPrimitive(numVertices, IUIRender::ptTriList, IUIRender::pttTL); - - DrawRect(r, back_color); - - if (!bGame || m_tips.size() == 0 || m_disable_tips) - { - GEnv.UIRender->FlushPrimitive(); - return; - } - - pcstr max_str = "xxxxx"; - for (auto& it : m_tips) - if (pFont->SizeOf_(it.text.c_str()) > pFont->SizeOf_(max_str)) - max_str = it.text.c_str(); - - float w1 = pFont->SizeOf_("_"); - float ioc_w = pFont->SizeOf_(ioc_prompt) - w1; - float cur_cmd_w = pFont->SizeOf_(m_cur_cmd.c_str()); - cur_cmd_w += (cur_cmd_w > 0.01f) ? w1 : 0.0f; - - float list_w = pFont->SizeOf_(max_str) + 2.0f * w1; - - float font_h = pFont->CurrentHeight_(); - float tips_h = std::min(m_tips.size(), (size_t)VIEW_TIPS_COUNT) * font_h; - tips_h += (m_tips.size() > 0) ? 5.0f : 0.0f; - - Frect pr, sr; - pr.x1 = ioc_w + cur_cmd_w; - pr.x2 = pr.x1 + list_w; - - pr.y1 = UI_BASE_HEIGHT * 0.5f; - pr.y1 *= float(Device.dwHeight) / UI_BASE_HEIGHT; - - pr.y2 = pr.y1 + tips_h; + if (ImGui::InputText("##input", m_edit_string, std::size(m_edit_string), input_text_flags, callback, this)) + { + if (m_select_tip < 0 || m_select_tip >= static_cast(m_tips.size())) + ExecuteCommand(m_edit_string); + else + { + shared_str const& str = m_tips[m_select_tip].text; + if (m_tips_mode == 1) + { + pstr buf; + STRCONCAT(buf, str.c_str(), " "); + xr_strcpy(m_edit_string, buf); + } + else if (m_tips_mode == 2) + { + pstr buf; + STRCONCAT(buf, m_cur_cmd.c_str(), " ", str.c_str()); + xr_strcpy(m_edit_string, buf); + } + reset_selected_tip(); - float select_y = 0.0f; - float select_h = 0.0f; + if (ImGuiInputTextState* state = ImGui::GetInputTextState(ImGui::GetItemID())) + state->ReloadUserBufAndMoveToEnd(); + } + m_disable_tips = false; + ImGui::SetKeyboardFocusHere(-1); + } + ImGui::SetItemDefaultFocus(); + ImGui::PopStyleColor(2); - if (m_select_tip >= 0 && m_select_tip < (int)m_tips.size()) - { - int sel_pos = m_select_tip - m_start_tip; + // Amount of log lines + ImGui::SameLine(); + ImGui::TextColored(reinterpret_cast(total_font_color), "[%zu]", amount); - select_y = sel_pos * font_h; - select_h = font_h; // 1 string + pos.y = ImGui::GetWindowPos().y + ImGui::GetWindowHeight(); } + ImGui::End(); + ImGui::PopStyleColor(); // ImGuiCol_WindowBg + ImGui::PopStyleVar(); // ImGuiStyleVar_WindowPadding - sr.x1 = pr.x1; - sr.y1 = pr.y1 + select_y; - - sr.x2 = pr.x2; - sr.y2 = sr.y1 + select_h; - - DrawRect(pr, tips_back_color); - DrawRect(sr, tips_select_color); - - // --------------------------- highlight words -------------------- - - if (m_select_tip < (int)m_tips.size()) + // Tips + if (bGame && !m_disable_tips && m_tips.size()) { - Frect r2; - xr_string tmp; - vecTipsEx::iterator itb2 = m_tips.begin() + m_start_tip; - vecTipsEx::iterator ite2 = m_tips.end(); - for (u32 i = 0; itb2 != ite2; ++itb2, ++i) // tips + constexpr ImGuiWindowFlags tips_window_flags = + ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | + ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoDocking; + + ImGui::PushStyleColor(ImGuiCol_WindowBg, reinterpret_cast(tips_back_color)); + ImGui::PushStyleColor(ImGuiCol_Text, (ImVec4&)tips_font_color); + ImGui::SetNextWindowPos(pos); + ImGui::SetNextWindowViewport(viewport->ID); + ImGui::SetNextWindowSizeConstraints({ 300.f, 50.f }, { 500.f, size.y * 0.9f }); + if (ImGui::Begin("##tooltip", nullptr, tips_window_flags)) { - TipString const& ts = (*itb2); - if ((ts.HL_start < 0) || (ts.HL_finish < 0) || (ts.HL_start > ts.HL_finish)) - { - continue; - } - int str_size = (int)ts.text.size(); - if ((ts.HL_start >= str_size) || (ts.HL_finish > str_size)) - { - continue; - } + ImDrawList* draw_list = ImGui::GetWindowDrawList(); - r2.set_zero(); - tmp.assign(ts.text.c_str(), ts.HL_start); - r2.x1 = pr.x1 + w1 + pFont->SizeOf_(tmp.c_str()); - r2.y1 = pr.y1 + i * font_h; + ImGuiListClipper clipper; + clipper.Begin(static_cast(m_tips.size())); - tmp.assign(ts.text.c_str(), ts.HL_finish); - r2.x2 = pr.x1 + w1 + pFont->SizeOf_(tmp.c_str()); - r2.y2 = r2.y1 + font_h; + // Scroll to focused item once + static int itm_scroll_to = -1; + if (itm_scroll_to != m_select_tip && m_select_tip >= 0) + clipper.IncludeItemByIndex(m_select_tip); - DrawRect(r2, tips_word_color); - - if (i >= VIEW_TIPS_COUNT - 1) + while (clipper.Step()) { - break; // for itb2 - } - } // for itb - } // if - - // --------------------------- scroll bar -------------------- + for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) + { + const auto& line = m_tips[i].text; + if (line.empty()) + continue; + + cpcstr text = line.c_str(); + pos = ImGui::GetCursorScreenPos(); + + const TipString& ts = m_tips[i]; + if (ts.HL_start >= 0 && ts.HL_finish >= 0 && ts.HL_start <= ts.HL_finish) + { + const int str_size = static_cast(ts.text.size()); + if (ts.HL_start < str_size && ts.HL_finish <= str_size) + { + const ImVec2 text_size_before = ImGui::CalcTextSize(text, text + ts.HL_start); + const ImVec2 text_size_after = ImGui::CalcTextSize(text + ts.HL_start, text + ts.HL_finish); + + const ImVec2 char_pos = ImVec2(pos.x + text_size_before.x, pos.y); + const float text_height = ImGui::GetTextLineHeight(); + const float rect_width = text_size_after.x; + + draw_list->AddRectFilled( + ImVec2(char_pos.x, char_pos.y), + ImVec2(char_pos.x + rect_width, char_pos.y + text_height), + tips_word_color.get_windows() + ); + } + } + + ImGui::PushStyleColor(ImGuiCol_Header, reinterpret_cast(tips_select_color)); + if (ImGui::Selectable(text, i == m_select_tip)) + { + if (m_tips_mode == 1) + { + pstr buf; + STRCONCAT(buf, text, " "); + xr_strcpy(m_edit_string, buf); + } + else if (m_tips_mode == 2) + { + pstr buf; + STRCONCAT(buf, m_cur_cmd.c_str(), " ", text); + xr_strcpy(m_edit_string, buf); + } + } + ImGui::PopStyleColor(); + + if (itm_scroll_to != m_select_tip && i == m_select_tip) + { + ImGui::SetScrollHereY(); + itm_scroll_to = m_select_tip; + } + } + } // while (clipper.Step()) + } + ImGui::End(); + ImGui::PopStyleColor(2); + } - u32 tips_sz = m_tips.size(); - if (tips_sz > VIEW_TIPS_COUNT) - { - Frect rb, rs; + ImGui::PopStyleVar(); // ImGuiStyleVar_WindowBorderSize +} - rb.x1 = pr.x2; - rb.y1 = pr.y1; - rb.x2 = rb.x1 + 2 * w1; - rb.y2 = pr.y2; - DrawRect(rb, tips_scroll_back_color); +void CConsole::OnEvent(EVENT E, u64 P1, u64 P2) +{ + pstr command = (pstr)P1; + ExecuteCommand(command, false); + xr_free(command); +} - VERIFY(rb.y2 - rb.y1 >= 1.0f); - float back_height = rb.y2 - rb.y1; - float u_height = (back_height * VIEW_TIPS_COUNT) / float(tips_sz); - if (u_height < 0.5f * font_h) +void CConsole::IR_OnKeyboardPress(int key) +{ + switch (GetBindedAction(key)) + { + case kQUIT: + if (0 <= m_select_tip && m_select_tip < (int)m_tips.size()) { - u_height = 0.5f * font_h; + m_disable_tips = true; + return; } + [[fallthrough]]; - // float u_pos = (back_height - u_height) * float(m_start_tip) / float(tips_sz); - float u_pos = back_height * float(m_start_tip) / float(tips_sz); - - // clamp( u_pos, 0.0f, back_height - u_height ); - - rs = rb; - rs.y1 = pr.y1 + u_pos; - rs.y2 = rs.y1 + u_height; - DrawRect(rs, tips_scroll_pos_color); + case kCONSOLE: + { + Hide(); + return; } + } // switch (GetBindedAction(key)) - GEnv.UIRender->FlushPrimitive(); + Device.editor().IR_OnKeyboardPress(key); } -void CConsole::DrawRect(Frect const& r, u32 color) +void CConsole::IR_OnKeyboardRelease(int key) { - GEnv.UIRender->PushPoint(r.x1, r.y1, 0.0f, color, 0.0f, 0.0f); - GEnv.UIRender->PushPoint(r.x2, r.y1, 0.0f, color, 1.0f, 0.0f); - GEnv.UIRender->PushPoint(r.x2, r.y2, 0.0f, color, 1.0f, 1.0f); + Device.editor().IR_OnKeyboardRelease(key); +} + +void CConsole::IR_OnKeyboardHold(int key) +{ + Device.editor().IR_OnKeyboardHold(key); +} - GEnv.UIRender->PushPoint(r.x1, r.y1, 0.0f, color, 0.0f, 0.0f); - GEnv.UIRender->PushPoint(r.x2, r.y2, 0.0f, color, 1.0f, 1.0f); - GEnv.UIRender->PushPoint(r.x1, r.y2, 0.0f, color, 0.0f, 1.0f); +void CConsole::IR_OnTextInput(pcstr text) +{ + Device.editor().IR_OnTextInput(text); } void CConsole::ExecuteCommand(pcstr cmd_str, bool record_cmd) @@ -530,7 +422,6 @@ void CConsole::ExecuteCommand(pcstr cmd_str, bool record_cmd) xr_strcpy(edt, str_size + 1, cmd_str); edt[str_size] = 0; - scroll_delta = 0; reset_cmd_history_idx(); reset_selected_tip(); @@ -599,7 +490,7 @@ void CConsole::ExecuteCommand(pcstr cmd_str, bool record_cmd) if (record_cmd) { - ec().clear_states(); + m_edit_string[0] = '\0'; } } @@ -611,23 +502,13 @@ void CConsole::Show() } bVisible = true; - ec().clear_states(); - scroll_delta = 0; + m_edit_string[0] = '\0'; reset_cmd_history_idx(); reset_selected_tip(); update_tips(); - ForAllActionKeys(kCONSOLE, [&](size_t keyboard_index, int key) - { - if (key < CInput::COUNT_KB_BUTTONS) - { - ec().assign_callback(key, text_editor::ks_free, Callback(this, &CConsole::Hide_cmd)); - lastBindedKeys[keyboard_index] = key; - } - }); - - m_editor->IR_Capture(); - Device.seqRender.Add(this, 1); + if (!Device.editor().IsActiveState()) + IR_Capture(); Device.seqFrame.Add(this); } @@ -645,16 +526,8 @@ void CConsole::Hide() reset_selected_tip(); update_tips(); - for (int key : lastBindedKeys) - { - if (key) - ec().remove_callback(key); - } - ZeroMemory(lastBindedKeys, sizeof(lastBindedKeys)); - Device.seqFrame.Remove(this); - Device.seqRender.Remove(this); - m_editor->IR_Release(); + IR_Release(); } void CConsole::SelectCommand() @@ -666,7 +539,7 @@ void CConsole::SelectCommand() VERIFY(0 <= m_cmd_history_idx && m_cmd_history_idx < (int)m_cmd_history.size()); vecHistory::reverse_iterator it_rb = m_cmd_history.rbegin() + m_cmd_history_idx; - ec().set_edit((*it_rb).c_str()); + xr_strcpy(m_edit_string, it_rb->c_str()); reset_selected_tip(); } @@ -832,7 +705,7 @@ void CConsole::update_tips() return; } - pcstr cur = ec().str_edit(); + pcstr cur = m_edit_string; u32 cur_length = xr_strlen(cur); if (cur_length == 0) diff --git a/src/xrEngine/XR_IOConsole.h b/src/xrEngine/XR_IOConsole.h index 855f1171ac0..6f043c87f07 100644 --- a/src/xrEngine/XR_IOConsole.h +++ b/src/xrEngine/XR_IOConsole.h @@ -52,10 +52,9 @@ struct TipString }; class ENGINE_API CConsole : - public pureRender, public pureFrame, + public IInputReceiver, public IEventReceiver, - public CUIResetNotifier, public IUserConfigHandler { public: @@ -82,20 +81,11 @@ class ENGINE_API CConsole : }; protected: - int scroll_delta{}; - - CGameFont* pFont{}; - CGameFont* pFont2{}; - - FactoryPtr* m_hShader_back{}; - bool m_disable_tips; private: EVENT eConsole; - int lastBindedKeys[bindtypes_count]{}; - vecHistory m_cmd_history; u32 m_cmd_history_max; int m_cmd_history_idx; @@ -117,11 +107,13 @@ class ENGINE_API CConsole : virtual void OnDeviceInitialize() {} - virtual void OnRender(); virtual void OnFrame(); virtual void OnEvent(EVENT E, u64 P1, u64 P2) override; - void OnUIReset() override; + void IR_OnKeyboardPress(int key) override; + void IR_OnKeyboardRelease(int key) override; + void IR_OnKeyboardHold(int key) override; + void IR_OnTextInput(pcstr text) override; pcstr GetUserConfigFileName() override { return ConfigFile; } @@ -151,8 +143,7 @@ class ENGINE_API CConsole : IConsole_Command* GetCommand(pcstr cmd) const; protected: - text_editor::line_editor* m_editor; - text_editor::line_edit_control& ec(); + char m_edit_string[CONSOLE_BUF_SIZE]{}; enum Console_mark // (int)=char { @@ -173,21 +164,9 @@ class ENGINE_API CConsole : }; bool is_mark(Console_mark type); - u32 get_mark_color(Console_mark type); - - void DrawBackgrounds(bool bGame); - void DrawRect(Frect const& r, u32 color); - void OutFont(pcstr text, float& pos_y); - void Register_callbacks(); + static Fcolor get_mark_color(Console_mark type); protected: - void Prev_log(); - void Next_log(); - void Begin_log(); - void End_log(); - - void Find_cmd(); - void Find_cmd_back(); void Prev_cmd(); void Next_cmd(); void Prev_tip(); @@ -198,12 +177,7 @@ class ENGINE_API CConsole : void PageUp_tips(); void PageDown_tips(); - void Execute_cmd(); - void Show_cmd(); - void Hide_cmd(); - void Hide_cmd_esc(); - - void GamePause(); + int InputCallback(ImGuiInputTextCallbackData* data); protected: void add_cmd_history(shared_str const& str); diff --git a/src/xrEngine/XR_IOConsole_callback.cpp b/src/xrEngine/XR_IOConsole_callback.cpp index 6a5e672fb74..8563542e20c 100644 --- a/src/xrEngine/XR_IOConsole_callback.cpp +++ b/src/xrEngine/XR_IOConsole_callback.cpp @@ -8,97 +8,91 @@ #include "stdafx.h" #include "XR_IOConsole.h" -#include "line_editor.h" -#include "xr_input.h" #include "xr_ioc_cmd.h" -#include -void CConsole::Register_callbacks() +int CConsole::InputCallback(ImGuiInputTextCallbackData* data) { - ec().assign_callback(SDL_SCANCODE_PAGEUP, text_editor::ks_free, Callback(this, &CConsole::Prev_log)); - ec().assign_callback(SDL_SCANCODE_PAGEDOWN, text_editor::ks_free, Callback(this, &CConsole::Next_log)); - ec().assign_callback(SDL_SCANCODE_PAGEUP, text_editor::ks_Ctrl, Callback(this, &CConsole::Begin_log)); - ec().assign_callback(SDL_SCANCODE_PAGEDOWN, text_editor::ks_Ctrl, Callback(this, &CConsole::End_log)); - - ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_free, Callback(this, &CConsole::Find_cmd)); - ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_Shift, Callback(this, &CConsole::Find_cmd_back)); - ec().assign_callback(SDL_SCANCODE_TAB, text_editor::ks_Alt, Callback(this, &CConsole::GamePause)); - - ec().assign_callback(SDL_SCANCODE_UP, text_editor::ks_free, Callback(this, &CConsole::Prev_tip)); - ec().assign_callback(SDL_SCANCODE_DOWN, text_editor::ks_free, Callback(this, &CConsole::Next_tip)); - ec().assign_callback(SDL_SCANCODE_UP, text_editor::ks_Ctrl, Callback(this, &CConsole::Prev_cmd)); - ec().assign_callback(SDL_SCANCODE_DOWN, text_editor::ks_Ctrl, Callback(this, &CConsole::Next_cmd)); - - ec().assign_callback(SDL_SCANCODE_HOME, text_editor::ks_Alt, Callback(this, &CConsole::Begin_tips)); - ec().assign_callback(SDL_SCANCODE_END, text_editor::ks_Alt, Callback(this, &CConsole::End_tips)); - ec().assign_callback(SDL_SCANCODE_PAGEUP, text_editor::ks_Alt, Callback(this, &CConsole::PageUp_tips)); - ec().assign_callback(SDL_SCANCODE_PAGEDOWN, text_editor::ks_Alt, Callback(this, &CConsole::PageDown_tips)); - - ec().assign_callback(SDL_SCANCODE_RETURN, text_editor::ks_free, Callback(this, &CConsole::Execute_cmd)); - ec().assign_callback(SDL_SCANCODE_KP_ENTER, text_editor::ks_free, Callback(this, &CConsole::Execute_cmd)); - - ec().assign_callback(SDL_SCANCODE_ESCAPE, text_editor::ks_free, Callback(this, &CConsole::Hide_cmd_esc)); -} - -void CConsole::Prev_log() // SDL_SCANCODE_PRIOR=PAGE_UP -{ - scroll_delta++; - if (scroll_delta > int(LogFile.size()) - 1) + switch (data->EventFlag) { - scroll_delta = LogFile.size() - 1; - } -} - -void CConsole::Next_log() // SDL_SCANCODE_NEXT=PAGE_DOWN -{ - scroll_delta--; - if (scroll_delta < 0) + case ImGuiInputTextFlags_CallbackCompletion: { - scroll_delta = 0; + // Shift + Tab doesn't result in the callback call :( + /*if (ImGui::IsKeyDown(ImGuiMod_Shift)) + { + constexpr pcstr radmin_cmd_name = "ra "; + + pcstr edt = data->Buf; + const bool b_ra = edt == strstr(edt, radmin_cmd_name); + const size_t offset = b_ra ? xr_strlen(radmin_cmd_name) : 0; + + vecCMD_IT it = Commands.lower_bound(edt + offset); + if (it != Commands.begin()) + { + --it; + IConsole_Command& cc = *it->second; + pcstr name_cmd = cc.Name(); + size_t name_cmd_size = xr_strlen(name_cmd); + const size_t size = offset + name_cmd_size + 2; + pstr new_str = static_cast(xr_alloca(size * sizeof(char))); + + xr_strcpy(new_str, size, (b_ra) ? radmin_cmd_name : ""); + xr_strcat(new_str, size - offset, name_cmd); + data->BufTextLen = 0; + data->InsertChars(0, new_str, new_str + size); + } + } + else*/ + { + shared_str out_str; + + IConsole_Command* cc = find_next_cmd(m_edit_string, out_str); + if (cc && out_str.size()) + { + data->BufTextLen = 0; + data->InsertChars(0, out_str.c_str(), out_str.c_str() + out_str.size()); + } + } + data->ClearSelection(); + break; } -} - -void CConsole::Begin_log() // PAGE_UP+Ctrl -{ - scroll_delta = LogFile.size() - 1; -} - -void CConsole::End_log() // PAGE_DOWN+Ctrl -{ - scroll_delta = 0; -} - -void CConsole::Find_cmd() // SDL_SCANCODE_TAB -{ - shared_str out_str; - - IConsole_Command* cc = find_next_cmd(ec().str_edit(), out_str); - if (cc && out_str.size()) + case ImGuiInputTextFlags_CallbackHistory: { - ec().set_edit(out_str.c_str()); - } -} + const bool ctrl = ImGui::IsKeyDown(ImGuiMod_Ctrl); + const bool alt = ImGui::IsKeyDown(ImGuiMod_Alt); -void CConsole::Find_cmd_back() // SDL_SCANCODE_TAB+shift -{ - pcstr edt = ec().str_edit(); - pcstr radmin_cmd_name = "ra "; - bool b_ra = (edt == strstr(edt, radmin_cmd_name)); - u32 offset = (b_ra) ? xr_strlen(radmin_cmd_name) : 0; - - vecCMD_IT it = Commands.lower_bound(edt + offset); - if (it != Commands.begin()) - { - --it; - IConsole_Command& cc = *(it->second); - pcstr name_cmd = cc.Name(); - u32 name_cmd_size = xr_strlen(name_cmd); - PSTR new_str = (PSTR)xr_alloca((offset + name_cmd_size + 2) * sizeof(char)); - - xr_strcpy(new_str, offset + name_cmd_size + 2, (b_ra) ? radmin_cmd_name : ""); - xr_strcat(new_str, offset + name_cmd_size + 2, name_cmd); - ec().set_edit(new_str); + if (ctrl && alt) + { + if (data->EventKey == ImGuiKey_UpArrow) + Begin_tips(); + else if (data->EventKey == ImGuiKey_DownArrow) + End_tips(); + } + else if (alt) + { + if (data->EventKey == ImGuiKey_UpArrow) + PageUp_tips(); + else if (data->EventKey == ImGuiKey_DownArrow) + PageDown_tips(); + } + else if (ctrl) + { + if (data->EventKey == ImGuiKey_UpArrow) + Prev_cmd(); + else if (data->EventKey == ImGuiKey_DownArrow) + Next_cmd(); + } + else + { + if (data->EventKey == ImGuiKey_UpArrow) + Prev_tip(); + else if (data->EventKey == ImGuiKey_DownArrow) + Next_tip(); + } + data->ClearSelection(); + break; } + } // switch (data->EventFlag) + return 0; } void CConsole::Prev_cmd() // SDL_SCANCODE_UP + Ctrl @@ -115,7 +109,7 @@ void CConsole::Next_cmd() // SDL_SCANCODE_DOWN + Ctrl void CConsole::Prev_tip() // SDL_SCANCODE_UP { - if (xr_strlen(ec().str_edit()) == 0) + if (xr_strlen(m_edit_string) == 0) { prev_cmd_history_idx(); SelectCommand(); @@ -126,7 +120,7 @@ void CConsole::Prev_tip() // SDL_SCANCODE_UP void CConsole::Next_tip() // SDL_SCANCODE_DOWN + Ctrl { - if (xr_strlen(ec().str_edit()) == 0) + if (xr_strlen(m_edit_string) == 0) { next_cmd_history_idx(); SelectCommand(); @@ -159,43 +153,3 @@ void CConsole::PageDown_tips() m_select_tip += VIEW_TIPS_COUNT; check_next_selected_tip(); } - -void CConsole::Execute_cmd() // SDL_SCANCODE_RETURN, SDL_SCANCODE_KP_ENTER -{ - if (0 <= m_select_tip && m_select_tip < (int)m_tips.size()) - { - shared_str const& str = m_tips[m_select_tip].text; - if (m_tips_mode == 1) - { - pstr buf; - STRCONCAT(buf, str.c_str(), " "); - ec().set_edit(buf); - } - else if (m_tips_mode == 2) - { - pstr buf; - STRCONCAT(buf, m_cur_cmd.c_str(), " ", str.c_str()); - ec().set_edit(buf); - } - reset_selected_tip(); - } - else - { - ExecuteCommand(ec().str_edit()); - } - m_disable_tips = false; -} - -void CConsole::Show_cmd() { Show(); } -void CConsole::Hide_cmd() { Hide(); } -void CConsole::Hide_cmd_esc() -{ - if (0 <= m_select_tip && m_select_tip < (int)m_tips.size()) - { - m_disable_tips = true; - return; - } - Hide(); -} - -void CConsole::GamePause() {} diff --git a/src/xrEngine/editor_base.cpp b/src/xrEngine/editor_base.cpp index 1953209661e..63457e1b2ba 100644 --- a/src/xrEngine/editor_base.cpp +++ b/src/xrEngine/editor_base.cpp @@ -2,6 +2,7 @@ #include "editor_base.h" #include "editor_helper.h" +#include "XR_IOConsole.h" namespace xray::editor { @@ -82,6 +83,17 @@ void ide::ShowMain() { if (ImGui::BeginMenu("File")) { + if (imgui::MenuItemWithShortcut("Console", kCONSOLE, + "Show engine console.\n" + "Key shortcut will only work when no window is in focus", + Console->bVisible)) + { + if (Console->bVisible) + Console->Hide(); + else + Console->Show(); + } + if (imgui::MenuItemWithShortcut("Stats", kSCORES, "Show engine statistics.\n" "Key shortcut will only work when no window is in focus", diff --git a/src/xrEngine/editor_base.h b/src/xrEngine/editor_base.h index e28e24c9cc6..a48b9c12ee1 100644 --- a/src/xrEngine/editor_base.h +++ b/src/xrEngine/editor_base.h @@ -64,6 +64,8 @@ class ENGINE_API ide final : void SwitchToNextState(); bool IsActiveState() const { return m_state == visible_state::full; } + void UpdateTextInput(bool force_disable = false); + public: // Interface implementations void OnFrame() override; @@ -105,7 +107,6 @@ class ENGINE_API ide final : void UpdateMouseCursor(); void UpdateMouseData(); - void UpdateTextInput(bool force_disable = false); private: visible_state m_state{}; diff --git a/src/xrEngine/editor_base_input.cpp b/src/xrEngine/editor_base_input.cpp index ddb00f51ae8..e796aedcb5b 100644 --- a/src/xrEngine/editor_base_input.cpp +++ b/src/xrEngine/editor_base_input.cpp @@ -2,6 +2,7 @@ #include "editor_base.h" #include "editor_helper.h" +#include "XR_IOConsole.h" namespace { @@ -302,6 +303,17 @@ void ide::IR_OnKeyboardPress(int key) SwitchToNextState(); return; + case kCONSOLE: + if (!ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow)) + { + if (Console->bVisible) + Console->Hide(); + else + Console->Show(); + return; + } + break; + case kSCORES: if (!ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow)) { From 9bce9610adcbc159f15c6ef1dd50d0b038d9c99d Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Mon, 16 Dec 2024 05:14:04 +0500 Subject: [PATCH 4/4] Removed line_editor as it's no longer needed Was used only for the console --- src/xrEngine/CMakeLists.txt | 8 ------ src/xrEngine/Text_Console.cpp | 1 - src/xrEngine/XR_IOConsole.cpp | 2 +- src/xrEngine/XR_IOConsole.h | 1 - src/xrEngine/line_editor.cpp | 34 ---------------------- src/xrEngine/line_editor.h | 41 --------------------------- src/xrEngine/xrEngine.vcxproj | 2 -- src/xrEngine/xrEngine.vcxproj.filters | 9 ------ 8 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 src/xrEngine/line_editor.cpp delete mode 100644 src/xrEngine/line_editor.h diff --git a/src/xrEngine/CMakeLists.txt b/src/xrEngine/CMakeLists.txt index 0a25f5f5237..01400a88526 100644 --- a/src/xrEngine/CMakeLists.txt +++ b/src/xrEngine/CMakeLists.txt @@ -68,14 +68,6 @@ target_sources_grouped( edit_actions.h ) -target_sources_grouped( - TARGET xrEngine - NAME "Engine\\text_editor\\line_editor" - FILES - line_editor.cpp - line_editor.h -) - target_sources_grouped( TARGET xrEngine NAME "Engine\\text_editor\\line_editor_control" diff --git a/src/xrEngine/Text_Console.cpp b/src/xrEngine/Text_Console.cpp index 136902ddbe3..f9af323228f 100644 --- a/src/xrEngine/Text_Console.cpp +++ b/src/xrEngine/Text_Console.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Text_Console.h" -#include "line_editor.h" #include diff --git a/src/xrEngine/XR_IOConsole.cpp b/src/xrEngine/XR_IOConsole.cpp index b31235f907d..1aa6f9e7d49 100644 --- a/src/xrEngine/XR_IOConsole.cpp +++ b/src/xrEngine/XR_IOConsole.cpp @@ -3,7 +3,7 @@ #include "stdafx.h" #include "XR_IOConsole.h" -#include "line_editor.h" +#include "line_edit_control.h" #include "IGame_Level.h" #include "IGame_Persistent.h" diff --git a/src/xrEngine/XR_IOConsole.h b/src/xrEngine/XR_IOConsole.h index 6f043c87f07..90c9793bcdf 100644 --- a/src/xrEngine/XR_IOConsole.h +++ b/src/xrEngine/XR_IOConsole.h @@ -14,7 +14,6 @@ class ENGINE_API IConsole_Command; namespace text_editor { -class line_editor; class line_edit_control; }; diff --git a/src/xrEngine/line_editor.cpp b/src/xrEngine/line_editor.cpp deleted file mode 100644 index 9509bc5b3e6..00000000000 --- a/src/xrEngine/line_editor.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : line_editor.cpp -// Created : 22.02.2008 -// Author : Evgeniy Sokolov -// Description : line editor class implementation -//////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "line_editor.h" - -namespace text_editor -{ -line_editor::line_editor(size_t str_buffer_size) : m_control(str_buffer_size) -{ -} - -void line_editor::on_frame() { m_control.on_frame(); } -void line_editor::IR_OnKeyboardPress(int dik) { m_control.on_key_press(dik); } -void line_editor::IR_OnKeyboardHold(int dik) { m_control.on_key_hold(dik); } -void line_editor::IR_OnKeyboardRelease(int dik) { m_control.on_key_release(dik); } -void line_editor::IR_OnTextInput(const char *text) { m_control.on_text_input(text); } - -void line_editor::IR_OnActivate() -{ - m_control.on_ir_capture(); - IInputReceiver::IR_OnDeactivate(); -} - -void line_editor::IR_OnDeactivate() -{ - m_control.on_ir_release(); - IInputReceiver::IR_OnDeactivate(); -} -} // namespace text_editor diff --git a/src/xrEngine/line_editor.h b/src/xrEngine/line_editor.h deleted file mode 100644 index 56351552bf0..00000000000 --- a/src/xrEngine/line_editor.h +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////////////////////// -// Module : line_editor.h -// Created : 22.02.2008 -// Author : Evgeniy Sokolov -// Description : line editor class, controller of line_edit_control -//////////////////////////////////////////////////////////////////////////// - -#ifndef LINE_EDITOR_H_INCLUDED -#define LINE_EDITOR_H_INCLUDED - -#include "IInputReceiver.h" -#include "line_edit_control.h" - -namespace text_editor -{ -class line_editor : public IInputReceiver -{ -public: - line_editor(size_t str_buffer_size); - virtual ~line_editor() = default; - - IC line_edit_control& control() { return m_control; } - void on_frame(); - - void IR_OnActivate() final; - void IR_OnDeactivate() final; - -protected: - void IR_OnKeyboardPress(int dik) final; - void IR_OnKeyboardHold(int dik) final; - void IR_OnKeyboardRelease(int dik) final; - void IR_OnTextInput(const char *text) final; - -private: - line_edit_control m_control; - -}; // class line_editor - -} // namespace text_editor - -#endif // LINE_EDITOR_H_INCLUDED diff --git a/src/xrEngine/xrEngine.vcxproj b/src/xrEngine/xrEngine.vcxproj index b0b07ea325d..ff1aed20ef0 100644 --- a/src/xrEngine/xrEngine.vcxproj +++ b/src/xrEngine/xrEngine.vcxproj @@ -69,7 +69,6 @@ - @@ -152,7 +151,6 @@ - diff --git a/src/xrEngine/xrEngine.vcxproj.filters b/src/xrEngine/xrEngine.vcxproj.filters index f4cd1855f2c..b113dd11576 100644 --- a/src/xrEngine/xrEngine.vcxproj.filters +++ b/src/xrEngine/xrEngine.vcxproj.filters @@ -112,9 +112,6 @@ {0f8148ae-26b3-4084-84f0-9711e72596b2} - - {a561951d-df21-4744-bd9e-0bc69e0dfa42} - {982d1115-af31-4164-88bf-d50bb3a7cad1} @@ -321,9 +318,6 @@ Engine\Noise - - Engine\text_editor\line_editor - Engine\text_editor\line_editor_control @@ -548,9 +542,6 @@ Engine\Noise - - Engine\text_editor\line_editor - Engine\text_editor\line_editor_control