high_score.rml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <rml>
  2. <head>
  3. <title>High Scores</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: 281px 331px;
  15. icon-image-t: 152px 191px;
  16. }
  17. datagrid
  18. {
  19. margin-bottom: 20px;
  20. min-rows: 10;
  21. }
  22. datagrid data_grid_body
  23. {
  24. min-height: 200px;
  25. }
  26. defender
  27. {
  28. display: block;
  29. width: 64px;
  30. height: 16px;
  31. defender-decorator: defender;
  32. defender-image-src: high_scores_defender.tga;
  33. }
  34. </style>
  35. <script>
  36. HighScore = HighScore or {}
  37. --because we pass it as a plain function in HighScore.OnLoad, we have to pay attention
  38. --to the order of arguments. We don't need the first two in this case, so the name doesn't matter
  39. function HighScore.OnRowAdd(_,_,document)
  40. input = document:GetElementById('player_input')
  41. if input then
  42. input:Focus()
  43. end
  44. end
  45. function HighScore.OnLoad(window)
  46. Window.OnWindowLoad(window)
  47. local datagrid = window:GetElementById('datagrid')
  48. datagrid:AddEventListener('rowupdate', HighScore.OnRowAdd, false)
  49. end
  50. function HighScore.OnKeyDown(event)
  51. if event.parameters['key_identifier'] == rmlui.key_identifier.RETURN then
  52. Game.SetHighScoreName(Element.As.ElementFormControlInput(event.current_element).value)
  53. --Game.SetHighScoreName(event.current_element:AsType(Element.etype.input).value)
  54. end
  55. end
  56. </script>
  57. </head>
  58. <body template="luawindow" onload="HighScore.OnLoad(document) Game.SubmitHighScore()" onunload="Game.SetHighScoreName('Anon')">
  59. <datagrid id="datagrid" source="high_scores.scores">
  60. <col fields="name,name_required" formatter="name" width="40%">Pilot:</col>
  61. <col fields="colour" formatter="ship" width="20%">Ship:</col>
  62. <col fields="wave" width="20%">Wave:</col>
  63. <col fields="score" width="20%">Score:</col>
  64. </datagrid>
  65. <button onclick="Window.LoadMenu('main_menu',document)">Main Menu</button>
  66. </body>
  67. </rml>