Research portable Memory game | Исследовать портируемую игру Память
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

176 行
4.3KB

  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 splash screens
  37. #
  38. # Conditions:
  39. # 1.splashImage, splashImageCount, splashImageHeight, or splashImageWidth has just changed
  40. @llm_by_value
  41. def gui_generateSplashTextureDescriptions(
  42. c: memory_Context
  43. ) -> memory_Context:
  44. if (
  45. c.recentField == "splashImage" or
  46. c.recentField == "splashImageCount" or
  47. c.recentField == "splashImageHeight" or
  48. c.recentField == "splashImageWidth"
  49. ):
  50. tds: list[gui_TextureDescription] = []
  51. for id in range(0, c.splashImageCount):
  52. td = gui_createTextureDescription()
  53. td.fileName = c.splashImage
  54. td.height = c.splashImageHeight
  55. td.width = c.splashImageWidth
  56. td.x = id * c.splashImageWidth
  57. td.y = 0
  58. tds.append(td)
  59. #}
  60. c.splashTextureDescriptions = tds
  61. c.recentField = "splashTextureDescriptions"
  62. return c
  63. #}
  64. c.recentField = "none"
  65. return c
  66. #}
  67. # Generate texture descriptions for tiles
  68. #
  69. # Conditions:
  70. # 1. tileImage or tileImageCount or tileImageHeight or tileImageWidth has just changed
  71. @llm_by_value
  72. def gui_generateTextureDescriptions(
  73. c: memory_Context
  74. ) -> memory_Context:
  75. if (
  76. c.recentField == "tileImage" or
  77. c.recentField == "tileImageCount" or
  78. c.recentField == "tileImageHeight" or
  79. c.recentField == "tileImageWidth"
  80. ):
  81. tds: list[gui_TextureDescription] = []
  82. for id in range(0, c.tileImageCount):
  83. td = gui_createTextureDescription()
  84. td.fileName = c.tileImage
  85. td.height = c.tileImageHeight
  86. td.width = c.tileImageWidth
  87. td.x = id * c.tileImageWidth
  88. td.y = 0
  89. tds.append(td)
  90. #}
  91. c.textureDescriptions = tds
  92. c.recentField = "textureDescriptions"
  93. return c
  94. #}
  95. c.recentField = "none"
  96. return c
  97. #}
  98. # Generate tile positions
  99. #
  100. # Conditions:
  101. # 1. cellSize, playField, windowHeight, or windowWidth has changed and none of them is zero
  102. @llm_by_value
  103. def gui_generateTilePositions(
  104. c: memory_Context
  105. ) -> memory_Context:
  106. if (
  107. (
  108. c.recentField != "cellPositions" and
  109. c.recentField != "cellSize" and
  110. c.recentField != "playfieldSize" and
  111. c.recentField != "windowHeight" and
  112. c.recentField != "windowWidth"
  113. ) or
  114. (
  115. len(c.cellPositions) == 0 or
  116. c.cellSize == 0 or
  117. c.playfieldSize == 0 or
  118. c.windowHeight == 0 or
  119. c.windowWidth == 0
  120. )
  121. ):
  122. c.recentField = "none"
  123. return c
  124. #}
  125. ps = []
  126. for i in range(0, len(c.cellPositions)):
  127. p = gui_aux_cellScreenPosition(c, c.cellPositions[i])
  128. ps.append(p)
  129. #}
  130. c.tilePositions = ps
  131. c.recentField = "tilePositions"
  132. return c
  133. #}
  134. # Generate texture descriptions for tiTLes
  135. #
  136. # Conditions:
  137. # 1. titleImage, titleImageCount, titleImageHeight, or titleImageWidth has just changed
  138. @llm_by_value
  139. def gui_generateTitleTextureDescriptions(
  140. c: memory_Context
  141. ) -> memory_Context:
  142. if (
  143. c.recentField == "titleImage" or
  144. c.recentField == "titleImageCount" or
  145. c.recentField == "titleImageHeight" or
  146. c.recentField == "titleImageWidth"
  147. ):
  148. tds: list[gui_TextureDescription] = []
  149. for id in range(0, c.titleImageCount):
  150. td = gui_createTextureDescription()
  151. td.fileName = c.titleImage
  152. td.height = c.titleImageHeight
  153. td.width = c.titleImageWidth
  154. td.x = id * c.titleImageWidth
  155. td.y = 0
  156. tds.append(td)
  157. #}
  158. c.titleTextureDescriptions = tds
  159. c.recentField = "titleTextureDescriptions"
  160. return c
  161. #}
  162. c.recentField = "none"
  163. return c
  164. #}