Михаил Капелько 4ヶ月前
コミット
042f73126c
7個のファイルの変更80行の追加8行の削除
  1. +32
    -2
      v5/desktop.py
  2. +5
    -1
      v5/desktop_Platform.py
  3. +4
    -2
      v5/desktop_Window.py
  4. +1
    -1
      v5/desktop_aux.py
  5. +33
    -2
      v5/gui.py
  6. +4
    -0
      v5/main-gui.py
  7. +1
    -0
      v5/memory_Context.py

+ 32
- 2
v5/desktop.py ファイルの表示

@@ -1,11 +1,12 @@
import arcade
from gui_aux import *
from desktop_Platform import *

def desktop_createDeselectedTiles(p):
for (id, pos) in enumerate(p.c.tilePositions):
tile = arcade.AnimatedTimeBasedSprite()
p.deselectedTiles.append(tile)
p.sprites.append(tile)
p.deselectedSprites.append(tile)

tile.guid = id
tile.texture = p.textures[0]
@@ -24,7 +25,7 @@ def desktop_createSelectedTiles(p):
for (id, pos) in enumerate(p.c.tilePositions):
tile = arcade.Sprite()
p.selectedTiles.append(tile)
p.sprites.append(tile)
p.selectedSprites.append(tile)

tile.guid = id
tile.texture = p.textures[2 + p.c.playfieldItems[id]]
@@ -36,6 +37,18 @@ def desktop_createSelectedTiles(p):
#}
#}

def desktop_createTitle(p):
p.title = arcade.Sprite()
p.titleSprites.append(p.title)
p.title.texture = p.titleTextures[0]
# Position.
pos = gui_aux_cellScreenPosition(p.c, p.c.titlePosition)
p.title.left = pos[0]
p.title.top = pos[1]
# Invisible by default.
p.title.visible = False
#}

# Deselect mismatched tiles
#
# Conditions:
@@ -80,6 +93,7 @@ def desktop_hideMatchingTiles(p):
#}
#}

# Load tile textures
def desktop_loadTextures(p):
texs = []
for (id, td) in enumerate(p.c.textureDescriptions):
@@ -95,6 +109,22 @@ def desktop_loadTextures(p):
p.textures = texs
#}

# Load tiTLe textures
def desktop_loadTitleTextures(p):
texs = []
for (id, td) in enumerate(p.c.titleTextureDescriptions):
tex = arcade.load_texture(
td.fileName,
x = td.x,
y = td.y,
width = td.width,
height = td.height
)
texs.append(tex)
#}
p.titleTextures = texs
#}

# Postpone deselection of mismatched tiles for better UX
#
# Conditions:


+ 5
- 1
v5/desktop_Platform.py ファイルの表示

@@ -4,9 +4,13 @@ class desktop_Platform:
def __init__(self):
self.c = None
self.ctrl = None
self.deselectedSprites = arcade.SpriteList()
self.deselectedTiles = []
self.mousePosition = []
self.selectedTiles = []
self.sequentialTimer = None
self.sprites = arcade.SpriteList()
self.selectedSprites = arcade.SpriteList()
self.textures = []
self.title = None
self.titleSprites = arcade.SpriteList()
self.titleTextures = []

+ 4
- 2
v5/desktop_Window.py ファイルの表示

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

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

def on_mouse_press(self, x, y, button, key_modifiers):
id = desktop_aux_tileIdAt(self.p, x, y)
@@ -24,5 +26,5 @@ class desktop_Window(arcade.Window):
self.p.ctrl.set("selectedId", id)

def on_update(self, delta):
self.p.sprites.update_animation()
self.p.deselectedSprites.update_animation()
self.p.sequentialTimer.update()

+ 1
- 1
v5/desktop_aux.py ファイルの表示

@@ -2,7 +2,7 @@ import arcade

# Find a visible tile id at the specified location
def desktop_aux_tileIdAt(p, x, y):
sprites = arcade.get_sprites_at_point([x, y], p.sprites)
sprites = arcade.get_sprites_at_point([x, y], p.deselectedSprites)
if (
len(sprites) != 0 and
sprites[0].visible


+ 33
- 2
v5/gui.py ファイルの表示

@@ -3,11 +3,10 @@ from gui_TextureDescription import *
from llm import *
from memory_Context import *

# Generate textures descriptions
# Generate texture descriptions for tiles
#
# 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
@@ -76,3 +75,35 @@ def gui_generateTilePositions(
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
#}

+ 4
- 0
v5/main-gui.py ファイルの表示

@@ -69,6 +69,7 @@ ctrl.registerFunctions([
# cli_showHelp,
gui_generateTextureDescriptions,
gui_generateTilePositions,
gui_generateTitleTextureDescriptions,
memory_detectMismatchedItems,
memory_detectVictory,
memory_generateConstPlayfield,
@@ -125,5 +126,8 @@ desktop_loadTextures(p)
desktop_createDeselectedTiles(p)
desktop_createSelectedTiles(p)

desktop_loadTitleTextures(p)
desktop_createTitle(p)

wnd = desktop_Window(p)
arcade.run()

+ 1
- 0
v5/memory_Context.py ファイルの表示

@@ -34,6 +34,7 @@ class memory_Context:
self.titleImageHeight = 0
self.titleImageWidth = 0
self.titlePosition = []
self.titleTextureDescriptions = []
self.windowBackgroundColor = "#000000"
self.windowHeight = 0
self.windowTitle = ""


読み込み中…
キャンセル
保存