Index: code/branches/buildsystem2/bin/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/bin/CMakeLists.txt	(revision 2589)
+++ code/branches/buildsystem2/bin/CMakeLists.txt	(revision 2590)
@@ -1,3 +1,4 @@
-SET(CONFIG_FILES
+SET(COMMON_CONFIG_FILES
+  orxonox.ini
   def_keybindings.ini
   def_masterKeybindings.ini
@@ -11,28 +12,55 @@
   # OGRE can't find fonts to display config screen on Tardis,
   # so providing default config file here (bug).
-  SET(CONFIG_FILES ${CONFIG_FILES}
-    linux/run-script
-    tardis/orxonox.ini
-    tardis/ogre.cfg
-  )
-
-ELSEIF(UNIX)
-  SET(CONFIG_FILES ${CONFIG_FILES}
-    linux/run-script
-    linux/orxonox.ini
-  )
+  SET(ADDITIONAL_CONFIG_FILES "ogre.cfg")
 ENDIF(TARDIS)
 
-IF(MINGW)
-  SET(CONFIG_FILES ${CONFIG_FILES}
-    "mingw/orxonox.ini"
-    "mingw/orxonox.bat"
-  )
-ENDIF(MINGW)
+SET(CONFIG_FILES ${COMMON_CONFIG_FILES} ${ADDITIONAL_CONFIG_FILES})
 
-FOREACH(_FILE ${CONFIG_FILES})
-  GET_FILENAME_COMPONENT(_filename ${_FILE} NAME)
-  IF (NOT EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_filename})
-    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${_FILE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_filename} COPYONLY)
-  ENDIF (NOT EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_filename})
-ENDFOREACH(_FILE)
+# Copy config files to all Visual Studio output directories
+IF(CMAKE_CONFIGURATION_TYPES)
+  SET(BUILD_CONFIGS ${CMAKE_CONFIGURATION_TYPES})
+ELSE(CMAKE_CONFIGURATION_TYPES)
+  SET(CONFIG_OUT_PATHS_REL ".")
+  SET(BUILD_CONFIGS ${CMAKE_BUILD_TYPE})
+ENDIF(CMAKE_CONFIGURATION_TYPES)
+
+FOREACH(_build_config ${BUILD_CONFIGS})
+  FOREACH(_file_name ${CONFIG_FILES})
+    # Is there an extra file in bin/Debug or bin/Release?
+    IF(${_build_config} MATCHES "Rel")
+      SET(_build_config_short "Release")
+    ELSE(${_build_config} MATCHES "Rel")
+      SET(_build_config_short "Debug")
+    ENDIF(${_build_config} MATCHES "Rel")
+    IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name})
+      SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name})
+    ELSE(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name})
+      SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file_name})
+    ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name})
+
+    # Copy to the folder named like the build config for Visual Studio
+    IF(CMAKE_CONFIGURATION_TYPES)
+      SET(_out_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_build_config}/${_file_name})
+    ELSE(CMAKE_CONFIGURATION_TYPES)
+      SET(_out_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_file_name})
+    ENDIF(CMAKE_CONFIGURATION_TYPES)
+    # Only copy if target file doesn't exist. This may result in problems but
+    # otherwise we might delete the a user's config
+    IF (NOT EXISTS ${_out_file})
+      CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY)
+    ENDIF (NOT EXISTS ${_out_file})
+  ENDFOREACH(_file_name)
+ENDFOREACH(_build_config)
+
+# Create a run script for both Windows and Linux in the source root path if
+# CMake is not used to create multi-configuration project files
+IF(NOT CMAKE_CONFIGURATION_TYPES)
+  IF(WIN32)
+    SET(RUN_SCRIPT ${ADDITIONAL_CONFIG_FILES} "run.bat")
+  ELSE(UNIX)
+    SET(RUN_SCRIPT ${ADDITIONAL_CONFIG_FILES} "run")
+  ENDIF(WIN32)
+  IF (NOT EXISTS ${CMAKE_SOURCE_DIR}/${RUN_SCRIPT})
+    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${RUN_SCRIPT} ${CMAKE_SOURCE_DIR}/${RUN_SCRIPT} @ONLY)
+  ENDIF (NOT EXISTS ${CMAKE_SOURCE_DIR}/${RUN_SCRIPT})
+ENDIF(NOT CMAKE_CONFIGURATION_TYPES)
Index: code/branches/buildsystem2/bin/Debug/orxonox.ini
===================================================================
--- code/branches/buildsystem2/bin/Debug/orxonox.ini	(revision 2590)
+++ code/branches/buildsystem2/bin/Debug/orxonox.ini	(revision 2590)
@@ -0,0 +1,11 @@
+[Settings]
+dataPath_ = @ORXONOX_MEDIA_DIRECTORY@
+
+[GSGraphics]
+ogrePluginsFolder_ = @OGRE_PLUGINS_FOLDER_DEBUG@
+ogrePlugins_ = @OGRE_PLUGINS_DEBUG@
+
+[Core]
+softDebugLevelConsole_=3
+softDebugLevelLogfile_=4
+softDebugLevelShell_=2
Index: code/branches/buildsystem2/bin/Release/orxonox.ini
===================================================================
--- code/branches/buildsystem2/bin/Release/orxonox.ini	(revision 2590)
+++ code/branches/buildsystem2/bin/Release/orxonox.ini	(revision 2590)
@@ -0,0 +1,11 @@
+[Settings]
+dataPath_ = @ORXONOX_MEDIA_DIRECTORY@
+
+[GSGraphics]
+ogrePluginsFolder_ = @OGRE_PLUGINS_FOLDER_RELEASE@
+ogrePlugins_ = @OGRE_PLUGINS_RELEASE@
+
+[Core]
+softDebugLevelConsole_=1
+softDebugLevelLogfile_=3
+softDebugLevelShell_=1
Index: code/branches/buildsystem2/bin/ogre.cfg
===================================================================
--- code/branches/buildsystem2/bin/ogre.cfg	(revision 2590)
+++ code/branches/buildsystem2/bin/ogre.cfg	(revision 2590)
@@ -0,0 +1,7 @@
+Render System=OpenGL Rendering Subsystem
+
+[OpenGL Rendering Subsystem]
+FSAA=0
+Full Screen=No
+RTT Preferred Mode=FBO
+Video Mode=800 x 600
Index: code/branches/buildsystem2/bin/run
===================================================================
--- code/branches/buildsystem2/bin/run	(revision 2590)
+++ code/branches/buildsystem2/bin/run	(revision 2590)
@@ -0,0 +1,4 @@
+#!/bin/sh
+# convenience script for starting orxonox on Linux
+
+cd @EXECUTABLE_OUTPUT_PATH@ && exec ./@ORXONOX_EXECUTABLE_NAME@ $@
Index: code/branches/buildsystem2/bin/run.bat
===================================================================
--- code/branches/buildsystem2/bin/run.bat	(revision 2590)
+++ code/branches/buildsystem2/bin/run.bat	(revision 2590)
@@ -0,0 +1,4 @@
+title @PROJECT_NAME@
+path @ORXONOX_LIBRARY_BIN_DIR@;%path%
+@ORXONOX_EXECUTABLE_NAME@
+pause
Index: code/branches/buildsystem2/cmake/ConfigMSVC.cmake
===================================================================
--- code/branches/buildsystem2/cmake/ConfigMSVC.cmake	(revision 2589)
+++ code/branches/buildsystem2/cmake/ConfigMSVC.cmake	(revision 2590)
@@ -44,4 +44,5 @@
     MESSAGE(FATAL_ERROR "Could not find dependency directory for the Visual Studio libraries")
   ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/dependencies/orxonox_vc8)
