Ursprung
Commit
9a638979d5
6 geänderte Dateien mit 59 neuen und 8 gelöschten Zeilen
  1. +13
    -1
      ht.config
  2. +13
    -3
      py/cfg_aux.py
  3. +11
    -1
      py/cfg_aux_test.py
  4. +3
    -2
      py/desktop.py
  5. +18
    -1
      py/desktop_aux.py
  6. +1
    -0
      py/do-test.py

+ 13
- 1
ht.config Datei anzeigen

@@ -8,7 +8,19 @@ windowWidth = 900
[static "s-floor1"]
left = 0
texture = t-floor1
top = 100
top = 25
visible = true

[static "s-floor2"]
left = 0
texture = t-floor1
top = 225
visible = true

[static "s-floor3"]
left = 0
texture = t-floor1
top = 425
visible = true

[texture "t-floor1"]


+ 13
- 3
py/cfg_aux.py Datei anzeigen

@@ -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]



+ 11
- 1
py/cfg_aux_test.py Datei anzeigen

@@ -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"


+ 3
- 2
py/desktop.py Datei anzeigen

@@ -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)



+ 18
- 1
py/desktop_aux.py Datei anzeigen

@@ -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]


+ 1
- 0
py/do-test.py Datei anzeigen

@@ -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,


Laden…
Abbrechen
Speichern