settings.lisp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ;;;; Copyright © 2023, Jaidyn Ann <jadedctrl@posteo.at>
  2. ;;;;
  3. ;;;; This program is free software: you can redistribute it and/or
  4. ;;;; modify it under the terms of the GNU General Public License as
  5. ;;;; published by the Free Software Foundation, either version 3 of
  6. ;;;; the License, or (at your option) any later version.
  7. ;;;;
  8. ;;;; This program is distributed in the hope that it will be useful,
  9. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;;;; GNU General Public License for more details.
  12. ;;;;
  13. ;;;; You should have received a copy of the GNU General Public License
  14. ;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. ;;;; FLORA-SEARCH-AURORA.SETTINGS 🔧
  16. ;;;; Guess whatttt? Settings, that’s what. =w=
  17. ;;;; How riveting!
  18. (in-package :flora-search-aurora.settings)
  19. (defun make-controls-function (controls)
  20. "Simple state-function (for use with STATE-LOOP's state plists) that sets the
  21. keyboard controls to the given CONTROLS."
  22. (lambda (matrix)
  23. (setq ⌨:*controls* controls)
  24. (list :drop 1)))
  25. (defun make-keyboard-function (layout)
  26. "Simple state-function (for use with STATE-LOOP's state plists) that sets the
  27. keyboard layout to the given LAYOUT."
  28. (lambda (matrix)
  29. (setq ⌨:*keyboard* layout)
  30. (list :drop 1)))
  31. (defun make-language-function (language)
  32. "Simple state-function (for use with STATE-LOOP's state plists) that sets the
  33. game language to the given LANGUAGE."
  34. (lambda (matrix)
  35. (setq …:*language* language)
  36. (list :drop 1)))
  37. (defun keyboard-menu ()
  38. `((:en "QWERTY"
  39. :selection 50 :selected t
  40. :function ,(make-keyboard-function ⌨:+qwerty-layout+)
  41. :drop 1)
  42. (:en "Dvorak"
  43. :function ,(make-keyboard-function ⌨:+dvorak-layout+)
  44. :drop 1)
  45. (:en "Arrows" :eo "Sagoj"
  46. :function ,(make-controls-function ⌨:+arrows-game-layout+)
  47. :row 1 :drop 1)
  48. (:en "WASD"
  49. :function ,(make-controls-function ⌨:+wasd-game-layout+)
  50. :row 1 :drop 1)
  51. (:en "IJKL" :eo "IJKL"
  52. :function ,(make-controls-function ⌨:+ijkl-game-layout+)
  53. :row 1 :drop 1)))
  54. (defun language-menu ()
  55. `((:en "Esperanto"
  56. :selected t :selection 50
  57. :function ,(make-language-function :eo)
  58. :drop 1)
  59. (:en "English"
  60. :function ,(make-language-function :en)
  61. :row 1 :drop 1)))
  62. (defun settings-menu ()
  63. `((:en "Keyboard" :eo "Klavararanĝo"
  64. :selection 50 :selected t
  65. :function
  66. ,(📋:make-menu-function (keyboard-menu))
  67. :drop 1)
  68. (:en "Language" :eo "Lingvo"
  69. :function ,(📋:make-menu-function (language-menu))
  70. :drop 1)
  71. (:en "Back" :eo "Reiri"
  72. :drop 1)))
  73. (defun make-settings-menu-function ()
  74. "Create a menu state-function for use with STATE-LOOP, displaying settings
  75. and allowing the user to modify them. Pretty self-explanatory, tbh."
  76. (📋:make-menu-function (settings-menu)))