From fc9115aafc1f7e702958e29e5b00130412d72230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Mon, 1 Jul 2024 01:14:52 +0300 Subject: [PATCH] d --- v5/desktop.py | 52 ++++++++++++++++++++++++++++++++++++++++++ v5/desktop_Platform.py | 3 +++ v5/desktop_Window.py | 1 + v5/gui.py | 33 +++++++++++++++++++++++++++ v5/main-gui.py | 9 +++++++- v5/memory_Context.py | 5 ++++ 6 files changed, 102 insertions(+), 1 deletion(-) diff --git a/v5/desktop.py b/v5/desktop.py index 3106b37..69d20c1 100644 --- a/v5/desktop.py +++ b/v5/desktop.py @@ -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) + #} +#} + diff --git a/v5/desktop_Platform.py b/v5/desktop_Platform.py index 383d53a..b796232 100644 --- a/v5/desktop_Platform.py +++ b/v5/desktop_Platform.py @@ -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() diff --git a/v5/desktop_Window.py b/v5/desktop_Window.py index a150bc2..8ca4165 100644 --- a/v5/desktop_Window.py +++ b/v5/desktop_Window.py @@ -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): diff --git a/v5/gui.py b/v5/gui.py index b24661a..c5560b4 100644 --- a/v5/gui.py +++ b/v5/gui.py @@ -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: diff --git a/v5/main-gui.py b/v5/main-gui.py index 06b303a..4f1375e 100644 --- a/v5/main-gui.py +++ b/v5/main-gui.py @@ -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) diff --git a/v5/memory_Context.py b/v5/memory_Context.py index 39d9978..0ad9db5 100644 --- a/v5/memory_Context.py +++ b/v5/memory_Context.py @@ -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