+  SET(ORXONOX_LIBRARY_BIN_DIR ${MSVC_LIBRARY_DIR}/bin)
 
   # Set variables for the include directories and the libraries
@@ -56,5 +57,5 @@
   SET(ENV{OPENALDIR}         ${MSVC_LIBRARY_DIR}/openal-1.1)
   SET(ENV{LUA_DIR}           ${MSVC_LIBRARY_DIR}/lua-5.1.3)
-  SET(ENV{OGRE_HOME}        "${MSVC_LIBRARY_DIR}/ogre-1.4.9;${MSVC_LIBRARY_DIR}/bin")
+  SET(ENV{OGRE_HOME}        "${MSVC_LIBRARY_DIR}/ogre-1.4.9;${ORXONOX_LIBRARY_BIN_DIR}")
   SET(TCL_INCLUDE_PATH       ${MSVC_LIBRARY_DIR}/tcl-8.5.2/include)
   SET(TCL_LIBRARY            ${MSVC_LIBRARY_DIR}/tcl-8.5.2/lib/tcl85t.lib)
@@ -126,4 +127,4 @@
 
   # Set tolua working directory because lua.dll is not where tolua is
-  SET(TOLUA_PARSER_WORKING_DIRECTORY ${MSVC_LIBRARY_DIR}/bin)
+  SET(TOLUA_PARSER_WORKING_DIRECTORY ${ORXONOX_LIBRARY_BIN_DIR})
 ENDIF (MSVC)
