37 m_console_view.cvw_enable_scrolling =
true;
42 ImGuiWindowFlags win_flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_MenuBar;
43 ImGui::SetNextWindowPosCenter(ImGuiCond_FirstUseEver);
44 ImGui::SetNextWindowSize(ImVec2((ImGui::GetIO().DisplaySize.x / 1.6), (ImGui::GetIO().DisplaySize.y / 1.3)), ImGuiCond_FirstUseEver);
45 bool keep_open =
true;
46 ImGui::Begin(
"Console", &keep_open, win_flags);
48 if (ImGui::BeginMenuBar())
50 if (ImGui::BeginMenu(
_LC(
"Console",
"Filter options")))
52 m_console_view.DrawFilteringOptions();
55 if (ImGui::BeginMenu(
_LC(
"Console",
"Commands")))
57 ImGui::Dummy(ImVec2(700.f, 1.f));
59 ImGui::SetColumnWidth(0, 100);
60 ImGui::SetColumnWidth(1, 170);
61 ImGui::SetColumnWidth(2, 500);
65 if (ImGui::Selectable(cmd_pair.second->getName().c_str()))
67 cmd_pair.second->Run(Ogre::StringVector{cmd_pair.second->getName()});
70 ImGui::Text(
"%s", cmd_pair.second->GetUsage().c_str());
72 ImGui::Text(
"%s", cmd_pair.second->GetDoc().c_str());
79 #ifdef USE_ANGELSCRIPT
80 ImGui::SetNextWindowSize(ImVec2((ImGui::GetIO().DisplaySize.x / 2), (ImGui::GetIO().DisplaySize.y / 1.5)));
81 if (ImGui::BeginMenu(
_LC(
"Console",
"AngelScript")))
83 ImGui::Dummy(ImVec2(720.f, 1.f));
85 ImGui::SetColumnWidth(0, 230);
86 ImGui::SetColumnWidth(1, 160);
87 ImGui::SetColumnWidth(2, 400);
89 m_angelscript_examples.Draw();
94 ImGui::SetNextWindowSize(ImVec2(0.f, 0.f));
96 if (ImGui::BeginMenu(
_LC(
"Console",
"Script Monitor")))
98 ImGui::Dummy(ImVec2(440.f, 1.f));
99 m_script_monitor.Draw();
106 const float footer_height_to_reserve = ImGui::GetFrameHeightWithSpacing();
107 ImGui::BeginChild(
"ScrollingRegion", ImVec2(0, -footer_height_to_reserve),
false, ImGuiWindowFlags_HorizontalScrollbar);
109 m_console_view.DrawConsoleMessages();
113 const ImGuiInputTextFlags cmd_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackHistory;
116 this->doCommand(m_cmd_buffer.ToCStr());
117 m_cmd_buffer.Clear();
120 m_is_hovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows);
127 this->SetVisible(
false);
133 Ogre::StringUtil::trim(msg);
140 m_cmd_history.push_back(msg);
141 if (m_cmd_history.size() > HISTORY_CAP)
143 m_cmd_history.erase(m_cmd_history.begin());
145 m_cmd_history_cursor = -1;
159 if (data->EventFlag == ImGuiInputTextFlags_CallbackHistory)
161 const int prev_cursor = m_cmd_history_cursor;
162 if (data->EventKey == ImGuiKey_UpArrow)
164 if (m_cmd_history_cursor == -1)
166 m_cmd_history_cursor =
static_cast<int>(m_cmd_history.size()) - 1;
168 else if (m_cmd_history_cursor > 0)
170 m_cmd_history_cursor--;
173 else if (data->EventKey == ImGuiKey_DownArrow)
175 if (m_cmd_history_cursor != -1)
177 ++m_cmd_history_cursor;
179 if (m_cmd_history_cursor >=
static_cast<int>(m_cmd_history.size()))
181 m_cmd_history_cursor = -1;
186 if (m_cmd_history_cursor != prev_cursor)
188 const char* text = (m_cmd_history_cursor >= 0) ? m_cmd_history.at(m_cmd_history_cursor).c_str() :
"";
189 data->DeleteChars(0, data->BufTextLen);
190 data->InsertChars(0, text);