dofile('Data/Scripts/Screens/HintAnimationLogic.lua')

local OFFSET_X = (SCR_W - WORK_W) / 2 

INVENTORY_DECREASED_SCALE = "INVENTORY_DECREASED_SCALE"
PANEL_CONSTANTLY_UNLOCKED = "PANEL_CONSTANTLY_UNLOCKED"
local CONSTANT_PANEL_LOCK_KEY = "CONSTANT_PANEL_LOCK_KEY"

local DEFAULT_VISIBILITY_LOCK_KEY = "DEFAULT_VISIBILITY_LOCK_KEY"
local DEFAULT_VISIBILITY_LOCK_VALUE = "DEFAULT_VISIBILITY_LOCK_VALUE"
local PANEL_LOCK_KEY = "PANEL_LOCK_KEY"
local MOUSE_LOCK_KEY = "MOUSE_LOCK_KEY"

-- black bar constants
local BLACK_BAR_DEFAULT_REVEALING_TIME   =   0.5

local ALL_PANELS_SHOW_OPACITY      =  1
local ALL_PANELS_HIDE_OPACITY      =  0

local BLACK_BAR_SHOW_OPACITY      =  1
local BLACK_BAR_HIDE_OPACITY      =  0.4
local BLACK_BAR_REVEALING_TIME   =   0.5
local BLACK_BAR_REVEALING_Y  =   70

local BOTTOM_BLACK_BAR_SHOW_OPACITY      =  1
local BOTTOM_BLACK_BAR_HIDE_OPACITY      =  0

-- bottom panel constants
local BOTTOM_PANEL_REVEALING_TIME   =   0.5
local BOTTOM_PANEL_REVEALING_Y  =   698

local BOTTOM_PANEL_SHOW_OPACITY =   1
local BOTTOM_PANEL_HIDE_OPACITY =   0

local BOTTOM_PANEL_FADE_SHOW_OPACITY =   1
local BOTTOM_PANEL_FADE_HIDE_OPACITY =   0

local PANEL_MODE_NAME_PLATE_SHOW_Y    =   693 - 733
local PANEL_MODE_NAME_PLATE_HIDE_Y    =   683 - 733

local LEFT_PLATE_SHOW_X    =   97 - 512
local LEFT_PLATE_HIDE_X    =   67 - 512

local RIGHT_PLATE_SHOW_X    =   927 - 512
local RIGHT_PLATE_HIDE_X    =   957 - 512

class 'ControlsPanel' (Node)

---------------------------------------------------------------------------------------------------
function ControlsPanel:__init(panel)
	Node.__init(self, panel:getMainEntity(), 'ControlsPanel', 2)
	self.panel      = panel
	self.game_scene = panel.game_scene
	
	if self.CreateLoaderTable then
        local table_resource = self:CreateLoaderTable()
        LoadScene(self.main_entity, table_resource)
    end

    self.phoneSound = nil

    self.timer   = Timer()
    
    self:entityHide('area_take_ringing_phone')
    self:getEntityNamed('area_take_ringing_phone'):setCursorOverName('CursorActive')
    self:getEntityNamed('area_take_ringing_phone').onPress:add(bind(self.onRingingPhoneClick, self))
    self:getEntityNamed('area_take_ringing_phone'):setSendEventsToParent(true)
    
    self:updatePhoneUpdatesState(true)
    
    self:getEntityNamed('bttn_menu').onPress:add(bind(self.onMenuButtonClick, self))
    self:getEntityNamed('bttn_menu'):setSendEventsToParent(true)

    self:getEntityNamed('bttn_m3').onPress:add(bind(self.OnM3ButtonClick, self))
    self:getEntityNamed('bttn_m3'):setSendEventsToParent(true)

    self:getEntityNamed('bttn_ho').onPress:add(bind(self.onHOButtonClick, self))
    self:getEntityNamed('bttn_ho'):setSendEventsToParent(true)

    self:getEntityNamed('bttn_phone').onPress:add(bind(self.onPhoneButtonClick, self))
    self:getEntityNamed('bttn_phone'):setSendEventsToParent(true)
    
    self:getEntityNamed('bttn_lock_on').onPress:add(function() self:onLockOnButtonClick() end)
    self:getEntityNamed('bttn_lock_on'):setSendEventsToParent(true)
    self:getEntityNamed('bttn_lock_on'):hide()
    self.lock_on_button = self:getEntityNamed('bttn_lock_on')
    
    self:getEntityNamed('bttn_lock_off').onPress:add(function() self:onLockOffButtonClick() end)
    self:getEntityNamed('bttn_lock_off'):setSendEventsToParent(true)
    self.lock_off_button = self:getEntityNamed('bttn_lock_off')

    self:getEntityNamed('bttn_clock').onPress:add(function() self:onClockButtonClick() end)
    self:getEntityNamed('bttn_clock'):setSendEventsToParent(true)
    self.clock_button = self:getEntityNamed('bttn_clock')
    
    -- self:getEntityNamed('bttn_magnifying_glass_on').onPress:add(bind(self.onMagnifyingGlassOnButtonClick, self))
    -- self:getEntityNamed('bttn_magnifying_glass_on'):setSendEventsToParent(true)
    -- self:getEntityNamed('bttn_magnifying_glass_on'):hide()
    -- self.magnifying_glass_on_button = self:getEntityNamed('bttn_magnifying_glass_on')
    
    -- self:getEntityNamed('bttn_magnifying_glass_off').onPress:add(bind(self.onMagnifyingGlassOffButtonClick, self))
    -- self:getEntityNamed('bttn_magnifying_glass_off'):setSendEventsToParent(true)
    -- self.magnifying_glass_off_button = self:getEntityNamed('bttn_magnifying_glass_off')
    
    self.update_panel_lock_and_magnifying_buttons_visibility = false
    self.need_to_restore_panel_lock_and_magnifying_buttons_state = false

    self:getMainEntity():getEntityNamed('bttn_menu'):setSFXTrackOnPress( getCommonSoundEntity('ButtonClick') )
    self:getMainEntity():getEntityNamed('bttn_clock').onFocusIn:add( function() playCommonSound('ClockButtonClick') end )

    self.hintAnimationLogic = HintAnimationLogic(self)

    self:updatePosition()
    -- self:shiftPlates()

    -- Заставляем вызываться OnUpdate по сигналу
    self:getMainEntity().onUpdate:add(bind(self.onDefaultUpdate, self))

    
    -- Устанавливаем обработчик для открытия менюшки
	do
	    self.game_scene:getWindow():getHotkeySignal(ERSK_ESCAPE):removeAll()
	    self.game_scene:getWindow():getHotkeySignal(ERSK_ESCAPE):add( bind(self.onMenuButtonClick, self) )
	end

	self.blackBarEff            = nil
    self.panelEff               = nil
    self.panelFadeEff           = nil
    self.panelModeNamePlateEff      = nil
	self.leftPlateEff           = nil
	self.rightPlateEff          = nil
	self.anchorBottomBlackBarEff    = nil
	self.anchorBottomPanelEff   = nil

	local function update(entity, dt)
		self:onUpdate(dt)
	end
	self.game_scene:getWindow().onUpdate:add(update)


    -- create achievment window
	-- Application.onScreenRatioChange:add(bind(self.shiftPlates, self, width, height))
	-- Application.onScreenModeChange:add(bind(self.shiftPlates, self, is_fullscreen))	
