|
- from gui_aux import *
- from gui_TextureDescription import *
- from llm import *
- from memory_Context import *
-
- # Generate textures descriptions
- #
- # Conditions:
- # 1. tileImage or tileImageCount or tileImageHeight or tileImageWidth has just changed
- # 2. tileImage, tileImageCount, tileImageHeight, tileImageWidth are not empty
- @llm_by_value
- def gui_generateTextureDescriptions(
- c: memory_Context
- ) -> memory_Context:
- if (
- c.recentField == "tileImage" or
- c.recentField == "tileImageCount" or
- c.recentField == "tileImageHeight" or
- c.recentField == "tileImageWidth"
- ):
- tds: list[gui_TextureDescription] = []
- for id in range(0, c.tileImageCount):
- td = gui_createTextureDescription()
- td.fileName = c.tileImage
- td.height = c.tileImageHeight
- td.width = c.tileImageWidth
- td.x = id * c.tileImageWidth
- td.y = 0
- tds.append(td)
- #}
- c.textureDescriptions = tds
- c.recentField = "textureDescriptions"
- return c
- #}
-
- c.recentField = "none"
- return c
- #}
-
- # Generate tile positions
- #
- # Conditions:
- # 1. cellSize, playField, windowHeight, or windowWidth has changed and none of them is zero
- @llm_by_value
- def gui_generateTilePositions(
- c: memory_Context
- ) -> memory_Context:
- if (
- (
- c.recentField != "cellPositions" and
- c.recentField != "cellSize" and
- c.recentField != "playfieldSize" and
- c.recentField != "windowHeight" and
- c.recentField != "windowWidth"
- ) or
- (
- len(c.cellPositions) == 0 or
- c.cellSize == 0 or
- c.playfieldSize == 0 or
- c.windowHeight == 0 or
- c.windowWidth == 0
- )
- ):
- c.recentField = "none"
- return c
- #}
-
- ps = []
- for i in range(0, len(c.cellPositions)):
- p = gui_aux_cellScreenPosition(c, c.cellPositions[i])
- ps.append(p)
- #}
-
- c.tilePositions = ps
- c.recentField = "tilePositions"
- return c
- #}
|