mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Merge branch 'master' into pgrd-rendering
Conflicts: apps/openmw/mwrender/renderingmanager.cpp apps/openmw/mwrender/renderingmanager.hpp apps/openmw/mwscript/docs/vmformat.txt
This commit is contained in:
commit
c3357c4396
539 changed files with 7490 additions and 54956 deletions
123
Bitstream Vera License.txt
Normal file
123
Bitstream Vera License.txt
Normal file
|
@ -0,0 +1,123 @@
|
|||
Bitstream Vera Fonts Copyright
|
||||
|
||||
The fonts have a generous copyright, allowing derivative works (as
|
||||
long as "Bitstream" or "Vera" are not in the names), and full
|
||||
redistribution (so long as they are not *sold* by themselves). They
|
||||
can be be bundled, redistributed and sold with any software.
|
||||
|
||||
The fonts are distributed under the following copyright:
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream
|
||||
Vera is a trademark of Bitstream, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the fonts accompanying this license ("Fonts") and associated
|
||||
documentation files (the "Font Software"), to reproduce and distribute
|
||||
the Font Software, including without limitation the rights to use,
|
||||
copy, merge, publish, distribute, and/or sell copies of the Font
|
||||
Software, and to permit persons to whom the Font Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice
|
||||
shall be included in all copies of one or more of the Font Software
|
||||
typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in
|
||||
particular the designs of glyphs or characters in the Fonts may be
|
||||
modified and additional glyphs or characters may be added to the
|
||||
Fonts, only if the fonts are renamed to names not containing either
|
||||
the words "Bitstream" or the word "Vera".
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts
|
||||
or Font Software that has been modified and is distributed under the
|
||||
"Bitstream Vera" names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but
|
||||
no copy of one or more of the Font Software typefaces may be sold by
|
||||
itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
||||
BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL,
|
||||
OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT
|
||||
SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the names of Gnome, the Gnome
|
||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
||||
otherwise to promote the sale, use or other dealings in this Font
|
||||
Software without prior written authorization from the Gnome Foundation
|
||||
or Bitstream Inc., respectively. For further information, contact:
|
||||
fonts at gnome dot org.
|
||||
|
||||
Copyright FAQ
|
||||
=============
|
||||
|
||||
1. I don't understand the resale restriction... What gives?
|
||||
|
||||
Bitstream is giving away these fonts, but wishes to ensure its
|
||||
competitors can't just drop the fonts as is into a font sale system
|
||||
and sell them as is. It seems fair that if Bitstream can't make money
|
||||
from the Bitstream Vera fonts, their competitors should not be able to
|
||||
do so either. You can sell the fonts as part of any software package,
|
||||
however.
|
||||
|
||||
2. I want to package these fonts separately for distribution and
|
||||
sale as part of a larger software package or system. Can I do so?
|
||||
|
||||
Yes. A RPM or Debian package is a "larger software package" to begin
|
||||
with, and you aren't selling them independently by themselves.
|
||||
See 1. above.
|
||||
|
||||
3. Are derivative works allowed?
|
||||
Yes!
|
||||
|
||||
4. Can I change or add to the font(s)?
|
||||
Yes, but you must change the name(s) of the font(s).
|
||||
|
||||
5. Under what terms are derivative works allowed?
|
||||
|
||||
You must change the name(s) of the fonts. This is to ensure the
|
||||
quality of the fonts, both to protect Bitstream and Gnome. We want to
|
||||
ensure that if an application has opened a font specifically of these
|
||||
names, it gets what it expects (though of course, using fontconfig,
|
||||
substitutions could still could have occurred during font
|
||||
opening). You must include the Bitstream copyright. Additional
|
||||
copyrights can be added, as per copyright law. Happy Font Hacking!
|
||||
|
||||
6. If I have improvements for Bitstream Vera, is it possible they might get
|
||||
adopted in future versions?
|
||||
|
||||
Yes. The contract between the Gnome Foundation and Bitstream has
|
||||
provisions for working with Bitstream to ensure quality additions to
|
||||
the Bitstream Vera font family. Please contact us if you have such
|
||||
additions. Note, that in general, we will want such additions for the
|
||||
entire family, not just a single font, and that you'll have to keep
|
||||
both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add
|
||||
glyphs to the font, they must be stylistically in keeping with Vera's
|
||||
design. Vera cannot become a "ransom note" font. Jim Lyles will be
|
||||
providing a document describing the design elements used in Vera, as a
|
||||
guide and aid for people interested in contributing to Vera.
|
||||
|
||||
7. I want to sell a software package that uses these fonts: Can I do so?
|
||||
|
||||
Sure. Bundle the fonts with your software and sell your software
|
||||
with the fonts. That is the intent of the copyright.
|
||||
|
||||
8. If applications have built the names "Bitstream Vera" into them,
|
||||
can I override this somehow to use fonts of my choosing?
|
||||
|
||||
This depends on exact details of the software. Most open source
|
||||
systems and software (e.g., Gnome, KDE, etc.) are now converting to
|
||||
use fontconfig (see www.fontconfig.org) to handle font configuration,
|
||||
selection and substitution; it has provisions for overriding font
|
||||
names and subsituting alternatives. An example is provided by the
|
||||
supplied local.conf file, which chooses the family Bitstream Vera for
|
||||
"sans", "serif" and "monospace". Other software (e.g., the XFree86
|
||||
core server) has other mechanisms for font substitution.
|
159
CMakeLists.txt
159
CMakeLists.txt
|
@ -4,9 +4,6 @@ if (APPLE)
|
|||
set(APP_BUNDLE_NAME "${CMAKE_PROJECT_NAME}.app")
|
||||
|
||||
set(APP_BUNDLE_DIR "${OpenMW_BINARY_DIR}/${APP_BUNDLE_NAME}")
|
||||
|
||||
# using 10.6 sdk
|
||||
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk")
|
||||
endif (APPLE)
|
||||
|
||||
# Macros
|
||||
|
@ -18,7 +15,7 @@ include (OpenMWMacros)
|
|||
# Version
|
||||
|
||||
set (OPENMW_VERSION_MAJOR 0)
|
||||
set (OPENMW_VERSION_MINOR 12)
|
||||
set (OPENMW_VERSION_MINOR 13)
|
||||
set (OPENMW_VERSION_RELEASE 0)
|
||||
|
||||
set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
|
||||
|
@ -27,8 +24,9 @@ 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")
|
||||
|
||||
option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE)
|
||||
|
||||
# Sound source selection
|
||||
option(USE_AUDIERE "use Audiere for sound" OFF)
|
||||
option(USE_FFMPEG "use ffmpeg for sound" OFF)
|
||||
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
|
||||
|
||||
|
@ -118,52 +116,31 @@ set(OENGINE_BULLET
|
|||
${LIBDIR}/openengine/bullet/BulletShapeLoader.h
|
||||
)
|
||||
|
||||
# Sound setup
|
||||
if (USE_AUDIERE)
|
||||
set(MANGLE_SOUND_OUTPUT
|
||||
${LIBDIR}/mangle/sound/sources/audiere_source.cpp
|
||||
${LIBDIR}/mangle/sound/sources/sample_reader.cpp
|
||||
${LIBDIR}/mangle/stream/clients/audiere_file.cpp)
|
||||
find_package(Audiere REQUIRED)
|
||||
set(SOUND_INPUT_INCLUDES ${AUDIERE_INCLUDE_DIR})
|
||||
set(SOUND_INPUT_LIBRARY ${AUDIERE_LIBRARY})
|
||||
set(SOUND_DEFINE -DOPENMW_USE_AUDIERE)
|
||||
endif (USE_AUDIERE)
|
||||
|
||||
if (USE_FFMPEG)
|
||||
set(MANGLE_SOUND_OUTPUT
|
||||
${LIBDIR}/mangle/sound/sources/ffmpeg_source.cpp)
|
||||
find_package(FFMPEG REQUIRED)
|
||||
set(SOUND_INPUT_INCLUDES ${FFMPEG_INCLUDE_DIR})
|
||||
set(SOUND_INPUT_LIBRARY ${FFMPEG_LIBRARIES})
|
||||
set(SOUND_DEFINE -DOPENMW_USE_FFMPEG)
|
||||
endif (USE_FFMPEG)
|
||||
|
||||
if (USE_MPG123)
|
||||
set(MANGLE_SOUND_OUTPUT
|
||||
${LIBDIR}/mangle/sound/sources/mpg123_source.cpp
|
||||
${LIBDIR}/mangle/sound/sources/libsndfile.cpp
|
||||
${LIBDIR}/mangle/sound/sources/sample_reader.cpp)
|
||||
find_package(MPG123 REQUIRED)
|
||||
find_package(SNDFILE REQUIRED)
|
||||
set(SOUND_INPUT_INCLUDES ${MPG123_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR})
|
||||
set(SOUND_INPUT_LIBRARY ${MPG123_LIBRARY} ${SNDFILE_LIBRARY})
|
||||
set(SOUND_DEFINE -DOPENMW_USE_MPG123)
|
||||
endif (USE_MPG123)
|
||||
|
||||
set(OENGINE_SOUND
|
||||
# Mangle and OEngine sound files are sort of intertwined, so put
|
||||
# them together here
|
||||
${LIBDIR}/openengine/sound/sndmanager.cpp
|
||||
${LIBDIR}/mangle/sound/outputs/openal_out.cpp
|
||||
${MANGLE_SOUND_OUTPUT}
|
||||
)
|
||||
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_SOUND} ${OENGINE_BULLET})
|
||||
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET})
|
||||
source_group(libs\\openengine FILES ${OENGINE_ALL})
|
||||
|
||||
set(OPENMW_LIBS ${MANGLE_ALL} ${OENGINE_ALL})
|
||||
set(OPENMW_LIBS_HEADER)
|
||||
|
||||
# Sound setup
|
||||
set(SOUND_INPUT_INCLUDES "")
|
||||
set(SOUND_INPUT_LIBRARY "")
|
||||
set(SOUND_DEFINE "")
|
||||
if (USE_FFMPEG)
|
||||
find_package(FFMPEG REQUIRED)
|
||||
set(SOUND_INPUT_INCLUDES ${SOUND_INPUT_INCLUDES} ${FFMPEG_INCLUDE_DIR})
|
||||
set(SOUND_INPUT_LIBRARY ${SOUND_INPUT_LIBRARY} ${FFMPEG_LIBRARIES})
|
||||
set(SOUND_DEFINE ${SOUND_DEFINE} -DOPENMW_USE_FFMPEG)
|
||||
endif (USE_FFMPEG)
|
||||
|
||||
if (USE_MPG123)
|
||||
find_package(MPG123 REQUIRED)
|
||||
find_package(SNDFILE REQUIRED)
|
||||
set(SOUND_INPUT_INCLUDES ${SOUND_INPUT_INCLUDES} ${MPG123_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR})
|
||||
set(SOUND_INPUT_LIBRARY ${SOUND_INPUT_LIBRARY} ${MPG123_LIBRARY} ${SNDFILE_LIBRARY})
|
||||
set(SOUND_DEFINE ${SOUND_DEFINE} -DOPENMW_USE_MPG123)
|
||||
endif (USE_MPG123)
|
||||
|
||||
# Platform specific
|
||||
if (WIN32)
|
||||
set(PLATFORM_INCLUDE_DIR "platform")
|
||||
|
@ -175,7 +152,6 @@ include_directories(${UUID_INCLUDE_DIR})
|
|||
endif (WIN32)
|
||||
if (MSVC10)
|
||||
set(PLATFORM_INCLUDE_DIR "")
|
||||
add_definitions(-DMYGUI_DONT_REPLACE_NULLPTR)
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
|
@ -184,23 +160,37 @@ endif (APPLE)
|
|||
|
||||
# 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(MyGUI REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
|
||||
find_package(OIS REQUIRED)
|
||||
find_package(OpenAL 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("."
|
||||
${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}
|
||||
${OIS_INCLUDE_DIRS} ${Boost_INCLUDE_DIR}
|
||||
${PLATFORM_INCLUDE_DIR}
|
||||
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
|
||||
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
|
||||
${MYGUI_INCLUDE_DIRS}
|
||||
${MYGUI_PLATFORM_INCLUDE_DIRS}
|
||||
${OPENAL_INCLUDE_DIR}
|
||||
${UUID_INCLUDE_DIR}
|
||||
${LIBDIR}
|
||||
)
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
|
||||
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR} ${MYGUI_LIB_DIR})
|
||||
|
||||
if(APPLE)
|
||||
# List used Ogre plugins
|
||||
|
@ -210,14 +200,7 @@ if(APPLE)
|
|||
"Plugin_ParticleFX")
|
||||
endif(APPLE)
|
||||
|
||||
add_subdirectory( extern/mygui_3.0.1 )
|
||||
|
||||
# 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)
|
||||
add_subdirectory( files/mygui )
|
||||
|
||||
# Specify build paths
|
||||
|
||||
|
@ -278,8 +261,16 @@ endif (APPLE)
|
|||
|
||||
# Compiler settings
|
||||
if (CMAKE_COMPILER_IS_GNUCC)
|
||||
#add_definitions (-Wall -Werror)
|
||||
add_definitions (-Wall)
|
||||
add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder)
|
||||
|
||||
# Silence warnings in OGRE headers. Remove once OGRE got fixed!
|
||||
add_definitions (-Wno-ignored-qualifiers)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
if ("${GCC_VERSION}" VERSION_GREATER 4.6 OR "${GCC_VERSION}" VERSION_EQUAL 4.6)
|
||||
add_definitions (-Wno-unused-but-set-parameter)
|
||||
endif("${GCC_VERSION}" VERSION_GREATER 4.6 OR "${GCC_VERSION}" VERSION_EQUAL 4.6)
|
||||
endif (CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
if(DPKG_PROGRAM)
|
||||
|
@ -319,7 +310,7 @@ if(DPKG_PROGRAM)
|
|||
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
||||
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")
|
||||
|
||||
|
@ -339,6 +330,7 @@ if(WIN32)
|
|||
FILE(GLOB files "${OpenMW_BINARY_DIR}/Release/*.*")
|
||||
INSTALL(FILES ${files} DESTINATION ".")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
|
||||
INSTALL(FILES "${OpenMW_SOURCE_DIR}/readme.txt" DESTINATION ".")
|
||||
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ".")
|
||||
|
||||
SET(CPACK_GENERATOR "NSIS")
|
||||
|
@ -349,6 +341,7 @@ if(WIN32)
|
|||
SET(CPACK_PACKAGE_VERSION_MINOR ${OPENMW_VERSION_MINO})
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH ${OPENMW_VERSION_RELEASE})
|
||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW;esmtool;Esmtool;omwlauncher;OpenMW Launcher")
|
||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Readme.lnk' '\$INSTDIR\\\\readme.txt'")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${OpenMW_SOURCE_DIR}/readme.txt")
|
||||
SET(CPACK_RESOURCE_FILE_LICENSE "${OpenMW_SOURCE_DIR}/GPL3.txt")
|
||||
SET(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
|
||||
|
@ -418,6 +411,47 @@ if (WIN32)
|
|||
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
||||
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_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)
|
||||
|
||||
# Same for MinGW
|
||||
|
@ -450,6 +484,7 @@ if (APPLE)
|
|||
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
|
||||
install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
|
||||
set(CPACK_GENERATOR "DragNDrop")
|
||||
set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION})
|
||||
|
|
93
OFL.txt
Normal file
93
OFL.txt
Normal file
|
@ -0,0 +1,93 @@
|
|||
Copyright (c) 2010, 2011 Georg Duffner (http://www.georgduffner.at)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
138
README_Mac.md
138
README_Mac.md
|
@ -1,46 +1,30 @@
|
|||
NOTE: This README is for ardekantur's Mac branch of OpenMW. A README
|
||||
for the main branch has yet to be written. If you want to submit one,
|
||||
please send me a message!
|
||||
#Getting OpenMW Working on OS X
|
||||
|
||||
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
|
||||
Morrowind. It aims to be a fully playable, open source
|
||||
implementation of the game. You must own Morrowind to use OpenMW.
|
||||
Or use your github url if you forked.
|
||||
|
||||
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
|
||||
------------------
|
||||
|
||||
This specific repository is a branch of OpenMW intended to keep pace
|
||||
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.
|
||||
|
||||
|
||||
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 OMW_LIB_PREFIX=$HOME/path/libs/root`
|
||||
|
||||
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.
|
||||
|
||||
As OpenMW currently only supports i386 architecture on OS X, denendencies also should support it. Set some env vars in current terminal:
|
||||
|
||||
$ export CFLAGS="-arch i386"
|
||||
$ export CXXFLAGS="-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:
|
||||
## Boost
|
||||
Download [boost][boost] and install it with the following command:
|
||||
|
||||
$ cd /path/to/boost/source
|
||||
$ ./bootstrap.sh --prefix=$OMW_LIB_PREFIX
|
||||
|
@ -49,32 +33,47 @@ Getting OpenMW Working
|
|||
--link-shared,static --prefix=$OMW_LIB_PREFIX install
|
||||
|
||||
|
||||
5. Download [Ogre][] SDK (tested with 1.7.2), unpack it and move
|
||||
`lib/Release/Ogre.framework` into `Library/Frameworks`.
|
||||
Alternatively you can install boost with homebrew:
|
||||
|
||||
6. Download [OIS][] and use the XCode project provided in
|
||||
`ois/Mac/XCode-2.2`. Be sure to set your build architecture to
|
||||
`i386` and your SDK platform to either 10.5 or 10.6. Once it
|
||||
builds, move `ois/Mac/XCode-2.2/build/Debug/OIS.framework` to
|
||||
`/Library/Frameworks`.
|
||||
$ brew install boost --universal
|
||||
|
||||
I think MacPorts also should support universal build for boost.
|
||||
|
||||
## Ogre
|
||||
Download [Ogre][] SDK (tested with 1.7.3), unpack it somewhere and move
|
||||
`lib/Release/Ogre.framework` into `/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
|
||||
$ ./configure --prefix=$OMW_LIB_PREFIX --disable-debug \
|
||||
--disable-dependency-tracking \
|
||||
--with-optimization=4 \
|
||||
--with-audio=coreaudio \
|
||||
--with-default-audio=coreaudio \
|
||||
--with-audio=dummy \
|
||||
--with-default-audio=dummy \
|
||||
--with-cpu=sse_alone \
|
||||
$ make install
|
||||
|
||||
8. Download [libsndfile][] and build it:
|
||||
## libsndfile
|
||||
Download [libsndfile][] and build it:
|
||||
|
||||
$ cd /path/to/libsndfile/source
|
||||
$ ./configure --prefix=$OMW_LIB_PREFIX \
|
||||
--disable-dependency-tracking
|
||||
$ 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
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
|
@ -87,12 +86,25 @@ Getting OpenMW Working
|
|||
-G"Unix Makefiles" ../
|
||||
$ 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
|
||||
$ cd /path/to/open/build/dir
|
||||
$ cmake \
|
||||
-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_LIBRARYDIR=$OMW_LIB_PREFIX/lib \
|
||||
-D SNDFILE_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
|
||||
|
@ -106,27 +118,43 @@ Getting OpenMW Working
|
|||
-D BULLET_INCLUDE_DIR=$OMW_LIB_PREFIX/include/bullet/ \
|
||||
-G "Unix Makefiles" /path/to/openmw/source/dir
|
||||
$ 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
|
||||
build.
|
||||
|
||||
11. Copy your Morrowind `Data Files` directory into the OpenMW build dir
|
||||
with the name `data` or create symlink:
|
||||
$ ln -s /path/to/morrowind/data/files /path/to/openmw/build/dir/data
|
||||
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
|
||||
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.
|
||||
|
||||
If all libs installed via homebrew (excluding mpg123), then command would be even simplier:
|
||||
|
||||
$ 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
|
||||
or:
|
||||
|
||||
$ open OpenMW.app
|
||||
Enjoy!
|
||||
|
||||
|
||||
|
||||
[homebrew]: https://github.com/mxcl/homebrew
|
||||
[boost]: http://www.boost.org
|
||||
[Ogre]: http://www.ogre3d.org
|
||||
[Bullet]: http://bulletphysics.org
|
||||
[OIS]: http://wgois.sf.net
|
||||
[OIS]: https://github.com/corristo/ois-fork
|
||||
[mpg123]: http://www.mpg123.de
|
||||
[libsndfile]: http://www.mega-nerd.com/libsndfile
|
||||
[official website]: http://openmw.com
|
||||
[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/
|
||||
[qt]: http://qt.nokia.com/
|
|
@ -53,6 +53,15 @@ QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC})
|
|||
include(${QT_USE_FILE})
|
||||
|
||||
# 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
|
||||
${GUI_TYPE}
|
||||
${LAUNCHER}
|
||||
|
@ -63,6 +72,7 @@ add_executable(omwlauncher
|
|||
target_link_libraries(omwlauncher
|
||||
${Boost_LIBRARIES}
|
||||
${OGRE_LIBRARIES}
|
||||
${OGRE_STATIC_PLUGINS}
|
||||
${QT_LIBRARIES}
|
||||
components
|
||||
)
|
||||
|
|
|
@ -222,10 +222,10 @@ void DataFilesPage::setupDataFiles()
|
|||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle("Error detecting Morrowind installation");
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
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> \
|
||||
Press \"Browse...\" to specify the location manually.<br>"));
|
||||
|
||||
QAbstractButton *dirSelectButton =
|
||||
|
@ -279,6 +279,8 @@ void DataFilesPage::setupDataFiles()
|
|||
const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp");
|
||||
|
||||
for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) {
|
||||
|
||||
try {
|
||||
ESMReader fileReader;
|
||||
QStringList availableMasters; // Will contain all found masters
|
||||
|
||||
|
@ -346,6 +348,11 @@ void DataFilesPage::setupDataFiles()
|
|||
currentItem->appendRow(child);
|
||||
}
|
||||
}
|
||||
|
||||
} catch(std::runtime_error &e) {
|
||||
// An error occurred while reading the .esp
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
readConfig();
|
||||
|
@ -1050,16 +1057,8 @@ void DataFilesPage::writeConfig(QString profile)
|
|||
return;
|
||||
}
|
||||
|
||||
// Prepare the OpenMW config
|
||||
QString config = QString::fromStdString((mCfgMgr.getLocalPath() / "openmw.cfg").string());
|
||||
QFile file(config);
|
||||
|
||||
if (!file.exists()) {
|
||||
config = QString::fromStdString((mCfgMgr.getUserPath() / "openmw.cfg").string());
|
||||
}
|
||||
|
||||
// Open the config as a QFile
|
||||
file.setFileName(config);
|
||||
// Open the OpenMW config as a QFile
|
||||
QFile file(QString::fromStdString((mCfgMgr.getUserPath() / "openmw.cfg").string()));
|
||||
|
||||
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||
// File cannot be opened or created
|
||||
|
|
|
@ -186,7 +186,11 @@ void GraphicsPage::setupOgre()
|
|||
|
||||
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");
|
||||
#endif
|
||||
}
|
||||
catch(Ogre::Exception &ex)
|
||||
{
|
||||
|
@ -207,6 +211,15 @@ void GraphicsPage::setupOgre()
|
|||
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
|
||||
const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers();
|
||||
|
||||
|
|
|
@ -8,6 +8,14 @@
|
|||
#include <OgreConfigFile.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 QCheckBox;
|
||||
class QStackedWidget;
|
||||
|
@ -32,6 +40,12 @@ private:
|
|||
Ogre::RenderSystem *mSelectedRenderSystem;
|
||||
Ogre::RenderSystem *mOpenGLRenderSystem;
|
||||
Ogre::RenderSystem *mDirect3DRenderSystem;
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
Ogre::GLPlugin* mGLPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||
Ogre::D3D9Plugin* mD3D9Plugin;
|
||||
#endif
|
||||
|
||||
QComboBox *mRendererComboBox;
|
||||
|
||||
|
|
|
@ -45,9 +45,28 @@ MainDialog::MainDialog()
|
|||
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setMinimumSize(QSize(575, 575));
|
||||
|
||||
// Install the stylesheet font
|
||||
QFile file;
|
||||
QFontDatabase fontDatabase;
|
||||
|
||||
const QStringList fonts = fontDatabase.families();
|
||||
|
||||
// Check if the font is installed
|
||||
if (!fonts.contains("EB Garamond")) {
|
||||
|
||||
QString font = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
||||
file.setFileName(font);
|
||||
|
||||
if (!file.exists()) {
|
||||
font = QString::fromStdString((mCfgMgr.getLocalPath() / "resources/mygui/EBGaramond-Regular.ttf").string());
|
||||
}
|
||||
|
||||
fontDatabase.addApplicationFont(font);
|
||||
}
|
||||
|
||||
// Load the stylesheet
|
||||
QString config = QString::fromStdString((mCfgMgr.getGlobalDataPath() / "resources/launcher.qss").string());
|
||||
QFile file(config);
|
||||
file.setFileName(config);
|
||||
|
||||
if (!file.exists()) {
|
||||
file.setFileName(QString::fromStdString((mCfgMgr.getLocalPath() / "launcher.qss").string()));
|
||||
|
@ -175,6 +194,7 @@ void MainDialog::play()
|
|||
QDir dir(QCoreApplication::applicationDirPath());
|
||||
QString game = dir.absoluteFilePath("openmw");
|
||||
QFile file(game);
|
||||
game = "\"" + game + "\"";
|
||||
#else
|
||||
QString game = "./openmw";
|
||||
QFile file(game);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 50 KiB |
|
@ -14,7 +14,8 @@ set(GAME_HEADER
|
|||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||
|
||||
add_openmw_dir (mwrender
|
||||
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects renderinginterface
|
||||
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects
|
||||
renderinginterface localmap
|
||||
)
|
||||
|
||||
add_openmw_dir (mwinput
|
||||
|
@ -38,13 +39,13 @@ add_openmw_dir (mwscript
|
|||
)
|
||||
|
||||
add_openmw_dir (mwsound
|
||||
soundmanager
|
||||
soundmanager openal_output mpgsnd_decoder ffmpeg_decoder
|
||||
)
|
||||
|
||||
add_openmw_dir (mwworld
|
||||
refdata world physicssystem scene environment globals class action nullaction actionteleport
|
||||
containerstore actiontalk actiontake manualref player cellfunctors
|
||||
cells localscripts customdata weather inventorystore
|
||||
cells localscripts customdata weather inventorystore ptr
|
||||
)
|
||||
|
||||
add_openmw_dir (mwclass
|
||||
|
@ -57,6 +58,15 @@ add_openmw_dir (mwmechanics
|
|||
)
|
||||
|
||||
# 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
|
||||
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
|
||||
${COMPONENT_FILES}
|
||||
|
@ -72,16 +82,22 @@ add_definitions(${SOUND_DEFINE})
|
|||
|
||||
target_link_libraries(openmw
|
||||
${OGRE_LIBRARIES}
|
||||
${OGRE_STATIC_PLUGINS}
|
||||
${OIS_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${OPENAL_LIBRARY}
|
||||
${SOUND_INPUT_LIBRARY}
|
||||
${BULLET_LIBRARIES}
|
||||
${MYGUI_LIBRARIES}
|
||||
${MYGUI_PLATFORM_LIBRARIES}
|
||||
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)
|
||||
find_library(CARBON_FRAMEWORK Carbon)
|
||||
target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||
|
|
|
@ -60,7 +60,7 @@ void OMW::Engine::executeLocalScripts()
|
|||
|
||||
MWScript::InterpreterContext interpreterContext (mEnvironment,
|
||||
&script.second.getRefData().getLocals(), script.second);
|
||||
mScriptManager->run (script.first, interpreterContext);
|
||||
mEnvironment.mScriptManager->run (script.first, interpreterContext);
|
||||
|
||||
if (mEnvironment.mWorld->hasCellChanged())
|
||||
break;
|
||||
|
@ -117,11 +117,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
|
||||
// sound
|
||||
if (mUseSound)
|
||||
{
|
||||
mEnvironment.mSoundManager->playPlaylist();
|
||||
|
||||
mEnvironment.mSoundManager->update (evt.timeSinceLastFrame);
|
||||
}
|
||||
|
||||
// update GUI
|
||||
Ogre::RenderWindow* window = mOgre->getWindow();
|
||||
|
@ -182,7 +178,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
|||
, mCompileAll (false)
|
||||
, mReportFocus (false)
|
||||
, mFocusTDiff (0)
|
||||
, mScriptManager (0)
|
||||
, mScriptContext (0)
|
||||
, mFSStrict (false)
|
||||
, mCfgMgr(configurationManager)
|
||||
|
@ -199,7 +194,7 @@ OMW::Engine::~Engine()
|
|||
delete mEnvironment.mMechanicsManager;
|
||||
delete mEnvironment.mDialogueManager;
|
||||
delete mEnvironment.mJournal;
|
||||
delete mScriptManager;
|
||||
delete mEnvironment.mScriptManager;
|
||||
delete mScriptContext;
|
||||
delete mOgre;
|
||||
}
|
||||
|
@ -338,28 +333,25 @@ void OMW::Engine::go()
|
|||
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"));
|
||||
|
||||
// Create sound system
|
||||
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre->getRoot(),
|
||||
mOgre->getCamera(),
|
||||
mDataDirs,
|
||||
mUseSound, mFSStrict, mEnvironment);
|
||||
mEnvironment.mSoundManager = new MWSound::SoundManager(mUseSound, mEnvironment);
|
||||
|
||||
// Create script system
|
||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
|
||||
mEnvironment);
|
||||
mScriptContext->setExtensions (&mExtensions);
|
||||
|
||||
mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts,
|
||||
*mScriptContext);
|
||||
mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(),
|
||||
mVerboseScripts, *mScriptContext);
|
||||
|
||||
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
|
||||
*mScriptManager);
|
||||
*mEnvironment.mScriptManager);
|
||||
|
||||
// Create game mechanics system
|
||||
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment);
|
||||
|
||||
// Create dialog system
|
||||
mEnvironment.mJournal = new MWDialogue::Journal (mEnvironment);
|
||||
mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment);
|
||||
mEnvironment.mDialogueManager = new MWDialogue::DialogueManager (mEnvironment,mExtensions);
|
||||
|
||||
// load cell
|
||||
ESM::Position pos;
|
||||
|
@ -393,7 +385,7 @@ void OMW::Engine::go()
|
|||
// scripts
|
||||
if (mCompileAll)
|
||||
{
|
||||
std::pair<int, int> result = mScriptManager->compileAll();
|
||||
std::pair<int, int> result = mEnvironment.mScriptManager->compileAll();
|
||||
|
||||
if (result.first)
|
||||
std::cout
|
||||
|
@ -411,6 +403,9 @@ void OMW::Engine::go()
|
|||
|
||||
void OMW::Engine::activate()
|
||||
{
|
||||
if (mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game)
|
||||
return;
|
||||
|
||||
std::string handle = mEnvironment.mWorld->getFacedHandle();
|
||||
|
||||
if (handle.empty())
|
||||
|
@ -435,7 +430,7 @@ void OMW::Engine::activate()
|
|||
if (!script.empty())
|
||||
{
|
||||
mEnvironment.mWorld->getLocalScripts().setIgnore (ptr);
|
||||
mScriptManager->run (script, interpreterContext);
|
||||
mEnvironment.mScriptManager->run (script, interpreterContext);
|
||||
}
|
||||
|
||||
if (!interpreterContext.hasActivationBeenHandled())
|
||||
|
|
|
@ -78,7 +78,6 @@ namespace OMW
|
|||
std::string mFocusName;
|
||||
|
||||
MWWorld::Environment mEnvironment;
|
||||
MWScript::ScriptManager *mScriptManager;
|
||||
Compiler::Extensions mExtensions;
|
||||
Compiler::Context *mScriptContext;
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -71,4 +76,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,15 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -116,7 +121,7 @@ namespace MWClass
|
|||
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 =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
@ -142,13 +147,13 @@ namespace MWClass
|
|||
if (typeGmst.empty())
|
||||
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)
|
||||
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)
|
||||
return ESM::Skill::MediumArmor;
|
||||
|
||||
|
@ -161,4 +166,26 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,18 @@ namespace MWClass
|
|||
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
|
||||
/// stay stacked when equipped?
|
||||
|
||||
virtual int getEuqipmentSkill (const MWWorld::Ptr& ptr,
|
||||
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Environment& environment) const;
|
||||
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
|
||||
/// no such skill.
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||
|
@ -55,6 +58,8 @@ namespace MWClass
|
|||
{
|
||||
// TODO implement reading
|
||||
|
||||
environment.mSoundManager->playSound3D (ptr, getUpSoundId(ptr, environment), 1.0, 1.0, false, true);
|
||||
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -73,4 +78,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -106,7 +111,7 @@ namespace MWClass
|
|||
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
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
|
@ -124,4 +129,28 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,18 @@ namespace MWClass
|
|||
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
|
||||
/// stay stacked when equipped?
|
||||
|
||||
virtual int getEuqipmentSkill (const MWWorld::Ptr& ptr,
|
||||
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Environment& environment) const;
|
||||
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
|
||||
/// no such skill.
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace MWClass
|
|||
{
|
||||
// TODO check for key
|
||||
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);
|
||||
}
|
||||
else
|
||||
|
@ -100,7 +100,7 @@ namespace MWClass
|
|||
{
|
||||
// Trap activation goes here
|
||||
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 = "";
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace MWClass
|
|||
// TODO check for key
|
||||
// TODO report failure to player (message, sound?). Look up behaviour of original MW.
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ namespace MWClass
|
|||
{
|
||||
// Trap activation
|
||||
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 = "";
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ namespace MWClass
|
|||
if (environment.mWorld->getPlayer().getPlayer()==actor)
|
||||
{
|
||||
// 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);
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
|
||||
|
@ -109,7 +110,7 @@ namespace MWClass
|
|||
// TODO return action for rotating the door
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -69,4 +74,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ namespace MWClass
|
|||
if (!(ref->base->data.flags & ESM::Light::Carry))
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -114,4 +116,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@ namespace MWClass
|
|||
/// stay stacked when equipped?
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -82,4 +87,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ namespace MWClass
|
|||
/// stay stacked when equipped?
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -71,4 +76,28 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -71,4 +76,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -81,4 +86,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ namespace MWClass
|
|||
/// stay stacked when equipped?
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -71,4 +76,14 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace MWClass
|
|||
///< Return name of the script attached to ptr
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontake.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/inventorystore.hpp"
|
||||
|
||||
#include "../mwrender/objects.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
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,
|
||||
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> (
|
||||
new MWWorld::ActionTake (ptr));
|
||||
}
|
||||
|
@ -103,7 +108,7 @@ namespace MWClass
|
|||
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
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
|
@ -140,4 +145,96 @@ namespace MWClass
|
|||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,12 +35,18 @@ namespace MWClass
|
|||
///< \return first: Return IDs of the slot this object can be equipped in; second: can object
|
||||
/// stay stacked when equipped?
|
||||
|
||||
virtual int getEuqipmentSkill (const MWWorld::Ptr& ptr,
|
||||
virtual int getEquipmentSkill (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Environment& environment) const;
|
||||
/// Return the index of the skill this item corresponds to when equiopped or -1, if there is
|
||||
/// no such skill.
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -9,16 +9,36 @@
|
|||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
||||
#include "../mwinput/inputmanager.hpp"
|
||||
#include "../mwgui/dialogue.hpp"
|
||||
#include "../mwgui/window_manager.hpp"
|
||||
|
||||
#include "journal.hpp"
|
||||
|
||||
#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
|
||||
{
|
||||
std::string toLower (const std::string& name)
|
||||
|
@ -31,6 +51,7 @@ namespace
|
|||
return lowerCase;
|
||||
}
|
||||
|
||||
|
||||
template<typename T1, typename T2>
|
||||
bool selectCompare (char comp, T1 value1, T2 value2)
|
||||
{
|
||||
|
@ -115,6 +136,125 @@ namespace
|
|||
|
||||
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,
|
||||
const ESM::DialInfo::SelectStruct& select) const
|
||||
{
|
||||
|
@ -124,14 +264,13 @@ namespace MWDialogue
|
|||
{
|
||||
char comp = select.selectRule[4];
|
||||
std::string name = select.selectRule.substr (5);
|
||||
|
||||
// TODO types 4, 5, 6, 7, 8, 9, A, B, C
|
||||
std::string function = select.selectRule.substr(1,2);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case '1': // function
|
||||
|
||||
return false; // TODO implement functions
|
||||
return true; // TODO implement functions
|
||||
|
||||
case '2': // global
|
||||
|
||||
|
@ -173,6 +312,122 @@ namespace MWDialogue
|
|||
|
||||
return true;
|
||||
|
||||
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");
|
||||
|
||||
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))
|
||||
return false;
|
||||
|
||||
//PC Faction
|
||||
if(!info.pcFaction.empty()) return false;
|
||||
|
||||
//NPC race
|
||||
if (!info.race.empty())
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
||||
|
@ -200,6 +459,7 @@ namespace MWDialogue
|
|||
return false;
|
||||
}
|
||||
|
||||
//NPC class
|
||||
if (!info.clas.empty())
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
||||
|
@ -211,6 +471,7 @@ namespace MWDialogue
|
|||
return false;
|
||||
}
|
||||
|
||||
//NPC faction
|
||||
if (!info.npcFaction.empty())
|
||||
{
|
||||
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))
|
||||
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
|
||||
|
||||
//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
|
||||
if (!info.cell.empty())
|
||||
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
|
||||
return false;
|
||||
|
||||
// TODO check DATAstruct
|
||||
|
||||
for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
|
||||
iter != info.selects.end(); ++iter)
|
||||
if (!isMatching (actor, *iter))
|
||||
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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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());
|
||||
iter!=dialogue->mInfo.end(); ++iter)
|
||||
mDialogueMap.clear();
|
||||
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)
|
||||
{
|
||||
if (greetingFound) break;
|
||||
for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin());
|
||||
iter!=it->second.mInfo.end(); ++iter)
|
||||
{
|
||||
if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true))
|
||||
{
|
||||
// start dialogue
|
||||
std::cout << "found matching info record" << std::endl;
|
||||
|
||||
std::cout << "response: " << iter->response << std::endl;
|
||||
|
||||
if (!iter->sound.empty())
|
||||
{
|
||||
// TODO play sound
|
||||
}
|
||||
|
||||
if (!iter->resultScript.empty())
|
||||
{
|
||||
std::cout << "script: " << iter->resultScript << std::endl;
|
||||
// TODO execute script
|
||||
}
|
||||
|
||||
mEnvironment.mInputManager->setGuiMode(MWGui::GM_Dialogue);
|
||||
std::string text = iter->response;
|
||||
parseText(text);
|
||||
win->addText(iter->response);
|
||||
executeScript(iter->resultScript);
|
||||
greetingFound = true;
|
||||
mLastTopic = it->first;
|
||||
mLastDialogue = *iter;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,13 @@
|
|||
|
||||
#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 <map>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
|
@ -20,12 +26,48 @@ namespace MWDialogue
|
|||
|
||||
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:
|
||||
|
||||
DialogueManager (MWWorld::Environment& environment);
|
||||
DialogueManager (MWWorld::Environment& environment,const Compiler::Extensions& extensions);
|
||||
|
||||
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);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwgui/window_manager.hpp"
|
||||
#include "../mwgui/messagebox.hpp"
|
||||
|
||||
namespace MWDialogue
|
||||
{
|
||||
Quest& Journal::getQuest (const std::string& id)
|
||||
|
@ -34,6 +37,10 @@ namespace MWDialogue
|
|||
Quest& quest = getQuest (id);
|
||||
|
||||
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)
|
||||
|
@ -60,7 +67,12 @@ namespace MWDialogue
|
|||
|
||||
int Journal::getJournalIndex (const std::string& id) const
|
||||
{
|
||||
TQuestContainer::const_iterator iter = mQuests.find (id);
|
||||
|
||||
if (iter==mQuests.end())
|
||||
return 0;
|
||||
|
||||
return iter->second.getIndex();
|
||||
}
|
||||
|
||||
Journal::TEntryIter Journal::begin() const
|
||||
|
|
|
@ -21,18 +21,18 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager)
|
|||
|
||||
getWidget(birthList, "BirthsignList");
|
||||
birthList->setScrollVisible(true);
|
||||
birthList->eventListSelectAccept = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
birthList->eventListMouseItemActivate = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
birthList->eventListChangePosition = MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
birthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||
|
||||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &BirthDialog::onBackClicked);
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &BirthDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked);
|
||||
|
||||
updateBirths();
|
||||
updateSpells();
|
||||
|
@ -100,7 +100,7 @@ void BirthDialog::onBackClicked(MyGUI::Widget* _sender)
|
|||
eventBack();
|
||||
}
|
||||
|
||||
void BirthDialog::onSelectBirth(MyGUI::List* _sender, size_t _index)
|
||||
void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
|
||||
{
|
||||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
@ -188,7 +188,7 @@ void BirthDialog::updateSpells()
|
|||
{
|
||||
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, ""));
|
||||
spellItems.push_back(label);
|
||||
coord.top += lineHeight;
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace MWGui
|
|||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Back button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -40,7 +40,7 @@ namespace MWGui
|
|||
EventHandle_Void eventBack;
|
||||
|
||||
protected:
|
||||
void onSelectBirth(MyGUI::List* _sender, size_t _index);
|
||||
void onSelectBirth(MyGUI::ListBox* _sender, size_t _index);
|
||||
|
||||
void onOkClicked(MyGUI::Widget* _sender);
|
||||
void onBackClicked(MyGUI::Widget* _sender);
|
||||
|
@ -49,9 +49,9 @@ namespace MWGui
|
|||
void updateBirths();
|
||||
void updateSpells();
|
||||
|
||||
MyGUI::ListPtr birthList;
|
||||
MyGUI::ListBox* birthList;
|
||||
MyGUI::WidgetPtr spellArea;
|
||||
MyGUI::StaticImagePtr birthImage;
|
||||
MyGUI::ImageBox* birthImage;
|
||||
std::vector<MyGUI::WidgetPtr> spellItems;
|
||||
|
||||
std::string currentBirthId;
|
||||
|
|
|
@ -121,7 +121,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
|
||||
mNameDialog->setTextInput(mPlayerName);
|
||||
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
|
||||
mNameDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
|
||||
mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
|
||||
mNameDialog->open();
|
||||
break;
|
||||
|
||||
|
@ -131,8 +131,8 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mRaceDialog = new RaceDialog(*mWM);
|
||||
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
|
||||
mRaceDialog->setRaceId(mPlayerRaceId);
|
||||
mRaceDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
||||
mRaceDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
|
||||
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
||||
mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
|
||||
mRaceDialog->open();
|
||||
break;
|
||||
|
||||
|
@ -140,7 +140,7 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
if (mClassChoiceDialog)
|
||||
mWM->removeDialog(mClassChoiceDialog);
|
||||
mClassChoiceDialog = new ClassChoiceDialog(*mWM);
|
||||
mClassChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
|
||||
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
|
||||
mClassChoiceDialog->open();
|
||||
break;
|
||||
|
||||
|
@ -150,8 +150,8 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mPickClassDialog = new PickClassDialog(*mWM);
|
||||
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
||||
mPickClassDialog->setClassId(mPlayerClass.name);
|
||||
mPickClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
|
||||
mPickClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
|
||||
mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
|
||||
mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
|
||||
mPickClassDialog->open();
|
||||
break;
|
||||
|
||||
|
@ -161,8 +161,8 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mBirthSignDialog = new BirthDialog(*mWM);
|
||||
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
|
||||
mBirthSignDialog->setBirthId(mPlayerBirthSignId);
|
||||
mBirthSignDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
|
||||
mBirthSignDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
|
||||
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
|
||||
mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
|
||||
mBirthSignDialog->open();
|
||||
break;
|
||||
|
||||
|
@ -170,8 +170,8 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
if (mCreateClassDialog)
|
||||
mWM->removeDialog(mCreateClassDialog);
|
||||
mCreateClassDialog = new CreateClassDialog(*mWM);
|
||||
mCreateClassDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
|
||||
mCreateClassDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
|
||||
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
|
||||
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
|
||||
mCreateClassDialog->open();
|
||||
break;
|
||||
case GM_ClassGenerate:
|
||||
|
@ -212,9 +212,9 @@ void CharacterCreation::spawnDialog(const char id)
|
|||
mReviewDialog->configureSkills(mPlayerMajorSkills, mPlayerMinorSkills);
|
||||
}
|
||||
|
||||
mReviewDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
||||
mReviewDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
||||
mReviewDialog->eventActivateDialog = MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
|
||||
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
||||
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
||||
mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
|
||||
mReviewDialog->open();
|
||||
break;
|
||||
}
|
||||
|
@ -559,8 +559,8 @@ void CharacterCreation::showClassQuestionDialog()
|
|||
mWM->removeDialog(mGenerateClassResultDialog);
|
||||
mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
|
||||
mGenerateClassResultDialog->setClassId(mGenerateClass);
|
||||
mGenerateClassResultDialog->eventBack = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
|
||||
mGenerateClassResultDialog->eventDone = MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
|
||||
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
|
||||
mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
|
||||
mGenerateClassResultDialog->open();
|
||||
return;
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ void CharacterCreation::showClassQuestionDialog()
|
|||
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[1]);
|
||||
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
|
||||
mGenerateClassQuestionDialog->setButtons(buttons);
|
||||
mGenerateClassQuestionDialog->eventButtonSelected = MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
|
||||
mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
|
||||
mGenerateClassQuestionDialog->open();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowMan
|
|||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked);
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &GenerateClassResultDialog::onOkClicked);
|
||||
}
|
||||
|
||||
void GenerateClassResultDialog::open()
|
||||
|
@ -96,20 +96,20 @@ PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
|
|||
|
||||
getWidget(classList, "ClassList");
|
||||
classList->setScrollVisible(true);
|
||||
classList->eventListSelectAccept = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
|
||||
classList->eventListMouseItemActivate = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
|
||||
classList->eventListChangePosition = MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
|
||||
classList->eventListSelectAccept += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
|
||||
classList->eventListMouseItemActivate += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
|
||||
classList->eventListChangePosition += MyGUI::newDelegate(this, &PickClassDialog::onSelectClass);
|
||||
|
||||
getWidget(classImage, "ClassImage");
|
||||
|
||||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &PickClassDialog::onBackClicked);
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &PickClassDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked);
|
||||
|
||||
updateClasses();
|
||||
updateStats();
|
||||
|
@ -177,7 +177,7 @@ void PickClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
|||
eventBack();
|
||||
}
|
||||
|
||||
void PickClassDialog::onSelectClass(MyGUI::List* _sender, size_t _index)
|
||||
void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index)
|
||||
{
|
||||
if (_index == MyGUI::ITEM_NONE)
|
||||
return;
|
||||
|
@ -248,7 +248,7 @@ void PickClassDialog::updateStats()
|
|||
|
||||
/* InfoBoxDialog */
|
||||
|
||||
void InfoBoxDialog::fitToText(MyGUI::StaticTextPtr widget)
|
||||
void InfoBoxDialog::fitToText(MyGUI::TextBox* widget)
|
||||
{
|
||||
MyGUI::IntCoord inner = widget->getTextRegion();
|
||||
MyGUI::IntCoord outer = widget->getCoord();
|
||||
|
@ -267,7 +267,7 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
|
|||
for (unsigned i = 0; i < count; ++i)
|
||||
{
|
||||
MyGUI::WidgetPtr child = widget->getChildAt(i);
|
||||
if (!child->isVisible())
|
||||
if (!child->getVisible())
|
||||
continue;
|
||||
|
||||
child->setPosition(child->getLeft(), pos);
|
||||
|
@ -322,7 +322,7 @@ void InfoBoxDialog::setButtons(ButtonList &buttons)
|
|||
button->getSubWidgetText()->setWordWrap(true);
|
||||
button->setCaption(text);
|
||||
fitToText(button);
|
||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked);
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &InfoBoxDialog::onButtonClicked);
|
||||
coord.top += button->getHeight();
|
||||
this->buttons.push_back(button);
|
||||
}
|
||||
|
@ -389,15 +389,15 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
|
|||
setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
|
||||
getWidget(specializationName, "SpecializationName");
|
||||
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:"));
|
||||
getWidget(favoriteAttribute0, "FavoriteAttribute0");
|
||||
getWidget(favoriteAttribute1, "FavoriteAttribute1");
|
||||
favoriteAttribute0->setWindowManager(&mWindowManager);
|
||||
favoriteAttribute1->setWindowManager(&mWindowManager);
|
||||
favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
||||
favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
||||
favoriteAttribute0->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
||||
favoriteAttribute1->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
||||
|
||||
setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", ""));
|
||||
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)
|
||||
{
|
||||
(*it)->setWindowManager(&mWindowManager);
|
||||
(*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
|
||||
(*it)->eventClicked += MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
|
||||
}
|
||||
|
||||
setText("LabelT", mWindowManager.getGameSettingString("sName", ""));
|
||||
|
@ -426,15 +426,15 @@ CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
|
|||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr descriptionButton;
|
||||
getWidget(descriptionButton, "DescriptionButton");
|
||||
descriptionButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked);
|
||||
descriptionButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionClicked);
|
||||
|
||||
MyGUI::ButtonPtr backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked);
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CreateClassDialog::onOkClicked);
|
||||
|
||||
// Set default skills, attributes
|
||||
|
||||
|
@ -560,8 +560,8 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
|
|||
if (specDialog)
|
||||
delete specDialog;
|
||||
specDialog = new SelectSpecializationDialog(mWindowManager);
|
||||
specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
|
||||
specDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
specDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
|
||||
specDialog->setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -578,8 +578,8 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
|
|||
delete attribDialog;
|
||||
attribDialog = new SelectAttributeDialog(mWindowManager);
|
||||
attribDialog->setAffectedWidget(_sender);
|
||||
attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
|
||||
attribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
attribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
|
||||
attribDialog->setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -607,8 +607,8 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
|
|||
delete skillDialog;
|
||||
skillDialog = new SelectSkillDialog(mWindowManager);
|
||||
skillDialog->setAffectedWidget(_sender);
|
||||
skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
|
||||
skillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||
skillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
|
||||
skillDialog->setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
|
|||
{
|
||||
descDialog = new DescriptionDialog(mWindowManager);
|
||||
descDialog->setTextInput(description);
|
||||
descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
|
||||
descDialog->eventDone += MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
|
||||
descDialog->setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -672,18 +672,18 @@ SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowM
|
|||
getWidget(specialization1, "Specialization1");
|
||||
getWidget(specialization2, "Specialization2");
|
||||
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->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
||||
specialization1->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
||||
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;
|
||||
|
||||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
@ -725,14 +725,14 @@ SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager)
|
|||
getWidget(attribute, std::string("Attribute").append(1, theIndex));
|
||||
attribute->setWindowManager(&parWindowManager);
|
||||
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
|
||||
MyGUI::ButtonPtr cancelButton;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
@ -813,7 +813,7 @@ SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
|
|||
{
|
||||
skills[spec][i].widget->setWindowManager(&mWindowManager);
|
||||
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;
|
||||
getWidget(cancelButton, "CancelButton");
|
||||
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
|
||||
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
|
||||
}
|
||||
|
||||
// widget controls
|
||||
|
@ -850,7 +850,7 @@ DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
|
|||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
|
||||
okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", ""));
|
||||
|
||||
// Make sure the edit box has focus
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace MWGui
|
|||
int getChosenButton() const;
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate1<int> EventHandle_Int;
|
||||
typedef delegates::CMultiDelegate1<int> EventHandle_Int;
|
||||
|
||||
/** Event : Button was clicked.\n
|
||||
signature : void method(MyGUI::WidgetPtr widget, int index)\n
|
||||
|
@ -43,11 +43,11 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
|
||||
void fitToText(MyGUI::StaticTextPtr widget);
|
||||
void fitToText(MyGUI::TextBox* widget);
|
||||
void layoutVertically(MyGUI::WidgetPtr widget, int margin);
|
||||
int currentButton;
|
||||
MyGUI::WidgetPtr textBox;
|
||||
MyGUI::StaticTextPtr text;
|
||||
MyGUI::TextBox* text;
|
||||
MyGUI::WidgetPtr buttonBar;
|
||||
std::vector<MyGUI::ButtonPtr> buttons;
|
||||
};
|
||||
|
@ -78,7 +78,7 @@ namespace MWGui
|
|||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Back button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -90,8 +90,8 @@ namespace MWGui
|
|||
void onBackClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::StaticImagePtr classImage;
|
||||
MyGUI::StaticTextPtr className;
|
||||
MyGUI::ImageBox* classImage;
|
||||
MyGUI::TextBox* className;
|
||||
|
||||
std::string currentClassId;
|
||||
};
|
||||
|
@ -108,7 +108,7 @@ namespace MWGui
|
|||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Back button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -116,7 +116,7 @@ namespace MWGui
|
|||
EventHandle_Void eventBack;
|
||||
|
||||
protected:
|
||||
void onSelectClass(MyGUI::List* _sender, size_t _index);
|
||||
void onSelectClass(MyGUI::ListBox* _sender, size_t _index);
|
||||
|
||||
void onOkClicked(MyGUI::Widget* _sender);
|
||||
void onBackClicked(MyGUI::Widget* _sender);
|
||||
|
@ -125,9 +125,9 @@ namespace MWGui
|
|||
void updateClasses();
|
||||
void updateStats();
|
||||
|
||||
MyGUI::StaticImagePtr classImage;
|
||||
MyGUI::ListPtr classList;
|
||||
MyGUI::StaticTextPtr specializationName;
|
||||
MyGUI::ImageBox* classImage;
|
||||
MyGUI::ListBox* classList;
|
||||
MyGUI::TextBox* specializationName;
|
||||
Widgets::MWAttributePtr favoriteAttribute[2];
|
||||
Widgets::MWSkillPtr majorSkill[5];
|
||||
Widgets::MWSkillPtr minorSkill[5];
|
||||
|
@ -143,7 +143,7 @@ namespace MWGui
|
|||
ESM::Class::Specialization getSpecializationId() const { return specializationId; }
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Cancel button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -160,7 +160,7 @@ namespace MWGui
|
|||
void onCancelClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
MyGUI::WidgetPtr specialization0, specialization1, specialization2;
|
||||
MyGUI::TextBox *specialization0, *specialization1, *specialization2;
|
||||
|
||||
ESM::Class::Specialization specializationId;
|
||||
};
|
||||
|
@ -175,7 +175,7 @@ namespace MWGui
|
|||
void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; }
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Cancel button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -207,7 +207,7 @@ namespace MWGui
|
|||
void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; }
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Cancel button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -264,7 +264,7 @@ namespace MWGui
|
|||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Back button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -287,7 +287,7 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
MyGUI::EditPtr editName;
|
||||
MyGUI::WidgetPtr specializationName;
|
||||
MyGUI::TextBox* specializationName;
|
||||
Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1;
|
||||
Widgets::MWSkillPtr majorSkill[5];
|
||||
Widgets::MWSkillPtr minorSkill[5];
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace MWGui
|
|||
|
||||
return isGood();
|
||||
}
|
||||
catch (const Compiler::SourceException& error)
|
||||
catch (const Compiler::SourceException&)
|
||||
{
|
||||
// error has already been reported via error handler
|
||||
}
|
||||
|
@ -113,9 +113,9 @@ namespace MWGui
|
|||
getWidget(history, "list_History");
|
||||
|
||||
// Set up the command line box
|
||||
command->eventEditSelectAccept =
|
||||
command->eventEditSelectAccept +=
|
||||
newDelegate(this, &Console::acceptCommand);
|
||||
command->eventKeyButtonPressed =
|
||||
command->eventKeyButtonPressed +=
|
||||
newDelegate(this, &Console::keyPress);
|
||||
|
||||
// Set up the log window
|
||||
|
@ -139,6 +139,9 @@ namespace MWGui
|
|||
void Console::disable()
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "window_manager.hpp"
|
||||
#include "widgets.hpp"
|
||||
#include "components/esm_store/store.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwdialogue/dialoguemanager.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <iostream>
|
||||
|
@ -14,8 +16,29 @@
|
|||
using namespace MWGui;
|
||||
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
|
||||
center();
|
||||
|
@ -26,95 +49,159 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
|||
//History view
|
||||
getWidget(history, "History");
|
||||
history->setOverflowToTheLeft(true);
|
||||
history->getClient()->eventMouseButtonClick = MyGUI::newDelegate(this, &DialogueWindow::onHistoryClicked);
|
||||
history->setMaxTextLength(1000000);
|
||||
Widget* eventbox;
|
||||
|
||||
//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");
|
||||
topicsList->setScrollVisible(true);
|
||||
topicsList->eventListSelectAccept = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
topicsList->eventListMouseItemActivate = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
topicsList->eventListChangePosition = MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
//topicsList->eventListSelectAccept += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
topicsList->eventListMouseItemActivate += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
//topicsList->eventListChangePosition += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||
|
||||
MyGUI::ButtonPtr 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)
|
||||
{
|
||||
ISubWidgetText* t = history->getSubWidgetText();
|
||||
ISubWidgetText* t = history->getClient()->getSubWidgetText();
|
||||
if(t == nullptr)
|
||||
return;
|
||||
|
||||
const IntPoint& lastPressed = InputManager::getInstance().getLastLeftPressed();
|
||||
const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||
|
||||
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);
|
||||
std::cout << "Clicked on key: " << key << std::endl;
|
||||
//eventTopicSelected(key);
|
||||
if(color == "#686EBA") mEnvironment.mDialogueManager->keywordSelected(lower_string(key));
|
||||
|
||||
if(color == "#572D21") mEnvironment.mDialogueManager->questionAnswered(key);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogueWindow::open()
|
||||
{
|
||||
topicsList->removeAllItems();
|
||||
pTopicsText.clear();
|
||||
history->eraseText(0,history->getTextLength());
|
||||
updateOptions();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
//const std::string* theTopic = topicsList->getItemDataAt<std::string>(_index);
|
||||
//std::cout << "Selected: "<< theTopic << std::endl;
|
||||
//eventTopicSelected(key);
|
||||
std::string topic = _sender->getItemNameAt(_index);
|
||||
mEnvironment.mDialogueManager->keywordSelected(lower_string(topic));
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
//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
|
||||
topicsList->removeAllItems();
|
||||
int i = 0;
|
||||
topicsList->addItem("Ald'ruhn", i++);
|
||||
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++);
|
||||
}
|
||||
pTopicsText.clear();
|
||||
history->eraseText(0,history->getTextLength());
|
||||
|
||||
pDispositionBar->setProgressRange(100);
|
||||
pDispositionBar->setProgressPosition(40);
|
||||
pDispositionText->eraseText(0,pDispositionText->getTextLength());
|
||||
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
||||
}
|
||||
|
|
|
@ -9,6 +9,11 @@ namespace MWGui
|
|||
class WindowManager;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
}
|
||||
|
||||
/*
|
||||
This file contains the dialouge window
|
||||
Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml.
|
||||
|
@ -16,35 +21,52 @@ namespace MWGui
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class DialogeHistory;
|
||||
class DialogueHistory;
|
||||
|
||||
using namespace MyGUI;
|
||||
|
||||
class DialogueWindow: public WindowBase
|
||||
{
|
||||
public:
|
||||
DialogueWindow(WindowManager& parWindowManager);
|
||||
DialogueWindow(WindowManager& parWindowManager,MWWorld::Environment& environment);
|
||||
|
||||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Dialog finished, OK button clicked.\n
|
||||
signature : void method()\n
|
||||
*/
|
||||
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:
|
||||
void onSelectTopic(MyGUI::List* _sender, size_t _index);
|
||||
void onSelectTopic(MyGUI::ListBox* _sender, size_t _index);
|
||||
void onByeClicked(MyGUI::Widget* _sender);
|
||||
void onHistoryClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
void updateOptions();
|
||||
/**
|
||||
*Helper function that add topic keyword in blue in a text.
|
||||
*/
|
||||
std::string parseText(std::string text);
|
||||
|
||||
DialogeHistory* history;
|
||||
MyGUI::ListPtr topicsList;
|
||||
DialogueHistory* history;
|
||||
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
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
using namespace MWGui;
|
||||
using namespace Widgets;
|
||||
|
||||
UString DialogeHistory::getColorAtPos(size_t _pos)
|
||||
UString DialogueHistory::getColorAtPos(size_t _pos)
|
||||
{
|
||||
UString colour = TextIterator::convertTagColour(mText->getTextColour());
|
||||
TextIterator iterator(mText->getCaption());
|
||||
UString colour = TextIterator::convertTagColour(getTextColour());
|
||||
TextIterator iterator(getCaption());
|
||||
while(iterator.moveNext())
|
||||
{
|
||||
size_t pos = iterator.getPosition();
|
||||
|
@ -29,12 +29,12 @@ UString DialogeHistory::getColorAtPos(size_t _pos)
|
|||
return colour;
|
||||
}
|
||||
|
||||
UString DialogeHistory::getColorTextAt(size_t _pos)
|
||||
UString DialogueHistory::getColorTextAt(size_t _pos)
|
||||
{
|
||||
bool breakOnNext = false;
|
||||
UString colour = TextIterator::convertTagColour(mText->getTextColour());
|
||||
UString colour = TextIterator::convertTagColour(getTextColour());
|
||||
UString colour2 = colour;
|
||||
TextIterator iterator(mText->getCaption());
|
||||
TextIterator iterator(getCaption());
|
||||
TextIterator col_start = iterator;
|
||||
while(iterator.moveNext())
|
||||
{
|
||||
|
@ -59,15 +59,15 @@ UString DialogeHistory::getColorTextAt(size_t _pos)
|
|||
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("#FFFFFF\n");
|
||||
head.append("#B29154\n");
|
||||
addText(head);
|
||||
}
|
||||
|
||||
void DialogeHistory::addDialogText(const UString& parText)
|
||||
void DialogueHistory::addDialogText(const UString& parText)
|
||||
{
|
||||
addText(parText);
|
||||
addText("\n");
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
namespace MWGui
|
||||
{
|
||||
using namespace MyGUI;
|
||||
class DialogeHistory : public MyGUI::Edit
|
||||
class DialogueHistory : public MyGUI::EditBox
|
||||
{
|
||||
MYGUI_RTTI_DERIVED( DialogeHistory )
|
||||
MYGUI_RTTI_DERIVED( DialogueHistory )
|
||||
public:
|
||||
Widget* getClient() { return mClient; }
|
||||
UString getColorAtPos(size_t _pos);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct book
|
||||
|
@ -87,9 +89,9 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
|
|||
getWidget(mLeftTextWidget, "LeftText");
|
||||
getWidget(mRightTextWidget, "RightText");
|
||||
getWidget(mPrevBtn, "PrevPageBTN");
|
||||
mPrevBtn->eventMouseButtonClick = MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage);
|
||||
mPrevBtn->eventMouseButtonClick += MyGUI::newDelegate(this,&MWGui::JournalWindow::notifyPrevPage);
|
||||
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();
|
||||
//list->addItem("qaq","aqzazaz");
|
||||
//mScrollerWidget->addChildItem(list);
|
||||
|
@ -109,12 +111,14 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
|
|||
//displayLeftText(list.front());
|
||||
|
||||
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()
|
||||
{
|
||||
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())
|
||||
{
|
||||
book journal;
|
||||
|
@ -176,6 +180,8 @@ void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
|
|||
{
|
||||
if(mPageNumber < int(leftPages.size())-1)
|
||||
{
|
||||
std::string nextSound = "book page2";
|
||||
mWindowManager.getEnvironment().mSoundManager->playSound (nextSound, 1.0, 1.0);
|
||||
mPageNumber = mPageNumber + 1;
|
||||
displayLeftText(leftPages[mPageNumber]);
|
||||
displayRightText(rightPages[mPageNumber]);
|
||||
|
@ -186,6 +192,8 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender)
|
|||
{
|
||||
if(mPageNumber > 0)
|
||||
{
|
||||
std::string prevSound = "book page";
|
||||
mWindowManager.getEnvironment().mSoundManager->playSound (prevSound, 1.0, 1.0);
|
||||
mPageNumber = mPageNumber - 1;
|
||||
displayLeftText(leftPages[mPageNumber]);
|
||||
displayRightText(rightPages[mPageNumber]);
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace MWGui
|
|||
static const int lineHeight;
|
||||
|
||||
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
|
||||
MyGUI::VScrollPtr skillScrollerWidget;
|
||||
MyGUI::ScrollBar* skillScrollerWidget;
|
||||
int lastPos, clientHeight;
|
||||
MyGUI::EditPtr mLeftTextWidget;
|
||||
MyGUI::EditPtr mRightTextWidget;
|
||||
|
|
|
@ -15,6 +15,22 @@ using namespace MWGui;
|
|||
|
||||
HUD::HUD(int width, int height, int fpsLevel)
|
||||
: Layout("openmw_hud_layout.xml")
|
||||
, health(NULL)
|
||||
, magicka(NULL)
|
||||
, stamina(NULL)
|
||||
, weapImage(NULL)
|
||||
, spellImage(NULL)
|
||||
, weapStatus(NULL)
|
||||
, spellStatus(NULL)
|
||||
, effectBox(NULL)
|
||||
, effect1(NULL)
|
||||
, minimap(NULL)
|
||||
, compass(NULL)
|
||||
, crosshair(NULL)
|
||||
, fpsbox(NULL)
|
||||
, fpscounter(NULL)
|
||||
, trianglecounter(NULL)
|
||||
, batchcounter(NULL)
|
||||
{
|
||||
setCoord(0,0, width, height);
|
||||
|
||||
|
@ -61,6 +77,8 @@ HUD::HUD(int width, int height, int fpsLevel)
|
|||
setSpellIcon("icons\\s\\b_tx_s_rstor_health.dds");
|
||||
setSpellStatus(65, 100);
|
||||
setEffect("icons\\s\\tx_s_chameleon.dds");
|
||||
|
||||
LocalMapBase::init(minimap, this);
|
||||
}
|
||||
|
||||
void HUD::setFPS(float fps)
|
||||
|
@ -142,3 +160,175 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HUD::setPlayerDir(const float x, const float y)
|
||||
{
|
||||
MyGUI::ISubWidget* main = compass->getSubWidgetMain();
|
||||
MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>();
|
||||
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
|
||||
float angle = std::atan2(x,y);
|
||||
rotatingSubskin->setAngle(angle);
|
||||
}
|
||||
|
||||
void HUD::setPlayerPos(const float x, const float y)
|
||||
{
|
||||
MyGUI::IntSize size = minimap->getCanvasSize();
|
||||
MyGUI::IntPoint middle = MyGUI::IntPoint((1/3.f + x/3.f)*size.width,(1/3.f + y/3.f)*size.height);
|
||||
MyGUI::IntCoord viewsize = minimap->getCoord();
|
||||
MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top);
|
||||
|
||||
minimap->setViewOffset(pos);
|
||||
compass->setPosition(MyGUI::IntPoint(x*512-16, y*512-16));
|
||||
}
|
||||
|
||||
MapWindow::MapWindow()
|
||||
: Layout("openmw_map_window_layout.xml")
|
||||
, mGlobal(false)
|
||||
, mVisible(false)
|
||||
{
|
||||
setCoord(500,0,320,300);
|
||||
setText("WorldButton", "World");
|
||||
setImage("Compass", "textures\\compass.dds");
|
||||
|
||||
// Obviously you should override this later on
|
||||
setCellName("No Cell Loaded");
|
||||
|
||||
getWidget(mLocalMap, "LocalMap");
|
||||
getWidget(mGlobalMap, "GlobalMap");
|
||||
getWidget(mPlayerArrow, "Compass");
|
||||
|
||||
getWidget(mButton, "WorldButton");
|
||||
mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked);
|
||||
|
||||
MyGUI::Button* eventbox;
|
||||
getWidget(eventbox, "EventBox");
|
||||
eventbox->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag);
|
||||
eventbox->eventMouseButtonPressed += MyGUI::newDelegate(this, &MapWindow::onDragStart);
|
||||
|
||||
LocalMapBase::init(mLocalMap, this);
|
||||
}
|
||||
|
||||
void MapWindow::setVisible(bool b)
|
||||
{
|
||||
mMainWidget->setVisible(b);
|
||||
if (b)
|
||||
mVisible = true;
|
||||
else
|
||||
mVisible = false;
|
||||
}
|
||||
|
||||
void MapWindow::setCellName(const std::string& cellName)
|
||||
{
|
||||
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(cellName);
|
||||
adjustWindowCaption();
|
||||
}
|
||||
|
||||
void MapWindow::setPlayerPos(const float x, const float y)
|
||||
{
|
||||
if (mGlobal || mVisible) return;
|
||||
MyGUI::IntSize size = mLocalMap->getCanvasSize();
|
||||
MyGUI::IntPoint middle = MyGUI::IntPoint((1/3.f + x/3.f)*size.width,(1/3.f + y/3.f)*size.height);
|
||||
MyGUI::IntCoord viewsize = mLocalMap->getCoord();
|
||||
MyGUI::IntPoint pos(0.5*viewsize.width - middle.left, 0.5*viewsize.height - middle.top);
|
||||
mLocalMap->setViewOffset(pos);
|
||||
|
||||
mPlayerArrow->setPosition(MyGUI::IntPoint(x*512-16, y*512-16));
|
||||
}
|
||||
|
||||
void MapWindow::setPlayerDir(const float x, const float y)
|
||||
{
|
||||
if (!mVisible) return;
|
||||
MyGUI::ISubWidget* main = mPlayerArrow->getSubWidgetMain();
|
||||
MyGUI::RotatingSkin* rotatingSubskin = main->castType<MyGUI::RotatingSkin>();
|
||||
rotatingSubskin->setCenter(MyGUI::IntPoint(16,16));
|
||||
float angle = std::atan2(x,y);
|
||||
rotatingSubskin->setAngle(angle);
|
||||
}
|
||||
|
||||
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
if (_id!=MyGUI::MouseButton::Left) return;
|
||||
if (!mGlobal)
|
||||
mLastDragPos = MyGUI::IntPoint(_left, _top);
|
||||
}
|
||||
|
||||
void MapWindow::onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
if (_id!=MyGUI::MouseButton::Left) return;
|
||||
|
||||
if (!mGlobal)
|
||||
{
|
||||
MyGUI::IntPoint diff = MyGUI::IntPoint(_left, _top) - mLastDragPos;
|
||||
mLocalMap->setViewOffset( mLocalMap->getViewOffset() + diff );
|
||||
|
||||
mLastDragPos = MyGUI::IntPoint(_left, _top);
|
||||
}
|
||||
}
|
||||
|
||||
void MapWindow::onWorldButtonClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
mGlobal = !mGlobal;
|
||||
mGlobalMap->setVisible(mGlobal);
|
||||
mLocalMap->setVisible(!mGlobal);
|
||||
|
||||
mButton->setCaption( mGlobal ? "Local" : "World" );
|
||||
}
|
||||
|
||||
LocalMapBase::LocalMapBase()
|
||||
: mCurX(0)
|
||||
, mCurY(0)
|
||||
, mInterior(false)
|
||||
, mLocalMap(NULL)
|
||||
, mPrefix()
|
||||
, mChanged(true)
|
||||
, mLayout(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void LocalMapBase::init(MyGUI::ScrollView* widget, OEngine::GUI::Layout* layout)
|
||||
{
|
||||
mLocalMap = widget;
|
||||
mLayout = layout;
|
||||
}
|
||||
|
||||
void LocalMapBase::setCellPrefix(const std::string& prefix)
|
||||
{
|
||||
mPrefix = prefix;
|
||||
mChanged = true;
|
||||
}
|
||||
|
||||
void LocalMapBase::setActiveCell(const int x, const int y, bool interior)
|
||||
{
|
||||
if (x==mCurX && y==mCurY && mInterior==interior && !mChanged) return; // don't do anything if we're still in the same cell
|
||||
for (int mx=0; mx<3; ++mx)
|
||||
{
|
||||
for (int my=0; my<3; ++my)
|
||||
{
|
||||
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
|
||||
+ boost::lexical_cast<std::string>(my);
|
||||
|
||||
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_"
|
||||
+ boost::lexical_cast<std::string>(y + (interior ? (my-1) : -1*(my-1)));
|
||||
|
||||
MyGUI::ImageBox* box;
|
||||
mLayout->getWidget(box, name);
|
||||
MyGUI::ImageBox* fog;
|
||||
mLayout->getWidget(fog, name+"_fog");
|
||||
|
||||
if (MyGUI::RenderManager::getInstance().getTexture(image) != 0)
|
||||
box->setImageTexture(image);
|
||||
else
|
||||
box->setImageTexture("black.png");
|
||||
|
||||
if (MyGUI::RenderManager::getInstance().getTexture(image+"_fog") != 0)
|
||||
fog->setImageTexture(image+"_fog");
|
||||
else
|
||||
fog->setImageTexture("black.png");
|
||||
}
|
||||
}
|
||||
mInterior = interior;
|
||||
mCurX = x;
|
||||
mCurY = y;
|
||||
mChanged = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "../mwmechanics/stat.hpp"
|
||||
#include "window_base.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
/*
|
||||
This file contains classes corresponding to window layouts
|
||||
defined in resources/mygui/ *.xml.
|
||||
|
@ -29,7 +31,26 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class HUD : public OEngine::GUI::Layout
|
||||
class LocalMapBase
|
||||
{
|
||||
public:
|
||||
LocalMapBase();
|
||||
void init(MyGUI::ScrollView* widget, OEngine::GUI::Layout* layout);
|
||||
|
||||
void setCellPrefix(const std::string& prefix);
|
||||
void setActiveCell(const int x, const int y, bool interior=false);
|
||||
|
||||
protected:
|
||||
int mCurX, mCurY;
|
||||
bool mInterior;
|
||||
MyGUI::ScrollView* mLocalMap;
|
||||
std::string mPrefix;
|
||||
bool mChanged;
|
||||
|
||||
OEngine::GUI::Layout* mLayout;
|
||||
};
|
||||
|
||||
class HUD : public OEngine::GUI::Layout, public LocalMapBase
|
||||
{
|
||||
public:
|
||||
HUD(int width, int height, int fpsLevel);
|
||||
|
@ -43,40 +64,46 @@ namespace MWGui
|
|||
void setFPS(float fps);
|
||||
void setTriangleCount(size_t count);
|
||||
void setBatchCount(size_t count);
|
||||
void setPlayerDir(const float x, const float y);
|
||||
void setPlayerPos(const float x, const float y);
|
||||
|
||||
MyGUI::ProgressPtr health, magicka, stamina;
|
||||
MyGUI::StaticImagePtr weapImage, spellImage;
|
||||
MyGUI::ImageBox *weapImage, *spellImage;
|
||||
MyGUI::ProgressPtr weapStatus, spellStatus;
|
||||
MyGUI::WidgetPtr effectBox;
|
||||
MyGUI::StaticImagePtr effect1;
|
||||
MyGUI::StaticImagePtr minimap;
|
||||
MyGUI::StaticImagePtr compass;
|
||||
MyGUI::StaticImagePtr crosshair;
|
||||
MyGUI::ImageBox* effect1;
|
||||
MyGUI::ScrollView* minimap;
|
||||
MyGUI::ImageBox* compass;
|
||||
MyGUI::ImageBox* crosshair;
|
||||
|
||||
MyGUI::WidgetPtr fpsbox;
|
||||
MyGUI::StaticTextPtr fpscounter;
|
||||
MyGUI::StaticTextPtr trianglecounter;
|
||||
MyGUI::StaticTextPtr batchcounter;
|
||||
MyGUI::TextBox* fpscounter;
|
||||
MyGUI::TextBox* trianglecounter;
|
||||
MyGUI::TextBox* batchcounter;
|
||||
};
|
||||
|
||||
class MapWindow : public OEngine::GUI::Layout
|
||||
class MapWindow : public OEngine::GUI::Layout, public LocalMapBase
|
||||
{
|
||||
public:
|
||||
MapWindow()
|
||||
: Layout("openmw_map_window_layout.xml")
|
||||
{
|
||||
setCoord(500,0,320,300);
|
||||
setText("WorldButton", "World");
|
||||
setImage("Compass", "compass.dds");
|
||||
MapWindow();
|
||||
virtual ~MapWindow(){}
|
||||
|
||||
// Obviously you should override this later on
|
||||
setCellName("No Cell Loaded");
|
||||
}
|
||||
void setVisible(bool b);
|
||||
void setPlayerPos(const float x, const float y);
|
||||
void setPlayerDir(const float x, const float y);
|
||||
void setCellName(const std::string& cellName);
|
||||
|
||||
void setCellName(const std::string& cellName)
|
||||
{
|
||||
mMainWidget->setCaption(cellName);
|
||||
}
|
||||
private:
|
||||
void onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
|
||||
void onWorldButtonClicked(MyGUI::Widget* _sender);
|
||||
|
||||
MyGUI::ScrollView* mGlobalMap;
|
||||
MyGUI::ImageBox* mPlayerArrow;
|
||||
MyGUI::Button* mButton;
|
||||
MyGUI::IntPoint mLastDragPos;
|
||||
bool mVisible;
|
||||
bool mGlobal;
|
||||
};
|
||||
|
||||
class MainMenu : public OEngine::GUI::Layout
|
||||
|
@ -127,7 +154,7 @@ namespace MWGui
|
|||
getWidget(avatar, "Avatar");
|
||||
|
||||
// Adjust armor rating text to bottom of avatar widget
|
||||
MyGUI::StaticTextPtr armor_rating;
|
||||
MyGUI::TextBox* armor_rating;
|
||||
getWidget(armor_rating, "ArmorRating");
|
||||
armor_rating->setCaption("Armor: 11");
|
||||
MyGUI::IntCoord coord = armor_rating->getCoord();
|
||||
|
@ -165,7 +192,7 @@ namespace MWGui
|
|||
last_x += coord.width + margin;
|
||||
button_pt->setCoord(coord);
|
||||
|
||||
button_pt->eventMouseButtonClick = MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected);
|
||||
button_pt->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onCategorySelected);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,6 @@ void MessageBoxManager::onFrame (float frameDuration)
|
|||
|
||||
void MessageBoxManager::createMessageBox (const std::string& message)
|
||||
{
|
||||
std::cout << "MessageBox: " << message << std::endl;
|
||||
|
||||
MessageBox *box = new MessageBox(*this, message);
|
||||
|
||||
removeMessageBox(message.length()*mMessageBoxSpeed, box);
|
||||
|
@ -168,7 +166,8 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
|
|||
|
||||
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
|
||||
|
||||
mMainWidget->setSize(size);
|
||||
|
@ -178,7 +177,7 @@ MessageBox::MessageBox(MessageBoxManager& parMessageBoxManager, const std::strin
|
|||
|
||||
void MessageBox::update (int height)
|
||||
{
|
||||
MyGUI::IntSize gameWindowSize = mMessageBoxManager.mWindowManager->getGui()->getViewSize();
|
||||
MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntCoord coord;
|
||||
coord.left = (gameWindowSize.width - mFixedWidth)/2;
|
||||
coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding);
|
||||
|
@ -221,9 +220,9 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
mMessageWidget->setOverflowToTheLeft(true);
|
||||
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 buttonWidth = 0;
|
||||
|
@ -241,13 +240,13 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
MyGUI::Align::Default);
|
||||
button->setCaption(*it);
|
||||
|
||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &InteractiveMessageBox::mousePressed);
|
||||
|
||||
mButtons.push_back(button);
|
||||
|
||||
buttonWidth = button->_getTextSize().width + 2*buttonPadding + buttonLeftPadding;
|
||||
buttonWidth = button->getTextSize().width + 2*buttonPadding + buttonLeftPadding;
|
||||
buttonsWidth += buttonWidth;
|
||||
buttonHeight = button->_getTextSize().height + 2*buttonPadding + buttonTopPadding;
|
||||
buttonHeight = button->getTextSize().height + 2*buttonPadding + buttonTopPadding;
|
||||
|
||||
if(buttonWidth > biggestButtonWidth)
|
||||
{
|
||||
|
@ -301,8 +300,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
buttonCord.left = left;
|
||||
buttonCord.top = textSize.height + textButtonPadding;
|
||||
|
||||
buttonSize.width = (*button)->_getTextSize().width + 2*buttonPadding;
|
||||
buttonSize.height = (*button)->_getTextSize().height + 2*buttonPadding;
|
||||
buttonSize.width = (*button)->getTextSize().width + 2*buttonPadding;
|
||||
buttonSize.height = (*button)->getTextSize().height + 2*buttonPadding;
|
||||
|
||||
(*button)->setCoord(buttonCord);
|
||||
(*button)->setSize(buttonSize);
|
||||
|
@ -349,8 +348,8 @@ InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxMan
|
|||
std::vector<MyGUI::ButtonPtr>::const_iterator button;
|
||||
for(button = mButtons.begin(); button != mButtons.end(); ++button)
|
||||
{
|
||||
buttonSize.width = (*button)->_getTextSize().width + buttonPadding*2;
|
||||
buttonSize.height = (*button)->_getTextSize().height + buttonPadding*2;
|
||||
buttonSize.width = (*button)->getTextSize().width + buttonPadding*2;
|
||||
buttonSize.height = (*button)->getTextSize().height + buttonPadding*2;
|
||||
|
||||
buttonCord.top = top;
|
||||
buttonCord.left = (mainWidgetSize.width - buttonSize.width)/2 - 5; // FIXME: -5 is not so nice :/
|
||||
|
@ -387,8 +386,3 @@ int InteractiveMessageBox::readPressedButton ()
|
|||
mButtonPressed = -1;
|
||||
return pressed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "window_base.hpp"
|
||||
#include "window_manager.hpp"
|
||||
|
||||
#undef MessageBox
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
|
|||
headRotate->setScrollRange(50);
|
||||
headRotate->setScrollPosition(20);
|
||||
headRotate->setScrollViewPage(10);
|
||||
headRotate->eventScrollChangePosition = MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
|
||||
headRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
|
||||
|
||||
// Set up next/previous buttons
|
||||
MyGUI::ButtonPtr prevButton, nextButton;
|
||||
|
@ -42,27 +42,27 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
|
|||
setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex"));
|
||||
getWidget(prevButton, "PrevGenderButton");
|
||||
getWidget(nextButton, "NextGenderButton");
|
||||
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
|
||||
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
|
||||
prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
|
||||
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
|
||||
|
||||
setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face"));
|
||||
getWidget(prevButton, "PrevFaceButton");
|
||||
getWidget(nextButton, "NextFaceButton");
|
||||
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
|
||||
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
|
||||
prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
|
||||
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
|
||||
|
||||
setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Hair"));
|
||||
getWidget(prevButton, "PrevHairButton");
|
||||
getWidget(nextButton, "NextHairButton");
|
||||
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
|
||||
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
|
||||
prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
|
||||
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
|
||||
|
||||
setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race"));
|
||||
getWidget(raceList, "RaceList");
|
||||
raceList->setScrollVisible(true);
|
||||
raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||
raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||
raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||
raceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||
raceList->eventListMouseItemActivate += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||
raceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||
|
||||
setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
|
||||
getWidget(skillList, "SkillList");
|
||||
|
@ -72,11 +72,11 @@ RaceDialog::RaceDialog(WindowManager& parWindowManager)
|
|||
// TODO: These buttons should be managed by a Dialog class
|
||||
MyGUI::ButtonPtr backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
|
||||
|
||||
updateRaces();
|
||||
updateSkills();
|
||||
|
@ -157,7 +157,7 @@ void RaceDialog::onBackClicked(MyGUI::Widget* _sender)
|
|||
eventBack();
|
||||
}
|
||||
|
||||
void RaceDialog::onHeadRotate(MyGUI::VScroll*, size_t _position)
|
||||
void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position)
|
||||
{
|
||||
// TODO: Rotate head
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ void RaceDialog::onSelectNextHair(MyGUI::Widget*)
|
|||
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)
|
||||
return;
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace MWGui
|
|||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
|
||||
/** Event : Back button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -54,7 +54,7 @@ namespace MWGui
|
|||
EventHandle_Void eventBack;
|
||||
|
||||
protected:
|
||||
void onHeadRotate(MyGUI::VScroll* _sender, size_t _position);
|
||||
void onHeadRotate(MyGUI::ScrollBar* _sender, size_t _position);
|
||||
|
||||
void onSelectPreviousGender(MyGUI::Widget* _sender);
|
||||
void onSelectNextGender(MyGUI::Widget* _sender);
|
||||
|
@ -65,7 +65,7 @@ namespace MWGui
|
|||
void onSelectPreviousHair(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 onBackClicked(MyGUI::Widget* _sender);
|
||||
|
@ -76,8 +76,8 @@ namespace MWGui
|
|||
void updateSpellPowers();
|
||||
|
||||
MyGUI::CanvasPtr appearanceBox;
|
||||
MyGUI::ListPtr raceList;
|
||||
MyGUI::HScrollPtr headRotate;
|
||||
MyGUI::ListBox* raceList;
|
||||
MyGUI::ScrollBar* headRotate;
|
||||
|
||||
MyGUI::WidgetPtr skillList;
|
||||
std::vector<MyGUI::WidgetPtr> skillItems;
|
||||
|
|
|
@ -28,22 +28,22 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
|
|||
getWidget(nameWidget, "NameText");
|
||||
getWidget(button, "NameButton");
|
||||
button->setCaption(mWindowManager.getGameSettingString("sName", ""));
|
||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
|
||||
|
||||
getWidget(raceWidget, "RaceText");
|
||||
getWidget(button, "RaceButton");
|
||||
button->setCaption(mWindowManager.getGameSettingString("sRace", ""));
|
||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
|
||||
|
||||
getWidget(classWidget, "ClassText");
|
||||
getWidget(button, "ClassButton");
|
||||
button->setCaption(mWindowManager.getGameSettingString("sClass", ""));
|
||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
|
||||
|
||||
getWidget(birthSignWidget, "SignText");
|
||||
getWidget(button, "SignButton");
|
||||
button->setCaption(mWindowManager.getGameSettingString("sBirthSign", ""));
|
||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
|
||||
button->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
|
||||
|
||||
// Setup dynamic stats
|
||||
getWidget(health, "Health");
|
||||
|
@ -75,25 +75,25 @@ ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
|
|||
getWidget(skillClientWidget, "SkillClient");
|
||||
getWidget(skillScrollerWidget, "SkillScroller");
|
||||
|
||||
skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition);
|
||||
skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &ReviewDialog::onScrollChangePosition);
|
||||
updateScroller();
|
||||
|
||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||
{
|
||||
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
|
||||
MyGUI::ButtonPtr backButton;
|
||||
getWidget(backButton, "BackButton");
|
||||
backButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBackClicked);
|
||||
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onBackClicked);
|
||||
|
||||
MyGUI::ButtonPtr okButton;
|
||||
getWidget(okButton, "OKButton");
|
||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onOkClicked);
|
||||
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ReviewDialog::onOkClicked);
|
||||
}
|
||||
|
||||
void ReviewDialog::open()
|
||||
|
@ -102,7 +102,7 @@ void ReviewDialog::open()
|
|||
setVisible(true);
|
||||
}
|
||||
|
||||
void ReviewDialog::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos)
|
||||
void ReviewDialog::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
||||
{
|
||||
int diff = lastPos - pos;
|
||||
// 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)
|
||||
{
|
||||
skillValues[skillId] = value;
|
||||
MyGUI::StaticTextPtr widget = skillWidgetMap[skillId];
|
||||
MyGUI::TextBox* widget = skillWidgetMap[skillId];
|
||||
if (widget)
|
||||
{
|
||||
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);
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
skillWidgets.push_back(groupWidget);
|
||||
|
||||
|
@ -240,14 +240,15 @@ void ReviewDialog::addGroup(const std::string &label, MyGUI::IntCoord &coord1, M
|
|||
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);
|
||||
|
||||
skillValueWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default);
|
||||
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
|
||||
setStyledText(skillValueWidget, style, value);
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
||||
skillWidgets.push_back(skillNameWidget);
|
||||
|
@ -299,7 +300,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
|
|||
style = CS_Super;
|
||||
else if (modified < base)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ namespace MWGui
|
|||
void open();
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate0 EventHandle_Void;
|
||||
typedef delegates::CDelegate1<int> EventHandle_Int;
|
||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
||||
typedef delegates::CMultiDelegate1<int> EventHandle_Int;
|
||||
|
||||
/** Event : Back button clicked.\n
|
||||
signature : void method()\n
|
||||
|
@ -75,23 +75,23 @@ namespace MWGui
|
|||
CS_Normal,
|
||||
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 addSeparator(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 updateScroller();
|
||||
void updateSkillArea();
|
||||
|
||||
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos);
|
||||
void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||
void onWindowResize(MyGUI::Window* window);
|
||||
|
||||
static const int lineHeight;
|
||||
|
||||
MyGUI::StaticTextPtr nameWidget, raceWidget, classWidget, birthSignWidget;
|
||||
MyGUI::TextBox *nameWidget, *raceWidget, *classWidget, *birthSignWidget;
|
||||
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
|
||||
MyGUI::VScrollPtr skillScrollerWidget;
|
||||
MyGUI::ScrollBar* skillScrollerWidget;
|
||||
int lastPos, clientHeight;
|
||||
|
||||
Widgets::MWDynamicStatPtr health, magicka, fatigue;
|
||||
|
@ -100,7 +100,7 @@ namespace MWGui
|
|||
|
||||
SkillList majorSkills, minorSkills, miscSkills;
|
||||
std::map<int, MWMechanics::Stat<float> > skillValues;
|
||||
std::map<int, MyGUI::StaticTextPtr> skillWidgetMap;
|
||||
std::map<int, MyGUI::TextBox*> skillWidgetMap;
|
||||
std::string name, raceId, birthSignId;
|
||||
ESM::Class klass;
|
||||
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information
|
||||
|
|
|
@ -13,9 +13,22 @@ const int StatsWindow::lineHeight = 18;
|
|||
|
||||
StatsWindow::StatsWindow (WindowManager& parWindowManager)
|
||||
: WindowBase("openmw_stats_window_layout.xml", parWindowManager)
|
||||
, skillAreaWidget(NULL)
|
||||
, skillClientWidget(NULL)
|
||||
, skillScrollerWidget(NULL)
|
||||
, lastPos(0)
|
||||
, clientHeight(0)
|
||||
, majorSkills()
|
||||
, minorSkills()
|
||||
, miscSkills()
|
||||
, skillValues()
|
||||
, skillWidgetMap()
|
||||
, factionWidgetMap()
|
||||
, factions()
|
||||
, birthSignId()
|
||||
, reputation(0)
|
||||
, bounty(0)
|
||||
, skillWidgets()
|
||||
{
|
||||
setCoord(0,0,498, 342);
|
||||
|
||||
|
@ -48,20 +61,20 @@ StatsWindow::StatsWindow (WindowManager& parWindowManager)
|
|||
getWidget(skillClientWidget, "SkillClient");
|
||||
getWidget(skillScrollerWidget, "SkillScroller");
|
||||
|
||||
skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
|
||||
skillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
|
||||
updateScroller();
|
||||
|
||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
// Adjust position of all widget according to difference
|
||||
|
@ -95,10 +108,10 @@ void StatsWindow::setBar(const std::string& name, const std::string& tname, int
|
|||
|
||||
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);
|
||||
if (style == CS_Super)
|
||||
|
@ -175,7 +188,7 @@ void StatsWindow::setValue (const std::string& id, int value)
|
|||
void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
||||
{
|
||||
skillValues[parSkill] = value;
|
||||
MyGUI::StaticTextPtr widget = skillWidgetMap[(int)parSkill];
|
||||
MyGUI::TextBox* widget = skillWidgetMap[(int)parSkill];
|
||||
if (widget)
|
||||
{
|
||||
float modified = value.getModified(), base = value.getBase();
|
||||
|
@ -221,7 +234,7 @@ void StatsWindow::setBirthSign (const std::string& signId)
|
|||
|
||||
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);
|
||||
|
||||
coord1.top += separator->getHeight();
|
||||
|
@ -230,7 +243,7 @@ void StatsWindow::addSeparator(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);
|
||||
skillWidgets.push_back(groupWidget);
|
||||
|
||||
|
@ -238,14 +251,14 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My
|
|||
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);
|
||||
|
||||
skillValueWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default);
|
||||
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
|
||||
setStyledText(skillValueWidget, style, value);
|
||||
|
||||
skillWidgets.push_back(skillNameWidget);
|
||||
|
@ -259,9 +272,9 @@ MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std
|
|||
|
||||
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);
|
||||
|
||||
skillWidgets.push_back(skillNameWidget);
|
||||
|
@ -297,7 +310,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
|
|||
style = CS_Super;
|
||||
else if (modified < base)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,26 +49,26 @@ namespace MWGui
|
|||
CS_Normal,
|
||||
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 addSeparator(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 updateScroller();
|
||||
|
||||
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos);
|
||||
void onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos);
|
||||
void onWindowResize(MyGUI::Window* window);
|
||||
|
||||
static const int lineHeight;
|
||||
|
||||
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
|
||||
MyGUI::VScrollPtr skillScrollerWidget;
|
||||
MyGUI::ScrollBar* skillScrollerWidget;
|
||||
int lastPos, clientHeight;
|
||||
|
||||
SkillList majorSkills, minorSkills, miscSkills;
|
||||
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;
|
||||
FactionList factions; ///< Stores a list of factions and the current rank
|
||||
std::string birthSignId;
|
||||
|
|
|
@ -10,12 +10,12 @@ TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
|
|||
center();
|
||||
|
||||
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
|
||||
MyGUI::ButtonPtr 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
|
||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);
|
||||
|
|
|
@ -62,24 +62,24 @@ void MWSkill::updateWidgets()
|
|||
{
|
||||
if (skillId == ESM::Skill::Length)
|
||||
{
|
||||
skillNameWidget->setCaption("");
|
||||
static_cast<MyGUI::TextBox*>(skillNameWidget)->setCaption("");
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::string &name = manager->getGameSettingString(ESM::Skill::sSkillNameIds[skillId], "");
|
||||
skillNameWidget->setCaption(name);
|
||||
static_cast<MyGUI::TextBox*>(skillNameWidget)->setCaption(name);
|
||||
}
|
||||
}
|
||||
if (skillValueWidget)
|
||||
{
|
||||
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)
|
||||
skillValueWidget->setState("increased");
|
||||
skillValueWidget->_setWidgetState("increased");
|
||||
else if (modified < base)
|
||||
skillValueWidget->setState("decreased");
|
||||
skillValueWidget->_setWidgetState("decreased");
|
||||
else
|
||||
skillValueWidget->setState("normal");
|
||||
skillValueWidget->_setWidgetState("normal");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,59 +88,32 @@ void MWSkill::onClicked(MyGUI::Widget* _sender)
|
|||
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()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
}
|
||||
|
||||
void MWSkill::baseChangeWidgetSkin(ResourceSkin* _info)
|
||||
void MWSkill::initialiseOverride()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
Base::baseChangeWidgetSkin(_info);
|
||||
initialiseWidgetSkin(_info);
|
||||
}
|
||||
Base::initialiseOverride();
|
||||
|
||||
void MWSkill::initialiseWidgetSkin(ResourceSkin* _info)
|
||||
assignWidget(skillNameWidget, "StatName");
|
||||
assignWidget(skillValueWidget, "StatValue");
|
||||
|
||||
MyGUI::ButtonPtr button;
|
||||
assignWidget(button, "StatNameButton");
|
||||
if (button)
|
||||
{
|
||||
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
|
||||
{
|
||||
const std::string &name = *(*iter)->_getInternalData<std::string>();
|
||||
if (name == "StatName")
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
@ -176,7 +149,7 @@ void MWAttribute::updateWidgets()
|
|||
{
|
||||
if (id < 0 || id >= 8)
|
||||
{
|
||||
attributeNameWidget->setCaption("");
|
||||
static_cast<MyGUI::TextBox*>(attributeNameWidget)->setCaption("");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -191,75 +164,48 @@ void MWAttribute::updateWidgets()
|
|||
"sAttributeLuck"
|
||||
};
|
||||
const std::string &name = manager->getGameSettingString(attributes[id], "");
|
||||
attributeNameWidget->setCaption(name);
|
||||
static_cast<MyGUI::TextBox*>(attributeNameWidget)->setCaption(name);
|
||||
}
|
||||
}
|
||||
if (attributeValueWidget)
|
||||
{
|
||||
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)
|
||||
attributeValueWidget->setState("increased");
|
||||
attributeValueWidget->_setWidgetState("increased");
|
||||
else if (modified < base)
|
||||
attributeValueWidget->setState("decreased");
|
||||
attributeValueWidget->_setWidgetState("decreased");
|
||||
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()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
}
|
||||
|
||||
void MWAttribute::baseChangeWidgetSkin(ResourceSkin* _info)
|
||||
void MWAttribute::initialiseOverride()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
Base::baseChangeWidgetSkin(_info);
|
||||
initialiseWidgetSkin(_info);
|
||||
}
|
||||
Base::initialiseOverride();
|
||||
|
||||
void MWAttribute::initialiseWidgetSkin(ResourceSkin* _info)
|
||||
assignWidget(attributeNameWidget, "StatName");
|
||||
assignWidget(attributeValueWidget, "StatValue");
|
||||
|
||||
MyGUI::ButtonPtr button;
|
||||
assignWidget(button, "StatNameButton");
|
||||
if (button)
|
||||
{
|
||||
for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter)
|
||||
{
|
||||
const std::string &name = *(*iter)->_getInternalData<std::string>();
|
||||
if (name == "StatName")
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 */
|
||||
|
@ -301,45 +247,20 @@ void MWSpell::updateWidgets()
|
|||
const ESMS::ESMStore &store = mWindowManager->getStore();
|
||||
const ESM::Spell *spell = store.spells.search(id);
|
||||
if (spell)
|
||||
spellNameWidget->setCaption(spell->name);
|
||||
static_cast<MyGUI::TextBox*>(spellNameWidget)->setCaption(spell->name);
|
||||
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()
|
||||
{
|
||||
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";
|
||||
else if (effect.range == ESM::RT_Target)
|
||||
spellLine += " on Target";
|
||||
textWidget->setCaption(spellLine);
|
||||
static_cast<MyGUI::TextBox*>(textWidget)->setCaption(spellLine);
|
||||
}
|
||||
else
|
||||
textWidget->setCaption("");
|
||||
static_cast<MyGUI::TextBox*>(textWidget)->setCaption("");
|
||||
}
|
||||
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()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
}
|
||||
|
||||
void MWSpellEffect::baseChangeWidgetSkin(ResourceSkin* _info)
|
||||
void MWSpellEffect::initialiseOverride()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
Base::baseChangeWidgetSkin(_info);
|
||||
initialiseWidgetSkin(_info);
|
||||
}
|
||||
Base::initialiseOverride();
|
||||
|
||||
void MWSpellEffect::initialiseWidgetSkin(ResourceSkin* _info)
|
||||
{
|
||||
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()
|
||||
{
|
||||
assignWidget(textWidget, "Text");
|
||||
assignWidget(imageWidget, "Image");
|
||||
}
|
||||
|
||||
/* MWDynamicStat */
|
||||
|
@ -491,60 +383,27 @@ void MWDynamicStat::setValue(int cur, int max_)
|
|||
{
|
||||
std::stringstream out;
|
||||
out << value << "/" << max;
|
||||
barTextWidget->setCaption(out.str().c_str());
|
||||
static_cast<MyGUI::TextBox*>(barTextWidget)->setCaption(out.str().c_str());
|
||||
}
|
||||
else
|
||||
barTextWidget->setCaption("");
|
||||
static_cast<MyGUI::TextBox*>(barTextWidget)->setCaption("");
|
||||
}
|
||||
}
|
||||
void MWDynamicStat::setTitle(const std::string text)
|
||||
{
|
||||
if (textWidget)
|
||||
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);
|
||||
static_cast<MyGUI::TextBox*>(textWidget)->setCaption(text);
|
||||
}
|
||||
|
||||
MWDynamicStat::~MWDynamicStat()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
}
|
||||
|
||||
void MWDynamicStat::baseChangeWidgetSkin(ResourceSkin* _info)
|
||||
void MWDynamicStat::initialiseOverride()
|
||||
{
|
||||
shutdownWidgetSkin();
|
||||
Base::baseChangeWidgetSkin(_info);
|
||||
initialiseWidgetSkin(_info);
|
||||
}
|
||||
Base::initialiseOverride();
|
||||
|
||||
void MWDynamicStat::initialiseWidgetSkin(ResourceSkin* _info)
|
||||
{
|
||||
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 == "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()
|
||||
{
|
||||
assignWidget(textWidget, "Text");
|
||||
assignWidget(barWidget, "Bar");
|
||||
assignWidget(barTextWidget, "BarText");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
#include "../mwmechanics/stat.hpp"
|
||||
|
||||
#undef MYGUI_EXPORT
|
||||
#define MYGUI_EXPORT
|
||||
|
||||
/*
|
||||
This file contains various custom widgets used in OpenMW.
|
||||
*/
|
||||
|
@ -38,26 +41,21 @@ namespace MWGui
|
|||
const SkillValue& getSkillValue() const { return value; }
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate1<MWSkill*> EventHandle_SkillVoid;
|
||||
typedef delegates::CMultiDelegate1<MWSkill*> EventHandle_SkillVoid;
|
||||
|
||||
/** Event : Skill clicked.\n
|
||||
signature : void method(MWSkill* _sender)\n
|
||||
*/
|
||||
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:
|
||||
virtual ~MWSkill();
|
||||
|
||||
void baseChangeWidgetSkin(ResourceSkin* _info);
|
||||
virtual void initialiseOverride();
|
||||
|
||||
void onClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
void initialiseWidgetSkin(ResourceSkin* _info);
|
||||
void shutdownWidgetSkin();
|
||||
|
||||
void updateWidgets();
|
||||
|
||||
|
@ -85,26 +83,21 @@ namespace MWGui
|
|||
const AttributeValue& getAttributeValue() const { return value; }
|
||||
|
||||
// Events
|
||||
typedef delegates::CDelegate1<MWAttribute*> EventHandle_AttributeVoid;
|
||||
typedef delegates::CMultiDelegate1<MWAttribute*> EventHandle_AttributeVoid;
|
||||
|
||||
/** Event : Attribute clicked.\n
|
||||
signature : void method(MWAttribute* _sender)\n
|
||||
*/
|
||||
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:
|
||||
virtual ~MWAttribute();
|
||||
|
||||
void baseChangeWidgetSkin(ResourceSkin* _info);
|
||||
virtual void initialiseOverride();
|
||||
|
||||
void onClicked(MyGUI::Widget* _sender);
|
||||
|
||||
private:
|
||||
void initialiseWidgetSkin(ResourceSkin* _info);
|
||||
void shutdownWidgetSkin();
|
||||
|
||||
void updateWidgets();
|
||||
|
||||
|
@ -130,23 +123,17 @@ namespace MWGui
|
|||
|
||||
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:
|
||||
virtual ~MWSpell();
|
||||
|
||||
void baseChangeWidgetSkin(ResourceSkin* _info);
|
||||
virtual void initialiseOverride();
|
||||
|
||||
private:
|
||||
void initialiseWidgetSkin(ResourceSkin* _info);
|
||||
void shutdownWidgetSkin();
|
||||
|
||||
void updateWidgets();
|
||||
|
||||
WindowManager* mWindowManager;
|
||||
std::string id;
|
||||
MyGUI::StaticTextPtr spellNameWidget;
|
||||
MyGUI::TextBox* spellNameWidget;
|
||||
};
|
||||
typedef MWSpell* MWSpellPtr;
|
||||
|
||||
|
@ -163,24 +150,19 @@ namespace MWGui
|
|||
|
||||
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:
|
||||
virtual ~MWSpellEffect();
|
||||
|
||||
void baseChangeWidgetSkin(ResourceSkin* _info);
|
||||
virtual void initialiseOverride();
|
||||
|
||||
private:
|
||||
void initialiseWidgetSkin(ResourceSkin* _info);
|
||||
void shutdownWidgetSkin();
|
||||
|
||||
void updateWidgets();
|
||||
|
||||
WindowManager* mWindowManager;
|
||||
SpellEffectValue effect;
|
||||
MyGUI::StaticImagePtr imageWidget;
|
||||
MyGUI::StaticTextPtr textWidget;
|
||||
MyGUI::ImageBox* imageWidget;
|
||||
MyGUI::TextBox* textWidget;
|
||||
};
|
||||
typedef MWSpellEffect* MWSpellEffectPtr;
|
||||
|
||||
|
@ -196,22 +178,17 @@ namespace MWGui
|
|||
int getValue() const { return value; }
|
||||
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:
|
||||
virtual ~MWDynamicStat();
|
||||
|
||||
void baseChangeWidgetSkin(ResourceSkin* _info);
|
||||
virtual void initialiseOverride();
|
||||
|
||||
private:
|
||||
void initialiseWidgetSkin(ResourceSkin* _info);
|
||||
void shutdownWidgetSkin();
|
||||
|
||||
int value, max;
|
||||
MyGUI::StaticTextPtr textWidget;
|
||||
MyGUI::TextBox* textWidget;
|
||||
MyGUI::ProgressPtr barWidget;
|
||||
MyGUI::StaticTextPtr barTextWidget;
|
||||
MyGUI::TextBox* barTextWidget;
|
||||
};
|
||||
typedef MWDynamicStat* MWDynamicStatPtr;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ void WindowBase::open()
|
|||
void WindowBase::center()
|
||||
{
|
||||
// Centre dialog
|
||||
MyGUI::IntSize gameWindowSize = mWindowManager.getGui()->getViewSize();
|
||||
MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntCoord coord = mMainWidget->getCoord();
|
||||
coord.left = (gameWindowSize.width - coord.width)/2;
|
||||
coord.top = (gameWindowSize.height - coord.height)/2;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace MWGui
|
|||
WindowBase(const std::string& parLayout, WindowManager& parWindowManager);
|
||||
|
||||
// Events
|
||||
typedef MyGUI::delegates::CDelegate1<WindowBase*> EventHandle_WindowBase;
|
||||
typedef MyGUI::delegates::CMultiDelegate1<WindowBase*> EventHandle_WindowBase;
|
||||
|
||||
virtual void open();
|
||||
void center();
|
||||
|
|
|
@ -22,27 +22,52 @@ using namespace MWGui;
|
|||
|
||||
WindowManager::WindowManager(MWWorld::Environment& environment,
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame, OEngine::Render::OgreRenderer *mOgre, const std::string logpath)
|
||||
: environment(environment)
|
||||
: mGuiManager(NULL)
|
||||
, environment(environment)
|
||||
, hud(NULL)
|
||||
, map(NULL)
|
||||
, menu(NULL)
|
||||
, stats(NULL)
|
||||
, mMessageBoxManager(NULL)
|
||||
, console(NULL)
|
||||
, mJournal(NULL)
|
||||
, dialogueWindow(nullptr)
|
||||
, mCharGen(NULL)
|
||||
, playerClass()
|
||||
, playerName()
|
||||
, playerRaceId()
|
||||
, playerBirthSignId()
|
||||
, playerAttributes()
|
||||
, playerMajorSkills()
|
||||
, playerMinorSkills()
|
||||
, playerSkillValues()
|
||||
, playerHealth()
|
||||
, playerMagicka()
|
||||
, playerFatigue()
|
||||
, gui(NULL)
|
||||
, mode(GM_Game)
|
||||
, nextMode(GM_Game)
|
||||
, needModeChange(false)
|
||||
, garbageDialogs()
|
||||
, shown(GW_ALL)
|
||||
, allowed(newGame ? GW_None : GW_ALL)
|
||||
, showFPSLevel(fpsLevel)
|
||||
, mFPS(0.0f)
|
||||
, mTriangleCount(0)
|
||||
, mBatchCount(0)
|
||||
{
|
||||
showFPSLevel = fpsLevel;
|
||||
|
||||
// Set up the GUI system
|
||||
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre->getWindow(), mOgre->getScene(), false, logpath);
|
||||
gui = mGuiManager->getGui();
|
||||
|
||||
//Register own widgets with MyGUI
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<DialogueHistory>("Widget");
|
||||
|
||||
// Get size info from the Gui object
|
||||
assert(gui);
|
||||
int w = gui->getViewSize().width;
|
||||
int h = gui->getViewSize().height;
|
||||
int w = MyGUI::RenderManager::getInstance().getViewSize().width;
|
||||
int h = MyGUI::RenderManager::getInstance().getViewSize().height;
|
||||
|
||||
hud = new HUD(w,h, showFPSLevel);
|
||||
menu = new MainMenu(w,h);
|
||||
|
@ -51,6 +76,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
|
|||
console = new Console(w,h, environment, extensions);
|
||||
mJournal = new JournalWindow(*this);
|
||||
mMessageBoxManager = new MessageBoxManager(this);
|
||||
dialogueWindow = new DialogueWindow(*this,environment);
|
||||
|
||||
// The HUD is always on
|
||||
hud->setVisible(true);
|
||||
|
@ -149,9 +175,10 @@ void WindowManager::updateVisible()
|
|||
stats->setVisible(false);
|
||||
console->disable();
|
||||
mJournal->setVisible(false);
|
||||
dialogueWindow->setVisible(false);
|
||||
|
||||
// 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(mode == GM_Game) //Use a switch/case structure
|
||||
|
@ -195,11 +222,6 @@ void WindowManager::updateVisible()
|
|||
|
||||
if (mode == GM_Dialogue)
|
||||
{
|
||||
if (!dialogueWindow)
|
||||
{
|
||||
dialogueWindow = new DialogueWindow(*this);
|
||||
dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye);
|
||||
}
|
||||
dialogueWindow->open();
|
||||
return;
|
||||
}
|
||||
|
@ -349,6 +371,7 @@ void WindowManager::updateSkillArea()
|
|||
|
||||
void WindowManager::removeDialog(OEngine::GUI::Layout*dialog)
|
||||
{
|
||||
std::cout << "dialogue a la poubelle";
|
||||
assert(dialog);
|
||||
if (!dialog)
|
||||
return;
|
||||
|
@ -387,7 +410,8 @@ void WindowManager::onDialogueWindowBye()
|
|||
if (dialogueWindow)
|
||||
{
|
||||
//FIXME set some state and stuff?
|
||||
removeDialog(dialogueWindow);
|
||||
//removeDialog(dialogueWindow);
|
||||
dialogueWindow->setVisible(false);
|
||||
}
|
||||
setGuiMode(GM_Game);
|
||||
}
|
||||
|
@ -401,3 +425,47 @@ const ESMS::ESMStore& WindowManager::getStore() const
|
|||
{
|
||||
return environment.mWorld->getStore();
|
||||
}
|
||||
|
||||
void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
|
||||
{
|
||||
if (!(cell->cell->data.flags & ESM::Cell::Interior))
|
||||
{
|
||||
std::string name;
|
||||
if (cell->cell->name != "")
|
||||
name = cell->cell->name;
|
||||
else
|
||||
name = cell->cell->region;
|
||||
|
||||
map->setCellName( name );
|
||||
|
||||
map->setCellPrefix("Cell");
|
||||
hud->setCellPrefix("Cell");
|
||||
map->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY );
|
||||
hud->setActiveCell( cell->cell->data.gridX, cell->cell->data.gridY );
|
||||
}
|
||||
else
|
||||
{
|
||||
map->setCellName( cell->cell->name );
|
||||
map->setCellPrefix( cell->cell->name );
|
||||
hud->setCellPrefix( cell->cell->name );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WindowManager::setInteriorMapTexture(const int x, const int y)
|
||||
{
|
||||
map->setActiveCell(x,y, true);
|
||||
hud->setActiveCell(x,y, true);
|
||||
}
|
||||
|
||||
void WindowManager::setPlayerPos(const float x, const float y)
|
||||
{
|
||||
map->setPlayerPos(x,y);
|
||||
hud->setPlayerPos(x,y);
|
||||
}
|
||||
|
||||
void WindowManager::setPlayerDir(const float x, const float y)
|
||||
{
|
||||
map->setPlayerDir(x,y);
|
||||
hud->setPlayerDir(x,y);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <openengine/ogre/renderer.hpp>
|
||||
#include <openengine/gui/manager.hpp>
|
||||
#include "../mwmechanics/stat.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "mode.hpp"
|
||||
|
||||
namespace MyGUI
|
||||
|
@ -124,6 +125,8 @@ namespace MWGui
|
|||
updateVisible();
|
||||
}
|
||||
|
||||
MWGui::DialogueWindow* getDialogueWindow() {return dialogueWindow;}
|
||||
|
||||
MyGUI::Gui* getGui() const { return gui; }
|
||||
|
||||
void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount)
|
||||
|
@ -150,6 +153,12 @@ namespace MWGui
|
|||
void setBounty (int bounty); ///< set the current bounty value
|
||||
void updateSkillArea(); ///< update display of skills, factions, birth sign, reputation and bounty
|
||||
|
||||
void changeCell(MWWorld::Ptr::CellStore* cell); ///< change the active cell
|
||||
void setPlayerPos(const float x, const float y); ///< set player position in map space
|
||||
void setPlayerDir(const float x, const float y); ///< set player view direction in map space
|
||||
|
||||
void setInteriorMapTexture(const int x, const int y);
|
||||
///< set the index of the map texture that should be used (for interiors)
|
||||
|
||||
template<typename T>
|
||||
void removeDialog(T*& dialog); ///< Casts to OEngine::GUI::Layout and calls removeDialog, then resets pointer to nullptr.
|
||||
|
|
|
@ -8,6 +8,15 @@ using namespace Ogre;
|
|||
using namespace MWRender;
|
||||
using namespace NifOgre;
|
||||
|
||||
Actors::~Actors(){
|
||||
|
||||
std::map<MWWorld::Ptr, Animation*>::iterator it = mAllActors.begin();
|
||||
for (; it != mAllActors.end(); ++it) {
|
||||
delete it->second;
|
||||
it->second = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void Actors::setMwRoot(Ogre::SceneNode* root){
|
||||
mMwRoot = root;
|
||||
}
|
||||
|
@ -61,6 +70,7 @@ void Actors::insertCreature (const MWWorld::Ptr& ptr){
|
|||
insertBegin(ptr, true, true);
|
||||
CreatureAnimation* anim = new MWRender::CreatureAnimation(ptr, mEnvironment, mRend);
|
||||
//mAllActors.insert(std::pair<MWWorld::Ptr, Animation*>(ptr,anim));
|
||||
delete mAllActors[ptr];
|
||||
mAllActors[ptr] = anim;
|
||||
//mAllActors.push_back(&anim);*/
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace MWRender{
|
|||
|
||||
public:
|
||||
Actors(OEngine::Render::OgreRenderer& _rend, MWWorld::Environment& _env): mRend(_rend), mEnvironment(_env){}
|
||||
~Actors(){}
|
||||
~Actors();
|
||||
void setMwRoot(Ogre::SceneNode* root);
|
||||
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
|
||||
void insertCreature (const MWWorld::Ptr& ptr);
|
||||
|
|
|
@ -4,7 +4,30 @@
|
|||
namespace MWRender{
|
||||
std::map<std::string, int> Animation::mUniqueIDs;
|
||||
|
||||
Animation::~Animation(){
|
||||
Animation::Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend)
|
||||
: insert(NULL)
|
||||
, mRend(_rend)
|
||||
, mEnvironment(_env)
|
||||
, vecRotPos()
|
||||
, shapeparts()
|
||||
, time(0.0f)
|
||||
, startTime(0.0f)
|
||||
, stopTime(0.0f)
|
||||
, animate(0)
|
||||
, rindexI()
|
||||
, tindexI()
|
||||
, shapeNumber(0)
|
||||
, shapeIndexI()
|
||||
, shapes(NULL)
|
||||
, entityparts()
|
||||
, transformations(NULL)
|
||||
, textmappings(NULL)
|
||||
, base(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Animation::~Animation()
|
||||
{
|
||||
}
|
||||
|
||||
std::string Animation::getUniqueID(std::string mesh){
|
||||
|
@ -111,7 +134,6 @@ namespace MWRender{
|
|||
|
||||
Nif::NiTriShapeCopy& copy = *allshapesiter;
|
||||
std::vector<Ogre::Vector3>* allvertices = ©.vertices;
|
||||
std::vector<Ogre::Vector3>* allnormals = ©.normals;
|
||||
|
||||
|
||||
|
||||
|
@ -182,7 +204,6 @@ namespace MWRender{
|
|||
std::vector<Nif::NiSkinData::IndividualWeight> inds = iter->second;
|
||||
int verIndex = iter->first;
|
||||
Ogre::Vector3 currentVertex = (*allvertices)[verIndex];
|
||||
Ogre::Vector3 currentNormal = (*allnormals)[verIndex];
|
||||
Nif::NiSkinData::BoneInfoCopy* boneinfocopy = &(allshapesiter->boneinfo[inds[0].boneinfocopyindex]);
|
||||
Ogre::Bone *bonePtr = 0;
|
||||
|
||||
|
|
|
@ -60,13 +60,13 @@ class Animation{
|
|||
std::string getUniqueID(std::string mesh);
|
||||
|
||||
public:
|
||||
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend): mRend(_rend), mEnvironment(_env), animate(0){};
|
||||
Animation(MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||
virtual void runAnimation(float timepassed) = 0;
|
||||
void startScript(std::string groupname, int mode, int loops);
|
||||
void stopScript();
|
||||
|
||||
|
||||
~Animation();
|
||||
virtual ~Animation();
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace MWRender{
|
|||
class CreatureAnimation: public Animation{
|
||||
|
||||
public:
|
||||
~CreatureAnimation();
|
||||
virtual ~CreatureAnimation();
|
||||
CreatureAnimation(const MWWorld::Ptr& ptr, MWWorld::Environment& _env, OEngine::Render::OgreRenderer& _rend);
|
||||
virtual void runAnimation(float timepassed);
|
||||
|
||||
|
|
305
apps/openmw/mwrender/localmap.cpp
Normal file
305
apps/openmw/mwrender/localmap.cpp
Normal file
|
@ -0,0 +1,305 @@
|
|||
#include "localmap.hpp"
|
||||
#include "renderingmanager.hpp"
|
||||
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwgui/window_manager.hpp"
|
||||
|
||||
#include <OgreOverlayManager.h>
|
||||
#include <OgreMaterialManager.h>
|
||||
|
||||
using namespace MWRender;
|
||||
using namespace Ogre;
|
||||
|
||||
LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWWorld::Environment* env)
|
||||
{
|
||||
mRendering = rend;
|
||||
mEnvironment = env;
|
||||
|
||||
mCellCamera = mRendering->getScene()->createCamera("CellCamera");
|
||||
mCellCamera->setProjectionType(PT_ORTHOGRAPHIC);
|
||||
// look down -y
|
||||
const float sqrt0pt5 = 0.707106781;
|
||||
mCellCamera->setOrientation(Quaternion(sqrt0pt5, -sqrt0pt5, 0, 0));
|
||||
}
|
||||
|
||||
LocalMap::~LocalMap()
|
||||
{
|
||||
deleteBuffers();
|
||||
}
|
||||
|
||||
void LocalMap::deleteBuffers()
|
||||
{
|
||||
mBuffers.clear();
|
||||
}
|
||||
|
||||
void LocalMap::saveTexture(const std::string& texname, const std::string& filename)
|
||||
{
|
||||
TexturePtr tex = TextureManager::getSingleton().getByName(texname);
|
||||
if (tex.isNull()) return;
|
||||
HardwarePixelBufferSharedPtr readbuffer = tex->getBuffer();
|
||||
readbuffer->lock(HardwareBuffer::HBL_NORMAL );
|
||||
const PixelBox &readrefpb = readbuffer->getCurrentLock();
|
||||
uchar *readrefdata = static_cast<uchar*>(readrefpb.data);
|
||||
|
||||
Image img;
|
||||
img = img.loadDynamicImage (readrefdata, tex->getWidth(),
|
||||
tex->getHeight(), tex->getFormat());
|
||||
img.save("./" + filename);
|
||||
|
||||
readbuffer->unlock();
|
||||
}
|
||||
|
||||
std::string LocalMap::coordStr(const int x, const int y)
|
||||
{
|
||||
return StringConverter::toString(x) + "_" + StringConverter::toString(y);
|
||||
}
|
||||
|
||||
void LocalMap::saveFogOfWar(MWWorld::Ptr::CellStore* cell)
|
||||
{
|
||||
if (!mInterior)
|
||||
{
|
||||
/*saveTexture("Cell_"+coordStr(mCellX, mCellY)+"_fog",
|
||||
"Cell_"+coordStr(mCellX, mCellY)+"_fog.png");*/
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
||||
Vector2 max(mBounds.getMaximum().x, mBounds.getMaximum().z);
|
||||
/// \todo why is this workaround needed?
|
||||
min *= 1.3;
|
||||
max *= 1.3;
|
||||
Vector2 length = max-min;
|
||||
|
||||
// divide into segments
|
||||
const int segsX = std::ceil( length.x / sSize );
|
||||
const int segsY = std::ceil( length.y / sSize );
|
||||
|
||||
for (int x=0; x<segsX; ++x)
|
||||
{
|
||||
for (int y=0; y<segsY; ++y)
|
||||
{
|
||||
/*saveTexture(
|
||||
mInteriorName + "_" + coordStr(x,y) + "_fog",
|
||||
mInteriorName + "_" + coordStr(x,y) + "_fog.png");*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell)
|
||||
{
|
||||
mInterior = false;
|
||||
|
||||
std::string name = "Cell_"+coordStr(cell->cell->data.gridX, cell->cell->data.gridY);
|
||||
|
||||
int x = cell->cell->data.gridX;
|
||||
int y = cell->cell->data.gridY;
|
||||
|
||||
render((x+0.5)*sSize, (-y-0.5)*sSize, -10000, 10000, sSize, sSize, name);
|
||||
}
|
||||
|
||||
void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell,
|
||||
AxisAlignedBox bounds)
|
||||
{
|
||||
mInterior = true;
|
||||
mBounds = bounds;
|
||||
|
||||
Vector2 z(bounds.getMaximum().y, bounds.getMinimum().y);
|
||||
Vector2 min(bounds.getMinimum().x, bounds.getMinimum().z);
|
||||
Vector2 max(bounds.getMaximum().x, bounds.getMaximum().z);
|
||||
|
||||
/// \todo why is this workaround needed?
|
||||
min *= 1.3;
|
||||
max *= 1.3;
|
||||
|
||||
Vector2 length = max-min;
|
||||
Vector2 center(bounds.getCenter().x, bounds.getCenter().z);
|
||||
|
||||
// divide into segments
|
||||
const int segsX = std::ceil( length.x / sSize );
|
||||
const int segsY = std::ceil( length.y / sSize );
|
||||
|
||||
mInteriorName = cell->cell->name;
|
||||
|
||||
for (int x=0; x<segsX; ++x)
|
||||
{
|
||||
for (int y=0; y<segsY; ++y)
|
||||
{
|
||||
Vector2 start = min + Vector2(sSize*x,sSize*y);
|
||||
Vector2 newcenter = start + 4096;
|
||||
|
||||
render(newcenter.x, newcenter.y, z.y, z.x, sSize, sSize,
|
||||
cell->cell->name + "_" + coordStr(x,y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LocalMap::render(const float x, const float y,
|
||||
const float zlow, const float zhigh,
|
||||
const float xw, const float yw, const std::string& texture)
|
||||
{
|
||||
// disable fog
|
||||
// changing FOG_MODE is not a solution when using shaders, thus we have to push linear start/end
|
||||
const float fStart = mRendering->getScene()->getFogStart();
|
||||
const float fEnd = mRendering->getScene()->getFogEnd();
|
||||
const ColourValue& clr = mRendering->getScene()->getFogColour();
|
||||
mRendering->getScene()->setFog(FOG_LINEAR, clr, 0, 1000000, 10000000);
|
||||
|
||||
// make everything visible
|
||||
mRendering->getScene()->setAmbientLight(ColourValue(1,1,1));
|
||||
|
||||
mCellCamera->setPosition(Vector3(x, zhigh+100000, y));
|
||||
//mCellCamera->setFarClipDistance( (zhigh-zlow) * 1.1 );
|
||||
mCellCamera->setFarClipDistance(0); // infinite
|
||||
|
||||
mCellCamera->setOrthoWindow(xw, yw);
|
||||
|
||||
TexturePtr tex;
|
||||
// try loading from memory
|
||||
tex = TextureManager::getSingleton().getByName(texture);
|
||||
if (tex.isNull())
|
||||
{
|
||||
// try loading from disk
|
||||
//if (boost::filesystem::exists(texture+".jpg"))
|
||||
//{
|
||||
/// \todo
|
||||
//}
|
||||
//else
|
||||
{
|
||||
// render
|
||||
tex = TextureManager::getSingleton().createManual(
|
||||
texture,
|
||||
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
TEX_TYPE_2D,
|
||||
xw*sMapResolution/sSize, yw*sMapResolution/sSize,
|
||||
0,
|
||||
PF_R8G8B8,
|
||||
TU_RENDERTARGET);
|
||||
|
||||
RenderTarget* rtt = tex->getBuffer()->getRenderTarget();
|
||||
rtt->setAutoUpdated(false);
|
||||
Viewport* vp = rtt->addViewport(mCellCamera);
|
||||
vp->setOverlaysEnabled(false);
|
||||
vp->setShadowsEnabled(false);
|
||||
vp->setBackgroundColour(ColourValue(0, 0, 0));
|
||||
//vp->setVisibilityMask( ... );
|
||||
|
||||
rtt->update();
|
||||
|
||||
// create "fog of war" texture
|
||||
TexturePtr tex2 = TextureManager::getSingleton().createManual(
|
||||
texture + "_fog",
|
||||
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
TEX_TYPE_2D,
|
||||
xw*sFogOfWarResolution/sSize, yw*sFogOfWarResolution/sSize,
|
||||
0,
|
||||
PF_A8R8G8B8,
|
||||
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
|
||||
|
||||
// create a buffer to use for dynamic operations
|
||||
std::vector<uint32> buffer;
|
||||
buffer.resize(sFogOfWarResolution*sFogOfWarResolution);
|
||||
|
||||
// initialize to (0, 0, 0, 1)
|
||||
for (int p=0; p<sFogOfWarResolution*sFogOfWarResolution; ++p)
|
||||
{
|
||||
buffer[p] = (255 << 24);
|
||||
}
|
||||
|
||||
memcpy(tex2->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4);
|
||||
tex2->getBuffer()->unlock();
|
||||
|
||||
mBuffers[texture] = buffer;
|
||||
|
||||
// save to cache for next time
|
||||
//rtt->writeContentsToFile("./" + texture + ".jpg");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// re-enable fog
|
||||
mRendering->getScene()->setFog(FOG_LINEAR, clr, 0, fStart, fEnd);
|
||||
}
|
||||
|
||||
void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& direction)
|
||||
{
|
||||
if (sFogOfWarSkip != 0)
|
||||
{
|
||||
static int count=0;
|
||||
if (++count % sFogOfWarSkip != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// retrieve the x,y grid coordinates the player is in
|
||||
int x,y;
|
||||
Vector2 pos(position.x, position.z);
|
||||
if (!mInterior)
|
||||
{
|
||||
x = std::ceil(pos.x / sSize)-1;
|
||||
y = std::ceil(-pos.y / sSize)-1;
|
||||
mCellX = x;
|
||||
mCellY = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
||||
min *= 1.3;
|
||||
|
||||
x = std::ceil((pos.x - min.x)/sSize)-1;
|
||||
y = std::ceil((pos.y - min.y)/sSize)-1;
|
||||
|
||||
mEnvironment->mWindowManager->setInteriorMapTexture(x,y);
|
||||
}
|
||||
|
||||
// convert from world coordinates to texture UV coordinates
|
||||
float u,v;
|
||||
std::string texName;
|
||||
if (!mInterior)
|
||||
{
|
||||
u = std::abs((pos.x - (sSize*x))/sSize);
|
||||
v = 1-std::abs((pos.y + (sSize*y))/sSize);
|
||||
texName = "Cell_"+coordStr(x,y);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 min(mBounds.getMinimum().x, mBounds.getMinimum().z);
|
||||
min *= 1.3;
|
||||
|
||||
u = (pos.x - min.x - sSize*x)/sSize;
|
||||
v = (pos.y - min.y - sSize*y)/sSize;
|
||||
|
||||
texName = mInteriorName + "_" + coordStr(x,y);
|
||||
}
|
||||
mEnvironment->mWindowManager->setPlayerPos(u, v);
|
||||
mEnvironment->mWindowManager->setPlayerDir(direction.x, -direction.z);
|
||||
|
||||
// explore radius (squared)
|
||||
const float sqrExploreRadius = 0.01 * sFogOfWarResolution*sFogOfWarResolution;
|
||||
|
||||
// get the appropriate fog of war texture
|
||||
TexturePtr tex = TextureManager::getSingleton().getByName(texName+"_fog");
|
||||
if (!tex.isNull())
|
||||
{
|
||||
// get its buffer
|
||||
if (mBuffers.find(texName) == mBuffers.end()) return;
|
||||
int i=0;
|
||||
for (int texV = 0; texV<sFogOfWarResolution; ++texV)
|
||||
{
|
||||
for (int texU = 0; texU<sFogOfWarResolution; ++texU)
|
||||
{
|
||||
float sqrDist = Math::Sqr(texU - u*sFogOfWarResolution) + Math::Sqr(texV - v*sFogOfWarResolution);
|
||||
uint32 clr = mBuffers[texName][i];
|
||||
uint8 alpha = (clr >> 24);
|
||||
alpha = std::min( alpha, (uint8) (std::max(0.f, std::min(1.f, (sqrDist/sqrExploreRadius)))*255) );
|
||||
mBuffers[texName][i] = (uint32) (alpha << 24);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// copy to the texture
|
||||
memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &mBuffers[texName][0], sFogOfWarResolution*sFogOfWarResolution*4);
|
||||
tex->getBuffer()->unlock();
|
||||
}
|
||||
}
|
100
apps/openmw/mwrender/localmap.hpp
Normal file
100
apps/openmw/mwrender/localmap.hpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
#ifndef _GAME_RENDER_LOCALMAP_H
|
||||
#define _GAME_RENDER_LOCALMAP_H
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
///
|
||||
/// \brief Local map rendering
|
||||
///
|
||||
class LocalMap
|
||||
{
|
||||
public:
|
||||
LocalMap(OEngine::Render::OgreRenderer*, MWWorld::Environment* env);
|
||||
~LocalMap();
|
||||
|
||||
/**
|
||||
* Request the local map for an exterior cell.
|
||||
* @remarks It will either be loaded from a disk cache,
|
||||
* or rendered if it is not already cached.
|
||||
* @param exterior cell
|
||||
*/
|
||||
void requestMap (MWWorld::Ptr::CellStore* cell);
|
||||
|
||||
/**
|
||||
* Request the local map for an interior cell.
|
||||
* @remarks It will either be loaded from a disk cache,
|
||||
* or rendered if it is not already cached.
|
||||
* @param interior cell
|
||||
* @param bounding box of the cell
|
||||
*/
|
||||
void requestMap (MWWorld::Ptr::CellStore* cell,
|
||||
Ogre::AxisAlignedBox bounds);
|
||||
|
||||
/**
|
||||
* Set the position & direction of the player.
|
||||
* @remarks This is used to draw a "fog of war" effect
|
||||
* to hide areas on the map the player has not discovered yet.
|
||||
* @param position (OGRE coordinates)
|
||||
* @param view direction (OGRE coordinates)
|
||||
*/
|
||||
void updatePlayer (const Ogre::Vector3& position, const Ogre::Vector3& direction);
|
||||
|
||||
/**
|
||||
* Save the fog of war for the current cell to disk.
|
||||
* @remarks This should be called before loading a
|
||||
* new cell, as well as when the game is quit.
|
||||
* @param current cell
|
||||
*/
|
||||
void saveFogOfWar(MWWorld::Ptr::CellStore* cell);
|
||||
|
||||
private:
|
||||
OEngine::Render::OgreRenderer* mRendering;
|
||||
MWWorld::Environment* mEnvironment;
|
||||
|
||||
// 1024*1024 pixels for a cell
|
||||
static const int sMapResolution = 1024;
|
||||
|
||||
// the dynamic texture is a bottleneck, so don't set this too high
|
||||
static const int sFogOfWarResolution = 32;
|
||||
|
||||
// frames to skip before rendering fog of war
|
||||
static const int sFogOfWarSkip = 2;
|
||||
|
||||
// size of a map segment (for exteriors, 1 cell)
|
||||
static const int sSize = 8192;
|
||||
|
||||
Ogre::Camera* mCellCamera;
|
||||
|
||||
void render(const float x, const float y,
|
||||
const float zlow, const float zhigh,
|
||||
const float xw, const float yw,
|
||||
const std::string& texture);
|
||||
|
||||
void saveTexture(const std::string& texname, const std::string& filename);
|
||||
|
||||
std::string coordStr(const int x, const int y);
|
||||
|
||||
// a buffer for the "fog of war" texture of the current cell.
|
||||
// interior cells could be divided into multiple textures,
|
||||
// so we store in a map.
|
||||
std::map <std::string, std::vector<Ogre::uint32> > mBuffers;
|
||||
|
||||
void deleteBuffers();
|
||||
|
||||
bool mInterior;
|
||||
int mCellX, mCellY;
|
||||
Ogre::AxisAlignedBox mBounds;
|
||||
std::string mInteriorName;
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
|
@ -20,7 +20,7 @@ class NpcAnimation: public Animation{
|
|||
|
||||
public:
|
||||
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);
|
||||
void insertFreePart(const std::string &mesh, const std::string suffix, Ogre::SceneNode* insert);
|
||||
virtual void runAnimation(float timepassed);
|
||||
|
|
|
@ -109,6 +109,9 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
|
|||
// If it is set too low:
|
||||
// - there will be too many batches.
|
||||
sg->setRegionDimensions(Ogre::Vector3(2500,2500,2500));
|
||||
|
||||
mBounds[ptr.getCell()] = Ogre::AxisAlignedBox::BOX_NULL;
|
||||
mBounds[ptr.getCell()].merge(ent->getBoundingBox());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -116,6 +119,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh)
|
|||
}
|
||||
|
||||
sg->addEntity(ent,insert->_getDerivedPosition(),insert->_getDerivedOrientation(),insert->_getDerivedScale());
|
||||
mBounds[ptr.getCell()].merge(insert->_getDerivedPosition());
|
||||
|
||||
mRenderer.getScene()->destroyEntity(ent);
|
||||
}
|
||||
|
@ -202,6 +206,9 @@ void Objects::removeCell(MWWorld::Ptr::CellStore* store)
|
|||
mRenderer.getScene()->destroyStaticGeometry (sg);
|
||||
sg = 0;
|
||||
}
|
||||
|
||||
if(mBounds.find(store) != mBounds.end())
|
||||
mBounds.erase(store);
|
||||
}
|
||||
|
||||
void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell)
|
||||
|
@ -212,3 +219,8 @@ void Objects::buildStaticGeometry(ESMS::CellStore<MWWorld::RefData>& cell)
|
|||
sg->build();
|
||||
}
|
||||
}
|
||||
|
||||
Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::Ptr::CellStore* cell)
|
||||
{
|
||||
return mBounds[cell];
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ class Objects{
|
|||
OEngine::Render::OgreRenderer &mRenderer;
|
||||
std::map<MWWorld::Ptr::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
|
||||
std::map<MWWorld::Ptr::CellStore *, Ogre::StaticGeometry*> mStaticGeometry;
|
||||
std::map<MWWorld::Ptr::CellStore *, Ogre::AxisAlignedBox> mBounds;
|
||||
Ogre::SceneNode* mMwRoot;
|
||||
bool mIsStatic;
|
||||
static int uniqueID;
|
||||
|
@ -42,6 +43,9 @@ public:
|
|||
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
|
||||
|
||||
Ogre::AxisAlignedBox getDimensions(MWWorld::Ptr::CellStore*);
|
||||
///< get a bounding box that encloses all objects in the specified cell
|
||||
|
||||
bool deleteObject (const MWWorld::Ptr& ptr);
|
||||
///< \return found?
|
||||
|
||||
|
|
|
@ -51,12 +51,13 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
|||
cameraPitchNode->attachObject(mRendering.getCamera());
|
||||
|
||||
//mSkyManager = 0;
|
||||
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera());
|
||||
mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment);
|
||||
|
||||
mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode);
|
||||
mSun = 0;
|
||||
|
||||
mDebugging = new Debugging(mMwRoot, environment, engine);
|
||||
mLocalMap = new MWRender::LocalMap(&mRendering, &environment);
|
||||
}
|
||||
|
||||
RenderingManager::~RenderingManager ()
|
||||
|
@ -65,6 +66,7 @@ RenderingManager::~RenderingManager ()
|
|||
delete mPlayer;
|
||||
delete mSkyManager;
|
||||
delete mDebugging;
|
||||
delete mLocalMap;
|
||||
}
|
||||
|
||||
MWRender::SkyManager* RenderingManager::getSkyManager()
|
||||
|
@ -142,6 +144,8 @@ void RenderingManager::update (float duration){
|
|||
mSkyManager->update(duration);
|
||||
|
||||
mRendering.update(duration);
|
||||
|
||||
mLocalMap->updatePlayer( mRendering.getCamera()->getRealPosition(), mRendering.getCamera()->getRealDirection() );
|
||||
}
|
||||
|
||||
void RenderingManager::skyEnable ()
|
||||
|
@ -332,4 +336,17 @@ void RenderingManager::setGlare(bool glare)
|
|||
mSkyManager->setGlare(glare);
|
||||
}
|
||||
|
||||
void RenderingManager::requestMap(MWWorld::Ptr::CellStore* cell)
|
||||
{
|
||||
if (!(cell->cell->data.flags & ESM::Cell::Interior))
|
||||
mLocalMap->requestMap(cell);
|
||||
else
|
||||
mLocalMap->requestMap(cell, mObjects.getDimensions(cell));
|
||||
}
|
||||
|
||||
void RenderingManager::preCellChange(MWWorld::Ptr::CellStore* cell)
|
||||
{
|
||||
mLocalMap->saveFogOfWar(cell);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "objects.hpp"
|
||||
#include "actors.hpp"
|
||||
#include "player.hpp"
|
||||
#include "localmap.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
|
@ -75,6 +76,9 @@ class RenderingManager: private RenderingInterface {
|
|||
/// when rebatching is needed and update automatically at the end of each frame.
|
||||
void cellAdded (MWWorld::Ptr::CellStore *store);
|
||||
|
||||
void preCellChange (MWWorld::Ptr::CellStore* store);
|
||||
///< this event is fired immediately before changing cell
|
||||
|
||||
void addObject (const MWWorld::Ptr& ptr);
|
||||
void removeObject (const MWWorld::Ptr& ptr);
|
||||
|
||||
|
@ -103,6 +107,9 @@ class RenderingManager: private RenderingInterface {
|
|||
void skySetMoonColour (bool red);
|
||||
void configureAmbient(ESMS::CellStore<MWWorld::RefData> &mCell);
|
||||
|
||||
void requestMap (MWWorld::Ptr::CellStore* cell);
|
||||
///< request the local map for a cell
|
||||
|
||||
/// configure fog according to cell
|
||||
void configureFog(ESMS::CellStore<MWWorld::RefData> &mCell);
|
||||
|
||||
|
@ -147,7 +154,10 @@ class RenderingManager: private RenderingInterface {
|
|||
OEngine::Physic::PhysicEngine* mPhysicsEngine;
|
||||
|
||||
MWRender::Player *mPlayer;
|
||||
|
||||
MWRender::Debugging *mDebugging;
|
||||
|
||||
MWRender::LocalMap* mLocalMap;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -10,16 +10,12 @@
|
|||
|
||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
using namespace MWRender;
|
||||
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,
|
||||
const float initialSize,
|
||||
const Vector3& position,
|
||||
|
@ -50,7 +46,7 @@ void BillboardObject::setVisibility(const float visibility)
|
|||
void BillboardObject::setPosition(const Vector3& pPosition)
|
||||
{
|
||||
Vector3 normalised = pPosition.normalisedCopy();
|
||||
Vector3 finalPosition = normalised * CELESTIAL_BODY_DISTANCE;
|
||||
Vector3 finalPosition = normalised * 1000.f;
|
||||
|
||||
mBBSet->setCommonDirection( -normalised );
|
||||
|
||||
|
@ -59,7 +55,8 @@ void BillboardObject::setPosition(const Vector3& pPosition)
|
|||
|
||||
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)
|
||||
|
@ -84,7 +81,7 @@ void BillboardObject::init(const String& textureName,
|
|||
{
|
||||
SceneManager* sceneMgr = rootNode->getCreator();
|
||||
|
||||
Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE;
|
||||
Vector3 finalPosition = position.normalisedCopy() * 1000.f;
|
||||
|
||||
static unsigned int bodyCount=0;
|
||||
|
||||
|
@ -161,14 +158,20 @@ Moon::Moon( const String& textureName,
|
|||
" in float2 uv : TEXCOORD0, \n"
|
||||
" out float4 oColor : COLOR, \n"
|
||||
" uniform sampler2D texture : TEXUNIT0, \n"
|
||||
" uniform float4 skyColour, \n"
|
||||
" uniform float4 diffuse, \n"
|
||||
" uniform float4 emissive \n"
|
||||
") \n"
|
||||
"{ \n"
|
||||
" float4 tex = tex2D(texture, uv); \n"
|
||||
" oColor = float4(emissive.xyz,1) * tex2D(texture, uv) * float4(1,1,1,diffuse.a); \n"
|
||||
" float bump = pow((1-diffuse.a),4); \n"
|
||||
" oColor.rgb += float3(bump, bump, bump)*0.5; \n"
|
||||
" oColor = float4(emissive.xyz,1) * tex; \n"
|
||||
// use a circle for the alpha (compute UV distance to center)
|
||||
// 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->load();
|
||||
|
@ -186,10 +189,14 @@ void Moon::setType(const Moon::Type& 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)
|
||||
{
|
||||
// Colour texture
|
||||
Ogre::String textureName = "textures\\tx_";
|
||||
|
||||
if (mType == Moon::Type_Secunda) textureName += "secunda_";
|
||||
|
@ -247,7 +254,7 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
|
|||
// Get a pointer to the vertex colour
|
||||
ves_diffuse->baseVertexPointerToElement( pData, ¤tVertex );
|
||||
|
||||
unsigned char alpha;
|
||||
unsigned char alpha=0;
|
||||
if (meshType == 0) alpha = i%2 ? 0 : 255; // this is a cylinder, so every second vertex belongs to the bottom-most row
|
||||
else if (meshType == 1)
|
||||
{
|
||||
|
@ -285,9 +292,40 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType)
|
|||
ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock();
|
||||
}
|
||||
|
||||
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
|
||||
mGlareFade(0), mGlareEnabled(false)
|
||||
SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env)
|
||||
: mEnvironment(env)
|
||||
, mHour(0.0f)
|
||||
, mDay(0)
|
||||
, mMonth(0)
|
||||
, mSun(NULL)
|
||||
, mSunGlare(NULL)
|
||||
, mMasser(NULL)
|
||||
, mSecunda(NULL)
|
||||
, mViewport(NULL)
|
||||
, mRootNode(NULL)
|
||||
, mSceneMgr(NULL)
|
||||
, mAtmosphereDay(NULL)
|
||||
, mAtmosphereNight(NULL)
|
||||
, mCloudMaterial()
|
||||
, mAtmosphereMaterial()
|
||||
, mCloudFragmentShader()
|
||||
, mClouds()
|
||||
, mNextClouds()
|
||||
, mCloudBlendFactor(0.0f)
|
||||
, mCloudOpacity(0.0f)
|
||||
, mCloudSpeed(0.0f)
|
||||
, mStarsOpacity(0.0f)
|
||||
, mThunderOverlay(NULL)
|
||||
, mThunderTextureUnit(NULL)
|
||||
, mRemainingTransitionTime(0.0f)
|
||||
, mGlareFade(0.0f)
|
||||
, mEnabled(true)
|
||||
, mGlareEnabled(true)
|
||||
, mSunEnabled(true)
|
||||
, mMasserEnabled(true)
|
||||
, mSecundaEnabled(true)
|
||||
{
|
||||
|
||||
mViewport = pCamera->getViewport();
|
||||
mSceneMgr = pMwRoot->getCreator();
|
||||
mRootNode = pCamera->getParentSceneNode()->createChildSceneNode();
|
||||
|
@ -301,7 +339,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
|
|||
Pass* pass = material->getTechnique(0)->getPass(0);
|
||||
pass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
|
||||
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);
|
||||
OverlayManager& ovm = OverlayManager::getSingleton();
|
||||
mThunderOverlay = ovm.create( "ThunderOverlay" );
|
||||
|
@ -438,6 +476,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
|
|||
vshader->getDefaultParameters()->setNamedAutoConstant("worldViewProj", GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
|
||||
vshader->getDefaultParameters()->setNamedAutoConstant("emissive", GpuProgramParameters::ACT_SURFACE_EMISSIVE_COLOUR);
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setVertexProgram(vshader->getName());
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setFragmentProgram("");
|
||||
|
||||
// Clouds
|
||||
NifOgre::NIFLoader::load("meshes\\sky_clouds_01.nif");
|
||||
|
@ -493,7 +532,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) :
|
|||
" uniform float4 emissive \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"
|
||||
" oColor = color * float4(emissive.xyz,1) * tex * float4(1,1,1,opacity); \n"
|
||||
"}";
|
||||
|
@ -547,7 +586,7 @@ void SkyManager::update(float duration)
|
|||
if (!mEnabled) return;
|
||||
|
||||
// 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
|
||||
mMasser->setPhase( static_cast<Moon::Phase>( (int) ((mDay % 32)/4.f)) );
|
||||
|
@ -582,6 +621,9 @@ void SkyManager::update(float duration)
|
|||
mSun->setVisible(mSunEnabled);
|
||||
mMasser->setVisible(mMasserEnabled);
|
||||
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()
|
||||
|
@ -646,6 +688,8 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||
if (mSkyColour != weather.mSkyColor)
|
||||
{
|
||||
mAtmosphereMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(weather.mSkyColor);
|
||||
mMasser->setSkyColour(weather.mSkyColor);
|
||||
mSecunda->setSkyColour(weather.mSkyColor);
|
||||
mSkyColour = weather.mSkyColor;
|
||||
}
|
||||
|
||||
|
@ -676,6 +720,7 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather)
|
|||
strength = 1.f;
|
||||
|
||||
mSunGlare->setVisibility(weather.mGlareView * strength);
|
||||
mSun->setVisibility(strength);
|
||||
|
||||
mAtmosphereNight->setVisible(weather.mNight && mEnabled);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace MWRender
|
|||
);
|
||||
BillboardObject();
|
||||
|
||||
virtual ~BillboardObject() {}
|
||||
|
||||
void setColour(const Ogre::ColourValue& pColour);
|
||||
void setPosition(const Ogre::Vector3& pPosition);
|
||||
void setVisible(const bool visible);
|
||||
|
@ -70,6 +72,8 @@ namespace MWRender
|
|||
Ogre::SceneNode* rootNode
|
||||
);
|
||||
|
||||
virtual ~Moon() {}
|
||||
|
||||
enum Phase
|
||||
{
|
||||
Phase_New = 0,
|
||||
|
@ -90,6 +94,7 @@ namespace MWRender
|
|||
|
||||
void setPhase(const Phase& phase);
|
||||
void setType(const Type& type);
|
||||
void setSkyColour(const Ogre::ColourValue& colour);
|
||||
|
||||
Phase getPhase() const;
|
||||
unsigned int getPhaseInt() const;
|
||||
|
@ -102,7 +107,7 @@ namespace MWRender
|
|||
class SkyManager
|
||||
{
|
||||
public:
|
||||
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera);
|
||||
SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env);
|
||||
~SkyManager();
|
||||
|
||||
void update(float duration);
|
||||
|
@ -159,6 +164,7 @@ namespace MWRender
|
|||
Ogre::Vector3 getRealSunPos();
|
||||
|
||||
private:
|
||||
MWWorld::Environment* mEnvironment;
|
||||
float mHour;
|
||||
int mDay;
|
||||
int mMonth;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <components/interpreter/opcodes.hpp>
|
||||
|
||||
#include "../mwdialogue/journal.hpp"
|
||||
#include "../mwdialogue/dialoguemanager.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 opcodeSetJournalIndex = 0x2000134;
|
||||
const int opcodeGetJournalIndex = 0x2000135;
|
||||
const int opcodeAddTopic = 0x200013a;
|
||||
const int opcodeChoice = 0x2000a;
|
||||
|
||||
void registerExtensions (Compiler::Extensions& extensions)
|
||||
{
|
||||
extensions.registerInstruction ("journal", "cl", opcodeJournal);
|
||||
extensions.registerInstruction ("setjournalindex", "cl", opcodeSetJournalIndex);
|
||||
extensions.registerFunction ("getjournalindex", 'l', "c", opcodeGetJournalIndex);
|
||||
extensions.registerInstruction ("addtopic", "S" , opcodeAddTopic);
|
||||
extensions.registerInstruction ("choice", "/SlSlSlSlSlSlSlSlSlSlSlSlSlSlSlSl", opcodeChoice);
|
||||
}
|
||||
|
||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||
|
@ -88,6 +136,8 @@ namespace MWScript
|
|||
interpreter.installSegment5 (opcodeJournal, new OpJournal);
|
||||
interpreter.installSegment5 (opcodeSetJournalIndex, new OpSetJournalIndex);
|
||||
interpreter.installSegment5 (opcodeGetJournalIndex, new OpGetJournalIndex);
|
||||
interpreter.installSegment5 (opcodeAddTopic, new OpAddTopic);
|
||||
interpreter.installSegment3 (opcodeChoice,new OpChoice);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ op 0x20006: PlayAnim
|
|||
op 0x20007: PlayAnim, explicit reference
|
||||
op 0x20008: LoopAnim
|
||||
op 0x20009: LoopAnim, explicit reference
|
||||
opcodes 0x2000a-0x3ffff unused
|
||||
op 0x2000a: Choice
|
||||
opcodes 0x2000b-0x3ffff unused
|
||||
|
||||
Segment 4:
|
||||
(not implemented yet)
|
||||
|
@ -115,7 +116,8 @@ op 0x2000136: GetPCCell
|
|||
op 0x2000137: GetButtonPressed
|
||||
op 0x2000138: SkipAnim
|
||||
op 0x2000139: SkipAnim, expplicit reference
|
||||
op 0x200013b: ToggleWireframe
|
||||
op 0x200013a: AddTopic
|
||||
op 0x200013b: twf
|
||||
op 0x200013c: FadeIn
|
||||
op 0x200013d: FadeOut
|
||||
op 0x200013e: FadeTo
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MWScript
|
|||
{
|
||||
std::vector<Interpreter::Type_Code> 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
|
||||
|
||||
|
@ -77,8 +77,7 @@ namespace MWScript
|
|||
void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
|
||||
{
|
||||
// compile script
|
||||
std::map<std::string, std::vector<Interpreter::Type_Code> >::iterator iter =
|
||||
mScripts.find (name);
|
||||
ScriptCollection::iterator iter = mScripts.find (name);
|
||||
|
||||
if (iter==mScripts.end())
|
||||
{
|
||||
|
@ -86,7 +85,7 @@ namespace MWScript
|
|||
{
|
||||
// failed -> ignore script from now on.
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -95,7 +94,7 @@ namespace MWScript
|
|||
}
|
||||
|
||||
// execute script
|
||||
if (!iter->second.empty())
|
||||
if (!iter->second.first.empty())
|
||||
try
|
||||
{
|
||||
if (!mOpcodesInstalled)
|
||||
|
@ -104,7 +103,7 @@ namespace MWScript
|
|||
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)
|
||||
{
|
||||
|
@ -113,7 +112,7 @@ namespace MWScript
|
|||
if (mVerbose)
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,11 @@ namespace MWScript
|
|||
Interpreter::Interpreter mInterpreter;
|
||||
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:
|
||||
|
||||
|
@ -56,6 +60,9 @@ namespace MWScript
|
|||
std::pair<int, int> compileAll();
|
||||
///< Compile all scripts
|
||||
/// \return count, success
|
||||
|
||||
Compiler::Locals& getLocals (const std::string& name);
|
||||
///< Return locals for script \a name.
|
||||
};
|
||||
};
|
||||
|
||||
|
|
407
apps/openmw/mwsound/ffmpeg_decoder.cpp
Normal file
407
apps/openmw/mwsound/ffmpeg_decoder.cpp
Normal file
|
@ -0,0 +1,407 @@
|
|||
#ifdef OPENMW_USE_FFMPEG
|
||||
|
||||
#include "ffmpeg_decoder.hpp"
|
||||
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
|
||||
static void fail(const std::string &msg)
|
||||
{ throw std::runtime_error("FFmpeg exception: "+msg); }
|
||||
|
||||
|
||||
struct PacketList {
|
||||
AVPacket pkt;
|
||||
PacketList *next;
|
||||
};
|
||||
|
||||
struct FFmpeg_Decoder::MyStream {
|
||||
AVCodecContext *mCodecCtx;
|
||||
int mStreamIdx;
|
||||
|
||||
PacketList *mPackets;
|
||||
|
||||
char *mDecodedData;
|
||||
size_t mDecodedDataSize;
|
||||
|
||||
FFmpeg_Decoder *mParent;
|
||||
|
||||
void clearPackets();
|
||||
void *getAVAudioData(size_t *length);
|
||||
size_t readAVAudioData(void *data, size_t length);
|
||||
};
|
||||
|
||||
|
||||
int FFmpeg_Decoder::readPacket(void *user_data, uint8_t *buf, int buf_size)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<FFmpeg_Decoder*>(user_data)->mDataStream;
|
||||
return stream->read(buf, buf_size);
|
||||
}
|
||||
|
||||
int FFmpeg_Decoder::writePacket(void *user_data, uint8_t *buf, int buf_size)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<FFmpeg_Decoder*>(user_data)->mDataStream;
|
||||
return stream->write(buf, buf_size);
|
||||
}
|
||||
|
||||
int64_t FFmpeg_Decoder::seek(void *user_data, int64_t offset, int whence)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<FFmpeg_Decoder*>(user_data)->mDataStream;
|
||||
|
||||
whence &= ~AVSEEK_FORCE;
|
||||
if(whence == AVSEEK_SIZE)
|
||||
return stream->size();
|
||||
if(whence == SEEK_SET)
|
||||
stream->seek(offset);
|
||||
else if(whence == SEEK_CUR)
|
||||
stream->seek(stream->tell()+offset);
|
||||
else if(whence == SEEK_END)
|
||||
stream->seek(stream->size()+offset);
|
||||
else
|
||||
return -1;
|
||||
|
||||
return stream->tell();
|
||||
}
|
||||
|
||||
|
||||
/* Used by getAV*Data to search for more compressed data, and buffer it in the
|
||||
* correct stream. It won't buffer data for streams that the app doesn't have a
|
||||
* handle for. */
|
||||
bool FFmpeg_Decoder::getNextPacket(int streamidx)
|
||||
{
|
||||
PacketList *packet;
|
||||
|
||||
packet = (PacketList*)av_malloc(sizeof(*packet));
|
||||
packet->next = NULL;
|
||||
|
||||
next_packet:
|
||||
while(av_read_frame(mFormatCtx, &packet->pkt) >= 0)
|
||||
{
|
||||
std::vector<MyStream*>::iterator iter = mStreams.begin();
|
||||
|
||||
/* Check each stream the user has a handle for, looking for the one
|
||||
* this packet belongs to */
|
||||
while(iter != mStreams.end())
|
||||
{
|
||||
if((*iter)->mStreamIdx == packet->pkt.stream_index)
|
||||
{
|
||||
PacketList **last;
|
||||
|
||||
last = &(*iter)->mPackets;
|
||||
while(*last != NULL)
|
||||
last = &(*last)->next;
|
||||
|
||||
*last = packet;
|
||||
if((*iter)->mStreamIdx == streamidx)
|
||||
return true;
|
||||
|
||||
packet = (PacketList*)av_malloc(sizeof(*packet));
|
||||
packet->next = NULL;
|
||||
goto next_packet;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
/* Free the packet and look for another */
|
||||
av_free_packet(&packet->pkt);
|
||||
}
|
||||
av_free(packet);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void FFmpeg_Decoder::MyStream::clearPackets()
|
||||
{
|
||||
while(mPackets)
|
||||
{
|
||||
PacketList *self = mPackets;
|
||||
mPackets = self->next;
|
||||
|
||||
av_free_packet(&self->pkt);
|
||||
av_free(self);
|
||||
}
|
||||
}
|
||||
|
||||
void *FFmpeg_Decoder::MyStream::getAVAudioData(size_t *length)
|
||||
{
|
||||
int size;
|
||||
int len;
|
||||
|
||||
if(length) *length = 0;
|
||||
if(mCodecCtx->codec_type != AVMEDIA_TYPE_AUDIO)
|
||||
return NULL;
|
||||
|
||||
mDecodedDataSize = 0;
|
||||
|
||||
next_packet:
|
||||
if(!mPackets && !mParent->getNextPacket(mStreamIdx))
|
||||
return NULL;
|
||||
|
||||
/* Decode some data, and check for errors */
|
||||
size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
||||
while((len=avcodec_decode_audio3(mCodecCtx, (int16_t*)mDecodedData, &size,
|
||||
&mPackets->pkt)) == 0)
|
||||
{
|
||||
PacketList *self;
|
||||
|
||||
if(size > 0)
|
||||
break;
|
||||
|
||||
/* Packet went unread and no data was given? Drop it and try the next,
|
||||
* I guess... */
|
||||
self = mPackets;
|
||||
mPackets = self->next;
|
||||
|
||||
av_free_packet(&self->pkt);
|
||||
av_free(self);
|
||||
|
||||
if(!mPackets)
|
||||
goto next_packet;
|
||||
|
||||
size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
|
||||
}
|
||||
|
||||
if(len < 0)
|
||||
return NULL;
|
||||
|
||||
if(len < mPackets->pkt.size)
|
||||
{
|
||||
/* Move the unread data to the front and clear the end bits */
|
||||
int remaining = mPackets->pkt.size - len;
|
||||
memmove(mPackets->pkt.data, &mPackets->pkt.data[len], remaining);
|
||||
memset(&mPackets->pkt.data[remaining], 0, mPackets->pkt.size - remaining);
|
||||
mPackets->pkt.size -= len;
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketList *self;
|
||||
|
||||
self = mPackets;
|
||||
mPackets = self->next;
|
||||
|
||||
av_free_packet(&self->pkt);
|
||||
av_free(self);
|
||||
}
|
||||
|
||||
if(size == 0)
|
||||
goto next_packet;
|
||||
|
||||
/* Set the output buffer size */
|
||||
mDecodedDataSize = size;
|
||||
if(length) *length = mDecodedDataSize;
|
||||
|
||||
return mDecodedData;
|
||||
}
|
||||
|
||||
size_t FFmpeg_Decoder::MyStream::readAVAudioData(void *data, size_t length)
|
||||
{
|
||||
size_t dec = 0;
|
||||
|
||||
while(dec < length)
|
||||
{
|
||||
/* If there's no decoded data, find some */
|
||||
if(mDecodedDataSize == 0)
|
||||
{
|
||||
if(getAVAudioData(NULL) == NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if(mDecodedDataSize > 0)
|
||||
{
|
||||
/* Get the amount of bytes remaining to be written, and clamp to
|
||||
* the amount of decoded data we have */
|
||||
size_t rem = length-dec;
|
||||
if(rem > mDecodedDataSize)
|
||||
rem = mDecodedDataSize;
|
||||
|
||||
/* Copy the data to the app's buffer and increment */
|
||||
if(data != NULL)
|
||||
{
|
||||
memcpy(data, mDecodedData, rem);
|
||||
data = (char*)data + rem;
|
||||
}
|
||||
dec += rem;
|
||||
|
||||
/* If there's any decoded data left, move it to the front of the
|
||||
* buffer for next time */
|
||||
if(rem < mDecodedDataSize)
|
||||
memmove(mDecodedData, &mDecodedData[rem], mDecodedDataSize - rem);
|
||||
mDecodedDataSize -= rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return the number of bytes we were able to get */
|
||||
return dec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FFmpeg_Decoder::open(const std::string &fname)
|
||||
{
|
||||
close();
|
||||
mDataStream = mResourceMgr.openResource(fname);
|
||||
|
||||
if((mFormatCtx=avformat_alloc_context()) == NULL)
|
||||
fail("Failed to allocate context");
|
||||
|
||||
mFormatCtx->pb = avio_alloc_context(NULL, 0, 0, this, readPacket, writePacket, seek);
|
||||
if(!mFormatCtx->pb || avformat_open_input(&mFormatCtx, fname.c_str(), NULL, NULL) != 0)
|
||||
{
|
||||
avformat_free_context(mFormatCtx);
|
||||
mFormatCtx = NULL;
|
||||
fail("Failed to allocate input stream");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(avformat_find_stream_info(mFormatCtx, NULL) < 0)
|
||||
fail("Failed to find stream info in "+fname);
|
||||
|
||||
for(size_t j = 0;j < mFormatCtx->nb_streams;j++)
|
||||
{
|
||||
if(mFormatCtx->streams[j]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
||||
{
|
||||
std::auto_ptr<MyStream> stream(new MyStream);
|
||||
stream->mCodecCtx = mFormatCtx->streams[j]->codec;
|
||||
stream->mStreamIdx = j;
|
||||
stream->mPackets = NULL;
|
||||
|
||||
AVCodec *codec = avcodec_find_decoder(stream->mCodecCtx->codec_id);
|
||||
if(!codec)
|
||||
{
|
||||
std::stringstream ss("No codec found for id ");
|
||||
ss << stream->mCodecCtx->codec_id;
|
||||
fail(ss.str());
|
||||
}
|
||||
if(avcodec_open(stream->mCodecCtx, codec) < 0)
|
||||
fail("Failed to open audio codec " + std::string(codec->long_name));
|
||||
|
||||
stream->mDecodedData = (char*)av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
|
||||
stream->mDecodedDataSize = 0;
|
||||
|
||||
stream->mParent = this;
|
||||
mStreams.push_back(stream.release());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(mStreams.empty())
|
||||
fail("No audio streams in "+fname);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
av_close_input_file(mFormatCtx);
|
||||
mFormatCtx = NULL;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void FFmpeg_Decoder::close()
|
||||
{
|
||||
while(!mStreams.empty())
|
||||
{
|
||||
MyStream *stream = mStreams.front();
|
||||
|
||||
stream->clearPackets();
|
||||
avcodec_close(stream->mCodecCtx);
|
||||
av_free(stream->mDecodedData);
|
||||
delete stream;
|
||||
|
||||
mStreams.erase(mStreams.begin());
|
||||
}
|
||||
if(mFormatCtx)
|
||||
av_close_input_file(mFormatCtx);
|
||||
mFormatCtx = NULL;
|
||||
|
||||
mDataStream.setNull();
|
||||
}
|
||||
|
||||
void FFmpeg_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type)
|
||||
{
|
||||
if(mStreams.empty())
|
||||
fail("No audio stream info");
|
||||
|
||||
MyStream *stream = mStreams[0];
|
||||
if(stream->mCodecCtx->sample_fmt == AV_SAMPLE_FMT_U8)
|
||||
*type = SampleType_UInt8;
|
||||
else if(stream->mCodecCtx->sample_fmt == AV_SAMPLE_FMT_S16)
|
||||
*type = SampleType_Int16;
|
||||
else
|
||||
fail(std::string("Unsupported sample format: ")+
|
||||
av_get_sample_fmt_name(stream->mCodecCtx->sample_fmt));
|
||||
|
||||
if(stream->mCodecCtx->channel_layout == AV_CH_LAYOUT_MONO)
|
||||
*chans = ChannelConfig_Mono;
|
||||
else if(stream->mCodecCtx->channel_layout == AV_CH_LAYOUT_STEREO)
|
||||
*chans = ChannelConfig_Stereo;
|
||||
else if(stream->mCodecCtx->channel_layout == 0)
|
||||
{
|
||||
/* Unknown channel layout. Try to guess. */
|
||||
if(stream->mCodecCtx->channels == 1)
|
||||
*chans = ChannelConfig_Mono;
|
||||
else if(stream->mCodecCtx->channels == 2)
|
||||
*chans = ChannelConfig_Stereo;
|
||||
else
|
||||
{
|
||||
std::stringstream sstr("Unsupported raw channel count: ");
|
||||
sstr << stream->mCodecCtx->channels;
|
||||
fail(sstr.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char str[1024];
|
||||
av_get_channel_layout_string(str, sizeof(str), stream->mCodecCtx->channels,
|
||||
stream->mCodecCtx->channel_layout);
|
||||
fail(std::string("Unsupported channel layout: ")+str);
|
||||
}
|
||||
|
||||
*samplerate = stream->mCodecCtx->sample_rate;
|
||||
}
|
||||
|
||||
size_t FFmpeg_Decoder::read(char *buffer, size_t bytes)
|
||||
{
|
||||
if(mStreams.empty())
|
||||
fail("No audio streams");
|
||||
|
||||
return mStreams.front()->readAVAudioData(buffer, bytes);
|
||||
}
|
||||
|
||||
void FFmpeg_Decoder::readAll(std::vector<char> &output)
|
||||
{
|
||||
if(mStreams.empty())
|
||||
fail("No audio streams");
|
||||
MyStream *stream = mStreams.front();
|
||||
char *inbuf;
|
||||
size_t got;
|
||||
|
||||
while((inbuf=(char*)stream->getAVAudioData(&got)) != NULL && got > 0)
|
||||
output.insert(output.end(), inbuf, inbuf+got);
|
||||
}
|
||||
|
||||
void FFmpeg_Decoder::rewind()
|
||||
{
|
||||
av_seek_frame(mFormatCtx, -1, 0, 0);
|
||||
std::for_each(mStreams.begin(), mStreams.end(), std::mem_fun(&MyStream::clearPackets));
|
||||
}
|
||||
|
||||
FFmpeg_Decoder::FFmpeg_Decoder() : mFormatCtx(NULL)
|
||||
{
|
||||
static bool done_init = false;
|
||||
|
||||
/* We need to make sure ffmpeg is initialized. Optionally silence warning
|
||||
* output from the lib */
|
||||
if(!done_init)
|
||||
{
|
||||
av_register_all();
|
||||
av_log_set_level(AV_LOG_ERROR);
|
||||
done_init = true;
|
||||
}
|
||||
}
|
||||
|
||||
FFmpeg_Decoder::~FFmpeg_Decoder()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
59
apps/openmw/mwsound/ffmpeg_decoder.hpp
Normal file
59
apps/openmw/mwsound/ffmpeg_decoder.hpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
#ifndef GAME_SOUND_FFMPEG_DECODER_H
|
||||
#define GAME_SOUND_FFMPEG_DECODER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
// FIXME: This can't be right? The headers refuse to build without UINT64_C,
|
||||
// which only gets defined in stdint.h in either C99 mode or with this macro
|
||||
// defined...
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
#include <stdint.h>
|
||||
extern "C"
|
||||
{
|
||||
#include <avcodec.h>
|
||||
#include <avformat.h>
|
||||
}
|
||||
|
||||
#include "sound_decoder.hpp"
|
||||
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class FFmpeg_Decoder : public Sound_Decoder
|
||||
{
|
||||
AVFormatContext *mFormatCtx;
|
||||
|
||||
struct MyStream;
|
||||
std::vector<MyStream*> mStreams;
|
||||
|
||||
bool getNextPacket(int streamidx);
|
||||
|
||||
Ogre::DataStreamPtr mDataStream;
|
||||
static int readPacket(void *user_data, uint8_t *buf, int buf_size);
|
||||
static int writePacket(void *user_data, uint8_t *buf, int buf_size);
|
||||
static int64_t seek(void *user_data, int64_t offset, int whence);
|
||||
|
||||
virtual void open(const std::string &fname);
|
||||
virtual void close();
|
||||
|
||||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes);
|
||||
virtual void readAll(std::vector<char> &output);
|
||||
virtual void rewind();
|
||||
|
||||
FFmpeg_Decoder& operator=(const FFmpeg_Decoder &rhs);
|
||||
FFmpeg_Decoder(const FFmpeg_Decoder &rhs);
|
||||
|
||||
FFmpeg_Decoder();
|
||||
public:
|
||||
virtual ~FFmpeg_Decoder();
|
||||
|
||||
friend class SoundManager;
|
||||
};
|
||||
#ifndef DEFAULT_DECODER
|
||||
#define DEFAULT_DECODER (::MWSound::FFmpeg_Decoder)
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
237
apps/openmw/mwsound/mpgsnd_decoder.cpp
Normal file
237
apps/openmw/mwsound/mpgsnd_decoder.cpp
Normal file
|
@ -0,0 +1,237 @@
|
|||
#ifdef OPENMW_USE_MPG123
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include "mpgsnd_decoder.hpp"
|
||||
|
||||
|
||||
static void fail(const std::string &msg)
|
||||
{ throw std::runtime_error("MpgSnd exception: "+msg); }
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
|
||||
//
|
||||
// libSndFile io callbacks
|
||||
//
|
||||
sf_count_t MpgSnd_Decoder::ogresf_get_filelen(void *user_data)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<MpgSnd_Decoder*>(user_data)->mDataStream;
|
||||
return stream->size();
|
||||
}
|
||||
|
||||
sf_count_t MpgSnd_Decoder::ogresf_seek(sf_count_t offset, int whence, void *user_data)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<MpgSnd_Decoder*>(user_data)->mDataStream;
|
||||
|
||||
if(whence == SEEK_CUR)
|
||||
stream->seek(stream->tell()+offset);
|
||||
else if(whence == SEEK_SET)
|
||||
stream->seek(offset);
|
||||
else if(whence == SEEK_END)
|
||||
stream->seek(stream->size()+offset);
|
||||
else
|
||||
return -1;
|
||||
|
||||
return stream->tell();
|
||||
}
|
||||
|
||||
sf_count_t MpgSnd_Decoder::ogresf_read(void *ptr, sf_count_t count, void *user_data)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<MpgSnd_Decoder*>(user_data)->mDataStream;
|
||||
return stream->read(ptr, count);
|
||||
}
|
||||
|
||||
sf_count_t MpgSnd_Decoder::ogresf_write(const void*, sf_count_t, void*)
|
||||
{ return -1; }
|
||||
|
||||
sf_count_t MpgSnd_Decoder::ogresf_tell(void *user_data)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<MpgSnd_Decoder*>(user_data)->mDataStream;
|
||||
return stream->tell();
|
||||
}
|
||||
|
||||
//
|
||||
// libmpg13 io callbacks
|
||||
//
|
||||
ssize_t MpgSnd_Decoder::ogrempg_read(void *user_data, void *ptr, size_t count)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<MpgSnd_Decoder*>(user_data)->mDataStream;
|
||||
return stream->read(ptr, count);
|
||||
}
|
||||
|
||||
off_t MpgSnd_Decoder::ogrempg_lseek(void *user_data, off_t offset, int whence)
|
||||
{
|
||||
Ogre::DataStreamPtr stream = static_cast<MpgSnd_Decoder*>(user_data)->mDataStream;
|
||||
|
||||
if(whence == SEEK_CUR)
|
||||
stream->seek(stream->tell()+offset);
|
||||
else if(whence == SEEK_SET)
|
||||
stream->seek(offset);
|
||||
else if(whence == SEEK_END)
|
||||
stream->seek(stream->size()+offset);
|
||||
else
|
||||
return -1;
|
||||
|
||||
return stream->tell();
|
||||
}
|
||||
|
||||
|
||||
void MpgSnd_Decoder::open(const std::string &fname)
|
||||
{
|
||||
close();
|
||||
mDataStream = mResourceMgr.openResource(fname);
|
||||
|
||||
SF_VIRTUAL_IO streamIO = {
|
||||
ogresf_get_filelen, ogresf_seek,
|
||||
ogresf_read, ogresf_write, ogresf_tell
|
||||
};
|
||||
mSndFile = sf_open_virtual(&streamIO, SFM_READ, &mSndInfo, this);
|
||||
if(mSndFile)
|
||||
{
|
||||
if(mSndInfo.channels == 1)
|
||||
mChanConfig = ChannelConfig_Mono;
|
||||
else if(mSndInfo.channels == 2)
|
||||
mChanConfig = ChannelConfig_Stereo;
|
||||
else
|
||||
{
|
||||
sf_close(mSndFile);
|
||||
mSndFile = NULL;
|
||||
fail("Unsupported channel count in "+fname);
|
||||
}
|
||||
mSampleRate = mSndInfo.samplerate;
|
||||
return;
|
||||
}
|
||||
mDataStream->seek(0);
|
||||
|
||||
mMpgFile = mpg123_new(NULL, NULL);
|
||||
if(mMpgFile && mpg123_replace_reader_handle(mMpgFile, ogrempg_read, ogrempg_lseek, NULL) == MPG123_OK &&
|
||||
mpg123_open_handle(mMpgFile, this) == MPG123_OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
int encoding, channels;
|
||||
long rate;
|
||||
if(mpg123_getformat(mMpgFile, &rate, &channels, &encoding) != MPG123_OK)
|
||||
fail("Failed to get audio format");
|
||||
if(encoding != MPG123_ENC_SIGNED_16)
|
||||
fail("Unsupported encoding in "+fname);
|
||||
if(channels != 1 && channels != 2)
|
||||
fail("Unsupported channel count in "+fname);
|
||||
mChanConfig = ((channels==2)?ChannelConfig_Stereo:ChannelConfig_Mono);
|
||||
mSampleRate = rate;
|
||||
return;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
mpg123_close(mMpgFile);
|
||||
mpg123_delete(mMpgFile);
|
||||
mMpgFile = NULL;
|
||||
throw;
|
||||
}
|
||||
mpg123_close(mMpgFile);
|
||||
}
|
||||
if(mMpgFile)
|
||||
mpg123_delete(mMpgFile);
|
||||
mMpgFile = NULL;
|
||||
|
||||
fail("Unsupported file type: "+fname);
|
||||
}
|
||||
|
||||
void MpgSnd_Decoder::close()
|
||||
{
|
||||
if(mSndFile)
|
||||
sf_close(mSndFile);
|
||||
mSndFile = NULL;
|
||||
|
||||
if(mMpgFile)
|
||||
{
|
||||
mpg123_close(mMpgFile);
|
||||
mpg123_delete(mMpgFile);
|
||||
mMpgFile = NULL;
|
||||
}
|
||||
|
||||
mDataStream.setNull();
|
||||
}
|
||||
|
||||
void MpgSnd_Decoder::getInfo(int *samplerate, ChannelConfig *chans, SampleType *type)
|
||||
{
|
||||
if(!mSndFile && !mMpgFile)
|
||||
fail("No open file");
|
||||
|
||||
*samplerate = mSampleRate;
|
||||
*chans = mChanConfig;
|
||||
*type = SampleType_Int16;
|
||||
}
|
||||
|
||||
size_t MpgSnd_Decoder::read(char *buffer, size_t bytes)
|
||||
{
|
||||
size_t got = 0;
|
||||
|
||||
if(mSndFile)
|
||||
{
|
||||
got = sf_read_short(mSndFile, (short*)buffer, bytes/2)*2;
|
||||
}
|
||||
else if(mMpgFile)
|
||||
{
|
||||
int err;
|
||||
err = mpg123_read(mMpgFile, (unsigned char*)buffer, bytes, &got);
|
||||
if(err != MPG123_OK && err != MPG123_DONE)
|
||||
fail("Failed to read from file");
|
||||
}
|
||||
return got;
|
||||
}
|
||||
|
||||
void MpgSnd_Decoder::readAll(std::vector<char> &output)
|
||||
{
|
||||
if(mSndFile && mSndInfo.frames > 0)
|
||||
{
|
||||
size_t pos = output.size();
|
||||
output.resize(pos + mSndInfo.frames*mSndInfo.channels*2);
|
||||
sf_readf_short(mSndFile, (short*)(output.data()+pos), mSndInfo.frames);
|
||||
return;
|
||||
}
|
||||
// Fallback in case we don't know the total already
|
||||
Sound_Decoder::readAll(output);
|
||||
}
|
||||
|
||||
void MpgSnd_Decoder::rewind()
|
||||
{
|
||||
if(!mSndFile && !mMpgFile)
|
||||
fail("No open file");
|
||||
|
||||
if(mSndFile)
|
||||
{
|
||||
if(sf_seek(mSndFile, 0, SEEK_SET) == -1)
|
||||
fail("seek failed");
|
||||
}
|
||||
else if(mMpgFile)
|
||||
{
|
||||
if(mpg123_seek(mMpgFile, 0, SEEK_SET) < 0)
|
||||
fail("seek failed");
|
||||
}
|
||||
}
|
||||
|
||||
MpgSnd_Decoder::MpgSnd_Decoder()
|
||||
: mSndInfo()
|
||||
, mSndFile(NULL)
|
||||
, mMpgFile(NULL)
|
||||
, mDataStream()
|
||||
, mChanConfig(ChannelConfig_Stereo)
|
||||
, mSampleRate(0)
|
||||
{
|
||||
static bool initdone = false;
|
||||
if(!initdone)
|
||||
mpg123_init();
|
||||
initdone = true;
|
||||
}
|
||||
|
||||
MpgSnd_Decoder::~MpgSnd_Decoder()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
57
apps/openmw/mwsound/mpgsnd_decoder.hpp
Normal file
57
apps/openmw/mwsound/mpgsnd_decoder.hpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#ifndef GAME_SOUND_MPGSND_DECODER_H
|
||||
#define GAME_SOUND_MPGSND_DECODER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <OgreDataStream.h>
|
||||
|
||||
#include "mpg123.h"
|
||||
#include "sndfile.h"
|
||||
|
||||
#include "sound_decoder.hpp"
|
||||
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class MpgSnd_Decoder : public Sound_Decoder
|
||||
{
|
||||
SF_INFO mSndInfo;
|
||||
SNDFILE *mSndFile;
|
||||
mpg123_handle *mMpgFile;
|
||||
|
||||
Ogre::DataStreamPtr mDataStream;
|
||||
static sf_count_t ogresf_get_filelen(void *user_data);
|
||||
static sf_count_t ogresf_seek(sf_count_t offset, int whence, void *user_data);
|
||||
static sf_count_t ogresf_read(void *ptr, sf_count_t count, void *user_data);
|
||||
static sf_count_t ogresf_write(const void*, sf_count_t, void*);
|
||||
static sf_count_t ogresf_tell(void *user_data);
|
||||
static ssize_t ogrempg_read(void*, void*, size_t);
|
||||
static off_t ogrempg_lseek(void*, off_t, int);
|
||||
|
||||
ChannelConfig mChanConfig;
|
||||
int mSampleRate;
|
||||
|
||||
virtual void open(const std::string &fname);
|
||||
virtual void close();
|
||||
|
||||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type);
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes);
|
||||
virtual void readAll(std::vector<char> &output);
|
||||
virtual void rewind();
|
||||
|
||||
MpgSnd_Decoder& operator=(const MpgSnd_Decoder &rhs);
|
||||
MpgSnd_Decoder(const MpgSnd_Decoder &rhs);
|
||||
|
||||
MpgSnd_Decoder();
|
||||
public:
|
||||
virtual ~MpgSnd_Decoder();
|
||||
|
||||
friend class SoundManager;
|
||||
};
|
||||
#ifndef DEFAULT_DECODER
|
||||
#define DEFAULT_DECODER (::MWSound::MpgSnd_Decoder)
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
793
apps/openmw/mwsound/openal_output.cpp
Normal file
793
apps/openmw/mwsound/openal_output.cpp
Normal file
|
@ -0,0 +1,793 @@
|
|||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#include "openal_output.hpp"
|
||||
#include "sound_decoder.hpp"
|
||||
#include "sound.hpp"
|
||||
#include "soundmanager.hpp"
|
||||
|
||||
#ifndef ALC_ALL_DEVICES_SPECIFIER
|
||||
#define ALC_ALL_DEVICES_SPECIFIER 0x1013
|
||||
#endif
|
||||
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
|
||||
static void fail(const std::string &msg)
|
||||
{ throw std::runtime_error("OpenAL exception: " + msg); }
|
||||
|
||||
static void throwALCerror(ALCdevice *device)
|
||||
{
|
||||
ALCenum err = alcGetError(device);
|
||||
if(err != ALC_NO_ERROR)
|
||||
fail(alcGetString(device, err));
|
||||
}
|
||||
|
||||
static void throwALerror()
|
||||
{
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
fail(alGetString(err));
|
||||
}
|
||||
|
||||
|
||||
static ALenum getALFormat(ChannelConfig chans, SampleType type)
|
||||
{
|
||||
static const struct {
|
||||
ALenum format;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
} fmtlist[] = {
|
||||
{ AL_FORMAT_MONO16, ChannelConfig_Mono, SampleType_Int16 },
|
||||
{ AL_FORMAT_MONO8, ChannelConfig_Mono, SampleType_UInt8 },
|
||||
{ AL_FORMAT_STEREO16, ChannelConfig_Stereo, SampleType_Int16 },
|
||||
{ AL_FORMAT_STEREO8, ChannelConfig_Stereo, SampleType_UInt8 },
|
||||
};
|
||||
static const size_t fmtlistsize = sizeof(fmtlist)/sizeof(fmtlist[0]);
|
||||
|
||||
for(size_t i = 0;i < fmtlistsize;i++)
|
||||
{
|
||||
if(fmtlist[i].chans == chans && fmtlist[i].type == type)
|
||||
return fmtlist[i].format;
|
||||
}
|
||||
fail(std::string("Unsupported sound format (")+getChannelConfigName(chans)+", "+getSampleTypeName(type)+")");
|
||||
return AL_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// A streaming OpenAL sound.
|
||||
//
|
||||
class OpenAL_SoundStream : public Sound
|
||||
{
|
||||
static const ALuint sNumBuffers = 6;
|
||||
static const ALfloat sBufferLength;
|
||||
|
||||
OpenAL_Output &mOutput;
|
||||
|
||||
ALuint mSource;
|
||||
ALuint mBuffers[sNumBuffers];
|
||||
|
||||
ALenum mFormat;
|
||||
ALsizei mSampleRate;
|
||||
ALuint mBufferSize;
|
||||
|
||||
DecoderPtr mDecoder;
|
||||
|
||||
volatile bool mIsFinished;
|
||||
|
||||
OpenAL_SoundStream(const OpenAL_SoundStream &rhs);
|
||||
OpenAL_SoundStream& operator=(const OpenAL_SoundStream &rhs);
|
||||
|
||||
public:
|
||||
OpenAL_SoundStream(OpenAL_Output &output, ALuint src, DecoderPtr decoder);
|
||||
virtual ~OpenAL_SoundStream();
|
||||
|
||||
virtual void stop();
|
||||
virtual bool isPlaying();
|
||||
virtual void setVolume(float volume);
|
||||
virtual void update(const float *pos);
|
||||
|
||||
void play();
|
||||
bool process();
|
||||
};
|
||||
|
||||
const ALfloat OpenAL_SoundStream::sBufferLength = 0.125f;
|
||||
|
||||
//
|
||||
// A background streaming thread (keeps active streams processed)
|
||||
//
|
||||
struct OpenAL_Output::StreamThread {
|
||||
typedef std::vector<OpenAL_SoundStream*> StreamVec;
|
||||
StreamVec mStreams;
|
||||
boost::mutex mMutex;
|
||||
boost::thread mThread;
|
||||
|
||||
StreamThread()
|
||||
: mThread(boost::ref(*this))
|
||||
{
|
||||
}
|
||||
~StreamThread()
|
||||
{
|
||||
mThread.interrupt();
|
||||
}
|
||||
|
||||
// boost::thread entry point
|
||||
void operator()()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
mMutex.lock();
|
||||
StreamVec::iterator iter = mStreams.begin();
|
||||
while(iter != mStreams.end())
|
||||
{
|
||||
if((*iter)->process() == false)
|
||||
iter = mStreams.erase(iter);
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
mMutex.unlock();
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
||||
}
|
||||
}
|
||||
|
||||
void add(OpenAL_SoundStream *stream)
|
||||
{
|
||||
mMutex.lock();
|
||||
if(std::find(mStreams.begin(), mStreams.end(), stream) == mStreams.end())
|
||||
mStreams.push_back(stream);
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
void remove(OpenAL_SoundStream *stream)
|
||||
{
|
||||
mMutex.lock();
|
||||
StreamVec::iterator iter = std::find(mStreams.begin(), mStreams.end(), stream);
|
||||
if(iter != mStreams.end())
|
||||
mStreams.erase(iter);
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
void removeAll()
|
||||
{
|
||||
mMutex.lock();
|
||||
mStreams.clear();
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
StreamThread(const StreamThread &rhs);
|
||||
StreamThread& operator=(const StreamThread &rhs);
|
||||
};
|
||||
|
||||
|
||||
OpenAL_SoundStream::OpenAL_SoundStream(OpenAL_Output &output, ALuint src, DecoderPtr decoder)
|
||||
: mOutput(output), mSource(src), mDecoder(decoder), mIsFinished(true)
|
||||
{
|
||||
throwALerror();
|
||||
|
||||
alGenBuffers(sNumBuffers, mBuffers);
|
||||
throwALerror();
|
||||
try
|
||||
{
|
||||
int srate;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
|
||||
mDecoder->getInfo(&srate, &chans, &type);
|
||||
mFormat = getALFormat(chans, type);
|
||||
mSampleRate = srate;
|
||||
|
||||
mBufferSize = static_cast<ALuint>(sBufferLength*srate);
|
||||
mBufferSize = framesToBytes(mBufferSize, chans, type);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
mOutput.mFreeSources.push_back(mSource);
|
||||
alDeleteBuffers(sNumBuffers, mBuffers);
|
||||
alGetError();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
OpenAL_SoundStream::~OpenAL_SoundStream()
|
||||
{
|
||||
mOutput.mStreamThread->remove(this);
|
||||
|
||||
alSourceStop(mSource);
|
||||
alSourcei(mSource, AL_BUFFER, 0);
|
||||
|
||||
mOutput.mFreeSources.push_back(mSource);
|
||||
alDeleteBuffers(sNumBuffers, mBuffers);
|
||||
alGetError();
|
||||
|
||||
mDecoder->close();
|
||||
}
|
||||
|
||||
void OpenAL_SoundStream::play()
|
||||
{
|
||||
std::vector<char> data(mBufferSize);
|
||||
|
||||
alSourceStop(mSource);
|
||||
alSourcei(mSource, AL_BUFFER, 0);
|
||||
throwALerror();
|
||||
|
||||
for(ALuint i = 0;i < sNumBuffers;i++)
|
||||
{
|
||||
size_t got;
|
||||
got = mDecoder->read(data.data(), data.size());
|
||||
alBufferData(mBuffers[i], mFormat, data.data(), got, mSampleRate);
|
||||
}
|
||||
throwALerror();
|
||||
|
||||
alSourceQueueBuffers(mSource, sNumBuffers, mBuffers);
|
||||
alSourcePlay(mSource);
|
||||
throwALerror();
|
||||
|
||||
mIsFinished = false;
|
||||
mOutput.mStreamThread->add(this);
|
||||
}
|
||||
|
||||
void OpenAL_SoundStream::stop()
|
||||
{
|
||||
mOutput.mStreamThread->remove(this);
|
||||
mIsFinished = true;
|
||||
|
||||
alSourceStop(mSource);
|
||||
alSourcei(mSource, AL_BUFFER, 0);
|
||||
throwALerror();
|
||||
|
||||
mDecoder->rewind();
|
||||
}
|
||||
|
||||
bool OpenAL_SoundStream::isPlaying()
|
||||
{
|
||||
ALint state;
|
||||
|
||||
alGetSourcei(mSource, AL_SOURCE_STATE, &state);
|
||||
throwALerror();
|
||||
|
||||
if(state == AL_PLAYING)
|
||||
return true;
|
||||
return !mIsFinished;
|
||||
}
|
||||
|
||||
void OpenAL_SoundStream::setVolume(float volume)
|
||||
{
|
||||
alSourcef(mSource, AL_GAIN, volume*mBaseVolume);
|
||||
throwALerror();
|
||||
mVolume = volume;
|
||||
}
|
||||
|
||||
void OpenAL_SoundStream::update(const float *pos)
|
||||
{
|
||||
alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
bool OpenAL_SoundStream::process()
|
||||
{
|
||||
bool finished = mIsFinished;
|
||||
ALint processed, state;
|
||||
|
||||
alGetSourcei(mSource, AL_SOURCE_STATE, &state);
|
||||
alGetSourcei(mSource, AL_BUFFERS_PROCESSED, &processed);
|
||||
throwALerror();
|
||||
|
||||
if(processed > 0)
|
||||
{
|
||||
std::vector<char> data(mBufferSize);
|
||||
do {
|
||||
ALuint bufid;
|
||||
size_t got;
|
||||
|
||||
alSourceUnqueueBuffers(mSource, 1, &bufid);
|
||||
processed--;
|
||||
|
||||
if(finished)
|
||||
continue;
|
||||
|
||||
got = mDecoder->read(data.data(), data.size());
|
||||
finished = (got < data.size());
|
||||
if(got > 0)
|
||||
{
|
||||
alBufferData(bufid, mFormat, data.data(), got, mSampleRate);
|
||||
alSourceQueueBuffers(mSource, 1, &bufid);
|
||||
}
|
||||
} while(processed > 0);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
if(state != AL_PLAYING && state != AL_PAUSED)
|
||||
{
|
||||
ALint queued;
|
||||
|
||||
alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
|
||||
throwALerror();
|
||||
if(queued > 0)
|
||||
{
|
||||
alSourcePlay(mSource);
|
||||
throwALerror();
|
||||
}
|
||||
}
|
||||
|
||||
mIsFinished = finished;
|
||||
return !finished;
|
||||
}
|
||||
|
||||
//
|
||||
// A regular OpenAL sound
|
||||
//
|
||||
class OpenAL_Sound : public Sound
|
||||
{
|
||||
OpenAL_Output &mOutput;
|
||||
|
||||
ALuint mSource;
|
||||
ALuint mBuffer;
|
||||
|
||||
OpenAL_Sound(const OpenAL_Sound &rhs);
|
||||
OpenAL_Sound& operator=(const OpenAL_Sound &rhs);
|
||||
|
||||
public:
|
||||
OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf);
|
||||
virtual ~OpenAL_Sound();
|
||||
|
||||
virtual void stop();
|
||||
virtual bool isPlaying();
|
||||
virtual void setVolume(float volume);
|
||||
virtual void update(const float *pos);
|
||||
};
|
||||
|
||||
OpenAL_Sound::OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf)
|
||||
: mOutput(output), mSource(src), mBuffer(buf)
|
||||
{
|
||||
}
|
||||
OpenAL_Sound::~OpenAL_Sound()
|
||||
{
|
||||
alSourceStop(mSource);
|
||||
alSourcei(mSource, AL_BUFFER, 0);
|
||||
|
||||
mOutput.mFreeSources.push_back(mSource);
|
||||
mOutput.bufferFinished(mBuffer);
|
||||
}
|
||||
|
||||
void OpenAL_Sound::stop()
|
||||
{
|
||||
alSourceStop(mSource);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
bool OpenAL_Sound::isPlaying()
|
||||
{
|
||||
ALint state;
|
||||
|
||||
alGetSourcei(mSource, AL_SOURCE_STATE, &state);
|
||||
throwALerror();
|
||||
|
||||
return state==AL_PLAYING;
|
||||
}
|
||||
|
||||
void OpenAL_Sound::setVolume(float volume)
|
||||
{
|
||||
alSourcef(mSource, AL_GAIN, volume*mBaseVolume);
|
||||
throwALerror();
|
||||
mVolume = volume;
|
||||
}
|
||||
|
||||
void OpenAL_Sound::update(const float *pos)
|
||||
{
|
||||
alSource3f(mSource, AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// An OpenAL output device
|
||||
//
|
||||
std::vector<std::string> OpenAL_Output::enumerate()
|
||||
{
|
||||
std::vector<std::string> devlist;
|
||||
const ALCchar *devnames;
|
||||
|
||||
if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
|
||||
devnames = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
|
||||
else
|
||||
devnames = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
|
||||
while(devnames && *devnames)
|
||||
{
|
||||
devlist.push_back(devnames);
|
||||
devnames += strlen(devnames)+1;
|
||||
}
|
||||
return devlist;
|
||||
}
|
||||
|
||||
void OpenAL_Output::init(const std::string &devname)
|
||||
{
|
||||
if(mDevice || mContext)
|
||||
fail("Device already open");
|
||||
|
||||
mDevice = alcOpenDevice(devname.c_str());
|
||||
if(!mDevice)
|
||||
{
|
||||
if(devname.empty())
|
||||
fail("Failed to open default device");
|
||||
else
|
||||
fail("Failed to open \""+devname+"\"");
|
||||
}
|
||||
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER)<<"\"" << std::endl;
|
||||
else
|
||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
||||
|
||||
mContext = alcCreateContext(mDevice, NULL);
|
||||
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
||||
fail(std::string("Failed to setup context: ")+alcGetString(mDevice, alcGetError(mDevice)));
|
||||
|
||||
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
||||
throwALerror();
|
||||
|
||||
ALCint maxmono=0, maxstereo=0;
|
||||
alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &maxmono);
|
||||
alcGetIntegerv(mDevice, ALC_STEREO_SOURCES, 1, &maxstereo);
|
||||
throwALCerror(mDevice);
|
||||
|
||||
try
|
||||
{
|
||||
ALCuint maxtotal = std::min<ALCuint>(maxmono+maxstereo, 256);
|
||||
for(size_t i = 0;i < maxtotal;i++)
|
||||
{
|
||||
ALuint src = 0;
|
||||
alGenSources(1, &src);
|
||||
throwALerror();
|
||||
mFreeSources.push_back(src);
|
||||
}
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout <<"Error: "<<e.what()<<", trying to continue"<< std::endl;
|
||||
}
|
||||
if(mFreeSources.empty())
|
||||
fail("Could not allocate any sources");
|
||||
}
|
||||
|
||||
void OpenAL_Output::deinit()
|
||||
{
|
||||
mStreamThread->removeAll();
|
||||
|
||||
while(!mFreeSources.empty())
|
||||
{
|
||||
alDeleteSources(1, &mFreeSources.front());
|
||||
mFreeSources.pop_front();
|
||||
}
|
||||
|
||||
mBufferRefs.clear();
|
||||
mUnusedBuffers.clear();
|
||||
while(!mBufferCache.empty())
|
||||
{
|
||||
alDeleteBuffers(1, &mBufferCache.begin()->second);
|
||||
mBufferCache.erase(mBufferCache.begin());
|
||||
}
|
||||
|
||||
alcMakeContextCurrent(0);
|
||||
if(mContext)
|
||||
alcDestroyContext(mContext);
|
||||
mContext = 0;
|
||||
if(mDevice)
|
||||
alcCloseDevice(mDevice);
|
||||
mDevice = 0;
|
||||
}
|
||||
|
||||
|
||||
ALuint OpenAL_Output::getBuffer(const std::string &fname)
|
||||
{
|
||||
ALuint buf = 0;
|
||||
|
||||
NameMap::iterator iditer = mBufferCache.find(fname);
|
||||
if(iditer != mBufferCache.end())
|
||||
{
|
||||
buf = iditer->second;
|
||||
if(mBufferRefs[buf]++ == 0)
|
||||
{
|
||||
IDDq::iterator iter = std::find(mUnusedBuffers.begin(),
|
||||
mUnusedBuffers.end(), buf);
|
||||
if(iter != mUnusedBuffers.end())
|
||||
mUnusedBuffers.erase(iter);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
throwALerror();
|
||||
|
||||
std::vector<char> data;
|
||||
ChannelConfig chans;
|
||||
SampleType type;
|
||||
ALenum format;
|
||||
int srate;
|
||||
|
||||
DecoderPtr decoder = mManager.getDecoder();
|
||||
try
|
||||
{
|
||||
decoder->open(fname);
|
||||
}
|
||||
catch(Ogre::FileNotFoundException &e)
|
||||
{
|
||||
std::string::size_type pos = fname.rfind('.');
|
||||
if(pos == std::string::npos)
|
||||
throw;
|
||||
decoder->open(fname.substr(0, pos)+".mp3");
|
||||
}
|
||||
|
||||
decoder->getInfo(&srate, &chans, &type);
|
||||
format = getALFormat(chans, type);
|
||||
|
||||
decoder->readAll(data);
|
||||
decoder->close();
|
||||
|
||||
alGenBuffers(1, &buf);
|
||||
throwALerror();
|
||||
|
||||
alBufferData(buf, format, data.data(), data.size(), srate);
|
||||
mBufferCache[fname] = buf;
|
||||
mBufferRefs[buf] = 1;
|
||||
|
||||
ALint bufsize = 0;
|
||||
alGetBufferi(buf, AL_SIZE, &bufsize);
|
||||
mBufferCacheMemSize += bufsize;
|
||||
|
||||
// NOTE: Max buffer cache: 15MB
|
||||
while(mBufferCacheMemSize > 15*1024*1024)
|
||||
{
|
||||
if(mUnusedBuffers.empty())
|
||||
{
|
||||
std::cout <<"No more unused buffers to clear!"<< std::endl;
|
||||
break;
|
||||
}
|
||||
|
||||
ALuint oldbuf = mUnusedBuffers.front();
|
||||
mUnusedBuffers.pop_front();
|
||||
|
||||
NameMap::iterator nameiter = mBufferCache.begin();
|
||||
while(nameiter != mBufferCache.end())
|
||||
{
|
||||
if(nameiter->second == oldbuf)
|
||||
mBufferCache.erase(nameiter++);
|
||||
else
|
||||
nameiter++;
|
||||
}
|
||||
|
||||
bufsize = 0;
|
||||
alGetBufferi(oldbuf, AL_SIZE, &bufsize);
|
||||
alDeleteBuffers(1, &oldbuf);
|
||||
mBufferCacheMemSize -= bufsize;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void OpenAL_Output::bufferFinished(ALuint buf)
|
||||
{
|
||||
if(mBufferRefs.at(buf)-- == 1)
|
||||
{
|
||||
mBufferRefs.erase(mBufferRefs.find(buf));
|
||||
mUnusedBuffers.push_back(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SoundPtr OpenAL_Output::playSound(const std::string &fname, float volume, float pitch, bool loop)
|
||||
{
|
||||
throwALerror();
|
||||
|
||||
boost::shared_ptr<OpenAL_Sound> sound;
|
||||
ALuint src=0, buf=0;
|
||||
|
||||
if(mFreeSources.empty())
|
||||
fail("No free sources");
|
||||
src = mFreeSources.front();
|
||||
mFreeSources.pop_front();
|
||||
|
||||
try
|
||||
{
|
||||
buf = getBuffer(fname);
|
||||
sound.reset(new OpenAL_Sound(*this, src, buf));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
mFreeSources.push_back(src);
|
||||
if(buf && alIsBuffer(buf))
|
||||
bufferFinished(buf);
|
||||
alGetError();
|
||||
throw;
|
||||
}
|
||||
|
||||
alSource3f(src, AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
alSourcef(src, AL_REFERENCE_DISTANCE, 1.0f);
|
||||
alSourcef(src, AL_MAX_DISTANCE, 1000.0f);
|
||||
alSourcef(src, AL_ROLLOFF_FACTOR, 0.0f);
|
||||
|
||||
alSourcef(src, AL_GAIN, volume);
|
||||
alSourcef(src, AL_PITCH, pitch);
|
||||
|
||||
alSourcei(src, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSourcei(src, AL_LOOPING, (loop?AL_TRUE:AL_FALSE));
|
||||
throwALerror();
|
||||
|
||||
alSourcei(src, AL_BUFFER, buf);
|
||||
alSourcePlay(src);
|
||||
throwALerror();
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
||||
float min, float max, bool loop)
|
||||
{
|
||||
throwALerror();
|
||||
|
||||
boost::shared_ptr<OpenAL_Sound> sound;
|
||||
ALuint src=0, buf=0;
|
||||
|
||||
if(mFreeSources.empty())
|
||||
fail("No free sources");
|
||||
src = mFreeSources.front();
|
||||
mFreeSources.pop_front();
|
||||
|
||||
try
|
||||
{
|
||||
buf = getBuffer(fname);
|
||||
sound.reset(new OpenAL_Sound(*this, src, buf));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
mFreeSources.push_back(src);
|
||||
if(buf && alIsBuffer(buf))
|
||||
bufferFinished(buf);
|
||||
alGetError();
|
||||
throw;
|
||||
}
|
||||
|
||||
alSource3f(src, AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||
alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
alSourcef(src, AL_REFERENCE_DISTANCE, min);
|
||||
alSourcef(src, AL_MAX_DISTANCE, max);
|
||||
alSourcef(src, AL_ROLLOFF_FACTOR, 1.0f);
|
||||
|
||||
alSourcef(src, AL_GAIN, volume);
|
||||
alSourcef(src, AL_PITCH, pitch);
|
||||
|
||||
alSourcei(src, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||
alSourcei(src, AL_LOOPING, (loop?AL_TRUE:AL_FALSE));
|
||||
throwALerror();
|
||||
|
||||
alSourcei(src, AL_BUFFER, buf);
|
||||
alSourcePlay(src);
|
||||
throwALerror();
|
||||
|
||||
return sound;
|
||||
}
|
||||
|
||||
|
||||
SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, float pitch)
|
||||
{
|
||||
throwALerror();
|
||||
|
||||
boost::shared_ptr<OpenAL_SoundStream> sound;
|
||||
ALuint src;
|
||||
|
||||
if(mFreeSources.empty())
|
||||
fail("No free sources");
|
||||
src = mFreeSources.front();
|
||||
mFreeSources.pop_front();
|
||||
|
||||
try
|
||||
{
|
||||
DecoderPtr decoder = mManager.getDecoder();
|
||||
decoder->open(fname);
|
||||
sound.reset(new OpenAL_SoundStream(*this, src, decoder));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
mFreeSources.push_back(src);
|
||||
throw;
|
||||
}
|
||||
|
||||
alSource3f(src, AL_POSITION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
alSourcef(src, AL_REFERENCE_DISTANCE, 1.0f);
|
||||
alSourcef(src, AL_MAX_DISTANCE, 1000.0f);
|
||||
alSourcef(src, AL_ROLLOFF_FACTOR, 0.0f);
|
||||
|
||||
alSourcef(src, AL_GAIN, volume);
|
||||
alSourcef(src, AL_PITCH, pitch);
|
||||
|
||||
alSourcei(src, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||
alSourcei(src, AL_LOOPING, AL_FALSE);
|
||||
throwALerror();
|
||||
|
||||
sound->play();
|
||||
return sound;
|
||||
}
|
||||
|
||||
SoundPtr OpenAL_Output::streamSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
||||
float min, float max)
|
||||
{
|
||||
throwALerror();
|
||||
|
||||
boost::shared_ptr<OpenAL_SoundStream> sound;
|
||||
ALuint src;
|
||||
|
||||
if(mFreeSources.empty())
|
||||
fail("No free sources");
|
||||
src = mFreeSources.front();
|
||||
mFreeSources.pop_front();
|
||||
|
||||
try
|
||||
{
|
||||
DecoderPtr decoder = mManager.getDecoder();
|
||||
decoder->open(fname);
|
||||
sound.reset(new OpenAL_SoundStream(*this, src, decoder));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
mFreeSources.push_back(src);
|
||||
throw;
|
||||
}
|
||||
|
||||
alSource3f(src, AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||
alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||
alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
alSourcef(src, AL_REFERENCE_DISTANCE, min);
|
||||
alSourcef(src, AL_MAX_DISTANCE, max);
|
||||
alSourcef(src, AL_ROLLOFF_FACTOR, 1.0f);
|
||||
|
||||
alSourcef(src, AL_GAIN, volume);
|
||||
alSourcef(src, AL_PITCH, pitch);
|
||||
|
||||
alSourcei(src, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||
alSourcei(src, AL_LOOPING, AL_FALSE);
|
||||
throwALerror();
|
||||
|
||||
sound->play();
|
||||
return sound;
|
||||
}
|
||||
|
||||
|
||||
void OpenAL_Output::updateListener(const float *pos, const float *atdir, const float *updir)
|
||||
{
|
||||
float orient[6] = {
|
||||
atdir[0], atdir[2], -atdir[1],
|
||||
updir[0], updir[2], -updir[1]
|
||||
};
|
||||
|
||||
alListener3f(AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||
alListenerfv(AL_ORIENTATION, orient);
|
||||
throwALerror();
|
||||
}
|
||||
|
||||
|
||||
OpenAL_Output::OpenAL_Output(SoundManager &mgr)
|
||||
: Sound_Output(mgr), mDevice(0), mContext(0), mBufferCacheMemSize(0),
|
||||
mStreamThread(new StreamThread)
|
||||
{
|
||||
}
|
||||
|
||||
OpenAL_Output::~OpenAL_Output()
|
||||
{
|
||||
deinit();
|
||||
}
|
||||
|
||||
}
|
71
apps/openmw/mwsound/openal_output.hpp
Normal file
71
apps/openmw/mwsound/openal_output.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef GAME_SOUND_OPENAL_OUTPUT_H
|
||||
#define GAME_SOUND_OPENAL_OUTPUT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <deque>
|
||||
|
||||
#include "alc.h"
|
||||
#include "al.h"
|
||||
|
||||
#include "sound_output.hpp"
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class SoundManager;
|
||||
class Sound;
|
||||
|
||||
class OpenAL_Output : public Sound_Output
|
||||
{
|
||||
ALCdevice *mDevice;
|
||||
ALCcontext *mContext;
|
||||
|
||||
typedef std::deque<ALuint> IDDq;
|
||||
IDDq mFreeSources;
|
||||
IDDq mUnusedBuffers;
|
||||
|
||||
typedef std::map<std::string,ALuint> NameMap;
|
||||
NameMap mBufferCache;
|
||||
|
||||
typedef std::map<ALuint,ALuint> IDRefMap;
|
||||
IDRefMap mBufferRefs;
|
||||
|
||||
uint64_t mBufferCacheMemSize;
|
||||
|
||||
ALuint getBuffer(const std::string &fname);
|
||||
void bufferFinished(ALuint buffer);
|
||||
|
||||
virtual std::vector<std::string> enumerate();
|
||||
virtual void init(const std::string &devname="");
|
||||
virtual void deinit();
|
||||
|
||||
virtual SoundPtr playSound(const std::string &fname, float volume, float pitch, bool loop);
|
||||
virtual SoundPtr playSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
||||
float min, float max, bool loop);
|
||||
|
||||
virtual SoundPtr streamSound(const std::string &fname, float volume, float pitch);
|
||||
virtual SoundPtr streamSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
||||
float min, float max);
|
||||
|
||||
virtual void updateListener(const float *pos, const float *atdir, const float *updir);
|
||||
|
||||
OpenAL_Output& operator=(const OpenAL_Output &rhs);
|
||||
OpenAL_Output(const OpenAL_Output &rhs);
|
||||
|
||||
OpenAL_Output(SoundManager &mgr);
|
||||
virtual ~OpenAL_Output();
|
||||
|
||||
class StreamThread;
|
||||
std::auto_ptr<StreamThread> mStreamThread;
|
||||
|
||||
friend class OpenAL_Sound;
|
||||
friend class OpenAL_SoundStream;
|
||||
friend class SoundManager;
|
||||
};
|
||||
#ifndef DEFAULT_OUTPUT
|
||||
#define DEFAULT_OUTPUT (::MWSound::OpenAL_Output)
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
36
apps/openmw/mwsound/sound.hpp
Normal file
36
apps/openmw/mwsound/sound.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef GAME_SOUND_SOUND_H
|
||||
#define GAME_SOUND_SOUND_H
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class Sound
|
||||
{
|
||||
virtual void update(const float *pos) = 0;
|
||||
|
||||
Sound& operator=(const Sound &rhs);
|
||||
Sound(const Sound &rhs);
|
||||
|
||||
protected:
|
||||
float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */
|
||||
float mBaseVolume;
|
||||
float mMinDistance;
|
||||
float mMaxDistance;
|
||||
|
||||
public:
|
||||
virtual void stop() = 0;
|
||||
virtual bool isPlaying() = 0;
|
||||
virtual void setVolume(float volume) = 0;
|
||||
|
||||
Sound() : mVolume(1.0f)
|
||||
, mBaseVolume(1.0f)
|
||||
, mMinDistance(20.0f) /* 1 * min_range_scale */
|
||||
, mMaxDistance(12750.0f) /* 255 * max_range_scale */
|
||||
{ }
|
||||
virtual ~Sound() { }
|
||||
|
||||
friend class OpenAL_Output;
|
||||
friend class SoundManager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
48
apps/openmw/mwsound/sound_decoder.hpp
Normal file
48
apps/openmw/mwsound/sound_decoder.hpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#ifndef GAME_SOUND_SOUND_DECODER_H
|
||||
#define GAME_SOUND_SOUND_DECODER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <OgreResourceGroupManager.h>
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
enum SampleType {
|
||||
SampleType_UInt8,
|
||||
SampleType_Int16
|
||||
};
|
||||
const char *getSampleTypeName(SampleType type);
|
||||
|
||||
enum ChannelConfig {
|
||||
ChannelConfig_Mono,
|
||||
ChannelConfig_Stereo
|
||||
};
|
||||
const char *getChannelConfigName(ChannelConfig config);
|
||||
|
||||
size_t framesToBytes(size_t frames, ChannelConfig config, SampleType type);
|
||||
size_t bytesToFrames(size_t bytes, ChannelConfig config, SampleType type);
|
||||
|
||||
struct Sound_Decoder
|
||||
{
|
||||
Ogre::ResourceGroupManager &mResourceMgr;
|
||||
|
||||
virtual void open(const std::string &fname) = 0;
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual void getInfo(int *samplerate, ChannelConfig *chans, SampleType *type) = 0;
|
||||
|
||||
virtual size_t read(char *buffer, size_t bytes) = 0;
|
||||
virtual void readAll(std::vector<char> &output);
|
||||
virtual void rewind() = 0;
|
||||
|
||||
Sound_Decoder() : mResourceMgr(Ogre::ResourceGroupManager::getSingleton())
|
||||
{ }
|
||||
virtual ~Sound_Decoder() { }
|
||||
|
||||
private:
|
||||
Sound_Decoder(const Sound_Decoder &rhs);
|
||||
Sound_Decoder& operator=(const Sound_Decoder &rhs);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
46
apps/openmw/mwsound/sound_output.hpp
Normal file
46
apps/openmw/mwsound/sound_output.hpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
#ifndef GAME_SOUND_SOUND_OUTPUT_H
|
||||
#define GAME_SOUND_SOUND_OUTPUT_H
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "soundmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class SoundManager;
|
||||
class Sound_Decoder;
|
||||
class Sound;
|
||||
|
||||
class Sound_Output
|
||||
{
|
||||
SoundManager &mManager;
|
||||
|
||||
virtual std::vector<std::string> enumerate() = 0;
|
||||
virtual void init(const std::string &devname="") = 0;
|
||||
virtual void deinit() = 0;
|
||||
|
||||
virtual SoundPtr playSound(const std::string &fname, float volume, float pitch, bool loop) = 0;
|
||||
virtual SoundPtr playSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
||||
float min, float max, bool loop) = 0;
|
||||
virtual SoundPtr streamSound(const std::string &fname, float volume, float pitch) = 0;
|
||||
virtual SoundPtr streamSound3D(const std::string &fname, const float *pos, float volume, float pitch,
|
||||
float min, float max) = 0;
|
||||
|
||||
virtual void updateListener(const float *pos, const float *atdir, const float *updir) = 0;
|
||||
|
||||
Sound_Output& operator=(const Sound_Output &rhs);
|
||||
Sound_Output(const Sound_Output &rhs);
|
||||
|
||||
Sound_Output(SoundManager &mgr) : mManager(mgr) { }
|
||||
public:
|
||||
virtual ~Sound_Output() { }
|
||||
|
||||
friend class OpenAL_Output;
|
||||
friend class SoundManager;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -6,107 +6,78 @@
|
|||
|
||||
#include <OgreRoot.h>
|
||||
|
||||
#include <openengine/sound/sndmanager.hpp>
|
||||
#include <mangle/sound/clients/ogre_listener_mover.hpp>
|
||||
#include <mangle/sound/clients/ogre_output_updater.hpp>
|
||||
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
/* Set up the sound manager to use Audiere, FFMPEG or
|
||||
MPG123/libsndfile for input. The OPENMW_USE_x macros are set in
|
||||
CMakeLists.txt.
|
||||
*/
|
||||
#ifdef OPENMW_USE_AUDIERE
|
||||
#include <mangle/sound/filters/openal_audiere.hpp>
|
||||
#define SOUND_FACTORY OpenAL_Audiere_Factory
|
||||
#define SOUND_OUT "OpenAL"
|
||||
#define SOUND_IN "Audiere"
|
||||
#endif
|
||||
#include "sound_output.hpp"
|
||||
#include "sound_decoder.hpp"
|
||||
#include "sound.hpp"
|
||||
|
||||
#ifdef OPENMW_USE_FFMPEG
|
||||
#include <mangle/sound/filters/openal_ffmpeg.hpp>
|
||||
#define SOUND_FACTORY OpenAL_FFMpeg_Factory
|
||||
#include "openal_output.hpp"
|
||||
#define SOUND_OUT "OpenAL"
|
||||
/* Set up the sound manager to use FFMPEG or MPG123+libsndfile for input. The
|
||||
* OPENMW_USE_x macros are set in CMakeLists.txt.
|
||||
*/
|
||||
#ifdef OPENMW_USE_FFMPEG
|
||||
#include "ffmpeg_decoder.hpp"
|
||||
#ifndef SOUND_IN
|
||||
#define SOUND_IN "FFmpeg"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef OPENMW_USE_MPG123
|
||||
#include <mangle/sound/filters/openal_sndfile_mpg123.hpp>
|
||||
#define SOUND_FACTORY OpenAL_SndFile_Mpg123_Factory
|
||||
#define SOUND_OUT "OpenAL"
|
||||
#include "mpgsnd_decoder.hpp"
|
||||
#ifndef SOUND_IN
|
||||
#define SOUND_IN "mpg123,sndfile"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace Mangle::Sound;
|
||||
typedef OEngine::Sound::SoundManager OEManager;
|
||||
|
||||
// Set the position on a sound based on a Ptr.
|
||||
static void setPos(SoundPtr &snd, const MWWorld::Ptr ref)
|
||||
{
|
||||
// Get sound position from the reference
|
||||
const float *pos = ref.getCellRef().pos.pos;
|
||||
|
||||
// Move the sound, converting from MW coordinates to Ogre
|
||||
// coordinates.
|
||||
snd->setPos(pos[0], pos[2], -pos[1]);
|
||||
}
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
|
||||
SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera,
|
||||
const Files::PathContainer& dataDirs,
|
||||
bool useSound, bool fsstrict, MWWorld::Environment& environment)
|
||||
: mFSStrict(fsstrict)
|
||||
SoundManager::SoundManager(bool useSound, MWWorld::Environment& environment)
|
||||
: mResourceMgr(Ogre::ResourceGroupManager::getSingleton())
|
||||
, mEnvironment(environment)
|
||||
, mgr(new OEManager(SoundFactoryPtr(new SOUND_FACTORY)))
|
||||
, updater(mgr)
|
||||
, cameraTracker(mgr)
|
||||
, mCurrentPlaylist(NULL)
|
||||
{
|
||||
if(useSound)
|
||||
{
|
||||
// The music library will accept these filetypes
|
||||
// If none is given then it will accept all filetypes
|
||||
std::vector<std::string> acceptableExtensions;
|
||||
acceptableExtensions.push_back(".mp3");
|
||||
acceptableExtensions.push_back(".wav");
|
||||
acceptableExtensions.push_back(".ogg");
|
||||
acceptableExtensions.push_back(".flac");
|
||||
|
||||
// Makes a list of all sound files, searches in reverse for priority reasons
|
||||
for (Files::PathContainer::const_reverse_iterator it = dataDirs.rbegin(); it != dataDirs.rend(); ++it)
|
||||
{
|
||||
Files::FileLister(*it / std::string("Sound"), mSoundFiles, true);
|
||||
}
|
||||
|
||||
// Makes a FileLibrary of all music files, searches in reverse for priority reasons
|
||||
for (Files::PathContainer::const_reverse_iterator it = dataDirs.rbegin(); it != dataDirs.rend(); ++it)
|
||||
{
|
||||
mMusicLibrary.add(*it / std::string("Music"), true, mFSStrict, acceptableExtensions);
|
||||
}
|
||||
|
||||
std::string anything = "anything"; // anything is better that a segfault
|
||||
mCurrentPlaylist = mMusicLibrary.section(anything, mFSStrict); // now points to an empty path
|
||||
if(!useSound)
|
||||
return;
|
||||
|
||||
std::cout << "Sound output: " << SOUND_OUT << std::endl;
|
||||
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
||||
// Attach the camera to the camera tracker
|
||||
cameraTracker.followCamera(camera);
|
||||
|
||||
// Tell Ogre to update the sound system each frame
|
||||
root->addFrameListener(&updater);
|
||||
try
|
||||
{
|
||||
mOutput.reset(new DEFAULT_OUTPUT(*this));
|
||||
|
||||
std::vector<std::string> names = mOutput->enumerate();
|
||||
std::cout <<"Enumerated output devices:"<< std::endl;
|
||||
for(size_t i = 0;i < names.size();i++)
|
||||
std::cout <<" "<<names[i]<< std::endl;
|
||||
|
||||
mOutput->init();
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout <<"Sound init failed: "<<e.what()<< std::endl;
|
||||
mOutput.reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SoundManager::~SoundManager()
|
||||
{
|
||||
Ogre::Root::getSingleton().removeFrameListener(&updater);
|
||||
cameraTracker.unfollowCamera();
|
||||
mActiveSounds.clear();
|
||||
mMusic.reset();
|
||||
mOutput.reset();
|
||||
}
|
||||
|
||||
// Return a new decoder instance, used as needed by the output implementations
|
||||
DecoderPtr SoundManager::getDecoder()
|
||||
{
|
||||
return DecoderPtr(new DEFAULT_DECODER);
|
||||
}
|
||||
|
||||
// Convert a soundId to file name, and modify the volume
|
||||
|
@ -116,7 +87,8 @@ namespace MWSound
|
|||
float &volume, float &min, float &max)
|
||||
{
|
||||
const ESM::Sound *snd = mEnvironment.mWorld->getStore().sounds.search(soundId);
|
||||
if(snd == NULL) return "";
|
||||
if(snd == NULL)
|
||||
throw std::runtime_error(std::string("Failed to lookup sound ")+soundId);
|
||||
|
||||
if(snd->data.volume == 0)
|
||||
volume = 0.0f;
|
||||
|
@ -136,248 +108,93 @@ namespace MWSound
|
|||
max = std::max(min, max);
|
||||
}
|
||||
|
||||
return Files::FileListLocator(mSoundFiles, snd->sound, mFSStrict);
|
||||
return std::string("Sound/")+snd->sound;
|
||||
}
|
||||
|
||||
// Add a sound to the list and play it
|
||||
void SoundManager::add(const std::string &file,
|
||||
MWWorld::Ptr ptr,
|
||||
const std::string &id,
|
||||
float volume, float pitch,
|
||||
float min, float max,
|
||||
bool loop)
|
||||
{
|
||||
try
|
||||
{
|
||||
SoundPtr snd = mgr->load(file);
|
||||
snd->setRepeat(loop);
|
||||
snd->setVolume(volume);
|
||||
snd->setPitch(pitch);
|
||||
snd->setRange(min,max);
|
||||
setPos(snd, ptr);
|
||||
snd->play();
|
||||
|
||||
sounds[ptr][id] = WSoundPtr(snd);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
std::cout << "Error loading " << file << ", skipping.\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Clears all the sub-elements of a given iterator, and then
|
||||
// removes it from 'sounds'.
|
||||
void SoundManager::clearAll(PtrMap::iterator& it)
|
||||
{
|
||||
IDMap::iterator sit = it->second.begin();
|
||||
|
||||
while(sit != it->second.end())
|
||||
{
|
||||
// Get sound pointer, if any
|
||||
SoundPtr snd = sit->second.lock();
|
||||
|
||||
// Stop the sound
|
||||
if(snd) snd->stop();
|
||||
|
||||
sit++;
|
||||
}
|
||||
|
||||
// Remove the ptr reference
|
||||
sounds.erase(it);
|
||||
}
|
||||
|
||||
// Stop a sound and remove it from the list. If id="" then
|
||||
// remove the entire object and stop all its sounds.
|
||||
void SoundManager::remove(MWWorld::Ptr ptr, const std::string &id)
|
||||
{
|
||||
PtrMap::iterator it = sounds.find(ptr);
|
||||
if(it != sounds.end())
|
||||
{
|
||||
if(id == "")
|
||||
// Kill all references to 'ptr'
|
||||
clearAll(it);
|
||||
else
|
||||
{
|
||||
// Only find the id we're looking for
|
||||
IDMap::iterator it2 = it->second.find(id);
|
||||
if(it2 != it->second.end())
|
||||
{
|
||||
// Stop the sound and remove it from the list
|
||||
SoundPtr snd = it2->second.lock();
|
||||
if(snd) snd->stop();
|
||||
it->second.erase(it2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SoundManager::isPlaying(MWWorld::Ptr ptr, const std::string &id) const
|
||||
{
|
||||
PtrMap::const_iterator it = sounds.find(ptr);
|
||||
if(it != sounds.end())
|
||||
SoundMap::const_iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
IDMap::const_iterator it2 = it->second.find(id);
|
||||
if(it2 != it->second.end())
|
||||
{
|
||||
// Get a shared_ptr from the weak_ptr
|
||||
SoundPtr snd = it2->second.lock();;
|
||||
|
||||
// Is it still alive?
|
||||
if(snd)
|
||||
{
|
||||
// Then return its status!
|
||||
return snd->isPlaying();
|
||||
if(snditer->second.first == ptr && snditer->second.second == id)
|
||||
return snditer->first->isPlaying();
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Nothing found, sound is not playing
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove all references to objects belonging to a given cell
|
||||
void SoundManager::removeCell(const MWWorld::Ptr::CellStore *cell)
|
||||
{
|
||||
PtrMap::iterator it2, it = sounds.begin();
|
||||
while(it != sounds.end())
|
||||
{
|
||||
// Make sure to increase the iterator before we erase it.
|
||||
it2 = it++;
|
||||
if(it2->first.getCell() == cell)
|
||||
clearAll(it2);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::updatePositions(MWWorld::Ptr ptr)
|
||||
{
|
||||
// Find the reference (if any)
|
||||
PtrMap::iterator it = sounds.find(ptr);
|
||||
if(it != sounds.end())
|
||||
{
|
||||
// Then find all sounds in it (if any)
|
||||
IDMap::iterator it2 = it->second.begin();
|
||||
for(;it2 != it->second.end(); it2++)
|
||||
{
|
||||
// Get the sound (if it still exists)
|
||||
SoundPtr snd = it2->second.lock();
|
||||
if(snd)
|
||||
// Update position
|
||||
setPos(snd, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::stopMusic()
|
||||
{
|
||||
if (music)
|
||||
music->stop();
|
||||
setPlaylist();
|
||||
if(mMusic)
|
||||
mMusic->stop();
|
||||
mMusic.reset();
|
||||
}
|
||||
|
||||
|
||||
void SoundManager::streamMusicFull(const std::string& filename)
|
||||
{
|
||||
// Play the sound and tell it to stream, if possible. TODO:
|
||||
// Store the reference, the jukebox will need to check status,
|
||||
// control volume etc.
|
||||
if (music)
|
||||
music->stop();
|
||||
music = mgr->load(filename);
|
||||
music->setStreaming(true);
|
||||
music->setVolume(0.4);
|
||||
music->play();
|
||||
|
||||
}
|
||||
|
||||
void SoundManager::streamMusic(const std::string& filename)
|
||||
{
|
||||
std::string filePath = mMusicLibrary.locate(filename, mFSStrict).string();
|
||||
if(!filePath.empty())
|
||||
{
|
||||
streamMusicFull(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::startRandomTitle()
|
||||
{
|
||||
if(mCurrentPlaylist && !mCurrentPlaylist->empty())
|
||||
{
|
||||
Files::PathContainer::const_iterator fileIter = mCurrentPlaylist->begin();
|
||||
srand( time(NULL) );
|
||||
int r = rand() % mCurrentPlaylist->size() + 1; //old random code
|
||||
|
||||
std::advance(fileIter, r - 1);
|
||||
std::string music = fileIter->string();
|
||||
std::cout << "Playing " << music << "\n";
|
||||
|
||||
std::cout <<"Playing "<<filename<< std::endl;
|
||||
try
|
||||
{
|
||||
streamMusicFull(music);
|
||||
if(mMusic)
|
||||
mMusic->stop();
|
||||
mMusic = mOutput->streamSound(filename, 0.4f, 1.0f);
|
||||
mMusic->mBaseVolume = 0.4f;
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout << "Music Error: " << e.what() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::streamMusic(const std::string& filename)
|
||||
{
|
||||
streamMusicFull("Music/"+filename);
|
||||
}
|
||||
|
||||
void SoundManager::startRandomTitle()
|
||||
{
|
||||
Ogre::StringVectorPtr filelist;
|
||||
filelist = mResourceMgr.findResourceNames(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
"Music/"+mCurrentPlaylist+"/*");
|
||||
if(!filelist->size())
|
||||
return;
|
||||
|
||||
int i = rand()%filelist->size();
|
||||
streamMusicFull((*filelist)[i]);
|
||||
}
|
||||
|
||||
bool SoundManager::isMusicPlaying()
|
||||
{
|
||||
bool test = false;
|
||||
if(music)
|
||||
{
|
||||
test = music->isPlaying();
|
||||
}
|
||||
return test;
|
||||
return mMusic && mMusic->isPlaying();
|
||||
}
|
||||
|
||||
bool SoundManager::setPlaylist(std::string playlist)
|
||||
{
|
||||
const Files::PathContainer* previousPlaylist;
|
||||
previousPlaylist = mCurrentPlaylist;
|
||||
if (playlist == "")
|
||||
{
|
||||
mCurrentPlaylist = mMusicLibrary.section(playlist, mFSStrict);
|
||||
}
|
||||
else if(mMusicLibrary.containsSection(playlist, mFSStrict))
|
||||
{
|
||||
mCurrentPlaylist = mMusicLibrary.section(playlist, mFSStrict);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Warning: playlist named " << playlist << " does not exist.\n";
|
||||
}
|
||||
return previousPlaylist == mCurrentPlaylist;
|
||||
}
|
||||
|
||||
void SoundManager::playPlaylist(std::string playlist)
|
||||
{
|
||||
if (playlist == "")
|
||||
{
|
||||
if(!isMusicPlaying())
|
||||
void SoundManager::playPlaylist(const std::string &playlist)
|
||||
{
|
||||
mCurrentPlaylist = playlist;
|
||||
startRandomTitle();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!setPlaylist(playlist))
|
||||
{
|
||||
startRandomTitle();
|
||||
}
|
||||
else if (!isMusicPlaying())
|
||||
{
|
||||
startRandomTitle();
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::say(MWWorld::Ptr ptr, const std::string& filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
// The range values are not tested
|
||||
std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict);
|
||||
if(!filePath.empty())
|
||||
add(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false);
|
||||
else
|
||||
std::cout << "Sound file " << filename << " not found, skipping.\n";
|
||||
float basevol = 1.0f; /* TODO: volume settings */
|
||||
std::string filePath = std::string("Sound/")+filename;
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
|
||||
SoundPtr sound = mOutput->playSound3D(filePath, pos.pos, basevol, 1.0f,
|
||||
20.0f, 12750.0f, false);
|
||||
sound->mBaseVolume = basevol;
|
||||
|
||||
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout <<"Sound Error: "<<e.what()<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool SoundManager::sayDone(MWWorld::Ptr ptr) const
|
||||
|
@ -386,116 +203,176 @@ namespace MWSound
|
|||
}
|
||||
|
||||
|
||||
void SoundManager::playSound(const std::string& soundId, float volume, float pitch, bool loop)
|
||||
SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, bool loop)
|
||||
{
|
||||
SoundPtr sound;
|
||||
try
|
||||
{
|
||||
float basevol = 1.0f; /* TODO: volume settings */
|
||||
float min, max;
|
||||
const std::string &file = lookup(soundId, volume, min, max);
|
||||
if (file != "")
|
||||
{
|
||||
SoundPtr snd = mgr->load(file);
|
||||
snd->setRepeat(loop);
|
||||
snd->setVolume(volume);
|
||||
snd->setRange(min,max);
|
||||
snd->setPitch(pitch);
|
||||
snd->play();
|
||||
std::string file = lookup(soundId, basevol, min, max);
|
||||
|
||||
if (loop)
|
||||
sound = mOutput->playSound(file, volume*basevol, pitch, loop);
|
||||
sound->mVolume = volume;
|
||||
sound->mBaseVolume = basevol;
|
||||
sound->mMinDistance = min;
|
||||
sound->mMaxDistance = max;
|
||||
|
||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
// Only add the looping sound once
|
||||
IDMap::iterator it = mLoopedSounds.find(soundId);
|
||||
if(it == mLoopedSounds.end())
|
||||
{
|
||||
mLoopedSounds[soundId] = WSoundPtr(snd);
|
||||
}
|
||||
}
|
||||
std::cout <<"Sound Error: "<<e.what()<< std::endl;
|
||||
}
|
||||
return sound;
|
||||
}
|
||||
|
||||
void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId,
|
||||
float volume, float pitch, bool loop)
|
||||
SoundPtr SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
||||
float volume, float pitch, bool loop,
|
||||
bool untracked)
|
||||
{
|
||||
SoundPtr sound;
|
||||
try
|
||||
{
|
||||
// Look up the sound in the ESM data
|
||||
float basevol = 1.0f; /* TODO: volume settings */
|
||||
float min, max;
|
||||
const std::string &file = lookup(soundId, volume, min, max);
|
||||
if (file != "")
|
||||
add(file, ptr, soundId, volume, pitch, min, max, loop);
|
||||
std::string file = lookup(soundId, basevol, min, max);
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
|
||||
sound = mOutput->playSound3D(file, pos.pos, volume*basevol, pitch, min, max, loop);
|
||||
sound->mVolume = volume;
|
||||
sound->mBaseVolume = basevol;
|
||||
sound->mMinDistance = min;
|
||||
sound->mMaxDistance = max;
|
||||
|
||||
mActiveSounds[sound] = (!untracked ? std::make_pair(ptr, soundId) :
|
||||
std::make_pair(MWWorld::Ptr(), soundId));
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
std::cout <<"Sound Error: "<<e.what()<< std::endl;
|
||||
}
|
||||
return sound;
|
||||
}
|
||||
|
||||
void SoundManager::stopSound3D(MWWorld::Ptr ptr, const std::string& soundId)
|
||||
{
|
||||
remove(ptr, soundId);
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
if(snditer->second.first == ptr && snditer->second.second == soundId)
|
||||
{
|
||||
snditer->first->stop();
|
||||
mActiveSounds.erase(snditer++);
|
||||
}
|
||||
else
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell)
|
||||
void SoundManager::stopSound3D(MWWorld::Ptr ptr)
|
||||
{
|
||||
removeCell(cell);
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
if(snditer->second.first == ptr)
|
||||
{
|
||||
snditer->first->stop();
|
||||
mActiveSounds.erase(snditer++);
|
||||
}
|
||||
else
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::stopSound(const MWWorld::Ptr::CellStore *cell)
|
||||
{
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
if(snditer->second.first != MWWorld::Ptr() &&
|
||||
snditer->second.first.getCell() == cell)
|
||||
{
|
||||
snditer->first->stop();
|
||||
mActiveSounds.erase(snditer++);
|
||||
}
|
||||
else
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::stopSound(const std::string& soundId)
|
||||
{
|
||||
IDMap::iterator it = mLoopedSounds.find(soundId);
|
||||
if(it != mLoopedSounds.end())
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
SoundPtr snd = it->second.lock();
|
||||
if(snd) snd->stop();
|
||||
mLoopedSounds.erase(it);
|
||||
if(snditer->second.first == MWWorld::Ptr() &&
|
||||
snditer->second.second == soundId)
|
||||
{
|
||||
snditer->first->stop();
|
||||
mActiveSounds.erase(snditer++);
|
||||
}
|
||||
else
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
|
||||
bool SoundManager::getSoundPlaying(MWWorld::Ptr ptr, const std::string& soundId) const
|
||||
{
|
||||
// Mark all sounds as playing, otherwise the scripts will just
|
||||
// keep trying to play them every frame.
|
||||
|
||||
return isPlaying(ptr, soundId);
|
||||
}
|
||||
|
||||
void SoundManager::updateObject(MWWorld::Ptr ptr)
|
||||
{
|
||||
updatePositions(ptr);
|
||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
if(snditer->second.first == ptr)
|
||||
snditer->first->update(pos.pos);
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::update (float duration)
|
||||
void SoundManager::updateRegionSound(float duration)
|
||||
{
|
||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
||||
static int total = 0;
|
||||
static std::string regionName = "";
|
||||
static float timePassed = 0.0;
|
||||
timePassed += duration;
|
||||
|
||||
//If the region has changed
|
||||
if(!(current->cell->data.flags & current->cell->Interior) && timePassed >= 10)
|
||||
{
|
||||
|
||||
ESM::Region test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
||||
|
||||
timePassed += duration;
|
||||
if((current->cell->data.flags & current->cell->Interior) || timePassed < 10)
|
||||
return;
|
||||
timePassed = 0;
|
||||
|
||||
if(regionName != current->cell->region)
|
||||
{
|
||||
regionName = current->cell->region;
|
||||
total = 0;
|
||||
}
|
||||
|
||||
if(test.soundList.size() > 0)
|
||||
{
|
||||
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
|
||||
//mEnvironment.mSoundManager
|
||||
const ESM::Region *regn = mEnvironment.mWorld->getStore().regions.find(regionName);
|
||||
std::vector<ESM::Region::SoundRef>::const_iterator soundIter;
|
||||
if(total == 0)
|
||||
{
|
||||
while (soundIter != test.soundList.end())
|
||||
soundIter = regn->soundList.begin();
|
||||
while(soundIter != regn->soundList.end())
|
||||
{
|
||||
int chance = (int) soundIter->chance;
|
||||
//ESM::NAME32 go = soundIter->sound;
|
||||
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
||||
total += (int)soundIter->chance;
|
||||
soundIter++;
|
||||
total += chance;
|
||||
}
|
||||
if(total == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
int r = rand() % total; //old random code
|
||||
int r = (int)(rand()/((double)RAND_MAX+1) * total);
|
||||
int pos = 0;
|
||||
soundIter = test.soundList.begin();
|
||||
while (soundIter != test.soundList.end())
|
||||
|
||||
soundIter = regn->soundList.begin();
|
||||
while(soundIter != regn->soundList.end())
|
||||
{
|
||||
const std::string go = soundIter->sound.toString();
|
||||
int chance = (int) soundIter->chance;
|
||||
|
@ -505,18 +382,112 @@ namespace MWSound
|
|||
{
|
||||
//play sound
|
||||
std::cout << "Sound: " << go <<" Chance:" << chance << "\n";
|
||||
mEnvironment.mSoundManager->playSound(go, 20.0, 1.0);
|
||||
|
||||
playSound(go, 1.0f, 1.0f);
|
||||
break;
|
||||
}
|
||||
pos += chance;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(current->cell->data.flags & current->cell->Interior)
|
||||
|
||||
void SoundManager::updateSounds(float duration)
|
||||
{
|
||||
regionName = "";
|
||||
static float timePassed = 0.0;
|
||||
|
||||
timePassed += duration;
|
||||
if(timePassed < (1.0f/30.0f))
|
||||
return;
|
||||
timePassed = 0.0f;
|
||||
|
||||
// Make sure music is still playing
|
||||
if(!isMusicPlaying())
|
||||
startRandomTitle();
|
||||
|
||||
Ogre::Camera *cam = mEnvironment.mWorld->getPlayer().getRenderer()->getCamera();
|
||||
Ogre::Vector3 nPos, nDir, nUp;
|
||||
nPos = cam->getRealPosition();
|
||||
nDir = cam->getRealDirection();
|
||||
nUp = cam->getRealUp();
|
||||
|
||||
// The output handler is expecting vectors oriented like the game
|
||||
// (that is, -Z goes down, +Y goes forward), but that's not what we
|
||||
// get from Ogre's camera, so we have to convert.
|
||||
float pos[3] = { nPos[0], -nPos[2], nPos[1] };
|
||||
float at[3] = { nDir[0], -nDir[2], nDir[1] };
|
||||
float up[3] = { nUp[0], -nUp[2], nUp[1] };
|
||||
mOutput->updateListener(pos, at, up);
|
||||
|
||||
// Check if any sounds are finished playing, and trash them
|
||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||
while(snditer != mActiveSounds.end())
|
||||
{
|
||||
if(!snditer->first->isPlaying())
|
||||
mActiveSounds.erase(snditer++);
|
||||
else
|
||||
snditer++;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::update(float duration)
|
||||
{
|
||||
updateSounds(duration);
|
||||
updateRegionSound(duration);
|
||||
}
|
||||
|
||||
|
||||
// Default readAll implementation, for decoders that can't do anything
|
||||
// better
|
||||
void Sound_Decoder::readAll(std::vector<char> &output)
|
||||
{
|
||||
size_t total = output.size();
|
||||
size_t got;
|
||||
|
||||
output.resize(total+32768);
|
||||
while((got=read(&output[total], output.size()-total)) > 0)
|
||||
{
|
||||
total += got;
|
||||
output.resize(total*2);
|
||||
}
|
||||
output.resize(total);
|
||||
}
|
||||
|
||||
|
||||
const char *getSampleTypeName(SampleType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case SampleType_UInt8: return "U8";
|
||||
case SampleType_Int16: return "S16";
|
||||
}
|
||||
return "(unknown sample type)";
|
||||
}
|
||||
|
||||
const char *getChannelConfigName(ChannelConfig config)
|
||||
{
|
||||
switch(config)
|
||||
{
|
||||
case ChannelConfig_Mono: return "Mono";
|
||||
case ChannelConfig_Stereo: return "Stereo";
|
||||
}
|
||||
return "(unknown channel config)";
|
||||
}
|
||||
|
||||
size_t framesToBytes(size_t frames, ChannelConfig config, SampleType type)
|
||||
{
|
||||
switch(config)
|
||||
{
|
||||
case ChannelConfig_Mono: frames *= 1; break;
|
||||
case ChannelConfig_Stereo: frames *= 2; break;
|
||||
}
|
||||
switch(type)
|
||||
{
|
||||
case SampleType_UInt8: frames *= 1; break;
|
||||
case SampleType_Int16: frames *= 2; break;
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
|
||||
size_t bytesToFrames(size_t bytes, ChannelConfig config, SampleType type)
|
||||
{
|
||||
return bytes / framesToBytes(1, config, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
#define GAME_SOUND_SOUNDMANAGER_H
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <map>
|
||||
|
||||
#include <mangle/sound/clients/ogre_output_updater.hpp>
|
||||
#include <mangle/sound/clients/ogre_listener_mover.hpp>
|
||||
|
||||
#include <openengine/sound/sndmanager.hpp>
|
||||
|
||||
#include <components/files/filelibrary.hpp>
|
||||
#include <OgreResourceGroupManager.h>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
|
@ -19,16 +16,6 @@ namespace Ogre
|
|||
class Camera;
|
||||
}
|
||||
|
||||
namespace Mangle
|
||||
{
|
||||
namespace Sound
|
||||
{
|
||||
typedef boost::shared_ptr<Sound> SoundPtr;
|
||||
}
|
||||
}
|
||||
|
||||
typedef OEngine::Sound::SoundManagerPtr OEManagerPtr;
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
struct Environment;
|
||||
|
@ -36,69 +23,44 @@ namespace MWWorld
|
|||
|
||||
namespace MWSound
|
||||
{
|
||||
class Sound_Output;
|
||||
struct Sound_Decoder;
|
||||
class Sound;
|
||||
|
||||
typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;
|
||||
typedef boost::shared_ptr<Sound> SoundPtr;
|
||||
|
||||
class SoundManager
|
||||
{
|
||||
|
||||
// This is used for case insensitive and slash-type agnostic file
|
||||
// finding. It takes DOS paths (any case, \\ slashes or / slashes)
|
||||
// relative to the sound dir, and translates them into full paths
|
||||
// of existing files in the filesystem, if they exist.
|
||||
bool mFSStrict;
|
||||
Ogre::ResourceGroupManager& mResourceMgr;
|
||||
|
||||
MWWorld::Environment& mEnvironment;
|
||||
|
||||
void streamMusicFull (const std::string& filename);
|
||||
///< Play a soundifle
|
||||
/// \param absolute filename
|
||||
std::auto_ptr<Sound_Output> mOutput;
|
||||
|
||||
/* This is the sound manager. It loades, stores and deletes
|
||||
sounds based on the sound factory it is given.
|
||||
*/
|
||||
OEManagerPtr mgr;
|
||||
Mangle::Sound::SoundPtr music;
|
||||
boost::shared_ptr<Sound> mMusic;
|
||||
std::string mCurrentPlaylist;
|
||||
|
||||
/* This class calls update() on the sound manager each frame
|
||||
using and Ogre::FrameListener
|
||||
*/
|
||||
Mangle::Sound::OgreOutputUpdater updater;
|
||||
|
||||
/* This class tracks the movement of an Ogre::Camera and moves
|
||||
a sound listener automatically to follow it.
|
||||
*/
|
||||
Mangle::Sound::OgreListenerMover cameraTracker;
|
||||
|
||||
typedef std::map<std::string,Mangle::Sound::WSoundPtr> IDMap;
|
||||
typedef std::map<MWWorld::Ptr,IDMap> PtrMap;
|
||||
PtrMap sounds;
|
||||
|
||||
// A list of all sound files used to lookup paths
|
||||
Files::PathContainer mSoundFiles;
|
||||
|
||||
// A library of all Music file paths stored by the folder they are contained in
|
||||
Files::FileLibrary mMusicLibrary;
|
||||
|
||||
// Points to the current playlist of music files stored in the music library
|
||||
const Files::PathContainer* mCurrentPlaylist;
|
||||
|
||||
IDMap mLoopedSounds;
|
||||
typedef std::pair<MWWorld::Ptr,std::string> PtrIDPair;
|
||||
typedef std::map<SoundPtr,PtrIDPair> SoundMap;
|
||||
SoundMap mActiveSounds;
|
||||
|
||||
std::string lookup(const std::string &soundId,
|
||||
float &volume, float &min, float &max);
|
||||
void add(const std::string &file,
|
||||
MWWorld::Ptr ptr, const std::string &id,
|
||||
float volume, float pitch, float min, float max,
|
||||
bool loop);
|
||||
void clearAll(PtrMap::iterator& it);
|
||||
void remove(MWWorld::Ptr ptr, const std::string &id = "");
|
||||
void streamMusicFull(const std::string& filename);
|
||||
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
|
||||
void removeCell(const MWWorld::Ptr::CellStore *cell);
|
||||
void updatePositions(MWWorld::Ptr ptr);
|
||||
void updateSounds(float duration);
|
||||
void updateRegionSound(float duration);
|
||||
|
||||
SoundManager(const SoundManager &rhs);
|
||||
SoundManager& operator=(const SoundManager &rhs);
|
||||
|
||||
protected:
|
||||
DecoderPtr getDecoder();
|
||||
friend class OpenAL_Output;
|
||||
|
||||
public:
|
||||
|
||||
SoundManager(Ogre::Root*, Ogre::Camera*,
|
||||
const Files::PathContainer& dataDir, bool useSound, bool fsstrict,
|
||||
MWWorld::Environment& environment);
|
||||
SoundManager(bool useSound, MWWorld::Environment& environment);
|
||||
~SoundManager();
|
||||
|
||||
void stopMusic();
|
||||
|
@ -114,16 +76,9 @@ namespace MWSound
|
|||
bool isMusicPlaying();
|
||||
///< Returns true if music is playing
|
||||
|
||||
bool setPlaylist(std::string playlist="");
|
||||
///< Set the playlist to an existing folder
|
||||
/// \param name of the folder that contains the playlist
|
||||
/// if none is set then it is set to an empty playlist
|
||||
/// \return Return true if the previous playlist was the same
|
||||
|
||||
void playPlaylist(std::string playlist="");
|
||||
void playPlaylist(const std::string &playlist);
|
||||
///< Start playing music from the selected folder
|
||||
/// \param name of the folder that contains the playlist
|
||||
/// if none is set then it plays from the current playlist
|
||||
|
||||
void say(MWWorld::Ptr reference, const std::string& filename);
|
||||
///< Make an actor say some text.
|
||||
|
@ -132,18 +87,21 @@ namespace MWSound
|
|||
bool sayDone(MWWorld::Ptr reference) const;
|
||||
///< Is actor not speaking?
|
||||
|
||||
void playSound (const std::string& soundId, float volume, float pitch, bool loop=false);
|
||||
SoundPtr playSound(const std::string& soundId, float volume, float pitch, bool loop=false);
|
||||
///< Play a sound, independently of 3D-position
|
||||
|
||||
void playSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
||||
float volume, float pitch, bool loop);
|
||||
SoundPtr playSound3D(MWWorld::Ptr reference, const std::string& soundId,
|
||||
float volume, float pitch, bool loop,
|
||||
bool untracked=false);
|
||||
///< Play a sound from an object
|
||||
|
||||
void stopSound3D (MWWorld::Ptr reference, const std::string& soundId = "");
|
||||
///< Stop the given object from playing the given sound, If no soundId is given,
|
||||
/// all sounds for this reference will stop.
|
||||
void stopSound3D(MWWorld::Ptr reference, const std::string& soundId);
|
||||
///< Stop the given object from playing the given sound,
|
||||
|
||||
void stopSound (MWWorld::Ptr::CellStore *cell);
|
||||
void stopSound3D(MWWorld::Ptr reference);
|
||||
///< Stop the given object from playing all sounds.
|
||||
|
||||
void stopSound(const MWWorld::Ptr::CellStore *cell);
|
||||
///< Stop all sounds for the given cell.
|
||||
|
||||
void stopSound(const std::string& soundId);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue