mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-04-19 01:32:58 +02:00
engine tools: make services list a table and editable
This commit is contained in:
parent
ee3386e1ad
commit
77b43c572e
@ -28,6 +28,7 @@ namespace MM::Services {
|
|||||||
// returns wether the channel type is supported
|
// returns wether the channel type is supported
|
||||||
virtual bool getSupportedChannelType(channel_type type) = 0;
|
virtual bool getSupportedChannelType(channel_type type) = 0;
|
||||||
|
|
||||||
|
// in the best case, this performs a propper MTU estimation (lol)
|
||||||
virtual size_t getMaxPacketSize(void) = 0;
|
virtual size_t getMaxPacketSize(void) = 0;
|
||||||
|
|
||||||
// TODO: add set channel type utils
|
// TODO: add set channel type utils
|
||||||
|
@ -75,10 +75,46 @@ namespace MM::Services {
|
|||||||
|
|
||||||
void ImGuiEngineTools::renderServices(Engine& engine) {
|
void ImGuiEngineTools::renderServices(Engine& engine) {
|
||||||
if (ImGui::Begin("Services##EngineTools", &_show_services)) {
|
if (ImGui::Begin("Services##EngineTools", &_show_services)) {
|
||||||
ImGui::Text("TODO: use new table api");
|
ImGui::Text("TODO: make sortable");
|
||||||
|
ImGui::Checkbox("edit mode", &_services_edit_mode);
|
||||||
|
|
||||||
for (auto& it : engine._services) {
|
if (ImGui::BeginTable(
|
||||||
ImGui::Text("[%d|%s]: %s", it.first, it.second->second->name(), it.second->first ? "enabled" : "disabled");
|
"services_table",
|
||||||
|
3,
|
||||||
|
ImGuiTableFlags_RowBg //|
|
||||||
|
)) {
|
||||||
|
ImGui::TableSetupColumn("id", ImGuiTableColumnFlags_WidthFixed);
|
||||||
|
ImGui::TableSetupColumn("name");
|
||||||
|
ImGui::TableSetupColumn("status");
|
||||||
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
|
for (auto& it : engine._services) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%d", it.first);
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%s", it.second->second->name());
|
||||||
|
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (_services_edit_mode) {
|
||||||
|
ImGui::PushID(it.first);
|
||||||
|
if (ImGui::SmallButton(it.second->first ? "enabled" : "disabled")) {
|
||||||
|
if (it.second->first) {
|
||||||
|
engine.disableService(it.first);
|
||||||
|
} else {
|
||||||
|
engine.enableService(it.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ImGui::SetTooltip("click to toggle!"); the heck?
|
||||||
|
ImGui::PopID();
|
||||||
|
} else {
|
||||||
|
ImGui::Text("%s", it.second->first ? "enabled" : "disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
@ -17,6 +17,8 @@ namespace MM::Services {
|
|||||||
bool _show_about = false;
|
bool _show_about = false;
|
||||||
bool _show_services = false;
|
bool _show_services = false;
|
||||||
|
|
||||||
|
bool _services_edit_mode = false;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void renderImGui(Engine& engine);
|
void renderImGui(Engine& engine);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user