|
- 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 != "cellSize" and
- c.recentField != "playfieldSize" and
- c.recentField != "windowHeight" and
- c.recentField != "windowWidth"
- ) or
- (
- c.cellSize == 0 or
- c.playfieldSize == 0 or
- c.windowHeight == 0 or
- c.windowWidth == 0
- )
- ):
- c.recentField = "none"
- return c
- #}
-
- # Assume window size is an integer multiple of cell size.
- widthInCells = c.windowWidth / c.cellSize
- heightInCells = c.windowHeight / c.cellSize
- positions = gui_aux_cellPositions(c.playfieldSize)
-
- poss = []
- for i in range(0, len(positions)):
- p = positions[i]
- pos = [p[0] * c.cellSize, p[1] * c.cellSize]
- poss.append(pos)
- #}
- #tile.center_x = CELL * 2 + p[0] * CELL
- #tile.center_y = HEIGHT - CELL * 2 - p[1] * CELL
-
- c.tilePositions = poss
- c.recentField = "tilePositions"
- return c
- #}
|