Merge branch 'dev' into dev-graphics

dev-ui
Piotr Dziwinski 2013-01-04 00:05:28 +01:00
commit 89a3f586a2
98 changed files with 8713 additions and 6346 deletions

3
.gitignore vendored
View File

@ -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

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "data"]
path = data
url = git://github.com/colobot/colobot-data.git

8
.travis.yml Normal file
View File

@ -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

View File

@ -7,6 +7,32 @@ cmake_minimum_required(VERSION 2.8)
project(colobot C CXX)
##
# Project version
##
set(COLOBOT_VERSION_CODENAME "Gold")
set(COLOBOT_VERSION_MAJOR 0)
set(COLOBOT_VERSION_MINOR 1)
set(COLOBOT_VERSION_REVISION 0)
# Comment out when releasing
set(COLOBOT_VERSION_UNRELEASED "~pre-alpha")
# Append git characteristics to version
if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
find_package(Git)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(COLOBOT_VERSION_UNRELEASED "${COLOBOT_VERSION_UNRELEASED}-git-${GIT_BRANCH}~r${GIT_REVISION}")
endif()
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}")
message(STATUS "Building Colobot \"${COLOBOT_VERSION_CODENAME}\" (${COLOBOT_VERSION_FULL})")
# Include cmake directory with some additional scripts
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${colobot_SOURCE_DIR}/cmake")
@ -16,12 +42,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 +61,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,6 +76,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(Gettext REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
@ -118,7 +153,22 @@ if(${TESTS})
add_definitions(-DTEST_VIRTUAL=virtual)
enable_testing()
else()
add_definitions(-DTEST_VIRTUAL)
add_definitions(-DTEST_VIRTUAL=)
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()
@ -128,11 +178,57 @@ endif()
if(${TESTS})
# Google Test library
set(GTEST_DIR "${colobot_SOURCE_DIR}/lib/gtest")
add_subdirectory(lib/gtest bin/test)
find_path(GTEST_SRC_DIR NAMES src/gtest.cc src/gtest-all.cc PATHS /usr/src PATH_SUFFIXES gtest)
find_path(GTEST_INCLUDE_DIR gtest/gtest.h PATHS /usr/include)
if(GTEST_SRC_DIR AND GTEST_INCLUDE_DIR)
message(STATUS "Using system gtest library in ${GTEST_SRC_DIR}")
else()
message(STATUS "Using bundled gtest library")
set(GTEST_SRC_DIR ${colobot_SOURCE_DIR}/lib/gtest)
set(GTEST_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gtest/include)
endif()
add_subdirectory(${GTEST_SRC_DIR} bin/gtest)
# Google Mock library
find_path(GMOCK_SRC_DIR NAMES src/gmock.cc src/gmock-all.cc PATHS /usr/src PATH_SUFFIXES gmock)
find_path(GMOCK_INCLUDE_DIR gmock/gmock.h PATHS /usr/include)
if(GMOCK_SRC_DIR AND GMOCK_INCLUDE_DIR)
message(STATUS "Using system gmock library in ${GMOCK_SRC_DIR}")
include_directories(${GMOCK_SRC_DIR})
# gmock-all.cc includes all other sources
add_library(gmock STATIC ${GMOCK_SRC_DIR}/src/gmock-all.cc)
else()
message(STATUS "Using bundled gmock library")
set(GMOCK_SRC_DIR ${colobot_SOURCE_DIR}/lib/gmock)
set(GMOCK_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/gmock/include)
add_subdirectory(${GMOCK_SRC_DIR} bin/gmock)
endif()
endif()
# Installation paths defined before compiling sources
set(COLOBOT_INSTALL_BIN_DIR games CACHE PATH "Colobot binary directory")
set(COLOBOT_INSTALL_DATA_DIR share/games/colobot CACHE PATH "Colobot shared data directory")
set(COLOBOT_INSTALL_LIB_DIR lib/colobot CACHE PATH "Colobot libraries directory")
set(COLOBOT_INSTALL_DOC_DIR share/doc/colobot CACHE PATH "Colobot documentation directory")
set(COLOBOT_INSTALL_I18N_DIR share/locale CACHE PATH "Colobot translations directory")
# Subdirectory with sources
add_subdirectory(src bin)
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()

View File

@ -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

View File

@ -13,7 +13,7 @@ libraries and tools.
so moving that directory can be tricky.
3. `cd' to the MXE root directory.
It already contains a univeral Makefile for everything.
It already contains a universal Makefile for everything.
Usage is simply `make [name_of_package]'.
It will automatically check for dependencies, etc.
The packages will be installed in the MXE directory in usr/.
@ -61,4 +61,4 @@ libraries and tools.
The exe is linked against all libraries *statically*, so there are no dependencies
on external dlls. However, the resulting binary will be huge with all these libraries,
so you should `strip bin/colobot.exe'.

View File

@ -20,7 +20,7 @@ How to...
http://www.cmake.org/cmake/resources/software.html (the Windows zip file)
Unpack the contents of the archive to where MinGW is installed (files from bin/ should go into bin/, etc.)
3. Download the following libraries, installing them in your MinGW directory like with CMake:
SDL >=1.2.10, SDL_imgage >= 1.2, SDL_ttf >= 2.0, libpng >= 1.2, GLEW >= 1.8.0, Boost >= 1.51 (with filesystem)
SDL >=1.2.10, SDL_image >= 1.2, SDL_ttf >= 2.0, libpng >= 1.2, GLEW >= 1.8.0, Boost >= 1.51 (with filesystem)
Note #1: For most libraries, you can download binary packages with compiled files.
However, you must ensure that they work with MinGW as some are built with MSVC
and may be incompatible. If that is the case, you should compile the libraries from sources
@ -37,7 +37,7 @@ How to...
Since you're running Linux, you probably know how to do this anyway ;)
But just in case, here's what you need:
gcc compiler (with gcc-g++), cmake, libraries with header files: SDL, SDL_image, SDL_ttf, libpng
gcc compiler (with gcc-g++), cmake, libraries with header files: SDL, SDL_image, SDL_ttf, libpng, boost
Instructions are the same:
$ cmake .
$ make
@ -66,7 +66,7 @@ Jak...
1.1 Windows:
CROSS-KOMPILACJA: zobacz plik HOWTO-MXE.txt z instrukcjami jak cross-skompilować projekt używając
CROSS-KOMPILACJA: zobacz plik HOWTO-MXE.txt z instrukcjami (po angielsku) jak cross-skompilować projekt używając
MXE (http://mxe.cc/).
UWAGA: obecnie występują problemy z kompilacją na Windowsie, głównie ze względu na konflikt w makrach,
@ -79,14 +79,13 @@ Jak...
2. Ściągamy i instalujemy CMake:
http://www.cmake.org/cmake/resources/software.html (plik zip dla Windowsa)
Zip rozpakowujemy do katalogu, gdzie zainstalowany jest MinGW (pliki z bin/ mają trafić do bin/ itd.).
3. Ścągamy następujące biblioteki i instalujemy je tam, gdzie MinGW, podobnie jak z CMake:
3. Ściągamy następujące biblioteki i instalujemy je tam, gdzie MinGW, podobnie jak z CMake:
SDL >= 1.2.10, SDL_image >= 1.2, SDL_ttf >= 2.0, libpng >= 1.2, Boost >= 1.51 (wraz z filesystem)
Uwaga #1: W większości wymienionych bibliotek można ściągnąć paczki binarne ze skompilowanymi plikami.
Jednak musisz się upewnić, że pliki te będą współpracowały z MinGW, bo część z nich
jest kompilowana MSVC i może być niezgodna. W takim wypadku, musisz skompilować bibliotekę
ze źródeł pod MinGW.
Uwaga #2: W przypadku GLEW, musisz skompilować bibiotekę ze źródeł pod MinGW. Ponieważ nie ma skryptu
Uwaga #2: W przypadku GLEW, musisz skompilować bibliotekę ze źródeł pod MinGW. Ponieważ nie ma skryptu
make do tego, użyj poleceń opisanych tutaj: http://stackoverflow.com/questions/6005076/
4. Uruchamiamy MinGW console ze skrótu w menu start.
5. Przechodzimy do katalogu, gdzie są źródła wpisując "cd /c/tam/gdzie/sa/zrodla"
@ -96,9 +95,9 @@ Jak...
1.2 Linux:
Skoro już masz Linuksa, to prawdpobodobnie wiesz co robić ;)
Skoro już masz Linuksa, to prawdopodobnie wiesz co robić ;)
Ale na wszelki wypadek, potrzebujesz tego:
kompilator gcc (razem z gcc-g++), cmake, biblioteki wraz z nagłówkami: SDL, SDL_image, SDL_ttf, libpng
kompilator gcc (razem z gcc-g++), cmake, biblioteki wraz z nagłówkami: SDL, SDL_image, SDL_ttf, libpng, boost
Polecenia są takie same:
$ cmake .
$ make

View File

@ -1,87 +1,91 @@
EN
# English
Welcome to Colobot project repository
Welcome to the Colobot project code repository
NOTE: this is the new repository which was moved here from https://github.com/adiblol/colobot. The new repository has been purged of binary files cluttering the history, so all commits have been overwritten. If you have been using the old repository, you have to clone from scratch the new one.
> NOTE: this is the new repository which was moved here from https://github.com/adiblol/colobot. The new repository has been purged of binary files cluttering the history, so all commits have been overwritten. If you have been using the old repository, you have to clone from scratch the new one.
This is official repository for the open-source Colobot project developed by Polish Portal of Colobot (PPC; Polish: Polski Portal Colobota) with the official site at: http://colobot.cba.pl/.
This is official repository for the open-source Colobot project developed by Polish Portal of Colobot (PPC; in Polish: Polski Portal Colobota) with the official site at: http://colobot.info/.
The source code contained here was released by Epsitec -- the original creator of the game -- on open source (GPLv3) license. The code was given and the rights granted specifically to PPC community in March 2012. Since then, we have been modifying the code and working on our goals, which are briefly summed up below.
More information for developers can be found at developer wiki at: http://colobot.info/wiki. However, the freshest source of information is our IRC channel #colobot at pirc.pl.
More information for developers (in English) can be found on the [developer wiki](https://colobot.info/wiki/Dev:Main_Page). However, the freshest source of information is our IRC channels, see below.
This repository contains only the source code of the project. The game requires also data files which are available in separate packages, currently from http://colobot.info/files. The packages are named colobot-data-YYYY-MM-DD.zip. Make sure you have the latest package before compiling and running the code in repository.
This repository contains only the source code of the project. The game requires also data files which are available in separate packages, currently at http://colobot.info/files/. The packages are named colobot-data-YYYY-MM-DD.zip. Make sure you have the latest package before compiling and running the code in repository.
Status
## Status
Our main goals can be summed up in three milestones:
Milestone 1 - Colobot Classic
### Milestone 1 - Colobot Classic
This is the original version of the game, as released to us by Epsitec with only minor changes and bugfixes. It is available as a tag named colobot-original in the repository. This version will not be developed further. The compiled version and data packs needed to run the game (split by language version) can be found at: http://colobot.info/files.
This is the original version of the game, as released to us by Epsitec with only minor changes and bugfixes. It is available as a tag named colobot-original in the repository. This version will not be developed further. The compiled version and data packs needed to run the game (split by language version) can also be found at http://colobot.info/files/.
Milestone 2 - Colobot Gold
### Milestone 2 - Colobot Gold
This is a version of the game that is currently being developed in this repository. It is based on the original code, but refreshed and rewritten using SDL and OpenGL libraries, thus making it multiplatform.
As of September 2012, we have rewritten almost all of the original code and we are in the process of testing and fixing issues that are still present in the game. The game runs and compiles under Windows and Linux. The master branch contains the current snapshot code which should always compile and run with the latest data pack. The dev branch and dev-* sub-branches are used for general development.
As of September 2012, we have rewritten almost all of the original code and we are in the process of testing and fixing issues that are still present in the game. The game runs and compiles under Windows and Linux. The master branch contains the current snapshot code which should always compile and run with the latest data pack. The dev branch and dev-\* sub-branches are used for general development.
Milestone 3 - Colobot 2
### Milestone 3 - Colobot 2
This will be a new installment in the Colobot series. We have many ideas for the new game and we are still discussing them. Generally, the development of this version will begin only after finishing Colobot Gold (it will be probably hosted in another repository, forked off the Colobot Gold code).
Compiling and running the game
## Compiling and running the game
For these instructions see HOWTO.txt file.
Contact
## Contact
If you want to help in the project, please contact us on our IRC channel #colobot at pirc.pl or the forum on our website: http://colobot.cba.pl/forum (there is also an English board). We're in the process of moving to a new site and forum so not all information on our old site is up-to-date, but we're be done soon.
If you want to help in the project, please contact us on our IRC channels or the forum on our website: http://colobot.info/forum (Polish only). We're in the process of moving to a new site and forum so not all information on our old site is up-to-date, but we'll be done soon.
### IRC channels
* [#colobot on pirc.pl](irc://pirc.pl#colobot) in Polish;
* [#colobot on Freenode](irc://freenode.net#colobot) in English;
PL
# PL
Witamy w repozytorium projektu Colobot
UWAGA: to jest nowe repozytorium, które zostało przeniesione tu z https://github.com/adiblol/colobot. Nowe repozytorium zostało wyczyszczone z plików binarnych, które zostały w historii, więc wszystkie commity zostały nadpisane. Jeżeli korzystałeś/aś ze starego repozytorium, musisz sklonować od zera te nowe.
> UWAGA: to jest nowe repozytorium, które zostało przeniesione tu z https://github.com/adiblol/colobot. Nowe repozytorium zostało wyczyszczone z plików binarnych, które zostały w historii, więc wszystkie commity zostały nadpisane. Jeżeli korzystałeś/aś ze starego repozytorium, musisz sklonować od zera te nowe.
To jest oficjalne repozytorium z kodem projektu open-source Colobot rozwijanego przez Polski Portal Colobota (PPC; angielski: Polish Portal of Colobot) z oficjalną stroną: http://colobot.cba.pl/.
To jest oficjalne repozytorium z kodem projektu open-source Colobot rozwijanego przez Polski Portal Colobota (PPC; po angielsku: Polish Portal of Colobot) z oficjalną stroną: http://colobot.info/.
Kod źródłowy zawarty tutaj został wydany przez Epsitec -- oryginalnego twórcę gry -- na otwartej licencji (GPLv3). Kod został wydany i prawa nadane specjalnie dla społeczności PPC w marcu 2012. Od tamtej pory, zajmujemy się modyfikowaniem kodu i pracowaniem nad naszymi celami, które są krótko podsumowane poniżej.
Więcej informacji dla developerów projektu można znaleźć na wiki dla developerów: http://colobot.info/wiki. Jednak źródłem najświeższych informacji jest nasz kanał IRC #colobot na pirc.pl.
Więcej informacji dla developerów projektu (po angielsku) można znaleźć na [wiki dla developerów](http://colobot.info/wiki/Dev:Main_Page). Jednak źródłem najświeższych informacji jest nasz kanał IRC #colobot na pirc.pl.
To repozytorium zawiera jedynie kod źródłowy projektu. Gra wymaga jeszcze plików danych, które są dostępne w osobnych paczkach, obecnie na stronie http://colobot.info/files. Paczki są nazwane colobot-data-RRRR-MM-DD.zip. Upewnij się, że masz najnowszą wersję paczki zanim skompilujesz i uruchomisz kod z repozytorium.
Status
## Status
Nasze główne cele można podsumować w trzech cel, które chcemy osiągnąć:
Cel 1 - Colobot Classic
### Cel 1 - Colobot Classic
To jest oryginalna wersja gry, dokładnie taka, jaką otrzymaliśmy od Epsiteca z jedynie niewielkimi zmianami i poprawkami. Jest dostępna jako tag nazwany colobot-original w repozytorium. Ta wersja nie będzie dalej rozwijana. Skompilowaną wersję wraz z potrzebnymi paczkami danych (podzielone wg wersji językowej) można pobrać z http://colobot.info/files.
Cel 2 - Colobot Gold
### Cel 2 - Colobot Gold
Jest to wersja gry, którą obecnie rozwijamy w tym repozytorium. Jest oparta na oryginalnym kodzie, ale odświeżonym i przepisanym z wykorzystaniem bibliotek SDL i OpenGL, czyniąc ją wieloplatformową.
Do września 2012, przepisaliśmy prawie cały oryginalny kod i jesteśmy teraz w trakcie testowania i poprawiania błędów nadal obecnych w grze. Gałąź master zawiera obecny snapshot kodu, który powinien zawsze dać się skompilować i uruchomić z najnowszą paczką danych. Gałęzie dev i podgałęzie dev-* są wykorzystywane do ogólnego rozwoju.
Do września 2012, przepisaliśmy prawie cały oryginalny kod i jesteśmy teraz w trakcie testowania i poprawiania błędów nadal obecnych w grze. Gałąź master zawiera obecny snapshot kodu, który powinien zawsze dać się skompilować i uruchomić z najnowszą paczką danych. Gałęzie dev i podgałęzie dev-\* są wykorzystywane do ogólnego rozwoju.
Krok 3 - Colobot 2
### Krok 3 - Colobot 2
To będzie nowa część z cyklu gier Colobot. Mamy wiele pomysłów na nową grę i nadal dyskutujemy nad nimi. Ogólnie, rozwój tej wersji zacznie się po skończeniu wersji Colobot Gold (prawdopodobnie będzie hostowane w osobnym repozytorium, sforkowanym z kodu Colobot Gold).
Kompilacja i uruchomienie gry
## Kompilacja i uruchomienie gry
Instrukcje te znajdują się w pliku HOWTO.txt.
Kontakt
## Kontakt
Jeżeli chcesz pomóc w projekcie, prosimy o kontakt na naszym kanale IRC: #colobot na pirc.pl albo na forum na naszej stronie: http://colobot.cba.pl/forum. Jesteśmy teraz w trakcie przenoszenia strony i forum w nowe miejsce i nie wszystkie informacje na starej stronie są aktualne, ale już niedługo skończymy przenosiny.
Jeżeli chcesz pomóc w projekcie, prosimy o kontakt na naszym kanale IRC: #colobot na pirc.pl (po polsku i angielsku) albo na forum na naszej stronie: http://colobot.info/forum (jedynie polski). Jesteśmy teraz w trakcie przenoszenia strony i forum w nowe miejsce i nie wszystkie informacje na starej stronie są aktualne, ale już niedługo skończymy przenosiny.

View File

@ -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)

1
data Submodule

@ -0,0 +1 @@
Subproject commit 6b6e5a0ab56bf42f17d969c1bd4c09185605cad6

6
lib/gmock/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.8)
include_directories(. include ${GTEST_INCLUDE_DIR})
# gmock-all.cc includes all other sources
add_library(gmock STATIC src/gmock-all.cc)

5
lib/gmock/README.txt Normal file
View File

@ -0,0 +1,5 @@
This directory contains part of distribution of Google Test (http://code.google.com/p/googletest/)
- a C++ framework for unit tests. There are source files, include headers and a custom CMakeLists.txt
to compile static library. Only these files are kept from the official distribution as only
they are necessary. For more info, see the original README file from gtest: REDME-gtest.txt.
License info is kept in the original COPYING.txt.

View File

@ -7,4 +7,3 @@ add_definitions(-DGTEST_HAS_PTHREAD=0)
# gtest-all.cc includes all other sources
add_library(gtest STATIC src/gtest-all.cc)
add_library(gmock STATIC src/gmock-all.cc)

View File

@ -1,424 +0,0 @@
Google C++ Testing Framework
============================
http://code.google.com/p/googletest/
Overview
--------
Google's framework for writing C++ tests on a variety of platforms
(Linux, Mac OS X, Windows, Windows CE, Symbian, etc). Based on the
xUnit architecture. Supports automatic test discovery, a rich set of
assertions, user-defined assertions, death tests, fatal and non-fatal
failures, various options for running the tests, and XML test report
generation.
Please see the project page above for more information as well as the
mailing list for questions, discussions, and development. There is
also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please
join us!
Requirements for End Users
--------------------------
Google Test is designed to have fairly minimal requirements to build
and use with your projects, but there are some. Currently, we support
Linux, Windows, Mac OS X, and Cygwin. We will also make our best
effort to support other platforms (e.g. Solaris, AIX, and z/OS).
However, since core members of the Google Test project have no access
to these platforms, Google Test may have outstanding issues there. If
you notice any problems on your platform, please notify
googletestframework@googlegroups.com. Patches for fixing them are
even more welcome!
### Linux Requirements ###
These are the base requirements to build and use Google Test from a source
package (as described below):
* GNU-compatible Make or gmake
* POSIX-standard shell
* POSIX(-2) Regular Expressions (regex.h)
* A C++98-standard-compliant compiler
### Windows Requirements ###
* Microsoft Visual C++ 7.1 or newer
### Cygwin Requirements ###
* Cygwin 1.5.25-14 or newer
### Mac OS X Requirements ###
* Mac OS X 10.4 Tiger or newer
* Developer Tools Installed
Also, you'll need CMake 2.6.4 or higher if you want to build the
samples using the provided CMake script, regardless of the platform.
Requirements for Contributors
-----------------------------
We welcome patches. If you plan to contribute a patch, you need to
build Google Test and its own tests from an SVN checkout (described
below), which has further requirements:
* Python version 2.3 or newer (for running some of the tests and
re-generating certain source files from templates)
* CMake 2.6.4 or newer
Getting the Source
------------------
There are two primary ways of getting Google Test's source code: you
can download a stable source release in your preferred archive format,
or directly check out the source from our Subversion (SVN) repositary.
The SVN checkout requires a few extra steps and some extra software
packages on your system, but lets you track the latest development and
make patches much more easily, so we highly encourage it.
### Source Package ###
Google Test is released in versioned source packages which can be
downloaded from the download page [1]. Several different archive
formats are provided, but the only difference is the tools used to
manipulate them, and the size of the resulting file. Download
whichever you are most comfortable with.
[1] http://code.google.com/p/googletest/downloads/list
Once the package is downloaded, expand it using whichever tools you
prefer for that type. This will result in a new directory with the
name "gtest-X.Y.Z" which contains all of the source code. Here are
some examples on Linux:
tar -xvzf gtest-X.Y.Z.tar.gz
tar -xvjf gtest-X.Y.Z.tar.bz2
unzip gtest-X.Y.Z.zip
### SVN Checkout ###
To check out the main branch (also known as the "trunk") of Google
Test, run the following Subversion command:
svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
Setting up the Build
--------------------
To build Google Test and your tests that use it, you need to tell your
build system where to find its headers and source files. The exact
way to do it depends on which build system you use, and is usually
straightforward.
### Generic Build Instructions ###
Suppose you put Google Test in directory ${GTEST_DIR}. To build it,
create a library build target (or a project as called by Visual Studio
and Xcode) to compile
${GTEST_DIR}/src/gtest-all.cc
with
${GTEST_DIR}/include and ${GTEST_DIR}
in the header search path. Assuming a Linux-like system and gcc,
something like the following will do:
g++ -I${GTEST_DIR}/include -I${GTEST_DIR} -c ${GTEST_DIR}/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
Next, you should compile your test source file with
${GTEST_DIR}/include in the header search path, and link it with gtest
and any other necessary libraries:
g++ -I${GTEST_DIR}/include path/to/your_test.cc libgtest.a -o your_test
As an example, the make/ directory contains a Makefile that you can
use to build Google Test on systems where GNU make is available
(e.g. Linux, Mac OS X, and Cygwin). It doesn't try to build Google
Test's own tests. Instead, it just builds the Google Test library and
a sample test. You can use it as a starting point for your own build
script.
If the default settings are correct for your environment, the
following commands should succeed:
cd ${GTEST_DIR}/make
make
./sample1_unittest
If you see errors, try to tweak the contents of make/Makefile to make
them go away. There are instructions in make/Makefile on how to do
it.
### Using CMake ###
Google Test comes with a CMake build script (CMakeLists.txt) that can
be used on a wide range of platforms ("C" stands for cross-platofrm.).
If you don't have CMake installed already, you can download it for
free from http://www.cmake.org/.
CMake works by generating native makefiles or build projects that can
be used in the compiler environment of your choice. The typical
workflow starts with:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake ${GTEST_DIR} # Generate native build scripts.
If you want to build Google Test's samples, you should replace the
last command with
cmake -Dgtest_build_samples=ON ${GTEST_DIR}
If you are on a *nix system, you should now see a Makefile in the
current directory. Just type 'make' to build gtest.
If you use Windows and have Vistual Studio installed, a gtest.sln file
and several .vcproj files will be created. You can then build them
using Visual Studio.
On Mac OS X with Xcode installed, a .xcodeproj file will be generated.
### Legacy Build Scripts ###
Before settling on CMake, we have been providing hand-maintained build
projects/scripts for Visual Studio, Xcode, and Autotools. While we
continue to provide them for convenience, they are not actively
maintained any more. We highly recommend that you follow the
instructions in the previous two sections to integrate Google Test
with your existing build system.
If you still need to use the legacy build scripts, here's how:
The msvc\ folder contains two solutions with Visual C++ projects.
Open the gtest.sln or gtest-md.sln file using Visual Studio, and you
are ready to build Google Test the same way you build any Visual
Studio project. Files that have names ending with -md use DLL
versions of Microsoft runtime libraries (the /MD or the /MDd compiler
option). Files without that suffix use static versions of the runtime
libraries (the /MT or the /MTd option). Please note that one must use
the same option to compile both gtest and the test code. If you use
Visual Studio 2005 or above, we recommend the -md version as /MD is
the default for new projects in these versions of Visual Studio.
On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using
Xcode. Build the "gtest" target. The universal binary framework will
end up in your selected build directory (selected in the Xcode
"Preferences..." -> "Building" pane and defaults to xcode/build).
Alternatively, at the command line, enter:
xcodebuild
This will build the "Release" configuration of gtest.framework in your
default build location. See the "xcodebuild" man page for more
information about building different configurations and building in
different locations.
Tweaking Google Test
--------------------
Google Test can be used in diverse environments. The default
configuration may not work (or may not work well) out of the box in
some environments. However, you can easily tweak Google Test by
defining control macros on the compiler command line. Generally,
these macros are named like GTEST_XYZ and you define them to either 1
or 0 to enable or disable a certain feature.
We list the most frequently used macros below. For a complete list,
see file include/gtest/internal/gtest-port.h.
### Choosing a TR1 Tuple Library ###
Some Google Test features require the C++ Technical Report 1 (TR1)
tuple library, which is not yet available with all compilers. The
good news is that Google Test implements a subset of TR1 tuple that's
enough for its own need, and will automatically use this when the
compiler doesn't provide TR1 tuple.
Usually you don't need to care about which tuple library Google Test
uses. However, if your project already uses TR1 tuple, you need to
tell Google Test to use the same TR1 tuple library the rest of your
project uses, or the two tuple implementations will clash. To do
that, add
-DGTEST_USE_OWN_TR1_TUPLE=0
to the compiler flags while compiling Google Test and your tests. If
you want to force Google Test to use its own tuple library, just add
-DGTEST_USE_OWN_TR1_TUPLE=1
to the compiler flags instead.
If you don't want Google Test to use tuple at all, add
-DGTEST_HAS_TR1_TUPLE=0
and all features using tuple will be disabled.
### Multi-threaded Tests ###
Google Test is thread-safe where the pthread library is available.
After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
macro to see whether this is the case (yes if the macro is #defined to
1, no if it's undefined.).
If Google Test doesn't correctly detect whether pthread is available
in your environment, you can force it with
-DGTEST_HAS_PTHREAD=1
or
-DGTEST_HAS_PTHREAD=0
When Google Test uses pthread, you may need to add flags to your
compiler and/or linker to select the pthread library, or you'll get
link errors. If you use the CMake script or the deprecated Autotools
script, this is taken care of for you. If you use your own build
script, you'll need to read your compiler and linker's manual to
figure out what flags to add.
### As a Shared Library (DLL) ###
Google Test is compact, so most users can build and link it as a
static library for the simplicity. You can choose to use Google Test
as a shared library (known as a DLL on Windows) if you prefer.
To compile *gtest* as a shared library, add
-DGTEST_CREATE_SHARED_LIBRARY=1
to the compiler flags. You'll also need to tell the linker to produce
a shared library instead - consult your linker's manual for how to do
it.
To compile your *tests* that use the gtest shared library, add
-DGTEST_LINKED_AS_SHARED_LIBRARY=1
to the compiler flags.
Note: while the above steps aren't technically necessary today when
using some compilers (e.g. GCC), they may become necessary in the
future, if we decide to improve the speed of loading the library (see
http://gcc.gnu.org/wiki/Visibility for details). Therefore you are
recommended to always add the above flags when using Google Test as a
shared library. Otherwise a future release of Google Test may break
your build script.
### Avoiding Macro Name Clashes ###
In C++, macros don't obey namespaces. Therefore two libraries that
both define a macro of the same name will clash if you #include both
definitions. In case a Google Test macro clashes with another
library, you can force Google Test to rename its macro to avoid the
conflict.
Specifically, if both Google Test and some other code define macro
FOO, you can add
-DGTEST_DONT_DEFINE_FOO=1
to the compiler flags to tell Google Test to change the macro's name
from FOO to GTEST_FOO. Currently FOO can be FAIL, SUCCEED, or TEST.
For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write
GTEST_TEST(SomeTest, DoesThis) { ... }
instead of
TEST(SomeTest, DoesThis) { ... }
in order to define a test.
Upgrating from an Earlier Version
---------------------------------
We strive to keep Google Test releases backward compatible.
Sometimes, though, we have to make some breaking changes for the
users' long-term benefits. This section describes what you'll need to
do if you are upgrading from an earlier version of Google Test.
### Upgrading from 1.3.0 or Earlier ###
You may need to explicitly enable or disable Google Test's own TR1
tuple library. See the instructions in section "Choosing a TR1 Tuple
Library".
### Upgrading from 1.4.0 or Earlier ###
The Autotools build script (configure + make) is no longer officially
supportted. You are encouraged to migrate to your own build system or
use CMake. If you still need to use Autotools, you can find
instructions in the README file from Google Test 1.4.0.
On platforms where the pthread library is available, Google Test uses
it in order to be thread-safe. See the "Multi-threaded Tests" section
for what this means to your build script.
If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google
Test will no longer compile. This should affect very few people, as a
large portion of STL (including <string>) doesn't compile in this mode
anyway. We decided to stop supporting it in order to greatly simplify
Google Test's implementation.
Developing Google Test
----------------------
This section discusses how to make your own changes to Google Test.
### Testing Google Test Itself ###
To make sure your changes work as intended and don't break existing
functionality, you'll want to compile and run Google Test's own tests.
For that you can use CMake:
mkdir mybuild
cd mybuild
cmake -Dgtest_build_tests=ON ${GTEST_DIR}
Make sure you have Python installed, as some of Google Test's tests
are written in Python. If the cmake command complains about not being
able to find Python ("Could NOT find PythonInterp (missing:
PYTHON_EXECUTABLE)"), try telling it explicitly where your Python
executable can be found:
cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
Next, you can build Google Test and all of its own tests. On *nix,
this is usually done by 'make'. To run the tests, do
make test
All tests should pass.
### Regenerating Source Files ###
Some of Google Test's source files are generated from templates (not
in the C++ sense) using a script. A template file is named FOO.pump,
where FOO is the name of the file it will generate. For example, the
file include/gtest/internal/gtest-type-util.h.pump is used to generate
gtest-type-util.h in the same directory.
Normally you don't need to worry about regenerating the source files,
unless you need to modify them. In that case, you should modify the
corresponding .pump files instead and run the pump.py Python script to
regenerate them. You can find pump.py in the scripts/ directory.
Read the Pump manual [2] for how to use it.
[2] http://code.google.com/p/googletest/wiki/PumpManual
### Contributing a Patch ###
We welcome patches. Please read the Google Test developer's guide [3]
for how you can contribute. In particular, make sure you have signed
the Contributor License Agreement, or we won't be able to accept the
patch.
[3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide
Happy testing!

View File

@ -1,5 +1,424 @@
This directory contains part of distribution of Google Test (http://code.google.com/p/googletest/)
- a C++ framework for unit tests. There are source files, include headers and a custom CMakeLists.txt
to compile static library. Only these files are kept from the official distribution as only
they are necessary. For more info, see the original README file from gtest: REDME-gtest.txt.
License info is kept in the original COPYING.txt.
Google C++ Testing Framework
============================
http://code.google.com/p/googletest/
Overview
--------
Google's framework for writing C++ tests on a variety of platforms
(Linux, Mac OS X, Windows, Windows CE, Symbian, etc). Based on the
xUnit architecture. Supports automatic test discovery, a rich set of
assertions, user-defined assertions, death tests, fatal and non-fatal
failures, various options for running the tests, and XML test report
generation.
Please see the project page above for more information as well as the
mailing list for questions, discussions, and development. There is
also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please
join us!
Requirements for End Users
--------------------------
Google Test is designed to have fairly minimal requirements to build
and use with your projects, but there are some. Currently, we support
Linux, Windows, Mac OS X, and Cygwin. We will also make our best
effort to support other platforms (e.g. Solaris, AIX, and z/OS).
However, since core members of the Google Test project have no access
to these platforms, Google Test may have outstanding issues there. If
you notice any problems on your platform, please notify
googletestframework@googlegroups.com. Patches for fixing them are
even more welcome!
### Linux Requirements ###
These are the base requirements to build and use Google Test from a source
package (as described below):
* GNU-compatible Make or gmake
* POSIX-standard shell
* POSIX(-2) Regular Expressions (regex.h)
* A C++98-standard-compliant compiler
### Windows Requirements ###
* Microsoft Visual C++ 7.1 or newer
### Cygwin Requirements ###
* Cygwin 1.5.25-14 or newer
### Mac OS X Requirements ###
* Mac OS X 10.4 Tiger or newer
* Developer Tools Installed
Also, you'll need CMake 2.6.4 or higher if you want to build the
samples using the provided CMake script, regardless of the platform.
Requirements for Contributors
-----------------------------
We welcome patches. If you plan to contribute a patch, you need to
build Google Test and its own tests from an SVN checkout (described
below), which has further requirements:
* Python version 2.3 or newer (for running some of the tests and
re-generating certain source files from templates)
* CMake 2.6.4 or newer
Getting the Source
------------------
There are two primary ways of getting Google Test's source code: you
can download a stable source release in your preferred archive format,
or directly check out the source from our Subversion (SVN) repositary.
The SVN checkout requires a few extra steps and some extra software
packages on your system, but lets you track the latest development and
make patches much more easily, so we highly encourage it.
### Source Package ###
Google Test is released in versioned source packages which can be
downloaded from the download page [1]. Several different archive
formats are provided, but the only difference is the tools used to
manipulate them, and the size of the resulting file. Download
whichever you are most comfortable with.
[1] http://code.google.com/p/googletest/downloads/list
Once the package is downloaded, expand it using whichever tools you
prefer for that type. This will result in a new directory with the
name "gtest-X.Y.Z" which contains all of the source code. Here are
some examples on Linux:
tar -xvzf gtest-X.Y.Z.tar.gz
tar -xvjf gtest-X.Y.Z.tar.bz2
unzip gtest-X.Y.Z.zip
### SVN Checkout ###
To check out the main branch (also known as the "trunk") of Google
Test, run the following Subversion command:
svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
Setting up the Build
--------------------
To build Google Test and your tests that use it, you need to tell your
build system where to find its headers and source files. The exact
way to do it depends on which build system you use, and is usually
straightforward.
### Generic Build Instructions ###
Suppose you put Google Test in directory ${GTEST_DIR}. To build it,
create a library build target (or a project as called by Visual Studio
and Xcode) to compile
${GTEST_DIR}/src/gtest-all.cc
with
${GTEST_DIR}/include and ${GTEST_DIR}
in the header search path. Assuming a Linux-like system and gcc,
something like the following will do:
g++ -I${GTEST_DIR}/include -I${GTEST_DIR} -c ${GTEST_DIR}/src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
Next, you should compile your test source file with
${GTEST_DIR}/include in the header search path, and link it with gtest
and any other necessary libraries:
g++ -I${GTEST_DIR}/include path/to/your_test.cc libgtest.a -o your_test
As an example, the make/ directory contains a Makefile that you can
use to build Google Test on systems where GNU make is available
(e.g. Linux, Mac OS X, and Cygwin). It doesn't try to build Google
Test's own tests. Instead, it just builds the Google Test library and
a sample test. You can use it as a starting point for your own build
script.
If the default settings are correct for your environment, the
following commands should succeed:
cd ${GTEST_DIR}/make
make
./sample1_unittest
If you see errors, try to tweak the contents of make/Makefile to make
them go away. There are instructions in make/Makefile on how to do
it.
### Using CMake ###
Google Test comes with a CMake build script (CMakeLists.txt) that can
be used on a wide range of platforms ("C" stands for cross-platofrm.).
If you don't have CMake installed already, you can download it for
free from http://www.cmake.org/.
CMake works by generating native makefiles or build projects that can
be used in the compiler environment of your choice. The typical
workflow starts with:
mkdir mybuild # Create a directory to hold the build output.
cd mybuild
cmake ${GTEST_DIR} # Generate native build scripts.
If you want to build Google Test's samples, you should replace the
last command with
cmake -Dgtest_build_samples=ON ${GTEST_DIR}
If you are on a *nix system, you should now see a Makefile in the
current directory. Just type 'make' to build gtest.
If you use Windows and have Vistual Studio installed, a gtest.sln file
and several .vcproj files will be created. You can then build them
using Visual Studio.
On Mac OS X with Xcode installed, a .xcodeproj file will be generated.
### Legacy Build Scripts ###
Before settling on CMake, we have been providing hand-maintained build
projects/scripts for Visual Studio, Xcode, and Autotools. While we
continue to provide them for convenience, they are not actively
maintained any more. We highly recommend that you follow the
instructions in the previous two sections to integrate Google Test
with your existing build system.
If you still need to use the legacy build scripts, here's how:
The msvc\ folder contains two solutions with Visual C++ projects.
Open the gtest.sln or gtest-md.sln file using Visual Studio, and you
are ready to build Google Test the same way you build any Visual
Studio project. Files that have names ending with -md use DLL
versions of Microsoft runtime libraries (the /MD or the /MDd compiler
option). Files without that suffix use static versions of the runtime
libraries (the /MT or the /MTd option). Please note that one must use
the same option to compile both gtest and the test code. If you use
Visual Studio 2005 or above, we recommend the -md version as /MD is
the default for new projects in these versions of Visual Studio.
On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using
Xcode. Build the "gtest" target. The universal binary framework will
end up in your selected build directory (selected in the Xcode
"Preferences..." -> "Building" pane and defaults to xcode/build).
Alternatively, at the command line, enter:
xcodebuild
This will build the "Release" configuration of gtest.framework in your
default build location. See the "xcodebuild" man page for more
information about building different configurations and building in
different locations.
Tweaking Google Test
--------------------
Google Test can be used in diverse environments. The default
configuration may not work (or may not work well) out of the box in
some environments. However, you can easily tweak Google Test by
defining control macros on the compiler command line. Generally,
these macros are named like GTEST_XYZ and you define them to either 1
or 0 to enable or disable a certain feature.
We list the most frequently used macros below. For a complete list,
see file include/gtest/internal/gtest-port.h.
### Choosing a TR1 Tuple Library ###
Some Google Test features require the C++ Technical Report 1 (TR1)
tuple library, which is not yet available with all compilers. The
good news is that Google Test implements a subset of TR1 tuple that's
enough for its own need, and will automatically use this when the
compiler doesn't provide TR1 tuple.
Usually you don't need to care about which tuple library Google Test
uses. However, if your project already uses TR1 tuple, you need to
tell Google Test to use the same TR1 tuple library the rest of your
project uses, or the two tuple implementations will clash. To do
that, add
-DGTEST_USE_OWN_TR1_TUPLE=0
to the compiler flags while compiling Google Test and your tests. If
you want to force Google Test to use its own tuple library, just add
-DGTEST_USE_OWN_TR1_TUPLE=1
to the compiler flags instead.
If you don't want Google Test to use tuple at all, add
-DGTEST_HAS_TR1_TUPLE=0
and all features using tuple will be disabled.
### Multi-threaded Tests ###
Google Test is thread-safe where the pthread library is available.
After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE
macro to see whether this is the case (yes if the macro is #defined to
1, no if it's undefined.).
If Google Test doesn't correctly detect whether pthread is available
in your environment, you can force it with
-DGTEST_HAS_PTHREAD=1
or
-DGTEST_HAS_PTHREAD=0
When Google Test uses pthread, you may need to add flags to your
compiler and/or linker to select the pthread library, or you'll get
link errors. If you use the CMake script or the deprecated Autotools
script, this is taken care of for you. If you use your own build
script, you'll need to read your compiler and linker's manual to
figure out what flags to add.
### As a Shared Library (DLL) ###
Google Test is compact, so most users can build and link it as a
static library for the simplicity. You can choose to use Google Test
as a shared library (known as a DLL on Windows) if you prefer.
To compile *gtest* as a shared library, add
-DGTEST_CREATE_SHARED_LIBRARY=1
to the compiler flags. You'll also need to tell the linker to produce
a shared library instead - consult your linker's manual for how to do
it.
To compile your *tests* that use the gtest shared library, add
-DGTEST_LINKED_AS_SHARED_LIBRARY=1
to the compiler flags.
Note: while the above steps aren't technically necessary today when
using some compilers (e.g. GCC), they may become necessary in the
future, if we decide to improve the speed of loading the library (see
http://gcc.gnu.org/wiki/Visibility for details). Therefore you are
recommended to always add the above flags when using Google Test as a
shared library. Otherwise a future release of Google Test may break
your build script.
### Avoiding Macro Name Clashes ###
In C++, macros don't obey namespaces. Therefore two libraries that
both define a macro of the same name will clash if you #include both
definitions. In case a Google Test macro clashes with another
library, you can force Google Test to rename its macro to avoid the
conflict.
Specifically, if both Google Test and some other code define macro
FOO, you can add
-DGTEST_DONT_DEFINE_FOO=1
to the compiler flags to tell Google Test to change the macro's name
from FOO to GTEST_FOO. Currently FOO can be FAIL, SUCCEED, or TEST.
For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write
GTEST_TEST(SomeTest, DoesThis) { ... }
instead of
TEST(SomeTest, DoesThis) { ... }
in order to define a test.
Upgrating from an Earlier Version
---------------------------------
We strive to keep Google Test releases backward compatible.
Sometimes, though, we have to make some breaking changes for the
users' long-term benefits. This section describes what you'll need to
do if you are upgrading from an earlier version of Google Test.
### Upgrading from 1.3.0 or Earlier ###
You may need to explicitly enable or disable Google Test's own TR1
tuple library. See the instructions in section "Choosing a TR1 Tuple
Library".
### Upgrading from 1.4.0 or Earlier ###
The Autotools build script (configure + make) is no longer officially
supportted. You are encouraged to migrate to your own build system or
use CMake. If you still need to use Autotools, you can find
instructions in the README file from Google Test 1.4.0.
On platforms where the pthread library is available, Google Test uses
it in order to be thread-safe. See the "Multi-threaded Tests" section
for what this means to your build script.
If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google
Test will no longer compile. This should affect very few people, as a
large portion of STL (including <string>) doesn't compile in this mode
anyway. We decided to stop supporting it in order to greatly simplify
Google Test's implementation.
Developing Google Test
----------------------
This section discusses how to make your own changes to Google Test.
### Testing Google Test Itself ###
To make sure your changes work as intended and don't break existing
functionality, you'll want to compile and run Google Test's own tests.
For that you can use CMake:
mkdir mybuild
cd mybuild
cmake -Dgtest_build_tests=ON ${GTEST_DIR}
Make sure you have Python installed, as some of Google Test's tests
are written in Python. If the cmake command complains about not being
able to find Python ("Could NOT find PythonInterp (missing:
PYTHON_EXECUTABLE)"), try telling it explicitly where your Python
executable can be found:
cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}
Next, you can build Google Test and all of its own tests. On *nix,
this is usually done by 'make'. To run the tests, do
make test
All tests should pass.
### Regenerating Source Files ###
Some of Google Test's source files are generated from templates (not
in the C++ sense) using a script. A template file is named FOO.pump,
where FOO is the name of the file it will generate. For example, the
file include/gtest/internal/gtest-type-util.h.pump is used to generate
gtest-type-util.h in the same directory.
Normally you don't need to worry about regenerating the source files,
unless you need to modify them. In that case, you should modify the
corresponding .pump files instead and run the pump.py Python script to
regenerate them. You can find pump.py in the scripts/ directory.
Read the Pump manual [2] for how to use it.
[2] http://code.google.com/p/googletest/wiki/PumpManual
### Contributing a Patch ###
We welcome patches. Please read the Google Test developer's guide [3]
for how you can contribute. In particular, make sure you have signed
the Contributor License Agreement, or we won't be able to accept the
patch.
[3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide
Happy testing!

View File

@ -127,7 +127,8 @@ CBotString::CBotString()
CBotString::~CBotString()
{
free(m_ptr); //we can call free on null pointer as it's save
delete[] m_ptr;
m_ptr = nullptr;
}
@ -138,7 +139,7 @@ CBotString::CBotString(const char* p)
m_ptr = NULL;
if (m_lg>0)
{
m_ptr = static_cast<char*>(malloc(m_lg+1));
m_ptr = new char[m_lg+1];
strcpy(m_ptr, p);
}
}
@ -150,7 +151,7 @@ CBotString::CBotString(const CBotString& srcString)
m_ptr = NULL;
if (m_lg>0)
{
m_ptr = static_cast<char*>(malloc(m_lg+1));
m_ptr = new char[m_lg+1];
strcpy(m_ptr, srcString.m_ptr);
}
}
@ -285,12 +286,12 @@ CBotString CBotString::Mid(int start, int lg)
if ( lg < 0 ) lg = m_lg - start;
char* p = static_cast<char*>(malloc(m_lg+1));
char* p = new char[m_lg+1];
strcpy(p, m_ptr+start);
p[lg] = 0;
res = p;
free(p);
delete[] p;
return res;
}
@ -314,15 +315,16 @@ void CBotString::MakeLower()
bool CBotString::LoadString(unsigned int id)
{
const char * str = NULL;
const char * str = nullptr;
str = MapIdToString(static_cast<EID>(id));
if (m_ptr != NULL) free(m_ptr);
if (m_ptr != nullptr)
delete[] m_ptr;
m_lg = strlen(str);
m_ptr = NULL;
if (m_lg > 0)
{
m_ptr = static_cast<char*>(malloc(m_lg+1));
m_ptr = new char[m_lg+1];
strcpy(m_ptr, str);
return true;
}
@ -332,14 +334,14 @@ bool CBotString::LoadString(unsigned int id)
const CBotString& CBotString::operator=(const CBotString& stringSrc)
{
free(m_ptr);
m_ptr = NULL;
delete[] m_ptr;
m_ptr = nullptr;
m_lg = stringSrc.m_lg;
if (m_lg > 0)
{
m_ptr = static_cast<char*>(malloc(m_lg+1));
m_ptr = new char[m_lg+1];
strcpy(m_ptr, stringSrc.m_ptr);
}
@ -355,13 +357,13 @@ CBotString operator+(const CBotString& string, const char * lpsz)
const CBotString& CBotString::operator+(const CBotString& stringSrc)
{
char* p = static_cast<char*>(malloc(m_lg+stringSrc.m_lg+1));
char* p = new char[m_lg+stringSrc.m_lg+1];
if (m_ptr!=NULL) strcpy(p, m_ptr);
char* pp = p + m_lg;
if (stringSrc.m_ptr!=NULL) strcpy(pp, stringSrc.m_ptr);
free(m_ptr);
delete[] m_ptr;
m_ptr = p;
m_lg += stringSrc.m_lg;
@ -370,11 +372,11 @@ const CBotString& CBotString::operator+(const CBotString& stringSrc)
const CBotString& CBotString::operator=(const char ch)
{
free(m_ptr);
delete[] m_ptr;
m_lg = 1;
m_ptr = static_cast<char*>(malloc(2));
m_ptr = new char[2];
m_ptr[0] = ch;
m_ptr[1] = 0;
@ -383,16 +385,16 @@ const CBotString& CBotString::operator=(const char ch)
const CBotString& CBotString::operator=(const char* pString)
{
free(m_ptr);
m_ptr = NULL;
delete[] m_ptr;
m_ptr = nullptr;
if (pString != NULL)
if (pString != nullptr)
{
m_lg = strlen(pString);
if (m_lg != 0)
{
m_ptr = static_cast<char*>(malloc(m_lg+1));
m_ptr = new char[m_lg+1];
strcpy(m_ptr, pString);
}
}
@ -403,13 +405,13 @@ const CBotString& CBotString::operator=(const char* pString)
const CBotString& CBotString::operator+=(const char ch)
{
char* p = static_cast<char*>(malloc(m_lg+2));
char* p = new char[m_lg+2];
if (m_ptr!=NULL) strcpy(p, m_ptr);
if (m_ptr != nullptr) strcpy(p, m_ptr);
p[m_lg++] = ch;
p[m_lg] = 0;
free(m_ptr);
delete[] m_ptr;
m_ptr = p;
@ -418,7 +420,7 @@ const CBotString& CBotString::operator+=(const char ch)
const CBotString& CBotString::operator+=(const CBotString& str)
{
char* p = static_cast<char*>(malloc(m_lg+str.m_lg+1));
char* p = new char[m_lg+str.m_lg+1];
strcpy(p, m_ptr);
char* pp = p + m_lg;
@ -426,7 +428,7 @@ const CBotString& CBotString::operator+=(const CBotString& str)
m_lg = m_lg + str.m_lg;
free(m_ptr);
delete[] m_ptr;
m_ptr = p;
@ -500,8 +502,8 @@ bool CBotString::IsEmpty() const
void CBotString::Empty()
{
free(m_ptr);
m_ptr = NULL;
delete[] m_ptr;
m_ptr = nullptr;
m_lg = 0;
}

View File

@ -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)

View File

@ -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")

View File

@ -4,6 +4,10 @@ add_subdirectory(CBot)
# Tools directory is built separately
add_subdirectory(tools)
add_subdirectory(po)
add_subdirectory(desktop)
# Tests
if(${TESTS})
add_subdirectory(common/test)
@ -25,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")
@ -40,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
@ -159,10 +187,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}
@ -172,8 +200,8 @@ ${PNG_LIBRARIES}
${OPTIONAL_LIBS}
${PLATFORM_LIBS}
${Boost_LIBRARIES}
ltdl
CBot
${OPENAL_LIBS}
)
include_directories(
@ -194,4 +222,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})

View File

@ -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"
@ -30,17 +31,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
@ -90,7 +95,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;
@ -138,9 +142,9 @@ CApplication::CApplication()
m_mouseButtonsState = 0;
m_trackedKeys = 0;
m_dataPath = "./data";
m_dataPath = COLOBOT_DEFAULT_DATADIR;
m_language = LANGUAGE_ENGLISH;
m_language = LANGUAGE_ENV;
m_lowCPU = true;
@ -150,7 +154,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";
@ -167,9 +170,6 @@ CApplication::~CApplication()
delete m_eventQueue;
m_eventQueue = nullptr;
delete m_pluginManager;
m_pluginManager = nullptr;
delete m_profile;
m_profile = nullptr;
@ -260,7 +260,7 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
else if (arg == "-help")
{
GetLogger()->Message("\n");
GetLogger()->Message("COLOBOT GOLD pre-alpha\n");
GetLogger()->Message("Colobot %s (%s)\n",COLOBOT_CODENAME,COLOBOT_VERSION);
GetLogger()->Message("\n");
GetLogger()->Message("List of available options:\n");
GetLogger()->Message(" -help this help\n");
@ -289,13 +289,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.");
@ -303,66 +300,32 @@ bool CApplication::Create()
return false;
}
/* Gettext initialization */
std::string locale = "C";
switch (m_language)
{
case LANGUAGE_ENGLISH:
locale = "en_US.utf8";
break;
case LANGUAGE_GERMAN:
locale = "de_DE.utf8";
break;
case LANGUAGE_FRENCH:
locale = "fr_FR.utf8";
break;
case LANGUAGE_POLISH:
locale = "pl_PL.utf8";
break;
}
std::string langStr = "LANGUAGE=";
langStr += locale;
strcpy(S_LANGUAGE, langStr.c_str());
putenv(S_LANGUAGE);
setlocale(LC_ALL, locale.c_str());
std::string trPath = m_dataPath + "/" + m_dataDirs[DIR_I18N];
bindtextdomain("colobot", trPath.c_str());
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;
SetLanguage(m_language);
//Create the sound instance.
if (!GetProfile().InitCurrentDirectory()) {
if (!GetProfile().InitCurrentDirectory())
{
GetLogger()->Warn("Config not found. Default values will be used!\n");
m_sound = new CSoundInterface();
} else {
}
else
{
std::string path;
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))
m_sound->CacheAll(path);
else
m_sound->CacheAll(m_dataPath);
m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
}
std::string standardInfoMessage =
@ -397,7 +360,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
@ -417,8 +393,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() )
@ -1459,9 +1434,20 @@ std::string CApplication::GetDataDirPath()
return m_dataPath;
}
std::string CApplication::GetDataFilePath(DataDir dataDir, const std::string& subpath)
std::string CApplication::GetDataSubdirPath(DataDir stdDir)
{
int index = static_cast<int>(dataDir);
int index = static_cast<int>(stdDir);
assert(index >= 0 && index < DIR_MAX);
std::stringstream str;
str << m_dataPath;
str << "/";
str << m_dataDirs[index];
return str.str();
}
std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath)
{
int index = static_cast<int>(stdDir);
assert(index >= 0 && index < DIR_MAX);
std::stringstream str;
str << m_dataPath;
@ -1472,23 +1458,104 @@ std::string CApplication::GetDataFilePath(DataDir dataDir, const std::string& su
return str.str();
}
std::string CApplication::GetDataFilePath(const std::string& subpath)
{
std::stringstream str;
str << m_dataPath;
str << "/";
str << subpath;
return str.str();
}
Language CApplication::GetLanguage()
{
return m_language;
}
char CApplication::GetLanguageChar()
{
char langChar = 'E';
switch (m_language)
{
default:
case LANGUAGE_ENV:
case LANGUAGE_ENGLISH:
langChar = 'E';
break;
case LANGUAGE_GERMAN:
langChar = 'D';
break;
case LANGUAGE_FRENCH:
langChar = 'F';
break;
case LANGUAGE_POLISH:
langChar = 'P';
break;
}
return langChar;
}
void CApplication::SetLanguage(Language language)
{
m_language = language;
/* Gettext initialization */
std::string locale = "";
switch (m_language)
{
default:
case LANGUAGE_ENV:
locale = "";
break;
case LANGUAGE_ENGLISH:
locale = "en_US.utf8";
break;
case LANGUAGE_GERMAN:
locale = "de_DE.utf8";
break;
case LANGUAGE_FRENCH:
locale = "fr_FR.utf8";
break;
case LANGUAGE_POLISH:
locale = "pl_PL.utf8";
break;
}
if (locale.empty())
{
char *envLang = getenv("LANGUAGE");
if (strncmp(envLang,"en",2) == 0)
{
m_language = LANGUAGE_ENGLISH;
}
else if (strncmp(envLang,"de",2) == 0)
{
m_language = LANGUAGE_GERMAN;
}
else if (strncmp(envLang,"fr",2) == 0)
{
m_language = LANGUAGE_FRENCH;
}
else if (strncmp(envLang,"po",2) == 0)
{
m_language = LANGUAGE_POLISH;
}
GetLogger()->Trace("SetLanguage: Inherit LANGUAGE=%s from environment\n", envLang);
}
else
{
std::string langStr = "LANGUAGE=";
langStr += locale;
strcpy(S_LANGUAGE, langStr.c_str());
putenv(S_LANGUAGE);
GetLogger()->Trace("SetLanguage: Set LANGUAGE=%s in environment\n", locale.c_str());
}
setlocale(LC_ALL, "");
bindtextdomain("colobot", COLOBOT_I18N_DIR);
bind_textdomain_codeset("colobot", "UTF-8");
textdomain("colobot");
GetLogger()->Debug("SetLanguage: Test gettext translation: '%s'\n", gettext("Colobot rules!"));
}
void CApplication::SetLowCPU(bool low)

View File

@ -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>
@ -312,15 +311,16 @@ public:
//! Returns the full path to data directory
std::string GetDataDirPath();
//! Returns the full path to a file in data directory given standard dir and subpath
std::string GetDataFilePath(DataDir dir, const std::string &subpath);
//! Returns the full path to a standard dir in data directory
std::string GetDataSubdirPath(DataDir stdDir);
//! Returns the full path to a file in data directory given custom subpath in data dir
std::string GetDataFilePath(const std::string &subpath);
//! Returns the full path to a file in data directory given standard dir and subpath
std::string GetDataFilePath(DataDir stdDir, const std::string &subpath);
//! Management of language
//@{
Language GetLanguage();
char GetLanguageChar();
void SetLanguage(Language language);
//@}
@ -379,8 +379,6 @@ protected:
CSoundInterface* m_sound;
//! Main class of the proper game engine
CRobotMain* m_robotMain;
//! Plugin manager
CPluginManager* m_pluginManager;
//! Profile (INI) reader/writer
CProfile* m_profile;

View File

@ -6,4 +6,13 @@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
#cmakedefine USE_GLEW @USE_GLEW@
#cmakedefine GLEW_STATIC
#cmakedefine GLEW_STATIC
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
#define COLOBOT_CODENAME "@COLOBOT_VERSION_CODENAME@"
#define COLOBOT_FULLNAME "Colobot @COLOBOT_VERSION_CODENAME@"
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
#cmakedefine OPENAL_SOUND

View File

@ -165,6 +165,7 @@ enum Error
*/
enum Language
{
LANGUAGE_ENV = -1,
LANGUAGE_ENGLISH = 0,
LANGUAGE_FRENCH = 1,
LANGUAGE_GERMAN = 2,
@ -180,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

View File

@ -124,14 +124,14 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf)
png_write_info(png_ptr, info_ptr);
png_set_packing(png_ptr);
row_pointers = static_cast<png_bytep*>( malloc(sizeof(png_bytep)*surf->h) );
row_pointers = new png_bytep[surf->h];
for (i = 0; i < surf->h; i++)
row_pointers[i] = static_cast<png_bytep>( static_cast<Uint8 *>(surf->pixels) ) + i*surf->pitch;
png_write_image(png_ptr, row_pointers);
png_write_end(png_ptr, info_ptr);
/* Cleaning out... */
free(row_pointers);
delete[] row_pointers;
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);

View File

@ -17,6 +17,8 @@
#include "common/restext.h"
#include "common/config.h"
#include "common/global.h"
#include "common/event.h"
#include "common/logger.h"
@ -39,7 +41,7 @@ const char* stringsCbot[TX_MAX] = { nullptr };
void InitializeRestext()
{
stringsText[RT_VERSION_ID] = "Colobot Gold";
stringsText[RT_VERSION_ID] = COLOBOT_FULLNAME;
stringsText[RT_DISINFO_TITLE] = "SatCom";
stringsText[RT_WINDOW_MAXIMIZED] = "Maximize";

View File

@ -1,13 +1,16 @@
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(
.
../..
../../..
${GTEST_DIR}/include
${GTEST_INCLUDE_DIR}
)

1
src/desktop/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
lang/

View File

@ -0,0 +1,97 @@
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()
# Create manpage from pod-formatted file
find_program(POD2MAN pod2man)
if(POD2MAN)
set(COLOBOT_MANPAGE_SECTION 6)
macro(podman)
cmake_parse_arguments(PM "" "PODFILE;LOCALE;" "" ${ARGN})
if(PM_LOCALE)
# This copes with the fact that english has no "/LANG" in the paths and filenames.
set(SLASHLOCALE /${PM_LOCALE})
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE})
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
COMMAND ${POD2MAN} ARGS --section=${COLOBOT_MANPAGE_SECTION}
--center="Colobot" --stderr --utf8
--release="${COLOBOT_VERSION_FULL}"
${CMAKE_CURRENT_SOURCE_DIR}/${PM_PODFILE}
${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
COMMENT "Create ${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION} manpage"
)
add_custom_target(man${PM_LOCALE} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}${SLASHLOCALE}/colobot.${COLOBOT_MANPAGE_SECTION}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man${SLASHLOCALE}/man${COLOBOT_MANPAGE_SECTION}/ )
add_dependencies(man man${PM_LOCALE})
endmacro()
# Create the english manpage
podman(PODFILE colobot.pod)
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)
if(POD2MAN)
add_custom_target(man_po4a
COMMAND ${PO4A} po4a.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(man man_po4a)
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
foreach(LOCALE ${LINGUAS})
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
endforeach()
endif()
endif()

View File

@ -0,0 +1,6 @@
[Desktop Entry]
Version=1.0
Type=Application
Exec=colobot
Icon=colobot
Categories=Education;Robotics;Game;AdventureGame;StrategyGame;

3
src/desktop/colobot.ini Normal file
View File

@ -0,0 +1,3 @@
Name="Colobot"
GenericName="Game to learn programming"
Comment="Colonize with bots"

47
src/desktop/colobot.pod Normal file
View File

@ -0,0 +1,47 @@
=encoding utf8
=head1 COLOBOT
colobot - educational programming strategy game
=head1 SYNOPSIS
B<colobot> [B<-datadir> I<path>] [B<-debug>] [B<-loglevel> I<level>] [B<-language> I<lang>]
=head1 DESCRIPTION
Colobot (Colonize with Bots) is an educational game aiming to teach
programming through entertainment. You are playing as an astronaut on a
journey with robot helpers to find a planet for colonization. It features 3D
real-time graphics and a C++ and Java-like, object-oriented language, CBOT,
which can be used to program the robots available in the game.
=head1 OPTIONS
=over 8
=item B<-help>
Display a short help text
=item B<-datadir> F</path/to/data/>
Set custom data directory path
=item B<-debug>
Enable debug mode (more info printed in logs)
=item B<-loglevel> I<level>
Set log level. Possible choices are: trace, debug, info, warn, error, none.
=item B<-language> I<lang>
Set language. Note that you can also fill the B<LANG> environment variable.
=back
=head1 AUTHOR
This manpage was written by Didier Raboud <S<odyx@debian.org>>.

238
src/desktop/colobot.svg Normal file
View File

@ -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 &lt;odyx@debian.org&gt;</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

View File

@ -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

View File

@ -0,0 +1,134 @@
# 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-27 10:59+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=UTF-8\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 ""
#. type: =head1
#: colobot.pod:3
msgid "COLOBOT"
msgstr ""
#. type: textblock
#: colobot.pod:5
msgid "colobot - educational programming strategy game"
msgstr ""
#. type: =head1
#: colobot.pod:7
msgid "SYNOPSIS"
msgstr ""
#. type: textblock
#: colobot.pod:9
msgid ""
"B<colobot> [B<-datadir> I<path>] [B<-debug>] [B<-loglevel> I<level>] "
"[B<-language> I<lang>]"
msgstr ""
#. type: =head1
#: colobot.pod:11
msgid "DESCRIPTION"
msgstr ""
#. type: textblock
#: colobot.pod:13
msgid ""
"Colobot (Colonize with Bots) is an educational game aiming to teach "
"programming through entertainment. You are playing as an astronaut on a "
"journey with robot helpers to find a planet for colonization. It features 3D "
"real-time graphics and a C++ and Java-like, object-oriented language, CBOT, "
"which can be used to program the robots available in the game."
msgstr ""
#. type: =head1
#: colobot.pod:19
msgid "OPTIONS"
msgstr ""
#. type: =item
#: colobot.pod:23
msgid "B<-help>"
msgstr ""
#. type: textblock
#: colobot.pod:25
msgid "Display a short help text"
msgstr ""
#. type: =item
#: colobot.pod:27
msgid "B<-datadir> F</path/to/data/>"
msgstr ""
#. type: textblock
#: colobot.pod:29
msgid "Set custom data directory path"
msgstr ""
#. type: =item
#: colobot.pod:31
msgid "B<-debug>"
msgstr ""
#. type: textblock
#: colobot.pod:33
msgid "Enable debug mode (more info printed in logs)"
msgstr ""
#. type: =item
#: colobot.pod:35
msgid "B<-loglevel> I<level>"
msgstr ""
#. type: textblock
#: colobot.pod:37
msgid "Set log level. Possible choices are: trace, debug, info, warn, error, none."
msgstr ""
#. type: =item
#: colobot.pod:39
msgid "B<-language> I<lang>"
msgstr ""
#. type: textblock
#: colobot.pod:41
msgid "Set language. Note that you can also fill the B<LANG> environment variable."
msgstr ""
#. type: =head1
#: colobot.pod:45
msgid "AUTHOR"
msgstr ""
#. type: textblock
#: colobot.pod:47
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
msgstr ""

153
src/desktop/po/fr.po Normal file
View File

@ -0,0 +1,153 @@
# French translations for PACKAGE package
# Copyright (C) 2012 Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
#
# Didier Raboud <odyx@debian.org>, 2012.
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2012-12-27 10:55+0100\n"
"PO-Revision-Date: 2012-12-27 11:00+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"
#. type: =head1
#: colobot.pod:3
msgid "COLOBOT"
msgstr "COLOBOT"
#. type: textblock
#: colobot.pod:5
msgid "colobot - educational programming strategy game"
msgstr "colobot - Jeu éducatif de stratégie et de programmation"
#. type: =head1
#: colobot.pod:7
msgid "SYNOPSIS"
msgstr "RÉSUMÉ"
#. type: textblock
#: colobot.pod:9
msgid ""
"B<colobot> [B<-datadir> I<path>] [B<-debug>] [B<-loglevel> I<level>] [B<-"
"language> I<lang>]"
msgstr ""
"B<colobot> [B<-datadir> I<chemin>] [B<-debug>] [B<-loglevel> I<niveau>] [B<-"
"language> I<code-de-langue>]"
#. type: =head1
#: colobot.pod:11
msgid "DESCRIPTION"
msgstr "DESCRIPTION"
#. type: textblock
#: colobot.pod:13
msgid ""
"Colobot (Colonize with Bots) is an educational game aiming to teach "
"programming through entertainment. You are playing as an astronaut on a "
"journey with robot helpers to find a planet for colonization. It features 3D "
"real-time graphics and a C++ and Java-like, object-oriented language, CBOT, "
"which can be used to program the robots available in the game."
msgstr ""
"Colobot (Colonise avec des roBots) est un jeu éducatif visant à "
"l'enseignement de la programmation par le jeu. Vous jouez un astronaute en "
"voyage avec des robots à la recherche d'une planète à coloniser. Son "
"interface est en trois-dimensions et en temps réel; le language utilisé "
"(CBOT) ressemble au C++ et à Java et peut être utilisé pour programmer les "
"robots disponibles dans le jeu."
#. type: =head1
#: colobot.pod:19
msgid "OPTIONS"
msgstr "OPTIONS"
#. type: =item
#: colobot.pod:23
msgid "B<-help>"
msgstr "B<-help>"
#. type: textblock
#: colobot.pod:25
msgid "Display a short help text"
msgstr "Affiche un court texte d'aide"
#. type: =item
#: colobot.pod:27
msgid "B<-datadir> F</path/to/data/>"
msgstr "B<-datadir> F</chemin/vers/les/donnes/>"
#. type: textblock
#: colobot.pod:29
msgid "Set custom data directory path"
msgstr "Définit le chemin vers un répertoire de données spécifique"
#. type: =item
#: colobot.pod:31
msgid "B<-debug>"
msgstr "B<-debug>"
#. type: textblock
#: colobot.pod:33
msgid "Enable debug mode (more info printed in logs)"
msgstr ""
"Active le mode de déboguage (plus d'informations sont affichées dans le "
"journal)"
#. type: =item
#: colobot.pod:35
msgid "B<-loglevel> I<level>"
msgstr "B<-loglevel> I<niveau>"
#. type: textblock
#: colobot.pod:37
msgid ""
"Set log level. Possible choices are: trace, debug, info, warn, error, none."
msgstr ""
"Définit le niveau de journalisation parmi: trace, debug, info, warn, error, "
"none."
#. type: =item
#: colobot.pod:39
msgid "B<-language> I<lang>"
msgstr "B<-language> I<langue>"
#. type: textblock
#: colobot.pod:41
msgid ""
"Set language. Note that you can also fill the B<LANG> environment variable."
msgstr ""
"Définit la langue. Il est aussi possible d'utiliser la variable "
"d'environnement B<LANG>."
#. type: =head1
#: colobot.pod:45
msgid "AUTHOR"
msgstr "Auteur"
#. type: textblock
#: colobot.pod:47
msgid "This manpage was written by Didier Raboud <S<odyx@debian.org>>."
msgstr ""
"Cette page de manuel a été écrite et traduite par Didier Raboud "
"<S<odyx@debian.org>>."

4
src/desktop/po4a.cfg Normal file
View File

@ -0,0 +1,4 @@
[po_directory] po/
[type:ini] colobot.ini $lang:lang/$lang/colobot.ini
[type:pod] colobot.pod $lang:lang/$lang/colobot.pod

View File

@ -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
@ -15,7 +18,7 @@ add_definitions(-DMODELFILE_NO_ENGINE)
include_directories(
.
../../..
${GTEST_DIR}/include
${GTEST_INCLUDE_DIR}
)
add_executable(modelfile_test ${MODELFILE_TEST_SOURCES})

View File

@ -677,7 +677,7 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
return;
int width = 1;
if (ch.c1 < 32) { // FIXME add support for chars with code 9 10 23
if (ch.c1 > 0 && ch.c1 < 32) { // FIXME add support for chars with code 9 10 23
ch.c1 = ' ';
ch.c2 = 0;
ch.c3 = 0;

View File

@ -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 "")

View File

@ -1,13 +1,16 @@
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(
.
../..
../../..
${GTEST_DIR}/include
${GTEST_INCLUDE_DIR}
)
add_executable(matrix_test matrix_test.cpp)

View File

@ -99,7 +99,7 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
m_selScript = 0;
m_bTraceRecord = false;
m_traceRecordBuffer = 0;
m_traceRecordBuffer = nullptr;
}
// Object's destructor.
@ -111,12 +111,21 @@ CBrain::~CBrain()
for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
delete m_script[i];
m_script[i] = nullptr;
}
delete m_primaryTask;
m_primaryTask = nullptr;
delete m_secondaryTask;
m_secondaryTask = nullptr;
delete m_studio;
delete m_traceRecordBuffer;
m_studio = nullptr;
delete[] m_traceRecordBuffer;
m_traceRecordBuffer = nullptr;
m_iMan->DeleteInstance(CLASS_BRAIN, this);
}
@ -2791,8 +2800,8 @@ void CBrain::TraceRecordStart()
m_traceColor = -1;
}
delete m_traceRecordBuffer;
m_traceRecordBuffer = static_cast<TraceRecord*>(malloc(sizeof(TraceRecord)*MAXTRACERECORD));
delete[] m_traceRecordBuffer;
m_traceRecordBuffer = new TraceRecord[MAXTRACERECORD];
m_traceRecordIndex = 0;
}
@ -2858,10 +2867,10 @@ void CBrain::TraceRecordStop()
int max, i;
char* buffer;
if ( m_traceRecordBuffer == 0 ) return;
if ( m_traceRecordBuffer == nullptr ) return;
max = 10000;
buffer = static_cast<char*>(malloc(max));
buffer = new char[max];
*buffer = 0;
strncat(buffer, "extern void object::AutoDraw()\n{\n", max-1);
@ -2892,8 +2901,8 @@ void CBrain::TraceRecordStop()
}
TraceRecordPut(buffer, max, lastOper, lastParam);
delete m_traceRecordBuffer;
m_traceRecordBuffer = 0;
delete[] m_traceRecordBuffer;
m_traceRecordBuffer = nullptr;
strncat(buffer, "}\n", max-1);
buffer[max-1] = 0;
@ -2904,7 +2913,7 @@ void CBrain::TraceRecordStop()
m_script[i] = new CScript(m_iMan, m_object, &m_secondaryTask);
}
m_script[i]->SendScript(buffer);
delete buffer;
delete[] buffer;
}
// Saves an instruction CBOT.

View File

@ -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)
{
@ -3806,16 +3808,16 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
}
// TODO: language letters
sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/);
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_title);
sprintf(op, "Resume.%c", 'E' /*GetLanguageLetter()*/);
sprintf(op, "Resume.%c", m_app->GetLanguageChar());
if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_resume);
sprintf(op, "ScriptName.%c", 'E' /*GetLanguageLetter()*/);
sprintf(op, "ScriptName.%c", m_app->GetLanguageChar());
if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_scriptName);
@ -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

View File

@ -2119,7 +2119,7 @@ bool CTaskGoto::BitmapOpen()
BitmapClose();
m_bmSize = static_cast<int>(3200.0f/BM_DIM_STEP);
m_bmArray = static_cast<unsigned char*>(malloc(m_bmSize*m_bmSize/8*2));
m_bmArray = new unsigned char[m_bmSize*m_bmSize/8*2];
memset(m_bmArray, 0, m_bmSize*m_bmSize/8*2);
m_bmOffset = m_bmSize/2;
@ -2137,7 +2137,7 @@ bool CTaskGoto::BitmapOpen()
bool CTaskGoto::BitmapClose()
{
free(m_bmArray);
delete[] m_bmArray;
m_bmArray = 0;
return true;
}

View File

@ -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; }
};

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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)

View File

@ -1,3 +0,0 @@
[Plugins]
Path=.
File=libopenalsound.so

View File

@ -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;
}

18
src/po/CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 2.8)
set(_potFile colobot.pot)
find_program(XGETTEXT_CMD xgettext)
add_custom_command(OUTPUT ${_potFile}
COMMAND ${XGETTEXT_CMD} ../app/app.cpp --output=${_potFile}
COMMAND ${XGETTEXT_CMD} ../common/restext.cpp --output=${_potFile} --join-existing --extract-all --no-location
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Extract translatable messages to ${_potFile}"
)
add_custom_target(update-pot DEPENDS ${_potFile})
file(GLOB _poFiles *.po)
gettext_create_translations(${_potFile} ALL ${_poFiles})

1818
src/po/colobot.pot Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1571,7 +1571,7 @@ bool CScript::rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
if ( var == 0 )
if ( var == 0 )
{
type = TMA_FFRONT;
}
@ -2752,21 +2752,14 @@ void CScript::InitFonctions()
CScript::~CScript()
{
if (m_botProg != nullptr)
{
delete m_botProg;
m_botProg = nullptr;
}
if (m_primaryTask != nullptr)
{
delete m_primaryTask;
m_primaryTask = nullptr;
}
if (m_script != nullptr)
{
delete m_script;
m_script = nullptr;
}
delete m_botProg;
m_botProg = nullptr;
delete m_primaryTask;
m_primaryTask = nullptr;
delete[] m_script;
m_script = nullptr;
m_len = 0;
@ -2778,7 +2771,7 @@ CScript::~CScript()
void CScript::PutScript(Ui::CEdit* edit, const char* name)
{
if ( m_script == 0 )
if ( m_script == nullptr )
{
New(edit, name);
}
@ -2797,11 +2790,11 @@ bool CScript::GetScript(Ui::CEdit* edit)
{
int len;
delete m_script;
m_script = 0;
delete[] m_script;
m_script = nullptr;
len = edit->GetTextLength();
m_script = static_cast<char*>(malloc(sizeof(char)*(len+1)));
m_script = new char[len+1];
edit->GetText(m_script, len+1);
edit->GetCursor(m_cursor2, m_cursor1);
@ -3009,7 +3002,7 @@ void CScript::SetStepMode(bool bStep)
bool CScript::Run()
{
if( m_botProg == 0 ) return false;
if ( m_script == 0 || m_len == 0 ) return false;
if ( m_script == nullptr || m_len == 0 ) return false;
if ( !m_botProg->Start(m_title) ) return false;
@ -3487,9 +3480,9 @@ bool CScript::IntroduceVirus()
start = found[i+1];
i = found[i+0];
newScript = static_cast<char*>(malloc(sizeof(char)*(m_len+strlen(names[i+1])+1)));
newScript = new char[m_len+strlen(names[i+1])+1];
strcpy(newScript, m_script);
delete m_script;
delete[] m_script;
m_script = newScript;
DeleteToken(m_script, start, strlen(names[i]));
@ -3650,7 +3643,7 @@ void CScript::New(Ui::CEdit* edit, const char* name)
bool CScript::SendScript(char* text)
{
m_len = strlen(text);
m_script = static_cast<char*>(malloc(sizeof(char)*(m_len+1)));
m_script = new char[m_len+1];
strcpy(m_script, text);
if ( !CheckToken() ) return false;
if ( !Compile() ) return false;
@ -3681,8 +3674,8 @@ bool CScript::ReadScript(const char* filename)
if ( file == NULL ) return false;
fclose(file);
delete m_script;
m_script = 0;
delete[] m_script;
m_script = nullptr;
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
edit->SetMaxChar(Ui::EDITSTUDIOMAX);
@ -3709,7 +3702,7 @@ bool CScript::WriteScript(const char* filename)
name = filename;
}
if ( m_script == 0 )
if ( m_script == nullptr )
{
remove(filename);
return false;

View File

@ -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;
}
@ -324,6 +296,8 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
GetLogger()->Warn("Sound %d was not loaded!\n", sound);
return -1;
}
GetLogger()->Trace("ALSound::Play sound: %d volume: %f frequency: %f\n", sound, amplitude, frequency);
int channel;
bool bAlreadyLoaded;
@ -336,12 +310,12 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
Position(channel, pos);
// setting initial values
mChannels[channel]->SetStartAmplitude(amplitude);
mChannels[channel]->SetStartAmplitude(mAudioVolume);
mChannels[channel]->SetStartFrequency(frequency);
mChannels[channel]->SetChangeFrequency(1.0f);
mChannels[channel]->ResetOper();
mChannels[channel]->AdjustFrequency(frequency);
mChannels[channel]->AdjustVolume(mAudioVolume);
mChannels[channel]->AdjustFrequency(frequency);
mChannels[channel]->AdjustVolume(amplitude * mAudioVolume);
mChannels[channel]->Play();
return channel;
}
@ -479,17 +453,17 @@ void ALSound::FrameMove(float delta)
it.second->AdjustVolume(volume * mAudioVolume);
// setting frequency
frequency = progress * (oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency();
frequency = progress * abs(oper.finalFrequency - it.second->GetStartFrequency()) * it.second->GetStartFrequency() * it.second->GetChangeFrequency();
it.second->AdjustFrequency(frequency);
if (it.second->GetEnvelope().totalTime <= it.second->GetCurrentTime()) {
if (oper.nextOper == SOPER_LOOP) {
GetLogger()->Info("Replay.\n");
GetLogger()->Trace("ALSound::FrameMove oper: replay.\n");
it.second->SetCurrentTime(0.0f);
it.second->Play();
} else {
GetLogger()->Info("Next.\n");
GetLogger()->Trace("ALSound::FrameMove oper: next.\n");
it.second->SetStartAmplitude(oper.finalAmplitude);
it.second->SetStartFrequency(oper.finalFrequency);
it.second->PopEnvelope();

View File

@ -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;

View File

@ -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;

View File

@ -39,7 +39,7 @@ Channel::~Channel() {
alSourcei(mSource, AL_BUFFER, 0);
alDeleteSources(1, &mSource);
if (alCheck())
GetLogger()->Warn("Failed to delete sound source. Code: %s\n", alGetCode());
GetLogger()->Warn("Failed to delete sound source. Code: %d\n", alGetCode());
}
}
@ -50,7 +50,7 @@ bool Channel::Play() {
alSourcePlay(mSource);
if (alCheck())
GetLogger()->Warn("Could not play audio sound source. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode());
return true;
}
@ -61,7 +61,7 @@ bool Channel::SetPosition(Math::Vector pos) {
alSource3f(mSource, AL_POSITION, pos.x, pos.y, pos.z);
if (alCheck()) {
GetLogger()->Warn("Could not set sound position. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode());
return false;
}
return true;
@ -75,7 +75,7 @@ bool Channel::SetFrequency(float freq)
alSourcef(mSource, AL_PITCH, freq);
if (alCheck()) {
GetLogger()->Warn("Could not set sound pitch. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode());
return false;
}
return true;
@ -90,7 +90,7 @@ float Channel::GetFrequency()
alGetSourcef(mSource, AL_PITCH, &freq);
if (alCheck()) {
GetLogger()->Warn("Could not get sound pitch. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode());
return 0;
}
@ -105,7 +105,7 @@ bool Channel::SetVolume(float vol)
alSourcef(mSource, AL_GAIN, vol / MAXVOLUME);
if (alCheck()) {
GetLogger()->Warn("Could not set sound volume. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
return false;
}
return true;
@ -120,7 +120,7 @@ float Channel::GetVolume()
alGetSourcef(mSource, AL_GAIN, &vol);
if (alCheck()) {
GetLogger()->Warn("Could not get sound volume. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode());
return 0;
}
@ -213,7 +213,7 @@ bool Channel::SetBuffer(Buffer *buffer) {
mBuffer = buffer;
alSourcei(mSource, AL_BUFFER, buffer->GetBuffer());
if (alCheck()) {
GetLogger()->Warn("Could not set sound buffer. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not set sound buffer. Code: %d\n", alGetCode());
return false;
}
mInitFrequency = GetFrequency();
@ -227,7 +227,7 @@ void Channel::AdjustFrequency(float freq) {
void Channel::AdjustVolume(float volume) {
SetVolume(mStartAmplitude * (float) volume);
SetVolume(mStartAmplitude * volume);
}
@ -237,7 +237,7 @@ bool Channel::IsPlaying() {
alGetSourcei(mSource, AL_SOURCE_STATE, &status);
if (alCheck()) {
GetLogger()->Warn("Could not get sound status. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not get sound status. Code: %d\n", alGetCode());
return false;
}
@ -253,7 +253,7 @@ bool Channel::IsReady() {
bool Channel::Stop() {
alSourceStop(mSource);
if (alCheck()) {
GetLogger()->Warn("Could not stop sound. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not stop sound. Code: %d\n", alGetCode());
return false;
}
return true;
@ -265,7 +265,7 @@ float Channel::GetCurrentTime()
ALfloat current;
alGetSourcef(mSource, AL_SEC_OFFSET, &current);
if (alCheck()) {
GetLogger()->Warn("Could not get source current play time. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode());
return 0.0f;
}
return current;
@ -276,7 +276,7 @@ void Channel::SetCurrentTime(float current)
{
alSourcef(mSource, AL_SEC_OFFSET, current);
if (alCheck())
GetLogger()->Warn("Could not get source current play time. Code: %s\n", alGetCode());
GetLogger()->Warn("Could not get source current play time. Code: %d\n", alGetCode());
}

View File

@ -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})

View File

@ -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)

View File

@ -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;
}

View File

@ -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() {
@ -170,7 +168,7 @@ class CSoundInterface : public CPluginInterface
* Function calls \link CSoundInterface::Cache() \endlink for each file
*/
inline void CacheAll(std::string path) {
for ( int i = 1; i < 69; i++ ) {
for ( int i = 1; i <= 81; i++ ) {
std::stringstream filename;
filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav";
if ( !Cache(static_cast<Sound>(i), filename.str()) )

View File

@ -243,7 +243,7 @@ bool CEdit::EventProcess(const Event &event)
Scroll(m_lineFirst-3, true);
return true;
}
if (event.type == EVENT_KEY_DOWN &&
if (event.type == EVENT_MOUSE_WHEEL &&
event.mouseWheel.dir == WHEEL_DOWN &&
Detect(event.mousePos) )
{
@ -282,7 +282,7 @@ bool CEdit::EventProcess(const Event &event)
}
}
if ( m_scroll != 0 && !m_bGeneric )
if ( m_scroll != nullptr && !m_bGeneric )
{
m_scroll->EventProcess(event);
@ -1248,7 +1248,7 @@ void CEdit::SetText(const char *text, bool bNew)
{
int i, j, font;
bool bBOL;
if ( !bNew ) UndoMemorize(OPERUNDO_SPEC);
m_len = strlen(text);
@ -2172,11 +2172,11 @@ void CEdit::Scroll()
{
float value;
if ( m_scroll != 0 )
if ( m_scroll != nullptr )
{
value = m_scroll->GetVisibleValue();
value *= m_lineTotal-m_lineVisible;
Scroll(static_cast<int>(value+0.5f), true);
value *= m_lineTotal - m_lineVisible;
Scroll(static_cast<int>(value + 0.5f), true);
}
}
@ -3048,7 +3048,7 @@ bool CEdit::MinMaj(bool bMaj)
void CEdit::Justif()
{
float width, value, size, indentLength;
float width, size, indentLength;
int i, j, line, indent;
bool bDual, bString, bRem;
@ -3176,26 +3176,7 @@ void CEdit::Justif()
m_lineFirst = 0;
}
if ( m_scroll != 0 )
{
if ( m_lineTotal <= m_lineVisible )
{
m_scroll->SetVisibleRatio(1.0f);
m_scroll->SetVisibleValue(0.0f);
m_scroll->SetArrowStep(0.0f);
}
else
{
value = static_cast<float>(m_lineVisible/m_lineTotal);
m_scroll->SetVisibleRatio(value);
value = static_cast<float>(m_lineFirst/(m_lineTotal-m_lineVisible));
m_scroll->SetVisibleValue(value);
value = static_cast<float>(1.0f/(m_lineTotal-m_lineVisible));
m_scroll->SetArrowStep(value);
}
}
UpdateScroll();
m_timeBlink = 0.0f; // lights the cursor immediately
}
@ -3326,5 +3307,30 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format)
return true;
}
void CEdit::UpdateScroll()
{
float value;
if ( m_scroll != nullptr )
{
if ( m_lineTotal <= m_lineVisible )
{
m_scroll->SetVisibleRatio(1.0f);
m_scroll->SetVisibleValue(0.0f);
m_scroll->SetArrowStep(0.0f);
}
else
{
value = static_cast<float>(m_lineVisible) / m_lineTotal;
m_scroll->SetVisibleRatio(value);
value = static_cast<float>(m_lineFirst) / (m_lineTotal - m_lineVisible);
m_scroll->SetVisibleValue(value);
value = 1.0f / (m_lineTotal - m_lineVisible);
m_scroll->SetArrowStep(value);
}
}
}
}

View File

@ -234,6 +234,8 @@ protected:
void UndoFlush();
void UndoMemorize(OperUndo oper);
bool UndoRecall();
void UpdateScroll();
protected:
CScroll* m_scroll; // vertical scrollbar on the right

View File

@ -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;
@ -4329,8 +4305,8 @@ void CMainDialog::IOReadName()
}
}
// TODO: language letters
sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/ );
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar() );
if ( Cmd(line, op) )
{
OpString(line, "resume", resume);
@ -4725,8 +4701,8 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
/* TODO: language letters */
sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/);
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@ -4772,8 +4748,8 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
// TODO: language letters
sprintf(op, "Title.%c", 'E'/*GetLanguageLetter()*/);
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@ -4875,8 +4851,8 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
}
}
// TODO: language letters
sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/);
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@ -5020,8 +4996,8 @@ void CMainDialog::UpdateSceneResume(int rank)
}
}
// TODO: language letters
sprintf(op, "Resume.%c", 'E' /*MAX_FNAME()*/);
// TODO: Fallback to an non-localized entry
sprintf(op, "Resume.%c", m_app->GetLanguageChar());
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@ -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);
}
}

View File

@ -1,13 +1,17 @@
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(
.
../..
../../..
${GTEST_DIR}/include
${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR}
)