end
-----------------------------------------------------------------------------------

function ControlsPanel:isPanelConstantlyLocked()
    return not HasGameState(PANEL_CONSTANTLY_UNLOCKED)
end

function ControlsPanel:onLockOnButtonClick(_, _, time)
    if HasGameState(PANEL_CONSTANTLY_UNLOCKED) then
        RemoveGameState(PANEL_CONSTANTLY_UNLOCKED)
    end

    if not time then playCommonSound('LockClick') end

    self.lock_on_button:hide()
    self.lock_off_button:show()
    self:setBottomPanelVisible(true, time, CONSTANT_PANEL_LOCK_KEY)
    self:setBlackBarVisible(true, time, CONSTANT_PANEL_LOCK_KEY)
end

function ControlsPanel:onLockOffButtonClick(_, _, time)
    AddUniqueGameState(PANEL_CONSTANTLY_UNLOCKED, 'true')
    self.lock_off_button:hide()
    self.lock_on_button:show()

    if not time then playCommonSound('LockClick') end

    self:setBottomPanelVisible(false, time, CONSTANT_PANEL_LOCK_KEY)
    self:setBlackBarVisible(false, time, CONSTANT_PANEL_LOCK_KEY)
end
-----------------------------------------------------------------------------------
-- Викосити
-- function ControlsPanel:onMagnifyingGlassOnButtonClick(_, _, time)
--     if HasGameState(INVENTORY_DECREASED_SCALE) then
--         RemoveGameState(INVENTORY_DECREASED_SCALE)
--     end
--     self.magnifying_glass_on_button:hide()
--     self.magnifying_glass_off_button:show()
--     self.game_scene:getPanel():getInventory():setIncreasedCellScale(true, time)
-- end

-- function ControlsPanel:onMagnifyingGlassOffButtonClick(_, _, time)
--     AddUniqueGameState(INVENTORY_DECREASED_SCALE, 'true')
--     self.magnifying_glass_off_button:hide()
--     self.magnifying_glass_on_button:show()
--     self.game_scene:getPanel():getInventory():setIncreasedCellScale(false, time)
-- end
-----------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function ControlsPanel:onClockButtonClick(callback)
  --  playCommonSound('')
    
    createClockScreen(callback)
end

function ControlsPanel:requestPanelLockAndMagnifyingButtonsVisibility(visible)
    self.update_panel_lock_and_magnifying_buttons_visibility = true

    if visible then
        self.need_to_restore_panel_lock_and_magnifying_buttons_state = true
    else
        self.need_to_restore_panel_lock_and_magnifying_buttons_state = false
    end
end

