MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / DrawConsoleTab

Function DrawConsoleTab

engine/Poseidon/Dev/Debug/DebugOverlay.cpp:787–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

785}
786} // namespace
787
788void DrawConsoleTab()
789{
790 ImGui::TextUnformatted("SQF / DebugCommands console");
791 ImGui::Separator();
792
793 // Scrollback region. Reserve room for the input row at the bottom.
794 const float inputRowH = ImGui::GetFrameHeightWithSpacing();
795 if (ImGui::BeginChild("ConsoleScroll", ImVec2(0, -inputRowH), true, ImGuiWindowFlags_HorizontalScrollbar))
796 {
797 for (const auto& line : s_console.scrollback)
798 ImGui::TextUnformatted(line.c_str());
799 if (s_console.autoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())
800 ImGui::SetScrollHereY(1.0f);
801 }
802 ImGui::EndChild();
803
804 // Input row: text box + Run button. Enter inside the text box
805 // also runs the line. EnterReturnsTrue makes the InputText
806 // produce true when Enter is hit, so we don't need a separate
807 // key check.
808 if (s_console.focusOnShow)
809 {
810 ImGui::SetKeyboardFocusHere();
811 s_console.focusOnShow = false;
812 }
813 bool entered = ImGui::InputText("##ConsoleInput", s_console.input, sizeof(s_console.input),
814 ImGuiInputTextFlags_EnterReturnsTrue);
815 ImGui::SameLine();
816 bool clicked = ImGui::Button("Run");
817 if (entered || clicked)
818 {
819 std::string line(s_console.input);
820 s_console.input[0] = 0;
821 if (!line.empty())
822 Defer([line] { ConsoleRun(line); });
823 ImGui::SetKeyboardFocusHere(-1); // refocus the text box
824 }
825 ImGui::SameLine();
826 if (ImGui::Button("Clear"))
827 s_console.scrollback.clear();
828 ImGui::SameLine();
829 ImGui::Checkbox("Auto-scroll", &s_console.autoScroll);
830
831 if (ImGui::IsItemHovered())
832 ImGui::SetTooltip("Bare lines dispatch through DebugCommands first\n"
833 "(save, endmission win, weather 0.5, …).\n"
834 "Prefix `:` to force SQF (e.g. `:hint \"hi\"`)");
835}
836
837// Profile tab — FPS gauge + frame-time history graph. Reads the

Callers 1

DrawMainWindowFunction · 0.85

Calls 4

DeferFunction · 0.85
ConsoleRunFunction · 0.85
clearMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected