Merge branch 'dev-desktop-file' of git://github.com/OdyX/colobot
commit
fb13c0f219
|
@ -1,9 +1,6 @@
|
|||
# Ignore the documentation folder
|
||||
/doc
|
||||
|
||||
# We don't want anyone to checkin /data folder
|
||||
/data
|
||||
|
||||
# Ignore local data
|
||||
/colobot.ini
|
||||
/savegame
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "data"]
|
||||
path = data
|
||||
url = git://github.com/colobot/colobot-data.git
|
|
@ -0,0 +1,8 @@
|
|||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
script: cmake . -DCMAKE_VERBOSE_MAKEFILE=ON && make all doc test
|
||||
before_install:
|
||||
- git submodule update --init --recursive
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq --no-install-recommends libgl1-mesa-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libpng12-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev google-mock libgtest-dev doxygen graphviz po4a librsvg2-bin
|
|
@ -16,12 +16,15 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
|
|||
##
|
||||
|
||||
# Global build type
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif()
|
||||
|
||||
# Global compile flags
|
||||
# These are specific to GCC/MinGW; for other compilers, change as necessary
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
# Asserts can be enabled/disabled regardless of build type
|
||||
option(ASSERTS "Enable assert()s" ON)
|
||||
|
@ -32,6 +35,11 @@ option(TESTS "Enable tests" ON)
|
|||
# CBot can also be a static library
|
||||
option(CBOT_STATIC "Build CBot as static libary" OFF)
|
||||
|
||||
# Doxygen docs are optional for installation
|
||||
option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
|
||||
|
||||
# Build openal sound support
|
||||
option(OPENAL_SOUND "Build openal sound support" OFF)
|
||||
|
||||
##
|
||||
# Required packages
|
||||
|
@ -42,7 +50,7 @@ find_package(SDL 1.2.10 REQUIRED)
|
|||
find_package(SDL_image 1.2 REQUIRED)
|
||||
find_package(SDL_ttf 2.0 REQUIRED)
|
||||
find_package(PNG 1.2 REQUIRED)
|
||||
find_package(LTDL 2.4.2 REQUIRED)
|
||||
find_package(Gettext REQUIRED)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
|
@ -123,6 +131,21 @@ else()
|
|||
endif()
|
||||
|
||||
|
||||
##
|
||||
# Doxygen docs
|
||||
##
|
||||
|
||||
find_package(Doxygen)
|
||||
|
||||
if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
add_custom_target(doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Doxygen" VERBATIM)
|
||||
endif()
|
||||
|
||||
|
||||
##
|
||||
# Targets
|
||||
##
|
||||
|
@ -159,8 +182,27 @@ if(${TESTS})
|
|||
|
||||
endif()
|
||||
|
||||
# Installation paths defined before compiling sources
|
||||
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/games CACHE PATH "Colobot binary directory")
|
||||
set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/games/colobot CACHE PATH "Colobot shared data directory")
|
||||
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/colobot CACHE PATH "Colobot libraries directory")
|
||||
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/share/doc/colobot CACHE PATH "Colobot documentation directory")
|
||||
set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/share/locale CACHE PATH "Colobot translations directory")
|
||||
|
||||
# Subdirectory with sources
|
||||
add_subdirectory(src bin)
|
||||
|
||||
# TODO: provide data files as git submodule and setup correct data path
|
||||
install_files(/share/games/colobot ../data)
|
||||
|
||||
##
|
||||
# Installation
|
||||
##
|
||||
|
||||
file(GLOB DATA_FILES "data/*")
|
||||
|
||||
# Data
|
||||
install(DIRECTORY data/ DESTINATION ${COLOBOT_INSTALL_DATA_DIR})
|
||||
|
||||
# Documentation
|
||||
if(INSTALL_DOCS AND DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/ DESTINATION ${COLOBOT_INSTALL_DOC_DIR} OPTIONAL)
|
||||
endif()
|
||||
|
|
|
@ -665,8 +665,8 @@ WARN_LOGFILE =
|
|||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = "src" \
|
||||
"src/CBot"
|
||||
INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/src" \
|
||||
"@CMAKE_CURRENT_SOURCE_DIR@/src/CBot"
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
|
|
@ -1,30 +0,0 @@
|
|||
# Find the native LTDL includes and library
|
||||
# Copied verbatim from
|
||||
# http://code.metager.de/source/xref/hshannover/trust/tnc-fhh/shared/cmake_modules/FindLTDL.cmake
|
||||
# The above version was under GPL-2, this one is under GPL-3, for consistency
|
||||
# with the rest of the colobot project.
|
||||
#
|
||||
# This module defines
|
||||
# LTDL_INCLUDE_DIR, where to find ltdl.h, etc.
|
||||
# LTDL_LIBRARY, where to find the LTDL library.
|
||||
# LTDL_FOUND, If false, do not try to use LTDL.
|
||||
|
||||
FIND_PATH(LTDL_INCLUDE_DIR ltdl.h)
|
||||
|
||||
FIND_LIBRARY(LTDL_LIBRARY ltdl)
|
||||
|
||||
IF (LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
|
||||
SET(LTDL_FOUND TRUE)
|
||||
ELSE(LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
|
||||
SET(LTDL_FOUND FALSE)
|
||||
ENDIF (LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
|
||||
|
||||
IF (LTDL_FOUND)
|
||||
IF (NOT LTDL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found LTDL: ${LTDL_LIBRARY}")
|
||||
ENDIF (NOT LTDL_FIND_QUIETLY)
|
||||
ELSE (LTDL_FOUND)
|
||||
IF (LTDL_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find LTDL")
|
||||
ENDIF (LTDL_FIND_REQUIRED)
|
||||
ENDIF (LTDL_FOUND)
|
|
@ -18,11 +18,11 @@ if((${CMAKE_CROSSCOMPILING}) AND (DEFINED MSYS))
|
|||
${CMAKE_FIND_ROOT_PATH}/lib/libiconv.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libglew32s.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libfreetype.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libltdl.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libopengl32.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libjpeg.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libwinmm.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libdxguid.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libbz2.a
|
||||
)
|
||||
else()
|
||||
set(MXE 0)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 6b6e5a0ab56bf42f17d969c1bd4c09185605cad6
|
|
@ -16,6 +16,5 @@ if(${CBOT_STATIC})
|
|||
add_library(CBot STATIC ${SOURCES})
|
||||
else()
|
||||
add_library(CBot SHARED ${SOURCES})
|
||||
install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR})
|
||||
endif()
|
||||
|
||||
INSTALL_TARGETS(/lib CBot)
|
||||
|
|
|
@ -3,11 +3,14 @@ cmake_minimum_required(VERSION 2.8)
|
|||
project(CBot_console C CXX)
|
||||
|
||||
# Build with debugging symbols
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
# Global compile flags
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
# Include cmake directory
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
|
||||
|
|
|
@ -6,6 +6,8 @@ add_subdirectory(tools)
|
|||
|
||||
add_subdirectory(po)
|
||||
|
||||
add_subdirectory(desktop)
|
||||
|
||||
# Tests
|
||||
if(${TESTS})
|
||||
add_subdirectory(common/test)
|
||||
|
@ -27,9 +29,24 @@ endif()
|
|||
|
||||
# Additional libraries per platform
|
||||
set(PLATFORM_LIBS "")
|
||||
set(OPENAL_LIBS "")
|
||||
|
||||
if (${OPENAL_SOUND})
|
||||
if (${MXE})
|
||||
set(OPENAL_LIBS
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libOpenAL32.a
|
||||
${CMAKE_FIND_ROOT_PATH}/lib/libalut.a
|
||||
)
|
||||
else()
|
||||
set(OPENAL_LIBS
|
||||
openal
|
||||
alut
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (${MXE}) # MXE requires special treatment
|
||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
||||
elseif (${PLATFORM_WINDOWS})
|
||||
# because it isn't included in standard linking libraries
|
||||
set(PLATFORM_LIBS "-lintl")
|
||||
|
@ -42,6 +59,15 @@ endif()
|
|||
# Configure file
|
||||
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
|
||||
|
||||
set(OPENAL_SRC "")
|
||||
|
||||
if (${OPENAL_SOUND})
|
||||
set(OPENAL_SRC
|
||||
sound/oalsound/alsound.cpp
|
||||
sound/oalsound/buffer.cpp
|
||||
sound/oalsound/channel.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
# Source files
|
||||
set(SOURCES
|
||||
|
@ -160,10 +186,10 @@ ui/slider.cpp
|
|||
ui/studio.cpp
|
||||
ui/target.cpp
|
||||
ui/window.cpp
|
||||
plugins/pluginmanager.cpp
|
||||
plugins/pluginloader.cpp
|
||||
${OPENAL_SRC}
|
||||
)
|
||||
|
||||
|
||||
set(LIBS
|
||||
${SDL_LIBRARY}
|
||||
${SDLIMAGE_LIBRARY}
|
||||
|
@ -173,8 +199,8 @@ ${PNG_LIBRARIES}
|
|||
${OPTIONAL_LIBS}
|
||||
${PLATFORM_LIBS}
|
||||
${Boost_LIBRARIES}
|
||||
${LTDL_LIBRARY}
|
||||
CBot
|
||||
${OPENAL_LIBS}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -195,4 +221,5 @@ add_executable(colobot ${SOURCES})
|
|||
|
||||
target_link_libraries(colobot ${LIBS})
|
||||
|
||||
install_targets(/games colobot)
|
||||
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
||||
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#include "app/app.h"
|
||||
|
||||
|
@ -29,17 +30,21 @@
|
|||
|
||||
#include "object/robotmain.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#ifdef OPENAL_SOUND
|
||||
#include "sound/oalsound/alsound.h"
|
||||
#endif
|
||||
|
||||
|
||||
template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
|
||||
|
||||
//! Static buffer for putenv locale
|
||||
|
@ -89,7 +94,6 @@ CApplication::CApplication()
|
|||
m_private = new ApplicationPrivate();
|
||||
m_iMan = new CInstanceManager();
|
||||
m_eventQueue = new CEventQueue(m_iMan);
|
||||
m_pluginManager = new CPluginManager();
|
||||
m_profile = new CProfile();
|
||||
|
||||
m_engine = nullptr;
|
||||
|
@ -130,7 +134,7 @@ CApplication::CApplication()
|
|||
m_mouseButtonsState = 0;
|
||||
m_trackedKeys = 0;
|
||||
|
||||
m_dataPath = "./data";
|
||||
m_dataPath = COLOBOT_DEFAULT_DATADIR;
|
||||
|
||||
m_language = LANGUAGE_ENV;
|
||||
|
||||
|
@ -142,7 +146,6 @@ CApplication::CApplication()
|
|||
m_dataDirs[DIR_AI] = "ai";
|
||||
m_dataDirs[DIR_FONT] = "fonts";
|
||||
m_dataDirs[DIR_HELP] = "help";
|
||||
m_dataDirs[DIR_I18N] = "i18n";
|
||||
m_dataDirs[DIR_ICON] = "icons";
|
||||
m_dataDirs[DIR_LEVEL] = "levels";
|
||||
m_dataDirs[DIR_MODEL] = "models";
|
||||
|
@ -159,9 +162,6 @@ CApplication::~CApplication()
|
|||
delete m_eventQueue;
|
||||
m_eventQueue = nullptr;
|
||||
|
||||
delete m_pluginManager;
|
||||
m_pluginManager = nullptr;
|
||||
|
||||
delete m_profile;
|
||||
m_profile = nullptr;
|
||||
|
||||
|
@ -274,13 +274,10 @@ bool CApplication::Create()
|
|||
{
|
||||
GetLogger()->Info("Creating CApplication\n");
|
||||
|
||||
// I know, a primitive way to check for dir, but works
|
||||
std::string readmePath = m_dataPath + "/README.txt";
|
||||
std::ifstream testReadme;
|
||||
testReadme.open(readmePath.c_str(), std::ios_base::in);
|
||||
if (!testReadme.good())
|
||||
boost::filesystem::path dataPath(m_dataPath);
|
||||
if (! (boost::filesystem::exists(dataPath) && boost::filesystem::is_directory(dataPath)) )
|
||||
{
|
||||
GetLogger()->Error("Could not open test file in data dir: '%s'\n", readmePath.c_str());
|
||||
GetLogger()->Error("Data directory '%s' doesn't exist or is not a directory\n", m_dataPath.c_str());
|
||||
m_errorMessage = std::string("Could not read from data directory:\n") +
|
||||
std::string("'") + m_dataPath + std::string("'\n") +
|
||||
std::string("Please check your installation, or supply a valid data directory by -datadir option.");
|
||||
|
@ -319,19 +316,15 @@ bool CApplication::Create()
|
|||
langStr += locale;
|
||||
strcpy(S_LANGUAGE, langStr.c_str());
|
||||
putenv(S_LANGUAGE);
|
||||
setlocale(LC_ALL, "");
|
||||
setlocale(LC_ALL, locale.c_str());
|
||||
GetLogger()->Debug("Set locale to '%s'\n", locale.c_str());
|
||||
|
||||
std::string trPath = m_dataPath + "/" + m_dataDirs[DIR_I18N];
|
||||
bindtextdomain("colobot", trPath.c_str());
|
||||
bindtextdomain("colobot", COLOBOT_I18N_DIR);
|
||||
bind_textdomain_codeset("colobot", "UTF-8");
|
||||
textdomain("colobot");
|
||||
|
||||
GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!"));
|
||||
|
||||
// Temporarily -- only in windowed mode
|
||||
m_deviceConfig.fullScreen = false;
|
||||
|
||||
//Create the sound instance.
|
||||
if (!GetProfile().InitCurrentDirectory()) {
|
||||
GetLogger()->Warn("Config not found. Default values will be used!\n");
|
||||
|
@ -341,13 +334,12 @@ bool CApplication::Create()
|
|||
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
|
||||
m_dataPath = path;
|
||||
|
||||
m_pluginManager->LoadFromProfile();
|
||||
m_sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
|
||||
|
||||
if (!m_sound) {
|
||||
GetLogger()->Error("Sound not loaded, falling back to fake sound!\n");
|
||||
m_sound = new CSoundInterface();
|
||||
}
|
||||
#ifdef OPENAL_SOUND
|
||||
m_sound = static_cast<CSoundInterface *>(new ALSound());
|
||||
#else
|
||||
GetLogger()->Info("No sound support.\n");
|
||||
m_sound = new CSoundInterface();
|
||||
#endif
|
||||
|
||||
m_sound->Create(true);
|
||||
if (GetProfile().GetLocalProfileString("Resources", "Sound", path))
|
||||
|
@ -388,7 +380,20 @@ bool CApplication::Create()
|
|||
m_exitCode = 3;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// load settings from profile
|
||||
int iValue;
|
||||
if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) {
|
||||
std::vector<Math::IntPoint> modes;
|
||||
GetVideoResolutionList(modes, true, true);
|
||||
if (static_cast<unsigned int>(iValue) < modes.size())
|
||||
m_deviceConfig.size = modes.at(iValue);
|
||||
}
|
||||
|
||||
if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) {
|
||||
m_deviceConfig.fullScreen = (iValue == 1);
|
||||
}
|
||||
|
||||
if (! CreateVideoSurface())
|
||||
return false; // dialog is in function
|
||||
|
||||
|
@ -408,8 +413,7 @@ bool CApplication::Create()
|
|||
|
||||
// Don't generate joystick events
|
||||
SDL_JoystickEventState(SDL_IGNORE);
|
||||
|
||||
|
||||
|
||||
// The video is ready, we can create and initalize the graphics device
|
||||
m_device = new Gfx::CGLDevice(m_deviceConfig);
|
||||
if (! m_device->Create() )
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
|
||||
#include "common/global.h"
|
||||
#include "common/singleton.h"
|
||||
#include "common/profile.h"
|
||||
|
||||
#include "graphics/core/device.h"
|
||||
#include "graphics/engine/engine.h"
|
||||
#include "graphics/opengl/gldevice.h"
|
||||
|
||||
#include "plugins/pluginmanager.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -337,7 +336,6 @@ protected:
|
|||
CSoundInterface* m_sound;
|
||||
//! Main class of the proper game engine
|
||||
CRobotMain* m_robotMain;
|
||||
CPluginManager* m_pluginManager;
|
||||
CProfile* m_profile;
|
||||
|
||||
//! Code to return at exit
|
||||
|
|
|
@ -6,4 +6,9 @@
|
|||
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
|
||||
|
||||
#cmakedefine USE_GLEW @USE_GLEW@
|
||||
#cmakedefine GLEW_STATIC
|
||||
#cmakedefine GLEW_STATIC
|
||||
|
||||
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
|
||||
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
|
||||
|
||||
#cmakedefine OPENAL_SOUND
|
||||
|
|
|
@ -181,7 +181,6 @@ enum DataDir
|
|||
DIR_AI, //! < ai scripts
|
||||
DIR_FONT, //! < fonts
|
||||
DIR_HELP, //! < help files
|
||||
DIR_I18N, //! < translations
|
||||
DIR_ICON, //! < icons & images
|
||||
DIR_LEVEL, //! < levels
|
||||
DIR_MODEL, //! < models
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
include_directories(
|
||||
.
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Install Desktop Entry file
|
||||
set(COLOBOT_DESKTOP_FILE colobot.desktop)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
COMMAND ./create_desktop_file.sh > ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Build ${COLOBOT_DESKTOP_FILE}"
|
||||
)
|
||||
add_custom_target(desktopfile ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE})
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${COLOBOT_DESKTOP_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
|
||||
)
|
||||
|
||||
# Install Icon
|
||||
set(COLOBOT_ICON_FILE colobot.svg)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
|
||||
)
|
||||
|
||||
# Render SVG icon in various sizes
|
||||
find_program(RSVG_CONVERT rsvg-convert)
|
||||
if(RSVG_CONVERT)
|
||||
foreach(PNGSIZE "48" "32" "16")
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE})
|
||||
add_custom_target(resize_icon_${PNGSIZE} ALL
|
||||
COMMAND ${RSVG_CONVERT} -w ${PNGSIZE} -h ${PNGSIZE} ${CMAKE_CURRENT_SOURCE_DIR}/${COLOBOT_ICON_FILE}
|
||||
> ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
|
||||
)
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Translate translatable material
|
||||
find_program(PO4A po4a)
|
||||
|
||||
if(PO4A)
|
||||
add_custom_target(desktop_po4a
|
||||
COMMAND ${PO4A} po4a.cfg
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
add_dependencies(desktopfile desktop_po4a)
|
||||
endif()
|
|
@ -0,0 +1,5 @@
|
|||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Exec=colobot
|
||||
Icon=colobot
|
|
@ -0,0 +1,3 @@
|
|||
Name="Colobot"
|
||||
GenericName="Game to learn programming"
|
||||
Comment="Colonize with bots"
|
|
@ -0,0 +1,238 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="1.1"
|
||||
width="48"
|
||||
height="48"
|
||||
id="colobot-logo"
|
||||
style="enable-background:new">
|
||||
<title
|
||||
id="title3020">Colobot icon</title>
|
||||
<metadata
|
||||
id="metadata3061">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title>Colobot icon</dc:title>
|
||||
<dc:date>2012-12-27</dc:date>
|
||||
<dc:rights>
|
||||
<cc:Agent>
|
||||
<dc:title></dc:title>
|
||||
</cc:Agent>
|
||||
</dc:rights>
|
||||
<dc:creator>
|
||||
<cc:Agent>
|
||||
<dc:title>Polish Portal of Colobot</dc:title>
|
||||
</cc:Agent>
|
||||
</dc:creator>
|
||||
<cc:license
|
||||
rdf:resource="http://www.gnu.org/licenses/gpl-3.0-standalone.html" />
|
||||
<dc:description>Three spheres symbolizing planets.</dc:description>
|
||||
<dc:contributor>
|
||||
<cc:Agent>
|
||||
<dc:title>Didier Raboud <odyx@debian.org></dc:title>
|
||||
</cc:Agent>
|
||||
</dc:contributor>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3059">
|
||||
<linearGradient
|
||||
id="linearGradient4108">
|
||||
<stop
|
||||
id="stop4110"
|
||||
style="stop-color:#008000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4112"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4096">
|
||||
<stop
|
||||
id="stop4098"
|
||||
style="stop-color:#00ff00;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4100"
|
||||
style="stop-color:#00ff00;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4108-5">
|
||||
<stop
|
||||
id="stop4110-2"
|
||||
style="stop-color:#000080;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4112-8"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4096-0">
|
||||
<stop
|
||||
id="stop4098-3"
|
||||
style="stop-color:#0000ff;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4100-0"
|
||||
style="stop-color:#0000ff;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4108-5-2">
|
||||
<stop
|
||||
id="stop4110-2-3"
|
||||
style="stop-color:#500000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4112-8-6"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient4096-0-3">
|
||||
<stop
|
||||
id="stop4098-3-7"
|
||||
style="stop-color:#ff0000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop4100-0-3"
|
||||
style="stop-color:#ff0000;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
cx="54.8265"
|
||||
cy="57.607162"
|
||||
r="56.05489"
|
||||
fx="54.8265"
|
||||
fy="57.607162"
|
||||
id="radialGradient4416"
|
||||
xlink:href="#linearGradient4108-5-2"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.02726606,1.3911392,-1.8797791,0.03684323,176.62558,-41.562143)" />
|
||||
<radialGradient
|
||||
cx="63.5"
|
||||
cy="37.5"
|
||||
r="32"
|
||||
fx="63.5"
|
||||
fy="37.5"
|
||||
id="radialGradient4418"
|
||||
xlink:href="#linearGradient4096-0-3"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,0,0,0.796875,6.7936132,3.6927801)" />
|
||||
<radialGradient
|
||||
cx="54.8265"
|
||||
cy="57.607162"
|
||||
r="56.05489"
|
||||
fx="54.8265"
|
||||
fy="57.607162"
|
||||
id="radialGradient4420"
|
||||
xlink:href="#linearGradient4108"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.02726606,1.3911392,-1.8797791,0.03684323,176.62558,-41.562143)" />
|
||||
<radialGradient
|
||||
cx="63.5"
|
||||
cy="37.5"
|
||||
r="32"
|
||||
fx="63.5"
|
||||
fy="37.5"
|
||||
id="radialGradient4422"
|
||||
xlink:href="#linearGradient4096"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,0,0,0.796875,6.7936132,3.6927801)" />
|
||||
<radialGradient
|
||||
cx="54.8265"
|
||||
cy="57.607162"
|
||||
r="56.05489"
|
||||
fx="54.8265"
|
||||
fy="57.607162"
|
||||
id="radialGradient4424"
|
||||
xlink:href="#linearGradient4108-5"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(0.02726606,1.3911392,-1.8797791,0.03684323,176.62558,-41.562143)" />
|
||||
<radialGradient
|
||||
cx="63.5"
|
||||
cy="37.5"
|
||||
r="32"
|
||||
fx="63.5"
|
||||
fy="37.5"
|
||||
id="radialGradient4426"
|
||||
xlink:href="#linearGradient4096-0"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1,0,0,0.796875,6.7936132,3.6927801)" />
|
||||
</defs>
|
||||
<path
|
||||
d="m 35.001373,17.978157 a 17.137194,11.839104 0 1 1 -34.27438587,0 17.137194,11.839104 0 1 1 34.27438587,0 z"
|
||||
id="path3068"
|
||||
style="opacity:0;color:#000000;fill:#800000;fill-opacity:1;fill-rule:nonzero;stroke:#ff0000;stroke-width:1.45397186;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:11.63177575, 11.63177575;stroke-dashoffset:11.63177575;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
<g
|
||||
transform="matrix(1.4527314,0,0,1.4552231,61.790796,7.2674667)"
|
||||
id="layer1"
|
||||
style="display:inline">
|
||||
<g
|
||||
transform="translate(-64.376292,0)"
|
||||
id="g4403">
|
||||
<g
|
||||
transform="matrix(0.1151419,-0.11259991,0.11259991,0.1151419,78.136911,8.9624182)"
|
||||
id="g4122-3-7"
|
||||
style="stroke-width:6.52155399;stroke-miterlimit:4;stroke-dasharray:none;display:inline">
|
||||
<g
|
||||
transform="translate(-232.5787,-246.03551)"
|
||||
id="g4259-8">
|
||||
<path
|
||||
d="m 128.20539,62.567638 c 0,29.922729 -24.25716,54.179892 -54.179886,54.179892 -29.922729,0 -54.179893,-24.257163 -54.179893,-54.179892 0,-29.922729 24.257164,-54.1798929 54.179893,-54.1798929 29.922726,0 54.179886,24.2571639 54.179886,54.1798929 z"
|
||||
id="path1873-0-2"
|
||||
style="fill:url(#radialGradient4416);fill-opacity:1;fill-rule:nonzero;stroke:#808000;stroke-width:4.65700197;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
<path
|
||||
d="m 102.29361,33.575593 c 0,14.083261 -14.326885,25.5 -31.999997,25.5 -17.673112,0 -32,-11.416739 -32,-25.5 0,-14.083261 14.326888,-25.4999999 32,-25.4999999 17.673112,0 31.999997,11.4167389 31.999997,25.4999999 z"
|
||||
id="path2814-0-8"
|
||||
style="fill:url(#radialGradient4418);fill-opacity:1;fill-rule:nonzero;stroke:none" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.1151419,-0.11259991,0.11259991,0.1151419,15.374404,17.677401)"
|
||||
id="g4122"
|
||||
style="stroke-width:6.52155399;stroke-miterlimit:4;stroke-dasharray:none">
|
||||
<path
|
||||
d="m 128.20539,62.567638 c 0,29.922729 -24.25716,54.179892 -54.179886,54.179892 -29.922729,0 -54.179893,-24.257163 -54.179893,-54.179892 0,-29.922729 24.257164,-54.1798929 54.179893,-54.1798929 29.922726,0 54.179886,24.2571639 54.179886,54.1798929 z"
|
||||
id="path1873"
|
||||
style="fill:url(#radialGradient4420);fill-opacity:1;fill-rule:nonzero;stroke:#808000;stroke-width:4.65700197;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
<path
|
||||
d="m 102.29361,33.575593 c 0,14.083261 -14.326885,25.5 -31.999997,25.5 -17.673112,0 -32,-11.416739 -32,-25.5 0,-14.083261 14.326888,-25.4999999 32,-25.4999999 17.673112,0 31.999997,11.4167389 31.999997,25.4999999 z"
|
||||
id="path2814"
|
||||
style="fill:url(#radialGradient4422);fill-opacity:1;fill-rule:nonzero;stroke:none" />
|
||||
</g>
|
||||
<g
|
||||
transform="matrix(0.1151419,-0.11259991,0.11259991,0.1151419,57.006572,14.417637)"
|
||||
id="g4122-3"
|
||||
style="stroke-width:6.52155399;stroke-miterlimit:4;stroke-dasharray:none;display:inline">
|
||||
<g
|
||||
transform="translate(-136.63091,-98.230764)"
|
||||
id="g4259">
|
||||
<path
|
||||
d="m 128.20539,62.567638 c 0,29.922729 -24.25716,54.179892 -54.179886,54.179892 -29.922729,0 -54.179893,-24.257163 -54.179893,-54.179892 0,-29.922729 24.257164,-54.1798929 54.179893,-54.1798929 29.922726,0 54.179886,24.2571639 54.179886,54.1798929 z"
|
||||
id="path1873-0"
|
||||
style="fill:url(#radialGradient4424);fill-opacity:1;fill-rule:nonzero;stroke:#808000;stroke-width:4.65700197;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
<path
|
||||
d="m 102.29361,33.575593 c 0,14.083261 -14.326885,25.5 -31.999997,25.5 -17.673112,0 -32,-11.416739 -32,-25.5 0,-14.083261 14.326888,-25.4999999 32,-25.4999999 17.673112,0 31.999997,11.4167389 31.999997,25.4999999 z"
|
||||
id="path2814-0"
|
||||
style="fill:url(#radialGradient4426);fill-opacity:1;fill-rule:nonzero;stroke:none" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 9.4 KiB |
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Create colobot.desktop from various colobot.ini's
|
||||
|
||||
fname=colobot.ini
|
||||
|
||||
cat colobot.desktop.in
|
||||
|
||||
linguas=$([ ! -d lang ] || ( cd lang ; ls));
|
||||
|
||||
for type in Name GenericName Comment; do
|
||||
egrep "^$type=" $fname | sed -e "s/^$type=\"\(.*\)\"$/$type=\1/g"
|
||||
for l in $linguas; do
|
||||
egrep "^$type=" lang/$l/$fname | sed -e "s/^$type=\"\(.*\)\"$/$type[$l]=\1/g"
|
||||
done
|
||||
done
|
|
@ -0,0 +1,32 @@
|
|||
# SOME DESCRIPTIVE TITLE
|
||||
# Copyright (C) YEAR Free Software Foundation, Inc.
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2012-12-26 15:05+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: colobot.ini:1
|
||||
#, no-wrap
|
||||
msgid "Colobot"
|
||||
msgstr ""
|
||||
|
||||
#: colobot.ini:2
|
||||
#, no-wrap
|
||||
msgid "Game to learn programming"
|
||||
msgstr ""
|
||||
|
||||
#: colobot.ini:3
|
||||
#, no-wrap
|
||||
msgid "Colonize with bots"
|
||||
msgstr ""
|
|
@ -0,0 +1,32 @@
|
|||
# French translations for PACKAGE package
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# Automatically generated, 2012.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2012-12-26 15:05+0100\n"
|
||||
"PO-Revision-Date: 2012-12-26 15:05+0100\n"
|
||||
"Last-Translator: Didier Raboud <odyx@debian.org>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: colobot.ini:1
|
||||
#, no-wrap
|
||||
msgid "Colobot"
|
||||
msgstr "Colobot"
|
||||
|
||||
#: colobot.ini:2
|
||||
#, no-wrap
|
||||
msgid "Game to learn programming"
|
||||
msgstr "Apprentissage de la programmation par le jeu"
|
||||
|
||||
#: colobot.ini:3
|
||||
#, no-wrap
|
||||
msgid "Colonize with bots"
|
||||
msgstr "Colonise avec des roBots"
|
|
@ -0,0 +1,3 @@
|
|||
[po_directory] po/
|
||||
|
||||
[type:ini] colobot.ini $lang:lang/$lang/colobot.ini
|
|
@ -1,7 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
set(MODELFILE_TEST_SOURCES
|
||||
modelfile_test.cpp
|
||||
|
|
|
@ -5,8 +5,11 @@ find_package(SDL REQUIRED)
|
|||
find_package(SDL_image REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0 -Wold-style-cast -std=gnu++0x")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
set(ADD_LIBS "")
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
include_directories(
|
||||
.
|
||||
|
|
|
@ -3793,6 +3793,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
int rankObj = 0;
|
||||
int rankGadget = 0;
|
||||
CObject* sel = 0;
|
||||
char *locale = setlocale(LC_NUMERIC, nullptr);
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
|
||||
while (fgets(line, 500, file) != NULL)
|
||||
{
|
||||
|
@ -4526,6 +4528,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
}
|
||||
m_dialog->SetSceneRead("");
|
||||
m_dialog->SetStackRead("");
|
||||
|
||||
setlocale(LC_NUMERIC, locale);
|
||||
}
|
||||
|
||||
//! Creates an object of decoration mobile or stationary
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
// * This file is part of the COLOBOT source code
|
||||
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
/**
|
||||
* \file plugins/plugininterface.h
|
||||
* \brief Generic plugin interface
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
#define PLUGIN_INTERFACE(class_type) \
|
||||
static class_type* Plugin##class_type; \
|
||||
extern "C" void InstallPluginEntry() { Plugin##class_type = new class_type(); Plugin##class_type->InstallPlugin(); } \
|
||||
extern "C" bool UninstallPluginEntry(std::string &reason) { bool result = Plugin##class_type->UninstallPlugin(reason); \
|
||||
if (!result) \
|
||||
return false; \
|
||||
delete Plugin##class_type; \
|
||||
return true; } \
|
||||
extern "C" CPluginInterface* GetPluginInterfaceEntry() { return static_cast<CPluginInterface*>(Plugin##class_type); }
|
||||
|
||||
|
||||
/**
|
||||
* \class CPluginInterface
|
||||
*
|
||||
* \brief Generic plugin interface. All plugins that will be managed by plugin manager have to derive from this class.
|
||||
*
|
||||
*/
|
||||
class CPluginInterface {
|
||||
public:
|
||||
/** Function to get plugin name or description
|
||||
* \return returns plugin name
|
||||
*/
|
||||
inline virtual std::string PluginName() { return "abc"; }
|
||||
|
||||
/** Function to get plugin version. 1 means version 0.01, 2 means 0.02 etc.
|
||||
* \return number indicating plugin version
|
||||
*/
|
||||
inline virtual int PluginVersion() { return 0; }
|
||||
|
||||
/** Function to initialize plugin
|
||||
*/
|
||||
inline virtual void InstallPlugin() {}
|
||||
|
||||
/** Function called before removing plugin
|
||||
*/
|
||||
inline virtual bool UninstallPlugin(std::string &) { return true; }
|
||||
};
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
// * This file is part of the COLOBOT source code
|
||||
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include "plugins/pluginloader.h"
|
||||
|
||||
|
||||
CPluginLoader::CPluginLoader(std::string filename)
|
||||
{
|
||||
mInterface = nullptr;
|
||||
mFilename = filename;
|
||||
mLoaded = false;
|
||||
}
|
||||
|
||||
|
||||
std::string CPluginLoader::GetName()
|
||||
{
|
||||
if (mLoaded)
|
||||
return mInterface->PluginName();
|
||||
return "(not loaded)";
|
||||
}
|
||||
|
||||
|
||||
int CPluginLoader::GetVersion()
|
||||
{
|
||||
if (mLoaded)
|
||||
return mInterface->PluginVersion();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginLoader::IsLoaded()
|
||||
{
|
||||
return mLoaded;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginLoader::UnloadPlugin()
|
||||
{
|
||||
if (!mLoaded) {
|
||||
GetLogger()->Warn("Plugin %s is not loaded.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool (*uninstall)(std::string &) = reinterpret_cast<bool (*)(std::string &)>( lt_dlsym(mHandle, "UninstallPluginEntry") );
|
||||
if (!uninstall) {
|
||||
GetLogger()->Error("Error getting UninstallPluginEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string reason;
|
||||
if (!uninstall(reason)) {
|
||||
GetLogger()->Error("Could not unload plugin %s: %s\n", mFilename.c_str(), reason.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
lt_dlclose(mHandle);
|
||||
mLoaded = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginLoader::LoadPlugin()
|
||||
{
|
||||
if (mFilename.length() == 0) {
|
||||
GetLogger()->Warn("No plugin filename specified.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
mHandle = lt_dlopenext(mFilename.c_str());
|
||||
if (!mHandle) {
|
||||
GetLogger()->Error("Error loading plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
|
||||
return false;
|
||||
}
|
||||
|
||||
void (*install)() = reinterpret_cast<void (*)()>( lt_dlsym(mHandle, "InstallPluginEntry") );
|
||||
if (!install) {
|
||||
GetLogger()->Error("Error getting InstallPluginEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
|
||||
return false;
|
||||
}
|
||||
|
||||
CPluginInterface* (*getInterface)() = reinterpret_cast<CPluginInterface* (*)()>( lt_dlsym(mHandle, "GetPluginInterfaceEntry") );
|
||||
|
||||
if (!getInterface) {
|
||||
GetLogger()->Error("Error getting GetPluginInterfaceEntry for plugin %s: %s\n", mFilename.c_str(), lt_dlerror());
|
||||
return false;
|
||||
}
|
||||
|
||||
install();
|
||||
mInterface = getInterface();
|
||||
mLoaded = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginLoader::SetFilename(std::string filename)
|
||||
{
|
||||
bool ok = true;
|
||||
if (mLoaded)
|
||||
ok = UnloadPlugin();
|
||||
|
||||
if (ok)
|
||||
mFilename = filename;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
std::string CPluginLoader::GetFilename()
|
||||
{
|
||||
return mFilename;
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
// * This file is part of the COLOBOT source code
|
||||
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
/**
|
||||
* \file plugins/pluginloader.h
|
||||
* \brief Plugin loader interface
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "common/logger.h"
|
||||
|
||||
#include "plugins/plugininterface.h"
|
||||
|
||||
#include <ltdl.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
/**
|
||||
* \class CPluginLoader
|
||||
*
|
||||
* \brief Plugin loader interface. Plugin manager uses this class to load plugins.
|
||||
*
|
||||
*/
|
||||
class CPluginLoader {
|
||||
public:
|
||||
/** Class contructor
|
||||
* \param filename plugin filename
|
||||
*/
|
||||
CPluginLoader(std::string filename);
|
||||
|
||||
/** Function to get plugin name or description
|
||||
* \return returns plugin name
|
||||
*/
|
||||
std::string GetName();
|
||||
|
||||
/** Function to get plugin version
|
||||
* \return returns plugin version
|
||||
*/
|
||||
int GetVersion();
|
||||
|
||||
/** Function to unload plugin
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool UnloadPlugin();
|
||||
|
||||
/** Function to load plugin
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool LoadPlugin();
|
||||
|
||||
/** Function to check if plugin is loaded
|
||||
* \return returns true if plugin is loaded
|
||||
*/
|
||||
bool IsLoaded();
|
||||
|
||||
/** Function to set plugin filename
|
||||
* \return returns true on success. Action can fail if plugin was loaded and cannot be unloaded
|
||||
*/
|
||||
bool SetFilename(std::string);
|
||||
|
||||
/** Function to get plugin filename
|
||||
* \return returns plugin filename
|
||||
*/
|
||||
std::string GetFilename();
|
||||
|
||||
|
||||
private:
|
||||
CPluginInterface* mInterface;
|
||||
std::string mFilename;
|
||||
lt_dlhandle mHandle;
|
||||
bool mLoaded;
|
||||
};
|
|
@ -1,132 +0,0 @@
|
|||
// * This file is part of the COLOBOT source code
|
||||
// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
|
||||
#include "plugins/pluginmanager.h"
|
||||
|
||||
|
||||
template<> CPluginManager* CSingleton<CPluginManager>::mInstance = nullptr;
|
||||
|
||||
|
||||
CPluginManager::CPluginManager()
|
||||
{
|
||||
lt_dlinit();
|
||||
}
|
||||
|
||||
|
||||
CPluginManager::~CPluginManager()
|
||||
{
|
||||
UnloadAllPlugins();
|
||||
lt_dlexit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CPluginManager::LoadFromProfile()
|
||||
{
|
||||
GetLogger()->Info("Trying to load from profile...\n");
|
||||
std::vector< std::string > dirs = GetProfile().GetLocalProfileSection("Plugins", "Path");
|
||||
std::vector< std::string > plugins = GetProfile().GetLocalProfileSection("Plugins", "File");
|
||||
|
||||
GetLogger()->Info("Path %d, files %d\n", dirs.size(), plugins.size());
|
||||
for (std::string dir : dirs)
|
||||
m_folders.insert(dir);
|
||||
|
||||
for (std::string plugin : plugins) {
|
||||
GetLogger()->Info("Trying to load plugin %s...\n", plugin.c_str());
|
||||
LoadPlugin(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::LoadPlugin(std::string filename)
|
||||
{
|
||||
bool result = false;
|
||||
CPluginLoader *loader = new CPluginLoader("");
|
||||
for (std::string dir : m_folders) {
|
||||
loader->SetFilename(dir + "/" + filename);
|
||||
result = loader->LoadPlugin();
|
||||
if (result) {
|
||||
GetLogger()->Info("Plugin %s (%s) version %0.2f loaded!\n", filename.c_str(), loader->GetName().c_str(), loader->GetVersion() / 100.0f);
|
||||
m_plugins.push_back(loader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::UnloadPlugin(std::string filename)
|
||||
{
|
||||
std::vector<CPluginLoader *>::iterator it;
|
||||
GetLogger()->Info("Trying to unload plugin %s...\n", filename.c_str());
|
||||
for (it = m_plugins.begin(); it != m_plugins.end(); it++) {
|
||||
CPluginLoader *plugin = *it;
|
||||
if (NameEndsWith(plugin->GetFilename(), filename)) {
|
||||
m_plugins.erase(it);
|
||||
plugin->UnloadPlugin();
|
||||
delete plugin;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::AddSearchDirectory(std::string dir)
|
||||
{
|
||||
m_folders.insert(dir);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::RemoveSearchDirectory(std::string dir)
|
||||
{
|
||||
m_folders.erase(dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::UnloadAllPlugins()
|
||||
{
|
||||
bool allOk = true;
|
||||
std::vector<CPluginLoader *>::iterator it;
|
||||
for (it = m_plugins.begin(); it != m_plugins.end(); it++) {
|
||||
CPluginLoader *plugin = *it;
|
||||
bool result;
|
||||
|
||||
GetLogger()->Info("Trying to unload plugin %s (%s)...\n", plugin->GetFilename().c_str(), plugin->GetName().c_str());
|
||||
result = plugin->UnloadPlugin();
|
||||
if (!result) {
|
||||
allOk = false;
|
||||
continue;
|
||||
}
|
||||
delete plugin;
|
||||
m_plugins.erase(it);
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
|
||||
bool CPluginManager::NameEndsWith(std::string filename, std::string ending)
|
||||
{
|
||||
if (filename.length() > ending.length()) {
|
||||
std::string fileEnd = filename.substr(filename.length() - ending.length());
|
||||
return (fileEnd == ending);
|
||||
}
|
||||
return false;
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
// * This file is part of the COLOBOT source code
|
||||
// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify
|
||||
// * it under the terms of the GNU General Public License as published by
|
||||
// * the Free Software Foundation, either version 3 of the License, or
|
||||
// * (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// * GNU General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU General Public License
|
||||
// * along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
/**
|
||||
* \file plugins/pluginmanager.h
|
||||
* \brief Plugin manager class.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "common/logger.h"
|
||||
#include "common/profile.h"
|
||||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "plugins/pluginloader.h"
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
|
||||
/**
|
||||
* \class CPluginManager
|
||||
*
|
||||
* \brief Plugin manager class. Plugin manager can load plugins from colobot.ini or manually specified files.
|
||||
*
|
||||
*/
|
||||
class CPluginManager : public CSingleton<CPluginManager> {
|
||||
public:
|
||||
CPluginManager();
|
||||
~CPluginManager();
|
||||
|
||||
/** Function loads plugin list and path list from profile file
|
||||
*/
|
||||
void LoadFromProfile();
|
||||
|
||||
/** Function loads specified plugin
|
||||
* \param filename plugin filename
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool LoadPlugin(std::string filename);
|
||||
|
||||
/** Function unloads specified plugin
|
||||
* \param filename plugin filename
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool UnloadPlugin(std::string filename);
|
||||
|
||||
/** Function adds path to be checked when searching for plugin file. If path was already added it will be ignored
|
||||
* \param dir plugin search path
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool AddSearchDirectory(std::string dir);
|
||||
|
||||
/** Function removes path from list
|
||||
* \param dir plugin search path
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool RemoveSearchDirectory(std::string dir);
|
||||
|
||||
/** Function tries to unload all plugins
|
||||
* \return returns true on success
|
||||
*/
|
||||
bool UnloadAllPlugins();
|
||||
|
||||
private:
|
||||
bool NameEndsWith(std::string, std::string);
|
||||
|
||||
std::set< std::string > m_folders;
|
||||
std::vector<CPluginLoader *> m_plugins;
|
||||
};
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0 -std=c++11 -rdynamic")
|
||||
|
||||
add_executable(manager_test manager_test.cpp ../../common/logger.cpp ../../common/profile.cpp ../../common/iman.cpp ../pluginmanager.cpp ../pluginloader.cpp)
|
||||
|
||||
include_directories(".")
|
||||
include_directories("../../")
|
||||
include_directories("../../../")
|
||||
|
||||
target_link_libraries(manager_test ${LTDL_LIBRARY})
|
|
@ -1,3 +0,0 @@
|
|||
[Plugins]
|
||||
Path=.
|
||||
File=libopenalsound.so
|
|
@ -1,31 +0,0 @@
|
|||
#include <common/logger.h>
|
||||
#include <common/profile.h>
|
||||
#include <common/iman.h>
|
||||
#include <plugins/pluginmanager.h>
|
||||
#include <sound/sound.h>
|
||||
|
||||
|
||||
int main() {
|
||||
new CLogger();
|
||||
new CProfile();
|
||||
new CInstanceManager();
|
||||
CPluginManager *mgr = new CPluginManager();
|
||||
|
||||
if (!GetProfile()->InitCurrentDirectory()) {
|
||||
GetLogger()->Error("Config not found!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
mgr->LoadFromProfile();
|
||||
CSoundInterface *sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
|
||||
|
||||
if (!sound) {
|
||||
GetLogger()->Error("Sound not loaded!\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
sound->Create(true);
|
||||
mgr->UnloadAllPlugins();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,13 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
SET(_potFile colobot.pot)
|
||||
set(_potFile colobot.pot)
|
||||
|
||||
# TODO: Use a finder
|
||||
SET(XGETTEXT_CMD /usr/bin/xgettext)
|
||||
find_program(XGETTEXT_CMD xgettext)
|
||||
|
||||
find_package(Gettext REQUIRED)
|
||||
|
||||
ADD_CUSTOM_COMMAND(OUTPUT ${_potFile}
|
||||
add_custom_command(OUTPUT ${_potFile}
|
||||
COMMAND ${XGETTEXT_CMD} ../app/app.cpp --output=${_potFile}
|
||||
COMMAND ${XGETTEXT_CMD} ../common/restext_strings.c --output=${_potFile} --join-existing --extract-all --no-location
|
||||
|
||||
|
@ -15,10 +12,8 @@ ADD_CUSTOM_COMMAND(OUTPUT ${_potFile}
|
|||
COMMENT "Extract translatable messages to ${_potFile}"
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(_${potFile} ${_all}
|
||||
DEPENDS ${_potFile}
|
||||
)
|
||||
add_custom_target(_${potFile} ${_all} DEPENDS ${_potFile})
|
||||
|
||||
FILE(GLOB _poFiles *.po)
|
||||
file(GLOB _poFiles *.po)
|
||||
|
||||
GETTEXT_CREATE_TRANSLATIONS(${_potFile} ALL ${_poFiles})
|
||||
gettext_create_translations(${_potFile} ALL ${_poFiles})
|
||||
|
|
|
@ -23,51 +23,23 @@
|
|||
|
||||
#define MIN(a, b) (a > b ? b : a)
|
||||
|
||||
|
||||
PLUGIN_INTERFACE(ALSound)
|
||||
|
||||
|
||||
std::string ALSound::PluginName()
|
||||
{
|
||||
return "Sound plugin using OpenAL library to play sounds.";
|
||||
}
|
||||
|
||||
|
||||
int ALSound::PluginVersion()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
void ALSound::InstallPlugin()
|
||||
{
|
||||
auto pointer = CInstanceManager::GetInstancePointer();
|
||||
if (pointer != nullptr)
|
||||
CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
|
||||
}
|
||||
|
||||
|
||||
bool ALSound::UninstallPlugin(std::string &reason)
|
||||
{
|
||||
auto pointer = CInstanceManager::GetInstancePointer();
|
||||
if (pointer != nullptr)
|
||||
CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
|
||||
CleanUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
ALSound::ALSound()
|
||||
{
|
||||
mEnabled = false;
|
||||
m3D = false;
|
||||
mAudioVolume = MAXVOLUME;
|
||||
mMute = false;
|
||||
auto pointer = CInstanceManager::GetInstancePointer();
|
||||
if (pointer != nullptr)
|
||||
CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
|
||||
}
|
||||
|
||||
|
||||
ALSound::~ALSound()
|
||||
{
|
||||
auto pointer = CInstanceManager::GetInstancePointer();
|
||||
if (pointer != nullptr)
|
||||
CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
|
@ -114,14 +86,14 @@ void ALSound::SetSound3D(bool bMode)
|
|||
}
|
||||
|
||||
|
||||
bool ALSound::RetSound3D()
|
||||
bool ALSound::GetSound3D()
|
||||
{
|
||||
// TODO stub! need to be implemented
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ALSound::RetSound3DCap()
|
||||
bool ALSound::GetSound3DCap()
|
||||
{
|
||||
// TODO stub! need to be implemented
|
||||
return true;
|
||||
|
@ -141,7 +113,7 @@ void ALSound::SetAudioVolume(int volume)
|
|||
}
|
||||
|
||||
|
||||
int ALSound::RetAudioVolume()
|
||||
int ALSound::GetAudioVolume()
|
||||
{
|
||||
float volume;
|
||||
if ( !mEnabled )
|
||||
|
@ -158,7 +130,7 @@ void ALSound::SetMusicVolume(int volume)
|
|||
}
|
||||
|
||||
|
||||
int ALSound::RetMusicVolume()
|
||||
int ALSound::GetMusicVolume()
|
||||
{
|
||||
// TODO stub! Add music support
|
||||
if ( !mEnabled )
|
||||
|
@ -179,7 +151,7 @@ bool ALSound::Cache(Sound sound, std::string filename)
|
|||
}
|
||||
|
||||
|
||||
int ALSound::RetPriority(Sound sound)
|
||||
int ALSound::GetPriority(Sound sound)
|
||||
{
|
||||
if ( sound == SOUND_FLYh ||
|
||||
sound == SOUND_FLY ||
|
||||
|
@ -230,7 +202,7 @@ int ALSound::RetPriority(Sound sound)
|
|||
|
||||
bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
||||
{
|
||||
int priority = RetPriority(sound);
|
||||
int priority = GetPriority(sound);
|
||||
|
||||
// Seeks a channel used which sound is stopped.
|
||||
for (auto it : mChannels) {
|
||||
|
@ -287,7 +259,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
|||
int lowerOrEqual = -1;
|
||||
for (auto it : mChannels) {
|
||||
if (it.second->GetPriority() < priority) {
|
||||
GetLogger()->Info("Sound channel with lower priority will be reused.");
|
||||
GetLogger()->Debug("Sound channel with lower priority will be reused.");
|
||||
channel = it.first;
|
||||
return true;
|
||||
}
|
||||
|
@ -297,7 +269,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
|
|||
|
||||
if (lowerOrEqual != -1) {
|
||||
channel = lowerOrEqual;
|
||||
GetLogger()->Info("Sound channel with lower or equal priority will be reused.");
|
||||
GetLogger()->Debug("Sound channel with lower or equal priority will be reused.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -485,11 +457,11 @@ void ALSound::FrameMove(float delta)
|
|||
if (it.second->GetEnvelope().totalTime <= it.second->GetCurrentTime()) {
|
||||
|
||||
if (oper.nextOper == SOPER_LOOP) {
|
||||
GetLogger()->Info("Replay.\n");
|
||||
GetLogger()->Trace("Sound oper: replay.\n");
|
||||
it.second->SetCurrentTime(0.0f);
|
||||
it.second->Play();
|
||||
} else {
|
||||
GetLogger()->Info("Next.\n");
|
||||
GetLogger()->Trace("Sound oper: next.\n");
|
||||
it.second->SetStartAmplitude(oper.finalAmplitude);
|
||||
it.second->SetStartFrequency(oper.finalFrequency);
|
||||
it.second->PopEnvelope();
|
|
@ -45,13 +45,13 @@ class ALSound : public CSoundInterface
|
|||
bool RetEnable();
|
||||
|
||||
void SetSound3D(bool bMode);
|
||||
bool RetSound3D();
|
||||
bool RetSound3DCap();
|
||||
bool GetSound3D();
|
||||
bool GetSound3DCap();
|
||||
|
||||
void SetAudioVolume(int volume);
|
||||
int RetAudioVolume();
|
||||
int GetAudioVolume();
|
||||
void SetMusicVolume(int volume);
|
||||
int RetMusicVolume();
|
||||
int GetMusicVolume();
|
||||
|
||||
void SetListener(Math::Vector eye, Math::Vector lookat);
|
||||
void FrameMove(float rTime);
|
||||
|
@ -80,7 +80,7 @@ class ALSound : public CSoundInterface
|
|||
|
||||
private:
|
||||
void CleanUp();
|
||||
int RetPriority(Sound);
|
||||
int GetPriority(Sound);
|
||||
bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded);
|
||||
|
||||
bool mEnabled;
|
|
@ -36,7 +36,7 @@ Buffer::~Buffer() {
|
|||
bool Buffer::LoadFromFile(std::string filename, Sound sound) {
|
||||
mSound = sound;
|
||||
|
||||
GetLogger()->Info("Loading audio file: %s\n", filename.c_str());
|
||||
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
||||
mBuffer = alutCreateBufferFromFile(filename.c_str());
|
||||
|
||||
ALenum error = alutGetError();
|
||||
|
@ -53,7 +53,7 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound) {
|
|||
alGetBufferi(mBuffer, AL_CHANNELS, &channels);
|
||||
alGetBufferi(mBuffer, AL_FREQUENCY, &freq);
|
||||
|
||||
mDuration = (ALfloat)size / channels / bits / 8 / (ALfloat)freq;
|
||||
mDuration = static_cast<ALfloat>(size) / channels / bits / 8 / static_cast<ALfloat>(freq);
|
||||
|
||||
mLoaded = true;
|
||||
return true;
|
|
@ -227,7 +227,7 @@ void Channel::AdjustFrequency(float freq) {
|
|||
|
||||
|
||||
void Channel::AdjustVolume(float volume) {
|
||||
SetVolume(mStartAmplitude * (float) volume);
|
||||
SetVolume(mStartAmplitude * volume);
|
||||
}
|
||||
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(SOURCES
|
||||
alsound.cpp
|
||||
buffer.cpp
|
||||
channel.cpp
|
||||
)
|
||||
|
||||
SET (CMAKE_CXX_FLAGS "-Wall -g -std=c++0x -fPIC")
|
||||
|
||||
include(FindPkgConfig)
|
||||
include(FindOpenAL)
|
||||
pkg_check_modules(OPENAL_LIB REQUIRED openal)
|
||||
|
||||
set(OPENAL_LIBRARIES
|
||||
openal
|
||||
alut
|
||||
)
|
||||
|
||||
include_directories(../../..)
|
||||
include_directories(.)
|
||||
add_library(openalsound SHARED ${SOURCES})
|
||||
target_link_libraries(openalsound ${OPENAL_LIBRARIES})
|
|
@ -1,11 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0 -std=c++11 -rdynamic")
|
||||
|
||||
add_executable(plugin_test plugin_test.cpp ../../../../common/iman.cpp ../../../../common/logger.cpp ../../../../plugins/pluginloader.cpp)
|
||||
|
||||
include_directories(".")
|
||||
include_directories("../../../../")
|
||||
|
||||
target_link_libraries(plugin_test ${LTDL_LIBRARY})
|
|
@ -1,40 +0,0 @@
|
|||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <common/logger.h>
|
||||
#include <common/iman.h>
|
||||
#include <sound/sound.h>
|
||||
#include <plugins/pluginloader.h>
|
||||
|
||||
|
||||
int main() {
|
||||
new CLogger();
|
||||
new CInstanceManager();
|
||||
|
||||
lt_dlinit();
|
||||
|
||||
CPluginLoader *plugin = new CPluginLoader("libopenalsound");
|
||||
if (plugin->LoadPlugin()) {
|
||||
CSoundInterface *sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
|
||||
|
||||
sound->Create(true);
|
||||
sound->CacheAll();
|
||||
sound->Play((Sound)8);
|
||||
sound->Play((Sound)18);
|
||||
|
||||
sleep(10);
|
||||
/*
|
||||
while (1)
|
||||
{
|
||||
// just a test, very slow
|
||||
plugin->FrameMove(0);
|
||||
//if ('n' == getchar())
|
||||
// break;
|
||||
}*/
|
||||
plugin->UnloadPlugin();
|
||||
}
|
||||
|
||||
lt_dlexit();
|
||||
return 0;
|
||||
}
|
|
@ -28,8 +28,6 @@
|
|||
#include "common/iman.h"
|
||||
#include "common/logger.h"
|
||||
|
||||
#include "plugins/plugininterface.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
@ -152,7 +150,7 @@ enum SoundNext
|
|||
* \brief Sound plugin interface
|
||||
*
|
||||
*/
|
||||
class CSoundInterface : public CPluginInterface
|
||||
class CSoundInterface
|
||||
{
|
||||
public:
|
||||
inline CSoundInterface() {
|
||||
|
|
|
@ -1164,43 +1164,22 @@ pb->SetState(STATE_SHADOW);
|
|||
if ( m_phase == PHASE_SETUPd || // setup/display ?
|
||||
m_phase == PHASE_SETUPds )
|
||||
{
|
||||
|
||||
// TODO: device settings
|
||||
#if 0
|
||||
|
||||
pos.x = ox+sx*3;
|
||||
pos.y = oy+sy*9;
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*1;
|
||||
GetResource(RES_TEXT, RT_SETUP_DEVICE, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
|
||||
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
|
||||
|
||||
pos.x = ox+sx*3;
|
||||
pos.y = oy+sy*5.2f;
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*4.5f;
|
||||
pli = pw->CreateList(pos, ddim, 0, EVENT_LIST1);
|
||||
pli->SetState(STATE_SHADOW);
|
||||
UpdateDisplayDevice();
|
||||
|
||||
pos.x = ox+sx*10;
|
||||
pos.y = oy+sy*9;
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*1;
|
||||
GetResource(RES_TEXT, RT_SETUP_MODE, name);
|
||||
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
|
||||
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
|
||||
|
||||
m_setupFull = m_app->GetVideoConfig().fullScreen;
|
||||
pos.x = ox+sx*10;
|
||||
pos.x = ox+sx*3;
|
||||
pos.y = oy+sy*5.2f;
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*4.5f;
|
||||
pli = pw->CreateList(pos, ddim, 0, EVENT_LIST2);
|
||||
pli->SetState(STATE_SHADOW);
|
||||
UpdateDisplayMode();
|
||||
pli->SetState(STATE_ENABLE, m_setupFull);
|
||||
|
||||
ddim.x = dim.x*4;
|
||||
ddim.y = dim.y*0.5f;
|
||||
|
@ -1209,7 +1188,6 @@ pb->SetState(STATE_SHADOW);
|
|||
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_FULL);
|
||||
pc->SetState(STATE_SHADOW);
|
||||
pc->SetState(STATE_CHECK, m_setupFull);
|
||||
#endif
|
||||
|
||||
ddim.x = dim.x*6;
|
||||
ddim.y = dim.y*1;
|
||||
|
@ -2610,19 +2588,16 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == 0 ) break;
|
||||
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
|
||||
if ( pc == 0 ) break;
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
|
||||
if ( pl == 0 ) break;
|
||||
if ( pc->TestState(STATE_CHECK) )
|
||||
{
|
||||
pc->ClearState(STATE_CHECK); // window
|
||||
pl->ClearState(STATE_ENABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
pc->SetState(STATE_CHECK); // fullscreen
|
||||
pl->SetState(STATE_ENABLE);
|
||||
}
|
||||
if ( pc == 0 ) break;
|
||||
|
||||
if ( pc->TestState(STATE_CHECK) ) {
|
||||
m_setupFull = false;
|
||||
pc->ClearState(STATE_CHECK);
|
||||
} else {
|
||||
m_setupFull = true;
|
||||
pc->SetState(STATE_CHECK);
|
||||
}
|
||||
|
||||
UpdateApply();
|
||||
break;
|
||||
|
||||
|
@ -2633,7 +2608,8 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
if ( pb == 0 ) break;
|
||||
pb->ClearState(STATE_PRESS);
|
||||
pb->ClearState(STATE_HILIGHT);
|
||||
ChangeDisplay();
|
||||
// TODO: uncomment when changing display is implemented
|
||||
//ChangeDisplay();
|
||||
UpdateApply();
|
||||
break;
|
||||
|
||||
|
@ -2909,12 +2885,12 @@ bool CMainDialog::EventProcess(const Event &event)
|
|||
|
||||
case EVENT_INTERFACE_SILENT:
|
||||
m_sound->SetAudioVolume(0);
|
||||
//TODO: m_sound->SetMidiVolume(0);
|
||||
m_sound->SetMusicVolume(0);
|
||||
UpdateSetupButtons();
|
||||
break;
|
||||
case EVENT_INTERFACE_NOISY:
|
||||
m_sound->SetAudioVolume(MAXVOLUME);
|
||||
//TODO: m_sound->SetMidiVolume(MAXVOLUME*3/4);
|
||||
m_sound->SetMusicVolume(MAXVOLUME*3/4);
|
||||
UpdateSetupButtons();
|
||||
break;
|
||||
|
||||
|
@ -5076,9 +5052,6 @@ void CMainDialog::UpdateDisplayMode()
|
|||
{
|
||||
CWindow* pw;
|
||||
CList* pl;
|
||||
char bufDevices[1000];
|
||||
char bufModes[5000];
|
||||
int i, j, totalDevices, selectDevices, totalModes, selectModes;
|
||||
|
||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == 0 ) return;
|
||||
|
@ -5086,25 +5059,18 @@ void CMainDialog::UpdateDisplayMode()
|
|||
if ( pl == 0 ) return;
|
||||
pl->Flush();
|
||||
|
||||
bufModes[0] = 0;
|
||||
/* TODO: remove device choice
|
||||
m_engine->EnumDevices(bufDevices, 1000,
|
||||
bufModes, 5000,
|
||||
totalDevices, selectDevices,
|
||||
totalModes, selectModes);*/
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while ( bufModes[i] != 0 )
|
||||
{
|
||||
pl->SetName(j++, bufModes+i);
|
||||
while ( bufModes[i++] != 0 );
|
||||
std::vector<Math::IntPoint> modes;
|
||||
m_app->GetVideoResolutionList(modes, true, true);
|
||||
int i = 0;
|
||||
std::stringstream mode_text;
|
||||
for (Math::IntPoint mode : modes) {
|
||||
mode_text.str("");
|
||||
mode_text << mode.x << "x" << mode.y;
|
||||
pl->SetName(i++, mode_text.str().c_str());
|
||||
}
|
||||
|
||||
pl->SetSelect(selectModes);
|
||||
pl->SetSelect(m_setupSelMode);
|
||||
pl->ShowSelect(false);
|
||||
|
||||
m_setupSelMode = selectModes;
|
||||
}
|
||||
|
||||
// Change the graphics mode.
|
||||
|
@ -5392,9 +5358,8 @@ void CMainDialog::UpdateSetupButtons()
|
|||
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
|
||||
if ( ps != 0 )
|
||||
{
|
||||
/* TODO: midi volume
|
||||
value = (float)m_sound->GetMidiVolume();
|
||||
ps->SetVisibleValue(value);*/
|
||||
value = static_cast<float>(m_sound->GetMusicVolume());
|
||||
ps->SetVisibleValue(value);
|
||||
}
|
||||
|
||||
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOUND3D));
|
||||
|
@ -5474,10 +5439,6 @@ void CMainDialog::ChangeSetupButtons()
|
|||
|
||||
void CMainDialog::SetupMemorize()
|
||||
{
|
||||
float fValue;
|
||||
int iValue, i, j;
|
||||
char num[10];
|
||||
|
||||
GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir);
|
||||
GetProfile().SetLocalProfileString("Directory", "savegame", m_savegameDir);
|
||||
GetProfile().SetLocalProfileString("Directory", "public", m_publicDir);
|
||||
|
@ -5508,15 +5469,27 @@ void CMainDialog::SetupMemorize()
|
|||
GetProfile().SetLocalProfileInt("Setup", "TextureQuality", m_engine->GetTextureQuality());
|
||||
GetProfile().SetLocalProfileInt("Setup", "TotoMode", m_engine->GetTotoMode());
|
||||
GetProfile().SetLocalProfileInt("Setup", "AudioVolume", m_sound->GetAudioVolume());
|
||||
GetProfile().SetLocalProfileInt("Setup", "MusicVolume", m_sound->GetMusicVolume());
|
||||
GetProfile().SetLocalProfileInt("Setup", "Sound3D", m_sound->GetSound3D());
|
||||
GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode());
|
||||
GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue());
|
||||
|
||||
|
||||
// GetProfile()->SetLocalProfileInt("Setup", "NiceMouse", m_engine->GetNiceMouse());
|
||||
// GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick());
|
||||
// GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume());
|
||||
|
||||
|
||||
/* screen setup */
|
||||
if (m_setupFull)
|
||||
GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1);
|
||||
else
|
||||
GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0);
|
||||
|
||||
CList *pl;
|
||||
CWindow *pw;
|
||||
pw = static_cast<CWindow *>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw != 0 ) {
|
||||
pl = static_cast<CList *>(pw->SearchControl(EVENT_LIST2));
|
||||
if ( pl != 0 ) {
|
||||
GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect());
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream key;
|
||||
for (int i = 0; i < INPUT_SLOT_MAX; i++)
|
||||
{
|
||||
|
@ -5724,11 +5697,10 @@ void CMainDialog::SetupRecall()
|
|||
m_sound->SetAudioVolume(iValue);
|
||||
}
|
||||
|
||||
// TODO
|
||||
// if ( GetLocalProfileInt("Setup", "MidiVolume", iValue) )
|
||||
// {
|
||||
// m_sound->SetMidiVolume(iValue);
|
||||
// }
|
||||
if ( GetProfile().GetLocalProfileInt("Setup", "MusicVolume", iValue) )
|
||||
{
|
||||
m_sound->SetMusicVolume(iValue);
|
||||
}
|
||||
|
||||
if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) )
|
||||
{
|
||||
|
@ -5772,6 +5744,14 @@ void CMainDialog::SetupRecall()
|
|||
{
|
||||
m_bDeleteGamer = iValue;
|
||||
}
|
||||
|
||||
if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) {
|
||||
m_setupSelMode = iValue;
|
||||
}
|
||||
|
||||
if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) {
|
||||
m_setupFull = (iValue == 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE debug)
|
||||
endif(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast -std=gnu++0x")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
|
||||
include_directories(
|
||||
.
|
||||
|
|
Loading…
Reference in New Issue