index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. (() => {
  2. class ElIM02TopScore {
  3. static colorVariants = [
  4. 0xc8ffdb, 0x6da175, 0xc4b984, 0xc484a2, 0xbbbbbb, 0xfbffd9,
  5. ];
  6. fetch() {
  7. const current = [];
  8. for (let i = 0; i < 5; i++) {
  9. current[i] = hmFS.SysProGetInt("el02_top" + i);
  10. if (!current[i]) current[i] = i == 4 ? 0 : (4 - i) * 100;
  11. }
  12. return current;
  13. }
  14. addResult(v) {
  15. const current = this.fetch();
  16. if (v > current[4]) current[4] = v;
  17. current.sort();
  18. current.reverse();
  19. for (let i = 0; i < 5; i++) {
  20. hmFS.SysProSetInt("el02_top" + i, current[i]);
  21. }
  22. }
  23. start() {
  24. let current = this.fetch();
  25. let currentBgColor = hmFS.SysProGetInt("im02_bg");
  26. if (!currentBgColor) currentBgColor = 0;
  27. let color = ElIM02TopScore.colorVariants[currentBgColor];
  28. let bg = hmUI.createWidget(hmUI.widget.FILL_RECT, {
  29. x: 0,
  30. y: 0,
  31. w: 192,
  32. h: 490,
  33. color,
  34. });
  35. hmUI.createWidget(hmUI.widget.IMG, {
  36. x: 49,
  37. y: 30,
  38. src: "title_top.png",
  39. });
  40. const base = {
  41. font_array: [...Array(10).keys()].map((i) => `font/${i}.png`)
  42. };
  43. // TOP
  44. for (let i = 0; i < 5; i++) {
  45. hmUI.createWidget(hmUI.widget.TEXT_IMG, {
  46. x: 30,
  47. y: 100 + i * 30,
  48. text: (i + 1).toString(),
  49. ...base,
  50. });
  51. hmUI.createWidget(hmUI.widget.TEXT_IMG, {
  52. x: 100,
  53. y: 100 + i * 30,
  54. text: current[i].toString(),
  55. ...base,
  56. });
  57. }
  58. // Play btn
  59. hmUI.createWidget(hmUI.widget.IMG, {
  60. x: 0,
  61. y: 250,
  62. pos_x: 72,
  63. pos_y: 30,
  64. w: 192,
  65. h: 100,
  66. src: "play.png",
  67. }).addEventListener(hmUI.event.CLICK_UP, () => {
  68. hmApp.gotoPage({ url: "page/game", param: color });
  69. });
  70. hmUI.createWidget(hmUI.widget.TEXT, {
  71. x: 0,
  72. y: 350,
  73. w: 192,
  74. h: 50,
  75. align_h: hmUI.align.CENTER_H,
  76. align_v: hmUI.align.CENTER_V,
  77. text: "Изменить фон",
  78. color: 0x0,
  79. alpha: 192,
  80. }).addEventListener(hmUI.event.CLICK_UP, () => {
  81. let current = hmFS.SysProGetInt("im02_bg");
  82. if (!current) current = 0;
  83. current = (current + 1) % ElIM02TopScore.colorVariants.length;
  84. color = ElIM02TopScore.colorVariants[current];
  85. hmFS.SysProSetInt("im02_bg", current);
  86. bg.setProperty(hmUI.prop.MORE, { color });
  87. });
  88. // Copyright
  89. hmUI.createWidget(hmUI.widget.IMG, {
  90. x: 29,
  91. y: 420,
  92. alpha: 80,
  93. src: "copyright_do_not_remove.png",
  94. });
  95. }
  96. }
  97. let __$$app$$__ = __$$hmAppManager$$__.currentApp;
  98. let __$$module$$__ = __$$app$$__.current;
  99. __$$module$$__.module = DeviceRuntimeCore.Page({
  100. onInit() {
  101. hmSetting.setBrightScreen(30);
  102. hmUI.setLayerScrolling(false);
  103. new ElIM02TopScore().start();
  104. },
  105. onDestroy() {
  106. hmSetting.setBrightScreenCancel();
  107. }
  108. });
  109. })();