summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/FindLTDL.cmake30
-rw-r--r--cmake/mxe.cmake2
-rw-r--r--debian/control1
-rw-r--r--src/CBot/CMakeLists.txt3
-rw-r--r--src/CMakeLists.txt32
-rw-r--r--src/app/app.cpp45
-rw-r--r--src/app/app.h4
-rw-r--r--src/common/config.h.cmake2
-rw-r--r--src/object/robotmain.cpp4
-rw-r--r--src/plugins/plugininterface.h65
-rw-r--r--src/plugins/pluginloader.cpp124
-rw-r--r--src/plugins/pluginloader.h87
-rw-r--r--src/plugins/pluginmanager.cpp132
-rw-r--r--src/plugins/pluginmanager.h87
-rw-r--r--src/plugins/test/CMakeLists.txt15
-rw-r--r--src/plugins/test/colobot.ini3
-rw-r--r--src/plugins/test/manager_test.cpp31
-rw-r--r--src/sound/oalsound/alsound.cpp (renamed from src/sound/plugins/oalsound/alsound.cpp)60
-rw-r--r--src/sound/oalsound/alsound.h (renamed from src/sound/plugins/oalsound/alsound.h)10
-rw-r--r--src/sound/oalsound/buffer.cpp (renamed from src/sound/plugins/oalsound/buffer.cpp)4
-rw-r--r--src/sound/oalsound/buffer.h (renamed from src/sound/plugins/oalsound/buffer.h)0
-rw-r--r--src/sound/oalsound/channel.cpp (renamed from src/sound/plugins/oalsound/channel.cpp)2
-rw-r--r--src/sound/oalsound/channel.h (renamed from src/sound/plugins/oalsound/channel.h)0
-rw-r--r--src/sound/oalsound/check.h (renamed from src/sound/plugins/oalsound/check.h)0
-rw-r--r--src/sound/plugins/oalsound/CMakeLists.txt24
-rw-r--r--src/sound/plugins/oalsound/test/CMakeLists.txt14
-rw-r--r--src/sound/plugins/oalsound/test/plugin_test.cpp40
-rw-r--r--src/sound/sound.h4
-rw-r--r--src/ui/maindialog.cpp132
30 files changed, 147 insertions, 813 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce56bdd..a80e7d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,8 @@ 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
@@ -48,7 +50,6 @@ find_package(SDL 1.2.10 REQUIRED)
find_package(SDL_image 1.2 REQUIRED)
find_package(SDL_ttf 2.0 REQUIRED)
find_package(PNG 1.2 REQUIRED)
-find_package(LTDL 2.4.2 REQUIRED)
find_package(Gettext REQUIRED)
set(Boost_USE_STATIC_LIBS ON)
diff --git a/cmake/FindLTDL.cmake b/cmake/FindLTDL.cmake
deleted file mode 100644
index 051e70c..0000000
--- a/cmake/FindLTDL.cmake
+++ /dev/null
@@ -1,30 +0,0 @@
-# Find the native LTDL includes and library
-# Copied verbatim from
-# http://code.metager.de/source/xref/hshannover/trust/tnc-fhh/shared/cmake_modules/FindLTDL.cmake
-# The above version was under GPL-2, this one is under GPL-3, for consistency
-# with the rest of the colobot project.
-#
-# This module defines
-# LTDL_INCLUDE_DIR, where to find ltdl.h, etc.
-# LTDL_LIBRARY, where to find the LTDL library.
-# LTDL_FOUND, If false, do not try to use LTDL.
-
-FIND_PATH(LTDL_INCLUDE_DIR ltdl.h)
-
-FIND_LIBRARY(LTDL_LIBRARY ltdl)
-
-IF (LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
- SET(LTDL_FOUND TRUE)
-ELSE(LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
- SET(LTDL_FOUND FALSE)
-ENDIF (LTDL_INCLUDE_DIR AND LTDL_LIBRARY)
-
-IF (LTDL_FOUND)
- IF (NOT LTDL_FIND_QUIETLY)
- MESSAGE(STATUS "Found LTDL: ${LTDL_LIBRARY}")
- ENDIF (NOT LTDL_FIND_QUIETLY)
-ELSE (LTDL_FOUND)
- IF (LTDL_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find LTDL")
- ENDIF (LTDL_FIND_REQUIRED)
-ENDIF (LTDL_FOUND)
diff --git a/cmake/mxe.cmake b/cmake/mxe.cmake
index 4507a80..322ba4a 100644
--- a/cmake/mxe.cmake
+++ b/cmake/mxe.cmake
@@ -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)
diff --git a/debian/control b/debian/control
index d9ca58d..491dc35 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,6 @@ Build-Depends:
libsdl-image1.2-dev,
libsdl-ttf2.0-dev,
libpng12-dev (>= 1.2),
- libltdl-dev (>= 2.4.2),
libboost-dev,
libboost-system-dev,
libboost-filesystem-dev,
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index a347500..daf08c6 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -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 CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be50e94..3339b1a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,9 +27,24 @@ endif()
# Additional libraries per platform
set(PLATFORM_LIBS "")
+set(OPENAL_LIBS "")
+
+if (${OPENAL_SOUND})
+ if (${MXE})
+ set(OPENAL_LIBS
+ ${CMAKE_FIND_ROOT_PATH}/lib/libOpenAL32.a
+ ${CMAKE_FIND_ROOT_PATH}/lib/libalut.a
+ )
+ else()
+ set(OPENAL_LIBS
+ openal
+ alut
+ )
+ endif()
+endif()
if (${MXE}) # MXE requires special treatment
- set(PLATFORM_LIBS ${MXE_LIBS})
+ set(PLATFORM_LIBS ${MXE_LIBS})
elseif (${PLATFORM_WINDOWS})
# because it isn't included in standard linking libraries
set(PLATFORM_LIBS "-lintl")
@@ -42,6 +57,15 @@ endif()
# Configure file
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
+set(OPENAL_SRC "")
+
+if (${OPENAL_SOUND})
+ set(OPENAL_SRC
+ sound/oalsound/alsound.cpp
+ sound/oalsound/buffer.cpp
+ sound/oalsound/channel.cpp
+ )
+endif()
# Source files
set(SOURCES
@@ -160,10 +184,10 @@ ui/slider.cpp
ui/studio.cpp
ui/target.cpp
ui/window.cpp
-plugins/pluginmanager.cpp
-plugins/pluginloader.cpp
+${OPENAL_SRC}
)
+
set(LIBS
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
@@ -173,8 +197,8 @@ ${PNG_LIBRARIES}
${OPTIONAL_LIBS}
${PLATFORM_LIBS}
${Boost_LIBRARIES}
-${LTDL_LIBRARY}
CBot
+${OPENAL_LIBS}
)
include_directories(
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 3073d77..118e100 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -40,6 +40,11 @@
#include <unistd.h>
+#ifdef OPENAL_SOUND
+ #include "sound/oalsound/alsound.h"
+#endif
+
+
template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
//! Static buffer for putenv locale
@@ -89,7 +94,6 @@ CApplication::CApplication()
m_private = new ApplicationPrivate();
m_iMan = new CInstanceManager();
m_eventQueue = new CEventQueue(m_iMan);
- m_pluginManager = new CPluginManager();
m_profile = new CProfile();
m_engine = nullptr;
@@ -158,9 +162,6 @@ CApplication::~CApplication()
delete m_eventQueue;
m_eventQueue = nullptr;
- delete m_pluginManager;
- m_pluginManager = nullptr;
-
delete m_profile;
m_profile = nullptr;
@@ -315,7 +316,7 @@ bool CApplication::Create()
langStr += locale;
strcpy(S_LANGUAGE, langStr.c_str());
putenv(S_LANGUAGE);
- setlocale(LC_ALL, "");
+ setlocale(LC_ALL, locale.c_str());
GetLogger()->Debug("Set locale to '%s'\n", locale.c_str());
bindtextdomain("colobot", COLOBOT_I18N_DIR);
@@ -324,9 +325,6 @@ bool CApplication::Create()
GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!"));
- // Temporarily -- only in windowed mode
- m_deviceConfig.fullScreen = false;
-
//Create the sound instance.
if (!GetProfile().InitCurrentDirectory()) {
GetLogger()->Warn("Config not found. Default values will be used!\n");
@@ -336,13 +334,12 @@ bool CApplication::Create()
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
m_dataPath = path;
- m_pluginManager->LoadFromProfile();
- m_sound = static_cast<CSoundInterface*>(CInstanceManager::GetInstancePointer()->SearchInstance(CLASS_SOUND));
-
- if (!m_sound) {
- GetLogger()->Error("Sound not loaded, falling back to fake sound!\n");
- m_sound = new CSoundInterface();
- }
+ #ifdef OPENAL_SOUND
+ m_sound = static_cast<CSoundInterface *>(new ALSound());
+ #else
+ GetLogger()->Info("No sound support.\n");
+ m_sound = new CSoundInterface();
+ #endif
m_sound->Create(true);
if (GetProfile().GetLocalProfileString("Resources", "Sound", path))
@@ -383,7 +380,20 @@ bool CApplication::Create()
m_exitCode = 3;
return false;
}
-
+
+ // load settings from profile
+ int iValue;
+ if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) {
+ std::vector<Math::IntPoint> modes;
+ GetVideoResolutionList(modes, true, true);
+ if (static_cast<unsigned int>(iValue) < modes.size())
+ m_deviceConfig.size = modes.at(iValue);
+ }
+
+ if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) {
+ m_deviceConfig.fullScreen = (iValue == 1);
+ }
+
if (! CreateVideoSurface())
return false; // dialog is in function
@@ -403,8 +413,7 @@ bool CApplication::Create()
// Don't generate joystick events
SDL_JoystickEventState(SDL_IGNORE);
-
-
+
// The video is ready, we can create and initalize the graphics device
m_device = new Gfx::CGLDevice(m_deviceConfig);
if (! m_device->Create() )
diff --git a/src/app/app.h b/src/app/app.h
index 32f03f8..5bf6867 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -25,13 +25,12 @@
#include "common/global.h"
#include "common/singleton.h"
+#include "common/profile.h"
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
#include "graphics/opengl/gldevice.h"
-#include "plugins/pluginmanager.h"
-
#include <string>
#include <vector>
@@ -337,7 +336,6 @@ protected:
CSoundInterface* m_sound;
//! Main class of the proper game engine
CRobotMain* m_robotMain;
- CPluginManager* m_pluginManager;
CProfile* m_profile;
//! Code to return at exit
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 9b30720..dd280a3 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -10,3 +10,5 @@
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
+
+#cmakedefine OPENAL_SOUND
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 1da4587..d5805d0 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -3793,6 +3793,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
int rankObj = 0;
int rankGadget = 0;
CObject* sel = 0;
+ char *locale = setlocale(LC_NUMERIC, nullptr);
+ setlocale(LC_NUMERIC, "C");
while (fgets(line, 500, file) != NULL)
{
@@ -4526,6 +4528,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
m_dialog->SetSceneRead("");
m_dialog->SetStackRead("");
+
+ setlocale(LC_NUMERIC, locale);
}
//! Creates an object of decoration mobile or stationary
diff --git a/src/plugins/plugininterface.h b/src/plugins/plugininterface.h
deleted file mode 100644
index 838dbfd..0000000
--- a/src/plugins/plugininterface.h
+++ /dev/null
@@ -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; }
-};
-
diff --git a/src/plugins/pluginloader.cpp b/src/plugins/pluginloader.cpp
deleted file mode 100644
index bd0c8be..0000000
--- a/src/plugins/pluginloader.cpp
+++ /dev/null
@@ -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;
-}
diff --git a/src/plugins/pluginloader.h b/src/plugins/pluginloader.h
deleted file mode 100644
index e8c2c73..0000000
--- a/src/plugins/pluginloader.h
+++ /dev/null
@@ -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;
-};
diff --git a/src/plugins/pluginmanager.cpp b/src/plugins/pluginmanager.cpp
deleted file mode 100644
index f4dbcdb..0000000
--- a/src/plugins/pluginmanager.cpp
+++ /dev/null
@@ -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;
-}
diff --git a/src/plugins/pluginmanager.h b/src/plugins/pluginmanager.h
deleted file mode 100644
index 2798483..0000000
--- a/src/plugins/pluginmanager.h
+++ /dev/null
@@ -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;
-};
-
diff --git a/src/plugins/test/CMakeLists.txt b/src/plugins/test/CMakeLists.txt
deleted file mode 100644
index 31b4163..0000000
--- a/src/plugins/test/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -rdynamic")
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-add_executable(manager_test manager_test.cpp ../../common/logger.cpp ../../common/profile.cpp ../../common/iman.cpp ../pluginmanager.cpp ../pluginloader.cpp)
-
-include_directories(".")
-include_directories("../../")
-include_directories("../../../")
-
-target_link_libraries(manager_test ${LTDL_LIBRARY})
diff --git a/src/plugins/test/colobot.ini b/src/plugins/test/colobot.ini
deleted file mode 100644
index 08956be..0000000
--- a/src/plugins/test/colobot.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugins]
-Path=.
-File=libopenalsound.so
diff --git a/src/plugins/test/manager_test.cpp b/src/plugins/test/manager_test.cpp
deleted file mode 100644
index d921c1d..0000000
--- a/src/plugins/test/manager_test.cpp
+++ /dev/null
@@ -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;
-}
diff --git a/src/sound/plugins/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 83a4def..0201417 100644
--- a/src/sound/plugins/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -23,51 +23,23 @@
#define MIN(a, b) (a > b ? b : a)
-
-PLUGIN_INTERFACE(ALSound)
-
-
-std::string ALSound::PluginName()
-{
- return "Sound plugin using OpenAL library to play sounds.";
-}
-
-
-int ALSound::PluginVersion()
-{
- return 2;
-}
-
-
-void ALSound::InstallPlugin()
-{
- auto pointer = CInstanceManager::GetInstancePointer();
- if (pointer != nullptr)
- CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
-}
-
-
-bool ALSound::UninstallPlugin(std::string &reason)
-{
- auto pointer = CInstanceManager::GetInstancePointer();
- if (pointer != nullptr)
- CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
- CleanUp();
- return true;
-}
-
-
ALSound::ALSound()
{
mEnabled = false;
m3D = false;
mAudioVolume = MAXVOLUME;
mMute = false;
+ auto pointer = CInstanceManager::GetInstancePointer();
+ if (pointer != nullptr)
+ CInstanceManager::GetInstancePointer()->AddInstance(CLASS_SOUND, this);
}
ALSound::~ALSound()
{
+ auto pointer = CInstanceManager::GetInstancePointer();
+ if (pointer != nullptr)
+ CInstanceManager::GetInstancePointer()->DeleteInstance(CLASS_SOUND, this);
CleanUp();
}
@@ -114,14 +86,14 @@ void ALSound::SetSound3D(bool bMode)
}
-bool ALSound::RetSound3D()
+bool ALSound::GetSound3D()
{
// TODO stub! need to be implemented
return true;
}
-bool ALSound::RetSound3DCap()
+bool ALSound::GetSound3DCap()
{
// TODO stub! need to be implemented
return true;
@@ -141,7 +113,7 @@ void ALSound::SetAudioVolume(int volume)
}
-int ALSound::RetAudioVolume()
+int ALSound::GetAudioVolume()
{
float volume;
if ( !mEnabled )
@@ -158,7 +130,7 @@ void ALSound::SetMusicVolume(int volume)
}
-int ALSound::RetMusicVolume()
+int ALSound::GetMusicVolume()
{
// TODO stub! Add music support
if ( !mEnabled )
@@ -179,7 +151,7 @@ bool ALSound::Cache(Sound sound, std::string filename)
}
-int ALSound::RetPriority(Sound sound)
+int ALSound::GetPriority(Sound sound)
{
if ( sound == SOUND_FLYh ||
sound == SOUND_FLY ||
@@ -230,7 +202,7 @@ int ALSound::RetPriority(Sound sound)
bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
{
- int priority = RetPriority(sound);
+ int priority = GetPriority(sound);
// Seeks a channel used which sound is stopped.
for (auto it : mChannels) {
@@ -287,7 +259,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
int lowerOrEqual = -1;
for (auto it : mChannels) {
if (it.second->GetPriority() < priority) {
- GetLogger()->Info("Sound channel with lower priority will be reused.");
+ GetLogger()->Debug("Sound channel with lower priority will be reused.");
channel = it.first;
return true;
}
@@ -297,7 +269,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
if (lowerOrEqual != -1) {
channel = lowerOrEqual;
- GetLogger()->Info("Sound channel with lower or equal priority will be reused.");
+ GetLogger()->Debug("Sound channel with lower or equal priority will be reused.");
return true;
}
@@ -485,11 +457,11 @@ void ALSound::FrameMove(float delta)
if (it.second->GetEnvelope().totalTime <= it.second->GetCurrentTime()) {
if (oper.nextOper == SOPER_LOOP) {
- GetLogger()->Info("Replay.\n");
+ GetLogger()->Trace("Sound oper: replay.\n");
it.second->SetCurrentTime(0.0f);
it.second->Play();
} else {
- GetLogger()->Info("Next.\n");
+ GetLogger()->Trace("Sound oper: next.\n");
it.second->SetStartAmplitude(oper.finalAmplitude);
it.second->SetStartFrequency(oper.finalFrequency);
it.second->PopEnvelope();
diff --git a/src/sound/plugins/oalsound/alsound.h b/src/sound/oalsound/alsound.h
index a1128e0..7d24ba6 100644
--- a/src/sound/plugins/oalsound/alsound.h
+++ b/src/sound/oalsound/alsound.h
@@ -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;
diff --git a/src/sound/plugins/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp
index 37211e9..dbfdca2 100644
--- a/src/sound/plugins/oalsound/buffer.cpp
+++ b/src/sound/oalsound/buffer.cpp
@@ -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;
diff --git a/src/sound/plugins/oalsound/buffer.h b/src/sound/oalsound/buffer.h
index 8c4a2d3..8c4a2d3 100644
--- a/src/sound/plugins/oalsound/buffer.h
+++ b/src/sound/oalsound/buffer.h
diff --git a/src/sound/plugins/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp
index 4476dee..2285414 100644
--- a/src/sound/plugins/oalsound/channel.cpp
+++ b/src/sound/oalsound/channel.cpp
@@ -227,7 +227,7 @@ void Channel::AdjustFrequency(float freq) {
void Channel::AdjustVolume(float volume) {
- SetVolume(mStartAmplitude * (float) volume);
+ SetVolume(mStartAmplitude * volume);
}
diff --git a/src/sound/plugins/oalsound/channel.h b/src/sound/oalsound/channel.h
index 165ff50..165ff50 100644
--- a/src/sound/plugins/oalsound/channel.h
+++ b/src/sound/oalsound/channel.h
diff --git a/src/sound/plugins/oalsound/check.h b/src/sound/oalsound/check.h
index cf3e468..cf3e468 100644
--- a/src/sound/plugins/oalsound/check.h
+++ b/src/sound/oalsound/check.h
diff --git a/src/sound/plugins/oalsound/CMakeLists.txt b/src/sound/plugins/oalsound/CMakeLists.txt
deleted file mode 100644
index bb7e9ff..0000000
--- a/src/sound/plugins/oalsound/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-set(SOURCES
- alsound.cpp
- buffer.cpp
- channel.cpp
-)
-
-SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++0x -fPIC")
-SET (CMAKE_CXX_FLAGS_DEBUG "-g")
-
-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})
diff --git a/src/sound/plugins/oalsound/test/CMakeLists.txt b/src/sound/plugins/oalsound/test/CMakeLists.txt
deleted file mode 100644
index dd208ea..0000000
--- a/src/sound/plugins/oalsound/test/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -rdynamic")
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-add_executable(plugin_test plugin_test.cpp ../../../../common/iman.cpp ../../../../common/logger.cpp ../../../../plugins/pluginloader.cpp)
-
-include_directories(".")
-include_directories("../../../../")
-
-target_link_libraries(plugin_test ${LTDL_LIBRARY})
diff --git a/src/sound/plugins/oalsound/test/plugin_test.cpp b/src/sound/plugins/oalsound/test/plugin_test.cpp
deleted file mode 100644
index 40c1cd2..0000000
--- a/src/sound/plugins/oalsound/test/plugin_test.cpp
+++ /dev/null
@@ -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;
-}
diff --git a/src/sound/sound.h b/src/sound/sound.h
index c2b890f..566f415 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -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() {
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 5136a41..ebf7d10 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -1164,43 +1164,22 @@ pb->SetState(STATE_SHADOW);
if ( m_phase == PHASE_SETUPd || // setup/display ?
m_phase == PHASE_SETUPds )
{
-
-// TODO: device settings
-#if 0
-
pos.x = ox+sx*3;
pos.y = oy+sy*9;
ddim.x = dim.x*6;
ddim.y = dim.y*1;
- GetResource(RES_TEXT, RT_SETUP_DEVICE, name);
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
- pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
-
- pos.x = ox+sx*3;
- pos.y = oy+sy*5.2f;
- ddim.x = dim.x*6;
- ddim.y = dim.y*4.5f;
- pli = pw->CreateList(pos, ddim, 0, EVENT_LIST1);
- pli->SetState(STATE_SHADOW);
- UpdateDisplayDevice();
-
- pos.x = ox+sx*10;
- pos.y = oy+sy*9;
- ddim.x = dim.x*6;
- ddim.y = dim.y*1;
GetResource(RES_TEXT, RT_SETUP_MODE, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
m_setupFull = m_app->GetVideoConfig().fullScreen;
- pos.x = ox+sx*10;
+ pos.x = ox+sx*3;
pos.y = oy+sy*5.2f;
ddim.x = dim.x*6;
ddim.y = dim.y*4.5f;
pli = pw->CreateList(pos, ddim, 0, EVENT_LIST2);
pli->SetState(STATE_SHADOW);
UpdateDisplayMode();
- pli->SetState(STATE_ENABLE, m_setupFull);
ddim.x = dim.x*4;
ddim.y = dim.y*0.5f;
@@ -1209,7 +1188,6 @@ pb->SetState(STATE_SHADOW);
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_FULL);
pc->SetState(STATE_SHADOW);
pc->SetState(STATE_CHECK, m_setupFull);
-#endif
ddim.x = dim.x*6;
ddim.y = dim.y*1;
@@ -2610,19 +2588,16 @@ bool CMainDialog::EventProcess(const Event &event)
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
- if ( pc == 0 ) break;
- pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
- if ( pl == 0 ) break;
- if ( pc->TestState(STATE_CHECK) )
- {
- pc->ClearState(STATE_CHECK); // window
- pl->ClearState(STATE_ENABLE);
- }
- else
- {
- pc->SetState(STATE_CHECK); // fullscreen
- pl->SetState(STATE_ENABLE);
- }
+ if ( pc == 0 ) break;
+
+ if ( pc->TestState(STATE_CHECK) ) {
+ m_setupFull = false;
+ pc->ClearState(STATE_CHECK);
+ } else {
+ m_setupFull = true;
+ pc->SetState(STATE_CHECK);
+ }
+
UpdateApply();
break;
@@ -2633,7 +2608,8 @@ bool CMainDialog::EventProcess(const Event &event)
if ( pb == 0 ) break;
pb->ClearState(STATE_PRESS);
pb->ClearState(STATE_HILIGHT);
- ChangeDisplay();
+ // TODO: uncomment when changing display is implemented
+ //ChangeDisplay();
UpdateApply();
break;
@@ -2909,12 +2885,12 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_SILENT:
m_sound->SetAudioVolume(0);
- //TODO: m_sound->SetMidiVolume(0);
+ m_sound->SetMusicVolume(0);
UpdateSetupButtons();
break;
case EVENT_INTERFACE_NOISY:
m_sound->SetAudioVolume(MAXVOLUME);
- //TODO: m_sound->SetMidiVolume(MAXVOLUME*3/4);
+ m_sound->SetMusicVolume(MAXVOLUME*3/4);
UpdateSetupButtons();
break;
@@ -5076,9 +5052,6 @@ void CMainDialog::UpdateDisplayMode()
{
CWindow* pw;
CList* pl;
- char bufDevices[1000];
- char bufModes[5000];
- int i, j, totalDevices, selectDevices, totalModes, selectModes;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
@@ -5086,25 +5059,18 @@ void CMainDialog::UpdateDisplayMode()
if ( pl == 0 ) return;
pl->Flush();
- bufModes[0] = 0;
- /* TODO: remove device choice
- m_engine->EnumDevices(bufDevices, 1000,
- bufModes, 5000,
- totalDevices, selectDevices,
- totalModes, selectModes);*/
-
- i = 0;
- j = 0;
- while ( bufModes[i] != 0 )
- {
- pl->SetName(j++, bufModes+i);
- while ( bufModes[i++] != 0 );
+ std::vector<Math::IntPoint> modes;
+ m_app->GetVideoResolutionList(modes, true, true);
+ int i = 0;
+ std::stringstream mode_text;
+ for (Math::IntPoint mode : modes) {
+ mode_text.str("");
+ mode_text << mode.x << "x" << mode.y;
+ pl->SetName(i++, mode_text.str().c_str());
}
- pl->SetSelect(selectModes);
+ pl->SetSelect(m_setupSelMode);
pl->ShowSelect(false);
-
- m_setupSelMode = selectModes;
}
// Change the graphics mode.
@@ -5392,9 +5358,8 @@ void CMainDialog::UpdateSetupButtons()
ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
- /* TODO: midi volume
- value = (float)m_sound->GetMidiVolume();
- ps->SetVisibleValue(value);*/
+ value = static_cast<float>(m_sound->GetMusicVolume());
+ ps->SetVisibleValue(value);
}
pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOUND3D));
@@ -5474,10 +5439,6 @@ void CMainDialog::ChangeSetupButtons()
void CMainDialog::SetupMemorize()
{
- float fValue;
- int iValue, i, j;
- char num[10];
-
GetProfile().SetLocalProfileString("Directory", "scene", m_sceneDir);
GetProfile().SetLocalProfileString("Directory", "savegame", m_savegameDir);
GetProfile().SetLocalProfileString("Directory", "public", m_publicDir);
@@ -5508,15 +5469,27 @@ void CMainDialog::SetupMemorize()
GetProfile().SetLocalProfileInt("Setup", "TextureQuality", m_engine->GetTextureQuality());
GetProfile().SetLocalProfileInt("Setup", "TotoMode", m_engine->GetTotoMode());
GetProfile().SetLocalProfileInt("Setup", "AudioVolume", m_sound->GetAudioVolume());
+ GetProfile().SetLocalProfileInt("Setup", "MusicVolume", m_sound->GetMusicVolume());
GetProfile().SetLocalProfileInt("Setup", "Sound3D", m_sound->GetSound3D());
GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode());
GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue());
-
-
- // GetProfile()->SetLocalProfileInt("Setup", "NiceMouse", m_engine->GetNiceMouse());
- // GetProfile()->SetLocalProfileInt("Setup", "UseJoystick", m_engine->GetJoystick());
- // GetProfile()->SetLocalProfileInt("Setup", "MidiVolume", m_sound->GetMidiVolume());
-
+
+ /* screen setup */
+ if (m_setupFull)
+ GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1);
+ else
+ GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0);
+
+ CList *pl;
+ CWindow *pw;
+ pw = static_cast<CWindow *>(m_interface->SearchControl(EVENT_WINDOW5));
+ if ( pw != 0 ) {
+ pl = static_cast<CList *>(pw->SearchControl(EVENT_LIST2));
+ if ( pl != 0 ) {
+ GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect());
+ }
+ }
+
std::stringstream key;
for (int i = 0; i < INPUT_SLOT_MAX; i++)
{
@@ -5724,11 +5697,10 @@ void CMainDialog::SetupRecall()
m_sound->SetAudioVolume(iValue);
}
- // TODO
- // if ( GetLocalProfileInt("Setup", "MidiVolume", iValue) )
- // {
- // m_sound->SetMidiVolume(iValue);
- // }
+ if ( GetProfile().GetLocalProfileInt("Setup", "MusicVolume", iValue) )
+ {
+ m_sound->SetMusicVolume(iValue);
+ }
if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) )
{
@@ -5772,6 +5744,14 @@ void CMainDialog::SetupRecall()
{
m_bDeleteGamer = iValue;
}
+
+ if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) ) {
+ m_setupSelMode = iValue;
+ }
+
+ if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) ) {
+ m_setupFull = (iValue == 1);
+ }
}