scripted_gui = {

  firstwar_gui = {
    window_name = "firstwar_window"
    context_type = player_context

    visible = {
        has_country_flag = FirstWar_Open
    }

    effects = {
      FirstWar_sponge_click = {
        set_country_flag  = FirstWar_submenu
        set_country_flag  = FirstWar_spo
        clr_country_flag  = FirstWar_squ
        clr_country_flag  = FirstWar_pat
        clr_country_flag  = FirstWar_krab
        clr_country_flag  = FirstWar_cb
        clr_country_flag  = FirstWar_bb
      }
      FirstWar_SQU_click = {
        set_country_flag = FirstWar_submenu
        clr_country_flag  = FirstWar_spo
        set_country_flag  = FirstWar_squ
        clr_country_flag  = FirstWar_pat
        clr_country_flag  = FirstWar_krab
        clr_country_flag  = FirstWar_cb
        clr_country_flag  = FirstWar_bb
      }
      FirstWar_KK_click = {
        set_country_flag = FirstWar_submenu
        clr_country_flag  = FirstWar_spo
        clr_country_flag  = FirstWar_squ
        clr_country_flag  = FirstWar_pat
        set_country_flag  = FirstWar_krab
        clr_country_flag  = FirstWar_cb
        clr_country_flag  = FirstWar_bb
      }
      FirstWar_PAT_click = {
        set_country_flag = FirstWar_submenu
        clr_country_flag  = FirstWar_spo
        clr_country_flag  = FirstWar_squ
        set_country_flag  = FirstWar_pat
        clr_country_flag  = FirstWar_krab
        clr_country_flag  = FirstWar_cb
        clr_country_flag  = FirstWar_bb
      }
      FirstWar_bikini_click = {
        clr_country_flag = FirstWar_submenu
        clr_country_flag  = FirstWar_spo
        clr_country_flag  = FirstWar_squ
        clr_country_flag  = FirstWar_pat
        clr_country_flag  = FirstWar_krab
        clr_country_flag  = FirstWar_cb
        set_country_flag  = FirstWar_bb
        add_to_variable = { bar1_bb_var = 100 }
        add_to_variable = { bar2_bb_var = 100 }
        add_to_variable = { bar3_bb_var = 100 }
      }
      FirstWar_cb_click = {
        clr_country_flag = FirstWar_submenu
        clr_country_flag  = FirstWar_spo
        clr_country_flag  = FirstWar_squ
        clr_country_flag  = FirstWar_pat
        clr_country_flag  = FirstWar_krab
        set_country_flag  = FirstWar_cb
        clr_country_flag  = FirstWar_bb
        add_to_variable = { bar1_cb_var = 100 }
        add_to_variable = { bar2_cb_var = 100 }
        add_to_variable = { bar3_cb_var = 100 }
      }
    }

    triggers = {
      FirstWar_bobbg_visible = { has_country_flag = FirstWar_spo }
      FirstWar_kkbg_visible = { has_country_flag = FirstWar_krab }
      FirstWar_patbg_visible = { has_country_flag = FirstWar_pat }
      FirstWar_squbg_visible = { has_country_flag = FirstWar_squ }
      FirstWar_cbbg_visible = { has_country_flag = FirstWar_cb }
      FirstWar_bottombg_visible = { has_country_flag = FirstWar_bb }
      bar1_spo_visible = { has_country_flag = FirstWar_spo }
      bar2_spo_visible = { has_country_flag = FirstWar_spo }
      bar3_spo_visible = { has_country_flag = FirstWar_spo }
      bar1_kra_visible = { has_country_flag = FirstWar_krab }
      bar2_kra_visible = { has_country_flag = FirstWar_krab }
      bar3_kra_visible = { has_country_flag = FirstWar_krab }
      bar1_squ_visible = { has_country_flag = FirstWar_squ }
      bar2_squ_visible = { has_country_flag = FirstWar_squ }
      bar3_squ_visible = { has_country_flag = FirstWar_squ }
      bar1_pat_visible = { has_country_flag = FirstWar_pat }
      bar2_pat_visible = { has_country_flag = FirstWar_pat }
      bar3_pat_visible = { has_country_flag = FirstWar_pat }
      bar1_bb_visible = { has_country_flag = FirstWar_bb }
      bar2_bb_visible = { has_country_flag = FirstWar_bb }
      bar3_bb_visible = { has_country_flag = FirstWar_bb }
      bar1_cb_visible = { has_country_flag = FirstWar_cb }
      bar2_cb_visible = { has_country_flag = FirstWar_cb }
      bar3_cb_visible = { has_country_flag = FirstWar_cb }
    }

    dynamic_lists = {}

    properties = {
      bar1_spo = { frame = SPO.spo_combat_raw }
      bar2_spo = { frame = SPO.spo_health_raw }
      bar3_spo = { frame = SPO.spo_industry_raw }

      bar1_pat = { frame = PAT.pat_combat_raw }
      bar2_pat = { frame = PAT.pat_health_raw }
      bar3_pat = { frame = PAT.pat_industry_raw }

      bar1_squ = { frame = SQU.squ_combat_raw }
      bar2_squ = { frame = SQU.squ_health_raw }
      bar3_squ = { frame = SQU.squ_industry_raw }

      bar1_kra = { frame = KRA.kra_combat_raw }
      bar2_kra = { frame = KRA.kra_health_raw }
      bar3_kra = { frame = KRA.kra_industry_raw }

      bar1_bb = { frame = bar1_bb_var }
      bar2_bb = { frame = bar2_bb_var }
      bar3_bb = { frame = bar3_bb_var }
      bar1_cb = { frame = bar1_cb_var }
      bar2_cb = { frame = bar2_cb_var }
      bar3_cb = { frame = bar3_cb_var }
    }
  }

  firstwar_submenu_controller = {
    window_name = "FirstWar_submenu"
    context_type = player_context

    visible = {
      has_country_flag = FirstWar_submenu
	  has_country_flag = FirstWar_Open
    }

effects = {
  FirstWar_submenu_button1_click = {
    if = {
      limit = { check_variable = { warpoints > 0 } }   # Only if warpoints > 0
      add_to_variable = { warpoints = -1 }             # Spend 1 warpoint

      if = {
        limit = { has_country_flag = FirstWar_spo }
        SPO = { add_to_variable = { spo_combat_raw = -10 } }
        add_to_variable = { spo_combat_weekly = -0.002 }
        add_to_variable = { spo_combat_weekly_raw = 0.2 }
        add_to_variable = { spo_combat_weekly_display = -0.01 }
        SPO_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_pat }
        PAT = { add_to_variable = { pat_combat_raw = -10 } }
        add_to_variable = { pat_combat_weekly = -0.002 }
        add_to_variable = { pat_combat_weekly_raw = 0.2 }
        add_to_variable = { pat_combat_weekly_display = -0.01 }
        PAT_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_squ }
        SQU = { add_to_variable = { squ_combat_raw = -10 } }
        add_to_variable = { squ_combat_weekly = -0.002 }
        add_to_variable = { squ_combat_weekly_raw = 0.2 }
        add_to_variable = { squ_combat_weekly_display = -0.01 }
        SQU_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_krab }
        KRA = { add_to_variable = { kra_combat_raw = -10 } }
        add_to_variable = { kra_combat_weekly = -0.002 }
        add_to_variable = { kra_combat_weekly_raw = 0.2 }
        add_to_variable = { kra_combat_weekly_display = -0.01 }
        KRA_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_cb }
        add_to_variable = { bar1_cb_var = -10 }
      }
      if = {
        limit = { has_country_flag = FirstWar_bb }
        add_to_variable = { bar1_bb_var = -10 }
      }
    }
  }

  FirstWar_submenu_button2_click = {
    if = {
      limit = { check_variable = { warpoints > 0 } }
      add_to_variable = { warpoints = -1 }

      if = {
        limit = { has_country_flag = FirstWar_spo }
        SPO = { add_to_variable = { spo_health_raw = -10 } }
        add_to_variable = { spo_health_weekly = -0.002 }
        add_to_variable = { spo_health_weekly_raw = 0.2 }
        add_to_variable = { spo_health_weekly_display = -0.01 }
        SPO_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_pat }
        PAT = { add_to_variable = { pat_health_raw = -10 } }
        add_to_variable = { pat_health_weekly = -0.002 }
        add_to_variable = { pat_health_weekly_raw = 0.2 }
        add_to_variable = { pat_health_weekly_display = -0.01 }
        PAT_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_squ }
        SQU = { add_to_variable = { squ_health_raw = -10 } }
        add_to_variable = { squ_health_weekly = -0.002 }
        add_to_variable = { squ_health_weekly_raw = 0.2 }
        add_to_variable = { squ_health_weekly_display = -0.01 }
        SQU_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_krab }
        KRA = { add_to_variable = { kra_health_raw = -10 } }
        add_to_variable = { kra_health_weekly = -0.002 }
        add_to_variable = { kra_health_weekly_raw = 0.2 }
        add_to_variable = { kra_health_weekly_display = -0.01 }
        KRA_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_cb }
        add_to_variable = { bar2_cb_var = -10 }
      }
      if = {
        limit = { has_country_flag = FirstWar_bb }
        add_to_variable = { bar2_bb_var = -10 }
      }
    }
  }

  FirstWar_submenu_button3_click = {
    if = {
      limit = { check_variable = { warpoints > 0 } }
      add_to_variable = { warpoints = -1 }

      if = {
        limit = { has_country_flag = FirstWar_spo }
        SPO = { add_to_variable = { spo_industry_raw = -10 } }
        add_to_variable = { spo_industry_weekly = -0.002 }
        add_to_variable = { spo_industry_weekly_raw = 0.2 }
        add_to_variable = { spo_industry_weekly_display = -0.01 }
        SPO_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_pat }
        PAT = { add_to_variable = { pat_industry_raw = -10 } }
        add_to_variable = { pat_industry_weekly = -0.002 }
        add_to_variable = { pat_industry_weekly_raw = 0.2 }
        add_to_variable = { pat_industry_weekly_display = -0.01 }
        PAT_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_squ }
        SQU = { add_to_variable = { squ_industry_raw = -10 } }
        add_to_variable = { squ_industry_weekly = -0.002 }
        add_to_variable = { squ_industry_weekly_raw = 0.2 }
        add_to_variable = { squ_industry_weekly_display = -0.01 }
        SQU_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_krab }
        KRA = { add_to_variable = { kra_industry_raw = -10 } }
        add_to_variable = { kra_industry_weekly = -0.002 }
        add_to_variable = { kra_industry_weekly_raw = 0.2 }
        add_to_variable = { kra_industry_weekly_display = -0.01 }
        KRA_calculate_modifiers = yes
      }
      if = {
        limit = { has_country_flag = FirstWar_cb }
        add_to_variable = { bar3_cb_var = -10 }
      }
      if = {
        limit = { has_country_flag = FirstWar_bb }
        add_to_variable = { bar3_bb_var = -10 }
      }
    }
  }
}
  }
}