function ControlsPanel:checkUpdatePanelLockAndMagnifyingButtonsVisibility(visible)
    if self.update_panel_lock_and_magnifying_buttons_visibility then
        self.update_panel_lock_and_magnifying_buttons_visibility = false
    
        if self.need_to_restore_panel_lock_and_magnifying_buttons_state then
            self.need_to_restore_panel_lock_and_magnifying_buttons_state = false
            
            if current_scene and HasGameState(PANEL_CONSTANTLY_UNLOCKED) then
                self:onLockOffButtonClick(nil, nil, 0) 
            else
                self:onLockOnButtonClick(nil, nil, 0)
            end
    
            -- if current_scene and HasGameState(INVENTORY_DECREASED_SCALE) then
            --     self:onMagnifyingGlassOffButtonClick(nil, nil, 0) 
            -- else
            --     self:onMagnifyingGlassOnButtonClick(nil, nil, 0)
            -- end
        else
            self.lock_on_button:hide()
            self.lock_off_button:hide()
            -- self.magnifying_glass_on_button:hide()
            -- self.magnifying_glass_off_button:hide()
        end
    end
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:onUpdate(dt)
	local mousePos = getHandledCursor():getScrPosition()

    if not current_scene then
        return
    end

    if mousePos.y >= BOTTOM_PANEL_REVEALING_Y and not current_scene:getPlayField():getMouseBlocker():isHold() then
        self:setBottomPanelVisible(true, nil, MOUSE_LOCK_KEY)
    elseif not current_scene:getPlayField():getMouseBlocker():isHold() then
        self:setBottomPanelVisible(false, nil, MOUSE_LOCK_KEY)
    end
    
    if mousePos.y <= BLACK_BAR_REVEALING_Y and not current_scene:getPlayField():getMouseBlocker():isHold() then
        self:setBlackBarVisible(true, nil, MOUSE_LOCK_KEY)
    elseif not current_scene:getPlayField():getMouseBlocker():isHold() then
        self:setBlackBarVisible(false, nil, MOUSE_LOCK_KEY)
    end
    
    self:checkUpdatePanelLockAndMagnifyingButtonsVisibility()
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:setMode(mode)
	self.hintAnimationLogic:setMode(mode)
	
	local gui_move_time = 0.5--self:issPanelConstantlyLocked() and 0 or 0.5
	local gui_reveal_time = 0.5
		
	local mg_mode_name_plate_obj = self:getMainEntity():getEntityNamed('mg_mode_name_plate')
	local ho_mode_name_plate_obj = self:getMainEntity():getEntityNamed('ho_mode_name_plate')
	local inventory_mode_name_plate_obj = self:getMainEntity():getEntityNamed('inventory_mode_name_plate')	
	
	if mode == EPanelMode.MINIGAME then
	    mg_mode_name_plate_obj:destroyEffectors()
	    ho_mode_name_plate_obj:destroyEffectors()
	    inventory_mode_name_plate_obj:destroyEffectors()	    
	    mg_mode_name_plate_obj:setOpacity(1)
	    ho_mode_name_plate_obj:setOpacity(0)
	    inventory_mode_name_plate_obj:setOpacity(0)

	    self:setPanelsVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
		self:setBlackBarVisible(true, gui_move_time, PANEL_LOCK_KEY)
		self:setBottomBlackBarVisible(false, gui_reveal_time, PANEL_LOCK_KEY)
		self:setBottomPanelVisible(true, gui_move_time, PANEL_LOCK_KEY)

        self:setMatch3ButtonsVisible(false)

	elseif mode == EPanelMode.HIDDENOBJECT or mode == EPanelMode.MATCH3 then
	    mg_mode_name_plate_obj:destroyEffectors()
	    ho_mode_name_plate_obj:destroyEffectors()
	    inventory_mode_name_plate_obj:destroyEffectors()
	    mg_mode_name_plate_obj:setOpacity(0)
	    ho_mode_name_plate_obj:setOpacity(1)
	    inventory_mode_name_plate_obj:setOpacity(0)

	    self:setPanelsVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
		self:setBlackBarVisible(true, gui_move_time, PANEL_LOCK_KEY)
		self:setBottomBlackBarVisible(false, gui_reveal_time, PANEL_LOCK_KEY)
		self:setBottomPanelVisible(true, gui_move_time, PANEL_LOCK_KEY)

        if mode == EPanelMode.HIDDENOBJECT then
            self:setMatch3ButtonsVisible(true)
        end 

    elseif mode == EPanelMode.HIDDENPICTURE then
        mg_mode_name_plate_obj:destroyEffectors()
        ho_mode_name_plate_obj:destroyEffectors()
        inventory_mode_name_plate_obj:destroyEffectors()
        mg_mode_name_plate_obj:setOpacity(0)
        ho_mode_name_plate_obj:setOpacity(1)
        inventory_mode_name_plate_obj:setOpacity(0)

        self:setPanelsVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
        self:setBlackBarVisible(true, gui_move_time, PANEL_LOCK_KEY)
        self:setBottomBlackBarVisible(false, gui_reveal_time, PANEL_LOCK_KEY)
        self:setBottomPanelVisible(true, gui_move_time, PANEL_LOCK_KEY)

        self:setMatch3ButtonsVisible(false)
        
	else
	    mg_mode_name_plate_obj:destroyEffectors()
	    ho_mode_name_plate_obj:destroyEffectors()
	    inventory_mode_name_plate_obj:destroyEffectors()
	    mg_mode_name_plate_obj:setOpacity(0)
	    ho_mode_name_plate_obj:setOpacity(0)
	    inventory_mode_name_plate_obj:setOpacity(1)

        self:setMatch3ButtonsVisible(false)

	    if mode == EPanelMode.QUEST or mode == EPanelMode.MAZE then
	    	self:setPanelsVisible(true, gui_reveal_time, PANEL_LOCK_KEY)    
		    self:setBlackBarVisible(false, gui_move_time, PANEL_LOCK_KEY)
		    self:setBottomBlackBarVisible(false, gui_reveal_time, PANEL_LOCK_KEY)
		    self:setBottomPanelVisible(false, gui_move_time, PANEL_LOCK_KEY)
	    elseif mode == EPanelMode.COMICS then
	    	self:setPanelsVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
		    self:setBlackBarVisible(true, gui_move_time, PANEL_LOCK_KEY)
		    self:setBottomBlackBarVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
	    elseif mode == EPanelMode.CLEAN then
	    	self:setPanelsVisible(false, gui_reveal_time, PANEL_LOCK_KEY)
	    elseif mode == EPanelMode.CUTSCENE then
	    	self:setPanelsVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
		    self:setBlackBarVisible(true, gui_move_time, PANEL_LOCK_KEY)
		    self:setBottomBlackBarVisible(true, gui_reveal_time, PANEL_LOCK_KEY)
	    end
	end
		
    if mode == EPanelMode.QUEST or mode == EPanelMode.MAZE then
        self:requestPanelLockAndMagnifyingButtonsVisibility(true)
    else
        self:requestPanelLockAndMagnifyingButtonsVisibility(false)
    end
end

function ControlsPanel:setMatch3ButtonsVisible(bVisible)
    local ho_button = self:getEntityNamed('bttn_ho')
    local m3_button = self:getEntityNamed('bttn_m3')
    
    if bVisible then
        ho_button:hide()
        m3_button:show()
        m3_button:setActive(true)
        self:releasePlaceForButton('bttn_ho')
        self:releasePlaceForButton('bttn_m3')
        self:requestPlaceForButton('bttn_m3', function(x) m3_button:setScrX(x) end)
    else
        ho_button:hide()
        m3_button:hide()
        self:releasePlaceForButton('bttn_ho')
        self:releasePlaceForButton('bttn_m3')
    end
end

function ControlsPanel:setPanelsVisible(visible, time, key)
	if not self.panels_visibility_lock_keys then
		self.panels_visibility_lock_keys = {}
	end
	local panels_visibility_lock_keys = self.panels_visibility_lock_keys

    local time = time and time or BLACK_BAR_DEFAULT_REVEALING_TIME
    local key = key and key or DEFAULT_VISIBILITY_LOCK_KEY
    
    if visible then
        if panels_visibility_lock_keys[key] == nil then
            panels_visibility_lock_keys[key] = DEFAULT_VISIBILITY_LOCK_VALUE                
        else
            return
        end
    else
        if panels_visibility_lock_keys[key] ~= nil then
            panels_visibility_lock_keys[key] = nil
            
            if table.size(panels_visibility_lock_keys) > 0 then
                return
            end
        else
            return
        end            
    end

    local targetOpacity = (visible) and ALL_PANELS_SHOW_OPACITY or ALL_PANELS_HIDE_OPACITY
    local obj = self:getEntityNamed('anchor_all_panels')
    obj:setRespondable(visible)

    if self.allPanelsEff then
        self.allPanelsEff:destroy()
        self.allPanelsEff = nil
    end

    if time == 0 then
        obj:setOpacity(targetOpacity)
    else
        local requiredTime = math.abs(targetOpacity - obj:getOpacity())/(ALL_PANELS_SHOW_OPACITY - ALL_PANELS_HIDE_OPACITY) * time
    
        local eff = CreateAnimationEffector()
        eff:attachTo(obj)
        eff:setKey(_TRACK_O, 0,            obj:getOpacity())
        eff:setKey(_TRACK_O, requiredTime,         targetOpacity)
        eff:play()
    
        self.allPanelsEff = eff
    end
