Михаил Капелько 4 months ago
parent
commit
fc9115aafc
6 changed files with 102 additions and 1 deletions
  1. +52
    -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. +8
    -1
      v5/main-gui.py
  6. +5
    -0
      v5/memory_Context.py

+ 52
- 0
v5/desktop.py View File

@@ -49,6 +49,16 @@ def desktop_createSelectedTiles(p):
#}
#}

def desktop_createSplash(p):
p.splash = arcade.Sprite()
p.splashSprites.append(p.splash)
p.splash.texture = p.splashTextures[0]
# Position.
pos = gui_aux_cellScreenPosition(p.c, [0, 0])
p.splash.left = pos[0]
p.splash.top = pos[1]
#}

def desktop_createTitle(p):
p.title = arcade.Sprite()
p.titleSprites.append(p.title)
@@ -126,6 +136,18 @@ def desktop_displayTitle(p):
#}
#}

# Hide beginning splash screen
#
# Conditions:
# 1. Time to hide
def desktop_hideBeginningSplashScreen(p):
if (
p.c.recentField == "hideBeginningSplashScreen"
):
p.splash.visible = False
#}
#}

# Hide description
#
# Conditions:
@@ -183,6 +205,23 @@ def desktop_loadDescTextures(p):
p.descTextures = texs
#}

# Load beginning and ending textures
def desktop_loadSplashTextures(p):
texs = []
for (id, td) in enumerate(p.c.splashTextureDescriptions):
tex = arcade.load_texture(
td.fileName,
x = td.x,
y = td.y,
width = td.width,
height = td.height
)
texs.append(tex)
print(f"desktop_loadST: '{tex}'")
#}
p.splashTextures = texs
#}

# Load tile textures
def desktop_loadTextures(p):
texs = []
@@ -238,3 +277,16 @@ def desktop_scheduleHidingOfMatchingTiles(p):
p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
#}
#}

# Postpone hiding of the beginning splash screen
#
# Conditions:
# 1. just launched the game
def desktop_scheduleHidingOfBeginningSplashScreen(p):
if (
p.c.recentField == "didLaunch"
):
p.sequentialTimer.schedule("hideBeginningSplashScreen", True, p.c.splashBeginTimeout)
#}
#}


+ 3
- 0
v5/desktop_Platform.py View File

@@ -13,6 +13,9 @@ class desktop_Platform:
self.selectedTiles = []
self.sequentialTimer = None
self.selectedSprites = arcade.SpriteList()
self.splash = None
self.splashSprites = arcade.SpriteList()
self.splashTextures = []
self.textures = []
self.title = None
self.titleSprites = arcade.SpriteList()


+ 1
- 0
v5/desktop_Window.py View File

@@ -17,6 +17,7 @@ class desktop_Window(arcade.Window):
self.p.descSprites.draw()
self.p.deselectedSprites.draw()
self.p.selectedSprites.draw()
self.p.splashSprites.draw()
self.p.titleSprites.draw()

def on_mouse_press(self, x, y, button, key_modifiers):


+ 33
- 0
v5/gui.py View File

@@ -36,6 +36,39 @@ def gui_generateDescTextureDescriptions(
return c
#}

# Generate texture descriptions for splash screens
#
# Conditions:
# 1.splashImage, splashImageCount, splashImageHeight, or splashImageWidth has just changed
@llm_by_value
def gui_generateSplashTextureDescriptions(
c: memory_Context
) -> memory_Context:
if (
c.recentField == "splashImage" or
c.recentField == "splashImageCount" or
c.recentField == "splashImageHeight" or
c.recentField == "splashImageWidth"
):
tds: list[gui_TextureDescription] = []
for id in range(0, c.splashImageCount):
td = gui_createTextureDescription()
td.fileName = c.splashImage
td.height = c.splashImageHeight
td.width = c.splashImageWidth
td.x = id * c.splashImageWidth
td.y = 0
tds.append(td)
#}
c.splashTextureDescriptions = tds
c.recentField = "splashTextureDescriptions"
return c
#}

c.recentField = "none"
return c
#}

# Generate texture descriptions for tiles
#
# Conditions:


+ 8
- 1
v5/main-gui.py View File

@@ -68,6 +68,7 @@ ctrl.registerFunctions([
# cli_selectItem,
# cli_showHelp,
gui_generateDescTextureDescriptions,
gui_generateSplashTextureDescriptions,
gui_generateTextureDescriptions,
gui_generateTilePositions,
gui_generateTitleTextureDescriptions,
@@ -80,7 +81,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()
@@ -98,9 +99,11 @@ def process(c):
desktop_displayDesc(p)
desktop_displaySelectedTile(p)
desktop_displayTitle(p)
desktop_hideBeginningSplashScreen(p)
desktop_hideDesc(p)
desktop_hideMatchingTiles(p)
desktop_hideTitle(p)
desktop_scheduleHidingOfBeginningSplashScreen(p)
desktop_scheduleHidingOfMatchingTiles(p)
desktop_scheduleDeselectionOfMismatchedTiles(p)
ctrl.registerCallback(process)
@@ -117,6 +120,10 @@ ctrl.set("descImageHeight", 250)
ctrl.set("descImageWidth", 375)
ctrl.set("descPosition", [19, 12])
ctrl.set("hideMatchingTilesDelay", 500)
ctrl.set("splashImage", "res/splash.png")
ctrl.set("splashImageCount", 2)
ctrl.set("splashImageHeight", 600)
ctrl.set("splashImageWidth", 900)
ctrl.set("tileImage", "res/harmful-tiles.png")
ctrl.set("tileImageCount", 8)
ctrl.set("tileImageHeight", 100)


+ 5
- 0
v5/memory_Context.py View File

@@ -29,6 +29,11 @@ class memory_Context:
self.recentField = "none"
self.selectedId = -1
self.selectedItems = []
self.splashBeginTimeout = 2000
self.splashImage = ""
self.splashImageCount = 0
self.splashImageHeight = 0
self.splashImageWidth = 0
self.textureDescriptions = []
self.tileImage = ""
self.tileImageCount = 0


Loading…
Cancel
Save