@@ -2,6 +2,18 @@ import arcade | |||||
from gui_aux import * | from gui_aux import * | ||||
from desktop_Platform import * | from desktop_Platform import * | ||||
def desktop_createDesc(p): | |||||
p.desc = arcade.Sprite() | |||||
p.descSprites.append(p.desc) | |||||
p.desc.texture = p.descTextures[0] | |||||
# Position. | |||||
pos = gui_aux_cellScreenPosition(p.c, p.c.descPosition) | |||||
p.desc.left = pos[0] | |||||
p.desc.top = pos[1] | |||||
# Invisible by default. | |||||
p.desc.visible = False | |||||
#} | |||||
def desktop_createDeselectedTiles(p): | def desktop_createDeselectedTiles(p): | ||||
for (id, pos) in enumerate(p.c.tilePositions): | for (id, pos) in enumerate(p.c.tilePositions): | ||||
tile = arcade.AnimatedTimeBasedSprite() | tile = arcade.AnimatedTimeBasedSprite() | ||||
@@ -124,6 +136,22 @@ def desktop_hideTitle(p): | |||||
#} | #} | ||||
#} | #} | ||||
# Load description textures | |||||
def desktop_loadDescTextures(p): | |||||
texs = [] | |||||
for (id, td) in enumerate(p.c.descTextureDescriptions): | |||||
tex = arcade.load_texture( | |||||
td.fileName, | |||||
x = td.x, | |||||
y = td.y, | |||||
width = td.width, | |||||
height = td.height | |||||
) | |||||
texs.append(tex) | |||||
#} | |||||
p.descTextures = texs | |||||
#} | |||||
# Load tile textures | # Load tile textures | ||||
def desktop_loadTextures(p): | def desktop_loadTextures(p): | ||||
texs = [] | texs = [] | ||||
@@ -4,6 +4,9 @@ class desktop_Platform: | |||||
def __init__(self): | def __init__(self): | ||||
self.c = None | self.c = None | ||||
self.ctrl = None | self.ctrl = None | ||||
self.desc = None | |||||
self.descSprites = arcade.SpriteList() | |||||
self.descTextures = [] | |||||
self.deselectedSprites = arcade.SpriteList() | self.deselectedSprites = arcade.SpriteList() | ||||
self.deselectedTiles = [] | self.deselectedTiles = [] | ||||
self.mousePosition = [] | self.mousePosition = [] | ||||
@@ -14,6 +14,7 @@ class desktop_Window(arcade.Window): | |||||
def on_draw(self): | def on_draw(self): | ||||
arcade.start_render() | arcade.start_render() | ||||
self.p.descSprites.draw() | |||||
self.p.deselectedSprites.draw() | self.p.deselectedSprites.draw() | ||||
self.p.selectedSprites.draw() | self.p.selectedSprites.draw() | ||||
self.p.titleSprites.draw() | self.p.titleSprites.draw() | ||||
@@ -3,6 +3,39 @@ from gui_TextureDescription import * | |||||
from llm import * | from llm import * | ||||
from memory_Context import * | from memory_Context import * | ||||
# Generate texture descriptions for harm description | |||||
# | |||||
# Conditions: | |||||
# 1.descImage, descImageCount, descImageHeight, or descImageWidth has just changed | |||||
@llm_by_value | |||||
def gui_generateDescTextureDescriptions( | |||||
c: memory_Context | |||||
) -> memory_Context: | |||||
if ( | |||||
c.recentField == "descImage" or | |||||
c.recentField == "descImageCount" or | |||||
c.recentField == "descImageHeight" or | |||||
c.recentField == "descImageWidth" | |||||
): | |||||
tds: list[gui_TextureDescription] = [] | |||||
for id in range(0, c.descImageCount): | |||||
td = gui_createTextureDescription() | |||||
td.fileName = c.descImage | |||||
td.height = c.descImageHeight | |||||
td.width = c.descImageWidth | |||||
td.x = id * c.descImageWidth | |||||
td.y = 0 | |||||
tds.append(td) | |||||
#} | |||||
c.descTextureDescriptions = tds | |||||
c.recentField = "descTextureDescriptions" | |||||
return c | |||||
#} | |||||
c.recentField = "none" | |||||
return c | |||||
#} | |||||
# Generate texture descriptions for tiles | # Generate texture descriptions for tiles | ||||
# | # | ||||
# Conditions: | # Conditions: | ||||
@@ -67,6 +67,7 @@ ctrl.registerFunctions([ | |||||
# cli_reportVictory, | # cli_reportVictory, | ||||
# cli_selectItem, | # cli_selectItem, | ||||
# cli_showHelp, | # cli_showHelp, | ||||
gui_generateDescTextureDescriptions, | |||||
gui_generateTextureDescriptions, | gui_generateTextureDescriptions, | ||||
gui_generateTilePositions, | gui_generateTilePositions, | ||||
gui_generateTitleTextureDescriptions, | gui_generateTitleTextureDescriptions, | ||||
@@ -79,7 +80,7 @@ ctrl.registerFunctions([ | |||||
def printDbg(c): | def printDbg(c): | ||||
print(f"Dbg key/value: '{c.recentField}'/'{c.field(c.recentField)}'") | print(f"Dbg key/value: '{c.recentField}'/'{c.field(c.recentField)}'") | ||||
ctrl.registerCallback(printDbg) | |||||
#ctrl.registerCallback(printDbg) | |||||
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0)) | ctrl.registerFieldCallback("exit", lambda c: sys.exit(0)) | ||||
p = desktop_Platform() | p = desktop_Platform() | ||||
@@ -108,6 +109,11 @@ ctrl.set("playfieldSize", 6) | |||||
ctrl.set("cellPositions", gui_aux_cellHarmPositions()) | ctrl.set("cellPositions", gui_aux_cellHarmPositions()) | ||||
ctrl.set("cellSize", 25) | ctrl.set("cellSize", 25) | ||||
ctrl.set("deselectMismatchedTilesDelay", 500) | ctrl.set("deselectMismatchedTilesDelay", 500) | ||||
ctrl.set("descImage", "res/harm.png") | |||||
ctrl.set("descImageCount", 6) | |||||
ctrl.set("descImageHeight", 250) | |||||
ctrl.set("descImageWidth", 375) | |||||
ctrl.set("descPosition", [19, 12]) | |||||
ctrl.set("hideMatchingTilesDelay", 500) | ctrl.set("hideMatchingTilesDelay", 500) | ||||
ctrl.set("tileImage", "res/harmful-tiles.png") | ctrl.set("tileImage", "res/harmful-tiles.png") | ||||
ctrl.set("tileImageCount", 8) | ctrl.set("tileImageCount", 8) | ||||
@@ -131,5 +137,8 @@ desktop_createSelectedTiles(p) | |||||
desktop_loadTitleTextures(p) | desktop_loadTitleTextures(p) | ||||
desktop_createTitle(p) | desktop_createTitle(p) | ||||
desktop_loadDescTextures(p) | |||||
desktop_createDesc(p) | |||||
wnd = desktop_Window(p) | wnd = desktop_Window(p) | ||||
arcade.run() | arcade.run() |
@@ -2,6 +2,12 @@ class memory_Context: | |||||
def __init__(self): | def __init__(self): | ||||
self.cellPositions = [] | self.cellPositions = [] | ||||
self.cellSize = 0 | self.cellSize = 0 | ||||
self.descImage = "" | |||||
self.descImageCount = 0 | |||||
self.descImageHeight = 0 | |||||
self.descImageWidth = 0 | |||||
self.descPosition = [] | |||||
self.descTextureDescriptions = [] | |||||
self.deselectMismatchedTiles = False | self.deselectMismatchedTiles = False | ||||
self.deselectMismatchedTilesDelay = 0 | self.deselectMismatchedTilesDelay = 0 | ||||
self.didLaunch = False | self.didLaunch = False | ||||