end

function ControlsPanel:setBlackBarVisible(visible, time, key)
	if not self.black_bar_visibility_lock_keys then
		self.black_bar_visibility_lock_keys = {}
	end
	local black_bar_visibility_lock_keys = self.black_bar_visibility_lock_keys

    local time = time and time or BLACK_BAR_DEFAULT_REVEALING_TIME
    local key = key and key or DEFAULT_VISIBILITY_LOCK_KEY
    
    if visible then
        if black_bar_visibility_lock_keys[key] == nil then
            black_bar_visibility_lock_keys[key] = DEFAULT_VISIBILITY_LOCK_VALUE                
        else
            return
        end
    else
        if black_bar_visibility_lock_keys[key] ~= nil then
            black_bar_visibility_lock_keys[key] = nil
            
            if table.size(black_bar_visibility_lock_keys) > 0 then
                return
            end
        else
            return
        end            
    end

    local targetOpacity = (visible) and BLACK_BAR_SHOW_OPACITY or BLACK_BAR_HIDE_OPACITY
    local obj     = self:getEntityNamed('black_bar')

    if self.blackBarEff then
        self.blackBarEff:destroy()
        self.blackBarEff = nil
    end

    if time == 0 then
        obj:setOpacity(targetOpacity)
    else
        local requiredTime = math.abs(targetOpacity - obj:getOpacity())/(BLACK_BAR_SHOW_OPACITY - BLACK_BAR_HIDE_OPACITY) * time
    
        local eff = CreateAnimationEffector()
        eff:attachTo(obj)
        eff:setKey(_TRACK_O, 0,            obj:getOpacity())
        eff:setKey(_TRACK_O, requiredTime,         targetOpacity)
        eff:play()
    
        self.blackBarEff = eff
    end
end

function ControlsPanel:setBottomBlackBarVisible(visible, time, key)
	if not self.bottom_black_bar_visibility_lock_keys then
		self.bottom_black_bar_visibility_lock_keys = {}
	end
	local bottom_black_bar_visibility_lock_keys = self.bottom_black_bar_visibility_lock_keys

    local time = time and time or BLACK_BAR_DEFAULT_REVEALING_TIME
    local key = key and key or DEFAULT_VISIBILITY_LOCK_KEY
    
    if visible then
        if bottom_black_bar_visibility_lock_keys[key] == nil then
            bottom_black_bar_visibility_lock_keys[key] = DEFAULT_VISIBILITY_LOCK_VALUE                
        else
            return
        end
    else
        if bottom_black_bar_visibility_lock_keys[key] ~= nil then
            bottom_black_bar_visibility_lock_keys[key] = nil
            
            if table.size(bottom_black_bar_visibility_lock_keys) > 0 then
                return
            end
        else
            return
        end            
    end

    local targetOpacity = (visible) and BOTTOM_BLACK_BAR_SHOW_OPACITY or BOTTOM_BLACK_BAR_HIDE_OPACITY        
    local obj_black_bar = self:getEntityNamed('bottom_black_bar')
    local obj_panel     = self:getEntityNamed('anchor_bottom_panel')

    if self.bottomBlackBarEff then
        self.bottomBlackBarEff:destroy()
        self.bottomBlackBarEff = nil
    end
    
    if self.bottomPanelHideEff then
        self.bottomPanelHideEff:destroy()
        self.bottomPanelHideEff = nil
    end
    
    obj_black_bar:setRespondable(visible)
    obj_panel:setRespondable(not visible)

    if time == 0 then
        obj_black_bar:setOpacity(targetOpacity)
        obj_panel:setOpacity(1-targetOpacity)
    else
        local requiredTime = math.abs(targetOpacity - obj_black_bar:getOpacity())/(BOTTOM_BLACK_BAR_SHOW_OPACITY - BOTTOM_BLACK_BAR_HIDE_OPACITY) * time
    
        local eff = CreateAnimationEffector()
        eff:attachTo(obj_black_bar)
        eff:setKey(_TRACK_O, 0,            obj_black_bar:getOpacity())
        eff:setKey(_TRACK_O, requiredTime,         targetOpacity)
        eff:play()
    
        self.bottomBlackBarEff = eff
        
        eff = CreateAnimationEffector()
        eff:attachTo(obj_panel)
        eff:setKey(_TRACK_O, 0,            obj_panel:getOpacity())
        eff:setKey(_TRACK_O, requiredTime,         1-targetOpacity)
        eff:play()
    
        self.bottomPanelHideEff = eff        
    end
end

