@@ -7,9 +7,9 @@ WIDTH = 900 | |||||
class Context: | class Context: | ||||
def __init__(self): | def __init__(self): | ||||
self.images = [ | self.images = [ | ||||
["res/tiles_0.png", 0, 0, 75, 100], | |||||
["res/tiles_0.png", 75, 0, 75, 100], | |||||
["res/tiles_1.png", 0, 0, 75, 100], | |||||
["res/tiles.png", 0, 0, 75, 100], | |||||
["res/tiles.png", 75, 0, 75, 100], | |||||
["res/tiles.png", 150, 0, 75, 100], | |||||
] | ] | ||||
self.positions = [ | self.positions = [ | ||||
@@ -0,0 +1,37 @@ | |||||
from memory_Context import * | |||||
from gui_TextureDescription import * | |||||
from llm 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 | |||||
#} |
@@ -0,0 +1,15 @@ | |||||
class gui_TextureDescription: | |||||
def __init__(self): | |||||
self.fileName = "" | |||||
self.height = 0 | |||||
self.width = 0 | |||||
self.x = 0 | |||||
self.y = 0 | |||||
def __repr__(self): | |||||
return self.__str__() | |||||
def __str__(self): | |||||
return f"gui_TextureD(fileN/height/width/x/y: '{self.fileName}'/'{self.height}'/'{self.width}'/'{self.x}'/'{self.y}')" | |||||
def gui_createTextureDescription(): | |||||
return gui_TextureDescription() |
@@ -0,0 +1,27 @@ | |||||
from gui import * | |||||
from gui_TextureDescription import * | |||||
from memory_Context import * | |||||
def test_gui_generateTextureDescriptions( | |||||
) -> str: | |||||
c = memory_createContext() | |||||
c.tileImage = "res/img.png" | |||||
c.tileImageCount = 3 | |||||
c.tileImageHeight = 35 | |||||
c.tileImageWidth = 20 | |||||
c.recentField = "tileImageWidth" | |||||
c = gui_generateTextureDescriptions(c) | |||||
if ( | |||||
c.recentField == "textureDescriptions" and | |||||
len(c.textureDescriptions) == 3 and | |||||
c.textureDescriptions[0].fileName == "res/img.png" and | |||||
c.textureDescriptions[0].height == 35 and | |||||
c.textureDescriptions[0].width == 20 and | |||||
c.textureDescriptions[0].x == 0 and | |||||
c.textureDescriptions[1].x == 20 and | |||||
c.textureDescriptions[2].x == 40 | |||||
): | |||||
return "OK: gui_generateTextureDescriptions" | |||||
#} | |||||
return "ERR: gui_generateTextureDescriptions" | |||||
#} |
@@ -3,8 +3,8 @@ from cli import * | |||||
from cli_test import * | from cli_test import * | ||||
from ctx import * | from ctx import * | ||||
from ctx_test2 import * | from ctx_test2 import * | ||||
#from ctx_test import * | |||||
#from ctx_test_Python import * | |||||
from gui import * | |||||
from gui_test import * | |||||
from llm_test import * | from llm_test import * | ||||
from llm_test_Python import * | from llm_test_Python import * | ||||
from memory_test import * | from memory_test import * | ||||
@@ -47,6 +47,8 @@ print(cli_test_reportMatchedItems()) | |||||
print(cli_test_reportMismatchedItems()) | print(cli_test_reportMismatchedItems()) | ||||
print(cli_test_reportVictory()) | print(cli_test_reportVictory()) | ||||
print(test_gui_generateTextureDescriptions()) | |||||
ctrl = ctx_Controller(memory_createContext()) | ctrl = ctx_Controller(memory_createContext()) | ||||
ctrl.registerFunctions([ | ctrl.registerFunctions([ | ||||
# cli_exit, | # cli_exit, | ||||
@@ -58,6 +60,7 @@ ctrl.registerFunctions([ | |||||
# cli_reportVictory, | # cli_reportVictory, | ||||
# cli_selectItem, | # cli_selectItem, | ||||
# cli_showHelp, | # cli_showHelp, | ||||
gui_generateTextureDescriptions, | |||||
memory_detectMismatchedItems, | memory_detectMismatchedItems, | ||||
memory_detectVictory, | memory_detectVictory, | ||||
memory_generateConstPlayfield, | memory_generateConstPlayfield, | ||||
@@ -73,6 +76,10 @@ ctrl.registerFieldCallback("exit", lambda c: sys.exit(0)) | |||||
ctrl.set("didLaunch", True) | ctrl.set("didLaunch", True) | ||||
ctrl.set("playfieldSize", 2) | ctrl.set("playfieldSize", 2) | ||||
ctrl.set("tileImage", "res/tiles.png") | |||||
ctrl.set("tileImageCount", 3) | |||||
ctrl.set("tileImageHeight", 100) | |||||
ctrl.set("tileImageWidth", 75) | |||||
wnd = Window() | wnd = Window() | ||||
arcade.run() | arcade.run() |
@@ -17,6 +17,11 @@ class memory_Context: | |||||
self.recentField = "none" | self.recentField = "none" | ||||
self.selectedId = -1 | self.selectedId = -1 | ||||
self.selectedItems = [] | self.selectedItems = [] | ||||
self.textureDescriptions = [] | |||||
self.tileImage = "" | |||||
self.tileImageCount = 0 | |||||
self.tileImageHeight = 0 | |||||
self.tileImageWidth = 0 | |||||
self.victory = False | self.victory = False | ||||
def field(self, fieldName): | def field(self, fieldName): | ||||