summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-11-03 13:04:57 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-11-03 13:04:57 +0100
commitf1c5cd5f82d33d5db5033ea28e1d24a13b2e28a2 (patch)
treeb9e7e75a2138875ffed59772a2a1c7cf82b7aaa4
parentec38c14ee8293b2dc7436e0c06b0c294652c84cc (diff)
parentd8e50e4eeb2dde3e0d228e2bead29d73494f8874 (diff)
downloadcolobot-f1c5cd5f82d33d5db5033ea28e1d24a13b2e28a2.tar.gz
colobot-f1c5cd5f82d33d5db5033ea28e1d24a13b2e28a2.tar.bz2
colobot-f1c5cd5f82d33d5db5033ea28e1d24a13b2e28a2.zip
Colobot Gold 0.1.1-alpha
-rw-r--r--CMakeLists.txt86
m---------data0
-rw-r--r--desktop/CMakeLists.txt144
-rw-r--r--desktop/colobot.icobin0 -> 353118 bytes
-rw-r--r--desktop/colobot.rc.cmake25
-rw-r--r--lib/gtest/CMakeLists.txt3
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/app/app.cpp10
-rw-r--r--src/app/app.h3
-rw-r--r--src/app/system_other.cpp2
-rw-r--r--src/app/system_other.h3
-rw-r--r--src/common/config.h.cmake1
-rw-r--r--src/graphics/engine/engine.cpp28
-rw-r--r--src/graphics/engine/lightman.cpp10
-rw-r--r--src/graphics/engine/lightman.h18
-rw-r--r--src/graphics/engine/pyro.cpp31
-rw-r--r--src/graphics/engine/pyro.h5
-rw-r--r--src/graphics/engine/terrain.cpp19
-rw-r--r--src/graphics/engine/terrain.h2
-rw-r--r--src/graphics/engine/text.cpp23
-rw-r--r--src/graphics/opengl/gldevice.cpp8
-rw-r--r--src/object/auto/auto.cpp2
-rw-r--r--src/object/auto/auto.h2
-rw-r--r--src/object/auto/autobase.cpp5
-rw-r--r--src/object/auto/autoconvert.cpp5
-rw-r--r--src/object/auto/autoderrick.cpp3
-rw-r--r--src/object/auto/autodestroyer.cpp3
-rw-r--r--src/object/auto/autoenergy.cpp5
-rw-r--r--src/object/auto/autofactory.cpp7
-rw-r--r--src/object/auto/autolabo.cpp5
-rw-r--r--src/object/auto/autonuclear.cpp5
-rw-r--r--src/object/auto/autoresearch.cpp7
-rw-r--r--src/object/auto/autotower.cpp3
-rw-r--r--src/object/brain.cpp6
-rw-r--r--src/object/brain.h2
-rw-r--r--src/object/object.cpp7
-rw-r--r--src/object/object.h5
-rw-r--r--src/object/robotmain.cpp22
-rw-r--r--src/object/robotmain.h3
-rw-r--r--src/object/task/task.cpp1
-rw-r--r--src/object/task/task.h4
-rw-r--r--src/object/task/taskbuild.cpp6
-rw-r--r--src/object/task/taskrecover.cpp4
-rw-r--r--src/object/task/tasksearch.cpp8
-rw-r--r--src/object/task/taskshield.cpp1
-rw-r--r--src/object/task/taskterraform.cpp1
-rw-r--r--src/object/task/taskturn.cpp2
-rw-r--r--src/script/script.cpp19
-rw-r--r--src/script/script.h2
-rw-r--r--src/sound/oalsound/alsound.h2
-rw-r--r--src/sound/oalsound/buffer.h2
-rw-r--r--src/sound/oalsound/channel.h4
-rw-r--r--src/sound/oalsound/check.h6
-rw-r--r--src/ui/edit.cpp8
-rw-r--r--src/ui/edit.h4
-rw-r--r--src/ui/interface.cpp26
-rw-r--r--src/ui/maindialog.cpp11
-rw-r--r--test/unit/CMakeLists.txt5
-rw-r--r--test/unit/ui/CMakeLists.txt5
59 files changed, 370 insertions, 279 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a22138..43b4a8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,12 +13,12 @@ project(colobot C CXX)
set(COLOBOT_VERSION_CODENAME "Gold")
set(COLOBOT_VERSION_MAJOR 0)
set(COLOBOT_VERSION_MINOR 1)
-set(COLOBOT_VERSION_REVISION 0)
+set(COLOBOT_VERSION_REVISION 1)
# Used on official releases
-set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
+#set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
# Used on unreleased, development builds
-#set(COLOBOT_VERSION_UNRELEASED "+alpha")
+set(COLOBOT_VERSION_UNRELEASED "+alpha")
# Append git characteristics to version
if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
@@ -36,6 +36,37 @@ set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${CO
message(STATUS "Building Colobot \"${COLOBOT_VERSION_CODENAME}\" (${COLOBOT_VERSION_FULL})")
+##
+# Platform detection and some related checks
+##
+if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
+ message(STATUS "Build for Windows system")
+ set(PLATFORM_WINDOWS 1)
+ set(PLATFORM_LINUX 0)
+ set(PLATFORM_MACOSX 0)
+ set(PLATFORM_OTHER 0)
+elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
+ message(STATUS "Build for Linux system")
+ set(PLATFORM_WINDOWS 0)
+ set(PLATFORM_LINUX 1)
+ set(PLATFORM_MACOSX 0)
+ set(PLATFORM_OTHER 0)
+elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+ message(STATUS "Build for Mac OSX system")
+ set(PLATFORM_WINDOWS 0)
+ set(PLATFORM_LINUX 0)
+ set(PLATFORM_MACOSX 1)
+ set(PLATFORM_OTHER 0)
+
+ set(USE_SDL_MAIN 1) # fixes SDL_main
+else()
+ message(STATUS "Build for other system")
+ set(PLATFORM_WINDOWS 0)
+ set(PLATFORM_LINUX 0)
+ set(PLATFORM_MACOSX 0)
+ set(PLATFORM_OTHER 1)
+endif()
+
##
# Build options
@@ -111,6 +142,9 @@ option(BOOST_STATIC "Link with static boost libraries" OFF)
# This is useful on Windows, if linking against standard GLEW dll fails
option(GLEW_STATIC "Link statically with GLEW" OFF)
+# Sometimes helpful if there are different versions of gmock/gtest installed on system vs bundled
+option(FORCE_BUNDLED_GTEST "Force the use of bundled gtest" OFF)
+option(FORCE_BUNDLED_GMOCK "Force the use of bundled gmock" OFF)
# Default build type if not given is debug
if(NOT DEFINED CMAKE_BUILD_TYPE)
@@ -146,28 +180,11 @@ find_package(GLEW REQUIRED)
if (OPENAL_SOUND)
find_package(OpenAL REQUIRED)
+ include_directories(${OPENAL_INCLUDE_DIR})
find_package(LibSndFile REQUIRED)
endif()
-##
-# Platform detection and some related checks
-##
-
-if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
- set(PLATFORM_WINDOWS 1)
- set(PLATFORM_LINUX 0)
- set(PLATFORM_OTHER 0)
-elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
- set(PLATFORM_WINDOWS 0)
- set(PLATFORM_LINUX 1)
- set(PLATFORM_OTHER 0)
-else()
- set(PLATFORM_WINDOWS 0)
- set(PLATFORM_LINUX 0)
- set(PLATFORM_OTHER 1)
-endif()
-
if(NOT ASSERTS)
add_definitions(-DNDEBUG)
endif()
@@ -178,6 +195,9 @@ else()
add_definitions(-DTEST_VIRTUAL=)
endif()
+if(DEV_BUILD)
+ add_definitions(-DDEV_BUILD)
+endif()
##
# Additional settings to use when cross-compiling with MXE (http://mxe.cc/)
@@ -192,14 +212,14 @@ include("${colobot_SOURCE_DIR}/cmake/msys.cmake")
##
-# Summary of detected things
+# Clipboard support needs X11 libraries
##
-if (PLATFORM_WINDOWS)
- message(STATUS "Build for Windows system")
-elseif(PLATFORM_LINUX)
- message(STATUS "Build for Linux system")
-else()
- message(STATUS "Build for other system")
+if(PLATFORM_LINUX OR PLATFORM_MACOSX)
+ find_package(X11 REQUIRED)
+ if(PLATFORM_MACOSX)
+ # Add the includes for X11
+ include_directories("/opt/X11/include")
+ endif()
endif()
@@ -240,7 +260,7 @@ if(TESTS)
# Google Test library
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)
+ if(NOT(FORCE_BUNDLED_GTEST) AND GTEST_SRC_DIR AND GTEST_INCLUDE_DIR)
message(STATUS "Using system gtest library in ${GTEST_SRC_DIR}")
else()
message(STATUS "Using bundled gtest library")
@@ -253,7 +273,7 @@ if(TESTS)
# 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)
+ if(NOT(FORCE_BUNDLED_GMOCK) AND GMOCK_SRC_DIR AND GMOCK_INCLUDE_DIR)
message(STATUS "Using system gmock library in ${GMOCK_SRC_DIR}")
include_directories(${GMOCK_SRC_DIR})
@@ -303,11 +323,7 @@ add_subdirectory(src)
add_subdirectory(po)
if(DESKTOP)
- if(PLATFORM_WINDOWS)
- message("Desktop files ignored on Windows")
- else()
- add_subdirectory(desktop)
- endif()
+ add_subdirectory(desktop)
endif()
diff --git a/data b/data
-Subproject 2d7172438e8db1fa6d73d1c5f314489f8c936c1
+Subproject bab520ebec08a3a8e8763918e3db52b95f0d29d
diff --git a/desktop/CMakeLists.txt b/desktop/CMakeLists.txt
index 6d2ece0..bf9be06 100644
--- a/desktop/CMakeLists.txt
+++ b/desktop/CMakeLists.txt
@@ -1,75 +1,81 @@
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)
+if(NOT PLATFORM_WINDOWS)
+ # 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()
+else() # if(NOT PLATFORM_WINDOWS)
+ set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION},0")
+ configure_file(colobot.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/colobot.rc)
endif()
# Translate translatable material
diff --git a/desktop/colobot.ico b/desktop/colobot.ico
new file mode 100644
index 0000000..54ab418
--- /dev/null
+++ b/desktop/colobot.ico
Binary files differ
diff --git a/desktop/colobot.rc.cmake b/desktop/colobot.rc.cmake
new file mode 100644
index 0000000..40860e5
--- /dev/null
+++ b/desktop/colobot.rc.cmake
@@ -0,0 +1,25 @@
+id ICON "@CMAKE_CURRENT_SOURCE_DIR@/colobot.ico"
+
+1 VERSIONINFO
+FILEVERSION @COLOBOT_VERSION_4COMMAS@
+PRODUCTVERSION @COLOBOT_VERSION_4COMMAS@
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "OriginalFilename", "colobot.exe\0"
+ VALUE "InternalName", "colobot\0"
+ VALUE "FileDescription", "Colobot - Colonize with Bots\0"
+ VALUE "ProductName", "Colobot\0"
+ VALUE "CompanyName", "Polish Portal of Colobot\0"
+ VALUE "LegalCopyright", "Copyright (c) 2012-2013 Polish Portal of Colobot\0"
+ VALUE "FileVersion", "@COLOBOT_VERSION_FULL@\0"
+ VALUE "ProductVersion", "@COLOBOT_VERSION_FULL@\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
diff --git a/lib/gtest/CMakeLists.txt b/lib/gtest/CMakeLists.txt
index 1279f7d..316ea14 100644
--- a/lib/gtest/CMakeLists.txt
+++ b/lib/gtest/CMakeLists.txt
@@ -2,8 +2,5 @@ cmake_minimum_required(VERSION 2.8)
include_directories(. include)
-# pthread is not necessary
-add_definitions(-DGTEST_HAS_PTHREAD=0)
-
# gtest-all.cc includes all other sources
add_library(gtest STATIC src/gtest-all.cc)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 40373a3..2fab853 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,6 +31,9 @@ elseif(PLATFORM_WINDOWS)
elseif(PLATFORM_LINUX)
# for clock_gettime
set(PLATFORM_LIBS "-lrt -lX11")
+elseif(PLATFORM_MACOSX)
+ find_library(LIBINTL_LIBRARY NAMES intl libintl )
+ set(PLATFORM_LIBS ${LIBINTL_LIBRARY} ${X11_X11_LIB})
endif()
@@ -47,6 +50,12 @@ if(OPENAL_SOUND)
)
endif()
+set(RES_FILES "")
+
+if(PLATFORM_WINDOWS)
+ set(RES_FILES "../desktop/colobot.rc")
+endif()
+
# Platform-dependent implementation of system.h
if(PLATFORM_WINDOWS)
set(SYSTEM_CPP_MODULE "system_windows.cpp")
@@ -179,6 +188,7 @@ ui/studio.cpp
ui/target.cpp
ui/window.cpp
${OPENAL_SRC}
+${RES_FILES}
)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index f98e0fc..d2994a9 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -110,6 +110,7 @@ CApplication::CApplication()
m_exitCode = 0;
m_active = false;
m_debugModes = 0;
+ m_customDataPath = false;
m_windowTitle = "COLOBOT";
@@ -344,7 +345,8 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
case OPT_DATADIR:
{
m_dataPath = optarg;
- GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str());
+ m_customDataPath = true;
+ GetLogger()->Info("Using custom datadir or running mod: '%s'\n", m_dataPath.c_str());
break;
}
case OPT_LANGDIR:
@@ -404,7 +406,7 @@ bool CApplication::Create()
}
else
{
- if (GetProfile().GetLocalProfileString("Resources", "Data", path))
+ if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Data", path))
m_dataPath = path;
}
@@ -440,7 +442,7 @@ bool CApplication::Create()
GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC));
}
- if (GetProfile().GetLocalProfileString("Resources", "Sound", path))
+ if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path))
{
m_sound->CacheAll(path);
}
@@ -449,7 +451,7 @@ bool CApplication::Create()
m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
}
- if (GetProfile().GetLocalProfileString("Resources", "Music", path))
+ if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Music", path))
{
m_sound->AddMusicFiles(path);
}
diff --git a/src/app/app.h b/src/app/app.h
index 269fa9b..6b02f67 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -480,6 +480,9 @@ protected:
//! Path to directory with data files
std::string m_dataPath;
+ //! True if datadir was passed in command line
+ bool m_customDataPath;
+
//! Path to directory with language files
std::string m_langPath;
diff --git a/src/app/system_other.cpp b/src/app/system_other.cpp
index da81a6d..9d9f76a 100644
--- a/src/app/system_other.cpp
+++ b/src/app/system_other.cpp
@@ -33,7 +33,7 @@ long long int CSystemUtilsOther::GetTimeStampExactResolution()
return 1000000ll;
}
-long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after) const
+long long int CSystemUtilsOther::TimeStampExactDiff(SystemTimeStamp* before, SystemTimeStamp* after)
{
return (after->sdlTicks - before->sdlTicks) * 1000000ll;
}
diff --git a/src/app/system_other.h b/src/app/system_other.h
index b10a326..7eccf3f 100644
--- a/src/app/system_other.h
+++ b/src/app/system_other.h
@@ -40,10 +40,11 @@ struct SystemTimeStamp
class CSystemUtilsOther : public CSystemUtils
{
public:
+ virtual void Init() {};
virtual SystemDialogResult SystemDialog(SystemDialogType type, const std::string& title, const std::string& message) override;
virtual void GetCurrentTimeStamp(SystemTimeStamp *stamp) override;
- virtual long long GetTimeStampExactResolution() override;
+ virtual long long int GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
};
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 76b37b5..2f403fa 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -3,6 +3,7 @@
// Macros set by CMake
#cmakedefine PLATFORM_WINDOWS @PLATFORM_WINDOWS@
#cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@
+#cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
#cmakedefine GLEW_STATIC
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 669ea42..5cf7b23 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -276,7 +276,7 @@ bool CEngine::Create()
Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
TextureCreateParams params;
- params.format = TEX_IMG_RGB;
+ params.format = TEX_IMG_AUTO;
params.minFilter = TEX_MIN_FILTER_NEAREST;
params.magFilter = TEX_MAG_FILTER_NEAREST;
params.mipmap = false;
@@ -600,6 +600,31 @@ void CEngine::DeleteBaseObject(int baseObjRank)
void CEngine::DeleteAllBaseObjects()
{
+ for (int baseObjRank = 0; baseObjRank < static_cast<int>( m_baseObjects.size() ); baseObjRank++)
+ {
+ EngineBaseObject& p1 = m_baseObjects[baseObjRank];
+ if (! p1.used)
+ continue;
+
+ for (int l2 = 0; l2 < static_cast<int>( p1.next.size() ); l2++)
+ {
+ EngineBaseObjTexTier& p2 = p1.next[l2];
+
+ for (int l3 = 0; l3 < static_cast<int>( p2.next.size() ); l3++)
+ {
+ EngineBaseObjLODTier& p3 = p2.next[l3];
+
+ for (int l4 = 0; l4 < static_cast<int>( p3.next.size() ); l4++)
+ {
+ EngineBaseObjDataTier& p4 = p3.next[l4];
+
+ m_device->DestroyStaticBuffer(p4.staticBufferId);
+ p4.staticBufferId = 0;
+ }
+ }
+ }
+ }
+
m_baseObjects.clear();
}
@@ -817,6 +842,7 @@ int CEngine::CreateObject()
m_objects[objRank].drawWorld = true;
m_objects[objRank].distance = 0.0f;
+ m_objects[objRank].baseObjRank = -1;
m_objects[objRank].shadowRank = -1;
return objRank;
diff --git a/src/graphics/engine/lightman.cpp b/src/graphics/engine/lightman.cpp
index 8694c7a..564cced 100644
--- a/src/graphics/engine/lightman.cpp
+++ b/src/graphics/engine/lightman.cpp
@@ -69,16 +69,6 @@ void LightProgression::SetTarget(float value)
}
-DynamicLight::DynamicLight()
-{
- rank = 0;
- used = enabled = false;
- priority = LIGHT_PRI_LOW;
- includeType = excludeType = ENG_OBJTYPE_NULL;
-}
-
-
-
CLightManager::CLightManager(CEngine* engine)
{
m_device = nullptr;
diff --git a/src/graphics/engine/lightman.h b/src/graphics/engine/lightman.h
index a2f6044..5df466d 100644
--- a/src/graphics/engine/lightman.h
+++ b/src/graphics/engine/lightman.h
@@ -51,9 +51,12 @@ struct LightProgression
float speed;
LightProgression()
- {
- starting = ending = current = progress = speed = 0.0f;
- }
+ : starting(0.0f)
+ , ending(0.0f)
+ , current(0.0f)
+ , progress(0.0f)
+ , speed(0.0f)
+ {}
//! Initializes the progression
void Init(float value);
@@ -113,7 +116,14 @@ struct DynamicLight
//! Type of objects excluded from lighting with this light; if ENG_OBJTYPE_NULL is used, it is ignored
EngineObjectType excludeType;
- DynamicLight();
+ DynamicLight()
+ : rank(0)
+ , used(false)
+ , enabled(false)
+ , priority(LIGHT_PRI_LOW)
+ , includeType(ENG_OBJTYPE_NULL)
+ , excludeType(ENG_OBJTYPE_NULL)
+ {}
};
/**
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index 7c51829..d3e0405 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -32,8 +32,6 @@
#include "object/robotmain.h"
#include "object/motion/motionhuman.h"
-#include "ui/displaytext.h"
-
// Graphics module namespace
namespace Gfx {
@@ -49,7 +47,6 @@ CPyro::CPyro()
m_camera = m_main->GetCamera();
m_particle = m_engine->GetParticle();
m_lightMan = m_engine->GetLightManager();
- m_displayText = m_main->GetDisplayText();
m_sound = CApplication::GetInstancePointer()->GetSound();
m_object = nullptr;
@@ -1301,13 +1298,13 @@ void CPyro::DisplayError(PyroType type, CObject* obj)
oType == OBJECT_END )
{
err = ERR_DELETEBUILDING;
- m_displayText->DisplayError(err, obj->GetPosition(0), 5.0f);
+ m_main->DisplayError(err, obj->GetPosition(0), 5.0f);
return;
}
if ( err != ERR_OK )
{
- m_displayText->DisplayError(err, obj);
+ m_main->DisplayError(err, obj);
}
}
}
@@ -1556,15 +1553,18 @@ void CPyro::ExploStart()
for (int i = 0; i < OBJECTMAXPART; i++)
{
int objRank = m_object->GetObjectRank(i);
- if (objRank == -1) continue;
+ if (objRank == -1) continue;
// TODO: refactor later to material change
int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank);
- int newBaseObjRank = m_engine->CreateBaseObject();
- m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank);
- m_engine->SetObjectBaseRank(objRank, newBaseObjRank);
+ if (oldBaseObjRank != -1)
+ {
+ int newBaseObjRank = m_engine->CreateBaseObject();
+ m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank);
+ m_engine->SetObjectBaseRank(objRank, newBaseObjRank);
- m_engine->ChangeSecondTexture(objRank, "dirty04.png");
+ m_engine->ChangeSecondTexture(objRank, "dirty04.png");
+ }
Math::Vector pos = m_object->GetPosition(i);
@@ -1628,11 +1628,14 @@ void CPyro::BurnStart()
// TODO: refactor later to material change
int oldBaseObjRank = m_engine->GetObjectBaseRank(objRank);
- int newBaseObjRank = m_engine->CreateBaseObject();
- m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank);
- m_engine->SetObjectBaseRank(objRank, newBaseObjRank);
+ if (oldBaseObjRank != -1)
+ {
+ int newBaseObjRank = m_engine->CreateBaseObject();
+ m_engine->CopyBaseObject(oldBaseObjRank, newBaseObjRank);
+ m_engine->SetObjectBaseRank(objRank, newBaseObjRank);
- m_engine->ChangeSecondTexture(objRank, "dirty04.png");
+ m_engine->ChangeSecondTexture(objRank, "dirty04.png");
+ }
}
m_engine->LoadTexture("dirty04.png");
diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h
index 98b9a1b..60724b4 100644
--- a/src/graphics/engine/pyro.h
+++ b/src/graphics/engine/pyro.h
@@ -35,10 +35,6 @@ class CObject;
class CRobotMain;
class CSoundInterface;
-namespace Ui {
-class CDisplayText;
-}
-
// Graphics module namespace
namespace Gfx {
@@ -179,7 +175,6 @@ protected:
CParticle* m_particle;
CLightManager* m_lightMan;
CObject* m_object;
- Ui::CDisplayText* m_displayText;
CRobotMain* m_main;
CSoundInterface* m_sound;
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 4fe3057..4b5384e 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -90,7 +90,7 @@ bool CTerrain::Generate(int mosaicCount, int brickCountPow2, float brickSize,
std::vector<int>(dim).swap(m_textures);
dim = m_mosaicCount*m_mosaicCount;
- std::vector<int>(dim).swap(m_objRanks);
+ std::vector<int>(dim, -1).swap(m_objRanks);
return true;
}
@@ -258,6 +258,23 @@ TerrainRes CTerrain::GetResource(const Math::Vector &p)
void CTerrain::FlushRelief()
{
m_relief.clear();
+ m_resources.clear();
+ m_textures.clear();
+
+ for (int objRank : m_objRanks)
+ {
+ if (objRank == -1)
+ continue;
+
+ int baseObjRank = m_engine->GetObjectBaseRank(objRank);
+
+ if (baseObjRank != -1)
+ m_engine->DeleteBaseObject(baseObjRank);
+
+ m_engine->DeleteObject(objRank);
+ }
+
+ m_objRanks.clear();
}
/**
diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h
index e2317c4..e618691 100644
--- a/src/graphics/engine/terrain.h
+++ b/src/graphics/engine/terrain.h
@@ -239,7 +239,7 @@ public:
//! Generates a level in the terrain
bool GenerateMaterials(int *id, float min, float max, float slope, float freq, Math::Vector center, float radius);
- //! Clears the relief data to zero
+ //! Clears the relief, resources and all other associated data
void FlushRelief();
//! Load relief from image
bool LoadRelief(const std::string& fileName, float scaleRelief, bool adjustBorder);
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 610bfcf..ffd2eb2 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -140,6 +140,12 @@ void CText::FlushCache()
for (auto jt = mf->fonts.begin(); jt != mf->fonts.end(); ++jt)
{
CachedFont *f = (*jt).second;
+ for (auto ct = f->cache.begin(); ct != f->cache.end(); ++ct)
+ {
+ Texture tex;
+ tex.id = (*ct).second.id;
+ m_device->DestroyTexture(tex);
+ }
f->cache.clear();
}
}
@@ -358,14 +364,22 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
CachedFont* cf = GetOrOpenFont(font, size);
assert(cf != nullptr);
- CharTexture tex;
+ Math::Point charSize;
auto it = cf->cache.find(ch);
if (it != cf->cache.end())
- tex = (*it).second;
+ {
+ charSize = (*it).second.charSize;
+ }
else
- tex = CreateCharTexture(ch, cf);
+ {
+ Math::IntPoint wndSize;
+ std::string text;
+ text.append({ch.c1, ch.c2, ch.c3});
+ TTF_SizeUTF8(cf->font, text.c_str(), &wndSize.x, &wndSize.y);
+ charSize = m_engine->WindowToInterfaceSize(wndSize);
+ }
- return tex.charSize.x * width;
+ return charSize.x * width;
}
@@ -896,7 +910,6 @@ CharTexture CText::CreateCharTexture(UTF8Char ch, CachedFont* font)
if (! tex.Valid())
{
m_error = "Texture create error";
- return texture;
}
else
{
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index bbabdd6..9f64fab 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -606,7 +606,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
}
else if (params.format == TEX_IMG_AUTO)
{
- if (data->surface->format->Amask != 0)
+ if (data->surface->format->BytesPerPixel == 4)
{
if ((data->surface->format->Amask == 0xFF000000) &&
(data->surface->format->Rmask == 0x00FF0000) &&
@@ -630,7 +630,7 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
convert = true;
}
}
- else
+ else if (data->surface->format->BytesPerPixel == 3)
{
if ((data->surface->format->Rmask == 0xFF0000) &&
(data->surface->format->Gmask == 0x00FF00) &&
@@ -652,6 +652,10 @@ Texture CGLDevice::CreateTexture(ImageData *data, const TextureCreateParams &par
convert = true;
}
}
+ else {
+ GetLogger()->Error("Unknown data surface format");
+ assert(false);
+ }
}
else
assert(false);
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 8dc1d94..0aeaa0a 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -52,7 +52,6 @@ CAuto::CAuto(CObject* object)
m_lightning = m_engine->GetLightning();
m_camera = m_main->GetCamera();
m_interface = m_main->GetInterface();
- m_displayText = m_main->GetDisplayText();
m_type = m_object->GetType();
m_time = 0.0f;
@@ -83,7 +82,6 @@ CAuto::~CAuto()
m_lightning = nullptr;
m_camera = nullptr;
m_interface = nullptr;
- m_displayText = nullptr;
}
diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h
index 4a430ce..fd25e70 100644
--- a/src/object/auto/auto.h
+++ b/src/object/auto/auto.h
@@ -28,7 +28,6 @@ class CRobotMain;
class CSoundInterface;
namespace Ui {
-class CDisplayText;
class CInterface;
class CWindow;
} /* Ui */
@@ -101,7 +100,6 @@ protected:
Gfx::CLightning* m_lightning;
Gfx::CCamera* m_camera;
Ui::CInterface* m_interface;
- Ui::CDisplayText* m_displayText;
CRobotMain* m_main;
CObject* m_object;
CSoundInterface* m_sound;
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index d0bd87b..6d61bc2 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -34,7 +34,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
@@ -317,14 +316,14 @@ begin:
err = CheckCloseDoor();
if ( err != ERR_OK )
{
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
return false;
}
err = m_main->CheckEndMission(false);
if ( err != ERR_OK )
{
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
return false;
}
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index 7281ed7..ee1e83b 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -26,7 +26,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -515,7 +514,7 @@ void CAutoConvert::CreateMetal()
if ( !fret->CreateResource(pos, angle, OBJECT_METAL) )
{
delete fret;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return;
}
@@ -524,6 +523,6 @@ void CAutoConvert::CreateMetal()
fret->SetResetCap(RESET_DELETE);
}
- m_displayText->DisplayError(INFO_CONVERT, m_object);
+ m_main->DisplayError(INFO_CONVERT, m_object);
}
diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp
index b613406..5b6cea4 100644
--- a/src/object/auto/autoderrick.cpp
+++ b/src/object/auto/autoderrick.cpp
@@ -28,7 +28,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -535,7 +534,7 @@ void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type,
if ( !fret->CreateResource(pos, angle, type) )
{
delete fret;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return;
}
fret->SetLock(true); // object not yet usable
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index fdaebc0..dfe8e78 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.cpp
@@ -24,7 +24,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -122,7 +121,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
{
Error err = StartAction(0);
if ( err != ERR_OK )
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
return false;
}
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index 6a8672b..a38caf2 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -29,7 +29,6 @@
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -325,7 +324,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
fret->SetPosition(0, Math::Vector(0.0f, 3.0f, 0.0f));
m_object->SetPower(fret);
- m_displayText->DisplayError(INFO_ENERGY, m_object);
+ m_main->DisplayError(INFO_ENERGY, m_object);
}
SetBusy(false);
@@ -468,7 +467,7 @@ void CAutoEnergy::CreatePower()
if ( !power->CreateResource(pos, angle, OBJECT_POWER) )
{
delete power;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return;
}
power->SetLock(true); // battery not yet usable
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
index a648656..49abad4 100644
--- a/src/object/auto/autofactory.cpp
+++ b/src/object/auto/autofactory.cpp
@@ -32,7 +32,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -211,7 +210,7 @@ bool CAutoFactory::EventProcess(const Event &event)
Error err = StartAction(type);
if( err != ERR_OK && err != ERR_GENERIC )
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
if( err != ERR_GENERIC )
return false;
@@ -379,7 +378,7 @@ bool CAutoFactory::EventProcess(const Event &event)
}
else
{
- m_displayText->DisplayError(INFO_FACTORY, m_object);
+ m_main->DisplayError(INFO_FACTORY, m_object);
SoundManip(2.0f, 1.0f, 1.2f);
fret = SearchFret(); // transform metal?
@@ -678,7 +677,7 @@ bool CAutoFactory::CreateVehicle()
if ( !vehicle->CreateVehicle(pos, angle, m_type, -1.0f, false, false) )
{
delete vehicle;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return false;
}
vehicle->UpdateMapping();
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 172a618..07112b7 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -29,7 +29,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -179,7 +178,7 @@ bool CAutoLabo::EventProcess(const Event &event)
if ( event.type == EVENT_OBJECT_RiGUN ) err = StartAction(RESEARCH_iGUN);
if( err != ERR_OK && err != ERR_GENERIC )
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
if( err != ERR_GENERIC )
return false;
@@ -370,7 +369,7 @@ bool CAutoLabo::EventProcess(const Event &event)
delete power;
}
- m_displayText->DisplayError(INFO_LABO, m_object);
+ m_main->DisplayError(INFO_LABO, m_object);
SoundManip(1.5f, 1.0f, 0.5f);
m_phase = ALAP_CLOSE1;
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index 224776d..edab5eb 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.cpp
@@ -26,7 +26,6 @@
#include "ui/interface.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -274,7 +273,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
SetBusy(false);
UpdateInterface();
- m_displayText->DisplayError(INFO_NUCLEAR, m_object);
+ m_main->DisplayError(INFO_NUCLEAR, m_object);
m_phase = ANUP_WAIT;
m_progress = 0.0f;
@@ -402,7 +401,7 @@ void CAutoNuclear::CreatePower()
if ( !power->CreateResource(pos, angle, OBJECT_ATOMIC) )
{
delete power;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return;
}
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index 8308ebe..834a48c 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.cpp
@@ -29,7 +29,6 @@
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
#include <stdio.h>
#include <string.h>
@@ -178,7 +177,7 @@ bool CAutoResearch::EventProcess(const Event &event)
if ( event.type == EVENT_OBJECT_RATOMIC ) err = StartAction(RESEARCH_ATOMIC);
if( err != ERR_OK && err != ERR_GENERIC )
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
if( err != ERR_GENERIC )
return false;
@@ -257,7 +256,7 @@ bool CAutoResearch::EventProcess(const Event &event)
m_eventQueue->AddEvent(newEvent);
UpdateInterface();
- m_displayText->DisplayError(INFO_RESEARCH, m_object);
+ m_main->DisplayError(INFO_RESEARCH, m_object);
message = ERR_OK;
if ( m_research == RESEARCH_TANK ) message = INFO_RESEARCHTANK;
@@ -270,7 +269,7 @@ bool CAutoResearch::EventProcess(const Event &event)
if ( m_research == RESEARCH_ATOMIC ) message = INFO_RESEARCHATOMIC;
if ( message != ERR_OK )
{
- m_displayText->DisplayError(message, m_object);
+ m_main->DisplayError(message, m_object);
}
SetBusy(false);
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 17a41f4..329cab0 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -27,7 +27,6 @@
#include "script/cmdtoken.h"
#include "ui/interface.h"
-#include "ui/displaytext.h"
#include "ui/window.h"
#include "ui/gauge.h"
@@ -179,7 +178,7 @@ bool CAutoTower::EventProcess(const Event &event)
target = SearchTarget(m_targetPos);
if ( energy < ENERGY_FIRE )
{
- m_displayText->DisplayError(ERR_TOWER_ENERGY, m_object);
+ m_main->DisplayError(ERR_TOWER_ENERGY, m_object);
}
if ( target == 0 || energy < ENERGY_FIRE )
{
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 9e5149e..1b1565a 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -35,7 +35,6 @@
#include "sound/sound.h"
-#include "ui/displaytext.h"
#include "ui/interface.h"
#include "ui/slider.h"
#include "ui/studio.h"
@@ -61,7 +60,6 @@ CBrain::CBrain(CObject* object)
m_terrain = m_main->GetTerrain();
m_camera = m_main->GetCamera();
m_interface = m_main->GetInterface();
- m_displayText = m_main->GetDisplayText();
m_sound = CApplication::GetInstancePointer()->GetSound();
m_physics = nullptr;
m_motion = nullptr;
@@ -733,7 +731,7 @@ bool CBrain::EventProcess(const Event &event)
if ( err != ERR_OK )
{
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
}
return true;
@@ -1201,7 +1199,7 @@ void CBrain::GroundFlat()
err = ERR_FLAG_FLY;
pos = m_object->GetPosition(0);
if ( pos.y < m_water->GetLevel() ) err = ERR_FLAG_WATER;
- m_displayText->DisplayError(err, m_object);
+ m_main->DisplayError(err, m_object);
return;
}
diff --git a/src/object/brain.h b/src/object/brain.h
index dcf07a4..a1f5da7 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -43,7 +43,6 @@ namespace Ui {
class CStudio;
class CInterface;
class CWindow;
-class CDisplayText;
}
namespace Gfx {
@@ -177,7 +176,6 @@ protected:
CPhysics* m_physics;
CMotion* m_motion;
Ui::CInterface* m_interface;
- Ui::CDisplayText* m_displayText;
CRobotMain* m_main;
Ui::CStudio* m_studio;
CSoundInterface* m_sound;
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 4cf0688..5a709e6 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -79,8 +79,6 @@
#include "script/cbottoken.h"
#include "script/cmdtoken.h"
-#include "ui/displaytext.h"
-
#define ADJUST_ONBOARD false // true -> adjusts the camera ONBOARD
@@ -228,7 +226,6 @@ CObject::CObject()
m_main = CRobotMain::GetInstancePointer();
m_terrain = m_main->GetTerrain();
m_camera = m_main->GetCamera();
- m_displayText = m_main->GetDisplayText();
m_physics = nullptr;
m_brain = nullptr;
m_motion = nullptr;
@@ -5988,7 +5985,7 @@ bool CObject::EventFrame(const Event &event)
m_sound->Play(SOUND_FINDING);
pyro = new Gfx::CPyro();
pyro->Create(Gfx::PT_FINDING, this, 0.0f);
- m_displayText->DisplayError(INFO_FINDING, this);
+ m_main->DisplayError(INFO_FINDING, this);
}
}
@@ -6639,7 +6636,7 @@ void CObject::SetSelect(bool bMode, bool bDisplayError)
}
if ( err != ERR_OK && bDisplayError )
{
- m_displayText->DisplayError(err, this);
+ m_main->DisplayError(err, this);
}
}
diff --git a/src/object/object.h b/src/object/object.h
index 25ea708..e8b83d9 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -38,10 +38,6 @@ class CRobotMain;
class CBotVar;
class CScript;
-namespace Ui {
-class CDisplayText;
-}
-
/**
* \enum ObjectType
@@ -689,7 +685,6 @@ protected:
CBrain* m_brain;
CMotion* m_motion;
CAuto* m_auto;
- Ui::CDisplayText* m_displayText;
CRobotMain* m_main;
CSoundInterface* m_sound;
CBotVar* m_botVar;
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index b58e5f8..6fe85d3 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -107,7 +107,7 @@ float g_unit; // conversion factor
// Static variables
static CBotClass* m_pClassFILE;
-static CBotProgram* m_pFuncFile;
+//static CBotProgram* m_pFuncFile;
static int m_CompteurFileOpen = 0;
static std::string m_filesDir;
@@ -503,10 +503,10 @@ void InitClassFILE()
m_pClassFILE->AddFunction("readln", rfread, cfread );
m_pClassFILE->AddFunction("eof", rfeof, cfeof );
- m_pFuncFile = new CBotProgram( );
- CBotStringArray ListFonctions;
- m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
- m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
+ //m_pFuncFile = new CBotProgram( );
+ //CBotStringArray ListFonctions;
+ //m_pFuncFile->Compile( "public file openfile(string name, string mode) {return new file(name, mode);}", ListFonctions);
+ //m_pFuncFile->SetIdent(-2); // restoreState in special identifier for this function
}
@@ -1104,6 +1104,7 @@ void CRobotMain::ChangePhase(Phase phase)
ChangePause(false);
FlushDisplayInfo();
m_engine->SetRankView(0);
+ m_terrain->FlushRelief();
m_engine->DeleteAllObjects();
Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies();
m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
@@ -3842,9 +3843,9 @@ void CRobotMain::Convert()
void CRobotMain::ScenePerso()
{
DeleteAllObjects(); // removes all the current 3D Scene
+ m_terrain->FlushRelief();
m_engine->DeleteAllObjects();
Gfx::CModelManager::GetInstancePointer()->DeleteAllModelCopies();
- m_terrain->FlushRelief(); // all flat
m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit();
m_lightMan->FlushLights();
@@ -7520,3 +7521,12 @@ void CRobotMain::RestoreNumericLocale()
setlocale(LC_NUMERIC, m_oldLocale.c_str());
}
+void CRobotMain::DisplayError(Error err, CObject* pObj, float time)
+{
+ m_displayText->DisplayError(err, pObj, time);
+}
+
+void CRobotMain::DisplayError(Error err, Math::Vector goal, float height, float dist, float time)
+{
+ m_displayText->DisplayError(err, goal, height, dist, time);
+}
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 525e5df..035698c 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -379,6 +379,9 @@ public:
CObject* GetSelect();
+ void DisplayError(Error err, CObject* pObj, float time=10.0f);
+ void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f);
+
protected:
bool EventFrame(const Event &event);
bool EventObject(const Event &event);
diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp
index 5ec6f8a..3624816 100644
--- a/src/object/task/task.cpp
+++ b/src/object/task/task.cpp
@@ -35,7 +35,6 @@ CTask::CTask(CObject* object)
m_main = CRobotMain::GetInstancePointer();
m_terrain = m_main->GetTerrain();
m_camera = m_main->GetCamera();
- m_displayText = m_main->GetDisplayText();
m_object = object;
m_physics = m_object->GetPhysics();
diff --git a/src/object/task/task.h b/src/object/task/task.h
index 41b3d3b..800b880 100644
--- a/src/object/task/task.h
+++ b/src/object/task/task.h
@@ -32,9 +32,6 @@ class CObject;
class CRobotMain;
class CSoundInterface;
-namespace Ui {
-class CDisplayText;
-} /* Ui */
namespace Gfx {
class CEngine;
@@ -84,7 +81,6 @@ protected:
CPhysics* m_physics;
CObject* m_object;
CRobotMain* m_main;
- Ui::CDisplayText* m_displayText;
CSoundInterface* m_sound;
};
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index 39479a6..4a62a4a 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -33,8 +33,6 @@
#include "physics/physics.h"
-#include "ui/displaytext.h"
-
#include <string.h>
// Object's constructor.
@@ -264,7 +262,7 @@ bool CTaskBuild::EventProcess(const Event &event)
m_camera->FlushEffect();
Abort();
m_bError = true;
- m_displayText->DisplayError(ERR_TOOMANY, m_object->GetPosition(0));
+ m_main->DisplayError(ERR_TOOMANY, m_object->GetPosition(0));
return false;
}
CreateLight();
@@ -486,7 +484,7 @@ Error CTaskBuild::IsEnded()
m_building->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
m_building->SetLock(false); // building usable
m_main->CreateShortcuts();
- m_displayText->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f);
+ m_main->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f);
automat = m_building->GetAuto();
if ( automat != 0 )
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index b86e9a5..af84099 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -27,7 +27,7 @@
#include "physics/physics.h"
-#include "ui/displaytext.h"
+#include "object/robotmain.h"
const float ENERGY_RECOVER = 0.25f; // energy consumed by recovery
@@ -305,7 +305,7 @@ Error CTaskRecover::IsEnded()
m_metal = 0;
Abort();
m_bError = true;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return ERR_STOP;
}
m_metal->SetLock(true); // metal not yet usable
diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp
index 974a53d..aa731a0 100644
--- a/src/object/task/tasksearch.cpp
+++ b/src/object/task/tasksearch.cpp
@@ -26,9 +26,7 @@
#include "physics/physics.h"
-#include "ui/displaytext.h"
-
-
+#include "object/robotmain.h"
// Object's constructor.
@@ -293,11 +291,11 @@ bool CTaskSearch::CreateMark()
if ( !fret->CreateResource(pos, 0.0f, type) )
{
delete fret;
- m_displayText->DisplayError(ERR_TOOMANY, m_object);
+ m_main->DisplayError(ERR_TOOMANY, m_object);
return false;
}
- m_displayText->DisplayError(info, pos, 5.0f, 50.0f); // displays the message
+ m_main->DisplayError(info, pos, 5.0f, 50.0f); // displays the message
return true;
}
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index fe6eaeb..e9ab157 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -26,6 +26,7 @@
#include "math/geometry.h"
#include "object/brain.h"
+#include "object/robotmain.h"
#include "physics/physics.h"
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 1f5ef7b..096e5de 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -28,6 +28,7 @@
#include "math/geometry.h"
#include "object/brain.h"
+#include "object/robotmain.h"
#include "object/motion/motionant.h"
#include "object/motion/motionspider.h"
diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp
index bf9d593..9c099d2 100644
--- a/src/object/task/taskturn.cpp
+++ b/src/object/task/taskturn.cpp
@@ -20,7 +20,7 @@
#include "graphics/engine/terrain.h"
#include "physics/physics.h"
-
+#include "object/robotmain.h"
// Object's constructor.
diff --git a/src/script/script.cpp b/src/script/script.cpp
index b03702c..ca6ce25 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -3174,7 +3174,7 @@ bool CScript::rMessage(CBotVar* var, CBotVar* result, int& exception, void* user
type = static_cast<Ui::TextType>(var->GetValInt());
}
- script->m_displayText->DisplayText(p, script->m_object, 10.0f, type);
+ script->m_main->GetDisplayText()->DisplayText(p, script->m_object, 10.0f, type);
script->m_main->CheckEndMessage(p);
return true;
@@ -3504,7 +3504,6 @@ CScript::CScript(CObject* object, CTaskManager** secondaryTask)
m_secondaryTask = secondaryTask;
m_interface = m_main->GetInterface();
- m_displayText = m_main->GetDisplayText();
m_ipf = CBOT_IPF;
m_errMode = ERM_STOP;
@@ -3690,6 +3689,7 @@ bool CScript::IsEmpty()
bool CScript::CheckToken()
{
CBotToken* bt;
+ CBotToken* allBt;
CBotString bs;
const char* token;
int error, cursor1, cursor2, i;
@@ -3707,7 +3707,8 @@ bool CScript::CheckToken()
used[i] = 0; // token not used
}
- bt = CBotToken::CompileTokens(m_script, error);
+ allBt = CBotToken::CompileTokens(m_script, error);
+ bt = allBt;
while ( bt != 0 )
{
bs = bt->GetString();
@@ -3728,7 +3729,7 @@ bool CScript::CheckToken()
m_cursor1 = cursor1;
m_cursor2 = cursor2;
strcpy(m_title, "<erreur>");
- CBotToken::Delete(bt);
+ CBotToken::Delete(allBt);
return false;
}
@@ -3743,12 +3744,12 @@ bool CScript::CheckToken()
strcpy(m_token, m_main->GetObligatoryToken(i));
m_error = ERR_OBLIGATORYTOKEN;
strcpy(m_title, "<erreur>");
- CBotToken::Delete(bt);
+ CBotToken::Delete(allBt);
return false;
}
}
- CBotToken::Delete(bt);
+ CBotToken::Delete(allBt);
return true;
}
@@ -3899,7 +3900,7 @@ bool CScript::Continue(const Event &event)
{
char s[100];
GetError(s);
- m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
+ m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
}
m_engine->SetPause(true); // gives pause
return true;
@@ -3932,7 +3933,7 @@ bool CScript::Continue(const Event &event)
{
char s[100];
GetError(s);
- m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
+ m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
}
return true;
}
@@ -3974,7 +3975,7 @@ bool CScript::Step(const Event &event)
{
char s[100];
GetError(s);
- m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
+ m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
}
return true;
}
diff --git a/src/script/script.h b/src/script/script.h
index 7a5d075..7fd5555 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -34,7 +34,6 @@ class CTaskManager;
class CRobotMain;
namespace Ui{
-class CDisplayText;
class CEdit;
class CInterface;
class CList;
@@ -210,7 +209,6 @@ private:
protected:
Gfx::CEngine* m_engine;
Ui::CInterface* m_interface;
- Ui::CDisplayText* m_displayText;
CBotProgram* m_botProg;
CRobotMain* m_main;
Gfx::CTerrain* m_terrain;
diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h
index ad32204..cd44ae9 100644
--- a/src/sound/oalsound/alsound.h
+++ b/src/sound/oalsound/alsound.h
@@ -32,7 +32,7 @@
#include <map>
#include <string>
-#include <AL/al.h>
+#include <al.h>
class ALSound : public CSoundInterface
diff --git a/src/sound/oalsound/buffer.h b/src/sound/oalsound/buffer.h
index d847426..e693d75 100644
--- a/src/sound/oalsound/buffer.h
+++ b/src/sound/oalsound/buffer.h
@@ -30,7 +30,7 @@
#include <vector>
#include <array>
-#include <AL/al.h>
+#include <al.h>
#include <sndfile.h>
class Buffer
diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h
index a04b509..2930f26 100644
--- a/src/sound/oalsound/channel.h
+++ b/src/sound/oalsound/channel.h
@@ -30,8 +30,8 @@
#include <deque>
#include <cassert>
-#include <AL/al.h>
-#include <AL/alc.h>
+#include <al.h>
+#include <alc.h>
struct SoundOper
{
diff --git a/src/sound/oalsound/check.h b/src/sound/oalsound/check.h
index f677e17..b8f67c0 100644
--- a/src/sound/oalsound/check.h
+++ b/src/sound/oalsound/check.h
@@ -18,11 +18,11 @@
#pragma once
-#include <AL/al.h>
-#include <AL/alc.h>
-
#include "common/logger.h"
+#include <al.h>
+#include <alc.h>
+
static ALenum CODE = AL_NO_ERROR;
inline bool alCheck()
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 6fd1735..a187688 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -1144,7 +1144,7 @@ void CEdit::DrawImage(Math::Point pos, std::string name, float width,
float dp;
std::string filename;
- filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png";
+ filename = GetProfile().GetUserBasedPath(name, "../icons") + ".png";
m_engine->SetTexture(filename);
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
@@ -1426,7 +1426,7 @@ void CEdit::FreeImage()
for (int i = 0 ; i < m_imageTotal; i++ )
{
- filename = GetProfile().GetUserBasedPath(m_image[i].name, "diagram") + ".png";
+ filename = GetProfile().GetUserBasedPath(m_image[i].name, "../icons") + ".png";
m_engine->DeleteTexture(filename);
}
}
@@ -1436,7 +1436,7 @@ void CEdit::FreeImage()
void CEdit::LoadImage(std::string name)
{
std::string filename;
- filename = GetProfile().GetUserBasedPath(name, "diagram") + ".png";
+ filename = GetProfile().GetUserBasedPath(name, "../icons") + ".png";
m_engine->LoadTexture(filename);
}
@@ -1653,7 +1653,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
m_image[iIndex].width = iWidth*0.75f;
m_text[j] = static_cast<char>(iIndex++); // as an index into m_image
- m_format[j] = static_cast<unsigned char>(Gfx::FONT_MASK_IMAGE);
+ m_format[j] = Gfx::FONT_MASK_IMAGE;
j ++;
}
}
diff --git a/src/ui/edit.h b/src/ui/edit.h
index acdf72c..9484fc8 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -89,7 +89,7 @@ enum OperUndo
struct ImageLine
{
- //! name of the image (without diagram \)
+ //! name of the image (without icons/)
std::string name;
//! vertical offset (v texture)
float offset;
@@ -101,7 +101,7 @@ struct ImageLine
struct HyperLink
{
- //! text file name (without help \)
+ //! text file name (without help/)
std::string name;
//! name of the marker
std::string marker;
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 845579e..ab2c01b 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -29,7 +29,7 @@ CInterface::CInterface()
m_engine = Gfx::CEngine::GetInstancePointer();
m_camera = nullptr;
- for (int i = 0; i < MAXCONTROL; i++ )
+ for (int i = 0; i < MAXCONTROL; i++)
{
m_table[i] = nullptr;
}
@@ -47,9 +47,9 @@ CInterface::~CInterface()
void CInterface::Flush()
{
- for (int i = 0; i < MAXCONTROL; i++ )
+ for (int i = 0; i < MAXCONTROL; i++)
{
- if ( m_table[i] != nullptr )
+ if (m_table[i] != nullptr)
{
delete m_table[i];
m_table[i] = nullptr;
@@ -71,16 +71,15 @@ int CInterface::GetNextFreeControl()
template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- T* pc;
- int index;
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
- if ((index = GetNextFreeControl()) < 0)
+ int index = GetNextFreeControl();
+ if (index < 0)
return nullptr;
m_table[index] = new T();
- pc = static_cast<T *>(m_table[index]);
+ T* pc = static_cast<T *>(m_table[index]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -90,11 +89,10 @@ template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math:
CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CWindow* pc;
- int index;
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
+ int index = -1;
switch (eventMsg)
{
case EVENT_WINDOW0: index = 0; break;
@@ -114,8 +112,9 @@ CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, E
if (index < 0)
return nullptr;
+ delete m_table[index];
m_table[index] = new CWindow();
- pc = static_cast<CWindow *>(m_table[index]);
+ CWindow* pc = static_cast<CWindow *>(m_table[index]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -207,16 +206,15 @@ CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, Ev
CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
{
- CList* pc;
- int index;
if (eventMsg == EVENT_NULL)
eventMsg = GetUniqueEventType();
- if ((index = GetNextFreeControl()) < 0)
+ int index = GetNextFreeControl();
+ if (index < 0)
return nullptr;
m_table[index] = new CList();
- pc = static_cast<CList *>(m_table[index]);
+ CList* pc = static_cast<CList *>(m_table[index]);
pc->Create(pos, dim, icon, eventMsg, expand);
return pc;
}
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index defff84..407f8da 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -1841,17 +1841,6 @@ pos.y -= 0.048f;
pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));
- pos.x = 80.0f/640.0f;
- pos.y = 140.0f/480.0f;
- ddim.x = 490.0f/640.0f;
- ddim.y = 100.0f/480.0f;
- pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT2);
- pe->SetGenericMode(true);
- pe->SetEditCap(false);
- pe->SetHighlightCap(false);
- pe->SetFontType(Gfx::FONT_COURIER);
- pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
- pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/licences.txt"));
// #endif
/* TODO: #if _SCHOOL
#if _CEEBOTDEMO
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 95cf1b1..1f5e1bc 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -9,6 +9,9 @@ elseif(PLATFORM_WINDOWS)
elseif(PLATFORM_LINUX)
# for clock_gettime
set(PLATFORM_LIBS "-lrt -lX11")
+elseif(PLATFORM_MACOSX)
+ find_library(LIBINTL_LIBRARY NAMES intl libintl )
+ set(PLATFORM_LIBS ${LIBINTL_LIBRARY} ${X11_X11_LIB})
endif()
@@ -232,7 +235,7 @@ ${LIBSNDFILE_LIBRARY}
add_executable(colobot_ut ${COLOBOT_SOURCES} ${UT_SOURCES} ${OPENAL_SOURCES})
target_link_libraries(colobot_ut ${LIBS})
-add_test(colobot_ut ./colobot_ut)
+add_test(colobot_ut ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/colobot_ut)
# TODO: change the unit cases to independent automated tests to be included in colobot_ut
add_subdirectory(common)
diff --git a/test/unit/ui/CMakeLists.txt b/test/unit/ui/CMakeLists.txt
index c18af87..97dd681 100644
--- a/test/unit/ui/CMakeLists.txt
+++ b/test/unit/ui/CMakeLists.txt
@@ -14,6 +14,9 @@ if(PLATFORM_WINDOWS)
elseif(PLATFORM_LINUX)
set(SYSTEM_CPP_MODULE "system_linux.cpp")
set(ADDITIONAL_LIB "-lX11")
+elseif(PLATFORM_MACOSX)
+ set(SYSTEM_CPP_MODULE "system_other.cpp")
+ set(ADDITIONAL_LIB "${X11_X11_LIB}")
else()
set(SYSTEM_CPP_MODULE "system_other.cpp")
set(ADDITIONAL_LIB "-lX11")
@@ -44,4 +47,4 @@ target_link_libraries(edit_test gtest gmock clipboard ${SDL_LIBRARY} ${SDLTTF_LI
-add_test(edit_test ./edit_test)
+add_test(edit_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/edit_test)