1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 09:06:43 +00:00

Merge branch 'next' into terrain

Conflicts:
	CMakeLists.txt
	apps/openmw/CMakeLists.txt
This commit is contained in:
scrawl 2012-03-22 22:31:49 +01:00
commit 9076401892
441 changed files with 3718 additions and 50722 deletions

View file

@ -18,7 +18,7 @@ include (OpenMWMacros)
# Version # Version
set (OPENMW_VERSION_MAJOR 0) set (OPENMW_VERSION_MAJOR 0)
set (OPENMW_VERSION_MINOR 12) set (OPENMW_VERSION_MINOR 13)
set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION_RELEASE 0)
set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
@ -27,6 +27,8 @@ set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VE
configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp")
option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE)
# Sound source selection # Sound source selection
option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_AUDIERE "use Audiere for sound" OFF)
option(USE_FFMPEG "use ffmpeg for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF)
@ -175,7 +177,6 @@ include_directories(${UUID_INCLUDE_DIR})
endif (WIN32) endif (WIN32)
if (MSVC10) if (MSVC10)
set(PLATFORM_INCLUDE_DIR "") set(PLATFORM_INCLUDE_DIR "")
add_definitions(-DMYGUI_DONT_REPLACE_NULLPTR)
endif() endif()
if (APPLE) if (APPLE)
@ -184,24 +185,38 @@ endif (APPLE)
# Dependencies # Dependencies
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
find_package (Threads)
endif()
find_package(OGRE REQUIRED) find_package(OGRE REQUIRED)
find_package(MyGUI REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
find_package(OIS REQUIRED) find_package(OIS REQUIRED)
find_package(OpenAL REQUIRED) find_package(OpenAL REQUIRED)
find_package(Bullet REQUIRED) find_package(Bullet REQUIRED)
IF(OGRE_STATIC)
find_package(Cg REQUIRED)
IF(WIN32)
set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_Direct3D9_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS})
ELSE(WIN32)
set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS})
ENDIF(WIN32)
ENDIF(OGRE_STATIC)
include_directories("." include_directories("."
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_PLUGIN_INCLUDE_DIRS}
${OGRE_Terrain_INCLUDE_DIR} ${OGRE_Terrain_INCLUDE_DIR}
${OIS_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ${OIS_INCLUDE_DIRS} ${Boost_INCLUDE_DIR}
${PLATFORM_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR}
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include ${MYGUI_INCLUDE_DIRS}
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include ${MYGUI_PLATFORM_INCLUDE_DIRS}
${OPENAL_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR}
${UUID_INCLUDE_DIR} ${UUID_INCLUDE_DIR}
${LIBDIR} ${LIBDIR}
) )
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR}) link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR})
if(APPLE) if(APPLE)
# List used Ogre plugins # List used Ogre plugins
@ -211,14 +226,7 @@ if(APPLE)
"Plugin_ParticleFX") "Plugin_ParticleFX")
endif(APPLE) endif(APPLE)
add_subdirectory( extern/mygui_3.0.1 ) add_subdirectory( files/mygui )
# Make sure that certain libraries are used as static libraries
# This is in effect turns off __declspec (dllexport) for windows
# Each library will also need to be configured to build as a static lib
# MyGUI: extern/mygui_3.0.0/
add_definitions(-DMYGUI_STATIC)
# Specify build paths # Specify build paths
@ -256,14 +264,8 @@ if (APPLE)
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY) "${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
# prepare plugins # prepare plugins
if (${CMAKE_BUILD_TYPE} MATCHES "Release") if (${CMAKE_BUILD_TYPE} MATCHES "Release" OR
set(OPENMW_RELEASE_BUILD 1) ${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo")
endif()
if (${CMAKE_BUILD_TYPE} MATCHES "RelWithDebugInfo")
set(OPENMW_RELEASE_BUILD 1)
endif()
if (${OPENMW_RELEASE_BUILD})
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL}) set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
else() else()
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG}) set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
@ -279,8 +281,7 @@ endif (APPLE)
# Compiler settings # Compiler settings
if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_COMPILER_IS_GNUCC)
#add_definitions (-Wall -Werror) add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-reorder)
add_definitions (-Wall)
endif (CMAKE_COMPILER_IS_GNUCC) endif (CMAKE_COMPILER_IS_GNUCC)
if(DPKG_PROGRAM) if(DPKG_PROGRAM)
@ -320,7 +321,7 @@ if(DPKG_PROGRAM)
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw") SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}") SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher") SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogre-1.7.3 (>= 1.7.3), libbullet0 (>= 2.77), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)") SET(CPACK_DEBIAN_PACKAGE_DEPENDS "nvidia-cg-toolkit (>= 2.1), libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)")
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games") SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
@ -419,6 +420,47 @@ if (WIN32)
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE") set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE") set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE") set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
# Play a bit with the warning levels
set(WARNINGS "/Wall") # Since windows can only disable specific warnings, not enable them
set(WARNINGS_DISABLE
# Warnings that aren't enabled normally and don't need to be enabled
# They're unneeded and sometimes completely retarded warnings that /Wall enables
# Not going to bother commenting them as they tend to warn on every standard library files
4061 4263 4264 4266 4350 4514 4548 4571 4610 4619 4623 4625 4626 4628 4640 4668 4710 4711 4820 4826 4917 4946
# Warnings that are thrown on standard libraries and not OpenMW
4347 # Non-template function with same name and parameter count as template function
4365 # Variable signed/unsigned mismatch
4510 4512 # Unable to generate copy constructor/assignment operator as it's not public in the base
4706 # Assignment in conditional expression
4738 # Storing 32-bit float result in memory, possible loss of performance
4986 # Undocumented warning that occurs in the crtdbg.h file
4996 # Function was declared deprecated
# OpenMW specific warnings
4099 # Type mismatch, declared class or struct is defined with other type
4100 # Unreferenced formal parameter (-Wunused-parameter)
4127 # Conditional expression is constant
4242 # Storing value in a variable of a smaller type, possible loss of data
4244 # Storing value of one type in variable of another (size_t in int, for example)
4305 # Truncating value (double to float, for example)
4309 # Variable overflow, trying to store 128 in a signed char for example
4355 # Using 'this' in member initialization list
4701 # Potentially uninitialized local variable used
)
foreach(d ${WARNINGS_DISABLE})
set(WARNINGS "${WARNINGS} /wd${d}")
endforeach(d)
set_target_properties(components PROPERTIES COMPILE_FLAGS ${WARNINGS})
if (BUILD_LAUNCHER)
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif (BUILD_LAUNCHER)
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
endif(MSVC) endif(MSVC)
# Same for MinGW # Same for MinGW

View file

