start_game.rml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <rml>
  2. <head>
  3. <title>Start Game</title>
  4. <link type="text/template" href="window.rml" />
  5. <style>
  6. body
  7. {
  8. width: 300dp;
  9. height: 225dp;
  10. margin: auto;
  11. }
  12. div#title_bar div#icon
  13. {
  14. decorator: image( icon-game );
  15. }
  16. form div
  17. {
  18. width: 200dp;
  19. margin: auto;
  20. }
  21. color
  22. {
  23. display: inline-block;
  24. width: 9dp;
  25. height: 9dp;
  26. border: 1dp #666;
  27. margin-right: 0.5em;
  28. }
  29. </style>
  30. <script>
  31. StartGame = StartGame or {}
  32. function StartGame.SetupGame(event,document)
  33. if event.parameters['difficulty'] == 'hard' then
  34. Game.SetDifficulty(Game.difficulty.HARD)
  35. else
  36. Game.SetDifficulty(Game.difficulty.EASY)
  37. end
  38. --some lua trickery coming up. Compiling a string at runtime that will return the values,
  39. --because they are comma separated. For example, if the user chose "Denim", then the
  40. --compiled string would look like "return 21,96,189"
  41. local red,green,blue = load('return '..event.parameters['colour']) ()
  42. Game.SetDefenderColour(Colourb.new(red,green,blue,255))
  43. local elem = Window.LoadMenu('game',document):GetElementById('game')
  44. elem:Focus()
  45. end
  46. </script>
  47. </head>
  48. <body template="luawindow" onkeydown="if Window.EscapePressed(event) then Window.LoadMenu('main_menu',document) end">
  49. <form onsubmit="StartGame.SetupGame(event,document)">
  50. <div>
  51. <p>
  52. Difficulty<br />
  53. <label><input type="radio" name="difficulty" value="easy" checked="true" /> Easy</label><br />
  54. <label><input type="radio" name="difficulty" value="hard" /> Hard</label>
  55. </p>
  56. <p>
  57. Colour<br />
  58. <select name="colour">
  59. <option value="233,116,81"><color style="background: rgb(233,116,81)"/>Burnt Sienna</option>
  60. <option value="127,255,0"><color style="background: rgb(127,255,0)"/>Chartreuse</option>
  61. <option value="21,96,189"><color style="background: rgb(21,96,189)"/>Denim</option>
  62. <option value="246,74,138"><color style="background: rgb(246,74,138)"/>French Rose</option>
  63. <option value="255,0,255"><color style="background: rgb(255,0,255)"/>Fuchsia</option>
  64. <option value="218,165,32"><color style="background: rgb(218,165,32)"/>Goldenrod</option>
  65. <option selected value="255,255,240"><color style="background: rgb(255,255,240)"/>Ivory</option>
  66. </select>
  67. </p>
  68. </div>
  69. <input type="submit">Start Game!</input>
  70. </form>
  71. </body>
  72. </rml>