[expect TIMER_2_obj_??_time_out]
	[hide obj_?]
	[ stop_ps_emit obj_?]
	[forget ANIM_obj_?]
	[fade_out suitcase_open]
	[gosub @fill_strings]
[ende]

#include "..\interface\game.scr"

//Спрятать кнопку ХЕЛП
[hide btn_help_0]

///ISPY GAME
[goto @start]

[@fill_strings]
	[ remove_hint_from_all HINT1]
	[push_q]
	[$TEMP ""]
	[let {done=0}]
	[let {i=0}]
	[while {i=i+1;i<=OBJ_LIST}]
		[write $TEMP ""]
		[fill_qq_with {(i)ISPY}]
		[push_q]
		[get_group_name_but_not HINT1 obj_?]
		[compare ? NONE]
		[if not_?=NONE]  рисуем последнее имя
			[get_group_obj_name ? {?_children_visible}]
			[write $TEMP "?"]
		[endif]
		[pop_q]
		[if strings_equal]	рисуем единственное имя
			[forget strings_equal]
			[if not_obj_?_FOUND and {obj_?_is_inventory==0}]
				[write $TEMP "$" obj_?_name]
			[endif]

		[endif]
		[fill_qq_with {i}]
		[compare $TEMP ""]
		[if not_strings_equal]
			[write $LIST_? "$" $TEMP]
		[endif]
		[if strings_equal]
			[forget strings_equal]
			[let {done=done+1}]
			[color $LIST_? 255,255,255,40]
		[endif]

		[if {$LIST_?_px_length>75}]	/// правка шрифта для длинных надписей91
			[font_number $LIST_? 7]
			[tport $LIST_? {ii=?-1; 165+ii\6*76+(ii\6>2)*100-50},{544+trunc(ii/6)*18}]
		[endif]
	[endw]
	[pop_q]
	[if {done==12}]
		[fade_in level_complite 200]
		[scale level_complite 1.2 200]
		[delay 300 fade_out level_complite]
		[once delay 400 switch_back]
		[once play_sound win]
		[lock]
	[endif]
[return]


      
[@start]

[once gosub @fill_strings]

[for_each obj_??_is_clicked]
	[let {co_group=obj_?_group_n; i=0}]
	[let {co_group=0-1} if {co_group==0}]
	[while {i=i+1;i<=OBJ_LIST}]
		[push_q]
		[fill_qq_with {(i)ISPY}]
		[let {lo_group=obj_?_group_n}]
		[pop_q]
		[if {(i)ISPY==?} or {lo_group==co_group} and not_ONE_CLICK and not_ANTI_CLICK_LOCK]
			[if {?<=ISPY_OBJS} and not_ANIM_obj_?]
				[note obj_?_FOUND]
				[play_sound Ispy]
				[put obj_? under hud_bg]
				[clear_parent obj_?] 
				[scale obj_? 1.5 40]
				[note ANIM_obj_?]
				[set_timer TIMER_obj_? 40]
				[play_ps obj_? 200]
				[post ONE_CLICK]
				[set_counter ANTI_CLICK 1]
				[stop_ps_emit HINT1]
			[endif]

			[if {?>ISPY_OBJS} and not_ANIM_obj_?]
			[play_sound Ispy]
				[clear_parent obj_?]
				[scale obj_? 1.5 40]
				[note ANIM_obj_?]
				[set_timer TIMER_obj_? 40]
				[put obj_? under hud_bg]
				[play_ps obj_? 200]
				[post ONE_CLICK]
				[set_counter ANTI_CLICK 1]
				[note obj_?_FOUND]
				[stop_ps_emit HINT1]
			[endif]


			[let {k=0}]
			[for {i=0} {i=i+1;i<=12}]
				[if {(i)ISPY==?}]
					[let {k=i}]
				[endif]
			[endf]
			[for {i=0} {i=i+1;i<ICONS}]
				[if {k!=0} and {j=?; (obj_&i&_group_n==obj_&j&_group_n)*(obj_&j&_group_n!=0)*(j!=i)} and not_obj_{i}_FOUND and {obj_&j&_group_n!=HINT1_no}]
					[change_in_list ISPY {k} {i}]
				[endif]
			[endf]

			[gosub @fill_strings]
		[endif]

	[endw]
[endfe]

[expect TIMER_obj_??_time_out]
	[spin_CW obj_? 100]
	[scale obj_? 0.5 180]
	[add_path_dot obj_? 0    |{obj_?_x},{obj_?_y}]
	[add_path_dot obj_? 100    |400,300]
	[add_path_dot obj_? 200    |15, 520]
	[start_path obj_?] 
	[delay 100 put obj_? over suitcase_open]
	[delay 100 fade_out obj_?]
	[set_timer TIMER_2_obj_? 195]
	[fade_in suitcase_open]
[ende]

[once make_counter ANTI_CLICK]

[if mouse_up and {ANTI_CLICK<7}]
	[inc_counter ANTI_CLICK]
	[set_timer ANTI_CLICK_T 100]
[endif]

[if ANTI_CLICK_T_time_out]
	[if {ANTI_CLICK>0}]
		[set_timer ANTI_CLICK_T 100]
		[dec_counter ANTI_CLICK]
	[endif]
[endif]

[if {ANTI_CLICK>5}]
	[move window {it_x},200 50]
	[set_counter ANTI_CLICK 0]
[endif]

#include "..\interface\hint.scr"


///QUEST
[if obj_{QI}_is_clicked and not_QUEST_DONE and not_QI_INV]
	[show inv_{QI}]
	[note QI_INV]
	[let {qi_time=time}]
	[play_sound sound_find]
[endif]

[if inv_{QI}_on_quest_null]
	[deinvent inv_{QI}]
	[ drop inv_{QI}]
	[move inv_{QI} 747, 223 20]
	[fade_in obj_56]
	[note QUEST_DONE]
	[stop_ps_emit quest_null]
	[once play_sound ierog]
[endif]

//Что бы чемодан не открывался, после того как мы найдем главный предмет
[if suitcase_close_is_clicked and QUEST_DONE]
	[move hud_inventory -310,120 50]
	[play_sound warning]
	[stop_sound click_interface]
[endif]

[set_slot 1 {hud_inventory_x+120} 200]	
[ set_slot 2 {hud_inventory_x+50} 300]
[ set_slot 3 {hud_inventory_x+50} 400]

//Ambients
[once play_sound temple_indoor looped]

