# ============================================================================
# 马克思主义政治经济学系统 - 脚本化GUI
# ============================================================================

scripted_gui = {
	
	# 主面板
	CZD_political_economy_panel = {
		context_type = player_context
		window_name = "CZD_political_economy_panel"
		
		visible = {
			tag = CZD
			has_country_flag = CZD_show_political_economy_panel
		}
		
		# ========== 按钮启用条件 ==========
		triggers = {
			# 经济政策按钮 - 冷却期间禁用
			CZD_agriculture_left_btn_click_enabled = {
				NOT = { has_country_flag = CZD_agriculture_cooldown }
			}
			CZD_agriculture_right_btn_click_enabled = {
				NOT = { has_country_flag = CZD_agriculture_cooldown }
			}
			CZD_heavy_industry_left_btn_click_enabled = {
				NOT = { has_country_flag = CZD_heavy_industry_cooldown }
			}
			CZD_heavy_industry_right_btn_click_enabled = {
				NOT = { has_country_flag = CZD_heavy_industry_cooldown }
			}
			CZD_light_industry_left_btn_click_enabled = {
				NOT = { has_country_flag = CZD_light_industry_cooldown }
			}
			CZD_light_industry_right_btn_click_enabled = {
				NOT = { has_country_flag = CZD_light_industry_cooldown }
			}
			CZD_commerce_left_btn_click_enabled = {
				NOT = { has_country_flag = CZD_commerce_cooldown }
			}
			CZD_commerce_right_btn_click_enabled = {
				NOT = { has_country_flag = CZD_commerce_cooldown }
			}
			CZD_military_left_btn_click_enabled = {
				NOT = { has_country_flag = CZD_military_cooldown }
			}
			CZD_military_right_btn_click_enabled = {
				NOT = { has_country_flag = CZD_military_cooldown }
			}
			
			# 派系按钮 - 冷却期间禁用
			CZD_yanan_support_btn_click_enabled = {
				NOT = { has_country_flag = CZD_yanan_cooldown }
			}
			CZD_yanan_suppress_btn_click_enabled = {
				NOT = { has_country_flag = CZD_yanan_cooldown }
			}
			CZD_soviet_support_btn_click_enabled = {
				NOT = { has_country_flag = CZD_soviet_cooldown }
			}
			CZD_soviet_suppress_btn_click_enabled = {
				NOT = { has_country_flag = CZD_soviet_cooldown }
			}
			CZD_kapsan_support_btn_click_enabled = {
				NOT = { has_country_flag = CZD_kapsan_cooldown }
			}
			CZD_kapsan_suppress_btn_click_enabled = {
				NOT = { has_country_flag = CZD_kapsan_cooldown }
			}
			CZD_domestic_support_btn_click_enabled = {
				NOT = { has_country_flag = CZD_domestic_cooldown }
			}
			CZD_domestic_suppress_btn_click_enabled = {
				NOT = { has_country_flag = CZD_domestic_cooldown }
			}
			
			# ========== 路线选择按钮 - 条件检查 ==========
			# 无产阶级专政: 经济倾向<-20 且 延安派为多数派
			CZD_select_line_proletariat_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_proletariat }
				check_variable = { CZD_political_score < -20 }
				check_variable = { CZD_yanan_influence > CZD_soviet_influence }
				check_variable = { CZD_yanan_influence > CZD_kapsan_influence }
				check_variable = { CZD_yanan_influence > CZD_domestic_influence }
			}
			# 人民民主专政: 默认中间路线（始终可选）
			CZD_select_line_democracy_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_democracy }
			}
			# 技术官僚主导: 技术官僚>45 且 苏联派为多数派
			CZD_select_line_technocracy_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_technocracy }
				check_variable = { CZD_technocrats_power > 45 }
				check_variable = { CZD_soviet_influence > CZD_yanan_influence }
				check_variable = { CZD_soviet_influence > CZD_kapsan_influence }
				check_variable = { CZD_soviet_influence > CZD_domestic_influence }
			}
			# 修正主义(以经济发展为中心): 经济倾向>20
			CZD_select_line_revisionism_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_revisionism }
				check_variable = { CZD_political_score > 20 }
			}
			# 军国主义: 军事经济<30 且 甲山派为多数派
			CZD_select_line_militarism_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_militarism }
				check_variable = { CZD_military_policy < 30 }
				check_variable = { CZD_kapsan_influence > CZD_yanan_influence }
				check_variable = { CZD_kapsan_influence > CZD_soviet_influence }
				check_variable = { CZD_kapsan_influence > CZD_domestic_influence }
			}
			# 官僚资产阶级专政: 官僚资产阶级>40 且 经济倾向>15 且 国内派为多数派
			CZD_select_line_bureaucratic_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_bureaucratic }
				check_variable = { CZD_bureaucratic_bourgeoisie_power > 40 }
				check_variable = { CZD_political_score > 15 }
				check_variable = { CZD_domestic_influence > CZD_yanan_influence }
				check_variable = { CZD_domestic_influence > CZD_soviet_influence }
				check_variable = { CZD_domestic_influence > CZD_kapsan_influence }
			}
			# 工团主义: 轻工业>55 商业>55 且 经济倾向在-10到+10之间 且 国内派为多数派
			CZD_select_line_syndicalism_btn_click_enabled = {
				NOT = { has_country_flag = CZD_line_change_cooldown }
				NOT = { has_country_flag = CZD_current_line_syndicalism }
				check_variable = { CZD_light_industry_policy > 55 }
				check_variable = { CZD_commerce_policy > 55 }
				check_variable = { CZD_political_score > -10 }
				check_variable = { CZD_political_score < 10 }
				check_variable = { CZD_domestic_influence > CZD_yanan_influence }
				check_variable = { CZD_domestic_influence > CZD_soviet_influence }
				check_variable = { CZD_domestic_influence > CZD_kapsan_influence }
			}
		}
		
		effects = {
			close_button_click = {
				clr_country_flag = CZD_show_political_economy_panel
			}
			
			# ========== 经济基础 - 政策调整按钮 ==========
			
			# 农业政策
			CZD_agriculture_left_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_agriculture_policy > 0 }
						NOT = { has_country_flag = CZD_agriculture_cooldown }
					}
					subtract_from_variable = { CZD_agriculture_policy = 5 }
					set_country_flag = { flag = CZD_agriculture_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_agriculture_right_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_agriculture_policy < 100 }
						NOT = { has_country_flag = CZD_agriculture_cooldown }
					}
					add_to_variable = { CZD_agriculture_policy = 5 }
					set_country_flag = { flag = CZD_agriculture_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 重工业政策
			CZD_heavy_industry_left_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_heavy_industry_policy > 0 }
						NOT = { has_country_flag = CZD_heavy_industry_cooldown }
					}
					subtract_from_variable = { CZD_heavy_industry_policy = 5 }
					set_country_flag = { flag = CZD_heavy_industry_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_heavy_industry_right_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_heavy_industry_policy < 100 }
						NOT = { has_country_flag = CZD_heavy_industry_cooldown }
					}
					add_to_variable = { CZD_heavy_industry_policy = 5 }
					set_country_flag = { flag = CZD_heavy_industry_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 轻工业政策
			CZD_light_industry_left_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_light_industry_policy > 0 }
						NOT = { has_country_flag = CZD_light_industry_cooldown }
					}
					subtract_from_variable = { CZD_light_industry_policy = 5 }
					set_country_flag = { flag = CZD_light_industry_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_light_industry_right_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_light_industry_policy < 100 }
						NOT = { has_country_flag = CZD_light_industry_cooldown }
					}
					add_to_variable = { CZD_light_industry_policy = 5 }
					set_country_flag = { flag = CZD_light_industry_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 商业政策
			CZD_commerce_left_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_commerce_policy > 0 }
						NOT = { has_country_flag = CZD_commerce_cooldown }
					}
					subtract_from_variable = { CZD_commerce_policy = 5 }
					set_country_flag = { flag = CZD_commerce_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_commerce_right_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_commerce_policy < 100 }
						NOT = { has_country_flag = CZD_commerce_cooldown }
					}
					add_to_variable = { CZD_commerce_policy = 5 }
					set_country_flag = { flag = CZD_commerce_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 军事经济政策
			CZD_military_left_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_military_policy > 0 }
						NOT = { has_country_flag = CZD_military_cooldown }
					}
					subtract_from_variable = { CZD_military_policy = 5 }
					set_country_flag = { flag = CZD_military_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_military_right_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_military_policy < 100 }
						NOT = { has_country_flag = CZD_military_cooldown }
					}
					add_to_variable = { CZD_military_policy = 5 }
					set_country_flag = { flag = CZD_military_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# ========== 上层建筑 - 派系支持/打压按钮 ==========
			
			# 延安派
			CZD_yanan_support_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_yanan_influence < 100 }
						NOT = { has_country_flag = CZD_yanan_cooldown }
					}
					add_to_variable = { CZD_yanan_influence = 3 }
					set_country_flag = { flag = CZD_yanan_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_yanan_suppress_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_yanan_influence > 0 }
						NOT = { has_country_flag = CZD_yanan_cooldown }
					}
					subtract_from_variable = { CZD_yanan_influence = 3 }
					set_country_flag = { flag = CZD_yanan_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 苏联派
			CZD_soviet_support_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_soviet_influence < 100 }
						NOT = { has_country_flag = CZD_soviet_cooldown }
					}
					add_to_variable = { CZD_soviet_influence = 3 }
					set_country_flag = { flag = CZD_soviet_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_soviet_suppress_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_soviet_influence > 0 }
						NOT = { has_country_flag = CZD_soviet_cooldown }
					}
					subtract_from_variable = { CZD_soviet_influence = 3 }
					set_country_flag = { flag = CZD_soviet_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 甲山派
			CZD_kapsan_support_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_kapsan_influence < 100 }
						NOT = { has_country_flag = CZD_kapsan_cooldown }
					}
					add_to_variable = { CZD_kapsan_influence = 3 }
					set_country_flag = { flag = CZD_kapsan_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_kapsan_suppress_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_kapsan_influence > 0 }
						NOT = { has_country_flag = CZD_kapsan_cooldown }
					}
					subtract_from_variable = { CZD_kapsan_influence = 3 }
					set_country_flag = { flag = CZD_kapsan_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# 国内派
			CZD_domestic_support_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_domestic_influence < 100 }
						NOT = { has_country_flag = CZD_domestic_cooldown }
					}
					add_to_variable = { CZD_domestic_influence = 3 }
					set_country_flag = { flag = CZD_domestic_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			CZD_domestic_suppress_btn_click = {
				if = {
					limit = { 
						check_variable = { CZD_domestic_influence > 0 }
						NOT = { has_country_flag = CZD_domestic_cooldown }
					}
					subtract_from_variable = { CZD_domestic_influence = 3 }
					set_country_flag = { flag = CZD_domestic_cooldown days = 60 value = 1 }
					CZD_update_political_economy = yes
				}
			}
			
			# ========== 路线选择按钮效果 ==========
			# 无产阶级专政
			CZD_select_line_proletariat_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_proletariat
				set_variable = { CZD_current_line_id = 1 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
			# 人民民主专政
			CZD_select_line_democracy_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_democracy
				set_variable = { CZD_current_line_id = 2 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
			# 技术官僚主导
			CZD_select_line_technocracy_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_technocracy
				set_variable = { CZD_current_line_id = 3 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
			# 修正主义
			CZD_select_line_revisionism_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_revisionism
				set_variable = { CZD_current_line_id = 4 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
			# 军国主义
			CZD_select_line_militarism_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_militarism
				set_variable = { CZD_current_line_id = 5 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
			# 官僚资产阶级专政
			CZD_select_line_bureaucratic_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_bureaucratic
				set_variable = { CZD_current_line_id = 6 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
			# 工团主义
			CZD_select_line_syndicalism_btn_click = {
				CZD_clear_all_line_flags = yes
				set_country_flag = CZD_current_line_syndicalism
				set_variable = { CZD_current_line_id = 7 }
				set_country_flag = { flag = CZD_line_change_cooldown days = 120 value = 1 }
				CZD_apply_political_economy_effects = yes
			}
		}
	}
}