function ControlsPanel:setBottomPanelVisible(visible, time, key)
	if not self.bottom_panel_visibility_lock_keys then
		self.bottom_panel_visibility_lock_keys = {}
	end
	local bottom_panel_visibility_lock_keys = self.bottom_panel_visibility_lock_keys

    local time = time and time or BOTTOM_PANEL_REVEALING_TIME
    local key = key and key or DEFAULT_VISIBILITY_LOCK_KEY

    if visible then
        if bottom_panel_visibility_lock_keys[key] == nil then
            bottom_panel_visibility_lock_keys[key] = DEFAULT_VISIBILITY_LOCK_VALUE
        else
            return
        end
    else
        if bottom_panel_visibility_lock_keys[key] ~= nil then
            bottom_panel_visibility_lock_keys[key] = nil
            
            if table.size(bottom_panel_visibility_lock_keys) > 0 then
                return
            end
        else
            return
        end
    end
    
    local targetPanelOpacity = (visible) and BOTTOM_PANEL_SHOW_OPACITY or BOTTOM_PANEL_HIDE_OPACITY
    local panel_obj = self:getEntityNamed('panel_background')
    local targetPanelFadeOpacity = (visible) and BOTTOM_PANEL_FADE_HIDE_OPACITY or BOTTOM_PANEL_FADE_SHOW_OPACITY    
    local panel_fade_obj = self:getEntityNamed('panel_background_transparant')
    
    local targetPanelModeNamePlateY = (visible) and PANEL_MODE_NAME_PLATE_SHOW_Y or PANEL_MODE_NAME_PLATE_HIDE_Y
    local panel_mode_name_plate_anchor_obj =  self:getEntityNamed('panel_mode_name_plate_anchor')    
    local targetLeftPlateX = (visible) and LEFT_PLATE_SHOW_X or LEFT_PLATE_HIDE_X
    local left_plate_obj  =  self:getEntityNamed('left_plate')
    local targetRightPlateX = (visible) and RIGHT_PLATE_SHOW_X or RIGHT_PLATE_HIDE_X
    local right_plate_obj =  self:getEntityNamed('right_plate')
    
    if visible then
        panel_obj:setRespondable(true)
        panel_fade_obj:setRespondable(false)
    else
        panel_obj:setRespondable(false)
        panel_fade_obj:setRespondable(true)
    end

    if self.panelEff then
        self.panelEff:destroy()
        self.panelEff = nil
    end

    if self.panelFadeEff then
        self.panelFadeEff:destroy()
        self.panelFadeEff = nil
    end

    if self.panelModeNamePlateEff then
        self.panelModeNamePlateEff:destroy()
        self.panelModeNamePlateEff = nil
    end

    if self.leftPlateEff then
        self.leftPlateEff:destroy()
        self.leftPlateEff = nil
    end
    
    if self.rightPlateEff then
        self.rightPlateEff:destroy()
        self.rightPlateEff = nil
    end

    if time == 0 then
        panel_obj:setOpacity(targetPanelOpacity)
        panel_fade_obj:setOpacity(targetPanelFadeOpacity)
        panel_mode_name_plate_anchor_obj:setY(targetPanelModeNamePlateY)   
        left_plate_obj:setX(targetLeftPlateX)   
        right_plate_obj:setX(targetRightPlateX)
        
        self.game_scene:getPanel():getInventory():makeAllCellsColored(visible, 0)
    else 
        local requiredTime = math.abs(targetPanelOpacity - panel_obj:getOpacity()) * time
    
        local eff = CreateAnimationEffector()
        eff:attachTo(panel_obj)
        eff:setKey(_TRACK_O, 0,            panel_obj:getOpacity())
        eff:setKey(_TRACK_O, requiredTime,         targetPanelOpacity)
        eff:play()        
        self.panelEff = eff
        
        eff = CreateAnimationEffector()
        eff:attachTo(panel_fade_obj)
        eff:setKey(_TRACK_O, 0,            panel_fade_obj:getOpacity())
        eff:setKey(_TRACK_O, requiredTime,         targetPanelFadeOpacity)
        eff:play()        
        self.panelFadeEff = eff
    
        eff = CreateAnimationEffector()
        eff:attachTo(panel_mode_name_plate_anchor_obj)
        eff:setKey(_TRACK_Y, 0,            panel_mode_name_plate_anchor_obj:getY())
        eff:setKey(_TRACK_Y, requiredTime,         targetPanelModeNamePlateY)
        eff:play()        
        self.panelModeNamePlateEff = eff
        
        eff = CreateAnimationEffector()
        eff:attachTo(left_plate_obj)
        eff:setKey(_TRACK_X, 0,            left_plate_obj:getX())
        eff:setKey(_TRACK_X, requiredTime,         targetLeftPlateX)
        eff:play()        
        self.leftPlateEff = eff
        
        eff = CreateAnimationEffector()
        eff:attachTo(right_plate_obj)
        eff:setKey(_TRACK_X, 0,            right_plate_obj:getX())
        eff:setKey(_TRACK_X, requiredTime,         targetRightPlateX)
        eff:play()        
        self.rightPlateEff = eff
        
        self.game_scene:getPanel():getInventory():makeAllCellsColored(visible)
    end            
end

---------------------------------------------------------------------------------------------------

do  
    local buttons_priority = {  bttn_strategy_guide = 1,
                                bttn_m3 = 2,
                                bttn_ho = 3,
                                bttn_comics_skip = 4,
                                SkipTutorialButton = 5}

    local buttons_order = {}
    
    local buttons_x_updaters = {}
    
    local buttons_size_x = {}
    local buttons_h_x = {}
    local buttons_y = {}
    
    local function RecalculateButtonsPosition()
        if #buttons_order == 0 then
            return
        end
    
        buttons_x_updaters[buttons_order[1]](OFFSET_X + 4 + buttons_h_x[buttons_order[1]])
    
        if #buttons_order > 0 then
            local step = WORK_W/#buttons_order
            local sum = OFFSET_X
            for i = 2,#buttons_order do
                sum = sum + step
                buttons_x_updaters[buttons_order[i]](sum)
            end
        end
    end

    function ControlsPanel:requestPlaceForButton(bttn_name, updater, size_x, h_x)
        if not buttons_priority[bttn_name] then 
            return
        end
        
        local size_x, h_x = size_x, h_x
        
        if not size_x or not h_x then
            if not self:hasEntityNamed(bttn_name) then
                return
            else
                local obj = self:getEntityNamed(bttn_name)
                local rectangle = obj:getBoundingBox()
                size_x, h_x = rectangle:getWidth(), rectangle:getWidth()/2
            end
        end                
        
        local added = false
        for i,v in ipairs(buttons_order) do
            if v == bttn_name then                
                return
            end
            
            if buttons_priority[v] > buttons_priority[bttn_name] then
                table.insert(buttons_order, i, bttn_name)
                added = true
                break
            end                        
        end
        if not added then
            table.insert(buttons_order, bttn_name)
        end
        
        buttons_size_x[bttn_name] = size_x
        buttons_h_x[bttn_name] = h_x
        buttons_x_updaters[bttn_name] = updater
        RecalculateButtonsPosition()
        
        if self:hasEntityNamed(bttn_name) then            
            buttons_y[bttn_name] = self:getEntityNamed(bttn_name):getScrY()
        end
        
        return
    end

    function ControlsPanel:releasePlaceForButton(bttn_name)
        if not buttons_priority[bttn_name] then 
            return
        end
    
        for i,v in ipairs(buttons_order) do
            if v == bttn_name then                
                table.remove(buttons_order, i)
                buttons_size_x[bttn_name] = nil
                buttons_h_x[bttn_name] = nil
                buttons_x_updaters[bttn_name] = nil                
                RecalculateButtonsPosition()
                buttons_y[bttn_name] = nil
                return
            end
        end               
    end
    
    function ControlsPanel:setButtonsUnderBBTTemporaryVisible(visible)    
        for i = 1,#buttons_order do
            local bttn_name = buttons_order[i]
            if self:hasEntityNamed(bttn_name) then
                if visible then
                    self:getEntityNamed(bttn_name):setScrY(buttons_y[bttn_name])
                else
                    if i > 1 then
                        self:getEntityNamed(bttn_name):setScrY(buttons_y[bttn_name] - 1024)
                    end
                end                
            end
        end
    end
    
