diff --git a/scripts/Main.gd b/scripts/Main.gd index 39ede88..7989ec4 100644 --- a/scripts/Main.gd +++ b/scripts/Main.gd @@ -617,6 +617,90 @@ func _create_ui() -> void: func _make_hud() -> void: score_label = _label(Vector2(16, 12), "Score: 0", 30) wave_label = _label(Vector2(16, 50), "Wave: 1", 30) + _make_recipe_panel() + +func _make_recipe_panel() -> void: + const INGREDIENT_NAMES := { + "rock": "Rock", + "stick": "Stick", + "leather": "Leather", + "iron": "Iron", + "metal_plate":"Iron Plate", + } + const RESULT_NAMES := { + "LeatherBoots": "Leather Boots", + "Boulder": "Boulder", + "StickArmor": "Stick Armor", + "LeatherArmor": "Leather Armor", + "PlateArmor": "Plate Armor", + "WoodenShield": "Wooden Shield", + "IronShield": "Iron Shield", + "MetalArmor": "Metal Armor", + } + + const PAD_H := 10 + const PAD_V := 8 + const SEP := 4 + const TITLE_H := 22 + const ROW_H := 20 + var n := MergeRecipes._list.size() + var content_h := TITLE_H + SEP + n * ROW_H + (n - 1) * SEP + var panel_h := content_h + PAD_V * 2 + 10 + const PANEL_W := 260 + + var panel := Panel.new() + var sb := StyleBoxFlat.new() + sb.bg_color = Color(0.0, 0.0, 0.0, 0.55) + sb.corner_radius_top_left = 6 + sb.corner_radius_top_right = 6 + sb.corner_radius_bottom_left = 6 + sb.corner_radius_bottom_right = 6 + panel.add_theme_stylebox_override("panel", sb) + panel.anchor_left = 1.0 + panel.anchor_right = 1.0 + panel.anchor_top = 0.0 + panel.anchor_bottom = 0.0 + panel.offset_left = -(PANEL_W + 10) + panel.offset_right = -10 + panel.offset_top = 10 + panel.offset_bottom = 10 + panel_h + canvas.add_child(panel) + + var margin := MarginContainer.new() + margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + margin.add_theme_constant_override("margin_left", PAD_H) + margin.add_theme_constant_override("margin_right", PAD_H) + margin.add_theme_constant_override("margin_top", PAD_V) + margin.add_theme_constant_override("margin_bottom", PAD_V) + panel.add_child(margin) + + var vbox := VBoxContainer.new() + vbox.add_theme_constant_override("separation", SEP) + margin.add_child(vbox) + + var title := Label.new() + title.text = "Рецепты" + title.add_theme_font_size_override("font_size", 17) + title.add_theme_color_override("font_color", Color(1.0, 0.9, 0.5)) + title.add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.8)) + title.add_theme_constant_override("shadow_offset_x", 1) + title.add_theme_constant_override("shadow_offset_y", 1) + title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + vbox.add_child(title) + + for recipe in MergeRecipes._list: + var a: String = INGREDIENT_NAMES.get(recipe["ingredients"][0], recipe["ingredients"][0]) + var b: String = INGREDIENT_NAMES.get(recipe["ingredients"][1], recipe["ingredients"][1]) + var scene_name: String = (recipe["result_scene"] as String).get_file().get_basename() + var result: String = RESULT_NAMES.get(scene_name, scene_name) + var row := Label.new() + row.text = "%s + %s → %s" % [a, b, result] + row.add_theme_font_size_override("font_size", 15) + row.add_theme_color_override("font_color", Color.WHITE) + row.add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.8)) + row.add_theme_constant_override("shadow_offset_x", 1) + row.add_theme_constant_override("shadow_offset_y", 1) + vbox.add_child(row) _label(Vector2(16, 92), "HP", 20) hp_bar_bg = _crect(Vector2(16, 118), Vector2(260, 20), Color(0.25, 0.04, 0.04))