settings.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "../higan-ui.hpp"
  2. Settings settings;
  3. auto Settings::load() -> void {
  4. if(auto document = file::read({Path::userSettings(), "higan/settings.bml"})) {
  5. properties(0, BML::unserialize(document));
  6. }
  7. }
  8. auto Settings::save() -> void {
  9. Markup::Node document;
  10. properties(1, document);
  11. directory::create({Path::userSettings(), "higan/"});
  12. file::write({Path::userSettings(), "higan/settings.bml"}, BML::serialize(document));
  13. }
  14. auto Settings::properties(bool mode, Markup::Node document) -> void {
  15. #define s(name) \
  16. if(mode == 0 && document[string{#name}.trimRight(".identifier", 1L).transform(".", "/")]) { \
  17. document[string{#name}.trimRight(".identifier", 1L).transform(".", "/")].value(name); \
  18. } \
  19. if(mode == 1) { \
  20. document(string{#name}.trimRight(".identifier", 1L).transform(".", "/")).setValue(name); \
  21. }
  22. s(video.driver)
  23. s(video.monitor)
  24. s(video.format)
  25. s(video.exclusive)
  26. s(video.blocking)
  27. s(video.flush)
  28. s(video.luminance)
  29. s(video.saturation)
  30. s(video.gamma)
  31. s(video.output)
  32. s(video.aspectCorrection)
  33. s(video.scale)
  34. s(video.shader)
  35. s(audio.driver)
  36. s(audio.device)
  37. s(audio.frequency)
  38. s(audio.latency)
  39. s(audio.exclusive)
  40. s(audio.blocking)
  41. s(audio.dynamic)
  42. s(audio.skew)
  43. s(audio.volume)
  44. s(audio.balance)
  45. s(audio.mute)
  46. s(input.driver)
  47. s(input.unfocused)
  48. s(interface.showStatusBar)
  49. s(interface.showSystemPanels)
  50. s(interface.advancedMode)
  51. s(hotkeys.toggleStatus.identifier)
  52. s(hotkeys.togglePanels.identifier)
  53. s(hotkeys.toggleFullscreen.identifier)
  54. s(hotkeys.toggleMouseCapture.identifier)
  55. s(hotkeys.fastForward.identifier)
  56. s(hotkeys.saveState.identifier)
  57. s(hotkeys.loadState.identifier)
  58. s(hotkeys.incrementStateSlot.identifier)
  59. s(hotkeys.decrementStateSlot.identifier)
  60. s(hotkeys.pauseEmulation.identifier)
  61. s(hotkeys.exportMemory.identifier)
  62. s(hotkeys.quitEmulator.identifier)
  63. #undef s
  64. }