end
---------------------------------------------------------------------------------------------------
function ControlsPanel:onMenuButtonClick()
    createInGameMenu()
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function ControlsPanel:onDefaultUpdate(entity, dt)
    self.timer:update(dt)
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function ControlsPanel:OnM3ButtonClick()
    self.game_scene:getPlayField().match3:open()
    self.panel:setMode(EPanelMode.MATCH3)

    self:getEntityNamed('bttn_ho'):setRespondable(false)
    self.timer:add( function() 
                        self:getEntityNamed('bttn_ho'):setRespondable(true) 
                    end, 1.5)
end
---------------------------------------------------------------------------------------------------

function ControlsPanel:onHOButtonClick()
    self.game_scene:getPlayField().match3:close()
    self.panel:setMode(EPanelMode.HIDDENOBJECT)

     self:getEntityNamed('bttn_m3'):setRespondable(false)
    self.timer:add( function() self:getEntityNamed('bttn_m3'):setRespondable(true) end, 1.5)
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:onRingingPhoneClick()
    local level = self.game_scene:getPlayField()
    if not level then
        return
    end

    if self.phoneSound then
        self.phoneSound:stop()
    end

    local phone_call_name, pick_phone_callback = level:getPickPhoneParameters()  

    if pick_phone_callback and type(pick_phone_callback) == 'function' then        
        level:setPickPhoneCallback(nil, nil)
        pick_phone_callback()        
    end
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:onPhoneButtonClick(callback)
    playCommonSound('OpenPhone')
    createPhoneScreen(callback)
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:onNoteAdded()
	local level = self.game_scene:getPlayField()

    AddUniqueGameState(HAS_NOT_SHOWN_NOTES, 'true')		
	self:updatePhoneUpdatesState()
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:onNotebookClosed()
    local level = self.game_scene:getPlayField()

    self:updatePhoneUpdatesState()

    if level.onNotebookClosed then
    	level:onNotebookClosed()
    end
end

-------------------------------------------------------------------------------
function ControlsPanel:getHintAnimationLogic()
	return self.hintAnimationLogic
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:setPhoneButtonBlocked(blocked)
    if not blocked then
        self:entityShow('bttn_phone')
    elseif blocked then
        self:entityHide('bttn_phone')
	end
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function ControlsPanel:oscillatePhoneScreen(entity, start_pos, open_time, amplitude, frequency, damping_time, num_iterations)
    entity:destroyEffectors() 

    local OFFSET_X = 512
    local OFFSET_Y = 384
    
    local trigger_x = start_pos.x
    local trigger_y = start_pos.y
    
    local start_scale = 0.3 
    local ascreen_in_time = math.min(open_time, 0.1)
    local move_in_time = math.min(open_time, 0.2)
    local oscillation_time = open_time
    local k_max_move_amp = 3        
    -- move from trigger zone to the center
    local eff = CreateAnimationEffector()
    eff:setDestroysOnEnd(true)
    eff:attachTo(entity)
    eff:setKey(_TRACK_X, 0.0, trigger_x)
    eff:setKey(_TRACK_Y, 0.0, trigger_y)
    
    if oscillation_time>0 then
        eff:setKey(_TRACK_X, move_in_time, OFFSET_X)
        eff:setKey(_TRACK_Y, move_in_time, OFFSET_Y)
    
        eff:setKey(_TRACK_SX, 0, start_scale)
        eff:setKey(_TRACK_SY, 0, start_scale)
        
        local dx = OFFSET_X - trigger_x
        local move_amplitude_x = (dx / OFFSET_X) * k_max_move_amp
        
        local dy = OFFSET_Y - trigger_y
        local move_amplitude_y = (dy / OFFSET_Y) * k_max_move_amp

        for i = 1, num_iterations do
            local time = i*(oscillation_time / num_iterations)
            local damp_coeff = math.sin(time * frequency) * math.exp(-time / damping_time + M_E)
            local scale = amplitude * damp_coeff + 1
            eff:setKey(_TRACK_SX, time+ascreen_in_time, scale)
            eff:setKey(_TRACK_SY, time+ascreen_in_time, scale)
            
            local x = OFFSET_X + (move_amplitude_x * damp_coeff + 1)
            local y = OFFSET_Y + (move_amplitude_y * damp_coeff + 1)
            
            eff:setKey(_TRACK_X, time+move_in_time, x)
            eff:setKey(_TRACK_Y, time+move_in_time, y)
        end
        
        eff:setKey(_TRACK_SX, oscillation_time+ascreen_in_time, 1)
        eff:setKey(_TRACK_SY, oscillation_time+ascreen_in_time, 1)
    else
        eff:setKey(_TRACK_X, 0, OFFSET_X)
        eff:setKey(_TRACK_Y, 0, OFFSET_Y)
    
        eff:setKey(_TRACK_SX, 0, 1)
        eff:setKey(_TRACK_SY, 0, 1)
    end
    eff:play()
    
    return eff
