Wiki

effect · mark_focus_tree_layout_dirty

Definition

  • Supported scope:COUNTRY
  • Supported target:any

Description

Forces the refresh of the tree layout for the scoped country
mark_focus_tree_layout_dirty = yes

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

当 mod 通过脚本动态修改国策树布局(例如用 complete_national_focus 批量完成国策、或通过 add_ideas 间接影响国策可用性)后,界面上的国策树位置可能不会立即刷新,此时在同一执行块末尾加上此命令可强制重新计算布局。常见于"动态国策树"类 mod,在事件触发后确保玩家看到正确的树形结构。

country_event = {
    id = my_mod.1
    title = my_mod.1.t
    desc = my_mod.1.d

    option = {
        name = my_mod.1.a
        complete_national_focus = my_special_focus
        mark_focus_tree_layout_dirty = yes
    }
}

配合关系

  • [complete_national_focus](/wiki/effect/complete_national_focus) — 脚本强制完成国策后布局可能错位,需要紧跟此命令刷新树的渲染位置。
  • [activate_shine_on_focus](/wiki/effect/activate_shine_on_focus) / [deactivate_shine_on_focus](/wiki/effect/deactivate_shine_on_focus) — 动态高亮或取消高亮某个国策节点时,配合刷新确保视觉状态与逻辑状态一致。
  • [has_completed_focus](/wiki/trigger/has_completed_focus) — 作为条件检查某国策是否已完成,从而决定是否需要触发布局刷新(用于 if 块内按需调用)。

常见坑

  1. 遗漏调用导致国策树错位:新手在脚本里批量操作国策后忘记加此命令,玩家在 UI 中会看到节点重叠或偏移,误以为是 mod 存档损坏,实际只需补上 mark_focus_tree_layout_dirty = yes 即可解决。
  2. 在非 COUNTRY scope 下调用:此命令只在国家 scope 生效,若误写在 every_owned_state 等状态 scope 内,游戏会报错或静默跳过,应确保始终在国家 scope(如 ROOTFROM、具体国家标签)下执行。

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

When a mod dynamically modifies the focus tree layout through scripting (for example, by mass-completing focuses via complete_national_focus or indirectly affecting focus availability through add_ideas), the focus tree positions on the UI may not refresh immediately. Adding this command at the end of the same execution block forces a recalculation of the layout. This is common in "dynamic focus tree" mods to ensure players see the correct tree structure after an event is triggered.

country_event = {
    id = my_mod.1
    title = my_mod.1.t
    desc = my_mod.1.d

    option = {
        name = my_mod.1.a
        complete_national_focus = my_special_focus
        mark_focus_tree_layout_dirty = yes
    }
}

Synergy

  • [complete_national_focus](/wiki/effect/complete_national_focus) — After scripting forcefully completes a focus, the layout may shift. This command must immediately follow to refresh the tree's rendering positions.
  • [activate_shine_on_focus](/wiki/effect/activate_shine_on_focus) / [deactivate_shine_on_focus](/wiki/effect/deactivate_shine_on_focus) — When dynamically highlighting or unhighlighting a focus node, use this alongside to ensure visual state matches logical state.
  • [has_completed_focus](/wiki/trigger/has_completed_focus) — Serves as a conditional check to determine whether a focus has been completed, allowing you to decide whether a layout refresh is needed (call conditionally within if blocks as required).

Common Pitfalls

  1. Missing the call causes focus tree misalignment: Beginners often forget to add this command after bulk focus operations in scripts, causing players to see overlapping or shifted nodes in the UI. Players may mistakenly think the mod save is corrupted, when simply adding mark_focus_tree_layout_dirty = yes resolves the issue.
  2. Calling outside COUNTRY scope: This command only works in country scope. If mistakenly placed inside state scope such as every_owned_state, the game will error or silently skip it. Always ensure execution within country scope (such as ROOT, FROM, or a specific country tag).