Loadout-Auswahl: Rotpunktvisier und andere Visiere mit deutschem Namen statt Teil-ID; Tests für Auswahl, Speichern und V18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b04a953190
commit
9589703f7c
3 changed files with 34 additions and 1 deletions
|
|
@ -13,6 +13,13 @@ const PATH := "res://library/loadout_katalog.json"
|
||||||
const MODE_FIXED := "fixed"
|
const MODE_FIXED := "fixed"
|
||||||
const MODE_PLAYER := "player"
|
const MODE_PLAYER := "player"
|
||||||
|
|
||||||
|
## Deutsche Namen der Visiere mit eigener Funktion; alles andere zeigt die Teil-ID.
|
||||||
|
const TEIL_NAMEN := {
|
||||||
|
"sight_collimator": "Rotpunktvisier",
|
||||||
|
"sight_holographic": "Holo-Visier",
|
||||||
|
"sight_offset": "Schrägvisier",
|
||||||
|
}
|
||||||
|
|
||||||
static var _data: Dictionary = {}
|
static var _data: Dictionary = {}
|
||||||
static var _loaded := false
|
static var _loaded := false
|
||||||
|
|
||||||
|
|
@ -51,6 +58,10 @@ static func anzeigename(id: String) -> String:
|
||||||
return str((_data.get(id, {}) as Dictionary).get("name", id))
|
return str((_data.get(id, {}) as Dictionary).get("name", id))
|
||||||
|
|
||||||
|
|
||||||
|
static func teil_name(part: String) -> String:
|
||||||
|
return "— nichts —" if part.is_empty() else str(TEIL_NAMEN.get(part, part))
|
||||||
|
|
||||||
|
|
||||||
## Aufsatz-Slots einer Waffe: {slot: {default, optional, options}} (leer = keine).
|
## Aufsatz-Slots einer Waffe: {slot: {default, optional, options}} (leer = keine).
|
||||||
static func slots(id: String) -> Dictionary:
|
static func slots(id: String) -> Dictionary:
|
||||||
_ensure()
|
_ensure()
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ func _rebuild_attachments(prim: String, sec: String, att: Dictionary) -> void:
|
||||||
parts.append("")
|
parts.append("")
|
||||||
parts.append_array(sd.get("options", []))
|
parts.append_array(sd.get("options", []))
|
||||||
for p in parts:
|
for p in parts:
|
||||||
ob.add_item("— nichts —" if str(p) == "" else str(p))
|
ob.add_item(LoadoutKatalog.teil_name(str(p)))
|
||||||
ob.select(maxi(0, parts.find(sel.get(s, ""))))
|
ob.select(maxi(0, parts.find(sel.get(s, ""))))
|
||||||
ob.item_selected.connect(func(i: int) -> void:
|
ob.item_selected.connect(func(i: int) -> void:
|
||||||
if not _loading:
|
if not _loading:
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,16 @@ func _test_katalog() -> void:
|
||||||
var wire := LoadoutKatalog.encode("sr1", sel)
|
var wire := LoadoutKatalog.encode("sr1", sel)
|
||||||
_check(wire == "muzzle=muzzle_suppressor_01", "encode nur Abweichungen: " + wire)
|
_check(wire == "muzzle=muzzle_suppressor_01", "encode nur Abweichungen: " + wire)
|
||||||
_check(LoadoutKatalog.pruefe_aufsaetze("sr1", wire) == "", "encodierter Text gültig")
|
_check(LoadoutKatalog.pruefe_aufsaetze("sr1", wire) == "", "encodierter Text gültig")
|
||||||
|
# Rotpunktvisier statt Zielfernrohr: wählbar, gültig, deutscher Name
|
||||||
|
var rot := LoadoutKatalog.auswahl("sr1", "")
|
||||||
|
rot["sight"] = "sight_collimator"
|
||||||
|
var rot_wire := LoadoutKatalog.encode("sr1", rot)
|
||||||
|
_check(rot_wire == "sight=sight_collimator", "Rotpunkt-Draht: " + rot_wire)
|
||||||
|
_check(LoadoutKatalog.validate({"mode": "fixed", "primary": "sr1", "secondary": "",
|
||||||
|
"attachments": {"sr1": rot_wire}}).is_empty(), "Rotpunkt im festen Loadout gültig")
|
||||||
|
_check(LoadoutKatalog.auswahl("sr1", rot_wire)["sight"] == "sight_collimator", "Rotpunkt Rundlauf")
|
||||||
|
_check(LoadoutKatalog.teil_name("sight_collimator") == "Rotpunktvisier", "Rotpunkt-Name deutsch")
|
||||||
|
_check(LoadoutKatalog.teil_name("") == "— nichts —", "leerer Slot benannt")
|
||||||
|
|
||||||
|
|
||||||
func _test_panel() -> void:
|
func _test_panel() -> void:
|
||||||
|
|
@ -80,6 +90,18 @@ func _test_panel() -> void:
|
||||||
panel.set_part("ar1", "muzzle", "muzzle_suppressor_01")
|
panel.set_part("ar1", "muzzle", "muzzle_suppressor_01")
|
||||||
_check(not main.doc["loadout"]["attachments"].has("ar1"), "Aufsatz für Nicht-Loadout-Waffe ignoriert")
|
_check(not main.doc["loadout"]["attachments"].has("ar1"), "Aufsatz für Nicht-Loadout-Waffe ignoriert")
|
||||||
_check(SvmapIO.validate_map(_signed(main.doc)).is_empty(), "Map mit Loadout besteht V1–V18")
|
_check(SvmapIO.validate_map(_signed(main.doc)).is_empty(), "Map mit Loadout besteht V1–V18")
|
||||||
|
# Rotpunktvisier: in der Auswahl deutsch benannt, wird gespeichert, besteht die Prüfung
|
||||||
|
var visier := panel.attach_box.find_child("Teil_sr1_sight", true, false) as OptionButton
|
||||||
|
var eintraege: Array[String] = []
|
||||||
|
if visier != null:
|
||||||
|
for i in visier.item_count:
|
||||||
|
eintraege.append(visier.get_item_text(i))
|
||||||
|
_check(eintraege.has("Rotpunktvisier"), "Rotpunktvisier in der Visier-Auswahl")
|
||||||
|
panel.set_part("sr1", "sight", "sight_collimator")
|
||||||
|
_check(main.doc["loadout"]["attachments"]["sr1"] == "muzzle=muzzle_suppressor_01;sight=sight_collimator", "Rotpunkt gespeichert")
|
||||||
|
_check(SvmapIO.validate_map(_signed(main.doc)).is_empty(), "Map mit Rotpunkt besteht V1–V18")
|
||||||
|
main.history.undo()
|
||||||
|
main.call("_refresh_all")
|
||||||
|
|
||||||
panel.set_weapons("ar1", "")
|
panel.set_weapons("ar1", "")
|
||||||
_check(not main.doc["loadout"]["attachments"].has("sr1"), "Waffenwechsel verwirft Aufsätze der alten Waffe")
|
_check(not main.doc["loadout"]["attachments"].has("sr1"), "Waffenwechsel verwirft Aufsätze der alten Waffe")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue