--[[
	Sets the new view, destructing any previous view if it exists, and then creating the specified
	new view.
]]

function UIController.setView(view, ...)
	coroutine.wrap(
		function(...)
			if not views[view] then
				Logger.warn("Tried to set UIController view to ", view, ", but it does not exist!")
				return
			end

			if currentView then
				currentView.exit()
			end

			currentView = views[view]
			currentView.enter(...)
		end
	)(...)
end
