|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- from gui_aux import *
- from gui_TextureDescription import *
- from llm import *
- from memory_Context import *
-
- # Generate texture descriptions for tiles
- #
- # Conditions:
- # 1. tileImage or tileImageCount or tileImageHeight or tileImageWidth has just changed
- @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
- #}
-
- # Generate texture descriptions for tiTLes
- #
- # Conditions:
- # 1. titleImage, titleImageCount, titleImageHeight, or titleImageWidth has just changed
- @llm_by_value
- def gui_generateTitleTextureDescriptions(
- c: memory_Context
- ) -> memory_Context:
- if (
- c.recentField == "titleImage" or
- c.recentField == "titleImageCount" or
- c.recentField == "titleImageHeight" or
- c.recentField == "titleImageWidth"
- ):
- tds: list[gui_TextureDescription] = []
- for id in range(0, c.titleImageCount):
- td = gui_createTextureDescription()
- td.fileName = c.titleImage
- td.height = c.titleImageHeight
- td.width = c.titleImageWidth
- td.x = id * c.titleImageWidth
- td.y = 0
- tds.append(td)
- #}
- c.titleTextureDescriptions = tds
- c.recentField = "titleTextureDescriptions"
- return c
- #}
-
- c.recentField = "none"
- return c
- #}
|