Research portable Memory game | Исследовать портируемую игру Память
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

143 řádky
3.5KB

  1. from gui_aux import *
  2. from gui_TextureDescription import *
  3. from llm import *
  4. from memory_Context import *
  5. # Generate texture descriptions for harm description
  6. #
  7. # Conditions:
  8. # 1.descImage, descImageCount, descImageHeight, or descImageWidth has just changed
  9. @llm_by_value
  10. def gui_generateDescTextureDescriptions(
  11. c: memory_Context
  12. ) -> memory_Context:
  13. if (
  14. c.recentField == "descImage" or
  15. c.recentField == "descImageCount" or
  16. c.recentField == "descImageHeight" or
  17. c.recentField == "descImageWidth"
  18. ):
  19. tds: list[gui_TextureDescription] = []
  20. for id in range(0, c.descImageCount):
  21. td = gui_createTextureDescription()
  22. td.fileName = c.descImage
  23. td.height = c.descImageHeight
  24. td.width = c.descImageWidth
  25. td.x = id * c.descImageWidth
  26. td.y = 0
  27. tds.append(td)
  28. #}
  29. c.descTextureDescriptions = tds
  30. c.recentField = "descTextureDescriptions"
  31. return c
  32. #}
  33. c.recentField = "none"
  34. return c
  35. #}
  36. # Generate texture descriptions for tiles
  37. #
  38. # Conditions:
  39. # 1. tileImage or tileImageCount or tileImageHeight or tileImageWidth has just changed
  40. @llm_by_value
  41. def gui_generateTextureDescriptions(
  42. c: memory_Context
  43. ) -> memory_Context:
  44. if (
  45. c.recentField == "tileImage" or
  46. c.recentField == "tileImageCount" or
  47. c.recentField == "tileImageHeight" or
  48. c.recentField == "tileImageWidth"
  49. ):
  50. tds: list[gui_TextureDescription] = []
  51. for id in range(0, c.tileImageCount):
  52. td = gui_createTextureDescription()
  53. td.fileName = c.tileImage
  54. td.height = c.tileImageHeight
  55. td.width = c.tileImageWidth
  56. td.x = id * c.tileImageWidth
  57. td.y = 0
  58. tds.append(td)
  59. #}
  60. c.textureDescriptions = tds
  61. c.recentField = "textureDescriptions"
  62. return c
  63. #}
  64. c.recentField = "none"
  65. return c
  66. #}
  67. # Generate tile positions
  68. #
  69. # Conditions:
  70. # 1. cellSize, playField, windowHeight, or windowWidth has changed and none of them is zero
  71. @llm_by_value
  72. def gui_generateTilePositions(
  73. c: memory_Context
  74. ) -> memory_Context:
  75. if (
  76. (
  77. c.recentField != "cellPositions" and
  78. c.recentField != "cellSize" and
  79. c.recentField != "playfieldSize" and
  80. c.recentField != "windowHeight" and
  81. c.recentField != "windowWidth"
  82. ) or
  83. (
  84. len(c.cellPositions) == 0 or
  85. c.cellSize == 0 or
  86. c.playfieldSize == 0 or
  87. c.windowHeight == 0 or
  88. c.windowWidth == 0
  89. )
  90. ):
  91. c.recentField = "none"
  92. return c
  93. #}
  94. ps = []
  95. for i in range(0, len(c.cellPositions)):
  96. p = gui_aux_cellScreenPosition(c, c.cellPositions[i])
  97. ps.append(p)
  98. #}
  99. c.tilePositions = ps
  100. c.recentField = "tilePositions"
  101. return c
  102. #}
  103. # Generate texture descriptions for tiTLes
  104. #
  105. # Conditions:
  106. # 1. titleImage, titleImageCount, titleImageHeight, or titleImageWidth has just changed
  107. @llm_by_value
  108. def gui_generateTitleTextureDescriptions(
  109. c: memory_Context
  110. ) -> memory_Context:
  111. if (
  112. c.recentField == "titleImage" or
  113. c.recentField == "titleImageCount" or
  114. c.recentField == "titleImageHeight" or
  115. c.recentField == "titleImageWidth"
  116. ):
  117. tds: list[gui_TextureDescription] = []
  118. for id in range(0, c.titleImageCount):
  119. td = gui_createTextureDescription()
  120. td.fileName = c.titleImage
  121. td.height = c.titleImageHeight
  122. td.width = c.titleImageWidth
  123. td.x = id * c.titleImageWidth
  124. td.y = 0
  125. tds.append(td)
  126. #}
  127. c.titleTextureDescriptions = tds
  128. c.recentField = "titleTextureDescriptions"
  129. return c
  130. #}
  131. c.recentField = "none"
  132. return c
  133. #}