options.rml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <rml>
  2. <head>
  3. <title>Options</title>
  4. <link type="text/template" href="window.rml" />
  5. <style>
  6. body
  7. {
  8. width: 350px;
  9. height: 350px;
  10. margin: auto;
  11. }
  12. div#title_bar div#icon
  13. {
  14. icon-image-s: 230px 281px;
  15. icon-image-t: 152px 191px;
  16. display: none;
  17. }
  18. form div
  19. {
  20. width: 200px;
  21. margin: auto;
  22. }
  23. </style>
  24. <script>
  25. import cPickle
  26. def LoadOptions(document):
  27. try:
  28. f = open('options.dat', 'rt')
  29. options = cPickle.loads("".join(f.readlines()))
  30. document.GetElementById(options['graphics']).checked = True
  31. document.GetElementById('reverb').checked = options['reverb']
  32. document.GetElementById('3d').checked = options['3d']
  33. except IOError:
  34. pass
  35. def SaveOptions(event, document):
  36. try:
  37. if event.parameters['button'] == 'cancel':
  38. return
  39. options = {}
  40. options['graphics'] = event.parameters['graphics']
  41. options['reverb'] = 'reverb' in event.parameters
  42. options['3d'] = '3d' in event.parameters
  43. f = open('options.dat', 'wt')
  44. f.write(cPickle.dumps(options))
  45. f.close()
  46. except IOError:
  47. pass
  48. def DisplayBadGraphics(document, display):
  49. if display:
  50. document.GetElementById('bad_warning').style.display = 'block'
  51. else:
  52. document.GetElementById('bad_warning').style.display = 'none'
  53. </script>
  54. </head>
  55. <body template="pywindow" onload="OnWindowLoad(self); LoadOptions(document)">
  56. <form onsubmit="SaveOptions(event, document); LoadMenu('main_menu')">
  57. <div>
  58. <p>
  59. Graphics:<br />
  60. <input id="good" type="radio" name="graphics" value="good"/> Good<br />
  61. <input id="ok" type="radio" name="graphics" value="ok" checked="true"/> OK<br />
  62. <input id="bad" type="radio" name="graphics" value="bad" onchange="DisplayBadGraphics(document, self.checked)" /> Bad<br />
  63. </p>
  64. <p id="bad_warning" style="display: none;">Are you sure about this? Bad graphics are just plain <em>bad.</em></p>
  65. <p>
  66. Audio:<br />
  67. <input id="reverb" type="checkbox" name="reverb" value="true" checked="true" /> Reverb<br />
  68. <input id="3d" type="checkbox" name="3d" value="true" /> 3D Spatialisation
  69. </p>
  70. </div>
  71. <input type="submit" name="button" value="accept">Accept</input>
  72. <input type="submit" name="button" value="cancel">Cancel</input>
  73. </form>
  74. </body>
  75. </rml>