latest prompts by @gera
This commit is contained in:
+103
-5
@@ -47,6 +47,10 @@ var progress_bar: ColorRect
|
||||
var progress_bg: ColorRect
|
||||
var upgrade_panel: Panel
|
||||
var gameover_panel: Panel
|
||||
var pause_panel: Panel
|
||||
var pause_image: TextureRect
|
||||
var pause_toggle_btn: Button
|
||||
var _pause_showing_craft: bool = true
|
||||
|
||||
# Equipment slots
|
||||
var equip_fills: Array[ColorRect] = []
|
||||
@@ -85,10 +89,13 @@ func _input(event: InputEvent) -> void:
|
||||
cam_pitch = clampf(cam_pitch, PITCH_MIN, PITCH_MAX)
|
||||
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
if game_active and not upgrading:
|
||||
_toggle_pause_menu()
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
if OS.is_debug_build():
|
||||
var key := event as InputEventKey
|
||||
@@ -127,8 +134,7 @@ func _process(delta: float) -> void:
|
||||
var look_at_pos := player.global_position + Vector3(0, 0.8, 0)
|
||||
camera.global_position = camera.global_position.lerp(look_at_pos + offset, 14.0 * delta)
|
||||
camera.look_at(look_at_pos, Vector3.UP)
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT):
|
||||
player.set_aim_direction(deg_to_rad(cam_yaw))
|
||||
player.set_aim_direction(deg_to_rad(cam_yaw))
|
||||
_update_tier_label()
|
||||
|
||||
if boss_active:
|
||||
@@ -637,6 +643,7 @@ func _create_ui() -> void:
|
||||
_make_gameover_panel()
|
||||
_make_boss_ui()
|
||||
_make_win_panel()
|
||||
_make_pause_panel()
|
||||
|
||||
func _make_hud() -> void:
|
||||
score_label = _label(Vector2(16, 12), "Score: 0", 30)
|
||||
@@ -1030,3 +1037,94 @@ func _update_tier_label() -> void:
|
||||
var shield_str := "-" if st == 0 else str(st)
|
||||
tier_label.text = "Kick: %d Tough: %d Shield: %s" % [kt, tt, shield_str]
|
||||
_update_equipment_slots()
|
||||
|
||||
# ─── Pause menu ───────────────────────────────────────────────────────────────
|
||||
|
||||
const _PAUSE_CRAFT_IMG := "res://assets/Pause_Craft.jpeg"
|
||||
const _PAUSE_CONTROLS_IMG := "res://assets/Pause_Controls.jpeg"
|
||||
|
||||
func _make_pause_panel() -> void:
|
||||
pause_panel = Panel.new()
|
||||
pause_panel.process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
pause_panel.visible = false
|
||||
var sb := StyleBoxFlat.new()
|
||||
sb.bg_color = Color(0.05, 0.04, 0.10, 0.96)
|
||||
sb.border_width_left = 2; sb.border_width_right = 2
|
||||
sb.border_width_top = 2; sb.border_width_bottom = 2
|
||||
sb.border_color = Color(0.35, 0.28, 0.55)
|
||||
sb.corner_radius_top_left = 10; sb.corner_radius_top_right = 10
|
||||
sb.corner_radius_bottom_left = 10; sb.corner_radius_bottom_right = 10
|
||||
pause_panel.add_theme_stylebox_override("panel", sb)
|
||||
pause_panel.anchor_left = 0.5; pause_panel.anchor_right = 0.5
|
||||
pause_panel.anchor_top = 0.5; pause_panel.anchor_bottom = 0.5
|
||||
pause_panel.offset_left = -380; pause_panel.offset_right = 380
|
||||
pause_panel.offset_top = -300; pause_panel.offset_bottom = 300
|
||||
canvas.add_child(pause_panel)
|
||||
|
||||
var vbox := VBoxContainer.new()
|
||||
vbox.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
vbox.add_theme_constant_override("separation", 12)
|
||||
var margin := MarginContainer.new()
|
||||
margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
margin.add_theme_constant_override("margin_left", 20)
|
||||
margin.add_theme_constant_override("margin_right", 20)
|
||||
margin.add_theme_constant_override("margin_top", 16)
|
||||
margin.add_theme_constant_override("margin_bottom", 16)
|
||||
pause_panel.add_child(margin)
|
||||
margin.add_child(vbox)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "ПАУЗА"
|
||||
title.add_theme_font_size_override("font_size", 28)
|
||||
title.add_theme_color_override("font_color", Color(1.0, 0.9, 0.5))
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
vbox.add_child(title)
|
||||
|
||||
pause_image = TextureRect.new()
|
||||
pause_image.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
pause_image.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||||
pause_image.custom_minimum_size = Vector2(0, 380)
|
||||
pause_image.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
vbox.add_child(pause_image)
|
||||
_pause_load_image()
|
||||
|
||||
var hbox := HBoxContainer.new()
|
||||
hbox.alignment = BoxContainer.ALIGNMENT_CENTER
|
||||
hbox.add_theme_constant_override("separation", 16)
|
||||
vbox.add_child(hbox)
|
||||
|
||||
pause_toggle_btn = _pause_btn("Управление", _on_pause_toggle)
|
||||
hbox.add_child(pause_toggle_btn)
|
||||
hbox.add_child(_pause_btn("Продолжить", _toggle_pause_menu))
|
||||
hbox.add_child(_pause_btn("Главное меню", func() -> void:
|
||||
get_tree().paused = false
|
||||
get_tree().change_scene_to_file("res://scenes/MainMenu.tscn")
|
||||
))
|
||||
|
||||
func _pause_btn(text: String, cb: Callable) -> Button:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
b.custom_minimum_size = Vector2(160, 48)
|
||||
b.add_theme_font_size_override("font_size", 17)
|
||||
b.connect("pressed", cb)
|
||||
return b
|
||||
|
||||
func _pause_load_image() -> void:
|
||||
var path := _PAUSE_CRAFT_IMG if _pause_showing_craft else _PAUSE_CONTROLS_IMG
|
||||
pause_image.texture = load(path) as Texture2D if ResourceLoader.exists(path) else null
|
||||
|
||||
func _on_pause_toggle() -> void:
|
||||
_pause_showing_craft = not _pause_showing_craft
|
||||
pause_toggle_btn.text = "Управление" if _pause_showing_craft else "Рецепты Крафта"
|
||||
_pause_load_image()
|
||||
|
||||
func _toggle_pause_menu() -> void:
|
||||
var opening := not pause_panel.visible
|
||||
pause_panel.visible = opening
|
||||
get_tree().paused = opening
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE if opening else Input.MOUSE_MODE_CAPTURED
|
||||
if opening:
|
||||
_pause_showing_craft = true
|
||||
pause_toggle_btn.text = "Управление"
|
||||
_pause_load_image()
|
||||
|
||||
Reference in New Issue
Block a user