-- окно кредитсов
credits_window_dialog = {}
credits_window_dialog._actions = {}

function credits_window_dialog.Show(_window)
    local app = sf.core.g_Application			
	local dialog = sf.gui.CWindow()
	dialog.Load(g_App.GetSettings().GetChild("GUI", false).GetChildByAttribute("window", "id", "credits_dialog", true),
		g_App.GetSettings().GetChild("GUITemplates", false))

	dialog.UpdateLayout()
    local parent_window_size = _window.GetSize()
	dialog.SetOffset((parent_window_size.X - dialog.GetSize().X)/2, (parent_window_size.Y - dialog.GetSize().Y)/2)

	if not _no_effect then
		s11.AddShowEffectToWidget(dialog, misc.hide_window_delay, misc.show_window_delay, misc.shift_before_hide, _window)
	end
	credits_window_dialog._window = dialog
	credits_window_dialog._parent = _window
	_window.AddChildWindow(dialog)	
	
	dialog = nil
	collectgarbage()
end

function credits_window_dialog.DoDraw(_this, _renderer)
end

function credits_window_dialog.DoUpdate(_this)
end

function credits_window_dialog.OnChar(_this, _char, _keyboard_state, _state, _broadcast)
	return _this.SuperOnChar(_char, _keyboard_state, _state, _broadcast)
end

function credits_window_dialog.OnKeyDown(_this, _key, _keyboard_state, _state, _broadcast)
	if _this.SuperOnKeyDown( _key, _keyboard_state, _state, _broadcast) then
      return true
    end
    return false
end

function credits_window_dialog.OnKeyUp(_this, _key, _keyboard_state, _state, _broadcast)
	return _this.SuperOnKeyUp( _key, _keyboard_state, _state, _broadcast)
end

function credits_window_dialog.OnMouseMove(_this, _pos, _state, _broadcast)
	return _this.SuperOnMouseMove( _pos, _state, _broadcast) 
end

function credits_window_dialog.OnMouseDown(_this, _pos, _button, _state, _broadcast)
	return _this.SuperOnMouseDown( _pos, _button, _state, _broadcast) 
end

function credits_window_dialog.OnMouseUp(_this, _pos, _button, _state, _broadcast)
	return _this.SuperOnMouseUp( _pos, _button, _state, _broadcast) 
end

function credits_window_dialog.OnDoubleClick(_this, _pos, _state, _broadcast)
	return _this.SuperOnDoubleClick( _pos, _state, _broadcast) 
end

function credits_window_dialog.OnMouseWheel(_this, _pos, _delta, _state, _broadcast)
	return _this.SuperOnMouseWheel( _pos, _delta, _state, _broadcast)
end

function credits_window_dialog.OnChildAction(_this, _action, _child)
	if not _child then return end
	local handler = credits_window_dialog._actions[_child.GetId().c_str()]
	if handler then handler = handler[_action.c_str()] end
	if handler then handler(_this, _child) end
end
	
credits_window_dialog._actions.ok = 
{
	pressed = function(_window) 
		s11.AddHideEffectToWidget(credits_window_dialog._window, 300, 300, 300, credits_window_dialog._parent)	
	end
}
