diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 339 | ||||
-rw-r--r-- | src/common/profile.cpp | 26 | ||||
-rw-r--r-- | src/common/profile.h | 7 |
3 files changed, 200 insertions, 172 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 12171f3..fbbaa37 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,178 +59,197 @@ if(PLATFORM_WINDOWS) endif() # Source files -set(SOURCES -app/app.cpp -app/gamedata.cpp -app/main.cpp -app/pausemanager.cpp -app/system.cpp -app/${SYSTEM_CPP_MODULE} -app/system_other.cpp -common/event.cpp -common/image.cpp -common/iman.cpp -common/logger.cpp -common/misc.cpp -common/profile.cpp -common/restext.cpp -common/stringutils.cpp -graphics/core/color.cpp -graphics/engine/camera.cpp -graphics/engine/cloud.cpp -graphics/engine/engine.cpp -graphics/engine/lightman.cpp -graphics/engine/lightning.cpp -graphics/engine/modelfile.cpp -graphics/engine/modelmanager.cpp -graphics/engine/particle.cpp -graphics/engine/planet.cpp -graphics/engine/pyro.cpp -graphics/engine/terrain.cpp -graphics/engine/text.cpp -graphics/engine/water.cpp -graphics/opengl/gldevice.cpp -object/auto/auto.cpp -object/auto/autobase.cpp -object/auto/autoconvert.cpp -object/auto/autoderrick.cpp -object/auto/autodestroyer.cpp -object/auto/autoegg.cpp -object/auto/autoenergy.cpp -object/auto/autofactory.cpp -object/auto/autoflag.cpp -object/auto/autohuston.cpp -object/auto/autoinfo.cpp -object/auto/autojostle.cpp -object/auto/autokid.cpp -object/auto/autolabo.cpp -object/auto/automush.cpp -object/auto/autonest.cpp -object/auto/autonuclear.cpp -object/auto/autopara.cpp -object/auto/autoportico.cpp -object/auto/autoradar.cpp -object/auto/autorepair.cpp -object/auto/autoresearch.cpp -object/auto/autoroot.cpp -object/auto/autosafe.cpp -object/auto/autostation.cpp -object/auto/autotower.cpp -object/brain.cpp -object/mainmovie.cpp -object/motion/motion.cpp -object/motion/motionant.cpp -object/motion/motionbee.cpp -object/motion/motiondummy.cpp -object/motion/motionhuman.cpp -object/motion/motionmother.cpp -object/motion/motionspider.cpp -object/motion/motiontoto.cpp -object/motion/motionvehicle.cpp -object/motion/motionworm.cpp -object/object.cpp -object/robotmain.cpp -object/objman.cpp -object/task/task.cpp -object/task/taskadvance.cpp -object/task/taskbuild.cpp -object/task/taskfire.cpp -object/task/taskfireant.cpp -object/task/taskflag.cpp -object/task/taskgoto.cpp -object/task/taskgungoal.cpp -object/task/taskinfo.cpp -object/task/taskmanager.cpp -object/task/taskmanip.cpp -object/task/taskpen.cpp -object/task/taskrecover.cpp -object/task/taskreset.cpp -object/task/tasksearch.cpp -object/task/taskshield.cpp -object/task/taskspiderexplo.cpp -object/task/tasktake.cpp -object/task/taskterraform.cpp -object/task/taskturn.cpp -object/task/taskwait.cpp -physics/physics.cpp -script/cbottoken.cpp -script/cmdtoken.cpp -script/script.cpp -sound/sound.cpp -ui/button.cpp -ui/check.cpp -ui/color.cpp -ui/compass.cpp -ui/control.cpp -ui/displayinfo.cpp -ui/displaytext.cpp -ui/edit.cpp -ui/editvalue.cpp -ui/gauge.cpp -ui/group.cpp -ui/image.cpp -ui/interface.cpp -ui/key.cpp -ui/label.cpp -ui/list.cpp -ui/maindialog.cpp -ui/mainmap.cpp -ui/mainshort.cpp -ui/map.cpp -ui/scroll.cpp -ui/shortcut.cpp -ui/slider.cpp -ui/studio.cpp -ui/target.cpp -ui/window.cpp -${OPENAL_SRC} -${RES_FILES} +set(BASE_SOURCES + app/app.cpp + app/gamedata.cpp + app/pausemanager.cpp + app/system.cpp + app/${SYSTEM_CPP_MODULE} + app/system_other.cpp + common/event.cpp + common/image.cpp + common/iman.cpp + common/logger.cpp + common/misc.cpp + common/profile.cpp + common/restext.cpp + common/stringutils.cpp + graphics/core/color.cpp + graphics/engine/camera.cpp + graphics/engine/cloud.cpp + graphics/engine/engine.cpp + graphics/engine/lightman.cpp + graphics/engine/lightning.cpp + graphics/engine/modelfile.cpp + graphics/engine/modelmanager.cpp + graphics/engine/particle.cpp + graphics/engine/planet.cpp + graphics/engine/pyro.cpp + graphics/engine/terrain.cpp + graphics/engine/text.cpp + graphics/engine/water.cpp + graphics/opengl/gldevice.cpp + object/auto/auto.cpp + object/auto/autobase.cpp + object/auto/autoconvert.cpp + object/auto/autoderrick.cpp + object/auto/autodestroyer.cpp + object/auto/autoegg.cpp + object/auto/autoenergy.cpp + object/auto/autofactory.cpp + object/auto/autoflag.cpp + object/auto/autohuston.cpp + object/auto/autoinfo.cpp + object/auto/autojostle.cpp + object/auto/autokid.cpp + object/auto/autolabo.cpp + object/auto/automush.cpp + object/auto/autonest.cpp + object/auto/autonuclear.cpp + object/auto/autopara.cpp + object/auto/autoportico.cpp + object/auto/autoradar.cpp + object/auto/autorepair.cpp + object/auto/autoresearch.cpp + object/auto/autoroot.cpp + object/auto/autosafe.cpp + object/auto/autostation.cpp + object/auto/autotower.cpp + object/brain.cpp + object/mainmovie.cpp + object/motion/motion.cpp + object/motion/motionant.cpp + object/motion/motionbee.cpp + object/motion/motiondummy.cpp + object/motion/motionhuman.cpp + object/motion/motionmother.cpp + object/motion/motionspider.cpp + object/motion/motiontoto.cpp + object/motion/motionvehicle.cpp + object/motion/motionworm.cpp + object/object.cpp + object/robotmain.cpp + object/objman.cpp + object/task/task.cpp + object/task/taskadvance.cpp + object/task/taskbuild.cpp + object/task/taskfire.cpp + object/task/taskfireant.cpp + object/task/taskflag.cpp + object/task/taskgoto.cpp + object/task/taskgungoal.cpp + object/task/taskinfo.cpp + object/task/taskmanager.cpp + object/task/taskmanip.cpp + object/task/taskpen.cpp + object/task/taskrecover.cpp + object/task/taskreset.cpp + object/task/tasksearch.cpp + object/task/taskshield.cpp + object/task/taskspiderexplo.cpp + object/task/tasktake.cpp + object/task/taskterraform.cpp + object/task/taskturn.cpp + object/task/taskwait.cpp + physics/physics.cpp + script/cbottoken.cpp + script/cmdtoken.cpp + script/script.cpp + sound/sound.cpp + ui/button.cpp + ui/check.cpp + ui/color.cpp + ui/compass.cpp + ui/control.cpp + ui/displayinfo.cpp + ui/displaytext.cpp + ui/edit.cpp + ui/editvalue.cpp + ui/gauge.cpp + ui/group.cpp + ui/image.cpp + ui/interface.cpp + ui/key.cpp + ui/label.cpp + ui/list.cpp + ui/maindialog.cpp + ui/mainmap.cpp + ui/mainshort.cpp + ui/map.cpp + ui/scroll.cpp + ui/shortcut.cpp + ui/slider.cpp + ui/studio.cpp + ui/target.cpp + ui/window.cpp + ${OPENAL_SRC} + ${RES_FILES} +) + +set(MAIN_SOURCES + app/main.cpp ) +# Libraries set(LIBS -CBot -clipboard -localename -${SDL_LIBRARY} -${SDLIMAGE_LIBRARY} -${SDLTTF_LIBRARY} -${OPENGL_LIBRARY} -${PNG_LIBRARIES} -${GLEW_LIBRARY} -${Boost_LIBRARIES} -${LIBSNDFILE_LIBRARY} -${OPTIONAL_LIBS} -${PLATFORM_LIBS} + CBot + clipboard + localename + ${SDL_LIBRARY} + ${SDLIMAGE_LIBRARY} + ${SDLTTF_LIBRARY} + ${OPENGL_LIBRARY} + ${PNG_LIBRARIES} + ${GLEW_LIBRARY} + ${Boost_LIBRARIES} + ${LIBSNDFILE_LIBRARY} + ${OPTIONAL_LIBS} + ${PLATFORM_LIBS} +) + +set(COLOBOT_LIBS ${LIBS} PARENT_SCOPE) + + +# Includes +set(LOCAL_INCLUDES + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_BINARY_DIR} ) -# Local -include_directories( -. -.. -${CMAKE_CURRENT_BINARY_DIR} +set(SYSTEM_INCLUDES + ${SDL_INCLUDE_DIR} + ${SDLIMAGE_INCLUDE_DIR} + ${SDLTTF_INCLUDE_DIR} + ${PNG_INCLUDE_DIRS} + ${GLEW_INCLUDE_PATH} + ${Boost_INCLUDE_DIRS} + ${LIBSNDFILE_INCLUDE_DIR} + ${LOCALENAME_INCLUDE_DIR} + ${OPTIONAL_INCLUDE_DIRS} + ${CLIPBOARD_INCLUDE_DIR} ) -# System -include_directories( -SYSTEM -${SDL_INCLUDE_DIR} -${SDLIMAGE_INCLUDE_DIR} -${SDLTTF_INCLUDE_DIR} -${PNG_INCLUDE_DIRS} -${GLEW_INCLUDE_PATH} -${Boost_INCLUDE_DIRS} -${LIBSNDFILE_INCLUDE_DIR} -${LOCALENAME_INCLUDE_DIR} -${OPTIONAL_INCLUDE_DIRS} -${CLIPBOARD_INCLUDE_DIR} +set(COLOBOT_LOCAL_INCLUDES ${LOCAL_INCLUDES} PARENT_SCOPE) +set(COLOBOT_SYSTEM_INCLUDES ${SYSTEM_INCLUDES} PARENT_SCOPE) + +include_directories(${LOCAL_INCLUDES}) +include_directories(SYSTEM ${SYSTEM_INCLUDES}) + + +# Link directories +link_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/CBot ) -link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot) -add_executable(colobot ${SOURCES}) +# Targets + +add_library(colobotbase STATIC ${BASE_SOURCES}) -target_link_libraries(colobot ${LIBS}) +add_executable(colobot ${MAIN_SOURCES}) +target_link_libraries(colobot colobotbase ${LIBS}) install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR}) if(NOT CBOT_STATIC) diff --git a/src/common/profile.cpp b/src/common/profile.cpp index ee3e873..a63a772 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -31,8 +31,9 @@ template<> CProfile* CSingleton<CProfile>::m_instance = nullptr; namespace bp = boost::property_tree; -CProfile::CProfile() : - m_profileNeedSave(false) +CProfile::CProfile() + : m_profileNeedSave(false) + , m_useLocalDirectory(false) { } @@ -42,16 +43,21 @@ CProfile::~CProfile() SaveCurrentDirectory(); } +void CProfile::SetUseLocalDirectory(bool useLocalDirectory) +{ + m_useLocalDirectory = useLocalDirectory; +} + +std::string CProfile::GetIniFileLocation() +{ + return m_useLocalDirectory ? "colobot.ini" : GetSystemUtils()->GetProfileFileLocation(); +} bool CProfile::InitCurrentDirectory() { try { - #if DEV_BUILD - bp::ini_parser::read_ini("colobot.ini", m_propertyTree); - #else - bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #endif + bp::ini_parser::read_ini(GetIniFileLocation(), m_propertyTree); } catch (std::exception & e) { @@ -67,11 +73,7 @@ bool CProfile::SaveCurrentDirectory() { try { - #if DEV_BUILD - bp::ini_parser::write_ini("colobot.ini", m_propertyTree); - #else - bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #endif + bp::ini_parser::write_ini(GetIniFileLocation(), m_propertyTree); } catch (std::exception & e) { diff --git a/src/common/profile.h b/src/common/profile.h index f084ece..52f9f15 100644 --- a/src/common/profile.h +++ b/src/common/profile.h @@ -45,6 +45,9 @@ public: CProfile(); virtual ~CProfile(); + /** Set flag to force using ini file from local directory */ + void SetUseLocalDirectory(bool useLocalDirectory); + /** Loads colobot.ini from current directory * \return return true on success */ @@ -130,9 +133,13 @@ public: bool CopyFileToTemp(std::string filename); private: + std::string GetIniFileLocation(); + +private: boost::property_tree::ptree m_propertyTree; bool m_profileNeedSave; std::string m_userDirectory; + bool m_useLocalDirectory; }; //! Global function to get profile instance |