Index: code/branches/buildsystem2/cmake/ConfigMinGW.cmake
===================================================================
--- code/branches/buildsystem2/cmake/ConfigMinGW.cmake	(revision 2589)
+++ code/branches/buildsystem2/cmake/ConfigMinGW.cmake	(revision 2590)
@@ -42,5 +42,5 @@
     MESSAGE(FATAL_ERROR "Could not find dependency directory for the MinGW libraries")
   ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/libs)
-
+  SET(ORXONOX_LIBRARY_BIN_DIR ${MINGW_LIBRARY_DIR})
 
   # Note: When setting ENV${} variables, make sure to use quotes when
Index: code/branches/buildsystem2/cmake/ConfigPlatforms.cmake
===================================================================
--- code/branches/buildsystem2/cmake/ConfigPlatforms.cmake	(revision 2589)
+++ code/branches/buildsystem2/cmake/ConfigPlatforms.cmake	(revision 2590)
@@ -34,4 +34,6 @@
 # When searching for debug libraries, this is appended to the libarary name
 SET(LIBRARY_DEBUG_POSTFIX "_d")
+# Sets where to find the binary directory of external libraries
+SET(ORXONOX_LIBRARY_BIN_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 # Working directory for the tolua parser. Adjust for windows because lua.dll has to be there!
 SET(TOLUA_PARSER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
Index: code/branches/buildsystem2/run
===================================================================
--- code/branches/buildsystem2/run	(revision 2589)
+++ 	(revision )
@@ -1,4 +1,0 @@
-#!/bin/sh
-# convenience script for starting orxonox
-
-cd build/bin && exec ./run-script $@
Index: code/branches/buildsystem2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2589)
+++ code/branches/buildsystem2/src/orxonox/CMakeLists.txt	(revision 2590)
@@ -25,4 +25,8 @@
 
 ADD_EXECUTABLE(orxonox ${ORXONOX_SRC_FILES})
+GET_TARGET_PROPERTY(_exec_loc orxonox LOCATION)
+GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME)
+SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE STRING "")
+MARK_AS_ADVANCED(ORXONOX_EXECUTABLE_NAME)
 
 IF(NETWORKTRAFFIC_TESTING_ENABLED)
@@ -52,4 +56,20 @@
 )
 
