credits_window = credits_window or {}
credits_window.actions = credits_window.actions or {}
credits_window.object = nil

function credits_window.Show(_window)
	local dialog = sf.gui.CWindow()
	dialog.Load(g_App.GetSettings().GetChild("GUI", false).GetChildByAttribute("window", "id", "credits_window", true),
		g_App.GetSettings().GetChild("GUITemplates", false))
	dialog.UpdateLayout()
	dialog.SetOffset((_window.GetSize().X - dialog.GetSize().X)/2, (_window.GetSize().Y - dialog.GetSize().Y)/2)

    __cast(_window, sf.gui.CBaseWindow).AddChildWindow(sf.gui.CBaseWindowPtrT(dialog))
end

function credits_window.DoDraw(_this, _renderer) 
    return false 
end

function credits_window.DoUpdate(_this) 
    return false 
end


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

function credits_window.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.OnKeyUp(_this, _key, _keyboard_state, _state, _broadcast)
	return _this.SuperOnKeyUp( _key, _keyboard_state, _state, _broadcast)
end

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

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

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

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

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

function credits_window.OnChildAction(_this, _action, _child)
	if not _child then return end
	local handler = credits_window.actions[_child.GetId().c_str()]
	if handler then handler = handler[_action.c_str()] end
	if handler then handler(_this, _child) end
end
	
credits_window.actions.ok = 
{
	pressed = function(_window) 
		_window.AddFlags(_window.FlagDead)
	end
}