end
---------------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
function ControlsPanel:setPhoneRinging(visible, entity)
    if not visible then   
        self:entityHide('area_take_ringing_phone')
        self:entityShow('bttn_phone')
        
        self:getEntityNamed('ph_vertical'):destroyEffectors()
        self:getEntityNamed('ph_vertical'):setRotationRad(0)
    elseif visible then            
        self:entityHide('bttn_phone')  
        self:entityShow('area_take_ringing_phone')
        self:getEntityNamed('area_take_ringing_phone'):setRespondable(false)

        local time = (time == nil) and ZOOM_ZONE_APPEARING_TIME or time

        local function on_oscillation_ended()
            self.phoneSound = createSoundEntity(current_scene:getPlayField():getMainEntity(), 'PhoneRinging') 
            self.phoneSound:setRepeated(true)
            self.phoneSound:play()

            self:getEntityNamed('area_take_ringing_phone'):setRespondable(true)

            self:getEntityNamed('ph_vertical'):destroyEffectors()
            local effector = CreateAnimationEffector()
            effector:attachTo(self:getEntityNamed('ph_vertical'))
            effector:setDestroysOnEnd( true )
            effector:setMode( _ANIM_FWD + _ANIM_LOOP )
            
            effector:setKey( _TRACK_A, 0, 0 )
            effector:setKey( _TRACK_A, 0.1, math.rad(1) )
            effector:setKey( _TRACK_A, 0.2, math.rad(0) )
            effector:setKey( _TRACK_A, 0.3, math.rad(-1) )
            effector:setKey( _TRACK_A, 0.4, math.rad(0) )
            effector:setKey( _TRACK_A, 0.5, math.rad(1) )
            effector:setKey( _TRACK_A, 0.6, math.rad(0) )
            effector:setKey( _TRACK_A, 0.7, math.rad(-1) )
            effector:setKey( _TRACK_A, 0.8, math.rad(0) )
            effector:setKey( _TRACK_A, 1.5, math.rad(0) )
            
            effector:play()
        end

        local start_pos = {}
        if not entity then
            entity = self:getEntityNamed('bttn_phone')       
            start_pos = entity:getScrPosition() 
            start_pos.x = start_pos.x - 171   
        else
            start_pos       = {x = entity:getScrX(), y = entity:getScrY()}
        end

        

        self:oscillatePhoneScreen(self:getEntityNamed('area_take_ringing_phone'),
                            start_pos,  -- start position
                            time,    -- open time
                            0.005,      -- amplitude
                            10,         -- frequency
                            0.1,        -- damping time                                
                            10          -- number of iterations
                        ).onFinish:add(on_oscillation_ended)   
	end
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:updatePhoneUpdatesState(immidiate)    
    local message_display = self:getEntityNamed('message_display')

    message_display:destroyEffectors()
    if HasGameState(HAS_NOT_SHOWN_TASKS) or HasGameState(HAS_NOT_SHOWN_NOTES) then
        message_display:show()
        if immidiate then            
            message_display:setOpacity(1)
        else
            local current_o = message_display:getOpacity()
            local target_o = 1
        
            message_display:ChangeOpacity(current_o, target_o, 0.2*math.abs(target_o - current_o))
        end
    else        
        if immidiate then
            message_display:hide()
            message_display:setOpacity(0)
        else
            local current_o = message_display:getOpacity()
            local target_o = 0
        
            message_display:ChangeOpacity(current_o, target_o, 0.2*math.abs(target_o - current_o))
        end
    end
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:moveOut(move_time)
	--[[self:getEntityNamed('plate_left_block'):destroyEffectors()
	self:getEntityNamed('plate_right_block'):destroyEffectors()

	self:getEntityNamed('plate_left_block'):MoveTo(self.plate_left_out_position.x , self.plate_left_out_position.y, move_time, 0)
	self:getEntityNamed('plate_right_block'):MoveTo(self.plate_right_out_position.x , self.plate_right_out_position.y, move_time, 0)]]
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:moveIn(move_time)
	--[[self:getEntityNamed('plate_left_block'):destroyEffectors()
	self:getEntityNamed('plate_right_block'):destroyEffectors()

	self:getEntityNamed('plate_left_block'):MoveTo(self.plate_left_in_position.x , self.plate_left_in_position.y, move_time, 0)
	self:getEntityNamed('plate_right_block'):MoveTo(self.plate_right_in_position.x , self.plate_right_in_position.y, move_time, 0)]]
end

---------------------------------------------------------------------------------------------------
function ControlsPanel:updatePosition()
	local window = Application:getPlatform():getWindow()
	if window:isFullscreen() and not window:isWidescreen() then
		OFFSET_X = 0
	else
		OFFSET_X = 171
	end
	
	--[[local OFFSET_X = 0
	local left_pos = Vector2f(100 - OFFSET_X, 693)
	local right_pos = Vector2f(925 + OFFSET_X, 693)
	
	self.plate_left_in_position = left_pos
	self.plate_left_out_position = left_pos + Vector2f(-600 - OFFSET_X, 0)

    self.plate_right_in_position = right_pos
	self.plate_right_out_position = right_pos + Vector2f(600 + OFFSET_X, 0)]]
end

-------------------------------------------------------------------------------
function ControlsPanel:shiftPlates(w, h)
		-- Console:pushText('width: '..w..'| height: '..h)

		-- self:updatePosition()
		-- local is_panel_out_mode = self.panel:getMode() == EPanelMode.COMICS or self.panel:getMode() == EPanelMode.CUTSCENE		  
		-- if game_scene then
		-- 	self:getEntityNamed('plate_left_block'):setX(is_panel_out_mode and self.plate_left_out_position.x or self.plate_left_in_position.x)				
		-- 	self:getEntityNamed('plate_right_block'):setX(is_panel_out_mode and self.plate_right_out_position.x or self.plate_right_in_position.x)
		-- end
end
-------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--                      GENERATED CONTENT. DO NOT EDIT.                       --
--------------------------------------------------------------------------------

