mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 19:05:00 +01:00
feat(ui): memory cells section in the debug panel, to look up and set them while the simulation runs
This commit is contained in:
@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "application/driveruipanels.h"
|
#include "application/driveruipanels.h"
|
||||||
|
#include "application/editoruipanels.h"
|
||||||
|
|
||||||
#include "utilities/Globals.h"
|
#include "utilities/Globals.h"
|
||||||
#include "application/application.h"
|
#include "application/application.h"
|
||||||
@@ -544,6 +545,22 @@ void debug_panel::update()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// memory cells of the scenery, to look into and play with while the simulation runs
|
||||||
|
bool render_section_memcells() {
|
||||||
|
|
||||||
|
if( false == ImGui::CollapsingHeader( "Memory Cells" ) ) { return false; }
|
||||||
|
static memcells_panel memcells { "Memory cells", true };
|
||||||
|
memcells.listheight = ImGui::GetTextLineHeightWithSpacing() * 12.f;
|
||||||
|
ImGui::PushID( "memcells" );
|
||||||
|
memcells.render_body();
|
||||||
|
ImGui::PopID();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void
|
void
|
||||||
debug_panel::render() {
|
debug_panel::render() {
|
||||||
if( false == is_open ) { return; }
|
if( false == is_open ) { return; }
|
||||||
@@ -577,6 +594,7 @@ debug_panel::render() {
|
|||||||
render_section( "Vehicle Scan Table", m_scantablelines );
|
render_section( "Vehicle Scan Table", m_scantablelines );
|
||||||
render_section_scenario();
|
render_section_scenario();
|
||||||
render_section_eventqueue();
|
render_section_eventqueue();
|
||||||
|
render_section_memcells();
|
||||||
if( true == render_section( "Power Grid", m_powergridlines ) ) {
|
if( true == render_section( "Power Grid", m_powergridlines ) ) {
|
||||||
// traction state debug
|
// traction state debug
|
||||||
ImGui::Checkbox( "Debug Traction", &DebugTractionFlag );
|
ImGui::Checkbox( "Debug Traction", &DebugTractionFlag );
|
||||||
|
|||||||
@@ -2468,12 +2468,17 @@ void memcells_panel::render()
|
|||||||
auto const panelname{(title.empty() ? std::string{STR_C(m_name.c_str())} : title) + "###" + m_name};
|
auto const panelname{(title.empty() ? std::string{STR_C(m_name.c_str())} : title) + "###" + m_name};
|
||||||
if (ImGui::Begin(panelname.c_str(), &is_open, ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse))
|
if (ImGui::Begin(panelname.c_str(), &is_open, ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoCollapse))
|
||||||
{
|
{
|
||||||
render_list();
|
render_body();
|
||||||
render_cell();
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void memcells_panel::render_body()
|
||||||
|
{
|
||||||
|
render_list();
|
||||||
|
render_cell();
|
||||||
|
}
|
||||||
|
|
||||||
void memcells_panel::render_list()
|
void memcells_panel::render_list()
|
||||||
{
|
{
|
||||||
auto const &cells{simulation::Memory.sequence()};
|
auto const &cells{simulation::Memory.sequence()};
|
||||||
@@ -2533,8 +2538,8 @@ void memcells_panel::render_list()
|
|||||||
}
|
}
|
||||||
ImGui::TextDisabled(STR_C("Memory cells: %d, shown: %d"), static_cast<int>(m_sorted.size()), static_cast<int>(m_listed.size()));
|
ImGui::TextDisabled(STR_C("Memory cells: %d, shown: %d"), static_cast<int>(m_sorted.size()), static_cast<int>(m_listed.size()));
|
||||||
|
|
||||||
auto const listheight{std::max(120.0f, ImGui::GetContentRegionAvail().y - ImGui::GetFrameHeightWithSpacing() * 7.0f)};
|
auto const height{listheight > 0.0f ? listheight : std::max(120.0f, ImGui::GetContentRegionAvail().y - ImGui::GetFrameHeightWithSpacing() * 7.0f)};
|
||||||
if (ImGui::BeginTable("##memcells", 5, ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(-1.0f, listheight)))
|
if (ImGui::BeginTable("##memcells", 5, ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(-1.0f, height)))
|
||||||
{
|
{
|
||||||
ImGui::TableSetupScrollFreeze(0, 1);
|
ImGui::TableSetupScrollFreeze(0, 1);
|
||||||
ImGui::TableSetupColumn(STR_C("Name"), ImGuiTableColumnFlags_WidthStretch, 2.0f);
|
ImGui::TableSetupColumn(STR_C("Name"), ImGuiTableColumnFlags_WidthStretch, 2.0f);
|
||||||
@@ -2601,7 +2606,7 @@ void memcells_panel::render_cell()
|
|||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (m_selected == nullptr)
|
if (m_selected == nullptr)
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled("%s", STR_C("Pick a memory cell from the list to set what's in it. A double click shows where it is"));
|
ImGui::TextDisabled("%s", focus ? STR_C("Pick a memory cell from the list to set what's in it. A double click shows where it is") : STR_C("Pick a memory cell from the list to set what's in it"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto *cell{m_selected};
|
auto *cell{m_selected};
|
||||||
|
|||||||
@@ -283,9 +283,13 @@ class memcells_panel : public ui_panel
|
|||||||
memcells_panel(std::string const &Name, bool const Isopen) : ui_panel(Name, Isopen) {}
|
memcells_panel(std::string const &Name, bool const Isopen) : ui_panel(Name, Isopen) {}
|
||||||
|
|
||||||
void render() override;
|
void render() override;
|
||||||
|
// panel content without the window, also drawn in the debug panel of the driver mode
|
||||||
|
void render_body();
|
||||||
|
|
||||||
// moves the camera to specified node; provided by the editor mode
|
// moves the camera to specified node; provided by the editor mode
|
||||||
std::function<void(scene::basic_node *)> focus;
|
std::function<void(scene::basic_node *)> focus;
|
||||||
|
// height of the list, 0: it takes what the window has left
|
||||||
|
float listheight{0.0f};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// methods
|
// methods
|
||||||
|
|||||||
@@ -10375,3 +10375,6 @@ msgstr "Dodaj do wartości"
|
|||||||
|
|
||||||
msgid "Read again"
|
msgid "Read again"
|
||||||
msgstr "Odczytaj ponownie"
|
msgstr "Odczytaj ponownie"
|
||||||
|
|
||||||
|
msgid "Pick a memory cell from the list to set what's in it"
|
||||||
|
msgstr "Wybierz komórkę pamięci z listy, aby ustawić jej zawartość"
|
||||||
|
|||||||
Reference in New Issue
Block a user