program.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "system-selection.cpp"
  2. #include "home.cpp"
  3. #include "game-manager.cpp"
  4. #include "game-importer.cpp"
  5. namespace Instances { Instance<ProgramWindow> programWindow; }
  6. ProgramWindow& programWindow = Instances::programWindow();
  7. SystemSelection& systemSelection = programWindow.systemSelection;
  8. Home& home = programWindow.home;
  9. GameManager& gameManager = programWindow.gameManager;
  10. GameImporter& gameImporter = programWindow.gameImporter;
  11. ProgramWindow::ProgramWindow() {
  12. actionMenu.setText("Action");
  13. quitAction.setIcon(Icon::Action::Quit).setText("Quit").onActivate([&] { doClose(); });
  14. settingsMenu.setText("Settings");
  15. createManifests.setText("Create Manifests").setChecked(settings.createManifests).onToggle([&] {
  16. settings.createManifests = createManifests.checked();
  17. });
  18. useDatabase.setText("Use Database").setChecked(settings.useDatabase).onToggle([&] {
  19. settings.useDatabase = useDatabase.checked();
  20. });
  21. useHeuristics.setText("Use Heuristics").setChecked(settings.useHeuristics).onToggle([&] {
  22. settings.useHeuristics = useHeuristics.checked();
  23. });
  24. helpMenu.setText("Help");
  25. aboutAction.setIcon(Icon::Prompt::Question).setText("About icarus ...").onActivate([&] {
  26. image logo{Resource::Higan::Logo};
  27. logo.shrink();
  28. AboutDialog()
  29. .setName("icarus")
  30. .setLogo(logo)
  31. .setDescription("icarus — a game analyzer and converter")
  32. .setVersion(higan::Version)
  33. .setCopyright(higan::Copyright)
  34. .setLicense(higan::License, higan::LicenseURI)
  35. .setWebsite(higan::Website, higan::WebsiteURI)
  36. .setAlignment(*this)
  37. .show();
  38. });
  39. panels.setPadding(5_sx, 5_sy);
  40. for(auto& cell : panels.cells()) cell.setSpacing(0);
  41. resizeGrip.onActivate([&] {
  42. resizeWidth = panels.cell(systemSelection).size().width();
  43. });
  44. resizeGrip.onResize([&](auto offset) {
  45. float min = 128_sx, max = panels.geometry().width() - 128_sx;
  46. float width = resizeWidth + offset;
  47. width = width < min ? min : width > max ? max : width;
  48. if(panels.cell(systemSelection).size().width() != width) {
  49. panels.cell(systemSelection).setSize({width, ~0});
  50. panels.resize();
  51. }
  52. });
  53. systemSelection.setVisible(true);
  54. show(home);
  55. onClose(&Application::quit);
  56. setTitle({"icarus v", higan::Version});
  57. setSize({800_sx, 545_sy});
  58. setAlignment(Alignment::Center);
  59. setVisible();
  60. }
  61. auto ProgramWindow::show(Panel& panel) -> void {
  62. if(activePanel && *activePanel == panel) return;
  63. if(activePanel) activePanel->setVisible(false);
  64. activePanel = panel;
  65. activePanel->setVisible(true);
  66. panels.resize();
  67. }
  68. auto ProgramWindow::hide(Panel& panel) -> void {
  69. show(home);
  70. }