Add objective update notice
This commit is contained in:
@@ -36,6 +36,7 @@ const SFX_VOLUME_DB := -4.0
|
||||
const UI_SFX_VOLUME_DB := -8.0
|
||||
const FLOATING_TEXT_LIFETIME := 1.0
|
||||
const FLOATING_TEXT_RISE := 42.0
|
||||
const OBJECTIVE_NOTICE_DURATION := 2.6
|
||||
const UNIT_MOVE_ANIMATION_DURATION := 0.18
|
||||
const TARGET_PREVIEW_BADGE_SIZE := Vector2(92, 22)
|
||||
const LOW_HP_WARNING_RATIO := 0.35
|
||||
@@ -74,6 +75,8 @@ var objective_label: Label
|
||||
var campaign_status_label: Label
|
||||
var mission_title_label: Label
|
||||
var mission_detail_label: Label
|
||||
var objective_notice_panel: PanelContainer
|
||||
var objective_notice_label: Label
|
||||
var hud_unit_portrait_panel: PanelContainer
|
||||
var hud_unit_portrait_texture: TextureRect
|
||||
var hud_unit_portrait_label: Label
|
||||
@@ -157,6 +160,7 @@ var current_bgm_key := ""
|
||||
var audio_stream_cache := {}
|
||||
var last_announced_battle_status := ""
|
||||
var floating_texts: Array[Dictionary] = []
|
||||
var objective_notice_timer := 0.0
|
||||
var unit_motion_by_unit: Dictionary = {}
|
||||
|
||||
|
||||
@@ -168,6 +172,7 @@ func _ready() -> void:
|
||||
state.dialogue_requested.connect(_on_dialogue_requested)
|
||||
state.combat_feedback_requested.connect(_on_combat_feedback_requested)
|
||||
state.unit_motion_requested.connect(_on_unit_motion_requested)
|
||||
state.objective_updated.connect(_on_objective_updated)
|
||||
campaign_state.load_campaign(CAMPAIGN_PATH)
|
||||
campaign_state.load_or_start(campaign_state.get_start_scenario_id())
|
||||
if campaign_state.has_pending_post_battle_choice():
|
||||
@@ -252,6 +257,20 @@ func _create_hud() -> void:
|
||||
new_campaign_button.pressed.connect(_on_new_campaign_pressed)
|
||||
top_row.add_child(new_campaign_button)
|
||||
|
||||
objective_notice_panel = PanelContainer.new()
|
||||
objective_notice_panel.visible = false
|
||||
objective_notice_panel.position = Vector2(360, 84)
|
||||
objective_notice_panel.size = Vector2(560, 64)
|
||||
objective_notice_panel.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
root.add_child(objective_notice_panel)
|
||||
|
||||
objective_notice_label = Label.new()
|
||||
objective_notice_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
objective_notice_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
||||
objective_notice_label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
||||
objective_notice_label.custom_minimum_size = Vector2(520, 48)
|
||||
objective_notice_panel.add_child(objective_notice_label)
|
||||
|
||||
var side_panel := PanelContainer.new()
|
||||
side_panel.position = Vector2(760, 104)
|
||||
side_panel.size = Vector2(480, 610)
|
||||
@@ -814,6 +833,8 @@ func _play_ui_cancel() -> void:
|
||||
func _play_log_sfx(message: String) -> void:
|
||||
if message.contains(" but misses."):
|
||||
_play_sfx("guard_block")
|
||||
elif message.begins_with("Objective updated:") or message.begins_with("Defeat condition updated:"):
|
||||
_play_ui_confirm()
|
||||
elif message.contains(" attacks ") or message.contains(" counterattacks "):
|
||||
if message.contains(" for "):
|
||||
_play_sfx("hit_heavy")
|
||||
@@ -974,6 +995,11 @@ func _handle_key(event: InputEventKey) -> void:
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var needs_redraw := false
|
||||
if objective_notice_timer > 0.0:
|
||||
objective_notice_timer = maxf(0.0, objective_notice_timer - delta)
|
||||
if objective_notice_timer <= 0.0 and objective_notice_panel != null:
|
||||
objective_notice_panel.visible = false
|
||||
|
||||
if not floating_texts.is_empty():
|
||||
var active_texts: Array[Dictionary] = []
|
||||
for popup in floating_texts:
|
||||
@@ -2015,6 +2041,21 @@ func _on_log_added(message: String) -> void:
|
||||
log_box.scroll_to_line(max(0, log_box.get_line_count() - 1))
|
||||
|
||||
|
||||
func _on_objective_updated(victory: String, defeat: String) -> void:
|
||||
var notice_lines := ["Objective Updated"]
|
||||
if not victory.is_empty():
|
||||
notice_lines.append(victory)
|
||||
if not defeat.is_empty():
|
||||
notice_lines.append(defeat)
|
||||
if objective_notice_label != null:
|
||||
objective_notice_label.text = "\n".join(notice_lines)
|
||||
if objective_notice_panel != null:
|
||||
objective_notice_panel.visible = true
|
||||
objective_notice_timer = OBJECTIVE_NOTICE_DURATION
|
||||
_update_hud()
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _on_dialogue_requested(lines: Array) -> void:
|
||||
var normalized_lines := _normalized_dialogue_lines(lines)
|
||||
if normalized_lines.is_empty():
|
||||
|
||||
Reference in New Issue
Block a user