--[[
Вспомогальные функции ля ХО скринов
--]]


function skip_fun()
    if(CurrentScreen.mini_game and CurrentScreen.mini_game.OnSkip) then
        CurrentScreen.mini_game:OnSkip();
    end
	if(CurrentScreen.OnSkip) then
	    CurrentScreen:OnSkip()
	end
end

function show_all_objects()
    if(current_obj_step_by_step) then
        ItemSetColor(CurrentScreen.item_list[current_obj_step_by_step].obj[1], 1.0, 1.0, 1.0);
        ItemSetScale(CurrentScreen.item_list[current_obj_step_by_step].obj[1], 1.0)
            
        ItemRemove(CurrentScreen:GetName(), "item_name_debug_"..CurrentScreen.item_list[current_obj_step_by_step][1])
        current_obj_step_by_step = nil
    end
    
    if(CurrentScreen.mini_game and CurrentScreen.mini_game.ShowAllObjects) then
		CurrentScreen.mini_game:ShowAllObjects();
    end
end
--показывает имена всех объектов на екране, которые могут учавствовать в ХО. Для отладки при локализации
function show_all_objects_name()
    if(not CurrentScreen.mini_game or CurrentScreen.mini_game.name ~= "hidden_object") then return end
    if(current_obj_step_by_step) then
        ItemSetColor(CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1], 1.0, 1.0, 1.0);
        ItemSetScale(CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1], 1.0)
            
        ItemRemove(CurrentScreen:GetName(), "item_name_debug_"..CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1])
        current_obj_step_by_step = nil
    end
    
    if(show_all_item_list == nil) then
        if(CurrentScreen.mini_game.ho_list) then
            for key, value in pairs(CurrentScreen.mini_game.ho_list) do
                if(value.active) then
                    local y = ItemGetY(value.obj[1]) - 20
                    if(y < 0) then y = ItemGetY(value.obj[1]) + ItemGetHeight(value.obj[1]) + 20 end
                    CurrentScreen:CreateLabel("item_name_debug_"..key, GetString(mgt_hidden_object:GetItemType(value.obj[1])), ItemGetX(value.obj[1]) + ItemGetWidth(value.obj[1]) / 2 - 50, y, 20, FONT_UNDERWOOD);
                    ItemSetSize("item_name_debug_"..key, 100, 20)
                    SetLabelAlign("item_name_debug_"..key, TEXT_ALIGN.H_CENTER)	
                    ItemSetColor("item_name_debug_"..key, 1.0, 1.0, 1.0, 1.0);
                end
            end
            show_all_item_list = true
        end
        
    else
        if(CurrentScreen.mini_game.ho_list) then
            for key, value in pairs(CurrentScreen.mini_game.ho_list) do
                ItemRemove(CurrentScreen:GetName(), "item_name_debug_"..key)
            end
            show_all_item_list = nil
        end
    end
end
--показывать имена объектов по очереди
function show_objects_name_step_by_step()
    if(not CurrentScreen.mini_game or CurrentScreen.mini_game.name ~= "hidden_object") then return end
    
    if(show_all_item_list) then
        for key, value in pairs(CurrentScreen.mini_game.ho_list) do
            ItemRemove(CurrentScreen:GetName(), "item_name_debug_"..key)
        end
        show_all_item_list = nil
    end
    if(show_step_by_step == nil) then show_step_by_step = 0 end

    if(current_obj_step_by_step == nil) then current_obj_step_by_step = 0 end
        
    if(CurrentScreen.mini_game.ho_list[current_obj_step_by_step]) then
        ItemSetColor(CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1], 1.0, 1.0, 1.0);
        ItemSetScale(CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1], 1.0)
        
        ItemRemove(CurrentScreen:GetName(), "item_name_debug_"..CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1])
    end
    
    repeat
        current_obj_step_by_step = current_obj_step_by_step + 1
        if(not CurrentScreen.mini_game.ho_list[current_obj_step_by_step]) then
            current_obj_step_by_step = 1;
            break
        end
        if(CurrentScreen.mini_game.ho_list[current_obj_step_by_step].active) then
            break;
        end
    until false
    
    if(CurrentScreen.mini_game.ho_list[current_obj_step_by_step] and CurrentScreen.mini_game.ho_list[current_obj_step_by_step].active) then
        local name = CurrentScreen.mini_game.ho_list[current_obj_step_by_step].obj[1]
        
        ItemSetColor(name, 1.0, 0.0, 0.0);
        ItemSetScale(name, 1.1)
        
        local y = ItemGetY(name) - 20
        if(y < 0) then y = ItemGetY(name) + ItemGetHeight(name) + 20 end
        CurrentScreen:CreateLabel("item_name_debug_"..name, GetString(mgt_hidden_object:GetItemType(name)), ItemGetX(name) + ItemGetWidth(name) / 2 - 50, y, 20, FONT_UNDERWOOD);
        ItemSetSize("item_name_debug_"..name, 100, 20)
        SetLabelAlign("item_name_debug_"..name, TEXT_ALIGN.H_CENTER)	
        ItemSetColor("item_name_debug_"..name, 1.0, 1.0, 1.0, 1.0);
    end

end