system-overview.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. SystemOverview::SystemOverview(View* parent) : PanelItem(parent, Size{~0, ~0}) {
  2. setCollapsible().setVisible(false);
  3. header.setFont(Font().setBold());
  4. removeButton.setText("Remove").onActivate([&] { systemManager.doRemove(); });
  5. renameButton.setText("Rename").onActivate([&] { systemManager.doRename(); });
  6. launchButton.setText("Launch").onActivate([&] { systemManager.onActivate(); });
  7. }
  8. auto SystemOverview::show() -> void {
  9. refresh();
  10. setVisible(true);
  11. }
  12. auto SystemOverview::hide() -> void {
  13. setVisible(false);
  14. }
  15. auto SystemOverview::refresh() -> void {
  16. auto location = systemManager.listView.selected().attribute("location");
  17. nodeList.reset();
  18. auto manifest = BML::unserialize(file::read({location, "manifest.bml"}));
  19. header.setText(manifest["system"].text());
  20. if(auto root = higan::Node::unserialize(file::read({location, "settings.bml"}))) {
  21. for(auto& node : *root) scan(node);
  22. }
  23. }
  24. auto SystemOverview::scan(higan::Node::Object node, uint depth) -> void {
  25. if(node->is<higan::Node::Input>()) return;
  26. if(node->is<higan::Node::Screen>()) return;
  27. if(node->is<higan::Node::Component>() && !settings.interface.advancedMode) return;
  28. ListViewItem item{&nodeList};
  29. string name;
  30. for(uint n : range(depth)) name.append(" ");
  31. name.append(node->attribute("name") ? node->attribute("name") : node->name());
  32. if(auto setting = node->cast<higan::Node::Setting>()) {
  33. name.append(": ", setting->readValue());
  34. }
  35. item.setText(name);
  36. for(auto& node : *node) scan(node, depth + 1);
  37. }