@ -1,80 +1,79 @@
NOTE: This README is for ardekantur's Mac branch of OpenMW. A README #Getting OpenMW Working on OS X
for the main branch has yet to be written. If you want to submit one,
please send me a message!
OpenMW ## Initial setup
====== First of all, clone OpenMW repo.
From the [official website][]: $ git clone github.com/zinnschlag/openmw
> OpenMW is an attempt to reimplement the popular role playing game Or use your github url if you forked.
Morrowind. It aims to be a fully playable, open source
implementation of the game. You must own Morrowind to use OpenMW.
About dependencies: I prefer not to install them globally (i. e. in /usr/local/), so I'm installing them in directory in my home directory. If OpenMW sources is in $HOME/path/openmw, I'm using $HOME/path/libs/root as prefix for boost and other libs.
About This Project It's useful to create env var for lib install prefix:
------------------
$ export OMW_LIB_PREFIX=$HOME/path/libs/root`
This specific repository is a branch of OpenMW intended to keep pace Most of libs can be installed from [Homebrew][homebrew]. Only mpg123 needs to be installed from source (due to lack of universal compilation support). I think that some of libs can be installed from MacPorts or Fink too.
with development of the project in order to provide a Mac build for
interested parties to contribute. This is not an official, sanctioned
branch of the OpenMW project. I will only be able to answer specific
questions about getting this project running on Mac OS X, **no other
platform**. I will not even be able to guarantee my changes maintain
backwards compatibility against builds in other operating systems. You
have been warned.
As OpenMW currently only supports i386 architecture on OS X, denendencies also should support it. Set some env vars in current terminal:
Getting OpenMW Working
----------------------
1. Clone this repository.
2. Note about libs: I prefer not to install them globally (i. e. in /usr/local/), so I installing them in directory in my home directory. If OpenMW sources is in $HOME/path/openmw, I'm using $HOME/path/libs/root as prefix for boost and other libs.
It's useful to create env var for lib install prefix:
$ export OMW_LIB_PREFIX=$HOME/path/libs/root
3. First of all, set for current terminal some env vars:
$ export CFLAGS="-arch i386" $ export CFLAGS="-arch i386"
$ export CXXFLAGS="-arch i386" $ export CXXFLAGS="-arch i386"
$ export LDFLAGS="-arch i386" $ export LDFLAGS="-arch i386"
All libs will build with correct architecture.
If you close your terminal, you should set env vars again before pcoceeding to next steps!
4. Download [boost][] (tested with 1.45) and install it with the following command: If you close your terminal, you should set env vars again before pcoceeding to next steps!
## Boost
Download [boost][boost] and install it with the following command:
$ cd /path/to/boost/source $ cd /path/to/boost/source
$ ./bootstrap.sh --prefix=$OMW_LIB_PREFIX $ ./bootstrap.sh --prefix=$OMW_LIB_PREFIX
$ ./bjam --build-dir=build --layout=versioned \ $ ./bjam --build-dir=build --layout=versioned \
--toolset=darwin architecture=x86 address-model=32 \ --toolset=darwin architecture=x86 address-model=32 \
--link-shared,static --prefix=$OMW_LIB_PREFIX install --link-shared,static --prefix=$OMW_LIB_PREFIX install
Alternatively you can install boost with homebrew:
$ brew install boost --universal
5. Download [Ogre][] SDK (tested with 1.7.2), unpack it and move I think MacPorts also should support universal build for boost.
`lib/Release/Ogre.framework` into `Library/Frameworks`.
6. Download [OIS][] and use the XCode project provided in ## Ogre
`ois/Mac/XCode-2.2`. Be sure to set your build architecture to Download [Ogre][] SDK (tested with 1.7.3), unpack it somewhere and move
`i386` and your SDK platform to either 10.5 or 10.6. Once it `lib/Release/Ogre.framework` into `/Library/Frameworks`.
builds, move `ois/Mac/XCode-2.2/build/Debug/OIS.framework` to
`/Library/Frameworks`. ## OIS
Download patched [OIS][] and use the XCode project provided. Be sure to set your build architecture to
`i386`. Once it built, locate built OIS.framework with Xcode and move it to `/Library/Frameworks`.
## mpg123
Download [MPG 123][mpg123] and build it:
7. Download [mpg123][] and build it:
$ cd /path/to/mpg123/source $ cd /path/to/mpg123/source
$ ./configure --prefix=$OMW_LIB_PREFIX --disable-debug \ $ ./configure --prefix=$OMW_LIB_PREFIX --disable-debug \
--disable-dependency-tracking \ --disable-dependency-tracking \
--with-optimization=4 \ --with-optimization=4 \
--with-audio=coreaudio \ --with-audio=dummy \
--with-default-audio=coreaudio \ --with-default-audio=dummy \
--with-cpu=sse_alone \ --with-cpu=sse_alone \
$ make install $ make install
8. Download [libsndfile][] and build it: ## libsndfile
Download [libsndfile][] and build it:
$ cd /path/to/libsndfile/source $ cd /path/to/libsndfile/source
$ ./configure --prefix=$OMW_LIB_PREFIX \ $ ./configure --prefix=$OMW_LIB_PREFIX \
--disable-dependency-tracking --disable-dependency-tracking
$ make install $ make install
9. Download [Bullet][] and build it: or install with homebrew:
$ brew install libsndfile --universal
## Bullet
Download [Bullet][] and build it:
$ cd /path/to/bullet/source $ cd /path/to/bullet/source
$ mkdir build $ mkdir build
$ cd build $ cd build
@ -87,12 +86,25 @@ Getting OpenMW Working
-G"Unix Makefiles" ../ -G"Unix Makefiles" ../
$ make install $ make install
10. Generate the Makefile for OpenMW as follows and build OpenMW: or install with homebrew:
$ brew install bullet --HEAD --universal
I prefer head because 2.79 has some issue which causes OpenMW to lag. Also you can edit formula and install 2.77, which is stable and haven't mentioned issue.
## Qt
Install [Qt][qt]. Qt SDK distributed by Nokia is not an option because it's 64 bit only, and OpenMW currently doesn't build for 64 bit on OS X. I'm installing it from Homebrew:
$ brew install qt --universal
## Run CMake
Generate the Makefile for OpenMW as follows and build OpenMW:
$ mkdir /path/to/openmw/build/dir $ mkdir /path/to/openmw/build/dir
$ cd /path/to/open/build/dir $ cd /path/to/open/build/dir
$ cmake \ $ cmake \
-D CMAKE_OSX_ARCHITECTURES=i386 \ -D CMAKE_OSX_ARCHITECTURES=i386 \
-D OGRESDK=/path/to/ogre/sdk \ -D OGRE_SDK=/path/to/ogre/sdk \
-D BOOST_INCLUDEDIR=$OMW_LIB_PREFIX/include/boost-1_45 \ -D BOOST_INCLUDEDIR=$OMW_LIB_PREFIX/include/boost-1_45 \
-D BOOST_LIBRARYDIR=$OMW_LIB_PREFIX/lib \ -D BOOST_LIBRARYDIR=$OMW_LIB_PREFIX/lib \
-D SNDFILE_INCLUDE_DIR=$OMW_LIB_PREFIX/include \ -D SNDFILE_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
@ -106,27 +118,43 @@ Getting OpenMW Working
-D BULLET_INCLUDE_DIR=$OMW_LIB_PREFIX/include/bullet/ \ -D BULLET_INCLUDE_DIR=$OMW_LIB_PREFIX/include/bullet/ \
-G "Unix Makefiles" /path/to/openmw/source/dir -G "Unix Makefiles" /path/to/openmw/source/dir
$ make $ make
You can use -G"Xcode" if you prefer Xcode, or -G"Eclipse CDT4 - Unix Makefiles"
if you prefer Eclipse. You also can specify -D CMAKE_BUILD_TYPE=Debug for debug You can use `-G"Xcode"` if you prefer Xcode, or -G"Eclipse CDT4 - Unix Makefiles"
build. if you prefer Eclipse. You also can specify `-D CMAKE_BUILD_TYPE=Debug` for debug
build. As for CMake 2.8.7 and Xcode 4.3, Xcode generator is broken. Sadly Eclipse CDT also cannot import generated project at least on my machine.
11. Copy your Morrowind `Data Files` directory into the OpenMW build dir If all libs installed via homebrew (excluding mpg123), then command would be even simplier:
with the name `data` or create symlink:
$ ln -s /path/to/morrowind/data/files /path/to/openmw/build/dir/data $ cmake \
-D CMAKE_OSX_ARCHITECTURES="i386" \
-D OGRE_SDK=/path/to/ogre/sdk \
-D MPG123_LIBRARY=$OMW_LIB_PREFIX/lib/libmpg123.a \
-D MPG123_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
-G "Unix Makefiles" /path/to/openmw/source/dir
$ make
Note for users with recent Xcode versions: you must explicitly specify what set of compilers do you use! If not, gcc will be used for C and Clang for C++. Just add this two -D's to command: `-D CMAKE_C_COMPILER=/usr/bin/clang` and `-D CMAKE_CXX_COMPILER=/usr/bin/clang`
Note for Xcode 4.3 users: you should specify full path to used SDK, because current CMake (2.8.7) couldn't find SDKs inside Xcode app bundle:
-D CMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"
# Run
From your build directory run:
12. From your build directory run:
$ OpenMW.app/Contents/MacOS/openmw $ OpenMW.app/Contents/MacOS/openmw
or: or:
$ open OpenMW.app $ open OpenMW.app
Enjoy! Enjoy!
[homebrew]: https://github.com/mxcl/homebrew
[boost]: http://www.boost.org [boost]: http://www.boost.org
[Ogre]: http://www.ogre3d.org [Ogre]: http://www.ogre3d.org
[Bullet]: http://bulletphysics.org [Bullet]: http://bulletphysics.org
[OIS]: http://wgois.sf.net [OIS]: https://github.com/corristo/ois-fork
[mpg123]: http://www.mpg123.de [mpg123]: http://www.mpg123.de
[libsndfile]: http://www.mega-nerd.com/libsndfile [libsndfile]: http://www.mega-nerd.com/libsndfile
[official website]: http://openmw.com [official website]: http://openmw.com
[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/ [Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/
[qt]: http://qt.nokia.com/

View file

@ -53,6 +53,15 @@ QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
include(${QT_USE_FILE}) include(${QT_USE_FILE})
# Main executable # Main executable
IF(OGRE_STATIC)
IF(WIN32)
ADD_DEFINITIONS(-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL)
set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES})
ELSE(WIN32)
ADD_DEFINITIONS(-DENABLE_PLUGIN_GL)
set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_GL_LIBRARIES})
ENDIF(WIN32)
ENDIF(OGRE_STATIC)
add_executable(omwlauncher add_executable(omwlauncher
${GUI_TYPE} ${GUI_TYPE}
${LAUNCHER} ${LAUNCHER}
@ -63,6 +72,7 @@ add_executable(omwlauncher
target_link_libraries(omwlauncher target_link_libraries(omwlauncher
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${OGRE_LIBRARIES} ${OGRE_LIBRARIES}
${OGRE_STATIC_PLUGINS}
${QT_LIBRARIES} ${QT_LIBRARIES}
components components
) )

View file

@ -222,7 +222,7 @@ void DataFilesPage::setupDataFiles()
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle("Error detecting Morrowind installation"); msgBox.setWindowTitle("Error detecting Morrowind installation");
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Warning);
msgBox.setStandardButtons(QMessageBox::Cancel); msgBox.setStandardButtons(QMessageBox::Cancel);
msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \ msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \
The directory containing the Data Files was not found.<br><br> \ The directory containing the Data Files was not found.<br><br> \
@ -279,72 +279,79 @@ void DataFilesPage::setupDataFiles()
const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp"); const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp");
for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) { for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) {
ESMReader fileReader;
QStringList availableMasters; // Will contain all found masters
fileReader.setEncoding(variables["encoding"].as<std::string>()); try {
fileReader.open(iter->second.string()); ESMReader fileReader;
QStringList availableMasters; // Will contain all found masters
// First we fill the availableMasters and the mMastersWidget fileReader.setEncoding(variables["encoding"].as<std::string>());
ESMReader::MasterList mlist = fileReader.getMasters(); fileReader.open(iter->second.string());
for (unsigned int i = 0; i < mlist.size(); ++i) { // First we fill the availableMasters and the mMastersWidget
const QString currentMaster = QString::fromStdString(mlist[i].name); ESMReader::MasterList mlist = fileReader.getMasters();
availableMasters.append(currentMaster);
const QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); for (unsigned int i = 0; i < mlist.size(); ++i) {
const QString currentMaster = QString::fromStdString(mlist[i].name);
availableMasters.append(currentMaster);
if (itemList.isEmpty()) { // Master is not yet in the widget const QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly);
mMastersWidget->insertRow(i);
QTableWidgetItem *item = new QTableWidgetItem(currentMaster); if (itemList.isEmpty()) { // Master is not yet in the widget
item->setForeground(Qt::red); mMastersWidget->insertRow(i);
item->setFlags(item->flags() & ~(Qt::ItemIsSelectable));
mMastersWidget->setItem(i, 0, item); QTableWidgetItem *item = new QTableWidgetItem(currentMaster);
item->setForeground(Qt::red);
item->setFlags(item->flags() & ~(Qt::ItemIsSelectable));
mMastersWidget->setItem(i, 0, item);
}
} }
}
availableMasters.sort(); // Sort the masters alphabetically availableMasters.sort(); // Sort the masters alphabetically
// Now we put the current plugin in the mDataFilesModel under its masters // Now we put the current plugin in the mDataFilesModel under its masters
QStandardItem *parent = new QStandardItem(availableMasters.join(",")); QStandardItem *parent = new QStandardItem(availableMasters.join(","));
QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string());
QStandardItem *child = new QStandardItem(fileName); QStandardItem *child = new QStandardItem(fileName);
// Tooltip information // Tooltip information
QString author = QString::fromStdString(fileReader.getAuthor()); QString author = QString::fromStdString(fileReader.getAuthor());
float version = fileReader.getFVer(); float version = fileReader.getFVer();
QString description = QString::fromStdString(fileReader.getDesc()); QString description = QString::fromStdString(fileReader.getDesc());
// For the date created/modified // For the date created/modified
QFileInfo fi(QString::fromStdString(iter->second.string())); QFileInfo fi(QString::fromStdString(iter->second.string()));
QString toolTip= QString("<b>Author:</b> %1<br/> \ QString toolTip= QString("<b>Author:</b> %1<br/> \
<b>Version:</b> %2<br/><br/> \ <b>Version:</b> %2<br/><br/> \
<b>Description:</b><br/> \ <b>Description:</b><br/> \
%3<br/><br/> \ %3<br/><br/> \
<b>Created on:</b> %4<br/> \ <b>Created on:</b> %4<br/> \
<b>Last modified:</b> %5") <b>Last modified:</b> %5")
.arg(author) .arg(author)
.arg(version) .arg(version)
.arg(description) .arg(description)
.arg(fi.created().toString(Qt::TextDate)) .arg(fi.created().toString(Qt::TextDate))
.arg(fi.lastModified().toString(Qt::TextDate)); .arg(fi.lastModified().toString(Qt::TextDate));
child->setToolTip(toolTip); child->setToolTip(toolTip);
const QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(",")); const QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(","));
if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel
parent->appendRow(child); parent->appendRow(child);
mDataFilesModel->appendRow(parent); mDataFilesModel->appendRow(parent);
} else { } else {
// Masters node exists, append current plugin // Masters node exists, append current plugin
foreach (QStandardItem *currentItem, masterList) { foreach (QStandardItem *currentItem, masterList) {
currentItem->appendRow(child); currentItem->appendRow(child);
}
} }
} catch(std::runtime_error &e) {
// An error occurred while reading the .esp
continue;
} }
} }

View file

@ -186,7 +186,11 @@ void GraphicsPage::setupOgre()
try try
{ {
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9)
mOgre = new Ogre::Root("", file.fileName().toStdString(), "./launcherOgre.log");
#else
mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log"); mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log");
#endif
} }
catch(Ogre::Exception &ex) catch(Ogre::Exception &ex)
{ {
@ -207,6 +211,15 @@ void GraphicsPage::setupOgre()
return; return;
} }
#ifdef ENABLE_PLUGIN_GL
mGLPlugin = new Ogre::GLPlugin();
mOgre->installPlugin(mGLPlugin);
#endif
#ifdef ENABLE_PLUGIN_Direct3D9
mD3D9Plugin = new Ogre::D3D9Plugin();
mOgre->installPlugin(mD3D9Plugin);
#endif
// Get the available renderers and put them in the combobox // Get the available renderers and put them in the combobox
const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers(); const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers();

View file

@ -8,6 +8,14 @@
#include <OgreConfigFile.h> #include <OgreConfigFile.h>
#include <OgreConfigDialog.h> #include <OgreConfigDialog.h>
// Static plugin headers
#ifdef ENABLE_PLUGIN_GL
# include "OgreGLPlugin.h"
#endif
#ifdef ENABLE_PLUGIN_Direct3D9
# include "OgreD3D9Plugin.h"
#endif
class QComboBox; class QComboBox;
class QCheckBox; class QCheckBox;
class QStackedWidget; class QStackedWidget;
@ -32,6 +40,12 @@ private:
Ogre::RenderSystem *mSelectedRenderSystem; Ogre::RenderSystem *mSelectedRenderSystem;
Ogre::RenderSystem *mOpenGLRenderSystem; Ogre::RenderSystem *mOpenGLRenderSystem;
Ogre::RenderSystem *mDirect3DRenderSystem; Ogre::RenderSystem *mDirect3DRenderSystem;
#ifdef ENABLE_PLUGIN_GL
Ogre::GLPlugin* mGLPlugin;
#endif
#ifdef ENABLE_PLUGIN_Direct3D9
Ogre::D3D9Plugin* mD3D9Plugin;
#endif
QComboBox *mRendererComboBox; QComboBox *mRendererComboBox;

View file

@ -44,7 +44,7 @@ add_openmw_dir (mwsound
add_openmw_dir (mwworld add_openmw_dir (mwworld
refdata world physicssystem scene environment globals class action nullaction actionteleport refdata world physicssystem scene environment globals class action nullaction actionteleport
containerstore actiontalk actiontake manualref player cellfunctors containerstore actiontalk actiontake manualref player cellfunctors
cells localscripts customdata weather inventorystore cells localscripts customdata weather inventorystore ptr
) )
add_openmw_dir (mwclass add_openmw_dir (mwclass
@ -57,6 +57,15 @@ add_openmw_dir (mwmechanics
) )
# Main executable # Main executable
IF(OGRE_STATIC)
IF(WIN32)
ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL)
set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES})
ELSE(WIN32)
ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL)
set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES})
ENDIF(WIN32)
ENDIF(OGRE_STATIC)
add_executable(openmw add_executable(openmw
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
${COMPONENT_FILES} ${COMPONENT_FILES}
@ -73,16 +82,22 @@ add_definitions(${SOUND_DEFINE})
target_link_libraries(openmw target_link_libraries(openmw
${OGRE_LIBRARIES} ${OGRE_LIBRARIES}
${OGRE_Terrain_LIBRARY} ${OGRE_Terrain_LIBRARY}
${OGRE_STATIC_PLUGINS}
${OIS_LIBRARIES} ${OIS_LIBRARIES}
${Boost_LIBRARIES} ${Boost_LIBRARIES}
${OPENAL_LIBRARY} ${OPENAL_LIBRARY}
${SOUND_INPUT_LIBRARY} ${SOUND_INPUT_LIBRARY}
${BULLET_LIBRARIES} ${BULLET_LIBRARIES}
${MYGUI_LIBRARIES}
MyGUI.OgrePlatform #TODO MyGUI ogre platform is not added by the find script
components components
MyGUIEngine
MyGUIOgrePlatform
) )
# Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE)
target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT})
endif()
if(APPLE) if(APPLE)
find_library(CARBON_FRAMEWORK Carbon) find_library(CARBON_FRAMEWORK Carbon)
target_link_libraries(openmw ${CARBON_FRAMEWORK}) target_link_libraries(openmw ${CARBON_FRAMEWORK})

View file

@ -60,7 +60,7 @@ void OMW::Engine::executeLocalScripts()
MWScript::InterpreterContext interpreterContext (mEnvironment, MWScript::InterpreterContext interpreterContext (mEnvironment,
&script.second.getRefData().getLocals(), script.second); &script.second.getRefData().getLocals(), script.second);
mScriptManager->run (script.first, interpreterContext); mEnvironment.mScriptManager->run (script.first, interpreterContext);
if (mEnvironment.mWorld->hasCellChanged()) if (mEnvironment.mWorld->hasCellChanged())
break; break;
@ -182,7 +182,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mCompileAll (false) , mCompileAll (false)
, mReportFocus (false) , mReportFocus (false)
, mFocusTDiff (0) , mFocusTDiff (0)
, mScriptManager (0)
, mScriptContext (0) , mScriptContext (0)
, mFSStrict (false) , mFSStrict (false)
, mCfgMgr(configurationManager) , mCfgMgr(configurationManager)
@ -199,7 +198,7 @@ OMW::Engine::~Engine()
delete mEnvironment.mMechanicsManager; delete mEnvironment.mMechanicsManager;
delete mEnvironment.mDialogueManager; delete mEnvironment.mDialogueManager;
delete mEnvironment.mJournal; delete mEnvironment.mJournal;
delete mScriptManager; delete mEnvironment.mScriptManager;
delete mScriptContext; delete mScriptContext;
delete mOgre; delete mOgre;
} }
@ -348,18 +347,18 @@ void OMW::Engine::go()
mEnvironment); mEnvironment);
mScriptContext->setExtensions (&mExtensions); mScriptContext->setExtensions (&mExtensions);
mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts, mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(),
*mScriptContext); mVerboseScripts, *mScriptContext);
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(), mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
*mScriptManager); *mEnvironment.mScriptManager);
// Create game mechanics system // Create game mechanics system
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment); mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment);
// Create dialog system // Create dialog system
mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment); mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment);
mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment); mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions);
// load cell // load cell
ESM::Position pos; ESM::Position pos;
@ -393,7 +392,7 @@ void OMW::Engine::go()
// scripts // scripts
if (mCompileAll) if (mCompileAll)
{ {
std::pair<int, int> result = mScriptManager->compileAll(); std::pair<int, int> result = mEnvironment.mScriptManager->compileAll();
if (result.first) if (result.first)
std::cout std::cout
@ -411,6 +410,9 @@ void OMW::Engine::go()
void OMW::Engine::activate() void OMW::Engine::activate()
{ {
if (mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game)
return;
std::string handle = mEnvironment.mWorld->getFacedHandle(); std::string handle = mEnvironment.mWorld->getFacedHandle();
if (handle.empty()) if (handle.empty())
@ -435,7 +437,7 @@ void OMW::Engine::activate()
if (!script.empty()) if (!script.empty())
{ {
mEnvironment.mWorld->getLocalScripts().setIgnore (ptr); mEnvironment.mWorld->getLocalScripts().setIgnore (ptr);
mScriptManager->run (script, interpreterContext); mEnvironment.mScriptManager->run (script, interpreterContext);
} }
if (!interpreterContext.hasActivationBeenHandled()) if (!interpreterContext.hasActivationBeenHandled())

View file

@ -78,10 +78,9 @@ namespace OMW
std::string mFocusName; std::string mFocusName;
MWWorld::Environment mEnvironment; MWWorld::Environment mEnvironment;
MWScript::ScriptManager *mScriptManager;
Compiler::Extensions mExtensions; Compiler::Extensions mExtensions;
Compiler::Context *mScriptContext; Compiler::Context *mScriptContext;
Files::Collections mFileCollections; Files::Collections mFileCollections;
bool mFSStrict; bool mFSStrict;

View file

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,14 @@ namespace MWClass
registerClass (typeid (ESM::Apparatus).name(), instance); registerClass (typeid (ESM::Apparatus).name(), instance);
} }
std::string Apparatus::getUpSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Apparatus Up");
}
std::string Apparatus::getDownSoundId (const MWWorld::Ptr& ptr) const
{
return std::string("Item Apparatus Down");
}
} }

View file

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const;
///< Return the put down sound Id
}; };
} }

View file

@ -9,12 +9,15 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -57,6 +60,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -116,7 +121,7 @@ namespace MWClass
return std::make_pair (slots, false); return std::make_pair (slots, false);
} }
int Armor::getEuqipmentSkill (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{ {
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
ptr.get<ESM::Armor>(); ptr.get<ESM::Armor>();
@ -142,13 +147,13 @@ namespace MWClass
if (typeGmst.empty()) if (typeGmst.empty())
return -1; return -1;
float iWeight = environment.mWorld->getStore().gameSettings.find (typeGmst)->f; float iWeight = environment.mWorld->getStore().gameSettings.find (typeGmst)->i;
if (iWeight * environment.mWorld->getStore().gameSettings.find ("fLightMaxMod")->f<= if (iWeight * environment.mWorld->getStore().gameSettings.find ("fLightMaxMod")->f>=
ref->base->data.weight) ref->base->data.weight)
return ESM::Skill::LightArmor; return ESM::Skill::LightArmor;
if (iWeight * environment.mWorld->getStore().gameSettings.find ("fMedMaxMod")->f<= if (iWeight * environment.mWorld->getStore().gameSettings.find ("fMedMaxMod")->f>=
ref->base->data.weight) ref->base->data.weight)
return ESM::Skill::MediumArmor; return ESM::Skill::MediumArmor;
@ -161,4 +166,26 @@ namespace MWClass
registerClass (typeid (ESM::Armor).name(), instance); registerClass (typeid (ESM::Armor).name(), instance);
} }
std::string Armor::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
int es = getEquipmentSkill(ptr, environment);
if (es == ESM::Skill::LightArmor)
return std::string("Item Armor Light Up");
else if (es == ESM::Skill::MediumArmor)
return std::string("Item Armor Medium Up");
else
return std::string("Item Armor Heavy Up");
}
std::string Armor::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
int es = getEquipmentSkill(ptr, environment);
if (es == ESM::Skill::LightArmor)
return std::string("Item Armor Light Down");
else if (es == ESM::Skill::MediumArmor)
return std::string("Item Armor Medium Down");
else
return std::string("Item Armor Heavy Down");
}
} }

View file

@ -35,12 +35,18 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object ///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped? /// stay stacked when equipped?
virtual int getEuqipmentSkill (const MWWorld::Ptr& ptr, virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const; const MWWorld::Environment& environment) const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -55,6 +58,8 @@ namespace MWClass
{ {
// TODO implement reading // TODO implement reading
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -73,4 +78,14 @@ namespace MWClass
registerClass (typeid (ESM::Book).name(), instance); registerClass (typeid (ESM::Book).name(), instance);
} }
std::string Book::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Book Up");
}
std::string Book::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Book Down");
}
} }

View file

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -54,6 +57,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -106,7 +111,7 @@ namespace MWClass
return std::make_pair (slots, false); return std::make_pair (slots, false);
} }
int Clothing::getEuqipmentSkill (const MWWorld::Ptr& ptr, int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const const MWWorld::Environment& environment) const
{ {
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
@ -124,4 +129,28 @@ namespace MWClass
registerClass (typeid (ESM::Clothing).name(), instance); registerClass (typeid (ESM::Clothing).name(), instance);
} }
std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
if (ref->base->data.type == 8)
{
return std::string("Item Ring Up");
}
return std::string("Item Clothes Up");
}
std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
ptr.get<ESM::Clothing>();
if (ref->base->data.type == 8)
{
return std::string("Item Ring Down");
}
return std::string("Item Clothes Down");
}
} }

View file

@ -29,12 +29,18 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object ///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped? /// stay stacked when equipped?
virtual int getEuqipmentSkill (const MWWorld::Ptr& ptr, virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const; const MWWorld::Environment& environment) const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -85,7 +85,7 @@ namespace MWClass
{ {
// TODO check for key // TODO check for key
std::cout << "Locked container" << std::endl; std::cout << "Locked container" << std::endl;
environment.mSoundManager->playSound(lockedSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0, false);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
else else
@ -100,7 +100,7 @@ namespace MWClass
{ {
// Trap activation goes here // Trap activation goes here
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, trapActivationSound, 1.0, 1.0, false);
ptr.getCellRef().trap = ""; ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }

View file

@ -73,7 +73,7 @@ namespace MWClass
// TODO check for key // TODO check for key
// TODO report failure to player (message, sound?). Look up behaviour of original MW. // TODO report failure to player (message, sound?). Look up behaviour of original MW.
std::cout << "Locked!" << std::endl; std::cout << "Locked!" << std::endl;
environment.mSoundManager->playSound(lockedSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, lockedSound, 1.0, 1.0, false);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
@ -81,7 +81,7 @@ namespace MWClass
{ {
// Trap activation // Trap activation
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl; std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
environment.mSoundManager->playSound(trapActivationSound, 1.0, 1.0); environment.mSoundManager->playSound3D(ptr, trapActivationSound, 1.0, 1.0, false);
ptr.getCellRef().trap = ""; ptr.getCellRef().trap = "";
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
@ -92,6 +92,7 @@ namespace MWClass
if (environment.mWorld->getPlayer().getPlayer()==actor) if (environment.mWorld->getPlayer().getPlayer()==actor)
{ {
// the player is using the door // the player is using the door
// The reason this is not 3D is that it would get interrupted when you teleport
environment.mSoundManager->playSound(openSound, 1.0, 1.0); environment.mSoundManager->playSound(openSound, 1.0, 1.0);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest)); new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
@ -109,7 +110,7 @@ namespace MWClass
// TODO return action for rotating the door // TODO return action for rotating the door
// This is a little pointless, but helps with testing // This is a little pointless, but helps with testing
environment.mSoundManager->playSound(openSound, 1.0, 1.0); environment.mSoundManager->playSound3D (ptr, openSound, 1.0, 1.0, false);
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
} }
} }

View file

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -51,6 +54,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -69,4 +74,14 @@ namespace MWClass
registerClass (typeid (ESM::Ingredient).name(), instance); registerClass (typeid (ESM::Ingredient).name(), instance);
} }
std::string Ingredient::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Ingredient Up");
}
std::string Ingredient::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Ingredient Down");
}
} }

View file

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -83,6 +83,8 @@ namespace MWClass
if (!(ref->base->data.flags & ESM::Light::Carry)) if (!(ref->base->data.flags & ESM::Light::Carry))
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -114,4 +116,14 @@ namespace MWClass
registerClass (typeid (ESM::Light).name(), instance); registerClass (typeid (ESM::Light).name(), instance);
} }
std::string Light::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Misc Up");
}
std::string Light::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Misc Down");
}
} }

View file

@ -35,6 +35,12 @@ namespace MWClass
/// stay stacked when equipped? /// stay stacked when equipped?
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -55,6 +58,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -82,4 +87,14 @@ namespace MWClass
registerClass (typeid (ESM::Tool).name(), instance); registerClass (typeid (ESM::Tool).name(), instance);
} }
std::string Lockpick::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Lockpick Up");
}
std::string Lockpick::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Lockpick Down");
}
} }

View file

@ -30,6 +30,12 @@ namespace MWClass
/// stay stacked when equipped? /// stay stacked when equipped?
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,28 @@ namespace MWClass
registerClass (typeid (ESM::Miscellaneous).name(), instance); registerClass (typeid (ESM::Miscellaneous).name(), instance);
} }
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->base->name =="Gold")
{
return std::string("Item Gold Up");
}
return std::string("Item Misc Up");
}
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
ptr.get<ESM::Miscellaneous>();
if (ref->base->name =="Gold")
{
return std::string("Item Gold Down");
}
return std::string("Item Misc Down");
}
} }

View file

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,14 @@ namespace MWClass
registerClass (typeid (ESM::Potion).name(), instance); registerClass (typeid (ESM::Potion).name(), instance);
} }
std::string Potion::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Potion Up");
}
std::string Potion::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Potion Down");
}
} }

View file

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -54,6 +57,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -81,4 +86,14 @@ namespace MWClass
registerClass (typeid (ESM::Probe).name(), instance); registerClass (typeid (ESM::Probe).name(), instance);
} }
std::string Probe::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Probe Up");
}
std::string Probe::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Probe Down");
}
} }

View file

@ -30,6 +30,12 @@ namespace MWClass
/// stay stacked when equipped? /// stay stacked when equipped?
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,9 +7,12 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -53,6 +56,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -71,4 +76,14 @@ namespace MWClass
registerClass (typeid (ESM::Repair).name(), instance); registerClass (typeid (ESM::Repair).name(), instance);
} }
std::string Repair::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Repair Up");
}
std::string Repair::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
return std::string("Item Repair Down");
}
} }

View file

@ -26,6 +26,12 @@ namespace MWClass
///< Return name of the script attached to ptr ///< Return name of the script attached to ptr
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -7,10 +7,13 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/actiontake.hpp" #include "../mwworld/actiontake.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwrender/objects.hpp" #include "../mwrender/objects.hpp"
#include "../mwsound/soundmanager.hpp"
namespace MWClass namespace MWClass
{ {
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
@ -54,6 +57,8 @@ namespace MWClass
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
{ {
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
return boost::shared_ptr<MWWorld::Action> ( return boost::shared_ptr<MWWorld::Action> (
new MWWorld::ActionTake (ptr)); new MWWorld::ActionTake (ptr));
} }
@ -103,7 +108,7 @@ namespace MWClass
return std::make_pair (slots, stack); return std::make_pair (slots, stack);
} }
int Weapon::getEuqipmentSkill (const MWWorld::Ptr& ptr, int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const const MWWorld::Environment& environment) const
{ {
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref = ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
@ -140,4 +145,96 @@ namespace MWClass
registerClass (typeid (ESM::Weapon).name(), instance); registerClass (typeid (ESM::Weapon).name(), instance);
} }
std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
int type = ref->base->data.type;
// Ammo
if (type == 12 || type == 13)
{
return std::string("Item Ammo Up");
}
// Bow
if (type == 9)
{
return std::string("Item Weapon Bow Up");
}
// Crossbow
if (type == 10)
{
return std::string("Item Weapon Crossbow Up");
}
// Longblades, One hand and Two
if (type == 1 || type == 2)
{
return std::string("Item Weapon Longblade Up");
}
// Shortblade and thrown weapons
// thrown weapons may not be entirely correct
if (type == 0 || type == 11)
{
return std::string("Item Weapon Shortblade Up");
}
// Spear
if (type == 6)
{
return std::string("Item Weapon Spear Up");
}
// Blunts and Axes
if (type == 3 || type == 4 || type == 5 || type == 7 || type == 8)
{
return std::string("Item Weapon Blunt Up");
}
return std::string("Item Misc Up");
}
std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const
{
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
ptr.get<ESM::Weapon>();
int type = ref->base->data.type;
// Ammo
if (type == 12 || type == 13)
{
return std::string("Item Ammo Down");
}
// Bow
if (type == 9)
{
return std::string("Item Weapon Bow Down");
}
// Crossbow
if (type == 10)
{
return std::string("Item Weapon Crossbow Down");
}
// Longblades, One hand and Two
if (type == 1 || type == 2)
{
return std::string("Item Weapon Longblade Down");
}
// Shortblade and thrown weapons
// thrown weapons may not be entirely correct
if (type == 0 || type == 11)
{
return std::string("Item Weapon Shortblade Down");
}
// Spear
if (type == 6)
{
return std::string("Item Weapon Spear Down");
}
// Blunts and Axes
if (type == 3 || type == 4 || type == 5 || type == 7 || type == 8)
{
return std::string("Item Weapon Blunt Down");
}
return std::string("Item Misc Down");
}
} }

View file

@ -35,12 +35,18 @@ namespace MWClass
///< \return first: Return IDs of the slot this object can be equipped in; second: can object ///< \return first: Return IDs of the slot this object can be equipped in; second: can object
/// stay stacked when equipped? /// stay stacked when equipped?
virtual int getEuqipmentSkill (const MWWorld::Ptr& ptr, virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
const MWWorld::Environment& environment) const; const MWWorld::Environment& environment) const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
static void registerSelf(); static void registerSelf();
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the pick up sound Id
virtual std::string getDownSoundId (const MWWorld::Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the put down sound Id
}; };
} }

View file

@ -9,16 +9,36 @@
#include <components/esm_store/store.hpp> #include <components/esm_store/store.hpp>
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwworld/refdata.hpp" #include "../mwworld/refdata.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwinput/inputmanager.hpp" #include "../mwinput/inputmanager.hpp"
#include "../mwgui/dialogue.hpp"
#include "../mwgui/window_manager.hpp"
#include "journal.hpp"
#include <iostream> #include <iostream>
#include "../mwscript/extensions.hpp"
#include "../mwscript/scriptmanager.hpp"
#include <components/compiler/exception.hpp>
#include <components/compiler/errorhandler.hpp>
#include <components/compiler/scanner.hpp>
#include <components/compiler/locals.hpp>
#include <components/compiler/output.hpp>
#include <components/interpreter/interpreter.hpp>
#include "../mwscript/compilercontext.hpp"
#include "../mwscript/interpretercontext.hpp"
#include <components/compiler/scriptparser.hpp>
namespace namespace
{ {
std::string toLower (const std::string& name) std::string toLower (const std::string& name)
@ -31,17 +51,18 @@ namespace
return lowerCase; return lowerCase;
} }
template<typename T1, typename T2> template<typename T1, typename T2>
bool selectCompare (char comp, T1 value1, T2 value2) bool selectCompare (char comp, T1 value1, T2 value2)
{ {
switch (comp) switch (comp)
{ {
case '0': return value1==value2; case '0': return value1==value2;
case '1': return value1!=value2; case '1': return value1!=value2;
case '2': return value1>value2; case '2': return value1>value2;
case '3': return value1>=value2; case '3': return value1>=value2;
case '4': return value1<value2; case '4': return value1<value2;
case '5': return value1<=value2; case '5': return value1<=value2;
} }
throw std::runtime_error ("unknown compare type in dialogue info select"); throw std::runtime_error ("unknown compare type in dialogue info select");
@ -87,26 +108,26 @@ namespace
{ {
switch (world.getGlobalVariableType (name)) switch (world.getGlobalVariableType (name))
{ {
case 's': case 's':
return selectCompare (comp, value, world.getGlobalVariable (name).mShort); return selectCompare (comp, value, world.getGlobalVariable (name).mShort);
case 'l': case 'l':
return selectCompare (comp, value, world.getGlobalVariable (name).mLong); return selectCompare (comp, value, world.getGlobalVariable (name).mLong);
case 'f': case 'f':
return selectCompare (comp, value, world.getGlobalVariable (name).mFloat); return selectCompare (comp, value, world.getGlobalVariable (name).mFloat);
case ' ': case ' ':
world.getGlobalVariable (name); // trigger exception world.getGlobalVariable (name); // trigger exception
break; break;
default: default:
throw std::runtime_error ("unsupported gobal variable type"); throw std::runtime_error ("unsupported gobal variable type");
} }
return false; return false;
@ -115,6 +136,125 @@ namespace
namespace MWDialogue namespace MWDialogue
{ {
//helper function
std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos)
{
return toLower(str).find(toLower(substr),pos);
}
bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice)
{
for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
iter != info.selects.end(); ++iter)
{
ESM::DialInfo::SelectStruct select = *iter;
char type = select.selectRule[1];
if(type == '1')
{
char comp = select.selectRule[4];
std::string name = select.selectRule.substr (5);
std::string function = select.selectRule.substr(2,2);
int ifunction;
std::istringstream iss(function);
iss >> ifunction;
switch(ifunction)
{
case 39://PC Expelled
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 40://PC Common Disease
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 41://PC Blight Disease
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 43://PC Crime level
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 46://Same faction
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 48://Detected
if(!selectCompare<int,int>(comp,1,select.i)) return false;
break;
case 49://Alarmed
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 50://choice
if(choice)
{
if(!selectCompare<int,int>(comp,mChoice,select.i)) return false;
}
break;
case 60://PC Vampire
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 61://Level
if(!selectCompare<int,int>(comp,1,select.i)) return false;
break;
case 62://Attacked
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 63://Talked to PC
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 64://PC Health
if(!selectCompare<int,int>(comp,50,select.i)) return false;
break;
case 65://Creature target
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 66://Friend hit
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 67://Fight
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 68://Hello????
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 69://Alarm
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 70://Flee
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
case 71://Should Attack
if(!selectCompare<int,int>(comp,0,select.i)) return false;
break;
default:
break;
}
}
}
return true;
}
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, bool DialogueManager::isMatching (const MWWorld::Ptr& actor,
const ESM::DialInfo::SelectStruct& select) const const ESM::DialInfo::SelectStruct& select) const
{ {
@ -124,58 +264,173 @@ namespace MWDialogue
{ {
char comp = select.selectRule[4]; char comp = select.selectRule[4];
std::string name = select.selectRule.substr (5); std::string name = select.selectRule.substr (5);
std::string function = select.selectRule.substr(1,2);
// TODO types 4, 5, 6, 7, 8, 9, A, B, C
switch (type) switch (type)
{ {
case '1': // function case '1': // function
return false; // TODO implement functions return true; // TODO implement functions
case '2': // global case '2': // global
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
select.type==ESM::VT_Long) select.type==ESM::VT_Long)
{ {
if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld)) if (!checkGlobal (comp, toLower (name), select.i, *mEnvironment.mWorld))
return false; return false;
} }
else if (select.type==ESM::VT_Float) else if (select.type==ESM::VT_Float)
{ {
if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld)) if (!checkGlobal (comp, toLower (name), select.f, *mEnvironment.mWorld))
return false; return false;
} }
else else
throw std::runtime_error ( throw std::runtime_error (
"unsupported variable type in dialogue info select"); "unsupported variable type in dialogue info select");
return true; return true;
case '3': // local case '3': // local
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int || if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
select.type==ESM::VT_Long) select.type==ESM::VT_Long)
{ {
if (!checkLocal (comp, toLower (name), select.i, actor, if (!checkLocal (comp, toLower (name), select.i, actor,
mEnvironment.mWorld->getStore())) mEnvironment.mWorld->getStore()))
return false; return false;
} }
else if (select.type==ESM::VT_Float) else if (select.type==ESM::VT_Float)
{ {
if (!checkLocal (comp, toLower (name), select.f, actor, if (!checkLocal (comp, toLower (name), select.f, actor,
mEnvironment.mWorld->getStore())) mEnvironment.mWorld->getStore()))
return false; return false;
} }
else else
throw std::runtime_error ( throw std::runtime_error (
"unsupported variable type in dialogue info select"); "unsupported variable type in dialogue info select");
return true; return true;
default: case '4'://journal
if(select.type==ESM::VT_Int)
{
if(!selectCompare<int,int>(comp,mEnvironment.mJournal->getJournalIndex(toLower(name)),select.i)) return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; return true;
case '5'://item
{
MWWorld::Ptr player = mEnvironment.mWorld->getPlayer().getPlayer();
MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player);
int sum = 0;
for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter)
if (iter->getCellRef().refID==name)
sum += iter->getRefData().getCount();
if(!selectCompare<int,int>(comp,sum,select.i)) return false;
}
return true;
case '6'://dead
if(!selectCompare<int,int>(comp,0,select.i)) return false;
case '7':// not ID
if(select.type==ESM::VT_String ||select.type==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string
{
int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor)));
if (selectCompare<int,int>(comp,!isID,select.i)) return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
return true;
case '8':// not faction
if(select.type==ESM::VT_Int)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
int isFaction = int(toLower(npc->base->faction) == toLower(name));
if(selectCompare<int,int>(comp,!isFaction,select.i))
return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
return true;
case '9':// not class
if(select.type==ESM::VT_Int)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
int isClass = int(toLower(npc->base->cls) == toLower(name));
if(selectCompare<int,int>(comp,!isClass,select.i))
return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
return true;
case 'A'://not Race
if(select.type==ESM::VT_Int)
{
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
int isRace = int(toLower(npc->base->race) == toLower(name));
if(selectCompare<int,int>(comp,!isRace,select.i))
return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
return true;
case 'B'://not Cell
if(select.type==ESM::VT_Int)
{
int isCell = int(toLower(actor.getCell()->cell->name) == toLower(name));
if(selectCompare<int,int>(comp,!isCell,select.i))
return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
return true;
case 'C'://not local
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
select.type==ESM::VT_Long)
{
if (checkLocal (comp, toLower (name), select.i, actor,
mEnvironment.mWorld->getStore()))
return false;
}
else if (select.type==ESM::VT_Float)
{
if (checkLocal (comp, toLower (name), select.f, actor,
mEnvironment.mWorld->getStore()))
return false;
}
else
throw std::runtime_error (
"unsupported variable type in dialogue info select");
return true;
default:
std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl;
} }
} }
@ -189,6 +444,10 @@ namespace MWDialogue
if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor)) if (toLower (info.actor)!=MWWorld::Class::get (actor).getId (actor))
return false; return false;
//PC Faction
if(!info.pcFaction.empty()) return false;
//NPC race
if (!info.race.empty()) if (!info.race.empty())
{ {
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>(); ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
@ -200,6 +459,7 @@ namespace MWDialogue
return false; return false;
} }
//NPC class
if (!info.clas.empty()) if (!info.clas.empty())
{ {
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>(); ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
@ -211,6 +471,7 @@ namespace MWDialogue
return false; return false;
} }
//NPC faction
if (!info.npcFaction.empty()) if (!info.npcFaction.empty())
{ {
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>(); ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
@ -220,66 +481,320 @@ namespace MWDialogue
if (toLower (info.npcFaction)!=toLower (cellRef->base->faction)) if (toLower (info.npcFaction)!=toLower (cellRef->base->faction))
return false; return false;
//check NPC rank
if(cellRef->base->npdt52.gold != -10)
{
if(cellRef->base->npdt52.rank < info.data.rank) return false;
}
else
{
if(cellRef->base->npdt12.rank < info.data.rank) return false;
}
} }
// TODO check player faction // TODO check player faction
//check gender
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
if(npc->base->flags&npc->base->Female)
{
if(static_cast<int> (info.data.gender)==0) return false;
}
else
{
if(static_cast<int> (info.data.gender)==1) return false;
}
// check cell // check cell
if (!info.cell.empty()) if (!info.cell.empty())
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell) if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
return false; return false;
// TODO check DATAstruct // TODO check DATAstruct
for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin()); for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
iter != info.selects.end(); ++iter) iter != info.selects.end(); ++iter)
if (!isMatching (actor, *iter)) if (!isMatching (actor, *iter))
return false; return false;
std::cout
<< "unchecked entries:" << std::endl
<< " player faction: " << info.pcFaction << std::endl
<< " disposition: " << info.data.disposition << std::endl
<< " NPC rank: " << static_cast<int> (info.data.rank) << std::endl
<< " gender: " << static_cast<int> (info.data.gender) << std::endl
<< " PC rank: " << static_cast<int> (info.data.PCrank) << std::endl;
return true; return true;
} }
DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {} DialogueManager::DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions) :
mEnvironment (environment),mCompilerContext (MWScript::CompilerContext::Type_Dialgoue, environment),
mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream)
{
mChoice = -1;
mIsInChoice = false;
mCompilerContext.setExtensions (&extensions);
}
void DialogueManager::addTopic(std::string topic)
{
knownTopics[toLower(topic)] = true;
}
void DialogueManager::parseText(std::string text)
{
std::list<std::string>::iterator it;
for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++)
{
size_t pos = find_str_ci(text,*it,0);
if(pos !=std::string::npos)
{
if(pos==0)
{
knownTopics[*it] = true;
}
else if(text.substr(pos -1,1) == " ")
{
knownTopics[*it] = true;
}
}
}
updateTopics();
}
void DialogueManager::startDialogue (const MWWorld::Ptr& actor) void DialogueManager::startDialogue (const MWWorld::Ptr& actor)
{ {
std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl; mChoice = -1;
mIsInChoice = false;
const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello"); mActor = actor;
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); mDialogueMap.clear();
iter!=dialogue->mInfo.end(); ++iter) actorKnownTopics.clear();
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{ {
if (isMatching (actor, *iter)) mDialogueMap[it->first] = it->second;
}
//initialise the GUI
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->startDialogue(MWWorld::Class::get (actor).getName (actor));
//setup the list of topics known by the actor. Topics who are also on the knownTopics list will be added to the GUI
updateTopics();
//greeting
bool greetingFound = false;
//ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Greeting)
{ {
// start dialogue if (greetingFound) break;
std::cout << "found matching info record" << std::endl; for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin());
iter!=it->second.mInfo.end(); ++iter)
std::cout << "response: " << iter->response << std::endl;
if (!iter->sound.empty())
{ {
// TODO play sound if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true))
} {
if (!iter->sound.empty())
{
// TODO play sound
}
if (!iter->resultScript.empty()) std::string text = iter->response;
{ parseText(text);
std::cout << "script: " << iter->resultScript << std::endl; win->addText(iter->response);
// TODO execute script executeScript(iter->resultScript);
greetingFound = true;
mLastTopic = it->first;
mLastDialogue = *iter;
break;
}
} }
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
break;
} }
} }
} }
bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code)
{
try
{
mErrorHandler.reset();
std::istringstream input (cmd + "\n");
Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions());
Compiler::Locals locals;
std::string actorScript = MWWorld::Class::get (mActor).getScript (mActor);
if (!actorScript.empty())
{
// grab local variables from actor's script, if available.
locals = mEnvironment.mScriptManager->getLocals (actorScript);
}
Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false);
scanner.scan (parser);
if(mErrorHandler.isGood())
{
parser.getCode(code);
return true;
}
return false;
}
catch (const Compiler::SourceException& error)
{
// error has already been reported via error handler
}
catch (const std::exception& error)
{
printError (std::string ("An exception has been thrown: ") + error.what());
}
return false;
}
void DialogueManager::executeScript(std::string script)
{
std::vector<Interpreter::Type_Code> code;
if(compile(script,code))
{
try
{
MWScript::InterpreterContext interpreterContext(mEnvironment,&mActor.getRefData().getLocals(),mActor);
Interpreter::Interpreter interpreter;
MWScript::installOpcodes (interpreter);
interpreter.run (&code[0], code.size(), interpreterContext);
}
catch (const std::exception& error)
{
printError (std::string ("An exception has been thrown: ") + error.what());
}
}
}
void DialogueManager::updateTopics()
{
std::list<std::string> keywordList;
int choice = mChoice;
mChoice = -1;
actorKnownTopics.clear();
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list;
for(ESMS::RecListT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
{
ESM::Dialogue ndialogue = it->second;
if(ndialogue.type == ESM::Dialogue::Topic)
{
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin());
iter!=it->second.mInfo.end(); ++iter)
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
actorKnownTopics.push_back(it->first);
//does the player know the topic?
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
{
keywordList.push_back(it->first);
break;
}
}
}
}
}
win->setKeywords(keywordList);
mChoice = choice;
}
void DialogueManager::keywordSelected(std::string keyword)
{
if(!mIsInChoice)
{
if(mDialogueMap.find(keyword) != mDialogueMap.end())
{
ESM::Dialogue ndialogue = mDialogueMap[keyword];
if(ndialogue.type == ESM::Dialogue::Topic)
{
for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin();
iter!=ndialogue.mInfo.end(); ++iter)
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
std::string text = iter->response;
std::string script = iter->resultScript;
parseText(text);
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->addTitle(keyword);
win->addText(iter->response);
executeScript(script);
mLastTopic = keyword;
mLastDialogue = *iter;
break;
}
}
}
}
}
updateTopics();
}
void DialogueManager::goodbyeSelected()
{
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Game);
}
void DialogueManager::questionAnswered(std::string answere)
{
if(mChoiceMap.find(answere) != mChoiceMap.end())
{
mChoice = mChoiceMap[answere];
std::vector<ESM::DialInfo>::const_iterator iter;
if(mDialogueMap.find(mLastTopic) != mDialogueMap.end())
{
ESM::Dialogue ndialogue = mDialogueMap[mLastTopic];
if(ndialogue.type == ESM::Dialogue::Topic)
{
for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin();
iter!=ndialogue.mInfo.end(); ++iter)
{
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
{
mChoiceMap.clear();
mChoice = -1;
mIsInChoice = false;
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
std::string text = iter->response;
parseText(text);
win->addText(text);
executeScript(iter->resultScript);
mLastTopic = mLastTopic;
mLastDialogue = *iter;
break;
}
}
}
}
updateTopics();
}
}
void DialogueManager::printError(std::string error)
{
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->addText(error);
}
void DialogueManager::askQuestion(std::string question, int choice)
{
MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow();
win->askQuestion(question);
mChoiceMap[question] = choice;
mIsInChoice = true;
}
} }

View file

@ -3,7 +3,13 @@
#include <components/esm/loadinfo.hpp> #include <components/esm/loadinfo.hpp>
#include <components/compiler/streamerrorhandler.hpp>
#include "../mwscript/compilercontext.hpp"
#include "../mwscript/interpretercontext.hpp"
#include <components/compiler/output.hpp>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include <map>
namespace MWWorld namespace MWWorld
{ {
@ -20,12 +26,48 @@ namespace MWDialogue
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const;
bool functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice);
void parseText(std::string text);
void updateTopics();
std::map<std::string,ESM::Dialogue> mDialogueMap;
std::map<std::string,bool> knownTopics;// Those are the topics the player knows.
std::list<std::string> actorKnownTopics;
MWScript::CompilerContext mCompilerContext;
std::ostream mErrorStream;
Compiler::StreamErrorHandler mErrorHandler;
bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code);
void executeScript(std::string script);
MWWorld::Ptr mActor;
void printError(std::string error);
int mChoice;
std::map<std::string,int> mChoiceMap;
std::string mLastTopic;
ESM::DialInfo mLastDialogue;
bool mIsInChoice;
public: public:
DialogueManager (MWWorld::Environment& environment); DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions);
void startDialogue (const MWWorld::Ptr& actor); void startDialogue (const MWWorld::Ptr& actor);
void addTopic(std::string topic);
void askQuestion(std::string question,int choice);
//calbacks for the GUI
void keywordSelected(std::string keyword);
void goodbyeSelected();
void questionAnswered(std::string answere);
}; };
} }

View file

@ -3,6 +3,9 @@
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwgui/window_manager.hpp"
#include "../mwgui/messagebox.hpp"
namespace MWDialogue namespace MWDialogue
{ {
Quest& Journal::getQuest (const std::string& id) Quest& Journal::getQuest (const std::string& id)
@ -34,6 +37,10 @@ namespace MWDialogue
Quest& quest = getQuest (id); Quest& quest = getQuest (id);
quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here quest.addEntry (entry, *mEnvironment.mWorld); // we are doing slicing on purpose here
std::vector<std::string> empty;
std::string notification = "Your Journal has been updated.";
mEnvironment.mWindowManager->messageBox (notification, empty);
} }
void Journal::setJournalIndex (const std::string& id, int index) void Journal::setJournalIndex (const std::string& id, int index)
@ -60,7 +67,12 @@ namespace MWDialogue
int Journal::getJournalIndex (const std::string& id) const int Journal::getJournalIndex (const std::string& id) const
{ {
return 0; TQuestContainer::const_iterator iter = mQuests.find (id);
if (iter==mQuests.end())
return 0;
return iter->second.getIndex();
} }
Journal::TEntryIter Journal::begin() const Journal::TEntryIter Journal::begin() const

View file

@ -21,18 +21,18 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager)
getWidget(birthList, "BirthsignList"); getWidget(birthList, "BirthsignList");
birthList->setScrollVisible(true); birthList->setScrollVisible(true);
birthList->eventListSelectAccept = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); birthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
birthList->eventListMouseItemActivate = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
birthList->eventListChangePosition = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth); birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &BirthDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &BirthDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked);
updateBirths(); updateBirths();
updateSpells(); updateSpells();
@ -100,7 +100,7 @@ void BirthDialog::onBackClicked(MyGUI::Widget* _sender)
eventBack(); eventBack();
} }
void BirthDialog::onSelectBirth(MyGUI::List* _sender, size_t _index) void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
{ {
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
@ -188,7 +188,7 @@ void BirthDialog::updateSpells()
{ {
if (!categories[category].spells.empty()) if (!categories[category].spells.empty())
{ {
MyGUI::StaticTextPtr label = spellArea->createWidget<MyGUI::StaticText>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label")); MyGUI::TextBox* label = spellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
label->setCaption(mWindowManager.getGameSettingString(categories[category].label, "")); label->setCaption(mWindowManager.getGameSettingString(categories[category].label, ""));
spellItems.push_back(label); spellItems.push_back(label);
coord.top += lineHeight; coord.top += lineHeight;

View file

@ -32,7 +32,7 @@ namespace MWGui
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n
@ -40,7 +40,7 @@ namespace MWGui
EventHandle_Void eventBack; EventHandle_Void eventBack;
protected: protected:
void onSelectBirth(MyGUI::List* _sender, size_t _index); void onSelectBirth(MyGUI::ListBox* _sender, size_t _index);
void onOkClicked(MyGUI::Widget* _sender); void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender);
@ -49,9 +49,9 @@ namespace MWGui
void updateBirths(); void updateBirths();
void updateSpells(); void updateSpells();
MyGUI::ListPtr birthList; MyGUI::ListBox* birthList;
MyGUI::WidgetPtr spellArea; MyGUI::WidgetPtr spellArea;
MyGUI::StaticImagePtr birthImage; MyGUI::ImageBox* birthImage;
std::vector<MyGUI::WidgetPtr> spellItems; std::vector<MyGUI::WidgetPtr> spellItems;
std::string currentBirthId; std::string currentBirthId;

View file

@ -121,7 +121,7 @@ void CharacterCreation::spawnDialog(const char id)
mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name")); mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
mNameDialog->setTextInput(mPlayerName); mNameDialog->setTextInput(mPlayerName);
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen); mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
mNameDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone); mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
mNameDialog->open(); mNameDialog->open();
break; break;
@ -131,8 +131,8 @@ void CharacterCreation::spawnDialog(const char id)
mRaceDialog = new RaceDialog(*mWM); mRaceDialog = new RaceDialog(*mWM);
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen); mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
mRaceDialog->setRaceId(mPlayerRaceId); mRaceDialog->setRaceId(mPlayerRaceId);
mRaceDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone); mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
mRaceDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack); mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
mRaceDialog->open(); mRaceDialog->open();
break; break;
@ -140,7 +140,7 @@ void CharacterCreation::spawnDialog(const char id)
if (mClassChoiceDialog) if (mClassChoiceDialog)
mWM->removeDialog(mClassChoiceDialog); mWM->removeDialog(mClassChoiceDialog);
mClassChoiceDialog = new ClassChoiceDialog(*mWM); mClassChoiceDialog = new ClassChoiceDialog(*mWM);
mClassChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassChoice); mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
mClassChoiceDialog->open(); mClassChoiceDialog->open();
break; break;
@ -150,8 +150,8 @@ void CharacterCreation::spawnDialog(const char id)
mPickClassDialog = new PickClassDialog(*mWM); mPickClassDialog = new PickClassDialog(*mWM);
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen); mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
mPickClassDialog->setClassId(mPlayerClass.name); mPickClassDialog->setClassId(mPlayerClass.name);
mPickClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone); mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
mPickClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack); mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
mPickClassDialog->open(); mPickClassDialog->open();
break; break;
@ -161,8 +161,8 @@ void CharacterCreation::spawnDialog(const char id)
mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog = new BirthDialog(*mWM);
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
mBirthSignDialog->setBirthId(mPlayerBirthSignId); mBirthSignDialog->setBirthId(mPlayerBirthSignId);
mBirthSignDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
mBirthSignDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
mBirthSignDialog->open(); mBirthSignDialog->open();
break; break;
@ -170,8 +170,8 @@ void CharacterCreation::spawnDialog(const char id)
if (mCreateClassDialog) if (mCreateClassDialog)
mWM->removeDialog(mCreateClassDialog); mWM->removeDialog(mCreateClassDialog);
mCreateClassDialog = new CreateClassDialog(*mWM); mCreateClassDialog = new CreateClassDialog(*mWM);
mCreateClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone); mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
mCreateClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack); mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
mCreateClassDialog->open(); mCreateClassDialog->open();
break; break;
case GM_ClassGenerate: case GM_ClassGenerate:
@ -212,9 +212,9 @@ void CharacterCreation::spawnDialog(const char id)
mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills); mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills);
} }
mReviewDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone); mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
mReviewDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack); mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
mReviewDialog->eventActivateDialog = MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog); mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
mReviewDialog->open(); mReviewDialog->open();
break; break;
} }
@ -559,8 +559,8 @@ void CharacterCreation::showClassQuestionDialog()
mWM->removeDialog(mGenerateClassResultDialog); mWM->removeDialog(mGenerateClassResultDialog);
mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM); mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
mGenerateClassResultDialog->setClassId(mGenerateClass); mGenerateClassResultDialog->setClassId(mGenerateClass);
mGenerateClassResultDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack); mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
mGenerateClassResultDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone); mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
mGenerateClassResultDialog->open(); mGenerateClassResultDialog->open();
return; return;
} }
@ -581,7 +581,7 @@ void CharacterCreation::showClassQuestionDialog()
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[1]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[1]);
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]); buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
mGenerateClassQuestionDialog->setButtons(buttons); mGenerateClassQuestionDialog->setButtons(buttons);
mGenerateClassQuestionDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen); mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
mGenerateClassQuestionDialog->open(); mGenerateClassQuestionDialog->open();
} }

View file

@ -29,11 +29,11 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked);
} }
void GenerateClassResultDialog::open() void GenerateClassResultDialog::open()
@ -96,20 +96,20 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
getWidget(classList, "ClassList"); getWidget(classList, "ClassList");
classList->setScrollVisible(true); classList->setScrollVisible(true);
classList->eventListSelectAccept = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); classList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
classList->eventListMouseItemActivate = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); classList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
classList->eventListChangePosition = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass); classList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
getWidget(classImage, "ClassImage"); getWidget(classImage, "ClassImage");
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &PickClassDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onBackClicked);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked);
updateClasses(); updateClasses();
updateStats(); updateStats();
@ -177,7 +177,7 @@ void PickClassDialog::onBackClicked(MyGUI::Widget* _sender)
eventBack(); eventBack();
} }
void PickClassDialog::onSelectClass(MyGUI::List* _sender, size_t _index) void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
{ {
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
@ -248,7 +248,7 @@ void PickClassDialog::updateStats()
/* InfoBoxDialog */ /* InfoBoxDialog */
void InfoBoxDialog::fitToText(MyGUI::StaticTextPtr widget) void InfoBoxDialog::fitToText(MyGUI::TextBox* widget)
{ {
MyGUI::IntCoord inner = widget->getTextRegion(); MyGUI::IntCoord inner = widget->getTextRegion();
MyGUI::IntCoord outer = widget->getCoord(); MyGUI::IntCoord outer = widget->getCoord();
@ -267,7 +267,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
for (unsigned i = 0; i < count; ++i) for (unsigned i = 0; i < count; ++i)
{ {
MyGUI::WidgetPtr child = widget->getChildAt(i); MyGUI::WidgetPtr child = widget->getChildAt(i);
if (!child->isVisible()) if (!child->getVisible())
continue; continue;
child->setPosition(child->getLeft(), pos); child->setPosition(child->getLeft(), pos);
@ -322,7 +322,7 @@ void InfoBoxDialog::setButtons(ButtonList &buttons)
button->getSubWidgetText()->setWordWrap(true); button->getSubWidgetText()->setWordWrap(true);
button->setCaption(text); button->setCaption(text);
fitToText(button); fitToText(button);
button->eventMouseButtonClick = MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked);
coord.top += button->getHeight(); coord.top += button->getHeight();
this->buttons.push_back(button); this->buttons.push_back(button);
} }
@ -389,15 +389,15 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization")); setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
getWidget(specializationName, "SpecializationName"); getWidget(specializationName, "SpecializationName");
specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
specializationName->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked); specializationName->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked);
setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:")); setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
getWidget(favoriteAttribute0, "FavoriteAttribute0"); getWidget(favoriteAttribute0, "FavoriteAttribute0");
getWidget(favoriteAttribute1, "FavoriteAttribute1"); getWidget(favoriteAttribute1, "FavoriteAttribute1");
favoriteAttribute0->setWindowManager(&mWindowManager); favoriteAttribute0->setWindowManager(&mWindowManager);
favoriteAttribute1->setWindowManager(&mWindowManager); favoriteAttribute1->setWindowManager(&mWindowManager);
favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); favoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked); favoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", "")); setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", ""));
setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", "")); setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", ""));
@ -414,7 +414,7 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it) for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it)
{ {
(*it)->setWindowManager(&mWindowManager); (*it)->setWindowManager(&mWindowManager);
(*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked); (*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
} }
setText("LabelT", mWindowManager.getGameSettingString("sName", "")); setText("LabelT", mWindowManager.getGameSettingString("sName", ""));
@ -426,15 +426,15 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr descriptionButton; MyGUI::ButtonPtr descriptionButton;
getWidget(descriptionButton, "DescriptionButton"); getWidget(descriptionButton, "DescriptionButton");
descriptionButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked); descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked);
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked);
// Set default skills, attributes // Set default skills, attributes
@ -560,8 +560,8 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
if (specDialog) if (specDialog)
delete specDialog; delete specDialog;
specDialog = new SelectSpecializationDialog(mWindowManager); specDialog = new SelectSpecializationDialog(mWindowManager);
specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); specDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected); specDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
specDialog->setVisible(true); specDialog->setVisible(true);
} }
@ -578,8 +578,8 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
delete attribDialog; delete attribDialog;
attribDialog = new SelectAttributeDialog(mWindowManager); attribDialog = new SelectAttributeDialog(mWindowManager);
attribDialog->setAffectedWidget(_sender); attribDialog->setAffectedWidget(_sender);
attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); attribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); attribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
attribDialog->setVisible(true); attribDialog->setVisible(true);
} }
@ -607,8 +607,8 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
delete skillDialog; delete skillDialog;
skillDialog = new SelectSkillDialog(mWindowManager); skillDialog = new SelectSkillDialog(mWindowManager);
skillDialog->setAffectedWidget(_sender); skillDialog->setAffectedWidget(_sender);
skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); skillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); skillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
skillDialog->setVisible(true); skillDialog->setVisible(true);
} }
@ -638,7 +638,7 @@ void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
{ {
descDialog = new DescriptionDialog(mWindowManager); descDialog = new DescriptionDialog(mWindowManager);
descDialog->setTextInput(description); descDialog->setTextInput(description);
descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered); descDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
descDialog->setVisible(true); descDialog->setVisible(true);
} }
@ -672,18 +672,18 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM
getWidget(specialization1, "Specialization1"); getWidget(specialization1, "Specialization1");
getWidget(specialization2, "Specialization2"); getWidget(specialization2, "Specialization2");
specialization0->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], "")); specialization0->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization0->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specialization1->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], "")); specialization1->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""));
specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specialization2->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], "")); specialization2->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""));
specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked); specialization2->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
specializationId = ESM::Class::Combat; specializationId = ESM::Class::Combat;
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
} }
// widget controls // widget controls
@ -725,14 +725,14 @@ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager)
getWidget(attribute, std::string("Attribute").append(1, theIndex)); getWidget(attribute, std::string("Attribute").append(1, theIndex));
attribute->setWindowManager(&parWindowManager); attribute->setWindowManager(&parWindowManager);
attribute->setAttributeId(ESM::Attribute::attributeIds[i]); attribute->setAttributeId(ESM::Attribute::attributeIds[i]);
attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked); attribute->eventClicked += MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
} }
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
} }
// widget controls // widget controls
@ -813,7 +813,7 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
{ {
skills[spec][i].widget->setWindowManager(&mWindowManager); skills[spec][i].widget->setWindowManager(&mWindowManager);
skills[spec][i].widget->setSkillId(skills[spec][i].skillId); skills[spec][i].widget->setSkillId(skills[spec][i].skillId);
skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked); skills[spec][i].widget->eventClicked += MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked);
} }
} }
@ -821,7 +821,7 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
MyGUI::ButtonPtr cancelButton; MyGUI::ButtonPtr cancelButton;
getWidget(cancelButton, "CancelButton"); getWidget(cancelButton, "CancelButton");
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", "")); cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked); cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
} }
// widget controls // widget controls
@ -850,7 +850,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", "")); okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", ""));
// Make sure the edit box has focus // Make sure the edit box has focus

View file

@ -31,7 +31,7 @@ namespace MWGui
int getChosenButton() const; int getChosenButton() const;
// Events // Events
typedef delegates::CDelegate1<int> EventHandle_Int; typedef delegates::CMultiDelegate1<int> EventHandle_Int;
/** Event : Button was clicked.\n /** Event : Button was clicked.\n
signature : void method(MyGUI::WidgetPtr widget, int index)\n signature : void method(MyGUI::WidgetPtr widget, int index)\n
@ -43,11 +43,11 @@ namespace MWGui
private: private:
void fitToText(MyGUI::StaticTextPtr widget); void fitToText(MyGUI::TextBox* widget);
void layoutVertically(MyGUI::WidgetPtr widget, int margin); void layoutVertically(MyGUI::WidgetPtr widget, int margin);
int currentButton; int currentButton;
MyGUI::WidgetPtr textBox; MyGUI::WidgetPtr textBox;
MyGUI::StaticTextPtr text; MyGUI::TextBox* text;
MyGUI::WidgetPtr buttonBar; MyGUI::WidgetPtr buttonBar;
std::vector<MyGUI::ButtonPtr> buttons; std::vector<MyGUI::ButtonPtr> buttons;
}; };
@ -78,7 +78,7 @@ namespace MWGui
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n
@ -90,8 +90,8 @@ namespace MWGui
void onBackClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender);
private: private:
MyGUI::StaticImagePtr classImage; MyGUI::ImageBox* classImage;
MyGUI::StaticTextPtr className; MyGUI::TextBox* className;
std::string currentClassId; std::string currentClassId;
}; };
@ -108,7 +108,7 @@ namespace MWGui
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n
@ -116,7 +116,7 @@ namespace MWGui
EventHandle_Void eventBack; EventHandle_Void eventBack;
protected: protected:
void onSelectClass(MyGUI::List* _sender, size_t _index); void onSelectClass(MyGUI::ListBox* _sender, size_t _index);
void onOkClicked(MyGUI::Widget* _sender); void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender);
@ -125,9 +125,9 @@ namespace MWGui
void updateClasses(); void updateClasses();
void updateStats(); void updateStats();
MyGUI::StaticImagePtr classImage; MyGUI::ImageBox* classImage;
MyGUI::ListPtr classList; MyGUI::ListBox* classList;
MyGUI::StaticTextPtr specializationName; MyGUI::TextBox* specializationName;
Widgets::MWAttributePtr favoriteAttribute[2]; Widgets::MWAttributePtr favoriteAttribute[2];
Widgets::MWSkillPtr majorSkill[5]; Widgets::MWSkillPtr majorSkill[5];
Widgets::MWSkillPtr minorSkill[5]; Widgets::MWSkillPtr minorSkill[5];
@ -143,7 +143,7 @@ namespace MWGui
ESM::Class::Specialization getSpecializationId() const { return specializationId; } ESM::Class::Specialization getSpecializationId() const { return specializationId; }
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Cancel button clicked.\n /** Event : Cancel button clicked.\n
signature : void method()\n signature : void method()\n
@ -160,7 +160,7 @@ namespace MWGui
void onCancelClicked(MyGUI::Widget* _sender); void onCancelClicked(MyGUI::Widget* _sender);
private: private:
MyGUI::WidgetPtr specialization0, specialization1, specialization2; MyGUI::TextBox *specialization0, *specialization1, *specialization2;
ESM::Class::Specialization specializationId; ESM::Class::Specialization specializationId;
}; };
@ -175,7 +175,7 @@ namespace MWGui
void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; } void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; }
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Cancel button clicked.\n /** Event : Cancel button clicked.\n
signature : void method()\n signature : void method()\n
@ -207,7 +207,7 @@ namespace MWGui
void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; } void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; }
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Cancel button clicked.\n /** Event : Cancel button clicked.\n
signature : void method()\n signature : void method()\n
@ -264,7 +264,7 @@ namespace MWGui
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n
@ -287,7 +287,7 @@ namespace MWGui
private: private:
MyGUI::EditPtr editName; MyGUI::EditPtr editName;
MyGUI::WidgetPtr specializationName; MyGUI::TextBox* specializationName;
Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1; Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1;
Widgets::MWSkillPtr majorSkill[5]; Widgets::MWSkillPtr majorSkill[5];
Widgets::MWSkillPtr minorSkill[5]; Widgets::MWSkillPtr minorSkill[5];

View file

@ -50,7 +50,7 @@ namespace MWGui
return isGood(); return isGood();
} }
catch (const Compiler::SourceException& error) catch (const Compiler::SourceException&)
{ {
// error has already been reported via error handler // error has already been reported via error handler
} }
@ -113,9 +113,9 @@ namespace MWGui
getWidget(history, "list_History"); getWidget(history, "list_History");
// Set up the command line box // Set up the command line box
command->eventEditSelectAccept = command->eventEditSelectAccept +=
newDelegate(this, &Console::acceptCommand); newDelegate(this, &Console::acceptCommand);
command->eventKeyButtonPressed = command->eventKeyButtonPressed +=
newDelegate(this, &Console::keyPress); newDelegate(this, &Console::keyPress);
// Set up the log window // Set up the log window
@ -139,6 +139,9 @@ namespace MWGui
void Console::disable() void Console::disable()
{ {
setVisible(false); setVisible(false);
// Remove keyboard focus from the console input whenever the
// console is turned off
MyGUI::InputManager::getInstance().setKeyFocusWidget(NULL);
} }
void Console::setFont(const std::string &fntName) void Console::setFont(const std::string &fntName)
@ -342,7 +345,7 @@ namespace MWGui
if( ( matches.front().find(' ') != string::npos ) ) { if( ( matches.front().find(' ') != string::npos ) ) {
if( !has_front_quote ) if( !has_front_quote )
output.append(string("\"")); output.append(string("\""));
return output.append(matches.front() + string("\" ")); return output.append(matches.front() + string("\" "));
} }
else if( has_front_quote ) { else if( has_front_quote ) {
return output.append(matches.front() + string("\" ")); return output.append(matches.front() + string("\" "));
@ -361,7 +364,7 @@ namespace MWGui
/* Append the longest match to the end of the output string*/ /* Append the longest match to the end of the output string*/
output.append(matches.front().substr( 0, i)); output.append(matches.front().substr( 0, i));
return output; return output;
} }
} }
} }

View file

@ -3,6 +3,8 @@
#include "window_manager.hpp" #include "window_manager.hpp"
#include "widgets.hpp" #include "widgets.hpp"
#include "components/esm_store/store.hpp" #include "components/esm_store/store.hpp"
#include "../mwworld/environment.hpp"
#include "../mwdialogue/dialoguemanager.hpp"
#include <assert.h> #include <assert.h>
#include <iostream> #include <iostream>
@ -14,107 +16,192 @@
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
DialogueWindow::DialogueWindow(WindowManager& parWindowManager) /**
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager) *Copied from the internet.
*/
std::string lower_string(const std::string& str)
{
std::string lowerCase;
std::transform (str.begin(), str.end(), std::back_inserter (lowerCase),
(int(*)(int)) std::tolower);
return lowerCase;
}
std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos)
{
return lower_string(str).find(lower_string(substr),pos);
}
DialogueWindow::DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment)
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager),
mEnvironment(environment)
{ {
// Centre dialog // Centre dialog
center(); center();
//WindowManager *wm = environment.mWindowManager; //WindowManager *wm = environment.mWindowManager;
setText("NpcName", "Name of character"); setText("NpcName", "Name of character");
//History view //History view
getWidget(history, "History"); getWidget(history, "History");
history->setOverflowToTheLeft(true); history->setOverflowToTheLeft(true);
history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked); history->setMaxTextLength(1000000);
Widget* eventbox;
//Topics list
//An EditBox cannot receive mouse click events, so we use an
//invisible widget on top of the editbox to receive them
/// \todo scrolling the dialogue history with the mouse wheel doesn't work using this solution
getWidget(eventbox, "EventBox");
eventbox->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked);
//Topics list
getWidget(topicsList, "TopicsList"); getWidget(topicsList, "TopicsList");
topicsList->setScrollVisible(true); topicsList->setScrollVisible(true);
topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); //topicsList->eventListSelectAccept += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
topicsList->eventListMouseItemActivate = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); topicsList->eventListMouseItemActivate += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
topicsList->eventListChangePosition = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic); //topicsList->eventListChangePosition += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
MyGUI::ButtonPtr byeButton; MyGUI::ButtonPtr byeButton;
getWidget(byeButton, "ByeButton"); getWidget(byeButton, "ByeButton");
byeButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onByeClicked); byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
updateOptions(); getWidget(pDispositionBar, "Disposition");
getWidget(pDispositionText,"DispositionText");
} }
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender) void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
{ {
ISubWidgetText* t = history->getSubWidgetText(); ISubWidgetText* t = history->getClient()->getSubWidgetText();
if(t == nullptr) if(t == nullptr)
return; return;
const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed(); const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
size_t cursorPosition = t->getCursorPosition(lastPressed); size_t cursorPosition = t->getCursorPosition(lastPressed);
if(history->getColorAtPos(cursorPosition) != "#FFFFFF") MyGUI::UString color = history->getColorAtPos(cursorPosition);
if(color != "#B29154")
{ {
UString key = history->getColorTextAt(cursorPosition); UString key = history->getColorTextAt(cursorPosition);
std::cout << "Clicked on key: " << key << std::endl; if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key));
//eventTopicSelected(key);
if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key);
} }
} }
void DialogueWindow::open() void DialogueWindow::open()
{ {
topicsList->removeAllItems();
pTopicsText.clear();
history->eraseText(0,history->getTextLength());
updateOptions(); updateOptions();
setVisible(true); setVisible(true);
} }
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender) void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{ {
eventBye(); mEnvironment.mDialogueManager->goodbyeSelected();
} }
void DialogueWindow::onSelectTopic(MyGUI::List* _sender, size_t _index) void DialogueWindow::onSelectTopic(MyGUI::ListBox* _sender, size_t _index)
{ {
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;
std::string topic = _sender->getItemNameAt(_index);
//const std::string* theTopic = topicsList->getItemDataAt<std::string>(_index); mEnvironment.mDialogueManager->keywordSelected(lower_string(topic));
//std::cout << "Selected: "<< theTopic << std::endl;
//eventTopicSelected(key);
} }
void DialogueWindow::startDialogue(std::string npcName)
{
setText("NpcName", npcName);
}
void DialogueWindow::setKeywords(std::list<std::string> keyWords)
{
topicsList->removeAllItems();
for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); it++)
{
topicsList->addItem(*it);
}
}
void DialogueWindow::removeKeyword(std::string keyWord)
{
if(topicsList->findItemIndexWith(keyWord) != MyGUI::ITEM_NONE)
{
topicsList->removeItemAt(topicsList->findItemIndexWith(keyWord));
pTopicsText.erase(keyWord);
}
}
void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2)
{
size_t pos = 0;
while((pos = find_str_ci(str,keyword, pos)) != std::string::npos)
{
if(pos==0)
{
str.insert(pos,color1);
pos += color1.length();
pos += keyword.length();
str.insert(pos,color2);
pos+= color2.length();
}
else
{
if(str.substr(pos -1,1) == " ")
{
str.insert(pos,color1);
pos += color1.length();
pos += keyword.length();
str.insert(pos,color2);
pos+= color2.length();
}
else
{
pos += keyword.length();
}
}
}
}
std::string DialogueWindow::parseText(std::string text)
{
for(unsigned int i = 0;i<topicsList->getItemCount();i++)
{
std::string keyWord = topicsList->getItemNameAt(i);
addColorInString(text,keyWord,"#686EBA","#B29154");
}
return text;
}
void DialogueWindow::addText(std::string text)
{
history->addDialogText("#B29154"+parseText(text)+"#B29154");
}
void DialogueWindow::addTitle(std::string text)
{
history->addDialogHeading(text);
}
void DialogueWindow::askQuestion(std::string question)
{
history->addDialogText("#572D21"+question+"#B29154"+" ");
}
void DialogueWindow::updateOptions() void DialogueWindow::updateOptions()
{ {
//FIXME Add this properly
history->addDialogText("Through the translucent surface of the orb, you see shifting images of distant locations...");
for(int z = 0; z < 10; z++)
{
history->addDialogHeading("Fort Frostmoth");
history->addDialogText("The image in the orb flickers, and you see.... The cold courtyard of #FF0000Fort Frostmoth#FFFFFF, battered bu werewolf attack, but still standing, still projecting Imperial might even to this distant and cold corner of the world.");
}
//Clear the list of topics //Clear the list of topics
topicsList->removeAllItems(); topicsList->removeAllItems();
int i = 0; pTopicsText.clear();
topicsList->addItem("Ald'ruhn", i++); history->eraseText(0,history->getTextLength());
topicsList->addItem("Balmora", i++);
topicsList->addItem("Sadrith Mora", i++);
topicsList->addItem("Vivec", i++);
topicsList->addItem("Ald Velothi", i++);
topicsList->addItem("Caldera", i++);
topicsList->addItem("Dagon Fel ", i++);
topicsList->addItem("Gnaar Mok", i++);
topicsList->addItem("Gnisis", i++);
topicsList->addItem("Hla Oad", i++);
topicsList->addItem("Khuul", i++);
topicsList->addItem("Maar Gan", i++);
topicsList->addItem("Molag Mar", i++);
topicsList->addItem("Pelagiad", i++);
topicsList->addItem("Seyda Neen", i++);
topicsList->addItem("Suran", i++);
topicsList->addItem("Tel Aruhn", i++);
topicsList->addItem("Tel Branora", i++);
topicsList->addItem("Tel Fyr", i++);
topicsList->addItem("Tel Mora", i++);
topicsList->addItem("Tel Vos", i++);
topicsList->addItem("Vos", i++);
}
pDispositionBar->setProgressRange(100);
pDispositionBar->setProgressPosition(40);
pDispositionText->eraseText(0,pDispositionText->getTextLength());
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
}

View file

@ -9,6 +9,11 @@ namespace MWGui
class WindowManager; class WindowManager;
} }
namespace MWWorld
{
class Environment;
}
/* /*
This file contains the dialouge window This file contains the dialouge window
Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml. Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml.
@ -16,35 +21,52 @@ namespace MWGui
namespace MWGui namespace MWGui
{ {
class DialogeHistory; class DialogueHistory;
using namespace MyGUI; using namespace MyGUI;
class DialogueWindow: public WindowBase class DialogueWindow: public WindowBase
{ {
public: public:
DialogueWindow(WindowManager& parWindowManager); DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment);
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Dialog finished, OK button clicked.\n /** Event : Dialog finished, OK button clicked.\n
signature : void method()\n signature : void method()\n
*/ */
EventHandle_Void eventBye; EventHandle_Void eventBye;
void startDialogue(std::string npcName);
void stopDialogue();
void setKeywords(std::list<std::string> keyWord);
void removeKeyword(std::string keyWord);
void addText(std::string text);
void addTitle(std::string text);
void askQuestion(std::string question);
protected: protected:
void onSelectTopic(MyGUI::List* _sender, size_t _index); void onSelectTopic(MyGUI::ListBox* _sender, size_t _index);
void onByeClicked(MyGUI::Widget* _sender); void onByeClicked(MyGUI::Widget* _sender);
void onHistoryClicked(MyGUI::Widget* _sender); void onHistoryClicked(MyGUI::Widget* _sender);
private: private:
void updateOptions(); void updateOptions();
/**
*Helper function that add topic keyword in blue in a text.
*/
std::string parseText(std::string text);
DialogeHistory* history; DialogueHistory* history;
MyGUI::ListPtr topicsList; MyGUI::ListBox* topicsList;
MyGUI::ProgressPtr pDispositionBar;
MyGUI::EditPtr pDispositionText;
std::map<std::string,std::string> pTopicsText;// this map links keyword and "real" text.
MWWorld::Environment& mEnvironment;
}; };
} }
#endif #endif

View file

@ -13,10 +13,10 @@
using namespace MWGui; using namespace MWGui;
using namespace Widgets; using namespace Widgets;
UString DialogeHistory::getColorAtPos(size_t _pos) UString DialogueHistory::getColorAtPos(size_t _pos)
{ {
UString colour = TextIterator::convertTagColour(mText->getTextColour()); UString colour = TextIterator::convertTagColour(getTextColour());
TextIterator iterator(mText->getCaption()); TextIterator iterator(getCaption());
while(iterator.moveNext()) while(iterator.moveNext())
{ {
size_t pos = iterator.getPosition(); size_t pos = iterator.getPosition();
@ -29,12 +29,12 @@ UString DialogeHistory::getColorAtPos(size_t _pos)
return colour; return colour;
} }
UString DialogeHistory::getColorTextAt(size_t _pos) UString DialogueHistory::getColorTextAt(size_t _pos)
{ {
bool breakOnNext = false; bool breakOnNext = false;
UString colour = TextIterator::convertTagColour(mText->getTextColour()); UString colour = TextIterator::convertTagColour(getTextColour());
UString colour2 = colour; UString colour2 = colour;
TextIterator iterator(mText->getCaption()); TextIterator iterator(getCaption());
TextIterator col_start = iterator; TextIterator col_start = iterator;
while(iterator.moveNext()) while(iterator.moveNext())
{ {
@ -59,15 +59,15 @@ UString DialogeHistory::getColorTextAt(size_t _pos)
return ""; return "";
} }
void DialogeHistory::addDialogHeading(const UString& parText) void DialogueHistory::addDialogHeading(const UString& parText)
{ {
UString head("\n#00FF00"); UString head("\n#D8C09A");
head.append(parText); head.append(parText);
head.append("#FFFFFF\n"); head.append("#B29154\n");
addText(head); addText(head);
} }
void DialogeHistory::addDialogText(const UString& parText) void DialogueHistory::addDialogText(const UString& parText)
{ {
addText(parText); addText(parText);
addText("\n"); addText("\n");

View file

@ -5,9 +5,9 @@
namespace MWGui namespace MWGui
{ {
using namespace MyGUI; using namespace MyGUI;
class DialogeHistory : public MyGUI::Edit class DialogueHistory : public MyGUI::EditBox
{ {
MYGUI_RTTI_DERIVED( DialogeHistory ) MYGUI_RTTI_DERIVED( DialogueHistory )
public: public:
Widget* getClient() { return mClient; } Widget* getClient() { return mClient; }
UString getColorAtPos(size_t _pos); UString getColorAtPos(size_t _pos);

View file

@ -4,6 +4,8 @@
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwsound/soundmanager.hpp"
namespace namespace
{ {
struct book struct book
@ -87,9 +89,9 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
getWidget(mLeftTextWidget, "LeftText"); getWidget(mLeftTextWidget, "LeftText");
getWidget(mRightTextWidget, "RightText"); getWidget(mRightTextWidget, "RightText");
getWidget(mPrevBtn, "PrevPageBTN"); getWidget(mPrevBtn, "PrevPageBTN");
mPrevBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage); mPrevBtn->eventMouseButtonClick += MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage);
getWidget(mNextBtn, "NextPageBTN"); getWidget(mNextBtn, "NextPageBTN");
mNextBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyNextPage); mNextBtn->eventMouseButtonClick += MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyNextPage);
//MyGUI::ItemBox* list = new MyGUI::ItemBox(); //MyGUI::ItemBox* list = new MyGUI::ItemBox();
//list->addItem("qaq","aqzazaz"); //list->addItem("qaq","aqzazaz");
//mScrollerWidget->addChildItem(list); //mScrollerWidget->addChildItem(list);
@ -109,12 +111,14 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
//displayLeftText(list.front()); //displayLeftText(list.front());
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget); MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
t->eventWindowChangeCoord = MyGUI::newDelegate(this, &JournalWindow::onWindowResize); t->eventWindowChangeCoord += MyGUI::newDelegate(this, &JournalWindow::onWindowResize);
} }
void MWGui::JournalWindow::open() void MWGui::JournalWindow::open()
{ {
mPageNumber = 0; mPageNumber = 0;
std::string journalOpenSound = "book open";
mWindowManager.getEnvironment().mSoundManager->playSound (journalOpenSound, 1.0, 1.0);
if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end()) if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end())
{ {
book journal; book journal;
@ -176,6 +180,8 @@ void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
{ {
if(mPageNumber < int(leftPages.size())-1) if(mPageNumber < int(leftPages.size())-1)
{ {
std::string nextSound = "book page2";
mWindowManager.getEnvironment().mSoundManager->playSound (nextSound, 1.0, 1.0);
mPageNumber = mPageNumber + 1; mPageNumber = mPageNumber + 1;
displayLeftText(leftPages[mPageNumber]); displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]); displayRightText(rightPages[mPageNumber]);
@ -186,6 +192,8 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender)
{ {
if(mPageNumber > 0) if(mPageNumber > 0)
{ {
std::string prevSound = "book page";
mWindowManager.getEnvironment().mSoundManager->playSound (prevSound, 1.0, 1.0);
mPageNumber = mPageNumber - 1; mPageNumber = mPageNumber - 1;
displayLeftText(leftPages[mPageNumber]); displayLeftText(leftPages[mPageNumber]);
displayRightText(rightPages[mPageNumber]); displayRightText(rightPages[mPageNumber]);

View file

@ -41,7 +41,7 @@ namespace MWGui
static const int lineHeight; static const int lineHeight;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
MyGUI::VScrollPtr skillScrollerWidget; MyGUI::ScrollBar* skillScrollerWidget;
int lastPos, clientHeight; int lastPos, clientHeight;
MyGUI::EditPtr mLeftTextWidget; MyGUI::EditPtr mLeftTextWidget;
MyGUI::EditPtr mRightTextWidget; MyGUI::EditPtr mRightTextWidget;
@ -54,4 +54,4 @@ namespace MWGui
} }
#endif #endif

View file

@ -45,18 +45,18 @@ namespace MWGui
void setBatchCount(size_t count); void setBatchCount(size_t count);
MyGUI::ProgressPtr health, magicka, stamina; MyGUI::ProgressPtr health, magicka, stamina;
MyGUI::StaticImagePtr weapImage, spellImage; MyGUI::ImageBox *weapImage, *spellImage;
MyGUI::ProgressPtr weapStatus, spellStatus; MyGUI::ProgressPtr weapStatus, spellStatus;
MyGUI::WidgetPtr effectBox; MyGUI::WidgetPtr effectBox;
MyGUI::StaticImagePtr effect1; MyGUI::ImageBox* effect1;
MyGUI::StaticImagePtr minimap; MyGUI::ImageBox* minimap;
MyGUI::StaticImagePtr compass; MyGUI::ImageBox* compass;
MyGUI::StaticImagePtr crosshair; MyGUI::ImageBox* crosshair;
MyGUI::WidgetPtr fpsbox; MyGUI::WidgetPtr fpsbox;
MyGUI::StaticTextPtr fpscounter; MyGUI::TextBox* fpscounter;
MyGUI::StaticTextPtr trianglecounter; MyGUI::TextBox* trianglecounter;
MyGUI::StaticTextPtr batchcounter; MyGUI::TextBox* batchcounter;
}; };
class MapWindow : public OEngine::GUI::Layout class MapWindow : public OEngine::GUI::Layout
@ -75,7 +75,7 @@ namespace MWGui
void setCellName(const std::string& cellName) void setCellName(const std::string& cellName)
{ {
mMainWidget->setCaption(cellName); static_cast<MyGUI::Window*>(mMainWidget)->setCaption(cellName);
} }
}; };
@ -127,7 +127,7 @@ namespace MWGui
getWidget(avatar, "Avatar"); getWidget(avatar, "Avatar");
// Adjust armor rating text to bottom of avatar widget // Adjust armor rating text to bottom of avatar widget
MyGUI::StaticTextPtr armor_rating; MyGUI::TextBox* armor_rating;
getWidget(armor_rating, "ArmorRating"); getWidget(armor_rating, "ArmorRating");
armor_rating->setCaption("Armor: 11"); armor_rating->setCaption("Armor: 11");
MyGUI::IntCoord coord = armor_rating->getCoord(); MyGUI::IntCoord coord = armor_rating->getCoord();
@ -165,7 +165,7 @@ namespace MWGui
last_x += coord.width + margin; last_x += coord.width + margin;
button_pt->setCoord(coord); button_pt->setCoord(coord);
button_pt->eventMouseButtonClick = MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected); button_pt->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected);
} }
} }

View file

@ -19,7 +19,7 @@ void MessageBoxManager::onFrame (float frameDuration)
if(it->current >= it->max) if(it->current >= it->max)
{ {
it->messageBox->mMarkedToDelete = true; it->messageBox->mMarkedToDelete = true;
if(*mMessageBoxes.begin() == it->messageBox) // if this box is the last one if(*mMessageBoxes.begin() == it->messageBox) // if this box is the last one
{ {
// collect all with mMarkedToDelete and delete them. // collect all with mMarkedToDelete and delete them.
@ -47,7 +47,7 @@ void MessageBoxManager::onFrame (float frameDuration)
it++; it++;
} }
} }
if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) { if(mInterMessageBoxe != NULL && mInterMessageBoxe->mMarkedToDelete) {
delete mInterMessageBoxe; delete mInterMessageBoxe;
mInterMessageBoxe = NULL; mInterMessageBoxe = NULL;
@ -57,20 +57,18 @@ void MessageBoxManager::onFrame (float frameDuration)
void MessageBoxManager::createMessageBox (const std::string& message) void MessageBoxManager::createMessageBox (const std::string& message)
{ {
std::cout << "MessageBox: " << message << std::endl;
MessageBox *box = new MessageBox(*this, message); MessageBox *box = new MessageBox(*this, message);
removeMessageBox(message.length()*mMessageBoxSpeed, box); removeMessageBox(message.length()*mMessageBoxSpeed, box);
mMessageBoxes.push_back(box); mMessageBoxes.push_back(box);
std::vector<MessageBox*>::iterator it; std::vector<MessageBox*>::iterator it;
if(mMessageBoxes.size() > 3) { if(mMessageBoxes.size() > 3) {
delete *mMessageBoxes.begin(); delete *mMessageBoxes.begin();
mMessageBoxes.erase(mMessageBoxes.begin()); mMessageBoxes.erase(mMessageBoxes.begin());
} }
int height = 0; int height = 0;
for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it) for(it = mMessageBoxes.begin(); it != mMessageBoxes.end(); ++it)
{ {
@ -88,9 +86,9 @@ bool MessageBoxManager::createInteractiveMessageBox (const std::string& message,
std::cout << "interactive MessageBox: " << message << " - "; std::cout << "interactive MessageBox: " << message << " - ";
std::copy (buttons.begin(), buttons.end(), std::ostream_iterator<std::string> (std::cout, ", ")); std::copy (buttons.begin(), buttons.end(), std::ostream_iterator<std::string> (std::cout, ", "));
std::cout << std::endl; std::cout << std::endl;
mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons); mInterMessageBoxe = new InteractiveMessageBox(*this, message, buttons);
return true; return true;
} }
@ -105,7 +103,7 @@ void MessageBoxManager::removeMessageBox (float time, MessageBox *msgbox)
timer.current = 0; timer.current = 0;
timer.max = time; timer.max = time;
timer.messageBox = msgbox; timer.messageBox = msgbox;
mTimers.insert(mTimers.end(), timer); mTimers.insert(mTimers.end(), timer);
} }
@ -152,25 +150,26 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
mBottomPadding = 20; mBottomPadding = 20;
mNextBoxPadding = 20; mNextBoxPadding = 20;
mMarkedToDelete = false; mMarkedToDelete = false;
getWidget(mMessageWidget, "message"); getWidget(mMessageWidget, "message");
mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->setOverflowToTheLeft(true);
mMessageWidget->addText(cMessage); mMessageWidget->addText(cMessage);
MyGUI::IntSize size; MyGUI::IntSize size;
size.width = mFixedWidth; size.width = mFixedWidth;
size.height = 100; // dummy size.height = 100; // dummy
MyGUI::IntCoord coord; MyGUI::IntCoord coord;
coord.left = 10; // dummy coord.left = 10; // dummy
coord.top = 10; // dummy coord.top = 10; // dummy
mMessageWidget->setSize(size); mMessageWidget->setSize(size);
MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); MyGUI::IntSize textSize = mMessageWidget->getTextSize();
size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box
mMainWidget->setSize(size); mMainWidget->setSize(size);
size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0") size.width -= 15; // this is to center the text (see messagebox_layout.xml, Widget type="Edit" position="-2 -3 0 0")
mMessageWidget->setSize(size); mMessageWidget->setSize(size);
@ -178,15 +177,15 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
void MessageBox::update (int height) void MessageBox::update (int height)
{ {
MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::IntCoord coord; MyGUI::IntCoord coord;
coord.left = (gameWindowSize.width - mFixedWidth)/2; coord.left = (gameWindowSize.width - mFixedWidth)/2;
coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding); coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding);
MyGUI::IntSize size; MyGUI::IntSize size;
size.width = mFixedWidth; size.width = mFixedWidth;
size.height = mHeight; size.height = mHeight;
mMainWidget->setCoord(coord); mMainWidget->setCoord(coord);
mMainWidget->setSize(size); mMainWidget->setSize(size);
mMainWidget->setVisible(true); mMainWidget->setVisible(true);
@ -211,26 +210,26 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
int buttonTopPadding = 5; // ^-- if vertical int buttonTopPadding = 5; // ^-- if vertical
int buttonPadding = 5; // padding between button label and button itself int buttonPadding = 5; // padding between button label and button itself
int buttonMainPadding = 10; // padding between buttons and bottom of the main widget int buttonMainPadding = 10; // padding between buttons and bottom of the main widget
mMarkedToDelete = false; mMarkedToDelete = false;
getWidget(mMessageWidget, "message"); getWidget(mMessageWidget, "message");
getWidget(mButtonsWidget, "buttons"); getWidget(mButtonsWidget, "buttons");
mMessageWidget->setOverflowToTheLeft(true); mMessageWidget->setOverflowToTheLeft(true);
mMessageWidget->addText(message); mMessageWidget->addText(message);
MyGUI::IntSize textSize = mMessageWidget->_getTextSize(); MyGUI::IntSize textSize = mMessageWidget->getTextSize();
MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize(); MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
int biggestButtonWidth = 0; int biggestButtonWidth = 0;
int buttonWidth = 0; int buttonWidth = 0;
int buttonsWidth = 0; int buttonsWidth = 0;
int buttonHeight = 0; int buttonHeight = 0;
MyGUI::IntCoord dummyCoord(0, 0, 0, 0); MyGUI::IntCoord dummyCoord(0, 0, 0, 0);
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
for(it = buttons.begin(); it != buttons.end(); ++it) for(it = buttons.begin(); it != buttons.end(); ++it)
{ {
@ -240,28 +239,28 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
dummyCoord, dummyCoord,
MyGUI::Align::Default); MyGUI::Align::Default);
button->setCaption(*it); button->setCaption(*it);
button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed); button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
mButtons.push_back(button); mButtons.push_back(button);
buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding; buttonWidth = button->getTextSize().width + 2*buttonPadding + buttonLeftPadding;
buttonsWidth += buttonWidth; buttonsWidth += buttonWidth;
buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding; buttonHeight = button->getTextSize().height + 2*buttonPadding + buttonTopPadding;
if(buttonWidth > biggestButtonWidth) if(buttonWidth > biggestButtonWidth)
{ {
biggestButtonWidth = buttonWidth; biggestButtonWidth = buttonWidth;
} }
} }
buttonsWidth += buttonLeftPadding; buttonsWidth += buttonLeftPadding;
MyGUI::IntSize mainWidgetSize; MyGUI::IntSize mainWidgetSize;
if(buttonsWidth < fixedWidth) if(buttonsWidth < fixedWidth)
{ {
// on one line // on one line
std::cout << "on one line" << std::endl; std::cout << "on one line" << std::endl;
if(textSize.width + 2*textPadding < buttonsWidth) if(textSize.width + 2*textPadding < buttonsWidth)
{ {
std::cout << "width = buttonsWidth" << std::endl; std::cout << "width = buttonsWidth" << std::endl;
@ -272,48 +271,48 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
mainWidgetSize.width = textSize.width + 3*textPadding; mainWidgetSize.width = textSize.width + 3*textPadding;
} }
mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight + buttonMainPadding; mainWidgetSize.height = textSize.height + textButtonPadding + buttonHeight + buttonMainPadding;
MyGUI::IntCoord absCoord; MyGUI::IntCoord absCoord;
absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2;
absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2;
std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl;
std::cout << "left " << absCoord.left << " top " << absCoord.top << std::endl; std::cout << "left " << absCoord.left << " top " << absCoord.top << std::endl;
mMainWidget->setCoord(absCoord); mMainWidget->setCoord(absCoord);
mMainWidget->setSize(mainWidgetSize); mMainWidget->setSize(mainWidgetSize);
MyGUI::IntCoord messageWidgetCoord; MyGUI::IntCoord messageWidgetCoord;
messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2;
messageWidgetCoord.top = textPadding; messageWidgetCoord.top = textPadding;
mMessageWidget->setCoord(messageWidgetCoord); mMessageWidget->setCoord(messageWidgetCoord);
mMessageWidget->setSize(textSize); mMessageWidget->setSize(textSize);
MyGUI::IntCoord buttonCord; MyGUI::IntCoord buttonCord;
MyGUI::IntSize buttonSize(0, buttonHeight); MyGUI::IntSize buttonSize(0, buttonHeight);
int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding; int left = (mainWidgetSize.width - buttonsWidth)/2 + buttonPadding;
std::vector<MyGUI::ButtonPtr>::const_iterator button; std::vector<MyGUI::ButtonPtr>::const_iterator button;
for(button = mButtons.begin(); button != mButtons.end(); ++button) for(button = mButtons.begin(); button != mButtons.end(); ++button)
{ {
buttonCord.left = left; buttonCord.left = left;
buttonCord.top = textSize.height + textButtonPadding; buttonCord.top = textSize.height + textButtonPadding;
buttonSize.width = (*button)->_getTextSize().width + 2*buttonPadding; buttonSize.width = (*button)->getTextSize().width + 2*buttonPadding;
buttonSize.height = (*button)->_getTextSize().height + 2*buttonPadding; buttonSize.height = (*button)->getTextSize().height + 2*buttonPadding;
(*button)->setCoord(buttonCord); (*button)->setCoord(buttonCord);
(*button)->setSize(buttonSize); (*button)->setSize(buttonSize);
left += buttonSize.width + buttonLeftPadding; left += buttonSize.width + buttonLeftPadding;
} }
} }
else else
{ {
// among each other // among each other
if(biggestButtonWidth > textSize.width) { if(biggestButtonWidth > textSize.width) {
mainWidgetSize.width = biggestButtonWidth + buttonTopPadding; mainWidgetSize.width = biggestButtonWidth + buttonTopPadding;
} }
@ -321,46 +320,46 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
mainWidgetSize.width = textSize.width + 3*textPadding; mainWidgetSize.width = textSize.width + 3*textPadding;
} }
mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size() + buttonMainPadding; mainWidgetSize.height = textSize.height + 2*textPadding + textButtonPadding + buttonHeight * buttons.size() + buttonMainPadding;
std::cout << "biggestButtonWidth " << biggestButtonWidth << " textSize.width " << textSize.width << std::endl; std::cout << "biggestButtonWidth " << biggestButtonWidth << " textSize.width " << textSize.width << std::endl;
std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl; std::cout << "width " << mainWidgetSize.width << " height " << mainWidgetSize.height << std::endl;
mMainWidget->setSize(mainWidgetSize); mMainWidget->setSize(mainWidgetSize);
MyGUI::IntCoord absCoord; MyGUI::IntCoord absCoord;
absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2; absCoord.left = (gameWindowSize.width - mainWidgetSize.width)/2;
absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2; absCoord.top = (gameWindowSize.height - mainWidgetSize.height)/2;
mMainWidget->setCoord(absCoord); mMainWidget->setCoord(absCoord);
mMainWidget->setSize(mainWidgetSize); mMainWidget->setSize(mainWidgetSize);
MyGUI::IntCoord messageWidgetCoord; MyGUI::IntCoord messageWidgetCoord;
messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2; messageWidgetCoord.left = (mainWidgetSize.width - textSize.width)/2;
messageWidgetCoord.top = textPadding; messageWidgetCoord.top = textPadding;
mMessageWidget->setCoord(messageWidgetCoord); mMessageWidget->setCoord(messageWidgetCoord);
mMessageWidget->setSize(textSize); mMessageWidget->setSize(textSize);
MyGUI::IntCoord buttonCord; MyGUI::IntCoord buttonCord;
MyGUI::IntSize buttonSize(0, buttonHeight); MyGUI::IntSize buttonSize(0, buttonHeight);
int top = textButtonPadding + buttonTopPadding + textSize.height; int top = textButtonPadding + buttonTopPadding + textSize.height;
std::vector<MyGUI::ButtonPtr>::const_iterator button; std::vector<MyGUI::ButtonPtr>::const_iterator button;
for(button = mButtons.begin(); button != mButtons.end(); ++button) for(button = mButtons.begin(); button != mButtons.end(); ++button)
{ {
buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2; buttonSize.width = (*button)->getTextSize().width + buttonPadding*2;
buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2; buttonSize.height = (*button)->getTextSize().height + buttonPadding*2;
buttonCord.top = top; buttonCord.top = top;
buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/ buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/
(*button)->setCoord(buttonCord); (*button)->setCoord(buttonCord);
(*button)->setSize(buttonSize); (*button)->setSize(buttonSize);
top += buttonSize.height + 2*buttonTopPadding; top += buttonSize.height + 2*buttonTopPadding;
} }
} }
} }
@ -387,8 +386,3 @@ int InteractiveMessageBox::readPressedButton ()
mButtonPressed = -1; mButtonPressed = -1;
return pressed; return pressed;
} }

View file

@ -34,7 +34,7 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
headRotate->setScrollRange(50); headRotate->setScrollRange(50);
headRotate->setScrollPosition(20); headRotate->setScrollPosition(20);
headRotate->setScrollViewPage(10); headRotate->setScrollViewPage(10);
headRotate->eventScrollChangePosition = MyGUI::newDelegate(this, &RaceDialog::onHeadRotate); headRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
// Set up next/previous buttons // Set up next/previous buttons
MyGUI::ButtonPtr prevButton, nextButton; MyGUI::ButtonPtr prevButton, nextButton;
@ -42,27 +42,27 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex")); setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex"));
getWidget(prevButton, "PrevGenderButton"); getWidget(prevButton, "PrevGenderButton");
getWidget(nextButton, "NextGenderButton"); getWidget(nextButton, "NextGenderButton");
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender); prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face")); setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face"));
getWidget(prevButton, "PrevFaceButton"); getWidget(prevButton, "PrevFaceButton");
getWidget(nextButton, "NextFaceButton"); getWidget(nextButton, "NextFaceButton");
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace); prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Hair")); setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Hair"));
getWidget(prevButton, "PrevHairButton"); getWidget(prevButton, "PrevHairButton");
getWidget(nextButton, "NextHairButton"); getWidget(nextButton, "NextHairButton");
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair); prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair); nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race")); setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race"));
getWidget(raceList, "RaceList"); getWidget(raceList, "RaceList");
raceList->setScrollVisible(true); raceList->setScrollVisible(true);
raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace); raceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus")); setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
getWidget(skillList, "SkillList"); getWidget(skillList, "SkillList");
@ -72,11 +72,11 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
updateRaces(); updateRaces();
updateSkills(); updateSkills();
@ -157,7 +157,7 @@ void RaceDialog::onBackClicked(MyGUI::Widget* _sender)
eventBack(); eventBack();
} }
void RaceDialog::onHeadRotate(MyGUI::VScroll*, size_t _position) void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position)
{ {
// TODO: Rotate head // TODO: Rotate head
} }
@ -192,7 +192,7 @@ void RaceDialog::onSelectNextHair(MyGUI::Widget*)
hairIndex = wrap(hairIndex - 1, hairCount); hairIndex = wrap(hairIndex - 1, hairCount);
} }
void RaceDialog::onSelectRace(MyGUI::List* _sender, size_t _index) void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
{ {
if (_index == MyGUI::ITEM_NONE) if (_index == MyGUI::ITEM_NONE)
return; return;

View file

@ -46,7 +46,7 @@ namespace MWGui
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n
@ -54,7 +54,7 @@ namespace MWGui
EventHandle_Void eventBack; EventHandle_Void eventBack;
protected: protected:
void onHeadRotate(MyGUI::VScroll* _sender, size_t _position); void onHeadRotate(MyGUI::ScrollBar* _sender, size_t _position);
void onSelectPreviousGender(MyGUI::Widget* _sender); void onSelectPreviousGender(MyGUI::Widget* _sender);
void onSelectNextGender(MyGUI::Widget* _sender); void onSelectNextGender(MyGUI::Widget* _sender);
@ -65,7 +65,7 @@ namespace MWGui
void onSelectPreviousHair(MyGUI::Widget* _sender); void onSelectPreviousHair(MyGUI::Widget* _sender);
void onSelectNextHair(MyGUI::Widget* _sender); void onSelectNextHair(MyGUI::Widget* _sender);
void onSelectRace(MyGUI::List* _sender, size_t _index); void onSelectRace(MyGUI::ListBox* _sender, size_t _index);
void onOkClicked(MyGUI::Widget* _sender); void onOkClicked(MyGUI::Widget* _sender);
void onBackClicked(MyGUI::Widget* _sender); void onBackClicked(MyGUI::Widget* _sender);
@ -76,8 +76,8 @@ namespace MWGui
void updateSpellPowers(); void updateSpellPowers();
MyGUI::CanvasPtr appearanceBox; MyGUI::CanvasPtr appearanceBox;
MyGUI::ListPtr raceList; MyGUI::ListBox* raceList;
MyGUI::HScrollPtr headRotate; MyGUI::ScrollBar* headRotate;
MyGUI::WidgetPtr skillList; MyGUI::WidgetPtr skillList;
std::vector<MyGUI::WidgetPtr> skillItems; std::vector<MyGUI::WidgetPtr> skillItems;

View file

@ -28,22 +28,22 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
getWidget(nameWidget, "NameText"); getWidget(nameWidget, "NameText");
getWidget(button, "NameButton"); getWidget(button, "NameButton");
button->setCaption(mWindowManager.getGameSettingString("sName", "")); button->setCaption(mWindowManager.getGameSettingString("sName", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
getWidget(raceWidget, "RaceText"); getWidget(raceWidget, "RaceText");
getWidget(button, "RaceButton"); getWidget(button, "RaceButton");
button->setCaption(mWindowManager.getGameSettingString("sRace", "")); button->setCaption(mWindowManager.getGameSettingString("sRace", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
getWidget(classWidget, "ClassText"); getWidget(classWidget, "ClassText");
getWidget(button, "ClassButton"); getWidget(button, "ClassButton");
button->setCaption(mWindowManager.getGameSettingString("sClass", "")); button->setCaption(mWindowManager.getGameSettingString("sClass", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
getWidget(birthSignWidget, "SignText"); getWidget(birthSignWidget, "SignText");
getWidget(button, "SignButton"); getWidget(button, "SignButton");
button->setCaption(mWindowManager.getGameSettingString("sBirthSign", "")); button->setCaption(mWindowManager.getGameSettingString("sBirthSign", ""));
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);; button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
// Setup dynamic stats // Setup dynamic stats
getWidget(health, "Health"); getWidget(health, "Health");
@ -75,25 +75,25 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
getWidget(skillClientWidget, "SkillClient"); getWidget(skillClientWidget, "SkillClient");
getWidget(skillScrollerWidget, "SkillScroller"); getWidget(skillScrollerWidget, "SkillScroller");
skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition); skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition);
updateScroller(); updateScroller();
for (int i = 0; i < ESM::Skill::Length; ++i) for (int i = 0; i < ESM::Skill::Length; ++i)
{ {
skillValues.insert(std::make_pair(i, MWMechanics::Stat<float>())); skillValues.insert(std::make_pair(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::StaticText*> (0))); skillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::TextBox*> (0)));
} }
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize); static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr backButton; MyGUI::ButtonPtr backButton;
getWidget(backButton, "BackButton"); getWidget(backButton, "BackButton");
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBackClicked); backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked);
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked);
} }
void ReviewDialog::open() void ReviewDialog::open()
@ -102,7 +102,7 @@ void ReviewDialog::open()
setVisible(true); setVisible(true);
} }
void ReviewDialog::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos) void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
{ {
int diff = lastPos - pos; int diff = lastPos - pos;
// Adjust position of all widget according to difference // Adjust position of all widget according to difference
@ -176,7 +176,7 @@ void ReviewDialog::setAttribute(ESM::Attribute::AttributeID attributeId, const M
void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value) void ReviewDialog::setSkillValue(ESM::Skill::SkillEnum skillId, const MWMechanics::Stat<float>& value)
{ {
skillValues[skillId] = value; skillValues[skillId] = value;
MyGUI::StaticTextPtr widget = skillWidgetMap[skillId]; MyGUI::TextBox* widget = skillWidgetMap[skillId];
if (widget) if (widget)
{ {
float modified = value.getModified(), base = value.getBase(); float modified = value.getModified(), base = value.getBase();
@ -210,7 +210,7 @@ void ReviewDialog::configureSkills(const std::vector<int>& major, const std::vec
} }
} }
void ReviewDialog::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value) void ReviewDialog::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value)
{ {
widget->setCaption(value); widget->setCaption(value);
if (style == CS_Super) if (style == CS_Super)
@ -223,7 +223,7 @@ void ReviewDialog::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style,
void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticImagePtr separator = skillClientWidget->createWidget<MyGUI::StaticImage>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); MyGUI::ImageBox* separator = skillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default);
skillWidgets.push_back(separator); skillWidgets.push_back(separator);
coord1.top += separator->getHeight(); coord1.top += separator->getHeight();
@ -232,7 +232,7 @@ void ReviewDialog::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2
void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticTextPtr groupWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); MyGUI::TextBox* groupWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
groupWidget->setCaption(label); groupWidget->setCaption(label);
skillWidgets.push_back(groupWidget); skillWidgets.push_back(groupWidget);
@ -240,14 +240,15 @@ void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, M
coord2.top += lineHeight; coord2.top += lineHeight;
} }
MyGUI::StaticTextPtr ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::TextBox* ReviewDialog::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticTextPtr skillNameWidget, skillValueWidget; MyGUI::TextBox* skillNameWidget;
MyGUI::TextBox* skillValueWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1, MyGUI::Align::Default); skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillValueWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default); skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
setStyledText(skillValueWidget, style, value); setStyledText(skillValueWidget, style, value);
skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillNameWidget);
@ -261,9 +262,9 @@ MyGUI::StaticTextPtr ReviewDialog::addValueItem(const std::string text, const st
void ReviewDialog::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticTextPtr skillNameWidget; MyGUI::TextBox* skillNameWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillNameWidget);
@ -299,7 +300,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
style = CS_Super; style = CS_Super;
else if (modified < base) else if (modified < base)
style = CS_Sub; style = CS_Sub;
MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2); MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
skillWidgetMap[skillId] = widget; skillWidgetMap[skillId] = widget;
} }
} }

View file

@ -49,8 +49,8 @@ namespace MWGui
void open(); void open();
// Events // Events
typedef delegates::CDelegate0 EventHandle_Void; typedef delegates::CMultiDelegate0 EventHandle_Void;
typedef delegates::CDelegate1<int> EventHandle_Int; typedef delegates::CMultiDelegate1<int> EventHandle_Int;
/** Event : Back button clicked.\n /** Event : Back button clicked.\n
signature : void method()\n signature : void method()\n
@ -75,23 +75,23 @@ namespace MWGui
CS_Normal, CS_Normal,
CS_Super CS_Super
}; };
void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value); void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value);
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::StaticTextPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateScroller(); void updateScroller();
void updateSkillArea(); void updateSkillArea();
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos); void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
void onWindowResize(MyGUI::Window* window); void onWindowResize(MyGUI::Window* window);
static const int lineHeight; static const int lineHeight;
MyGUI::StaticTextPtr nameWidget, raceWidget, classWidget, birthSignWidget; MyGUI::TextBox *nameWidget, *raceWidget, *classWidget, *birthSignWidget;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
MyGUI::VScrollPtr skillScrollerWidget; MyGUI::ScrollBar* skillScrollerWidget;
int lastPos, clientHeight; int lastPos, clientHeight;
Widgets::MWDynamicStatPtr health, magicka, fatigue; Widgets::MWDynamicStatPtr health, magicka, fatigue;
@ -100,7 +100,7 @@ namespace MWGui
SkillList majorSkills, minorSkills, miscSkills; SkillList majorSkills, minorSkills, miscSkills;
std::map<int, MWMechanics::Stat<float> > skillValues; std::map<int, MWMechanics::Stat<float> > skillValues;
std::map<int, MyGUI::StaticTextPtr> skillWidgetMap; std::map<int, MyGUI::TextBox*> skillWidgetMap;
std::string name, raceId, birthSignId; std::string name, raceId, birthSignId;
ESM::Class klass; ESM::Class klass;
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information

View file

@ -48,20 +48,20 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
getWidget(skillClientWidget, "SkillClient"); getWidget(skillClientWidget, "SkillClient");
getWidget(skillScrollerWidget, "SkillScroller"); getWidget(skillScrollerWidget, "SkillScroller");
skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition); skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
updateScroller(); updateScroller();
for (int i = 0; i < ESM::Skill::Length; ++i) for (int i = 0; i < ESM::Skill::Length; ++i)
{ {
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>())); skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr)); skillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, nullptr));
} }
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget); MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
t->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize); t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
} }
void StatsWindow::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos) void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
{ {
int diff = lastPos - pos; int diff = lastPos - pos;
// Adjust position of all widget according to difference // Adjust position of all widget according to difference
@ -95,10 +95,10 @@ void StatsWindow::setBar(const std::string& name, const std::string& tname, int
void StatsWindow::setPlayerName(const std::string& playerName) void StatsWindow::setPlayerName(const std::string& playerName)
{ {
mMainWidget->setCaption(playerName); static_cast<MyGUI::Window*>(mMainWidget)->setCaption(playerName);
} }
void StatsWindow::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value) void StatsWindow::setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value)
{ {
widget->setCaption(value); widget->setCaption(value);
if (style == CS_Super) if (style == CS_Super)
@ -175,7 +175,7 @@ void StatsWindow::setValue (const std::string& id, int value)
void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value) void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
{ {
skillValues[parSkill] = value; skillValues[parSkill] = value;
MyGUI::StaticTextPtr widget = skillWidgetMap[(int)parSkill]; MyGUI::TextBox* widget = skillWidgetMap[(int)parSkill];
if (widget) if (widget)
{ {
float modified = value.getModified(), base = value.getBase(); float modified = value.getModified(), base = value.getBase();
@ -221,7 +221,7 @@ void StatsWindow::setBirthSign (const std::string& signId)
void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticImagePtr separator = skillClientWidget->createWidget<MyGUI::StaticImage>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default); MyGUI::ImageBox* separator = skillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default);
skillWidgets.push_back(separator); skillWidgets.push_back(separator);
coord1.top += separator->getHeight(); coord1.top += separator->getHeight();
@ -230,7 +230,7 @@ void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticTextPtr groupWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default); MyGUI::TextBox* groupWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
groupWidget->setCaption(label); groupWidget->setCaption(label);
skillWidgets.push_back(groupWidget); skillWidgets.push_back(groupWidget);
@ -238,14 +238,14 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My
coord2.top += lineHeight; coord2.top += lineHeight;
} }
MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticTextPtr skillNameWidget, skillValueWidget; MyGUI::TextBox *skillNameWidget, *skillValueWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1, MyGUI::Align::Default); skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillValueWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default); skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
setStyledText(skillValueWidget, style, value); setStyledText(skillValueWidget, style, value);
skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillNameWidget);
@ -259,9 +259,9 @@ MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std
void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::StaticTextPtr skillNameWidget; MyGUI::TextBox* skillNameWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default); skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillNameWidget);
@ -297,7 +297,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
style = CS_Super; style = CS_Super;
else if (modified < base) else if (modified < base)
style = CS_Sub; style = CS_Sub;
MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2); MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
skillWidgetMap[skillId] = widget; skillWidgetMap[skillId] = widget;
} }
} }

View file

@ -49,26 +49,26 @@ namespace MWGui
CS_Normal, CS_Normal,
CS_Super CS_Super
}; };
void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value); void setStyledText(MyGUI::TextBox* widget, ColorStyle style, const std::string &value);
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::StaticTextPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateScroller(); void updateScroller();
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos); void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
void onWindowResize(MyGUI::Window* window); void onWindowResize(MyGUI::Window* window);
static const int lineHeight; static const int lineHeight;
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget; MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
MyGUI::VScrollPtr skillScrollerWidget; MyGUI::ScrollBar* skillScrollerWidget;
int lastPos, clientHeight; int lastPos, clientHeight;
SkillList majorSkills, minorSkills, miscSkills; SkillList majorSkills, minorSkills, miscSkills;
std::map<int, MWMechanics::Stat<float> > skillValues; std::map<int, MWMechanics::Stat<float> > skillValues;
std::map<int, MyGUI::StaticTextPtr> skillWidgetMap; std::map<int, MyGUI::TextBox*> skillWidgetMap;
std::map<std::string, MyGUI::WidgetPtr> factionWidgetMap; std::map<std::string, MyGUI::WidgetPtr> factionWidgetMap;
FactionList factions; ///< Stores a list of factions and the current rank FactionList factions; ///< Stores a list of factions and the current rank
std::string birthSignId; std::string birthSignId;

View file

@ -10,12 +10,12 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
center(); center();
getWidget(textEdit, "TextEdit"); getWidget(textEdit, "TextEdit");
textEdit->eventEditSelectAccept = newDelegate(this, &TextInputDialog::onTextAccepted); textEdit->eventEditSelectAccept += newDelegate(this, &TextInputDialog::onTextAccepted);
// TODO: These buttons should be managed by a Dialog class // TODO: These buttons should be managed by a Dialog class
MyGUI::ButtonPtr okButton; MyGUI::ButtonPtr okButton;
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &TextInputDialog::onOkClicked); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TextInputDialog::onOkClicked);
// Make sure the edit box has focus // Make sure the edit box has focus
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit); MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);

View file

@ -62,24 +62,24 @@ void MWSkill::updateWidgets()
{ {
if (skillId == ESM::Skill::Length) if (skillId == ESM::Skill::Length)
{ {
skillNameWidget->setCaption(""); static_cast<MyGUI::TextBox*>(skillNameWidget)->setCaption("");
} }
else else
{ {
const std::string &name = manager->getGameSettingString(ESM::Skill::sSkillNameIds[skillId], ""); const std::string &name = manager->getGameSettingString(ESM::Skill::sSkillNameIds[skillId], "");
skillNameWidget->setCaption(name); static_cast<MyGUI::TextBox*>(skillNameWidget)->setCaption(name);
} }
} }
if (skillValueWidget) if (skillValueWidget)
{ {
SkillValue::Type modified = value.getModified(), base = value.getBase(); SkillValue::Type modified = value.getModified(), base = value.getBase();
skillValueWidget->setCaption(boost::lexical_cast<std::string>(modified)); static_cast<MyGUI::TextBox*>(skillValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base) if (modified > base)
skillValueWidget->setState("increased"); skillValueWidget->_setWidgetState("increased");
else if (modified < base) else if (modified < base)
skillValueWidget->setState("decreased"); skillValueWidget->_setWidgetState("decreased");
else else
skillValueWidget->setState("normal"); skillValueWidget->_setWidgetState("normal");
} }
} }
@ -88,59 +88,32 @@ void MWSkill::onClicked(MyGUI::Widget* _sender)
eventClicked(this); eventClicked(this);
} }
void MWSkill::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info);
}
MWSkill::~MWSkill() MWSkill::~MWSkill()
{ {
shutdownWidgetSkin();
} }
void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info) void MWSkill::initialiseOverride()
{ {
shutdownWidgetSkin(); Base::initialiseOverride();
Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info);
}
void MWSkill::initialiseWidgetSkin(ResourceSkin* _info) assignWidget(skillNameWidget, "StatName");
{ assignWidget(skillValueWidget, "StatValue");
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
MyGUI::ButtonPtr button;
assignWidget(button, "StatNameButton");
if (button)
{ {
const std::string &name = *(*iter)->_getInternalData<std::string>(); skillNameWidget = button;
if (name == "StatName") button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked);
{
MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned");
skillNameWidget = (*iter)->castType<StaticText>();
}
else if (name == "StatValue")
{
MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned");
skillValueWidget = (*iter)->castType<StaticText>();
}
else if (name == "StatNameButton")
{
MYGUI_DEBUG_ASSERT( ! skillNameWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>();
skillNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWSkill::onClicked);
}
else if (name == "StatValueButton")
{
MYGUI_DEBUG_ASSERT( ! skillValueWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>();
skillNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWSkill::onClicked);
}
} }
}
void MWSkill::shutdownWidgetSkin() button = 0;
{ assignWidget(button, "StatValueButton");
if (button)
{
skillNameWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWSkill::onClicked);
}
} }
/* MWAttribute */ /* MWAttribute */
@ -176,7 +149,7 @@ void MWAttribute::updateWidgets()
{ {
if (id < 0 || id >= 8) if (id < 0 || id >= 8)
{ {
attributeNameWidget->setCaption(""); static_cast<MyGUI::TextBox*>(attributeNameWidget)->setCaption("");
} }
else else
{ {
@ -191,75 +164,48 @@ void MWAttribute::updateWidgets()
"sAttributeLuck" "sAttributeLuck"
}; };
const std::string &name = manager->getGameSettingString(attributes[id], ""); const std::string &name = manager->getGameSettingString(attributes[id], "");
attributeNameWidget->setCaption(name); static_cast<MyGUI::TextBox*>(attributeNameWidget)->setCaption(name);
} }
} }
if (attributeValueWidget) if (attributeValueWidget)
{ {
AttributeValue::Type modified = value.getModified(), base = value.getBase(); AttributeValue::Type modified = value.getModified(), base = value.getBase();
attributeValueWidget->setCaption(boost::lexical_cast<std::string>(modified)); static_cast<MyGUI::TextBox*>(attributeValueWidget)->setCaption(boost::lexical_cast<std::string>(modified));
if (modified > base) if (modified > base)
attributeValueWidget->setState("increased"); attributeValueWidget->_setWidgetState("increased");
else if (modified < base) else if (modified < base)
attributeValueWidget->setState("decreased"); attributeValueWidget->_setWidgetState("decreased");
else else
attributeValueWidget->setState("normal"); attributeValueWidget->_setWidgetState("normal");
} }
} }
void MWAttribute::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info);
}
MWAttribute::~MWAttribute() MWAttribute::~MWAttribute()
{ {
shutdownWidgetSkin();
} }
void MWAttribute::baseChangeWidgetSkin(ResourceSkin* _info) void MWAttribute::initialiseOverride()
{ {
shutdownWidgetSkin(); Base::initialiseOverride();
Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info);
}
void MWAttribute::initialiseWidgetSkin(ResourceSkin* _info) assignWidget(attributeNameWidget, "StatName");
{ assignWidget(attributeValueWidget, "StatValue");
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
MyGUI::ButtonPtr button;
assignWidget(button, "StatNameButton");
if (button)
{ {
const std::string &name = *(*iter)->_getInternalData<std::string>(); attributeNameWidget = button;
if (name == "StatName") button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked);
{
MYGUI_DEBUG_ASSERT( ! attributeNameWidget, "widget already assigned");
attributeNameWidget = (*iter)->castType<StaticText>();
}
else if (name == "StatValue")
{
MYGUI_DEBUG_ASSERT( ! attributeValueWidget, "widget already assigned");
attributeValueWidget = (*iter)->castType<StaticText>();
}
else if (name == "StatNameButton")
{
MYGUI_DEBUG_ASSERT( ! attributeNameWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>();
attributeNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWAttribute::onClicked);
}
else if (name == "StatValue")
{
MYGUI_DEBUG_ASSERT( ! attributeValueWidget, "widget already assigned");
MyGUI::ButtonPtr button = (*iter)->castType<Button>();
attributeNameWidget = button;
button->eventMouseButtonClick = MyGUI::newDelegate(this, &MWAttribute::onClicked);
}
} }
}
void MWAttribute::shutdownWidgetSkin() button = 0;
{ assignWidget(button, "StatValueButton");
if (button)
{
attributeValueWidget = button;
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWAttribute::onClicked);
}
} }
/* MWSpell */ /* MWSpell */
@ -301,45 +247,20 @@ void MWSpell::updateWidgets()
const ESMS::ESMStore &store = mWindowManager->getStore(); const ESMS::ESMStore &store = mWindowManager->getStore();
const ESM::Spell *spell = store.spells.search(id); const ESM::Spell *spell = store.spells.search(id);
if (spell) if (spell)
spellNameWidget->setCaption(spell->name); static_cast<MyGUI::TextBox*>(spellNameWidget)->setCaption(spell->name);
else else
spellNameWidget->setCaption(""); static_cast<MyGUI::TextBox*>(spellNameWidget)->setCaption("");
} }
} }
void MWSpell::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name) void MWSpell::initialiseOverride()
{ {
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name); Base::initialiseOverride();
initialiseWidgetSkin(_info); assignWidget(spellNameWidget, "StatName");
} }
MWSpell::~MWSpell() MWSpell::~MWSpell()
{
shutdownWidgetSkin();
}
void MWSpell::baseChangeWidgetSkin(ResourceSkin* _info)
{
shutdownWidgetSkin();
Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info);
}
void MWSpell::initialiseWidgetSkin(ResourceSkin* _info)
{
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
{
const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "StatName")
{
MYGUI_DEBUG_ASSERT( ! spellNameWidget, "widget already assigned");
spellNameWidget = (*iter)->castType<StaticText>();
}
}
}
void MWSpell::shutdownWidgetSkin()
{ {
} }
@ -408,10 +329,10 @@ void MWSpellEffect::updateWidgets()
spellLine += " on Touch"; spellLine += " on Touch";
else if (effect.range == ESM::RT_Target) else if (effect.range == ESM::RT_Target)
spellLine += " on Target"; spellLine += " on Target";
textWidget->setCaption(spellLine); static_cast<MyGUI::TextBox*>(textWidget)->setCaption(spellLine);
} }
else else
textWidget->setCaption(""); static_cast<MyGUI::TextBox*>(textWidget)->setCaption("");
} }
if (imageWidget) if (imageWidget)
{ {
@ -421,45 +342,16 @@ void MWSpellEffect::updateWidgets()
} }
} }
void MWSpellEffect::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info);
}
MWSpellEffect::~MWSpellEffect() MWSpellEffect::~MWSpellEffect()
{ {
shutdownWidgetSkin();
} }
void MWSpellEffect::baseChangeWidgetSkin(ResourceSkin* _info) void MWSpellEffect::initialiseOverride()
{ {
shutdownWidgetSkin(); Base::initialiseOverride();
Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info);
}
void MWSpellEffect::initialiseWidgetSkin(ResourceSkin* _info) assignWidget(textWidget, "Text");
{ assignWidget(imageWidget, "Image");
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
{
const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "Text")
{
MYGUI_DEBUG_ASSERT( ! textWidget, "widget already assigned");
textWidget = (*iter)->castType<StaticText>();
}
else if (name == "Image")
{
MYGUI_DEBUG_ASSERT( ! imageWidget, "widget already assigned");
imageWidget = (*iter)->castType<StaticImage>();
}
}
}
void MWSpellEffect::shutdownWidgetSkin()
{
} }
/* MWDynamicStat */ /* MWDynamicStat */
@ -491,60 +383,27 @@ void MWDynamicStat::setValue(int cur, int max_)
{ {
std::stringstream out; std::stringstream out;
out << value << "/" << max; out << value << "/" << max;
barTextWidget->setCaption(out.str().c_str()); static_cast<MyGUI::TextBox*>(barTextWidget)->setCaption(out.str().c_str());
} }
else else
barTextWidget->setCaption(""); static_cast<MyGUI::TextBox*>(barTextWidget)->setCaption("");
} }
} }
void MWDynamicStat::setTitle(const std::string text) void MWDynamicStat::setTitle(const std::string text)
{ {
if (textWidget) if (textWidget)
textWidget->setCaption(text); static_cast<MyGUI::TextBox*>(textWidget)->setCaption(text);
}
void MWDynamicStat::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
{
Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
initialiseWidgetSkin(_info);
} }
MWDynamicStat::~MWDynamicStat() MWDynamicStat::~MWDynamicStat()
{ {
shutdownWidgetSkin();
} }
void MWDynamicStat::baseChangeWidgetSkin(ResourceSkin* _info) void MWDynamicStat::initialiseOverride()
{ {
shutdownWidgetSkin(); Base::initialiseOverride();
Base::baseChangeWidgetSkin(_info);
initialiseWidgetSkin(_info);
}
void MWDynamicStat::initialiseWidgetSkin(ResourceSkin* _info) assignWidget(textWidget, "Text");
{ assignWidget(barWidget, "Bar");
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) assignWidget(barTextWidget, "BarText");
{
const std::string &name = *(*iter)->_getInternalData<std::string>();
if (name == "Text")
{
MYGUI_DEBUG_ASSERT( ! textWidget, "widget already assigned");
textWidget = (*iter)->castType<StaticText>();
}
else if (name == "Bar")
{
MYGUI_DEBUG_ASSERT( ! barWidget, "widget already assigned");
barWidget = (*iter)->castType<Progress>();
}
else if (name == "BarText")
{
MYGUI_DEBUG_ASSERT( ! barTextWidget, "widget already assigned");
barTextWidget = (*iter)->castType<StaticText>();
}
}
}
void MWDynamicStat::shutdownWidgetSkin()
{
} }

View file

@ -38,26 +38,21 @@ namespace MWGui
const SkillValue& getSkillValue() const { return value; } const SkillValue& getSkillValue() const { return value; }
// Events // Events
typedef delegates::CDelegate1<MWSkill*> EventHandle_SkillVoid; typedef delegates::CMultiDelegate1<MWSkill*> EventHandle_SkillVoid;
/** Event : Skill clicked.\n /** Event : Skill clicked.\n
signature : void method(MWSkill* _sender)\n signature : void method(MWSkill* _sender)\n
*/ */
EventHandle_SkillVoid eventClicked; EventHandle_SkillVoid eventClicked;
/*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWSkill(); virtual ~MWSkill();
void baseChangeWidgetSkin(ResourceSkin* _info); virtual void initialiseOverride();
void onClicked(MyGUI::Widget* _sender); void onClicked(MyGUI::Widget* _sender);
private: private:
void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
@ -85,26 +80,21 @@ namespace MWGui
const AttributeValue& getAttributeValue() const { return value; } const AttributeValue& getAttributeValue() const { return value; }
// Events // Events
typedef delegates::CDelegate1<MWAttribute*> EventHandle_AttributeVoid; typedef delegates::CMultiDelegate1<MWAttribute*> EventHandle_AttributeVoid;
/** Event : Attribute clicked.\n /** Event : Attribute clicked.\n
signature : void method(MWAttribute* _sender)\n signature : void method(MWAttribute* _sender)\n
*/ */
EventHandle_AttributeVoid eventClicked; EventHandle_AttributeVoid eventClicked;
/*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWAttribute(); virtual ~MWAttribute();
void baseChangeWidgetSkin(ResourceSkin* _info); virtual void initialiseOverride();
void onClicked(MyGUI::Widget* _sender); void onClicked(MyGUI::Widget* _sender);
private: private:
void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
@ -130,23 +120,17 @@ namespace MWGui
const std::string &getSpellId() const { return id; } const std::string &getSpellId() const { return id; }
/*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWSpell(); virtual ~MWSpell();
void baseChangeWidgetSkin(ResourceSkin* _info); virtual void initialiseOverride();
private: private:
void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
WindowManager* mWindowManager; WindowManager* mWindowManager;
std::string id; std::string id;
MyGUI::StaticTextPtr spellNameWidget; MyGUI::TextBox* spellNameWidget;
}; };
typedef MWSpell* MWSpellPtr; typedef MWSpell* MWSpellPtr;
@ -163,24 +147,19 @@ namespace MWGui
const SpellEffectValue &getSpellEffect() const { return effect; } const SpellEffectValue &getSpellEffect() const { return effect; }
/*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWSpellEffect(); virtual ~MWSpellEffect();
void baseChangeWidgetSkin(ResourceSkin* _info); virtual void initialiseOverride();
private: private:
void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin();
void updateWidgets(); void updateWidgets();
WindowManager* mWindowManager; WindowManager* mWindowManager;
SpellEffectValue effect; SpellEffectValue effect;
MyGUI::StaticImagePtr imageWidget; MyGUI::ImageBox* imageWidget;
MyGUI::StaticTextPtr textWidget; MyGUI::TextBox* textWidget;
}; };
typedef MWSpellEffect* MWSpellEffectPtr; typedef MWSpellEffect* MWSpellEffectPtr;
@ -196,22 +175,17 @@ namespace MWGui
int getValue() const { return value; } int getValue() const { return value; }
int getMax() const { return max; } int getMax() const { return max; }
/*internal:*/
virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
protected: protected:
virtual ~MWDynamicStat(); virtual ~MWDynamicStat();
void baseChangeWidgetSkin(ResourceSkin* _info); virtual void initialiseOverride();
private: private:
void initialiseWidgetSkin(ResourceSkin* _info);
void shutdownWidgetSkin();
int value, max; int value, max;
MyGUI::StaticTextPtr textWidget; MyGUI::TextBox* textWidget;
MyGUI::ProgressPtr barWidget; MyGUI::ProgressPtr barWidget;
MyGUI::StaticTextPtr barTextWidget; MyGUI::TextBox* barTextWidget;
}; };
typedef MWDynamicStat* MWDynamicStatPtr; typedef MWDynamicStat* MWDynamicStatPtr;

View file

@ -16,7 +16,7 @@ void WindowBase::open()
void WindowBase::center() void WindowBase::center()
{ {
// Centre dialog // Centre dialog
MyGUI::IntSize gameWindowSize = mWindowManager.getGui()->getViewSize(); MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
MyGUI::IntCoord coord = mMainWidget->getCoord(); MyGUI::IntCoord coord = mMainWidget->getCoord();
coord.left = (gameWindowSize.width - coord.width)/2; coord.left = (gameWindowSize.width - coord.width)/2;
coord.top = (gameWindowSize.height - coord.height)/2; coord.top = (gameWindowSize.height - coord.height)/2;

View file

@ -13,7 +13,7 @@ namespace MWGui
WindowBase(const std::string& parLayout, WindowManager& parWindowManager); WindowBase(const std::string& parLayout, WindowManager& parWindowManager);
// Events // Events
typedef MyGUI::delegates::CDelegate1<WindowBase*> EventHandle_WindowBase; typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase;
virtual void open(); virtual void open();
void center(); void center();

View file

@ -37,12 +37,12 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
gui = mGuiManager->getGui(); gui = mGuiManager->getGui();
//Register own widgets with MyGUI //Register own widgets with MyGUI
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<DialogueHistory>("Widget");
// Get size info from the Gui object // Get size info from the Gui object
assert(gui); assert(gui);
int w = gui->getViewSize().width; int w = MyGUI::RenderManager::getInstance().getViewSize().width;
int h = gui->getViewSize().height; int h = MyGUI::RenderManager::getInstance().getViewSize().height;
hud = new HUD(w,h, showFPSLevel); hud = new HUD(w,h, showFPSLevel);
menu = new MainMenu(w,h); menu = new MainMenu(w,h);
@ -51,6 +51,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
console = new Console(w,h, environment, extensions); console = new Console(w,h, environment, extensions);
mJournal = new JournalWindow(*this); mJournal = new JournalWindow(*this);
mMessageBoxManager = new MessageBoxManager(this); mMessageBoxManager = new MessageBoxManager(this);
dialogueWindow = new DialogueWindow(*this,environment);
// The HUD is always on // The HUD is always on
hud->setVisible(true); hud->setVisible(true);
@ -149,9 +150,10 @@ void WindowManager::updateVisible()
stats->setVisible(false); stats->setVisible(false);
console->disable(); console->disable();
mJournal->setVisible(false); mJournal->setVisible(false);
dialogueWindow->setVisible(false);
// Mouse is visible whenever we're not in game mode // Mouse is visible whenever we're not in game mode
gui->setVisiblePointer(isGuiMode()); MyGUI::PointerManager::getInstance().setVisible(isGuiMode());
// If in game mode, don't show anything. // If in game mode, don't show anything.
if(mode == GM_Game) //Use a switch/case structure if(mode == GM_Game) //Use a switch/case structure
@ -195,11 +197,6 @@ void WindowManager::updateVisible()
if (mode == GM_Dialogue) if (mode == GM_Dialogue)
{ {
if (!dialogueWindow)
{
dialogueWindow = new DialogueWindow(*this);
dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye);
}
dialogueWindow->open(); dialogueWindow->open();
return; return;
} }
@ -349,6 +346,7 @@ void WindowManager::updateSkillArea()
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog) void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
{ {
std::cout << "dialogue a la poubelle";
assert(dialog); assert(dialog);
if (!dialog) if (!dialog)
return; return;
@ -387,7 +385,8 @@ void WindowManager::onDialogueWindowBye()
if (dialogueWindow) if (dialogueWindow)
{ {
//FIXME set some state and stuff? //FIXME set some state and stuff?
removeDialog(dialogueWindow); //removeDialog(dialogueWindow);
dialogueWindow->setVisible(false);
} }
setGuiMode(GM_Game); setGuiMode(GM_Game);
} }

View file

@ -124,6 +124,8 @@ namespace MWGui
updateVisible(); updateVisible();
} }
MWGui::DialogueWindow* getDialogueWindow() {return dialogueWindow;}
MyGUI::Gui* getGui() const { return gui; } MyGUI::Gui* getGui() const { return gui; }
void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount) void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount)

View file

@ -111,7 +111,6 @@ namespace MWRender{
Nif::NiTriShapeCopy& copy = *allshapesiter; Nif::NiTriShapeCopy& copy = *allshapesiter;
std::vector<Ogre::Vector3>* allvertices = &copy.vertices; std::vector<Ogre::Vector3>* allvertices = &copy.vertices;
std::vector<Ogre::Vector3>* allnormals = &copy.normals;
@ -182,7 +181,6 @@ namespace MWRender{
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second; std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
int verIndex = iter->first; int verIndex = iter->first;
Ogre::Vector3 currentVertex = (*allvertices)[verIndex]; Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
Ogre::Vector3 currentNormal = (*allnormals)[verIndex];
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]); Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
Ogre::Bone *bonePtr = 0; Ogre::Bone *bonePtr = 0;
@ -276,7 +274,7 @@ namespace MWRender{
rotmult = bonePtr->getOrientation(); rotmult = bonePtr->getOrientation();
scale = bonePtr->getScale().x; scale = bonePtr->getScale().x;
boneSequenceIter++; boneSequenceIter++;
for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++) for(; boneSequenceIter != boneSequence.end(); boneSequenceIter++)
{ {
if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){ if(creaturemodel->getSkeleton()->hasBone(*boneSequenceIter)){
@ -390,7 +388,7 @@ namespace MWRender{
void Animation::handleAnimationTransforms(){ void Animation::handleAnimationTransforms(){
Ogre::SkeletonInstance* skel = base->getSkeleton(); Ogre::SkeletonInstance* skel = base->getSkeleton();
@ -430,11 +428,11 @@ namespace MWRender{
const std::vector<Ogre::Quaternion> & quats = iter->getQuat(); const std::vector<Ogre::Quaternion> & quats = iter->getQuat();
const std::vector<float> & ttime = iter->gettTime(); const std::vector<float> & ttime = iter->gettTime();
const std::vector<float> & rtime = iter->getrTime(); const std::vector<float> & rtime = iter->getrTime();
int rindexJ = rindexI[slot]; int rindexJ = rindexI[slot];
timeIndex(time, rtime, rindexI[slot], rindexJ, x2); timeIndex(time, rtime, rindexI[slot], rindexJ, x2);
int tindexJ = tindexI[slot]; int tindexJ = tindexI[slot];
@ -447,10 +445,10 @@ namespace MWRender{
Ogre::Quaternion r; Ogre::Quaternion r;
bool bTrans = translist1.size() > 0; bool bTrans = translist1.size() > 0;
bool bQuats = quats.size() > 0; bool bQuats = quats.size() > 0;
if(skel->hasBone(iter->getBonename())){ if(skel->hasBone(iter->getBonename())){
Ogre::Bone* bone = skel->getBone(iter->getBonename()); Ogre::Bone* bone = skel->getBone(iter->getBonename());
if(bTrans){ if(bTrans){
@ -467,10 +465,10 @@ namespace MWRender{
} }
slot++; slot++;
} }

View file

@ -66,7 +66,7 @@ class Animation{
void stopScript(); void stopScript();
~Animation(); virtual ~Animation();
}; };
} }

View file

@ -16,7 +16,7 @@ namespace MWRender{
class CreatureAnimation: public Animation{ class CreatureAnimation: public Animation{
public: public:
~CreatureAnimation(); virtual ~CreatureAnimation();
CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);

View file

@ -20,7 +20,7 @@ class NpcAnimation: public Animation{
public: public:
NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend); NpcAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
~NpcAnimation(); virtual ~NpcAnimation();
Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename); Ogre::Entity* insertBoundedPart(const std::string &mesh, std::string bonename);
void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert); void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert);
virtual void runAnimation(float timepassed); virtual void runAnimation(float timepassed);

View file

@ -56,7 +56,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
cameraPitchNode->attachObject(mRendering.getCamera()); cameraPitchNode->attachObject(mRendering.getCamera());
//mSkyManager = 0; //mSkyManager = 0;
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera()); mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment);
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
mSun = 0; mSun = 0;
@ -220,9 +220,14 @@ void RenderingManager::configureFog(ESMS::CellStore<MWWorld::RefData> &mCell)
void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour) void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour)
{ {
/// \todo make the viewing distance and fog start/end configurable /// \todo make the viewing distance and fog start/end configurable
float low = 3000 / density;
float high = 6200 / density; // right now we load 3x3 cells, so the maximum viewing distance we
// can allow (to prevent objects suddenly popping up) equals:
// 8192 * 0.69
// ^ cell size ^ minimum density value used (clear weather)
float low = 5652.48 / density / 2.f;
float high = 5652.48 / density;
mRendering.getScene()->setFog (FOG_LINEAR, colour, 0, low, high); mRendering.getScene()->setFog (FOG_LINEAR, colour, 0, low, high);
mRendering.getCamera()->setFarClipDistance ( high ); mRendering.getCamera()->setFarClipDistance ( high );

View file

@ -10,16 +10,12 @@
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogre_nif_loader.hpp>
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
using namespace MWRender; using namespace MWRender;
using namespace Ogre; using namespace Ogre;
// the speed at which the clouds are animated
#define CLOUD_SPEED 0.001
// this distance has to be set accordingly so that the
// celestial bodies are behind the clouds, but in front of the atmosphere
#define CELESTIAL_BODY_DISTANCE 1000.f
BillboardObject::BillboardObject( const String& textureName, BillboardObject::BillboardObject( const String& textureName,
const float initialSize, const float initialSize,
const Vector3& position, const Vector3& position,
@ -50,7 +46,7 @@ void BillboardObject::setVisibility(const float visibility)
void BillboardObject::setPosition(const Vector3& pPosition) void BillboardObject::setPosition(const Vector3& pPosition)
{ {
Vector3 normalised = pPosition.normalisedCopy(); Vector3 normalised = pPosition.normalisedCopy();
Vector3 finalPosition = normalised * CELESTIAL_BODY_DISTANCE; Vector3 finalPosition = normalised * 1000.f;
mBBSet->setCommonDirection( -normalised ); mBBSet->setCommonDirection( -normalised );
@ -59,7 +55,8 @@ void BillboardObject::setPosition(const Vector3& pPosition)
Vector3 BillboardObject::getPosition() const Vector3 BillboardObject::getPosition() const
{ {
return mNode->getPosition(); Vector3 p = mNode->_getDerivedPosition() - mNode->getParentSceneNode()->_getDerivedPosition();
return Vector3(p.x, -p.z, p.y);
} }
void BillboardObject::setColour(const ColourValue& pColour) void BillboardObject::setColour(const ColourValue& pColour)
@ -84,7 +81,7 @@ void BillboardObject::init(const String& textureName,
{ {
SceneManager* sceneMgr = rootNode->getCreator(); SceneManager* sceneMgr = rootNode->getCreator();
Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE; Vector3 finalPosition = position.normalisedCopy() * 1000.f;
static unsigned int bodyCount=0; static unsigned int bodyCount=0;
@ -161,14 +158,20 @@ Moon::Moon( const String& textureName,
" in float2 uv : TEXCOORD0, \n" " in float2 uv : TEXCOORD0, \n"
" out float4 oColor : COLOR, \n" " out float4 oColor : COLOR, \n"
" uniform sampler2D texture : TEXUNIT0, \n" " uniform sampler2D texture : TEXUNIT0, \n"
" uniform float4 skyColour, \n"
" uniform float4 diffuse, \n" " uniform float4 diffuse, \n"
" uniform float4 emissive \n" " uniform float4 emissive \n"
") \n" ") \n"
"{ \n" "{ \n"
" float4 tex = tex2D(texture, uv); \n" " float4 tex = tex2D(texture, uv); \n"
" oColor = float4(emissive.xyz,1) * tex2D(texture, uv) * float4(1,1,1,diffuse.a); \n" " oColor = float4(emissive.xyz,1) * tex; \n"
" float bump = pow((1-diffuse.a),4); \n" // use a circle for the alpha (compute UV distance to center)
" oColor.rgb += float3(bump, bump, bump)*0.5; \n" // looks a bit bad because its not filtered on the edges,
// but it's cheaper than a seperate alpha texture.
" float sqrUVdist = pow(uv.x-0.5,2) + pow(uv.y-0.5, 2); \n"
" oColor.a = diffuse.a * (sqrUVdist >= 0.24 ? 0 : 1); \n"
" oColor.rgb += (1-tex.a) * oColor.a * skyColour.rgb; \n"//fill dark side of moon with skycolour
" oColor.rgb += (1-diffuse.a) * skyColour.rgb; \n"//fade bump
"}"; "}";
fshader->setSource(outStream2.str()); fshader->setSource(outStream2.str());
fshader->load(); fshader->load();
@ -186,15 +189,19 @@ void Moon::setType(const Moon::Type& type)
mType = type; mType = type;
} }
void Moon::setSkyColour(const Ogre::ColourValue& colour)
{
mMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("skyColour", colour);
}
/// \todo the moon phase rendering is not correct - the dark part of the moon does not occlude the stars
void Moon::setPhase(const Moon::Phase& phase) void Moon::setPhase(const Moon::Phase& phase)
{ {
// Colour texture
Ogre::String textureName = "textures\\tx_"; Ogre::String textureName = "textures\\tx_";
if (mType == Moon::Type_Secunda) textureName += "secunda_"; if (mType == Moon::Type_Secunda) textureName += "secunda_";
else textureName += "masser_"; else textureName += "masser_";
if (phase == Moon::Phase_New) textureName += "new"; if (phase == Moon::Phase_New) textureName += "new";
else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax"; else if (phase == Moon::Phase_WaxingCrescent) textureName += "one_wax";
else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax"; else if (phase == Moon::Phase_WaxingHalf) textureName += "half_wax";
@ -203,9 +210,9 @@ void Moon::setPhase(const Moon::Phase& phase)
else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan"; else if (phase == Moon::Phase_WaningHalf) textureName += "half_wan";
else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan"; else if (phase == Moon::Phase_WaningGibbous) textureName += "three_wan";
else if (phase == Moon::Phase_Full) textureName += "full"; else if (phase == Moon::Phase_Full) textureName += "full";
textureName += ".dds"; textureName += ".dds";
mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName); mMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(textureName);
mPhase = phase; mPhase = phase;
@ -285,9 +292,10 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
} }
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) :
mGlareFade(0), mGlareEnabled(false) mGlareFade(0), mGlareEnabled(false)
{ {
mEnvironment = env;
mViewport = pCamera->getViewport(); mViewport = pCamera->getViewport();
mSceneMgr = pMwRoot->getCreator(); mSceneMgr = pMwRoot->getCreator();
mRootNode = pCamera->getParentSceneNode()->createChildSceneNode(); mRootNode = pCamera->getParentSceneNode()->createChildSceneNode();
@ -301,7 +309,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
Pass* pass = material->getTechnique(0)->getPass(0); Pass* pass = material->getTechnique(0)->getPass(0);
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA); pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
mThunderTextureUnit = pass->createTextureUnitState(); mThunderTextureUnit = pass->createTextureUnitState();
mThunderTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.f, 1.f, 1.f)); // always black colour mThunderTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.f, 1.f, 1.f));
mThunderTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 0.5f); mThunderTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 0.5f);
OverlayManager& ovm = OverlayManager::getSingleton(); OverlayManager& ovm = OverlayManager::getSingleton();
mThunderOverlay = ovm.create( "ThunderOverlay" ); mThunderOverlay = ovm.create( "ThunderOverlay" );
@ -338,24 +346,11 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
mAtmosphereNight = mRootNode->createChildSceneNode(); mAtmosphereNight = mRootNode->createChildSceneNode();
mAtmosphereNight->attachObject(night1_ent); mAtmosphereNight->attachObject(night1_ent);
for (unsigned int i=0; i<night1_ent->getNumSubEntities(); ++i)
{
MaterialPtr mp = night1_ent->getSubEntity(i)->getMaterial();
mp->getTechnique(0)->getPass(0)->setSelfIllumination(1.0, 1.0, 1.0);
mp->getTechnique(0)->getPass(0)->setAmbient(0.0, 0.0, 0.0);
mp->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, 1.0);
mp->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
mp->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
mp->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
mStarsMaterials[i] = mp;
}
// Stars vertex shader // Stars vertex shader
HighLevelGpuProgramPtr vshader3 = mgr.createProgram("Stars_VP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, HighLevelGpuProgramPtr stars_vp = mgr.createProgram("Stars_VP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"cg", GPT_VERTEX_PROGRAM); "cg", GPT_VERTEX_PROGRAM);
vshader3->setParameter("profiles", "vs_2_x arbvp1"); stars_vp->setParameter("profiles", "vs_2_x arbvp1");
vshader3->setParameter("entry_point", "main_vp"); stars_vp->setParameter("entry_point", "main_vp");
StringUtil::StrStreamType outStream4; StringUtil::StrStreamType outStream4;
outStream4 << outStream4 <<
"void main_vp( \n" "void main_vp( \n"
@ -371,10 +366,9 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
" oFade = (position.z > 50) ? 1.f : 0.f; \n" " oFade = (position.z > 50) ? 1.f : 0.f; \n"
" oPosition = mul( worldViewProj, position ); \n" " oPosition = mul( worldViewProj, position ); \n"
"}"; "}";
vshader3->setSource(outStream4.str()); stars_vp->setSource(outStream4.str());
vshader3->load(); stars_vp->load();
vshader3->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX); stars_vp->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
night1_ent->getSubEntity(3)->getMaterial()->getTechnique(0)->getPass(0)->setVertexProgram(vshader3->getName());
// Stars fragment shader // Stars fragment shader
HighLevelGpuProgramPtr stars_fp = mgr.createProgram("Stars_FP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, HighLevelGpuProgramPtr stars_fp = mgr.createProgram("Stars_FP", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
@ -399,7 +393,20 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
stars_fp->load(); stars_fp->load();
stars_fp->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR); stars_fp->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
stars_fp->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR); stars_fp->getDefaultParameters()->setNamedAutoConstant("diffuse", GpuProgramParameters::ACT_SURFACE_DIFFUSE_COLOUR);
night1_ent->getSubEntity(3)->getMaterial()->getTechnique(0)->getPass(0)->setFragmentProgram(stars_fp->getName());
for (unsigned int i=0; i<night1_ent->getNumSubEntities(); ++i)
{
MaterialPtr mp = night1_ent->getSubEntity(i)->getMaterial();
mp->getTechnique(0)->getPass(0)->setSelfIllumination(1.0, 1.0, 1.0);
mp->getTechnique(0)->getPass(0)->setAmbient(0.0, 0.0, 0.0);
mp->getTechnique(0)->getPass(0)->setDiffuse(0.0, 0.0, 0.0, 1.0);
mp->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
mp->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
mp->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
mp->getTechnique(0)->getPass(0)->setVertexProgram(stars_vp->getName());
mp->getTechnique(0)->getPass(0)->setFragmentProgram(stars_fp->getName());
mStarsMaterials[i] = mp;
}
// Atmosphere (day) // Atmosphere (day)
mesh = NifOgre::NIFLoader::load("meshes\\sky_atmosphere.nif"); mesh = NifOgre::NIFLoader::load("meshes\\sky_atmosphere.nif");
@ -494,7 +501,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
" uniform float4 emissive \n" " uniform float4 emissive \n"
") \n" ") \n"
"{ \n" "{ \n"
" uv += float2(1,1) * time * speed * "<<CLOUD_SPEED<<"; \n" // Scroll in x,y direction " uv += float2(1,0) * time * speed * 0.003; \n" // Scroll in x direction
" float4 tex = lerp(tex2D(texture, uv), tex2D(secondTexture, uv), transitionFactor); \n" " float4 tex = lerp(tex2D(texture, uv), tex2D(secondTexture, uv), transitionFactor); \n"
" oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n" " oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n"
"}"; "}";
@ -548,7 +555,7 @@ void SkyManager::update(float duration)
if (!mEnabled) return; if (!mEnabled) return;
// UV Scroll the clouds // UV Scroll the clouds
mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", 1); mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", mEnvironment->mWorld->getTimeScaleFactor()/30.f);
/// \todo improve this /// \todo improve this
mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) ); mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) );
@ -583,6 +590,9 @@ void SkyManager::update(float duration)
mSun->setVisible(mSunEnabled); mSun->setVisible(mSunEnabled);
mMasser->setVisible(mMasserEnabled); mMasser->setVisible(mMasserEnabled);
mSecunda->setVisible(mSecundaEnabled); mSecunda->setVisible(mSecundaEnabled);
// rotate the stars by 360 degrees every 4 days
mAtmosphereNight->roll(Degree(mEnvironment->mWorld->getTimeScaleFactor()*duration*360 / (3600*96.f)));
} }
void SkyManager::enable() void SkyManager::enable()
@ -647,6 +657,8 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
if (mSkyColour != weather.mSkyColor) if (mSkyColour != weather.mSkyColor)
{ {
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor); mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor);
mMasser->setSkyColour(weather.mSkyColor);
mSecunda->setSkyColour(weather.mSkyColor);
mSkyColour = weather.mSkyColor; mSkyColour = weather.mSkyColor;
} }
@ -677,6 +689,7 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
strength = 1.f; strength = 1.f;
mSunGlare->setVisibility(weather.mGlareView * strength); mSunGlare->setVisibility(weather.mGlareView * strength);
mSun->setVisibility(strength);
mAtmosphereNight->setVisible(weather.mNight && mEnabled); mAtmosphereNight->setVisible(weather.mNight && mEnabled);
} }

View file

@ -34,6 +34,8 @@ namespace MWRender
Ogre::SceneNode* rootNode Ogre::SceneNode* rootNode
); );
BillboardObject(); BillboardObject();
virtual ~BillboardObject() {}
void setColour(const Ogre::ColourValue& pColour); void setColour(const Ogre::ColourValue& pColour);
void setPosition(const Ogre::Vector3& pPosition); void setPosition(const Ogre::Vector3& pPosition);
@ -69,6 +71,8 @@ namespace MWRender
const Ogre::Vector3& position, const Ogre::Vector3& position,
Ogre::SceneNode* rootNode Ogre::SceneNode* rootNode
); );
virtual ~Moon() {}
enum Phase enum Phase
{ {
@ -90,6 +94,7 @@ namespace MWRender
void setPhase(const Phase& phase); void setPhase(const Phase& phase);
void setType(const Type& type); void setType(const Type& type);
void setSkyColour(const Ogre::ColourValue& colour);
Phase getPhase() const; Phase getPhase() const;
unsigned int getPhaseInt() const; unsigned int getPhaseInt() const;
@ -102,7 +107,7 @@ namespace MWRender
class SkyManager class SkyManager
{ {
public: public:
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera); SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env);
~SkyManager(); ~SkyManager();
void update(float duration); void update(float duration);
@ -159,10 +164,11 @@ namespace MWRender
Ogre::Vector3 getRealSunPos(); Ogre::Vector3 getRealSunPos();
private: private:
MWWorld::Environment* mEnvironment;
float mHour; float mHour;
int mDay; int mDay;
int mMonth; int mMonth;
BillboardObject* mSun; BillboardObject* mSun;
BillboardObject* mSunGlare; BillboardObject* mSunGlare;
Moon* mMasser; Moon* mMasser;

View file

@ -8,6 +8,7 @@
#include <components/interpreter/opcodes.hpp> #include <components/interpreter/opcodes.hpp>
#include "../mwdialogue/journal.hpp" #include "../mwdialogue/journal.hpp"
#include "../mwdialogue/dialoguemanager.hpp"
#include "interpretercontext.hpp" #include "interpretercontext.hpp"
@ -72,15 +73,62 @@ namespace MWScript
} }
}; };
class OpAddTopic : public Interpreter::Opcode0
{
public:
virtual void execute (Interpreter::Runtime& runtime)
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
std::string topic = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
context.getEnvironment().mDialogueManager->addTopic(topic);
}
};
class OpChoice : public Interpreter::Opcode1
{
public:
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
MWDialogue::DialogueManager* dialogue = context.getEnvironment().mDialogueManager;
while(arg0>0)
{
std::string question = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
arg0 = arg0 -1;
Interpreter::Type_Integer choice = 1;
if(arg0>0)
{
choice = runtime[0].mInteger;
runtime.pop();
arg0 = arg0 -1;
}
dialogue->askQuestion(question,choice);
}
}
};
const int opcodeJournal = 0x2000133; const int opcodeJournal = 0x2000133;
const int opcodeSetJournalIndex = 0x2000134; const int opcodeSetJournalIndex = 0x2000134;
const int opcodeGetJournalIndex = 0x2000135; const int opcodeGetJournalIndex = 0x2000135;
const int opcodeAddTopic = 0x200013a;
const int opcodeChoice = 0x2000a;
void registerExtensions (Compiler::Extensions& extensions) void registerExtensions (Compiler::Extensions& extensions)
{ {
extensions.registerInstruction ("journal", "cl", opcodeJournal); extensions.registerInstruction ("journal", "cl", opcodeJournal);
extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex); extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex);
extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex); extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex);
extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic);
extensions.registerInstruction ("choice", "/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice);
} }
void installOpcodes (Interpreter::Interpreter& interpreter) void installOpcodes (Interpreter::Interpreter& interpreter)
@ -88,6 +136,8 @@ namespace MWScript
interpreter.installSegment5 (opcodeJournal, new OpJournal); interpreter.installSegment5 (opcodeJournal, new OpJournal);
interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex); interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex);
interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex); interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex);
interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic);
interpreter.installSegment3 (opcodeChoice,new OpChoice);
} }
} }

View file

@ -23,7 +23,8 @@ op 0x20006: PlayAnim
op 0x20007: PlayAnim, explicit reference op 0x20007: PlayAnim, explicit reference
op 0x20008: LoopAnim op 0x20008: LoopAnim
op 0x20009: LoopAnim, explicit reference op 0x20009: LoopAnim, explicit reference
opcodes 0x2000a-0x3ffff unused op 0x2000a: Choice
opcodes 0x2000b-0x3ffff unused
Segment 4: Segment 4:
(not implemented yet) (not implemented yet)
@ -115,6 +116,7 @@ op 0x2000136: GetPCCell
op 0x2000137: GetButtonPressed op 0x2000137: GetButtonPressed
op 0x2000138: SkipAnim op 0x2000138: SkipAnim
op 0x2000139: SkipAnim, expplicit reference op 0x2000139: SkipAnim, expplicit reference
op 0x200013a: AddTopic
op 0x200013b: twf op 0x200013b: twf
op 0x200013c: FadeIn op 0x200013c: FadeIn
op 0x200013d: FadeOut op 0x200013d: FadeOut

View file

@ -63,7 +63,7 @@ namespace MWScript
{ {
std::vector<Interpreter::Type_Code> code; std::vector<Interpreter::Type_Code> code;
mParser.getCode (code); mParser.getCode (code);
mScripts.insert (std::make_pair (name, code)); mScripts.insert (std::make_pair (name, std::make_pair (code, mParser.getLocals())));
// TODO sanity check on generated locals // TODO sanity check on generated locals
@ -77,8 +77,7 @@ namespace MWScript
void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext) void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
{ {
// compile script // compile script
std::map<std::string, std::vector<Interpreter::Type_Code> >::iterator iter = ScriptCollection::iterator iter = mScripts.find (name);
mScripts.find (name);
if (iter==mScripts.end()) if (iter==mScripts.end())
{ {
@ -86,7 +85,7 @@ namespace MWScript
{ {
// failed -> ignore script from now on. // failed -> ignore script from now on.
std::vector<Interpreter::Type_Code> empty; std::vector<Interpreter::Type_Code> empty;
mScripts.insert (std::make_pair (name, empty)); mScripts.insert (std::make_pair (name, std::make_pair (empty, Compiler::Locals())));
return; return;
} }
@ -95,7 +94,7 @@ namespace MWScript
} }
// execute script // execute script
if (!iter->second.empty()) if (!iter->second.first.empty())
try try
{ {
if (!mOpcodesInstalled) if (!mOpcodesInstalled)
@ -104,7 +103,7 @@ namespace MWScript
mOpcodesInstalled = true; mOpcodesInstalled = true;
} }
mInterpreter.run (&iter->second[0], iter->second.size(), interpreterContext); mInterpreter.run (&iter->second.first[0], iter->second.first.size(), interpreterContext);
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
@ -113,7 +112,7 @@ namespace MWScript
if (mVerbose) if (mVerbose)
std::cerr << "(" << e.what() << ")" << std::endl; std::cerr << "(" << e.what() << ")" << std::endl;
iter->second.clear(); // don't execute again. iter->second.first.clear(); // don't execute again.
} }
} }
@ -132,4 +131,24 @@ namespace MWScript
return std::make_pair (count, success); return std::make_pair (count, success);
} }
Compiler::Locals& ScriptManager::getLocals (const std::string& name)
{
ScriptCollection::iterator iter = mScripts.find (name);
if (iter==mScripts.end())
{
if (!compile (name))
{
// failed -> ignore script from now on.
std::vector<Interpreter::Type_Code> empty;
mScripts.insert (std::make_pair (name, std::make_pair (empty, Compiler::Locals())));
throw std::runtime_error ("failed to compile script " + name);
}
iter = mScripts.find (name);
}
return iter->second.second;
}
} }

View file

@ -39,7 +39,11 @@ namespace MWScript
Interpreter::Interpreter mInterpreter; Interpreter::Interpreter mInterpreter;
bool mOpcodesInstalled; bool mOpcodesInstalled;
std::map<std::string, std::vector<Interpreter::Type_Code> > mScripts; typedef std::pair<std::vector<Interpreter::Type_Code>, Compiler::Locals> CompiledScript;
typedef std::map<std::string, CompiledScript> ScriptCollection;
ScriptCollection mScripts;
public: public:
@ -56,6 +60,9 @@ namespace MWScript
std::pair<int, int> compileAll(); std::pair<int, int> compileAll();
///< Compile all scripts ///< Compile all scripts
/// \return count, success /// \return count, success
Compiler::Locals& getLocals (const std::string& name);
///< Return locals for script \a name.
}; };
}; };

View file

@ -67,6 +67,7 @@ namespace MWSound
, updater(mgr) , updater(mgr)
, cameraTracker(mgr) , cameraTracker(mgr)
, mCurrentPlaylist(NULL) , mCurrentPlaylist(NULL)
, mUsingSound(useSound)
{ {
if(useSound) if(useSound)
{ {
@ -105,8 +106,11 @@ namespace MWSound
SoundManager::~SoundManager() SoundManager::~SoundManager()
{ {
Ogre::Root::getSingleton().removeFrameListener(&updater); if(mUsingSound)
cameraTracker.unfollowCamera(); {
Ogre::Root::getSingleton().removeFrameListener(&updater);
cameraTracker.unfollowCamera();
}
} }
// Convert a soundId to file name, and modify the volume // Convert a soundId to file name, and modify the volume
@ -136,7 +140,7 @@ namespace MWSound
max = std::max(min, max); max = std::max(min, max);
} }
return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict); return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict, false);
} }
// Add a sound to the list and play it // Add a sound to the list and play it
@ -145,7 +149,7 @@ namespace MWSound
const std::string &id, const std::string &id,
float volume, float pitch, float volume, float pitch,
float min, float max, float min, float max,
bool loop) bool loop, bool untracked)
{ {
try try
{ {
@ -157,7 +161,10 @@ namespace MWSound
setPos(snd, ptr); setPos(snd, ptr);
snd->play(); snd->play();
sounds[ptr][id] = WSoundPtr(snd); if (!untracked)
{
sounds[ptr][id] = WSoundPtr(snd);
}
} }
catch(...) catch(...)
{ {
@ -290,7 +297,7 @@ namespace MWSound
void SoundManager::streamMusic(const std::string& filename) void SoundManager::streamMusic(const std::string& filename)
{ {
std::string filePath = mMusicLibrary.locate(filename, mFSStrict).string(); std::string filePath = mMusicLibrary.locate(filename, mFSStrict, true).string();
if(!filePath.empty()) if(!filePath.empty())
{ {
streamMusicFull(filePath); streamMusicFull(filePath);
@ -351,6 +358,9 @@ namespace MWSound
void SoundManager::playPlaylist(std::string playlist) void SoundManager::playPlaylist(std::string playlist)
{ {
if (!mUsingSound)
return;
if (playlist == "") if (playlist == "")
{ {
if(!isMusicPlaying()) if(!isMusicPlaying())
@ -372,8 +382,11 @@ namespace MWSound
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
{ {
if (!mUsingSound)
return;
// The range values are not tested // The range values are not tested
std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict); std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict, true);
if(!filePath.empty()) if(!filePath.empty())
add(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false); add(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false);
else else
@ -397,6 +410,7 @@ namespace MWSound
snd->setVolume(volume); snd->setVolume(volume);
snd->setRange(min,max); snd->setRange(min,max);
snd->setPitch(pitch); snd->setPitch(pitch);
snd->setRelative(true);
snd->play(); snd->play();
if (loop) if (loop)
@ -412,13 +426,13 @@ namespace MWSound
} }
void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId, void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId,
float volume, float pitch, bool loop) float volume, float pitch, bool loop, bool untracked)
{ {
// Look up the sound in the ESM data // Look up the sound in the ESM data
float min, max; float min, max;
const std::string &file = lookup(soundId, volume, min, max); const std::string &file = lookup(soundId, volume, min, max);
if (file != "") if (file != "")
add(file, ptr, soundId, volume, pitch, min, max, loop); add(file, ptr, soundId, volume, pitch, min, max, loop, untracked);
} }
void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId) void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId)

View file

@ -82,12 +82,14 @@ namespace MWSound
IDMap mLoopedSounds; IDMap mLoopedSounds;
bool mUsingSound;
std::string lookup(const std::string &soundId, std::string lookup(const std::string &soundId,
float &volume, float &min, float &max); float &volume, float &min, float &max);
void add(const std::string &file, void add(const std::string &file,
MWWorld::Ptr ptr, const std::string &id, MWWorld::Ptr ptr, const std::string &id,
float volume, float pitch, float min, float max, float volume, float pitch, float min, float max,
bool loop); bool loop, bool untracked=false);
void clearAll(PtrMap::iterator& it); void clearAll(PtrMap::iterator& it);
void remove(MWWorld::Ptr ptr, const std::string &id = ""); void remove(MWWorld::Ptr ptr, const std::string &id = "");
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const; bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
@ -136,7 +138,7 @@ namespace MWSound
///< Play a sound, independently of 3D-position ///< Play a sound, independently of 3D-position
void playSound3D (MWWorld::Ptr reference, const std::string& soundId, void playSound3D (MWWorld::Ptr reference, const std::string& soundId,
float volume, float pitch, bool loop); float volume, float pitch, bool loop, bool untracked=false);
///< Play a sound from an object ///< Play a sound from an object
void stopSound3D (MWWorld::Ptr reference, const std::string& soundId = ""); void stopSound3D (MWWorld::Ptr reference, const std::string& soundId = "");

View file

@ -132,7 +132,7 @@ namespace MWWorld
return std::make_pair (std::vector<int>(), false); return std::make_pair (std::vector<int>(), false);
} }
int Class::getEuqipmentSkill (const Ptr& ptr, const Environment& environment) const int Class::getEquipmentSkill (const Ptr& ptr, const Environment& environment) const
{ {
return -1; return -1;
} }
@ -156,4 +156,14 @@ namespace MWWorld
{ {
sClasses.insert (std::make_pair (key, instance)); sClasses.insert (std::make_pair (key, instance));
} }
std::string Class::getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const
{
throw std::runtime_error ("class does not have an up sound");
}
std::string Class::getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const
{
throw std::runtime_error ("class does not have an down sound");
}
} }

View file

@ -149,7 +149,7 @@ namespace MWWorld
/// ///
/// Default implementation: return (empty vector, false). /// Default implementation: return (empty vector, false).
virtual int getEuqipmentSkill (const Ptr& ptr, const Environment& environment) virtual int getEquipmentSkill (const Ptr& ptr, const Environment& environment)
const; const;
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is /// Return the index of the skill this item corresponds to when equiopped or -1, if there is
/// no such skill. /// no such skill.
@ -162,6 +162,14 @@ namespace MWWorld
///< If there is no class for this pointer, an exception is thrown. ///< If there is no class for this pointer, an exception is thrown.
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance); static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
virtual std::string getUpSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the up sound ID of \a ptr or throw an exception, if class does not support ID retrieval
/// (default implementation: throw an exception)
virtual std::string getDownSoundId (const Ptr& ptr, const MWWorld::Environment& environment) const;
///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval
/// (default implementation: throw an exception)
}; };
} }

View file

@ -8,6 +8,29 @@
#include <components/esm/loadcont.hpp> #include <components/esm/loadcont.hpp>
#include "manualref.hpp" #include "manualref.hpp"
#include "refdata.hpp"
namespace
{
template<typename T>
float getTotalWeight (const ESMS::CellRefList<T, MWWorld::RefData>& cellRefList)
{
float sum = 0;
for (typename ESMS::CellRefList<T, MWWorld::RefData>::List::const_iterator iter (
cellRefList.list.begin());
iter!=cellRefList.list.end();
++iter)
{
if (iter->mData.getCount()>0)
sum += iter->mData.getCount()*iter->base->data.weight;
}
return sum;
}
}
MWWorld::ContainerStore::ContainerStore() : mStateId (0), mCachedWeight (0), mWeightUpToDate (false) {}
MWWorld::ContainerStore::~ContainerStore() {} MWWorld::ContainerStore::~ContainerStore() {}
@ -40,6 +63,8 @@ void MWWorld::ContainerStore::add (const Ptr& ptr)
case Type_Repair: repairs.list.push_back (*ptr.get<ESM::Repair>()); break; case Type_Repair: repairs.list.push_back (*ptr.get<ESM::Repair>()); break;
case Type_Weapon: weapons.list.push_back (*ptr.get<ESM::Weapon>()); break; case Type_Weapon: weapons.list.push_back (*ptr.get<ESM::Weapon>()); break;
} }
flagAsModified();
} }
void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS::ESMStore& store) void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS::ESMStore& store)
@ -58,6 +83,8 @@ void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS:
ref.getPtr().getRefData().setCount (iter->count); ref.getPtr().getRefData().setCount (iter->count);
add (ref.getPtr()); add (ref.getPtr());
} }
flagAsModified();
} }
void MWWorld::ContainerStore::clear() void MWWorld::ContainerStore::clear()
@ -74,6 +101,44 @@ void MWWorld::ContainerStore::clear()
probes.list.clear(); probes.list.clear();
repairs.list.clear(); repairs.list.clear();
weapons.list.clear(); weapons.list.clear();
flagAsModified();
}
void MWWorld::ContainerStore::flagAsModified()
{
++mStateId;
mWeightUpToDate = false;
}
int MWWorld::ContainerStore::getStateId() const
{
return mStateId;
}
float MWWorld::ContainerStore::getWeight() const
{
if (!mWeightUpToDate)
{
mCachedWeight = 0;
mCachedWeight += getTotalWeight (potions);
mCachedWeight += getTotalWeight (appas);
mCachedWeight += getTotalWeight (armors);
mCachedWeight += getTotalWeight (books);
mCachedWeight += getTotalWeight (clothes);
mCachedWeight += getTotalWeight (ingreds);
mCachedWeight += getTotalWeight (lights);
mCachedWeight += getTotalWeight (lockpicks);
mCachedWeight += getTotalWeight (miscItems);
mCachedWeight += getTotalWeight (probes);
mCachedWeight += getTotalWeight (repairs);
mCachedWeight += getTotalWeight (weapons);
mWeightUpToDate = true;
}
return mCachedWeight;
} }
int MWWorld::ContainerStore::getType (const Ptr& ptr) int MWWorld::ContainerStore::getType (const Ptr& ptr)
@ -301,23 +366,30 @@ MWWorld::Ptr *MWWorld::ContainerStoreIterator::operator->() const
MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const MWWorld::Ptr MWWorld::ContainerStoreIterator::operator*() const
{ {
Ptr ptr;
switch (mType) switch (mType)
{ {
case ContainerStore::Type_Potion: return MWWorld::Ptr (&*mPotion, 0); case ContainerStore::Type_Potion: ptr = MWWorld::Ptr (&*mPotion, 0); break;
case ContainerStore::Type_Apparatus: return MWWorld::Ptr (&*mApparatus, 0); case ContainerStore::Type_Apparatus: ptr = MWWorld::Ptr (&*mApparatus, 0); break;
case ContainerStore::Type_Armor: return MWWorld::Ptr (&*mArmor, 0); case ContainerStore::Type_Armor: ptr = MWWorld::Ptr (&*mArmor, 0); break;
case ContainerStore::Type_Book: return MWWorld::Ptr (&*mBook, 0); case ContainerStore::Type_Book: ptr = MWWorld::Ptr (&*mBook, 0); break;
case ContainerStore::Type_Clothing: return MWWorld::Ptr (&*mClothing, 0); case ContainerStore::Type_Clothing: ptr = MWWorld::Ptr (&*mClothing, 0); break;
case ContainerStore::Type_Ingredient: return MWWorld::Ptr (&*mIngredient, 0); case ContainerStore::Type_Ingredient: ptr = MWWorld::Ptr (&*mIngredient, 0); break;
case ContainerStore::Type_Light: return MWWorld::Ptr (&*mLight, 0); case ContainerStore::Type_Light: ptr = MWWorld::Ptr (&*mLight, 0); break;
case ContainerStore::Type_Lockpick: return MWWorld::Ptr (&*mLockpick, 0); case ContainerStore::Type_Lockpick: ptr = MWWorld::Ptr (&*mLockpick, 0); break;
case ContainerStore::Type_Miscellaneous: return MWWorld::Ptr (&*mMiscellaneous, 0); case ContainerStore::Type_Miscellaneous: ptr = MWWorld::Ptr (&*mMiscellaneous, 0); break;
case ContainerStore::Type_Probe: return MWWorld::Ptr (&*mProbe, 0); case ContainerStore::Type_Probe: ptr = MWWorld::Ptr (&*mProbe, 0); break;
case ContainerStore::Type_Repair: return MWWorld::Ptr (&*mRepair, 0); case ContainerStore::Type_Repair: ptr = MWWorld::Ptr (&*mRepair, 0); break;
case ContainerStore::Type_Weapon: return MWWorld::Ptr (&*mWeapon, 0); case ContainerStore::Type_Weapon: ptr = MWWorld::Ptr (&*mWeapon, 0); break;
} }
throw std::runtime_error ("invalid pointer"); if (ptr.isEmpty())
throw std::runtime_error ("invalid iterator");
ptr.setContainerStore (mContainer);
return ptr;
} }
MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++() MWWorld::ContainerStoreIterator& MWWorld::ContainerStoreIterator::operator++()

View file

@ -52,9 +52,14 @@ namespace MWWorld
ESMS::CellRefList<ESM::Probe, RefData> probes; ESMS::CellRefList<ESM::Probe, RefData> probes;
ESMS::CellRefList<ESM::Repair, RefData> repairs; ESMS::CellRefList<ESM::Repair, RefData> repairs;
ESMS::CellRefList<ESM::Weapon, RefData> weapons; ESMS::CellRefList<ESM::Weapon, RefData> weapons;
int mStateId;
mutable float mCachedWeight;
mutable bool mWeightUpToDate;
public: public:
ContainerStore();
virtual ~ContainerStore(); virtual ~ContainerStore();
ContainerStoreIterator begin (int mask = Type_All); ContainerStoreIterator begin (int mask = Type_All);
@ -75,6 +80,18 @@ namespace MWWorld
void clear(); void clear();
///< Empty container. ///< Empty container.
void flagAsModified();
///< \attention This function is internal to the world model and should not be called from
/// outside.
int getStateId() const;
///< This ID is changed every time the container is modified or items in the container
/// are accessed in a way that may be used to modify the item.
/// \note This method of change-tracking will ocasionally yield false positives.
float getWeight() const;
///< Return total weight of the items contained in *this.
static int getType (const Ptr& ptr); static int getType (const Ptr& ptr);
///< This function throws an exception, if ptr does not point to an object, that can be ///< This function throws an exception, if ptr does not point to an object, that can be
/// put into a container. /// put into a container.

View file

@ -9,6 +9,7 @@ namespace MWSound
namespace MWScript namespace MWScript
{ {
class GlobalScripts; class GlobalScripts;
class ScriptManager;
} }
namespace MWGui namespace MWGui
@ -41,7 +42,7 @@ namespace MWWorld
{ {
public: public:
Environment() Environment()
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mWindowManager (0), : mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0),
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0), mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0),
mInputManager (0) mInputManager (0)
{} {}
@ -49,6 +50,7 @@ namespace MWWorld
World *mWorld; World *mWorld;
MWSound::SoundManager *mSoundManager; MWSound::SoundManager *mSoundManager;
MWScript::GlobalScripts *mGlobalScripts; MWScript::GlobalScripts *mGlobalScripts;
MWScript::ScriptManager *mScriptManager;
MWGui::WindowManager *mWindowManager; MWGui::WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager; MWMechanics::MechanicsManager *mMechanicsManager;
MWDialogue::DialogueManager *mDialogueManager; MWDialogue::DialogueManager *mDialogueManager;

View file

@ -65,6 +65,8 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
/// \todo unstack item pointed to by iterator if required) /// \todo unstack item pointed to by iterator if required)
mSlots[slot] = iterator; mSlots[slot] = iterator;
flagAsModified();
} }
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot)

View file

@ -0,0 +1,39 @@
#include "ptr.hpp"
#include <cassert>
#include "containerstore.hpp"
ESM::CellRef& MWWorld::Ptr::getCellRef() const
{
assert (mCellRef);
if (mContainerStore)
mContainerStore->flagAsModified();
return *mCellRef;
}
MWWorld::RefData& MWWorld::Ptr::getRefData() const
{
assert (mRefData);
if (mContainerStore)
mContainerStore->flagAsModified();
return *mRefData;
}
void MWWorld::Ptr::setContainerStore (ContainerStore *store)
{
assert (store);
assert (!mCell);
mContainerStore = store;
}
MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
{
return mContainerStore;
}

View file

@ -13,6 +13,8 @@
namespace MWWorld namespace MWWorld
{ {
class ContainerStore;
/// \brief Pointer to a LiveCellRef /// \brief Pointer to a LiveCellRef
class Ptr class Ptr
@ -26,10 +28,11 @@ namespace MWWorld
RefData *mRefData; RefData *mRefData;
CellStore *mCell; CellStore *mCell;
std::string mTypeName; std::string mTypeName;
ContainerStore *mContainerStore;
public: public:
Ptr() : mCellRef (0), mRefData (0), mCell (0) {} Ptr() : mCellRef (0), mRefData (0), mCell (0), mContainerStore (0) {}
bool isEmpty() const bool isEmpty() const
{ {
@ -49,6 +52,7 @@ namespace MWWorld
template<typename T> template<typename T>
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell) Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
: mContainerStore (0)
{ {
mPtr = liveCellRef; mPtr = liveCellRef;
mCellRef = &liveCellRef->ref; mCellRef = &liveCellRef->ref;
@ -63,23 +67,21 @@ namespace MWWorld
return boost::any_cast<ESMS::LiveCellRef<T, RefData>*> (mPtr); return boost::any_cast<ESMS::LiveCellRef<T, RefData>*> (mPtr);
} }
ESM::CellRef& getCellRef() const ESM::CellRef& getCellRef() const;
{
assert (mCellRef);
return *mCellRef;
}
RefData& getRefData() const RefData& getRefData() const;
{
assert (mRefData);
return *mRefData;
}
Ptr::CellStore *getCell() const Ptr::CellStore *getCell() const
{ {
assert (mCell); assert (mCell);
return mCell; return mCell;
} }
void setContainerStore (ContainerStore *store);
///< Must not be called on references that are in a cell.
ContainerStore *getContainerStore() const;
///< May return a 0-pointer, if reference is not in a container.
}; };
inline bool operator== (const Ptr& left, const Ptr& right) inline bool operator== (const Ptr& left, const Ptr& right)

View file

@ -21,6 +21,18 @@ const std::string WeatherGlobals::mThunderSoundID0 = "Thunder0";
const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1";
const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2";
const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3";
const float WeatherGlobals::mSunriseTime = 8;
const float WeatherGlobals::mSunsetTime = 18;
const float WeatherGlobals::mSunriseDuration = 2;
const float WeatherGlobals::mSunsetDuration = 2;
const float WeatherGlobals::mWeatherUpdateTime = 20.f;
// morrowind sets these per-weather, but since they are only used by 'thunderstorm'
// weather setting anyway, we can just as well set them globally
const float WeatherGlobals::mThunderFrequency = .4;
const float WeatherGlobals::mThunderThreshold = 0.6;
const float WeatherGlobals::mThunderSoundDelay = 0.25;
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) :
mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0),
@ -259,7 +271,8 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen
blight.mGlareView = 0; blight.mGlareView = 0;
blight.mAmbientLoopSoundID = "blight"; blight.mAmbientLoopSoundID = "blight";
mWeatherSettings["blight"] = blight; mWeatherSettings["blight"] = blight;
/*
Weather snow; Weather snow;
snow.mCloudTexture = "tx_bm_sky_snow.dds"; snow.mCloudTexture = "tx_bm_sky_snow.dds";
snow.mCloudsMaximumPercent = 1.0; snow.mCloudsMaximumPercent = 1.0;
@ -316,10 +329,14 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen
blizzard.mGlareView = 0; blizzard.mGlareView = 0;
blizzard.mAmbientLoopSoundID = "BM Blizzard"; blizzard.mAmbientLoopSoundID = "BM Blizzard";
mWeatherSettings["blizzard"] = blizzard; mWeatherSettings["blizzard"] = blizzard;
*/
} }
void WeatherManager::setWeather(const String& weather, bool instant) void WeatherManager::setWeather(const String& weather, bool instant)
{ {
if (weather == mCurrentWeather && mNextWeather == "")
return;
if (instant || mFirstUpdate) if (instant || mFirstUpdate)
{ {
mNextWeather = ""; mNextWeather = "";
@ -331,12 +348,12 @@ void WeatherManager::setWeather(const String& weather, bool instant)
if (mNextWeather != "") if (mNextWeather != "")
{ {
// transition more than 50% finished? // transition more than 50% finished?
if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60) <= 0.5) if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600) <= 0.5)
mCurrentWeather = mNextWeather; mCurrentWeather = mNextWeather;
} }
mNextWeather = weather; mNextWeather = weather;
mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60; mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600;
} }
} }
@ -344,7 +361,7 @@ WeatherResult WeatherManager::getResult(const String& weather)
{ {
const Weather& current = mWeatherSettings[weather]; const Weather& current = mWeatherSettings[weather];
WeatherResult result; WeatherResult result;
result.mCloudTexture = current.mCloudTexture; result.mCloudTexture = current.mCloudTexture;
result.mCloudBlendFactor = 0; result.mCloudBlendFactor = 0;
result.mCloudOpacity = current.mCloudsMaximumPercent; result.mCloudOpacity = current.mCloudsMaximumPercent;
@ -353,16 +370,13 @@ WeatherResult WeatherManager::getResult(const String& weather)
result.mGlareView = current.mGlareView; result.mGlareView = current.mGlareView;
result.mAmbientLoopSoundID = current.mAmbientLoopSoundID; result.mAmbientLoopSoundID = current.mAmbientLoopSoundID;
result.mSunColor = current.mSunDiscSunsetColor; result.mSunColor = current.mSunDiscSunsetColor;
const float fade_duration = current.mTransitionDelta * 24.f; result.mNight = (mHour < 6 || mHour > 19);
result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration);
result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth;
// night // night
if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) if (mHour <= 5.5f || mHour >= 21)
|| mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration))
{ {
result.mFogColor = current.mFogNightColor; result.mFogColor = current.mFogNightColor;
result.mAmbientColor = current.mAmbientNightColor; result.mAmbientColor = current.mAmbientNightColor;
@ -370,82 +384,68 @@ WeatherResult WeatherManager::getResult(const String& weather)
result.mSkyColor = current.mSkyNightColor; result.mSkyColor = current.mSkyNightColor;
result.mNightFade = 1.f; result.mNightFade = 1.f;
} }
// sunrise // sunrise
else if (mHour >= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) && mHour <= WeatherGlobals::mSunriseTime) else if (mHour >= 5.5f && mHour <= 9)
{ {
if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)) if (mHour <= 6)
{ {
// fade in // fade in
float advance = (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)-mHour; float advance = 6-mHour;
float factor = (advance / fade_duration); float factor = advance / 0.5f;
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor); result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor);
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor);
result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor); result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor);
result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor); result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor);
result.mNightFade = factor; result.mNightFade = factor;
} }
else if (mHour >= (WeatherGlobals::mSunriseTime-fade_duration)) else //if (mHour >= 6)
{ {
// fade out // fade out
float advance = mHour-(WeatherGlobals::mSunriseTime-fade_duration); float advance = mHour-6;
float factor = advance / fade_duration; float factor = advance / 3.f;
result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor);
result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor);
result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor); result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor);
result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor); result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor);
} }
else
{
result.mFogColor = current.mFogSunriseColor;
result.mAmbientColor = current.mAmbientSunriseColor;
result.mSunColor = current.mSunSunriseColor;
result.mSkyColor = current.mSkySunriseColor;
}
} }
// day // day
else if (mHour >= (WeatherGlobals::mSunriseTime) && mHour <= (WeatherGlobals::mSunsetTime)) else if (mHour >= 9 && mHour <= 17)
{ {
result.mFogColor = current.mFogDayColor; result.mFogColor = current.mFogDayColor;
result.mAmbientColor = current.mAmbientDayColor; result.mAmbientColor = current.mAmbientDayColor;
result.mSunColor = current.mSunDayColor; result.mSunColor = current.mSunDayColor;
result.mSkyColor = current.mSkyDayColor; result.mSkyColor = current.mSkyDayColor;
} }
// sunset // sunset
else if (mHour >= (WeatherGlobals::mSunsetTime) && mHour <= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) else if (mHour >= 17 && mHour <= 21)
{ {
if (mHour <= (WeatherGlobals::mSunsetTime+fade_duration)) if (mHour <= 19)
{ {
// fade in // fade in
float advance = (WeatherGlobals::mSunsetTime+fade_duration)-mHour; float advance = 19-mHour;
float factor = (advance / fade_duration); float factor = (advance / 2);
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor); result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor);
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor); result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor);
result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor); result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor);
result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor); result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor);
} }
else if (mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration)) else //if (mHour >= 19)
{ {
// fade out // fade out
float advance = mHour-(WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration); float advance = mHour-19;
float factor = advance / fade_duration; float factor = advance / 2.f;
result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor); result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor);
result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor); result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor);
result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor); result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor);
result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor); result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor);
result.mNightFade = factor; result.mNightFade = factor;
} }
else
{
result.mFogColor = current.mFogSunsetColor;
result.mAmbientColor = current.mAmbientSunsetColor;
result.mSunColor = current.mSunSunsetColor;
result.mSkyColor = current.mSkySunsetColor;
}
} }
return result; return result;
} }
@ -454,41 +454,37 @@ WeatherResult WeatherManager::transition(float factor)
const WeatherResult& current = getResult(mCurrentWeather); const WeatherResult& current = getResult(mCurrentWeather);
const WeatherResult& other = getResult(mNextWeather); const WeatherResult& other = getResult(mNextWeather);
WeatherResult result; WeatherResult result;
result.mCloudTexture = current.mCloudTexture; result.mCloudTexture = current.mCloudTexture;
result.mNextCloudTexture = other.mCloudTexture; result.mNextCloudTexture = other.mCloudTexture;
result.mCloudBlendFactor = factor; result.mCloudBlendFactor = factor;
result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity);
result.mFogColor = lerp(current.mFogColor, other.mFogColor); result.mFogColor = lerp(current.mFogColor, other.mFogColor);
result.mSunColor = lerp(current.mSunColor, other.mSunColor); result.mSunColor = lerp(current.mSunColor, other.mSunColor);
result.mSkyColor = lerp(current.mSkyColor, other.mSkyColor); result.mSkyColor = lerp(current.mSkyColor, other.mSkyColor);
result.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor); result.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor);
result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor);
result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth);
result.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed); result.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed);
result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); //result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed);
result.mCloudSpeed = current.mCloudSpeed;
result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity);
result.mGlareView = lerp(current.mGlareView, other.mGlareView); result.mGlareView = lerp(current.mGlareView, other.mGlareView);
result.mNight = current.mNight; result.mNight = current.mNight;
// sound change behaviour:
// if 'other' has a new sound, switch to it after 1/2 of the transition length
if (other.mAmbientLoopSoundID != "")
result.mAmbientLoopSoundID = factor>0.5 ? other.mAmbientLoopSoundID : current.mAmbientLoopSoundID;
// if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately
else if (current.mAmbientLoopSoundID != "")
result.mAmbientLoopSoundID = "";
return result; return result;
} }
void WeatherManager::update(float duration) void WeatherManager::update(float duration)
{ {
mWeatherUpdateTime -= duration; mWeatherUpdateTime -= duration * mEnvironment->mWorld->getTimeScaleFactor();
if (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior())
bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior());
if (exterior)
{ {
std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region;
boost::algorithm::to_lower(regionstr); boost::algorithm::to_lower(regionstr);
@ -496,17 +492,17 @@ void WeatherManager::update(float duration)
if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion)
{ {
mCurrentRegion = regionstr; mCurrentRegion = regionstr;
mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*3600;
std::string weather; std::string weather;
if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) if (mRegionOverrides.find(regionstr) != mRegionOverrides.end())
weather = mRegionOverrides[regionstr]; weather = mRegionOverrides[regionstr];
else else
{ {
// get weather probabilities for the current region // get weather probabilities for the current region
const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr);
float clear = region->data.clear/255.f; float clear = region->data.clear/255.f;
float cloudy = region->data.cloudy/255.f; float cloudy = region->data.cloudy/255.f;
float foggy = region->data.foggy/255.f; float foggy = region->data.foggy/255.f;
@ -515,86 +511,84 @@ void WeatherManager::update(float duration)
float thunder = region->data.thunder/255.f; float thunder = region->data.thunder/255.f;
float ash = region->data.ash/255.f; float ash = region->data.ash/255.f;
float blight = region->data.blight/255.f; float blight = region->data.blight/255.f;
float snow = region->data.a/255.f; //float snow = region->data.a/255.f;
float blizzard = region->data.b/255.f; //float blizzard = region->data.b/255.f;
// re-scale to 100 percent // re-scale to 100 percent
const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard;
srand(time(NULL)); srand(time(NULL));
float random = ((rand()%100)/100.f) * total; float random = ((rand()%100)/100.f) * total;
if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) //if (random > snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
weather = "blizzard"; // weather = "blizzard";
else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) //else if (random > blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
weather = "snow"; // weather = "snow";
else if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) /*else*/ if (random > ash+thunder+rain+overcast+foggy+cloudy+clear)
weather = "blight"; weather = "blight";
else if (random >= thunder+rain+overcast+foggy+cloudy+clear) else if (random > thunder+rain+overcast+foggy+cloudy+clear)
weather = "ashstorm"; weather = "ashstorm";
else if (random >= rain+overcast+foggy+cloudy+clear) else if (random > rain+overcast+foggy+cloudy+clear)
weather = "thunderstorm"; weather = "thunderstorm";
else if (random >= overcast+foggy+cloudy+clear) else if (random > overcast+foggy+cloudy+clear)
weather = "rain"; weather = "rain";
else if (random >= foggy+cloudy+clear) else if (random > foggy+cloudy+clear)
weather = "overcast"; weather = "overcast";
else if (random >= cloudy+clear) else if (random > cloudy+clear)
weather = "foggy"; weather = "foggy";
else if (random >= clear) else if (random > clear)
weather = "cloudy"; weather = "cloudy";
else else
weather = "clear"; weather = "clear";
} }
setWeather(weather, false); setWeather(weather, false);
/*
std::cout << "roll result: " << random << std::endl;
std::cout << regionstr << " weather probabilities: " << clear << " " << cloudy << " " << foggy << " "
<< overcast << " " << rain << " " << thunder << " " << ash << " " << blight << " " << snow << " "
<< blizzard << std::endl;
std::cout << "New weather : " << weather << std::endl;
*/
} }
WeatherResult result; WeatherResult result;
if (mNextWeather != "") if (mNextWeather != "")
{ {
mRemainingTransitionTime -= duration; mRemainingTransitionTime -= duration * mEnvironment->mWorld->getTimeScaleFactor();
if (mRemainingTransitionTime < 0) if (mRemainingTransitionTime < 0)
{ {
mCurrentWeather = mNextWeather; mCurrentWeather = mNextWeather;
mNextWeather = ""; mNextWeather = "";
} }
} }
if (mNextWeather != "") if (mNextWeather != "")
result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600)));
else else
result = getResult(mCurrentWeather); result = getResult(mCurrentWeather);
mRendering->configureFog(result.mFogDepth, result.mFogColor); mRendering->configureFog(result.mFogDepth, result.mFogColor);
// disable sun during night // disable sun during night
if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration if (mHour >= 20 || mHour <= 6.f)
|| mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration)
mRendering->getSkyManager()->sunDisable(); mRendering->getSkyManager()->sunDisable();
else else
{
// during day, calculate sun angle
float height = 1-std::abs(((mHour-13)/7.f));
int facing = mHour > 13.f ? 1 : -1;
Vector3 final(
(1-height)*facing,
(1-height)*facing,
height);
mRendering->setSunDirection(final);
mRendering->getSkyManager()->sunEnable(); mRendering->getSkyManager()->sunEnable();
}
// sun angle
float height;
// rise at 6, set at 20
if (mHour >= 6 && mHour <= 20)
height = 1-std::abs(((mHour-13)/7.f));
else if (mHour > 20)
height = (mHour-20.f)/4.f;
else //if (mHour > 0 && mHour < 6)
height = 1-(mHour/6.f);
int facing = (mHour > 13.f) ? 1 : -1;
Vector3 final(
(1-height)*facing,
(1-height)*facing,
height);
mRendering->setSunDirection(final);
// moon calculations // moon calculations
float night; float night;
if (mHour >= 14) if (mHour >= 14)
@ -603,9 +597,9 @@ void WeatherManager::update(float duration)
night = mHour+10; night = mHour+10;
else else
night = 0; night = 0;
night /= 20.f; night /= 20.f;
if (night != 0) if (night != 0)
{ {
float moonHeight = 1-std::abs((night-0.5)*2); float moonHeight = 1-std::abs((night-0.5)*2);
@ -614,17 +608,17 @@ void WeatherManager::update(float duration)
(1-moonHeight)*facing, (1-moonHeight)*facing,
(1-moonHeight)*facing, (1-moonHeight)*facing,
moonHeight); moonHeight);
Vector3 secunda( Vector3 secunda(
(1-moonHeight)*facing*0.8, (1-moonHeight)*facing*0.8,
(1-moonHeight)*facing*1.25, (1-moonHeight)*facing*1.25,
moonHeight); moonHeight);
mRendering->getSkyManager()->setMasserDirection(masser); mRendering->getSkyManager()->setMasserDirection(masser);
mRendering->getSkyManager()->setSecundaDirection(secunda); mRendering->getSkyManager()->setSecundaDirection(secunda);
mRendering->getSkyManager()->masserEnable(); mRendering->getSkyManager()->masserEnable();
mRendering->getSkyManager()->secundaEnable(); mRendering->getSkyManager()->secundaEnable();
float hour_fade; float hour_fade;
if (mHour >= 7.f && mHour <= 14.f) if (mHour >= 7.f && mHour <= 14.f)
hour_fade = 1-(mHour-7)/3.f; hour_fade = 1-(mHour-7)/3.f;
@ -632,28 +626,28 @@ void WeatherManager::update(float duration)
hour_fade = mHour-14; hour_fade = mHour-14;
else else
hour_fade = 1; hour_fade = 1;
float secunda_angle_fade; float secunda_angle_fade;
float masser_angle_fade; float masser_angle_fade;
float angle = moonHeight*90.f; float angle = moonHeight*90.f;
if (angle >= 30 && angle <= 50) if (angle >= 30 && angle <= 50)
secunda_angle_fade = (angle-30)/20.f; secunda_angle_fade = (angle-30)/20.f;
else if (angle <30) else if (angle <30)
secunda_angle_fade = 0.f; secunda_angle_fade = 0.f;
else else
secunda_angle_fade = 1.f; secunda_angle_fade = 1.f;
if (angle >= 40 && angle <= 50) if (angle >= 40 && angle <= 50)
masser_angle_fade = (angle-40)/10.f; masser_angle_fade = (angle-40)/10.f;
else if (angle <40) else if (angle <40)
masser_angle_fade = 0.f; masser_angle_fade = 0.f;
else else
masser_angle_fade = 1.f; masser_angle_fade = 1.f;
masser_angle_fade *= hour_fade; masser_angle_fade *= hour_fade;
secunda_angle_fade *= hour_fade; secunda_angle_fade *= hour_fade;
mRendering->getSkyManager()->setMasserFade(masser_angle_fade); mRendering->getSkyManager()->setMasserFade(masser_angle_fade);
mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade); mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade);
} }
@ -662,8 +656,8 @@ void WeatherManager::update(float duration)
mRendering->getSkyManager()->masserDisable(); mRendering->getSkyManager()->masserDisable();
mRendering->getSkyManager()->secundaDisable(); mRendering->getSkyManager()->secundaDisable();
} }
if (mCurrentWeather == "thunderstorm" && mNextWeather == "") if (mCurrentWeather == "thunderstorm" && mNextWeather == "" && exterior)
{ {
if (mThunderFlash > 0) if (mThunderFlash > 0)
{ {
@ -681,7 +675,7 @@ void WeatherManager::update(float duration)
mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0);
mThunderSoundDelay = 1000; mThunderSoundDelay = 1000;
} }
mThunderFlash -= duration; mThunderFlash -= duration;
if (mThunderFlash > 0) if (mThunderFlash > 0)
mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold );
@ -700,20 +694,20 @@ void WeatherManager::update(float duration)
if (mThunderChance >= mThunderChanceNeeded) if (mThunderChance >= mThunderChanceNeeded)
{ {
mThunderFlash = WeatherGlobals::mThunderThreshold; mThunderFlash = WeatherGlobals::mThunderThreshold;
mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold );
mThunderSoundDelay = WeatherGlobals::mThunderSoundDelay; mThunderSoundDelay = WeatherGlobals::mThunderSoundDelay;
} }
} }
} }
else else
mRendering->getSkyManager()->setThunder(0.f); mRendering->getSkyManager()->setThunder(0.f);
mRendering->setAmbientColour(result.mAmbientColor); mRendering->setAmbientColour(result.mAmbientColor);
mRendering->sunEnable(); mRendering->sunEnable();
mRendering->setSunColour(result.mSunColor); mRendering->setSunColour(result.mSunColor);
mRendering->getSkyManager()->setWeather(result); mRendering->getSkyManager()->setWeather(result);
} }
else else
@ -725,6 +719,7 @@ void WeatherManager::update(float duration)
// play sounds // play sounds
std::string ambientSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mAmbientLoopSoundID : ""); std::string ambientSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mAmbientLoopSoundID : "");
if (!exterior) ambientSnd = "";
if (ambientSnd != "") if (ambientSnd != "")
{ {
if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end()) if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end())
@ -735,6 +730,7 @@ void WeatherManager::update(float duration)
} }
std::string rainSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mRainLoopSoundID : ""); std::string rainSnd = (mNextWeather == "" ? mWeatherSettings[mCurrentWeather].mRainLoopSoundID : "");
if (!exterior) rainSnd = "";
if (rainSnd != "") if (rainSnd != "")
{ {
if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end()) if (std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end())
@ -760,15 +756,6 @@ void WeatherManager::update(float duration)
void WeatherManager::setHour(const float hour) void WeatherManager::setHour(const float hour)
{ {
// accelerate a bit for testing
/*
mHour += 0.005;
if (mHour >= 24.f) mHour = 0.f;
std::cout << "hour " << mHour << std::endl;
*/
mHour = hour; mHour = hour;
} }

View file

@ -95,18 +95,18 @@ namespace MWWorld
Script Color=255,20,20 Script Color=255,20,20
*/ */
static const float mSunriseTime = 8; static const float mSunriseTime;
static const float mSunsetTime = 18; static const float mSunsetTime;
static const float mSunriseDuration = 2; static const float mSunriseDuration;
static const float mSunsetDuration = 2; static const float mSunsetDuration;
static const float mWeatherUpdateTime = 20.f; static const float mWeatherUpdateTime;
// morrowind sets these per-weather, but since they are only used by 'thunderstorm' // morrowind sets these per-weather, but since they are only used by 'thunderstorm'
// weather setting anyway, we can just as well set them globally // weather setting anyway, we can just as well set them globally
static const float mThunderFrequency = .4; static const float mThunderFrequency;
static const float mThunderThreshold = 0.6; static const float mThunderThreshold;
static const float mThunderSoundDelay = 0.25; static const float mThunderSoundDelay;
static const std::string mThunderSoundID0; static const std::string mThunderSoundID0;
static const std::string mThunderSoundID1; static const std::string mThunderSoundID1;
static const std::string mThunderSoundID2; static const std::string mThunderSoundID2;

View file

@ -161,9 +161,9 @@ namespace MWWorld
{ {
mPhysics = new PhysicsSystem(renderer); mPhysics = new PhysicsSystem(renderer);
mPhysEngine = mPhysics->getEngine(); mPhysEngine = mPhysics->getEngine();
mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment); mRendering = new MWRender::RenderingManager(renderer, resDir, mPhysEngine, environment);
mWeatherManager = new MWWorld::WeatherManager(mRendering, &environment); mWeatherManager = new MWWorld::WeatherManager(mRendering, &environment);
boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master)); boost::filesystem::path masterPath (fileCollections.getCollection (".esm").getPath (master));
@ -381,7 +381,7 @@ namespace MWWorld
mGlobalVariables->setFloat ("gamehour", hour); mGlobalVariables->setFloat ("gamehour", hour);
mRendering->skySetHour (hour); mRendering->skySetHour (hour);
mWeatherManager->setHour (hour); mWeatherManager->setHour (hour);
if (days>0) if (days>0)
@ -418,10 +418,10 @@ namespace MWWorld
mGlobalVariables->setInt ("month", month); mGlobalVariables->setInt ("month", month);
mRendering->skySetDate (day, month); mRendering->skySetDate (day, month);
mWeatherManager->setDate (day, month); mWeatherManager->setDate (day, month);
} }
void World::setMonth (int month) void World::setMonth (int month)
@ -478,7 +478,7 @@ namespace MWWorld
float World::getTimeScaleFactor() const float World::getTimeScaleFactor() const
{ {
return mGlobalVariables->getInt ("timescale"); return mGlobalVariables->getFloat ("timescale");
} }
void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
@ -702,9 +702,9 @@ namespace MWWorld
void World::update (float duration) void World::update (float duration)
{ {
mWorldScene->update (duration); mWorldScene->update (duration);
mWeatherManager->update (duration); mWeatherManager->update (duration);
// cast a ray from player to sun to detect if the sun is visible // cast a ray from player to sun to detect if the sun is visible
// this is temporary until we find a better place to put this code // this is temporary until we find a better place to put this code
// currently its here because we need to access the physics system // currently its here because we need to access the physics system
@ -713,7 +713,7 @@ namespace MWWorld
sun = Vector3(sun.x, -sun.z, sun.y); sun = Vector3(sun.x, -sun.z, sun.y);
mRendering->getSkyManager()->setGlare(!mPhysics->castRay(Ogre::Vector3(p[0], p[1], p[2]), sun)); mRendering->getSkyManager()->setGlare(!mPhysics->castRay(Ogre::Vector3(p[0], p[1], p[2]), sun));
} }
bool World::isCellExterior() const bool World::isCellExterior() const
{ {
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
@ -726,7 +726,7 @@ namespace MWWorld
} }
return false; return false;
} }
bool World::isCellQuasiExterior() const bool World::isCellQuasiExterior() const
{ {
Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); Ptr::CellStore *currentCell = mWorldScene->getCurrentCell();
@ -739,17 +739,17 @@ namespace MWWorld
} }
return false; return false;
} }
int World::getCurrentWeather() const int World::getCurrentWeather() const
{ {
return mWeatherManager->getWeatherID(); return mWeatherManager->getWeatherID();
} }
void World::changeWeather(const std::string& region, const unsigned int id) void World::changeWeather(const std::string& region, const unsigned int id)
{ {
mWeatherManager->changeWeather(region, id); mWeatherManager->changeWeather(region, id);
} }
OEngine::Render::Fader* World::getFader() OEngine::Render::Fader* World::getFader()
{ {
return mRendering->getFader(); return mRendering->getFader();

53
cmake/FindCg.cmake Normal file
View file

@ -0,0 +1,53 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find Cg
# Once done, this will define
#
# Cg_FOUND - system has Cg
# Cg_INCLUDE_DIRS - the Cg include directories
# Cg_LIBRARIES - link these to use Cg
include(FindPkgMacros)
findpkg_begin(Cg)
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(Cg_HOME)
getenv_path(OGRE_SOURCE)
getenv_path(OGRE_HOME)
# construct search paths
set(Cg_PREFIX_PATH ${Cg_HOME} ${ENV_Cg_HOME}
${OGRE_SOURCE}/Dependencies
${ENV_OGRE_SOURCE}/Dependencies
${OGRE_HOME} ${ENV_OGRE_HOME}
/opt/nvidia-cg-toolkit)
create_search_paths(Cg)
# redo search if prefix path changed
clear_if_changed(Cg_PREFIX_PATH
Cg_LIBRARY_FWK
Cg_LIBRARY_REL
Cg_LIBRARY_DBG
Cg_INCLUDE_DIR
)
set(Cg_LIBRARY_NAMES Cg)
get_debug_names(Cg_LIBRARY_NAMES)
use_pkgconfig(Cg_PKGC Cg)
findpkg_framework(Cg)
find_path(Cg_INCLUDE_DIR NAMES cg.h HINTS ${Cg_FRAMEWORK_INCLUDES} ${Cg_INC_SEARCH_PATH} ${Cg_PKGC_INCLUDE_DIRS} PATH_SUFFIXES Cg)
find_library(Cg_LIBRARY_REL NAMES ${Cg_LIBRARY_NAMES} HINTS ${Cg_LIB_SEARCH_PATH} ${Cg_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel)
find_library(Cg_LIBRARY_DBG NAMES ${Cg_LIBRARY_NAMES_DBG} HINTS ${Cg_LIB_SEARCH_PATH} ${Cg_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug)
make_library_set(Cg_LIBRARY)
findpkg_finish(Cg)
add_parent_dir(Cg_INCLUDE_DIRS Cg_INCLUDE_DIR)

47
cmake/FindFreeImage.cmake Normal file
View file

@ -0,0 +1,47 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find FreeImage
# Once done, this will define
#
# FreeImage_FOUND - system has FreeImage
# FreeImage_INCLUDE_DIRS - the FreeImage include directories
# FreeImage_LIBRARIES - link these to use FreeImage
include(FindPkgMacros)
findpkg_begin(FreeImage)
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(FREEIMAGE_HOME)
# construct search paths
set(FreeImage_PREFIX_PATH ${FREEIMAGE_HOME} ${ENV_FREEIMAGE_HOME})
create_search_paths(FreeImage)
# redo search if prefix path changed
clear_if_changed(FreeImage_PREFIX_PATH
FreeImage_LIBRARY_FWK
FreeImage_LIBRARY_REL
FreeImage_LIBRARY_DBG
FreeImage_INCLUDE_DIR
)
set(FreeImage_LIBRARY_NAMES freeimage)
get_debug_names(FreeImage_LIBRARY_NAMES)
use_pkgconfig(FreeImage_PKGC freeimage)
findpkg_framework(FreeImage)
find_path(FreeImage_INCLUDE_DIR NAMES FreeImage.h HINTS ${FreeImage_INC_SEARCH_PATH} ${FreeImage_PKGC_INCLUDE_DIRS})
find_library(FreeImage_LIBRARY_REL NAMES ${FreeImage_LIBRARY_NAMES} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel)
find_library(FreeImage_LIBRARY_DBG NAMES ${FreeImage_LIBRARY_NAMES_DBG} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug)
make_library_set(FreeImage_LIBRARY)
findpkg_finish(FreeImage)

125
cmake/FindMyGUI.cmake Normal file
View file

@ -0,0 +1,125 @@
# - Find MyGUI includes and library
#
# This module defines
# MYGUI_INCLUDE_DIRS
# MYGUI_LIBRARIES, the libraries to link against to use MYGUI.
# MYGUI_LIB_DIR, the location of the libraries
# MYGUI_FOUND, If false, do not try to use MYGUI
#
# Copyright © 2007, Matt Williams
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
CMAKE_POLICY(PUSH)
include(FindPkgMacros)
# IF (MYGUI_LIBRARIES AND MYGUI_INCLUDE_DIRS)
# SET(MYGUI_FIND_QUIETLY TRUE)
# ENDIF (MYGUI_LIBRARIES AND MYGUI_INCLUDE_DIRS)
IF (WIN32) #Windows
MESSAGE(STATUS "Looking for MyGUI")
SET(MYGUISDK $ENV{MYGUI_HOME})
IF (MYGUISDK)
findpkg_begin ( "MYGUI" )
MESSAGE(STATUS "Using MyGUI in OGRE SDK")
STRING(REGEX REPLACE "[\\]" "/" MYGUISDK "${MYGUISDK}" )
find_path ( MYGUI_INCLUDE_DIRS
MyGUI.h
"${MYGUISDK}/MyGUIEngine/include"
NO_DEFAULT_PATH )
find_path ( MYGUI_PLATFORM_INCLUDE_DIRS
MyGUI_OgrePlatform.h
"${MYGUISDK}/Platforms/Ogre/OgrePlatform/include"
NO_DEFAULT_PATH )
SET ( MYGUI_LIB_DIR ${MYGUISDK}/*/lib )
find_library ( MYGUI_LIBRARIES_REL NAMES
MyGUIEngine.lib
MyGUI.OgrePlatform.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" release relwithdebinfo minsizerel )
find_library ( MYGUI_LIBRARIES_DBG NAMES
MyGUIEngine_d.lib
MyGUI.OgrePlatform_d.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" debug )
find_library ( MYGUI_PLATFORM_LIBRARIES_REL NAMES
MyGUI.OgrePlatform.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" release relwithdebinfo minsizerel )
find_library ( MYGUI_PLATFORM_LIBRARIES_DBG NAMES
MyGUI.OgrePlatform_d.lib
HINTS
${MYGUI_LIB_DIR}
PATH_SUFFIXES "" debug )
make_library_set ( MYGUI_LIBRARIES )
make_library_set ( MYGUI_PLATFORM_LIBRARIES )
MESSAGE ("${MYGUI_LIBRARIES}")
MESSAGE ("${MYGUI_PLATFORM_LIBRARIES}")
findpkg_finish ( "MYGUI" )
ENDIF (MYGUISDK)
IF (OGRESOURCE)
MESSAGE(STATUS "Using MyGUI in OGRE dependencies")
STRING(REGEX REPLACE "[\\]" "/" OGRESDK "${OGRESOURCE}" )
SET(MYGUI_INCLUDE_DIRS ${OGRESOURCE}/OgreMain/include/MYGUI)
SET(MYGUI_LIB_DIR ${OGRESOURCE}/lib)
SET(MYGUI_LIBRARIES debug Debug/MyGUIEngine_d optimized Release/MyGUIEngine)
ENDIF (OGRESOURCE)
ELSE (WIN32) #Unix
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
FIND_PACKAGE(PkgConfig)
PKG_SEARCH_MODULE(MYGUI MYGUI MyGUI)
IF (MYGUI_INCLUDE_DIRS)
SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS})
SET(MYGUI_LIB_DIR ${MYGUI_LIBDIR})
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "")
ELSE (MYGUI_INCLUDE_DIRS)
FIND_PATH(MYGUI_INCLUDE_DIRS MyGUI.h PATHS /usr/local/include /usr/include PATH_SUFFIXES MyGUI MYGUI)
FIND_LIBRARY(MYGUI_LIBRARIES mygui PATHS /usr/lib /usr/local/lib)
SET(MYGUI_LIB_DIR ${MYGUI_LIBRARIES})
STRING(REGEX REPLACE "(.*)/.*" "\\1" MYGUI_LIB_DIR "${MYGUI_LIB_DIR}")
STRING(REGEX REPLACE ".*/" "" MYGUI_LIBRARIES "${MYGUI_LIBRARIES}")
ENDIF (MYGUI_INCLUDE_DIRS)
ENDIF (WIN32)
#Do some preparation
SEPARATE_ARGUMENTS(MYGUI_INCLUDE_DIRS)
SEPARATE_ARGUMENTS(MYGUI_LIBRARIES)
SEPARATE_ARGUMENTS(MYGUI_PLATFORM_LIBRARIES)
SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS} CACHE PATH "")
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "")
SET(MYGUI_LIBRARIES ${MYGUI_PLATFORM_LIBRARIES} CACHE STRING "")
SET(MYGUI_LIB_DIR ${MYGUI_LIB_DIR} CACHE PATH "")
IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES)
SET(MYGUI_FOUND TRUE)
ENDIF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES)
IF (MYGUI_FOUND)
MARK_AS_ADVANCED(MYGUI_LIB_DIR)
IF (NOT MYGUI_FIND_QUIETLY)
MESSAGE(STATUS " libraries : ${MYGUI_LIBRARIES} from ${MYGUI_LIB_DIR}")
MESSAGE(STATUS " includes : ${MYGUI_INCLUDE_DIRS}")
ENDIF (NOT MYGUI_FIND_QUIETLY)
ELSE (MYGUI_FOUND)
IF (MYGUI_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find MYGUI")
ENDIF (MYGUI_FIND_REQUIRED)
ENDIF (MYGUI_FOUND)
CMAKE_POLICY(POP)

View file

@ -18,7 +18,7 @@
# Once done, this will define # Once done, this will define
# #
# OGRE_FOUND - system has OGRE # OGRE_FOUND - system has OGRE
# OGRE_INCLUDE_DIRS - the OGRE include directories # OGRE_INCLUDE_DIRS - the OGRE include directories
# OGRE_LIBRARIES - link these to use the OGRE core # OGRE_LIBRARIES - link these to use the OGRE core
# OGRE_BINARY_REL - location of the main Ogre binary (win32 non-static only, release) # OGRE_BINARY_REL - location of the main Ogre binary (win32 non-static only, release)
# OGRE_BINARY_DBG - location of the main Ogre binaries (win32 non-static only, debug) # OGRE_BINARY_DBG - location of the main Ogre binaries (win32 non-static only, debug)
@ -28,15 +28,14 @@
# Plugin_BSPSceneManager, Plugin_CgProgramManager, # Plugin_BSPSceneManager, Plugin_CgProgramManager,
# Plugin_OctreeSceneManager, Plugin_OctreeZone, # Plugin_OctreeSceneManager, Plugin_OctreeZone,
# Plugin_ParticleFX, Plugin_PCZSceneManager, # Plugin_ParticleFX, Plugin_PCZSceneManager,
# RenderSystem_GL, RenderSystem_Direct3D9, # RenderSystem_GL, RenderSystem_Direct3D9, RenderSystem_Direct3D10,
# Paging, Terrain # Paging, Terrain
# #
# For each of these components, the following variables are defined: # For each of these components, the following variables are defined:
# #
# OGRE_${COMPONENT}_FOUND - ${COMPONENT} is available # OGRE_${COMPONENT}_FOUND - ${COMPONENT} is available
# OGRE_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT} # OGRE_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT}
# OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT} # OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT}
# OGRE_${COMPONENT}_BINARY_REL - location of the component binary (win32 non-static only, release) # OGRE_${COMPONENT}_BINARY_REL - location of the component binary (win32 non-static only, release)
# OGRE_${COMPONENT}_BINARY_DBG - location of the component binary (win32 non-static only, debug) # OGRE_${COMPONENT}_BINARY_DBG - location of the component binary (win32 non-static only, debug)
# #
@ -113,7 +112,7 @@ if (OGRE_PREFIX_SOURCE AND OGRE_PREFIX_BUILD)
set(OGRE_BIN_SEARCH_PATH ${dir}/bin ${OGRE_BIN_SEARCH_PATH}) set(OGRE_BIN_SEARCH_PATH ${dir}/bin ${OGRE_BIN_SEARCH_PATH})
set(OGRE_BIN_SEARCH_PATH ${dir}/Samples/Common/bin ${OGRE_BIN_SEARCH_PATH}) set(OGRE_BIN_SEARCH_PATH ${dir}/Samples/Common/bin ${OGRE_BIN_SEARCH_PATH})
endforeach(dir) endforeach(dir)
if (OGRE_PREFIX_DEPENDENCIES_DIR) if (OGRE_PREFIX_DEPENDENCIES_DIR)
set(OGRE_INC_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/include ${OGRE_INC_SEARCH_PATH}) set(OGRE_INC_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/include ${OGRE_INC_SEARCH_PATH})
set(OGRE_LIB_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/lib ${OGRE_LIB_SEARCH_PATH}) set(OGRE_LIB_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/lib ${OGRE_LIB_SEARCH_PATH})
@ -125,12 +124,12 @@ else()
endif () endif ()
# redo search if any of the environmental hints changed # redo search if any of the environmental hints changed
set(OGRE_COMPONENTS Paging Terrain set(OGRE_COMPONENTS Paging Terrain
Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager
Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX
RenderSystem_Direct3D11 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES RenderSystem_GLES2) RenderSystem_Direct3D10 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES)
set(OGRE_RESET_VARS set(OGRE_RESET_VARS
OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR
OGRE_LIBRARY_FWK OGRE_LIBRARY_REL OGRE_LIBRARY_DBG OGRE_LIBRARY_FWK OGRE_LIBRARY_REL OGRE_LIBRARY_DBG
OGRE_PLUGIN_DIR_DBG OGRE_PLUGIN_DIR_REL OGRE_MEDIA_DIR) OGRE_PLUGIN_DIR_DBG OGRE_PLUGIN_DIR_REL OGRE_MEDIA_DIR)
foreach (comp ${OGRE_COMPONENTS}) foreach (comp ${OGRE_COMPONENTS})
@ -145,7 +144,7 @@ clear_if_changed(OGRE_PREFIX_WATCH ${OGRE_RESET_VARS})
# try to locate Ogre via pkg-config # try to locate Ogre via pkg-config
use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}") use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}")
if(NOT OGRE_BUILD_PLATFORM_APPLE_IOS) if(NOT OGRE_BUILD_PLATFORM_IPHONE AND APPLE)
# try to find framework on OSX # try to find framework on OSX
findpkg_framework(OGRE) findpkg_framework(OGRE)
else() else()
@ -236,7 +235,6 @@ if (OGRE_STATIC)
find_package(Freetype QUIET) find_package(Freetype QUIET)
find_package(OpenGL QUIET) find_package(OpenGL QUIET)
find_package(OpenGLES QUIET) find_package(OpenGLES QUIET)
find_package(OpenGLES2 QUIET)
find_package(ZLIB QUIET) find_package(ZLIB QUIET)
find_package(ZZip QUIET) find_package(ZZip QUIET)
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
@ -246,26 +244,24 @@ if (OGRE_STATIC)
set(X11_FOUND FALSE) set(X11_FOUND FALSE)
endif () endif ()
endif () endif ()
if (APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS) if (APPLE AND NOT OGRE_BUILD_PLATFORM_IPHONE)
find_package(Cocoa QUIET) find_package(Cocoa QUIET)
find_package(Carbon QUIET) find_package(Carbon QUIET)
find_package(CoreVideo QUIET) if (NOT Cocoa_FOUND OR NOT Carbon_FOUND)
if (NOT Cocoa_FOUND OR NOT Carbon_FOUND OR NOT CoreVideo_FOUND)
set(OGRE_DEPS_FOUND FALSE) set(OGRE_DEPS_FOUND FALSE)
endif () endif ()
endif () endif ()
if (APPLE AND OGRE_BUILD_PLATFORM_APPLE_IOS) if (APPLE AND OGRE_BUILD_PLATFORM_IPHONE)
find_package(iPhoneSDK QUIET) find_package(iPhoneSDK QUIET)
if (NOT iPhoneSDK_FOUND) if (NOT iPhoneSDK_FOUND)
set(OGRE_DEPS_FOUND FALSE) set(OGRE_DEPS_FOUND FALSE)
endif () endif ()
endif () endif ()
set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} ) set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES}
${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES}
if (APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS) ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB}
set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} ${Carbon_LIBRARIES} ${Cocoa_LIBRARIES}) ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES})
endif()
if (NOT ZLIB_FOUND OR NOT ZZip_FOUND) if (NOT ZLIB_FOUND OR NOT ZZip_FOUND)
set(OGRE_DEPS_FOUND FALSE) set(OGRE_DEPS_FOUND FALSE)
@ -309,7 +305,7 @@ if (OGRE_STATIC)
endif () endif ()
endif () endif ()
endif () endif ()
if (NOT OGRE_DEPS_FOUND) if (NOT OGRE_DEPS_FOUND)
pkg_message(OGRE "Could not find all required dependencies for the Ogre package.") pkg_message(OGRE "Could not find all required dependencies for the Ogre package.")
set(OGRE_FOUND FALSE) set(OGRE_FOUND FALSE)
@ -341,7 +337,7 @@ endif()
# Find Ogre components # Find Ogre components
######################################################### #########################################################
set(OGRE_COMPONENT_SEARCH_PATH_REL set(OGRE_COMPONENT_SEARCH_PATH_REL
${OGRE_LIBRARY_DIR_REL}/.. ${OGRE_LIBRARY_DIR_REL}/..
${OGRE_LIBRARY_DIR_REL}/../.. ${OGRE_LIBRARY_DIR_REL}/../..
${OGRE_BIN_SEARCH_PATH} ${OGRE_BIN_SEARCH_PATH}
@ -393,26 +389,38 @@ macro(ogre_find_plugin PLUGIN HEADER)
set(TMP_CMAKE_LIB_PREFIX ${CMAKE_FIND_LIBRARY_PREFIXES}) set(TMP_CMAKE_LIB_PREFIX ${CMAKE_FIND_LIBRARY_PREFIXES})
set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "")
endif() endif()
# strip RenderSystem_ or Plugin_ prefix from plugin name # strip RenderSystem_ or Plugin_ prefix from plugin name
string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN}) string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN})
string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP}) string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP})
# header files for plugins are not usually needed, but find them anyway if they are present # header files for plugins are not usually needed, but find them anyway if they are present
set(OGRE_PLUGIN_PATH_SUFFIXES set(OGRE_PLUGIN_PATH_SUFFIXES
PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN}
RenderSystems RenderSystems/${PLUGIN_NAME} ${ARGN}) RenderSystems RenderSystems/${PLUGIN_NAME} ${ARGN})
find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER} find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER}
HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE}
PATH_SUFFIXES ${OGRE_PLUGIN_PATH_SUFFIXES}) PATH_SUFFIXES ${OGRE_PLUGIN_PATH_SUFFIXES})
# find link libraries for plugins # find link libraries for plugins
set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}") set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}")
get_debug_names(OGRE_${PLUGIN}_LIBRARY_NAMES) get_debug_names(OGRE_${PLUGIN}_LIBRARY_NAMES)
set(OGRE_${PLUGIN}_LIBRARY_FWK ${OGRE_LIBRARY_FWK}) set(OGRE_${PLUGIN}_LIBRARY_FWK ${OGRE_LIBRARY_FWK})
# Search for release plugins in OGRE dir with version suffix
find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES}
HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt)
if(NOT EXISTS "${OGRE_${PLUGIN}_LIBRARY_REL}")
# Search for release plugins in OGRE dir without version suffix
find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES}
HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt)
endif()
# Search for debug plugins in OGRE dir with version suffix
find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG}
HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt debug debug/opt)
if(NOT EXISTS "${OGRE_${PLUGIN}_LIBRARY_DBG}")
# Search for debug plugins in OGRE dir without version suffix
find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG}
HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt)
endif()
make_library_set(OGRE_${PLUGIN}_LIBRARY) make_library_set(OGRE_${PLUGIN}_LIBRARY)
if (OGRE_${PLUGIN}_LIBRARY OR OGRE_${PLUGIN}_INCLUDE_DIR) if (OGRE_${PLUGIN}_LIBRARY OR OGRE_${PLUGIN}_INCLUDE_DIR)
@ -429,7 +437,7 @@ macro(ogre_find_plugin PLUGIN HEADER)
if (OGRE_${PLUGIN}_FOUND) if (OGRE_${PLUGIN}_FOUND)
if (NOT OGRE_PLUGIN_DIR_REL OR NOT OGRE_PLUGIN_DIR_DBG) if (NOT OGRE_PLUGIN_DIR_REL OR NOT OGRE_PLUGIN_DIR_DBG)
if (WIN32) if (WIN32)
set(OGRE_PLUGIN_SEARCH_PATH_REL set(OGRE_PLUGIN_SEARCH_PATH_REL
${OGRE_LIBRARY_DIR_REL}/.. ${OGRE_LIBRARY_DIR_REL}/..
${OGRE_LIBRARY_DIR_REL}/../.. ${OGRE_LIBRARY_DIR_REL}/../..
${OGRE_BIN_SEARCH_PATH} ${OGRE_BIN_SEARCH_PATH}
@ -445,12 +453,16 @@ macro(ogre_find_plugin PLUGIN HEADER)
PATH_SUFFIXES "" bin bin/debug debug) PATH_SUFFIXES "" bin bin/debug debug)
elseif (UNIX) elseif (UNIX)
get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH)
set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)" FORCE) # For some reason this fails
#set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)")
set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP})
get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH)
set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)" FORCE) # Same here
#set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)")
set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP})
endif () endif ()
endif () endif ()
# find binaries # find binaries
if (NOT OGRE_STATIC) if (NOT OGRE_STATIC)
if (WIN32) if (WIN32)
@ -459,7 +471,7 @@ macro(ogre_find_plugin PLUGIN HEADER)
endif() endif()
mark_as_advanced(OGRE_${PLUGIN}_REL OGRE_${PLUGIN}_DBG) mark_as_advanced(OGRE_${PLUGIN}_REL OGRE_${PLUGIN}_DBG)
endif() endif()
endif () endif ()
if (TMP_CMAKE_LIB_PREFIX) if (TMP_CMAKE_LIB_PREFIX)
@ -475,8 +487,8 @@ ogre_find_plugin(Plugin_OctreeSceneManager OgreOctreeSceneManager.h PlugIns/Octr
ogre_find_plugin(Plugin_ParticleFX OgreParticleFXPrerequisites.h PlugIns/ParticleFX/include) ogre_find_plugin(Plugin_ParticleFX OgreParticleFXPrerequisites.h PlugIns/ParticleFX/include)
ogre_find_plugin(RenderSystem_GL OgreGLRenderSystem.h RenderSystems/GL/include) ogre_find_plugin(RenderSystem_GL OgreGLRenderSystem.h RenderSystems/GL/include)
ogre_find_plugin(RenderSystem_GLES OgreGLESRenderSystem.h RenderSystems/GLES/include) ogre_find_plugin(RenderSystem_GLES OgreGLESRenderSystem.h RenderSystems/GLES/include)
ogre_find_plugin(RenderSystem_GLES2 OgreGLES2RenderSystem.h RenderSystems/GLES2/include)
ogre_find_plugin(RenderSystem_Direct3D9 OgreD3D9RenderSystem.h RenderSystems/Direct3D9/include) ogre_find_plugin(RenderSystem_Direct3D9 OgreD3D9RenderSystem.h RenderSystems/Direct3D9/include)
ogre_find_plugin(RenderSystem_Direct3D10 OgreD3D10RenderSystem.h RenderSystems/Direct3D10/include)
ogre_find_plugin(RenderSystem_Direct3D11 OgreD3D11RenderSystem.h RenderSystems/Direct3D11/include) ogre_find_plugin(RenderSystem_Direct3D11 OgreD3D11RenderSystem.h RenderSystems/Direct3D11/include)
if (OGRE_STATIC) if (OGRE_STATIC)
@ -484,26 +496,28 @@ if (OGRE_STATIC)
if (NOT DirectX_FOUND) if (NOT DirectX_FOUND)
set(OGRE_RenderSystem_Direct3D9_FOUND FALSE) set(OGRE_RenderSystem_Direct3D9_FOUND FALSE)
endif () endif ()
if (NOT DirectX_D3D10_FOUND)
set(OGRE_RenderSystem_Direct3D10_FOUND FALSE)
endif ()
if (NOT DirectX_D3D11_FOUND) if (NOT DirectX_D3D11_FOUND)
set(OGRE_RenderSystem_Direct3D11_FOUND FALSE) set(OGRE_RenderSystem_Direct3D11_FOUND FALSE)
endif () endif ()
if (NOT OPENGL_FOUND) if (NOT OPENGL_FOUND)
set(OGRE_RenderSystem_GL_FOUND FALSE) set(OGRE_RenderSystem_GL_FOUND FALSE)
endif () endif ()
if (NOT OPENGLES_FOUND) if (NOT OPENGLES_FOUND AND NOT OPENGLES2_FOUND)
set(OGRE_RenderSystem_GLES_FOUND FALSE) set(OGRE_RenderSystem_GLES_FOUND FALSE)
endif () endif ()
if (NOT OPENGLES2_FOUND)
set(OGRE_RenderSystem_GLES2_FOUND FALSE)
endif ()
if (NOT Cg_FOUND) if (NOT Cg_FOUND)
set(OGRE_Plugin_CgProgramManager_FOUND FALSE) set(OGRE_Plugin_CgProgramManager_FOUND FALSE)
endif () endif ()
set(OGRE_RenderSystem_Direct3D9_LIBRARIES ${OGRE_RenderSystem_Direct3D9_LIBRARIES} set(OGRE_RenderSystem_Direct3D9_LIBRARIES ${OGRE_RenderSystem_Direct3D9_LIBRARIES}
${DirectX_LIBRARIES} ${DirectX_LIBRARIES}
) )
set(OGRE_RenderSystem_Direct3D10_LIBRARIES ${OGRE_RenderSystem_Direct3D10_LIBRARIES}
${DirectX_D3D10_LIBRARIES}
)
set(OGRE_RenderSystem_Direct3D11_LIBRARIES ${OGRE_RenderSystem_Direct3D11_LIBRARIES} set(OGRE_RenderSystem_Direct3D11_LIBRARIES ${OGRE_RenderSystem_Direct3D11_LIBRARIES}
${DirectX_D3D11_LIBRARIES} ${DirectX_D3D11_LIBRARIES}
) )
@ -513,9 +527,6 @@ if (OGRE_STATIC)
set(OGRE_RenderSystem_GLES_LIBRARIES ${OGRE_RenderSystem_GLES_LIBRARIES} set(OGRE_RenderSystem_GLES_LIBRARIES ${OGRE_RenderSystem_GLES_LIBRARIES}
${OPENGLES_LIBRARIES} ${OPENGLES_LIBRARIES}
) )
set(OGRE_RenderSystem_GLES2_LIBRARIES ${OGRE_RenderSystem_GLES2_LIBRARIES}
${OPENGLES2_LIBRARIES}
)
set(OGRE_Plugin_CgProgramManager_LIBRARIES ${OGRE_Plugin_CgProgramManager_LIBRARIES} set(OGRE_Plugin_CgProgramManager_LIBRARIES ${OGRE_Plugin_CgProgramManager_LIBRARIES}
${Cg_LIBRARIES} ${Cg_LIBRARIES}
) )
@ -540,3 +551,4 @@ set(OGRE_MEDIA_SEARCH_SUFFIX
clear_if_changed(OGRE_PREFIX_WATCH OGRE_MEDIA_DIR) clear_if_changed(OGRE_PREFIX_WATCH OGRE_MEDIA_DIR)
find_path(OGRE_MEDIA_DIR NAMES packs/cubemapsJS.zip HINTS ${OGRE_MEDIA_SEARCH_PATH} find_path(OGRE_MEDIA_DIR NAMES packs/cubemapsJS.zip HINTS ${OGRE_MEDIA_SEARCH_PATH}
PATHS ${OGRE_PREFIX_PATH} PATH_SUFFIXES ${OGRE_MEDIA_SEARCH_SUFFIX}) PATHS ${OGRE_PREFIX_PATH} PATH_SUFFIXES ${OGRE_MEDIA_SEARCH_SUFFIX})

48
cmake/FindZZip.cmake Normal file
View file

@ -0,0 +1,48 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------
# - Try to find zziplib
# Once done, this will define
#
# ZZip_FOUND - system has ZZip
# ZZip_INCLUDE_DIRS - the ZZip include directories
# ZZip_LIBRARIES - link these to use ZZip
include(FindPkgMacros)
findpkg_begin(ZZip)
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(ZZIP_HOME)
# construct search paths
set(ZZip_PREFIX_PATH ${ZZIP_HOME} ${ENV_ZZIP_HOME})
create_search_paths(ZZip)
# redo search if prefix path changed
clear_if_changed(ZZip_PREFIX_PATH
ZZip_LIBRARY_FWK
ZZip_LIBRARY_REL
ZZip_LIBRARY_DBG
ZZip_INCLUDE_DIR
)
set(ZZip_LIBRARY_NAMES zzip zziplib)
get_debug_names(ZZip_LIBRARY_NAMES)
use_pkgconfig(ZZip_PKGC zziplib)
findpkg_framework(ZZip)
find_path(ZZip_INCLUDE_DIR NAMES zzip/zzip.h HINTS ${ZZip_INC_SEARCH_PATH} ${ZZip_PKGC_INCLUDE_DIRS})
find_library(ZZip_LIBRARY_REL NAMES ${ZZip_LIBRARY_NAMES} HINTS ${ZZip_LIB_SEARCH_PATH} ${ZZip_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel)
find_library(ZZip_LIBRARY_DBG NAMES ${ZZip_LIBRARY_NAMES_DBG} HINTS ${ZZip_LIB_SEARCH_PATH} ${ZZip_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug)
make_library_set(ZZip_LIBRARY)
findpkg_finish(ZZip)

View file

@ -95,8 +95,6 @@ namespace Compiler
return true; return true;
} }
return false;
} }
bool ControlParser::parseWhileBody (int keyword, const TokenLoc& loc, Scanner& scanner) bool ControlParser::parseWhileBody (int keyword, const TokenLoc& loc, Scanner& scanner)
@ -108,7 +106,7 @@ namespace Compiler
Codes expr; Codes expr;
mExprParser.append (expr); mExprParser.append (expr);
Generator::jump (loop, -mCodeBlock.size()-expr.size()); Generator::jump (loop, -static_cast<int> (mCodeBlock.size()-expr.size()));
std::copy (expr.begin(), expr.end(), std::back_inserter (mCode)); std::copy (expr.begin(), expr.end(), std::back_inserter (mCode));
@ -122,7 +120,7 @@ namespace Compiler
Codes loop2; Codes loop2;
Generator::jump (loop2, -mCodeBlock.size()-expr.size()-skip.size()); Generator::jump (loop2, -static_cast<int> (mCodeBlock.size()-expr.size()-skip.size()));
if (loop.size()!=loop2.size()) if (loop.size()!=loop2.size())
throw std::logic_error ( throw std::logic_error (
@ -153,8 +151,6 @@ namespace Compiler
return true; return true;
} }
return false;
} }
ControlParser::ControlParser (ErrorHandler& errorHandler, Context& context, Locals& locals, ControlParser::ControlParser (ErrorHandler& errorHandler, Context& context, Locals& locals,

View file

@ -639,7 +639,7 @@ namespace Compiler
std::vector<Interpreter::Type_Code>& code, bool invert) std::vector<Interpreter::Type_Code>& code, bool invert)
{ {
bool optional = false; bool optional = false;
bool optionalCount = 0; int optionalCount = 0;
ExprParser parser (getErrorHandler(), getContext(), mLocals, mLiterals, true); ExprParser parser (getErrorHandler(), getContext(), mLocals, mLiterals, true);
StringParser stringParser (getErrorHandler(), getContext(), mLiterals); StringParser stringParser (getErrorHandler(), getContext(), mLiterals);

View file

@ -24,7 +24,7 @@ namespace Compiler
mLineParser.reset(); mLineParser.reset();
if (mLineParser.parseName (name, loc, scanner)) if (mLineParser.parseName (name, loc, scanner))
scanner.scan (mLineParser); scanner.scan (mLineParser);
return true; return true;
} }
@ -34,22 +34,22 @@ namespace Compiler
{ {
mControlParser.reset(); mControlParser.reset();
if (mControlParser.parseKeyword (keyword, loc, scanner)) if (mControlParser.parseKeyword (keyword, loc, scanner))
scanner.scan (mControlParser); scanner.scan (mControlParser);
mControlParser.appendCode (mOutput.getCode()); mControlParser.appendCode (mOutput.getCode());
return true; return true;
} }
if (keyword==Scanner::K_end && mEnd) if (keyword==Scanner::K_end && mEnd)
{ {
return false; return false;
} }
mLineParser.reset(); mLineParser.reset();
if (mLineParser.parseKeyword (keyword, loc, scanner)) if (mLineParser.parseKeyword (keyword, loc, scanner))
scanner.scan (mLineParser); scanner.scan (mLineParser);
return true; return true;
} }
@ -57,11 +57,11 @@ namespace Compiler
{ {
if (code==Scanner::S_newline) // empty line if (code==Scanner::S_newline) // empty line
return true; return true;
mLineParser.reset(); mLineParser.reset();
if (mLineParser.parseSpecial (code, loc, scanner)) if (mLineParser.parseSpecial (code, loc, scanner))
scanner.scan (mLineParser); scanner.scan (mLineParser);
return true; return true;
} }
@ -77,4 +77,3 @@ namespace Compiler
mOutput.clear(); mOutput.clear();
} }
} }

View file

@ -39,6 +39,11 @@ namespace Compiler
mState = CommaState; mState = CommaState;
return true; return true;
} }
else if (code==Scanner::S_newline && mState==StartState)
{
scanner.putbackSpecial (code, loc);
return false;
}
return Parser::parseSpecial (code, loc, scanner); return Parser::parseSpecial (code, loc, scanner);
} }

View file

@ -3,32 +3,68 @@
namespace ESM namespace ESM
{ {
void PathGrid::load(ESMReader &esm) void Pathgrid::load(ESMReader &esm)
{ {
esm.getHNT(data, "DATA", 12); esm.getHNT(data, "DATA", 12);
cell = esm.getHNString("NAME"); cell = esm.getHNString("NAME");
// Remember this file position // keep track of total connections so we can reserve edge vector size
context = esm.getContext(); int edgeCount = 0;
// Check that the sizes match up. Size = 16 * s2 (path points?)
if (esm.isNextSub("PGRP")) if (esm.isNextSub("PGRP"))
{ {
esm.skipHSub(); esm.getSubHeader();
int size = esm.getSubSize(); int size = esm.getSubSize();
if (size != 16 * data.s2) // Check that the sizes match up. Size = 16 * s2 (path points)
esm.fail("Path grid table size mismatch"); if (size != static_cast<int> (sizeof(Point) * data.s2))
esm.fail("Path point subrecord size mismatch");
else
{
int pointCount = data.s2;
points.reserve(pointCount);
for (int i = 0; i < pointCount; ++i)
{
Point p;
esm.getExact(&p, sizeof(Point));
points.push_back(p);
edgeCount += p.connectionNum;
}
}
} }
// Size varies. Path grid chances? Connections? Multiples of 4
// suggest either int or two shorts, or perhaps a float. Study
// it later.
if (esm.isNextSub("PGRC")) if (esm.isNextSub("PGRC"))
{ {
esm.skipHSub(); esm.getSubHeader();
int size = esm.getSubSize(); int size = esm.getSubSize();
if (size % 4 != 0) if (size % sizeof(int) != 0)
esm.fail("PGRC size not a multiple of 4"); esm.fail("PGRC size not a multiple of 4");
else
{
int rawConnNum = size / sizeof(int);
std::vector<int> rawConnections;
rawConnections.reserve(rawConnNum);
for (int i = 0; i < rawConnNum; ++i)
{
int currentValue;
esm.getT(currentValue);
rawConnections.push_back(currentValue);
}
std::vector<int>::const_iterator rawIt = rawConnections.begin();
int pointIndex = 0;
edges.reserve(edgeCount);
for(PointList::const_iterator it = points.begin(); it != points.end(); it++, pointIndex++)
{
unsigned char connectionNum = (*it).connectionNum;
for (int i = 0; i < connectionNum; ++i) {
Edge edge;
edge.v0 = pointIndex;
edge.v1 = *rawIt;
rawIt++;
edges.push_back(edge);
}
}
}
} }
} }

View file

@ -9,20 +9,37 @@ namespace ESM
/* /*
* Path grid. * Path grid.
*/ */
struct PathGrid struct Pathgrid
{ {
struct DATAstruct struct DATAstruct
{ {
int x, y; // Grid location, matches cell for exterior cells int x, y; // Grid location, matches cell for exterior cells
short s1; // ?? Usually but not always a power of 2. Doesn't seem short s1; // ?? Usually but not always a power of 2. Doesn't seem
// to have any relation to the size of PGRC. // to have any relation to the size of PGRC.
short s2; // Number of path points? Size of PGRP block is always 16 * s2; short s2; // Number of path points.
}; // 12 bytes }; // 12 bytes
struct Point // path grid point
{
int x, y, z; // Location of point
unsigned char autogenerated; // autogenerated vs. user coloring flag?
unsigned char connectionNum; // number of connections for this point
short unknown;
}; // 16 bytes
struct Edge // path grid edge
{
int v0, v1; // index of points connected with this edge
}; // 8 bytes
std::string cell; // Cell name std::string cell; // Cell name
DATAstruct data; DATAstruct data;
ESM_Context context; // Context so we can return here later and
// finish the job typedef std::vector<Point> PointList;
PointList points;
typedef std::vector<Edge> EdgeList;
EdgeList edges;
void load(ESMReader &esm); void load(ESMReader &esm);
}; };

Some files were not shown because too many files have changed in this diff Show more