+# When using Visual Studio we want to use the output directory as working
+# directory and we also want to specify where the external dlls
+# (lua, ogre, etc.) are. The problem hereby is that these information cannot
+# be specified in CMake because they are not stored in the actual project file.
+# This workaround will create a configured *.vcproj.user file that holds the
+# right values. When starting the solution for the first time,
+# these get written to the *vcproj.yourPCname.yourname.user
+IF(MSVC)
+  IF(CMAKE_CL_64)
+    SET(MSVC_PLATFORM "x64")
+  ELSE(CMAKE_CL_64)
+    SET(MSVC_PLATFORM "Win32")
+  ENDIF(CMAKE_CL_64)
+  CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox.vcproj.user" "${CMAKE_CURRENT_BINARY_DIR}/orxonox.vcproj.user")
+ENDIF(MSVC)
+
 IF (NOT WIN32)
   INSTALL(TARGETS orxonox RUNTIME DESTINATION bin)
Index: code/branches/buildsystem2/src/orxonox/orxonox.vcproj.user
===================================================================
--- code/branches/buildsystem2/src/orxonox/orxonox.vcproj.user	(revision 2590)
+++ code/branches/buildsystem2/src/orxonox/orxonox.vcproj.user	(revision 2590)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+		<Configuration
+			Name="MinSizeRel|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+		<Configuration
+			Name="RelWithDebInfo|${MSVC_PLATFORM}"
+			>
+			<DebugSettings
+				WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+				Environment="Path=${ORXONOX_LIBRARY_BIN_DIR}"
+				EnvironmentMerge="true"
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>
Index: code/branches/buildsystem2/visual_studio/vc8/bin/debug/orxonox.ini
===================================================================
--- code/branches/buildsystem2/visual_studio/vc8/bin/debug/orxonox.ini	(revision 2590)
+++ code/branches/buildsystem2/visual_studio/vc8/bin/debug/orxonox.ini	(revision 2590)
@@ -0,0 +1,11 @@
+[Settings]
+dataPath_=../../../../media/
+
+[GSGraphics]
+ogrePluginsFolder_=.
+ogrePlugins_=RenderSystem_Direct3D9_d, RenderSystem_GL_d, Plugin_ParticleFX_d, Plugin_CgProgramManager_d #, Plugin_BSPSceneManager_d, Plugin_OctreeSceneManager_d
+
+[Core]
+softDebugLevelConsole_=3
+softDebugLevelLogfile_=4
+softDebugLevelShell_=3
Index: code/branches/buildsystem2/visual_studio/vc8/bin/release/orxonox.ini
===================================================================
--- code/branches/buildsystem2/visual_studio/vc8/bin/release/orxonox.ini	(revision 2590)
+++ code/branches/buildsystem2/visual_studio/vc8/bin/release/orxonox.ini	(revision 2590)
@@ -0,0 +1,6 @@
+[Settings]
+dataPath_=../../../../media/
+
+[GSGraphics]
+ogrePluginsFolder_ = .
+ogrePlugins_ = RenderSystem_Direct3D9, RenderSystem_GL, Plugin_ParticleFX, Plugin_CgProgramManager #, Plugin_BSPSceneManager, Plugin_OctreeSceneManager
Index: code/branches/buildsystem2/visual_studio/vc8/orxonox.vcproj
===================================================================
--- code/branches/buildsystem2/visual_studio/vc8/orxonox.vcproj	(revision 2589)
+++ code/branches/buildsystem2/visual_studio/vc8/orxonox.vcproj	(revision 2590)
@@ -77,5 +77,5 @@
 				Name="VCPostBuildEventTool"
 				Description="Copying default configuration files..."
-				CommandLine="for %%a in ($(RootDir)\bin\msvc\$(SolutionName)\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\bin\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;"
+				CommandLine="for %%a in ($(SolutionDir)\bin\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\bin\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;"
 			/>
 		</Configuration>
@@ -142,5 +142,5 @@
 				Name="VCPostBuildEventTool"
 				Description="Copying default configuration files..."
-				CommandLine="for %%a in ($(RootDir)\bin\msvc\$(SolutionName)\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\bin\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;"
+				CommandLine="for %%a in ($(SolutionDir)\bin\$(ConfigurationName)\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;for %%a in ($(RootDir)\bin\*) do replace %%a $(OutDir). /A &gt;nul&#x0D;&#x0A;"
 			/>
 		</Configuration>
