Михаил Капелько pirms 6 mēnešiem
vecāks
revīzija
0299882a68
6 mainītis faili ar 96 papildinājumiem un 5 dzēšanām
  1. +3
    -3
      v5/Window.py
  2. +37
    -0
      v5/gui.py
  3. +15
    -0
      v5/gui_TextureDescription.py
  4. +27
    -0
      v5/gui_test.py
  5. +9
    -2
      v5/main-gui.py
  6. +5
    -0
      v5/memory_Context.py

+ 3
- 3
v5/Window.py Parādīt failu

@@ -7,9 +7,9 @@ WIDTH = 900
class Context:
def __init__(self):
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 = [


+ 37
- 0
v5/gui.py Parādīt failu

@@ -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
#}

+ 15
- 0
v5/gui_TextureDescription.py Parādīt failu

@@ -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()

+ 27
- 0
v5/gui_test.py Parādīt failu

@@ -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"
#}

+ 9
- 2
v5/main-gui.py Parādīt failu

@@ -3,8 +3,8 @@ from cli import *
from cli_test import *
from ctx 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_Python import *
from memory_test import *
@@ -47,6 +47,8 @@ print(cli_test_reportMatchedItems())
print(cli_test_reportMismatchedItems())
print(cli_test_reportVictory())

print(test_gui_generateTextureDescriptions())

ctrl = ctx_Controller(memory_createContext())
ctrl.registerFunctions([
# cli_exit,
@@ -58,6 +60,7 @@ ctrl.registerFunctions([
# cli_reportVictory,
# cli_selectItem,
# cli_showHelp,
gui_generateTextureDescriptions,
memory_detectMismatchedItems,
memory_detectVictory,
memory_generateConstPlayfield,
@@ -73,6 +76,10 @@ ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))

ctrl.set("didLaunch", True)
ctrl.set("playfieldSize", 2)
ctrl.set("tileImage", "res/tiles.png")
ctrl.set("tileImageCount", 3)
ctrl.set("tileImageHeight", 100)
ctrl.set("tileImageWidth", 75)

wnd = Window()
arcade.run()

+ 5
- 0
v5/memory_Context.py Parādīt failu

@@ -17,6 +17,11 @@ class memory_Context:
self.recentField = "none"
self.selectedId = -1
self.selectedItems = []
self.textureDescriptions = []
self.tileImage = ""
self.tileImageCount = 0
self.tileImageHeight = 0
self.tileImageWidth = 0
self.victory = False

def field(self, fieldName):


Notiek ielāde…
Atcelt
Saglabāt