Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.6KB

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