From a91bc3fffd41d13990eefa161cddd95040eb89fe 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: Sun, 14 Jul 2024 14:59:42 +0300 Subject: [PATCH] d --- main.py | 1 + py/desktop.py | 22 ++++++++++++++++++++++ py/desktop_Platform.py | 1 + py/ht_Context.py | 2 ++ 4 files changed, 26 insertions(+) diff --git a/main.py b/main.py index cbc188e..a4c0a11 100644 --- a/main.py +++ b/main.py @@ -44,6 +44,7 @@ def process(c): # Perform context dependent calls of desktop functions. # Similar to context functions, but no platform is returned. desktop_applyConfigInit(p) + desktop_createConfigStaticSprites(p) desktop_loadConfigTextures(p) ctrl.registerCallback(process) diff --git a/py/desktop.py b/py/desktop.py index 8fd8eb4..a51f459 100644 --- a/py/desktop.py +++ b/py/desktop.py @@ -18,6 +18,26 @@ def desktop_applyConfigInit(p): value = desktop_aux_convertValue(val) p.ctrl.set(key, value) +# Create static sprites +# +# Conditions: +# 1. Config textures has just been loaded +def desktop_createConfigStaticSprites(p): + if ( + p.c.recentField != "didLoadConfigTextures" + ): + return + + for key in p.c.cfgTree: + if ( + cld_startswith(key, "static ") + ): + name = cfg_aux_spriteName(key) + sprite = desktop_aux_createSprite(p.c.cfgTree[key]) + p.statics[name] = sprite + # Report finish. + p.ctrl.set("didCreateConfigStaticSprites", True) + # Load textures # # Conditions: @@ -35,3 +55,5 @@ def desktop_loadConfigTextures(p): name = cfg_aux_textureName(key) tex = desktop_aux_loadTexture(p.c.cfgDir, p.c.cfgTree[key]) p.textures[name] = tex + # Report finish. + p.ctrl.set("didLoadConfigTextures", True) diff --git a/py/desktop_Platform.py b/py/desktop_Platform.py index ce6ba95..1f31eb2 100644 --- a/py/desktop_Platform.py +++ b/py/desktop_Platform.py @@ -4,5 +4,6 @@ class desktop_Platform: def __init__(self): self.c = None self.ctrl = None + self.statics = {} self.staticSprites = arcade.SpriteList() self.textures = {} diff --git a/py/ht_Context.py b/py/ht_Context.py index ac3db58..fd4f700 100644 --- a/py/ht_Context.py +++ b/py/ht_Context.py @@ -4,7 +4,9 @@ class ht_Context: self.cfgDir = None self.cfgPath = None self.cfgTree = {} + self.didCreateConfigStaticSprites = False self.didLaunch = False + self.didLoadConfigTextures = False self.recentField = "none" self.windowAntialiasing = False self.windowBackgroundColor = "#000000"