Михаил Капелько pirms 4 mēnešiem
vecāks
revīzija
03578f5b6d
6 mainītis faili ar 81 papildinājumiem un 1 dzēšanām
  1. +28
    -0
      v5/desktop.py
  2. +3
    -0
      v5/desktop_Platform.py
  3. +1
    -0
      v5/desktop_Window.py
  4. +33
    -0
      v5/gui.py
  5. +10
    -1
      v5/main-gui.py
  6. +6
    -0
      v5/memory_Context.py

+ 28
- 0
v5/desktop.py Parādīt failu

@@ -2,6 +2,18 @@ import arcade
from gui_aux 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):
for (id, pos) in enumerate(p.c.tilePositions):
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
def desktop_loadTextures(p):
texs = []


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

@@ -4,6 +4,9 @@ class desktop_Platform:
def __init__(self):
self.c = None
self.ctrl = None
self.desc = None
self.descSprites = arcade.SpriteList()
self.descTextures = []
self.deselectedSprites = arcade.SpriteList()
self.deselectedTiles = []
self.mousePosition = []


+ 1
- 0
v5/desktop_Window.py Parādīt failu

@@ -14,6 +14,7 @@ class desktop_Window(arcade.Window):

def on_draw(self):
arcade.start_render()
self.p.descSprites.draw()
self.p.deselectedSprites.draw()
self.p.selectedSprites.draw()
self.p.titleSprites.draw()


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

@@ -3,6 +3,39 @@ from gui_TextureDescription import *
from llm 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
#
# Conditions:


+ 10
- 1
v5/main-gui.py Parādīt failu

@@ -67,6 +67,7 @@ ctrl.registerFunctions([
# cli_reportVictory,
# cli_selectItem,
# cli_showHelp,
gui_generateDescTextureDescriptions,
gui_generateTextureDescriptions,
gui_generateTilePositions,
gui_generateTitleTextureDescriptions,
@@ -79,7 +80,7 @@ ctrl.registerFunctions([

def printDbg(c):
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))

p = desktop_Platform()
@@ -108,6 +109,11 @@ ctrl.set("playfieldSize", 6)
ctrl.set("cellPositions", gui_aux_cellHarmPositions())
ctrl.set("cellSize", 25)
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("tileImage", "res/harmful-tiles.png")
ctrl.set("tileImageCount", 8)
@@ -131,5 +137,8 @@ desktop_createSelectedTiles(p)
desktop_loadTitleTextures(p)
desktop_createTitle(p)

desktop_loadDescTextures(p)
desktop_createDesc(p)

wnd = desktop_Window(p)
arcade.run()

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

@@ -2,6 +2,12 @@ class memory_Context:
def __init__(self):
self.cellPositions = []
self.cellSize = 0
self.descImage = ""
self.descImageCount = 0
self.descImageHeight = 0
self.descImageWidth = 0
self.descPosition = []
self.descTextureDescriptions = []
self.deselectMismatchedTiles = False
self.deselectMismatchedTilesDelay = 0
self.didLaunch = False


Notiek ielāde…
Atcelt
Saglabāt