function ControlsPanel:CreateLoaderTable()
	local objects =
	{
		{ name = 'anchor_all_panels',  entityType = 'SpriteEntity',  x = 0,  y = 0,  order = 0,  isRespondable = false,  opacity = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 1, y = 1},  width = 2,  height = 2,  },
		{ name = 'anchor_top_panel',  entityType = 'SpriteEntity',  parentName = 'anchor_all_panels',  x = 512,  y = 34,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 10,  height = 10,  },
		{ name = 'black_bar',  entityType = 'SpriteEntity',  parentName = 'anchor_top_panel',  x = 0,  y = -9,  order = 0,  scaleX = 2,  scaleY = 0.8,  color = {r = 1, g = 1, b = 1, a = 0.235294},  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/black_bar.png',  width = 1028,  height = 100,  },
		{ name = 'bttn_menu',  entityType = 'ButtonEntity',  parentName = 'anchor_top_panel',  x = 464,  y = -6,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_menu.png',  text = '',  activeRectX = 120,  activeRectY = 50,  },
		{ name = 'bttn_m3',  entityType = 'ButtonEntity',  parentName = 'anchor_top_panel',  x = -45,  y = -3,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_m3.png',  text = '',  activeRectX = 277,  activeRectY = 50,  },
		{ name = 'bttn_ho',  entityType = 'ButtonEntity',  parentName = 'anchor_top_panel',  x = -28,  y = -3,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_ho.png',  text = '',  activeRectX = 296,  activeRectY = 50,  },
		{ name = 'anchor_bottom_panel',  entityType = 'SpriteEntity',  parentName = 'anchor_all_panels',  x = 512,  y = 733,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = false,  width = 10,  height = 10,  },
		{ name = 'panel_background',  entityType = 'SpriteEntity',  parentName = 'anchor_bottom_panel',  x = 0,  y = 0,  order = 0,  opacity = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/panel_background.png',  width = 1366,  height = 80,  },
		{ name = 'panel_mode_name_plate_anchor',  entityType = 'SpriteEntity',  parentName = 'panel_background',  x = -4,  y = -40,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  hotSpot = {x = 1, y = 1},  width = 2,  height = 2,  },
		{ name = 'inventory_mode_name_plate',  entityType = 'SpriteEntity',  parentName = 'panel_mode_name_plate_anchor',  x = 0,  y = -12,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/inventory_mode_name_plate.png',  width = 238,  height = 58,  },
		{ name = 'ho_mode_name_plate',  entityType = 'SpriteEntity',  parentName = 'panel_mode_name_plate_anchor',  x = 0,  y = -12,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/ho_mode_name_plate.png',  width = 238,  height = 58,  },
		{ name = 'mg_mode_name_plate',  entityType = 'SpriteEntity',  parentName = 'panel_mode_name_plate_anchor',  x = 0,  y = -12,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/mg_mode_name_plate.png',  width = 238,  height = 58,  },
		{ name = 'left_plate',  entityType = 'SpriteEntity',  parentName = 'panel_background',  x = -415,  y = -12,  order = 1,  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 279, y = 47},  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/left_plate.png',  width = 388,  height = 100,  },
		{ name = 'plate_ring_left',  entityType = 'SpriteEntity',  parentName = 'left_plate',  x = 26,  y = -9,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/plate_ring.png',  width = 54,  height = 68,  },
		{ name = 'bttn_clock',  entityType = 'ButtonEntity',  parentName = 'plate_ring_left',  x = -2,  y = 10,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_clock.png',  text = '',  },
		{ name = 'right_plate',  entityType = 'SpriteEntity',  parentName = 'panel_background',  x = 415,  y = -12,  order = 1,  editingLocked = false,  treeItemIsExpanded = true,  hotSpot = {x = 99, y = 47},  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/right_plate.png',  width = 386,  height = 100,  },
		{ name = 'bttn_magnifying_glass_on',  entityType = 'ButtonEntity',  parentName = 'right_plate',  x = -23,  y = -7,  order = 2,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_magnifying_glass_on.png',  text = '',  activeRectX = 50,  activeRectY = 50,  },
		{ name = 'bttn_magnifying_glass_off',  entityType = 'ButtonEntity',  parentName = 'right_plate',  x = -23,  y = -7,  order = 2,  isVisible = false,  isRespondable = false,  isActive = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_magnifying_glass_off.png',  text = '',  activeRectX = 50,  activeRectY = 50,  },
		{ name = 'plate_ring_right',  entityType = 'SpriteEntity',  parentName = 'right_plate',  x = -14,  y = -9,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/plate_ring.png',  width = 54,  height = 68,  },
		{ name = 'bttn_lock_on',  entityType = 'ButtonEntity',  parentName = 'plate_ring_right',  x = -1,  y = 3,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_lock_on.png',  text = '',  activeRectX = 50,  activeRectY = 50,  },
		{ name = 'bttn_lock_off',  entityType = 'ButtonEntity',  parentName = 'plate_ring_right',  x = -1,  y = 3,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_lock_off.png',  text = '',  activeRectX = 50,  activeRectY = 50,  },
		{ name = 'panel_background_transparant',  entityType = 'SpriteEntity',  parentName = 'anchor_bottom_panel',  x = 0,  y = 0,  order = 0,  scaleX = 2,  scaleY = 1,  color = {r = 1, g = 1, b = 1, a = 0.4},  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/panel_background_transparant.png',  width = 1028,  height = 80,  },
		{ name = 'bttn_phone',  entityType = 'ButtonEntity',  parentName = 'anchor_bottom_panel',  x = -469,  y = -6,  order = 2,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Buttons/bttn_phone.png',  text = '',  activeRectX = 56,  activeRectY = 75,  },
		{ name = 'message_display',  entityType = 'SpriteEntity',  parentName = 'bttn_phone',  x = 1,  y = -2,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/message_display.png',  width = 55,  height = 73,  },
		{ name = 'message',  entityType = 'SpriteEntity',  parentName = 'message_display',  x = -1,  y = -2,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/message.png',  width = 48,  height = 42,  },
		{ name = 'bottom_black_bar',  entityType = 'SpriteEntity',  parentName = 'anchor_all_panels',  x = 512,  y = 734,  order = 3,  isRespondable = false,  opacity = 0,  scaleX = 2,  scaleY = 1,  color = {r = 1, g = 1, b = 1, a = 0.235294},  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Layers/black_bar.png',  width = 1028,  height = 80,  },
		{ name = 'area_take_ringing_phone',  entityType = 'SpriteEntity',  parentName = 'anchor_all_panels',  x = 512,  y = 384,  order = 0,  color = {r = 1, g = 1, b = 1, a = 0.00392157},  editingLocked = false,  treeItemIsExpanded = true,  width = 300,  height = 500,  },
		{ name = 'ph_vertical',  entityType = 'SpriteEntity',  parentName = 'area_take_ringing_phone',  x = 0,  y = 0,  order = 0,  isRespondable = false,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_vertical.png',  width = 266,  height = 484,  },
		{ name = 'ph_attrition',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = -1,  y = 2,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_attrition.png',  width = 208,  height = 396,  },
		{ name = 'ph_father',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = 0,  y = -74,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_father.png',  width = 180,  height = 210,  },
		{ name = 'ph_strip',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = 0,  y = 79,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_strip.png',  width = 208,  height = 52,  },
		{ name = 'ph_label_txt',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = -1,  y = 77,  order = 0,  editingLocked = false,  treeItemIsExpanded = true,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_label_txt.png',  width = 122,  height = 34,  },
		{ name = 'ph_hotspot',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = -26,  y = 1,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_hotspot.png',  width = 154,  height = 410,  },
		{ name = 'ph_answer_button',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = 0,  y = 150,  order = 0,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/GUI/ControlsPanel/Phone_vertical/ph_answer_button.png',  width = 102,  height = 28,  },
		{ name = 'fake_bttn_close',  entityType = 'SpriteEntity',  parentName = 'ph_vertical',  x = 87,  y = 212,  order = 0,  angle = 90,  scale = 0.5,  editingLocked = false,  treeItemIsExpanded = false,  texturePath = 'Data/Textures/Screens/Phone/fake_bttn_close.png',  width = 25,  height = 25,  },
	}
	return objects
end
