d
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
from cld import *
|
||||
|
||||
# Extract static sprite name from config section
|
||||
def cfg_aux_staticSpriteName(
|
||||
sectionName: str
|
||||
) -> str:
|
||||
prefix = f"static \""
|
||||
postfix = f"\""
|
||||
start = cld_len(prefix)
|
||||
end = cld_len(postfix)
|
||||
return sectionName[start:-end]
|
||||
|
||||
# Extract texture name from config section
|
||||
def cfg_aux_textureName(
|
||||
sectionName: str
|
||||
) -> str:
|
||||
prefix = "texture \""
|
||||
postfix = "\""
|
||||
start = cld_len(prefix) + 1
|
||||
prefix = f"texture \""
|
||||
postfix = f"\""
|
||||
start = cld_len(prefix)
|
||||
end = cld_len(postfix)
|
||||
return sectionName[start:-end]
|
||||
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
from cfg_aux import *
|
||||
|
||||
def test_cfg_aux_staticSpriteName(
|
||||
) -> str:
|
||||
section = f"static \"s-floor1\""
|
||||
name = cfg_aux_staticSpriteName(section)
|
||||
if (
|
||||
name == "s-floor1"
|
||||
):
|
||||
return "OK: cfg_aux_staticSpriteName"
|
||||
return "ERR: cfg_aux_staticSpriteName"
|
||||
|
||||
def test_cfg_aux_textureName(
|
||||
) -> str:
|
||||
section = "textures \"t-floor1\""
|
||||
section = f"texture \"t-floor1\""
|
||||
tex = cfg_aux_textureName(section)
|
||||
if (
|
||||
tex == "t-floor1"
|
||||
|
||||
@@ -32,9 +32,10 @@ def desktop_createConfigStaticSprites(p):
|
||||
if (
|
||||
cld_startswith(key, "static ")
|
||||
):
|
||||
name = cfg_aux_spriteName(key)
|
||||
sprite = desktop_aux_createSprite(p.c.cfgTree[key])
|
||||
name = cfg_aux_staticSpriteName(key)
|
||||
sprite = desktop_aux_createStaticSprite(p, name, p.c.cfgTree[key])
|
||||
p.statics[name] = sprite
|
||||
p.staticSprites.append(sprite)
|
||||
# Report finish.
|
||||
p.ctrl.set("didCreateConfigStaticSprites", True)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import arcade
|
||||
from cld import *
|
||||
from desktop_Platform import *
|
||||
|
||||
# Convert String config value to Bool or Float if possible
|
||||
def desktop_aux_convertValue(
|
||||
@@ -22,7 +23,23 @@ def desktop_aux_convertValue(
|
||||
# String.
|
||||
return value
|
||||
|
||||
# Load texture
|
||||
def desktop_aux_createStaticSprite(
|
||||
p: desktop_Platform,
|
||||
name: str,
|
||||
desc: dict[str, str]
|
||||
):
|
||||
sp = arcade.Sprite()
|
||||
sp.guid = name
|
||||
texName = desc["texture"]
|
||||
sp.texture = p.textures[texName]
|
||||
# Position.
|
||||
sp.left = float(desc["left"])
|
||||
sp.top = float(desc["top"])
|
||||
# Visibility.
|
||||
sp.visible = True if desc["visible"] == "true" else False
|
||||
|
||||
return sp
|
||||
|
||||
def desktop_aux_loadTexture(
|
||||
resDir: str,
|
||||
desc: dict[str, str]
|
||||
|
||||
@@ -11,6 +11,7 @@ from cfg_test import *
|
||||
|
||||
functions = [
|
||||
test_cfg_parseConfigTree,
|
||||
test_cfg_aux_staticSpriteName,
|
||||
test_cfg_aux_textureName,
|
||||
test_cfg_aux_tree,
|
||||
test_cfg_aux_treeCreateSection,
|
||||
|
||||
Reference in New Issue
Block a user