settings.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. SettingsMenu::SettingsMenu(MenuBar* parent) : Menu(parent) {
  2. setText("Settings");
  3. outputMenu.setText("Output").setIcon(Icon::Emblem::Image);
  4. outputCenter.setText("Center").onActivate([&] {
  5. settings.video.output = "Center";
  6. });
  7. outputScale.setText("Scale").onActivate([&] {
  8. settings.video.output = "Scale";
  9. });
  10. outputStretch.setText("Stretch").onActivate([&] {
  11. settings.video.output = "Stretch";
  12. });
  13. if(settings.video.output == "Center") outputCenter.setChecked();
  14. if(settings.video.output == "Scale") outputScale.setChecked();
  15. if(settings.video.output == "Stretch") outputStretch.setChecked();
  16. aspectCorrection.setText("Aspect Correction").setChecked(settings.video.aspectCorrection).onToggle([&] {
  17. settings.video.aspectCorrection = aspectCorrection.checked();
  18. });
  19. scaleMenu.setText("Scale").setIcon(Icon::Emblem::Image);
  20. scale2x.setText("640x480").onActivate([&] {
  21. settings.video.scale = 2;
  22. program.resize();
  23. });
  24. scale3x.setText("960x720").onActivate([&] {
  25. settings.video.scale = 3;
  26. program.resize();
  27. });
  28. scale4x.setText("1280x960").onActivate([&] {
  29. settings.video.scale = 4;
  30. program.resize();
  31. });
  32. shaderMenu.setText("Shader").setIcon(Icon::Emblem::Image).setEnabled(false);
  33. muteAudio.setText("Mute Audio").setChecked(settings.audio.mute).onToggle([&] {
  34. settings.audio.mute = muteAudio.checked();
  35. emulator.audioUpdateEffects();
  36. });
  37. showStatusBar.setText("Show Status Bar").setChecked(settings.interface.showStatusBar).onToggle([&] {
  38. settings.interface.showStatusBar = showStatusBar.checked();
  39. if(showStatusBar.checked()) {
  40. program.showStatus();
  41. } else {
  42. program.hideStatus();
  43. }
  44. });
  45. showSystemPanels.setText("Show System Panels").setChecked(settings.interface.showSystemPanels).onToggle([&] {
  46. settings.interface.showSystemPanels = showSystemPanels.checked();
  47. if(showSystemPanels.checked()) {
  48. program.showPanels();
  49. } else {
  50. program.hidePanels();
  51. }
  52. });
  53. }
  54. auto SettingsMenu::updateShaders() -> void {
  55. shaderMenu.reset();
  56. if(!videoInstance.ready() || !videoInstance.hasShader()) {
  57. shaderMenu.setEnabled(false);
  58. return;
  59. }
  60. shaderMenu.setEnabled();
  61. Group shaders;
  62. MenuRadioItem none{&shaderMenu};
  63. none.setText("None").onActivate([&] {
  64. settings.video.shader = "None";
  65. emulator.videoUpdateShader();
  66. });
  67. shaders.append(none);
  68. MenuRadioItem blur{&shaderMenu};
  69. blur.setText("Blur").onActivate([&] {
  70. settings.video.shader = "Blur";
  71. emulator.videoUpdateShader();
  72. });
  73. shaders.append(blur);
  74. string location{Path::settings, "Shaders/"};
  75. if(settings.video.driver == "OpenGL 3.2") {
  76. for(auto shaderName : directory::folders(location, "*.shader")) {
  77. if(shaders.objectCount() == 2) shaderMenu.append(MenuSeparator());
  78. MenuRadioItem item{&shaderMenu};
  79. item.setText(Location::prefix(shaderName)).onActivate([=] {
  80. settings.video.shader = {location, shaderName};
  81. emulator.videoUpdateShader();
  82. });
  83. shaders.append(item);
  84. }
  85. }
  86. if(settings.video.shader == "None") none.setChecked();
  87. if(settings.video.shader == "Blur") blur.setChecked();
  88. for(auto item : shaders.objects<MenuRadioItem>()) {
  89. if(settings.video.shader == string{location, item.text(), ".shader/"}) {
  90. item.setChecked();
  91. }
  92. }
  93. }