MCPcopy Create free account
hub / github.com/MethanePowered/MethaneKit / InitUserInterface

Method InitUserInterface

Apps/08-ConsoleCompute/ConsoleApp.cpp:66–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void ConsoleApp::InitUserInterface()
67{
68 META_FUNCTION_TASK();
69 using namespace ftxui;
70 auto toolbar = Container::Horizontal({
71 Renderer([this]
72 {
73 return hbox({
74 text(fmt::format(" API: {} ", GetGraphicsApiName())),
75 separator(),
76 text(fmt::format(" GPU: {} ", GetComputeDeviceName())),
77 separator(),
78 text(fmt::format(" FPS: {} ", GetFramesCountPerSecond())),
79 separator(),
80 text(fmt::format(" Field: {} x {} ", m_field_size.GetWidth(), m_field_size.GetHeight())),
81 separator(),
82 text(fmt::format(" Visible {} ", static_cast<std::string>(m_frame_rect) )),
83 separator(),
84 text(fmt::format(" Visible Cells {} ", GetVisibleCellsCount()))
85 });
86 }) | border | xflex,
87 Button(" X ", m_screen.ExitLoopClosure(), ButtonOption::Simple()) | align_right
88 });
89
90 m_compute_device_option.on_change = [this]()
91 {
92 Release();
93 Init();
94 };
95
96 m_game_rule_option.on_change = [this]()
97 {
98 ResetRules();
99 };
100
101 auto sidebar = Container::Vertical({
102 Renderer([]{ return text("GPU Devices:") | ftxui::bold; }),
103 Radiobox(&GetComputeDeviceNames(), &m_compute_device_index, m_compute_device_option),
104 Checkbox("30 FPS limit", &m_30fps_screen_refresh_limit_enabled),
105 Renderer([] { return separator(); }),
106 Renderer([]{ return text("Game Rules:") | ftxui::bold; }),
107 Radiobox(&g_gol_rule_labels, &m_game_rule_index, m_game_rule_option),
108 Renderer([] { return separator(); }),
109 Container::Horizontal({
110 Button("Restart", [this]() { Restart(); }, ButtonOption::Border()),
111 Button("Play | Pause", [this]() { ToggleScreenRefresh(); }, ButtonOption::Border()),
112 Button("Next Step", [this]() { Compute(); }, ButtonOption::Border()),
113 }),
114 Slider("Initial Cells %", &m_initial_cells_percent),
115 Renderer([]
116 {
117 return vbox({
118 separator(),
119 paragraph("Controls:") | ftxui::bold,
120 paragraph(" ◆ Press mouse left button over game field to drag the visible area."),
121 paragraph(" ◆ Press mouse left button over vertical splitter and drag to resize left panel."),
122 paragraph(" ◆ Resize console window to increase canvas area."),
123 separator(),

Callers

nothing calls this directly

Calls 4

ButtonEnum · 0.85
GetWidthMethod · 0.45
GetHeightMethod · 0.45
RenderMethod · 0.45

Tested by

no test coverage detected