game: Traglast-Malus, Truhen, Bodenablage und weitere Tränke
This commit is contained in:
parent
01c312d918
commit
3e533e5089
23 changed files with 557 additions and 28 deletions
|
|
@ -311,7 +311,7 @@ func _details(p: Panel, figur: Dictionary) -> void:
|
|||
_aktions_knopf(box, "Benutzen", _benutzen.bind(_sel_id))
|
||||
|
||||
var geben := Button.new()
|
||||
geben.text = "Geben an"
|
||||
geben.text = "Tausch"
|
||||
geben.position = Vector2(450, 96)
|
||||
geben.size = Vector2(250, 52)
|
||||
geben.focus_mode = Control.FOCUS_NONE
|
||||
|
|
@ -422,7 +422,7 @@ func _geben_panel() -> void:
|
|||
_geben_ebene.add_child(p)
|
||||
|
||||
var kopf := Label.new()
|
||||
kopf.text = "GEBEN AN"
|
||||
kopf.text = "TAUSCH"
|
||||
kopf.position = Vector2(30, 24)
|
||||
kopf.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
p.add_child(kopf)
|
||||
|
|
@ -448,9 +448,18 @@ func _geben_panel() -> void:
|
|||
b.pressed.connect(_geben_an.bind(i))
|
||||
p.add_child(b)
|
||||
|
||||
var fallen := Button.new()
|
||||
fallen.text = "Fallen lassen"
|
||||
fallen.position = Vector2(30, 320)
|
||||
fallen.size = Vector2(350, 56)
|
||||
fallen.focus_mode = Control.FOCUS_NONE
|
||||
fallen.clip_text = true
|
||||
fallen.pressed.connect(_fallen_lassen)
|
||||
p.add_child(fallen)
|
||||
|
||||
var ab := Button.new()
|
||||
ab.text = "Abbrechen"
|
||||
ab.position = Vector2(230, 320)
|
||||
ab.position = Vector2(390, 320)
|
||||
ab.size = Vector2(240, 56)
|
||||
ab.focus_mode = Control.FOCUS_NONE
|
||||
ab.clip_text = true
|
||||
|
|
@ -468,6 +477,16 @@ func _geben_an(index: int) -> void:
|
|||
_bauen()
|
||||
|
||||
|
||||
func _fallen_lassen() -> void:
|
||||
if _sel_id.is_empty() or Game.party.is_empty():
|
||||
return
|
||||
_meldung = Game.fallen_lassen(Game.party[_index], _sel_id)
|
||||
if Game.inventar_hat(Game.party[_index], _sel_id) <= 0:
|
||||
_sel_id = ""
|
||||
_sel_quelle = ""
|
||||
_bauen()
|
||||
|
||||
|
||||
func _geben_schliessen() -> void:
|
||||
if _geben_ebene != null:
|
||||
_geben_ebene.queue_free()
|
||||
|
|
|
|||
128
game/scenes/ui/truhe.gd
Normal file
128
game/scenes/ui/truhe.gd
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
extends Control
|
||||
## Truhe als einmaliger Container (map-JSON: `containers`).
|
||||
##
|
||||
## „Alles nehmen" prüft die Traglast des Parteiführers, legt Gold und Beute
|
||||
## ab und setzt das Flag `truhe_<id>`. Ein zweites Öffnen ist leer.
|
||||
|
||||
signal geschlossen
|
||||
|
||||
const THEME := preload("res://scripts/ui/ui_theme.gd")
|
||||
|
||||
var container: Dictionary = {}
|
||||
var karte := "garana"
|
||||
|
||||
var _wurzel: Control
|
||||
var _meldung := ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
theme = THEME.baue()
|
||||
set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
_wurzel = Control.new()
|
||||
_wurzel.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
add_child(_wurzel)
|
||||
_bauen()
|
||||
|
||||
|
||||
func _bauen() -> void:
|
||||
_leeren(_wurzel)
|
||||
|
||||
var dimm := UiTheme.dimmung()
|
||||
dimm.color = Color(0.04, 0.03, 0.02, 0.72)
|
||||
_wurzel.add_child(dimm)
|
||||
|
||||
var p := Panel.new()
|
||||
p.position = Vector2(560, 260)
|
||||
p.size = Vector2(800, 560)
|
||||
p.add_theme_stylebox_override("panel", THEME.flaeche(Color(1, 1, 1)))
|
||||
_wurzel.add_child(p)
|
||||
|
||||
var titel := Label.new()
|
||||
titel.text = "TRUHE"
|
||||
titel.position = Vector2(40, 24)
|
||||
titel.add_theme_color_override("font_color", UiTheme.GOLD)
|
||||
p.add_child(titel)
|
||||
|
||||
var id := str(container.get("id", ""))
|
||||
if bool(Game.flags.get(id, false)):
|
||||
_label(p, "Leer.", Vector2(40, 120), UiTheme.CREAM_D)
|
||||
_schliessen_knopf(p)
|
||||
return
|
||||
|
||||
var gold := int(container.get("gold", 0))
|
||||
if gold > 0:
|
||||
_label(p, "Gold: %d" % gold, Vector2(40, 84), UiTheme.GOLD)
|
||||
|
||||
var loot: Array = container.get("loot", [])
|
||||
for i in loot.size():
|
||||
var eintrag: Dictionary = loot[i]
|
||||
var item_id := str(eintrag.get("id", ""))
|
||||
var y := 140 + i * 82
|
||||
var pfad := "res://assets/objects/item_%s_64.png" % item_id
|
||||
if ResourceLoader.exists(pfad):
|
||||
var icon := TextureRect.new()
|
||||
icon.texture = load(pfad)
|
||||
icon.position = Vector2(40, y)
|
||||
icon.size = Vector2(64, 64)
|
||||
icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
icon.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
|
||||
p.add_child(icon)
|
||||
_label(p, _item_name(item_id), Vector2(120, y + 12), UiTheme.CREAM)
|
||||
var anzahl := int(eintrag.get("count", 1))
|
||||
if anzahl > 1:
|
||||
_label(p, "x%d" % anzahl, Vector2(660, y + 12), UiTheme.CREAM_D)
|
||||
|
||||
if loot.is_empty() and gold == 0:
|
||||
_label(p, "Leer.", Vector2(40, 120), UiTheme.CREAM_D)
|
||||
|
||||
var nehmen := Button.new()
|
||||
nehmen.text = "Alles nehmen"
|
||||
nehmen.position = Vector2(40, 460)
|
||||
nehmen.size = Vector2(320, 56)
|
||||
nehmen.focus_mode = Control.FOCUS_NONE
|
||||
nehmen.clip_text = true
|
||||
nehmen.pressed.connect(_nehmen)
|
||||
p.add_child(nehmen)
|
||||
|
||||
_schliessen_knopf(p)
|
||||
|
||||
if not _meldung.is_empty():
|
||||
_label(p, _meldung, Vector2(40, 400), Color(0.9, 0.72, 0.45))
|
||||
|
||||
|
||||
func _nehmen() -> void:
|
||||
_meldung = Game.truhe_nehmen(container)
|
||||
_bauen()
|
||||
|
||||
|
||||
func _schliessen_knopf(p: Panel) -> void:
|
||||
var b := Button.new()
|
||||
b.text = "Schließen"
|
||||
b.position = Vector2(400, 460)
|
||||
b.size = Vector2(240, 56)
|
||||
b.focus_mode = Control.FOCUS_NONE
|
||||
b.clip_text = true
|
||||
b.pressed.connect(func() -> void: geschlossen.emit())
|
||||
p.add_child(b)
|
||||
|
||||
|
||||
func _label(p: Panel, text: String, pos: Vector2, farbe: Color) -> Label:
|
||||
var l := Label.new()
|
||||
l.text = text
|
||||
l.position = pos
|
||||
l.size = Vector2(700, 40)
|
||||
l.clip_text = true
|
||||
l.add_theme_color_override("font_color", farbe)
|
||||
p.add_child(l)
|
||||
return l
|
||||
|
||||
|
||||
func _item_name(id: String) -> String:
|
||||
return str(Content.entry("items", id).get("name", id))
|
||||
|
||||
|
||||
func _leeren(node: Node) -> void:
|
||||
for kind in node.get_children():
|
||||
node.remove_child(kind)
|
||||
kind.queue_free()
|
||||
1
game/scenes/ui/truhe.gd.uid
Normal file
1
game/scenes/ui/truhe.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://beimjkn6igm0r
|
||||
12
game/scenes/ui/truhe.tscn
Normal file
12
game/scenes/ui/truhe.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/ui/truhe.gd" id="1"]
|
||||
|
||||
[node name="Truhe" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1")
|
||||
Loading…
Add table
Add a link
Reference in a new issue