mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Merge remote-tracking branch 'zini/master' into sound
Conflicts: apps/openmw/mwsound/soundmanagerimp.cpp apps/openmw/mwsound/soundmanagerimp.hpp
This commit is contained in:
commit
991f942fba
1
.gitignore
vendored
1
.gitignore
vendored
@ -13,3 +13,4 @@ cmake_install.cmake
|
|||||||
Makefile
|
Makefile
|
||||||
makefile
|
makefile
|
||||||
data
|
data
|
||||||
|
*.kdev4
|
||||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "extern/shiny"]
|
||||||
|
path = extern/shiny
|
||||||
|
url = git://github.com/scrawl/shiny.git
|
163
CMakeLists.txt
163
CMakeLists.txt
@ -15,7 +15,7 @@ include (OpenMWMacros)
|
|||||||
# Version
|
# Version
|
||||||
|
|
||||||
set (OPENMW_VERSION_MAJOR 0)
|
set (OPENMW_VERSION_MAJOR 0)
|
||||||
set (OPENMW_VERSION_MINOR 16)
|
set (OPENMW_VERSION_MINOR 18)
|
||||||
set (OPENMW_VERSION_RELEASE 0)
|
set (OPENMW_VERSION_RELEASE 0)
|
||||||
|
|
||||||
set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
|
set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
|
||||||
@ -31,12 +31,17 @@ option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries
|
|||||||
option(BUILD_ESMTOOL "build ESM inspector" ON)
|
option(BUILD_ESMTOOL "build ESM inspector" ON)
|
||||||
option(BUILD_LAUNCHER "build Launcher" ON)
|
option(BUILD_LAUNCHER "build Launcher" ON)
|
||||||
option(BUILD_MWINIIMPORTER "build MWiniImporter" ON)
|
option(BUILD_MWINIIMPORTER "build MWiniImporter" ON)
|
||||||
|
option(BUILD_WITH_CODE_COVERAGE "Enable code coverage with gconv" OFF)
|
||||||
|
option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest ang GMock frameworks" OFF)
|
||||||
|
|
||||||
# Sound source selection
|
# Sound source selection
|
||||||
option(USE_FFMPEG "use ffmpeg for sound" OFF)
|
option(USE_FFMPEG "use ffmpeg for sound" OFF)
|
||||||
option(USE_AUDIERE "use audiere for sound" OFF)
|
option(USE_AUDIERE "use audiere for sound" OFF)
|
||||||
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
|
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
|
||||||
|
|
||||||
|
# OS X deployment
|
||||||
|
option(OPENMW_OSX_DEPLOYMENT OFF)
|
||||||
|
|
||||||
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
|
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
|
||||||
|
|
||||||
# Location of morrowind data files
|
# Location of morrowind data files
|
||||||
@ -93,20 +98,14 @@ ENDIF()
|
|||||||
|
|
||||||
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
|
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
|
||||||
|
|
||||||
set(MANGLE_VFS ${LIBDIR}/mangle/vfs/servers/ogre_vfs.cpp)
|
|
||||||
set(MANGLE_INPUT ${LIBDIR}/mangle/input/servers/ois_driver.cpp)
|
|
||||||
set(MANGLE_ALL ${MANGLE_VFS} ${MANGLE_INPUT})
|
|
||||||
source_group(libs\\mangle FILES ${MANGLE_ALL})
|
|
||||||
|
|
||||||
set(OENGINE_OGRE
|
set(OENGINE_OGRE
|
||||||
${LIBDIR}/openengine/ogre/renderer.cpp
|
${LIBDIR}/openengine/ogre/renderer.cpp
|
||||||
${LIBDIR}/openengine/ogre/mouselook.cpp
|
|
||||||
${LIBDIR}/openengine/ogre/fader.cpp
|
${LIBDIR}/openengine/ogre/fader.cpp
|
||||||
${LIBDIR}/openengine/ogre/imagerotate.cpp
|
${LIBDIR}/openengine/ogre/imagerotate.cpp
|
||||||
${LIBDIR}/openengine/ogre/atlas.cpp
|
${LIBDIR}/openengine/ogre/atlas.cpp
|
||||||
|
${LIBDIR}/openengine/ogre/selectionbuffer.cpp
|
||||||
)
|
)
|
||||||
set(OENGINE_GUI
|
set(OENGINE_GUI
|
||||||
${LIBDIR}/openengine/gui/events.cpp
|
|
||||||
${LIBDIR}/openengine/gui/manager.cpp
|
${LIBDIR}/openengine/gui/manager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ set(OENGINE_BULLET
|
|||||||
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET})
|
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_BULLET})
|
||||||
source_group(libs\\openengine FILES ${OENGINE_ALL})
|
source_group(libs\\openengine FILES ${OENGINE_ALL})
|
||||||
|
|
||||||
set(OPENMW_LIBS ${MANGLE_ALL} ${OENGINE_ALL})
|
set(OPENMW_LIBS ${OENGINE_ALL})
|
||||||
set(OPENMW_LIBS_HEADER)
|
set(OPENMW_LIBS_HEADER)
|
||||||
|
|
||||||
# Sound setup
|
# Sound setup
|
||||||
@ -187,14 +186,24 @@ if (UNIX AND NOT APPLE)
|
|||||||
find_package (Threads)
|
find_package (Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# find boost without components so we can use Boost_VERSION
|
||||||
|
find_package(Boost REQUIRED)
|
||||||
|
|
||||||
|
set(BOOST_COMPONENTS system filesystem program_options thread)
|
||||||
|
|
||||||
|
if (Boost_VERSION LESS 104900)
|
||||||
|
set(SHINY_USE_WAVE_SYSTEM_INSTALL "TRUE")
|
||||||
|
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} wave)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(OGRE REQUIRED)
|
find_package(OGRE REQUIRED)
|
||||||
find_package(MyGUI REQUIRED)
|
find_package(MyGUI REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
|
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||||
find_package(OIS REQUIRED)
|
find_package(OIS REQUIRED)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
find_package(Bullet REQUIRED)
|
find_package(Bullet REQUIRED)
|
||||||
IF(OGRE_STATIC)
|
IF(OGRE_STATIC)
|
||||||
find_package(Cg REQUIRED)
|
find_package(Cg)
|
||||||
IF(WIN32)
|
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})
|
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)
|
ELSE(WIN32)
|
||||||
@ -221,8 +230,50 @@ if (APPLE)
|
|||||||
${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL}
|
${OGRE_Plugin_OctreeSceneManager_LIBRARY_REL}
|
||||||
${OGRE_Plugin_CgProgramManager_LIBRARY_REL}
|
${OGRE_Plugin_CgProgramManager_LIBRARY_REL}
|
||||||
${OGRE_Plugin_ParticleFX_LIBRARY_REL})
|
${OGRE_Plugin_ParticleFX_LIBRARY_REL})
|
||||||
|
|
||||||
|
if (${OGRE_PLUGIN_DIR_REL}})
|
||||||
|
set(OGRE_PLUGINS_REL_FOUND TRUE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (${OGRE_PLUGIN_DIR_DBG})
|
||||||
|
set(OGRE_PLUGINS_DBG_FOUND TRUE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (${OGRE_PLUGINS_REL_FOUND})
|
||||||
|
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
|
||||||
|
else ()
|
||||||
|
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
|
||||||
|
|
||||||
|
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
|
||||||
|
"${APP_BUNDLE_DIR}/Contents/Info.plist")
|
||||||
|
|
||||||
|
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
|
||||||
|
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
|
# Set up DEBUG define
|
||||||
|
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG DEBUG=1)
|
||||||
|
|
||||||
|
# Set up Ogre plugin folder & debug suffix
|
||||||
|
if (APPLE)
|
||||||
|
# Ogre on OS X doesn't use "_d" suffix (see Ogre's CMakeLists.txt)
|
||||||
|
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="")
|
||||||
|
else ()
|
||||||
|
add_definitions(-DOGRE_PLUGIN_DEBUG_SUFFIX="_d")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-DOGRE_PLUGIN_DIR_REL="${OGRE_PLUGIN_DIR_REL}")
|
||||||
|
add_definitions(-DOGRE_PLUGIN_DIR_DBG="${OGRE_PLUGIN_DIR_DBG}")
|
||||||
|
if (APPLE AND OPENMW_OSX_DEPLOYMENT)
|
||||||
|
add_definitions(-DOGRE_PLUGIN_DIR="${APP_BUNDLE_NAME}/Contents/Plugins")
|
||||||
|
else()
|
||||||
|
add_definitions(-DOGRE_PLUGIN_DIR="${OGRE_PLUGIN_DIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(files/)
|
add_subdirectory(files/)
|
||||||
add_subdirectory(files/mygui)
|
add_subdirectory(files/mygui)
|
||||||
|
|
||||||
@ -247,53 +298,12 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local
|
|||||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
||||||
"${OpenMW_BINARY_DIR}/openmw.cfg.install")
|
"${OpenMW_BINARY_DIR}/openmw.cfg.install")
|
||||||
|
|
||||||
if (WIN32)
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32
|
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
|
|
||||||
endif (WIN32)
|
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux
|
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg")
|
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop
|
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop
|
||||||
"${OpenMW_BINARY_DIR}/openmw.desktop")
|
"${OpenMW_BINARY_DIR}/openmw.desktop")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
if (${OGRE_PLUGIN_DIR_REL}})
|
|
||||||
set(OGRE_PLUGINS_REL_FOUND TRUE)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (${OGRE_PLUGIN_DIR_DBG})
|
|
||||||
set(OGRE_PLUGINS_DBG_FOUND TRUE)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (${OGRE_PLUGINS_REL_FOUND})
|
|
||||||
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_REL})
|
|
||||||
else ()
|
|
||||||
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_DBG})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
set(OGRE_PLUGIN_DIR "${OGRE_PLUGIN_DIR}/")
|
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac
|
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg")
|
|
||||||
|
|
||||||
set(OGRE_PLUGIN_DIR_2 ${OGRE_PLUGIN_DIR})
|
|
||||||
set(OGRE_PLUGIN_DIR "")
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac
|
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg.install")
|
|
||||||
set(OGRE_PLUGIN_DIR ${OGRE_PLUGIN_DIR_2})
|
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/mac/Info.plist
|
|
||||||
"${APP_BUNDLE_DIR}/Contents/Info.plist")
|
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/mac/openmw.icns
|
|
||||||
"${APP_BUNDLE_DIR}/Contents/Resources/OpenMW.icns" COPYONLY)
|
|
||||||
endif (APPLE)
|
|
||||||
|
|
||||||
|
|
||||||
# Compiler settings
|
# Compiler settings
|
||||||
if (CMAKE_COMPILER_IS_GNUCC)
|
if (CMAKE_COMPILER_IS_GNUCC)
|
||||||
add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder)
|
add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder)
|
||||||
@ -330,7 +340,6 @@ if(DPKG_PROGRAM)
|
|||||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
||||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
|
|
||||||
|
|
||||||
#Install resources
|
#Install resources
|
||||||
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources")
|
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources")
|
||||||
@ -347,7 +356,7 @@ if(DPKG_PROGRAM)
|
|||||||
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
||||||
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
||||||
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
|
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW esmtool;Esmtool omwlauncher;OMWLauncher mwiniimporter;MWiniImporter")
|
||||||
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_DEPENDS "libboost-filesystem1.46.1 (>= 1.46.1), libboost-program-options1.46.1 (>= 1.46.1), libboost-system1.46.1 (>= 1.46.1), libboost-thread1.46.1 (>= 1.46.1), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.3.0 (>= 1.3.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2), libqtgui4 (>= 4.7.0)")
|
||||||
|
|
||||||
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
|
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
|
||||||
|
|
||||||
@ -368,7 +377,6 @@ if(WIN32)
|
|||||||
INSTALL(FILES ${dll_files} DESTINATION ".")
|
INSTALL(FILES ${dll_files} DESTINATION ".")
|
||||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "." RENAME "openmw.cfg")
|
||||||
INSTALL(FILES
|
INSTALL(FILES
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg"
|
|
||||||
"${OpenMW_SOURCE_DIR}/readme.txt"
|
"${OpenMW_SOURCE_DIR}/readme.txt"
|
||||||
"${OpenMW_SOURCE_DIR}/GPL3.txt"
|
"${OpenMW_SOURCE_DIR}/GPL3.txt"
|
||||||
"${OpenMW_SOURCE_DIR}/OFL.txt"
|
"${OpenMW_SOURCE_DIR}/OFL.txt"
|
||||||
@ -432,6 +440,10 @@ if(WIN32)
|
|||||||
include(CPack)
|
include(CPack)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
|
# Extern
|
||||||
|
add_subdirectory (extern/shiny)
|
||||||
|
add_subdirectory (extern/oics)
|
||||||
|
|
||||||
# Components
|
# Components
|
||||||
add_subdirectory (components)
|
add_subdirectory (components)
|
||||||
|
|
||||||
@ -450,6 +462,11 @@ if (BUILD_MWINIIMPORTER)
|
|||||||
add_subdirectory( apps/mwiniimporter )
|
add_subdirectory( apps/mwiniimporter )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# UnitTests
|
||||||
|
if (BUILD_UNITTESTS)
|
||||||
|
add_subdirectory( apps/openmw_test_suite )
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
if (USE_DEBUG_CONSOLE)
|
if (USE_DEBUG_CONSOLE)
|
||||||
@ -496,6 +513,7 @@ if (WIN32)
|
|||||||
4309 # Variable overflow, trying to store 128 in a signed char for example
|
4309 # Variable overflow, trying to store 128 in a signed char for example
|
||||||
4355 # Using 'this' in member initialization list
|
4355 # Using 'this' in member initialization list
|
||||||
4701 # Potentially uninitialized local variable used
|
4701 # Potentially uninitialized local variable used
|
||||||
|
4800 # Boolean optimization warning, e.g. myBool = (myInt != 0) instead of myBool = myInt
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(d ${WARNINGS_DISABLE})
|
foreach(d ${WARNINGS_DISABLE})
|
||||||
@ -507,6 +525,7 @@ if (WIN32)
|
|||||||
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
set_target_properties(omwlauncher PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
endif (BUILD_LAUNCHER)
|
endif (BUILD_LAUNCHER)
|
||||||
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
set_target_properties(openmw PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
|
set_target_properties(esmtool PROPERTIES COMPILE_FLAGS ${WARNINGS})
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
# Same for MinGW
|
# Same for MinGW
|
||||||
@ -537,7 +556,6 @@ if (APPLE)
|
|||||||
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||||
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||||
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||||
install(FILES "${OpenMW_BINARY_DIR}/plugins.cfg.install" RENAME "plugins.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
|
||||||
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
install(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||||
|
|
||||||
install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||||
@ -614,3 +632,36 @@ if (APPLE)
|
|||||||
" COMPONENT Runtime)
|
" COMPONENT Runtime)
|
||||||
include(CPack)
|
include(CPack)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
|
if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
|
||||||
|
## Non Debian based Linux building
|
||||||
|
# paths
|
||||||
|
set(BINDIR "${CMAKE_INSTALL_PREFIX}/usr/bin" CACHE PATH "Where to install binaries")
|
||||||
|
set(DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "Sets the root of data directories to a non-default location")
|
||||||
|
set(DATADIR "${DATAROOTDIR}/openmw" CACHE PATH "Sets the openmw data directories to a non-default location")
|
||||||
|
set(DOCDIR "${DATAROOTDIR}/doc/openmw" CACHE PATH "Sets the doc directory to a non-default location.")
|
||||||
|
set(MANDIR "${DATAROOTDIR}/man" CACHE PATH "Where to install manpages")
|
||||||
|
set(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc/openmw" CACHE PATH "Set config dir")
|
||||||
|
set(ICONDIR "${DATAROOTDIR}/pixmaps" CACHE PATH "Set icon dir")
|
||||||
|
|
||||||
|
# Install binaries
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/openmw" DESTINATION "${BINDIR}" )
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/omwlauncher" DESTINATION "${BINDIR}" )
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/esmtool" DESTINATION "${BINDIR}" )
|
||||||
|
INSTALL(PROGRAMS "${OpenMW_BINARY_DIR}/mwiniimport" DESTINATION "${BINDIR}" )
|
||||||
|
|
||||||
|
# Install icon and .desktop
|
||||||
|
INSTALL(FILES "${OpenMW_SOURCE_DIR}/apps/launcher/resources/images/openmw.png" DESTINATION "${ICONDIR}")
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.desktop" DESTINATION "${DATAROOTDIR}/applications")
|
||||||
|
|
||||||
|
# Install global configuration files
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "${SYSCONFDIR}" RENAME "openmw.cfg" )
|
||||||
|
#INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${SYSCONFDIR}" )
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" )
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" )
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.cfg" DESTINATION "${SYSCONFDIR}" )
|
||||||
|
|
||||||
|
# Install resources
|
||||||
|
INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" )
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.qss" DESTINATION "${DATADIR}/resources" )
|
||||||
|
endif(NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE)
|
||||||
|
@ -17,3 +17,8 @@ target_link_libraries(esmtool
|
|||||||
# find_library(CARBON_FRAMEWORK Carbon)
|
# find_library(CARBON_FRAMEWORK Carbon)
|
||||||
# target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
# target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||||
#endif (APPLE)
|
#endif (APPLE)
|
||||||
|
|
||||||
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
|
add_definitions (--coverage)
|
||||||
|
target_link_libraries(esmtool gcov)
|
||||||
|
endif()
|
||||||
|
@ -187,7 +187,7 @@ int main(int argc, char**argv)
|
|||||||
case REC_ALCH:
|
case REC_ALCH:
|
||||||
{
|
{
|
||||||
Potion p;
|
Potion p;
|
||||||
p.load(esm);
|
p.load(esm, id);
|
||||||
if(quiet) break;
|
if(quiet) break;
|
||||||
cout << " Name: " << p.name << endl;
|
cout << " Name: " << p.name << endl;
|
||||||
break;
|
break;
|
||||||
@ -226,7 +226,7 @@ int main(int argc, char**argv)
|
|||||||
case REC_BOOK:
|
case REC_BOOK:
|
||||||
{
|
{
|
||||||
Book b;
|
Book b;
|
||||||
b.load(esm);
|
b.load(esm, id);
|
||||||
if(quiet) break;
|
if(quiet) break;
|
||||||
cout << " Name: " << b.name << endl;
|
cout << " Name: " << b.name << endl;
|
||||||
cout << " Mesh: " << b.model << endl;
|
cout << " Mesh: " << b.model << endl;
|
||||||
|
@ -100,3 +100,8 @@ else()
|
|||||||
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg
|
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg
|
||||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg")
|
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
|
add_definitions (--coverage)
|
||||||
|
target_link_libraries(omwlauncher gcov)
|
||||||
|
endif()
|
||||||
|
@ -189,74 +189,8 @@ void DataFilesPage::setupConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DataFilesPage::setupDataFiles()
|
void DataFilesPage::addDataFiles(Files::Collections &fileCollections, const QString &encoding)
|
||||||
{
|
{
|
||||||
// We use the Configuration Manager to retrieve the configuration values
|
|
||||||
boost::program_options::variables_map variables;
|
|
||||||
boost::program_options::options_description desc;
|
|
||||||
|
|
||||||
desc.add_options()
|
|
||||||
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
|
||||||
// ("data-local", boost::program_options::value<std::string>()->default_value(""))
|
|
||||||
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
|
||||||
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
|
||||||
|
|
||||||
mCfgMgr.readConfiguration(variables, desc);
|
|
||||||
|
|
||||||
// Put the paths in a boost::filesystem vector to use with Files::Collections
|
|
||||||
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
|
||||||
|
|
||||||
// std::string local = variables["data-local"].as<std::string>();
|
|
||||||
// if (!local.empty()) {
|
|
||||||
// mDataLocal.push_back(Files::PathContainer::value_type(local));
|
|
||||||
// dataDirs.push_back(Files::PathContainer::value_type(local));
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (mDataDirs.size()>1)
|
|
||||||
mDataDirs.resize (1);
|
|
||||||
|
|
||||||
mCfgMgr.processPaths(mDataDirs);
|
|
||||||
|
|
||||||
while (mDataDirs.empty()) {
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setWindowTitle("Error detecting Morrowind installation");
|
|
||||||
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> \
|
|
||||||
Press \"Browse...\" to specify the location manually.<br>"));
|
|
||||||
|
|
||||||
QAbstractButton *dirSelectButton =
|
|
||||||
msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole);
|
|
||||||
|
|
||||||
msgBox.exec();
|
|
||||||
|
|
||||||
if (msgBox.clickedButton() == dirSelectButton) {
|
|
||||||
|
|
||||||
// Show a custom dir selection dialog which only accepts valid dirs
|
|
||||||
QString selectedDir = FileDialog::getExistingDirectory(
|
|
||||||
this, tr("Select Data Files Directory"),
|
|
||||||
QDir::currentPath(),
|
|
||||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
|
||||||
|
|
||||||
// Add the user selected data directory
|
|
||||||
if (!selectedDir.isEmpty()) {
|
|
||||||
mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString()));
|
|
||||||
mCfgMgr.processPaths(mDataDirs);
|
|
||||||
} else {
|
|
||||||
// Cancel from within the dir selection dialog
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Cancel
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a file collection for the data dirs
|
|
||||||
Files::Collections fileCollections(mDataDirs, !variables["fs-strict"].as<bool>());
|
|
||||||
|
|
||||||
// First we add all the master files
|
// First we add all the master files
|
||||||
const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm");
|
const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm");
|
||||||
unsigned int i = 0; // Row number
|
unsigned int i = 0; // Row number
|
||||||
@ -284,7 +218,7 @@ bool DataFilesPage::setupDataFiles()
|
|||||||
ESMReader fileReader;
|
ESMReader fileReader;
|
||||||
QStringList availableMasters; // Will contain all found masters
|
QStringList availableMasters; // Will contain all found masters
|
||||||
|
|
||||||
fileReader.setEncoding(variables["encoding"].as<std::string>());
|
fileReader.setEncoding(encoding.toStdString());
|
||||||
fileReader.open(iter->second.string());
|
fileReader.open(iter->second.string());
|
||||||
|
|
||||||
// First we fill the availableMasters and the mMastersWidget
|
// First we fill the availableMasters and the mMastersWidget
|
||||||
@ -351,10 +285,86 @@ bool DataFilesPage::setupDataFiles()
|
|||||||
|
|
||||||
} catch(std::runtime_error &e) {
|
} catch(std::runtime_error &e) {
|
||||||
// An error occurred while reading the .esp
|
// An error occurred while reading the .esp
|
||||||
|
std::cerr << "Error reading .esp: " << e.what() << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DataFilesPage::setupDataFiles()
|
||||||
|
{
|
||||||
|
// We use the Configuration Manager to retrieve the configuration values
|
||||||
|
boost::program_options::variables_map variables;
|
||||||
|
boost::program_options::options_description desc;
|
||||||
|
|
||||||
|
desc.add_options()
|
||||||
|
("data", boost::program_options::value<Files::PathContainer>()->default_value(Files::PathContainer(), "data")->multitoken())
|
||||||
|
("data-local", boost::program_options::value<std::string>()->default_value(""))
|
||||||
|
("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false))
|
||||||
|
("encoding", boost::program_options::value<std::string>()->default_value("win1252"));
|
||||||
|
|
||||||
|
mCfgMgr.readConfiguration(variables, desc);
|
||||||
|
|
||||||
|
// Put the paths in a boost::filesystem vector to use with Files::Collections
|
||||||
|
mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>());
|
||||||
|
|
||||||
|
std::string local = variables["data-local"].as<std::string>();
|
||||||
|
if (!local.empty()) {
|
||||||
|
mDataLocal.push_back(Files::PathContainer::value_type(local));
|
||||||
|
}
|
||||||
|
|
||||||
|
mCfgMgr.processPaths(mDataDirs);
|
||||||
|
mCfgMgr.processPaths(mDataLocal);
|
||||||
|
|
||||||
|
while (mDataDirs.empty()) {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setWindowTitle("Error detecting Morrowind installation");
|
||||||
|
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> \
|
||||||
|
Press \"Browse...\" to specify the location manually.<br>"));
|
||||||
|
|
||||||
|
QAbstractButton *dirSelectButton =
|
||||||
|
msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole);
|
||||||
|
|
||||||
|
msgBox.exec();
|
||||||
|
|
||||||
|
if (msgBox.clickedButton() == dirSelectButton) {
|
||||||
|
|
||||||
|
// Show a custom dir selection dialog which only accepts valid dirs
|
||||||
|
QString selectedDir = FileDialog::getExistingDirectory(
|
||||||
|
this, tr("Select Data Files Directory"),
|
||||||
|
QDir::currentPath(),
|
||||||
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||||
|
|
||||||
|
// Add the user selected data directory
|
||||||
|
if (!selectedDir.isEmpty()) {
|
||||||
|
mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString()));
|
||||||
|
mCfgMgr.processPaths(mDataDirs);
|
||||||
|
} else {
|
||||||
|
// Cancel from within the dir selection dialog
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Cancel
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the plugins in the data directories
|
||||||
|
Files::Collections dataCollections(mDataDirs, !variables["fs-strict"].as<bool>());
|
||||||
|
Files::Collections dataLocalCollections(mDataLocal, !variables["fs-strict"].as<bool>());
|
||||||
|
|
||||||
|
addDataFiles(dataCollections, QString::fromStdString(variables["encoding"].as<std::string>()));
|
||||||
|
addDataFiles(dataLocalCollections, QString::fromStdString(variables["encoding"].as<std::string>()));
|
||||||
|
|
||||||
|
mDataFilesModel->sort(0);
|
||||||
|
|
||||||
readConfig();
|
readConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1140,11 +1150,13 @@ void DataFilesPage::writeConfig(QString profile)
|
|||||||
path = QString::fromStdString(it->string());
|
path = QString::fromStdString(it->string());
|
||||||
path.remove(QChar('\"'));
|
path.remove(QChar('\"'));
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
// Make sure the string is quoted when it contains spaces
|
// Make sure the string is quoted when it contains spaces
|
||||||
if (path.contains(" ")) {
|
if (path.contains(" ")) {
|
||||||
gameConfig << "data=\"" << path << "\"" << endl;
|
gameConfig << "data=\"" << dir.absolutePath() << "\"" << endl;
|
||||||
} else {
|
} else {
|
||||||
gameConfig << "data=" << path << endl;
|
gameConfig << "data=" << dir.absolutePath() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1153,10 +1165,12 @@ void DataFilesPage::writeConfig(QString profile)
|
|||||||
path = QString::fromStdString(mDataLocal.front().string());
|
path = QString::fromStdString(mDataLocal.front().string());
|
||||||
path.remove(QChar('\"'));
|
path.remove(QChar('\"'));
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
if (path.contains(" ")) {
|
if (path.contains(" ")) {
|
||||||
gameConfig << "data-local=\"" << path << "\"" << endl;
|
gameConfig << "data-local=\"" << dir.absolutePath() << "\"" << endl;
|
||||||
} else {
|
} else {
|
||||||
gameConfig << "data-local=" << path << endl;
|
gameConfig << "data-local=" << dir.absolutePath() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ private:
|
|||||||
const QStringList checkedPlugins();
|
const QStringList checkedPlugins();
|
||||||
const QStringList selectedMasters();
|
const QStringList selectedMasters();
|
||||||
|
|
||||||
|
void addDataFiles(Files::Collections &fileCollections, const QString &encoding);
|
||||||
void addPlugins(const QModelIndex &index);
|
void addPlugins(const QModelIndex &index);
|
||||||
void removePlugins(const QModelIndex &index);
|
void removePlugins(const QModelIndex &index);
|
||||||
void uncheckPlugins();
|
void uncheckPlugins();
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <boost/math/common_factor.hpp>
|
#include <boost/math/common_factor.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
#include <components/files/ogreplugin.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "graphicspage.hpp"
|
#include "graphicspage.hpp"
|
||||||
@ -70,20 +74,13 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, QWidget *parent)
|
|||||||
|
|
||||||
bool GraphicsPage::setupOgre()
|
bool GraphicsPage::setupOgre()
|
||||||
{
|
{
|
||||||
QString pluginCfg = mCfgMgr.getPluginsConfigPath().string().c_str();
|
|
||||||
QFile file(pluginCfg);
|
|
||||||
|
|
||||||
// Create a log manager so we can surpress debug text to stdout/stderr
|
// Create a log manager so we can surpress debug text to stdout/stderr
|
||||||
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
|
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
|
||||||
logMgr->createLog((mCfgMgr.getLogPath().string() + "/launcherOgre.log"), true, false, false);
|
logMgr->createLog((mCfgMgr.getLogPath().string() + "/launcherOgre.log"), true, false, false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9)
|
|
||||||
mOgre = new Ogre::Root("", "", "./launcherOgre.log");
|
mOgre = new Ogre::Root("", "", "./launcherOgre.log");
|
||||||
#else
|
|
||||||
mOgre = new Ogre::Root(pluginCfg.toStdString(), "", "./launcherOgre.log");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
catch(Ogre::Exception &ex)
|
catch(Ogre::Exception &ex)
|
||||||
{
|
{
|
||||||
@ -93,7 +90,6 @@ bool GraphicsPage::setupOgre()
|
|||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.setText(tr("<br><b>Failed to create the Ogre::Root object</b><br><br> \
|
msgBox.setText(tr("<br><b>Failed to create the Ogre::Root object</b><br><br> \
|
||||||
Make sure the plugins.cfg is present and valid.<br><br> \
|
|
||||||
Press \"Show Details...\" for more information.<br>"));
|
Press \"Show Details...\" for more information.<br>"));
|
||||||
msgBox.setDetailedText(ogreError);
|
msgBox.setDetailedText(ogreError);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
@ -102,6 +98,31 @@ bool GraphicsPage::setupOgre()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string pluginDir;
|
||||||
|
const char* pluginEnv = getenv("OPENMW_OGRE_PLUGIN_DIR");
|
||||||
|
if (pluginEnv)
|
||||||
|
pluginDir = pluginEnv;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
||||||
|
pluginDir = ".\\";
|
||||||
|
#endif
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
pluginDir = OGRE_PLUGIN_DIR;
|
||||||
|
#endif
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||||
|
pluginDir = OGRE_PLUGIN_DIR_REL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path absPluginPath = boost::filesystem::absolute(boost::filesystem::path(pluginDir));
|
||||||
|
|
||||||
|
pluginDir = absPluginPath.string();
|
||||||
|
|
||||||
|
Files::loadOgrePlugin(pluginDir, "RenderSystem_GL", *mOgre);
|
||||||
|
Files::loadOgrePlugin(pluginDir, "RenderSystem_Direct3D9", *mOgre);
|
||||||
|
|
||||||
#ifdef ENABLE_PLUGIN_GL
|
#ifdef ENABLE_PLUGIN_GL
|
||||||
mGLPlugin = new Ogre::GLPlugin();
|
mGLPlugin = new Ogre::GLPlugin();
|
||||||
mOgre->installPlugin(mGLPlugin);
|
mOgre->installPlugin(mGLPlugin);
|
||||||
@ -177,7 +198,7 @@ void GraphicsPage::readConfig()
|
|||||||
QString resolution = QString::number(Settings::Manager::getInt("resolution x", "Video"));
|
QString resolution = QString::number(Settings::Manager::getInt("resolution x", "Video"));
|
||||||
resolution.append(" x " + QString::number(Settings::Manager::getInt("resolution y", "Video")));
|
resolution.append(" x " + QString::number(Settings::Manager::getInt("resolution y", "Video")));
|
||||||
|
|
||||||
int resIndex = mResolutionComboBox->findText(resolution);
|
int resIndex = mResolutionComboBox->findText(resolution, Qt::MatchStartsWith);
|
||||||
if (resIndex != -1)
|
if (resIndex != -1)
|
||||||
mResolutionComboBox->setCurrentIndex(resIndex);
|
mResolutionComboBox->setCurrentIndex(resIndex);
|
||||||
}
|
}
|
||||||
@ -189,8 +210,8 @@ void GraphicsPage::writeConfig()
|
|||||||
Settings::Manager::setString("antialiasing", "Video", mAntiAliasingComboBox->currentText().toStdString());
|
Settings::Manager::setString("antialiasing", "Video", mAntiAliasingComboBox->currentText().toStdString());
|
||||||
Settings::Manager::setString("render system", "Video", mRendererComboBox->currentText().toStdString());
|
Settings::Manager::setString("render system", "Video", mRendererComboBox->currentText().toStdString());
|
||||||
|
|
||||||
// parse resolution x and y from a string like "800 x 600"
|
// Get the current resolution, but with the tabs replaced with a single space
|
||||||
QString resolution = mResolutionComboBox->currentText();
|
QString resolution = mResolutionComboBox->currentText().simplified();
|
||||||
QStringList tokens = resolution.split(" ", QString::SkipEmptyParts);
|
QStringList tokens = resolution.split(" ", QString::SkipEmptyParts);
|
||||||
|
|
||||||
int resX = tokens.at(0).toInt();
|
int resX = tokens.at(0).toInt();
|
||||||
@ -249,8 +270,9 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
|||||||
|
|
||||||
Ogre::StringVector::iterator opt_it;
|
Ogre::StringVector::iterator opt_it;
|
||||||
uint idx = 0;
|
uint idx = 0;
|
||||||
|
|
||||||
for (opt_it = i->second.possibleValues.begin ();
|
for (opt_it = i->second.possibleValues.begin ();
|
||||||
opt_it != i->second.possibleValues.end (); opt_it++, idx++)
|
opt_it != i->second.possibleValues.end (); opt_it++, idx++)
|
||||||
{
|
{
|
||||||
QString qval = QString::fromStdString(*opt_it).simplified();
|
QString qval = QString::fromStdString(*opt_it).simplified();
|
||||||
// remove extra tokens after the resolution (for example bpp, can be there or not depending on rendersystem)
|
// remove extra tokens after the resolution (for example bpp, can be there or not depending on rendersystem)
|
||||||
@ -260,7 +282,7 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
|||||||
|
|
||||||
// do not add duplicate resolutions
|
// do not add duplicate resolutions
|
||||||
if (!result.contains(resolutionStr)) {
|
if (!result.contains(resolutionStr)) {
|
||||||
// Add the aspect ratio
|
|
||||||
QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt());
|
QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt());
|
||||||
|
|
||||||
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
|
if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) {
|
||||||
@ -271,9 +293,8 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
result << resolutionStr;
|
result << resolutionStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the resolutions in descending order
|
// Sort the resolutions in descending order
|
||||||
|
@ -18,3 +18,7 @@ target_link_libraries(mwiniimport
|
|||||||
components
|
components
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
|
add_definitions (--coverage)
|
||||||
|
target_link_libraries(mwiniimport gcov)
|
||||||
|
endif()
|
||||||
|
@ -15,42 +15,43 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
|
|||||||
|
|
||||||
add_openmw_dir (mwrender
|
add_openmw_dir (mwrender
|
||||||
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects
|
renderingmanager debugging sky player animation npcanimation creatureanimation actors objects
|
||||||
renderinginterface localmap occlusionquery terrain terrainmaterial water shadows shaderhelper
|
renderinginterface localmap occlusionquery terrain terrainmaterial water shadows
|
||||||
compositors
|
compositors characterpreview externalrendering globalmap
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwinput
|
add_openmw_dir (mwinput
|
||||||
inputmanager
|
inputmanagerimp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwgui
|
add_openmw_dir (mwgui
|
||||||
text_input widgets race class birth review window_manager console dialogue
|
text_input widgets race class birth review windowmanagerimp console dialogue
|
||||||
dialogue_history window_base stats_window messagebox journalwindow charactercreation
|
dialogue_history window_base stats_window messagebox journalwindow charactercreation
|
||||||
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list
|
||||||
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
formatting inventorywindow container hud countdialog tradewindow settingswindow
|
||||||
confirmationdialog alchemywindow referenceinterface spellwindow
|
confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu
|
||||||
|
itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwdialogue
|
add_openmw_dir (mwdialogue
|
||||||
dialoguemanager journal journalentry quest topic
|
dialoguemanagerimp journalimp journalentry quest topic
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwscript
|
add_openmw_dir (mwscript
|
||||||
locals scriptmanager compilercontext interpretercontext cellextensions miscextensions
|
locals scriptmanagerimp compilercontext interpretercontext cellextensions miscextensions
|
||||||
guiextensions soundextensions skyextensions statsextensions containerextensions
|
guiextensions soundextensions skyextensions statsextensions containerextensions
|
||||||
aiextensions controlextensions extensions globalscripts ref dialogueextensions
|
aiextensions controlextensions extensions globalscripts ref dialogueextensions
|
||||||
animationextensions
|
animationextensions transformationextensions consoleextensions userextensions
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwsound
|
add_openmw_dir (mwsound
|
||||||
soundmanager openal_output audiere_decoder mpgsnd_decoder ffmpeg_decoder
|
soundmanagerimp openal_output audiere_decoder mpgsnd_decoder ffmpeg_decoder
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwworld
|
add_openmw_dir (mwworld
|
||||||
refdata world physicssystem scene globals class action nullaction actionteleport
|
refdata worldimp physicssystem scene globals class action nullaction actionteleport
|
||||||
containerstore actiontalk actiontake manualref player cellfunctors
|
containerstore actiontalk actiontake manualref player cellfunctors
|
||||||
cells localscripts customdata weather inventorystore ptr actionopen actionread
|
cells localscripts customdata weather inventorystore ptr actionopen actionread
|
||||||
actionequip timestamp actionalchemy
|
actionequip timestamp actionalchemy cellstore actionapply actioneat
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwclass
|
add_openmw_dir (mwclass
|
||||||
@ -59,12 +60,13 @@ add_openmw_dir (mwclass
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwmechanics
|
add_openmw_dir (mwmechanics
|
||||||
mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells
|
mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells
|
||||||
activespells
|
activespells npcstats aipackage aisequence
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwbase
|
add_openmw_dir (mwbase
|
||||||
environment
|
environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager
|
||||||
|
inputmanager windowmanager
|
||||||
)
|
)
|
||||||
|
|
||||||
# Main executable
|
# Main executable
|
||||||
@ -79,7 +81,6 @@ ENDIF(WIN32)
|
|||||||
ENDIF(OGRE_STATIC)
|
ENDIF(OGRE_STATIC)
|
||||||
add_executable(openmw
|
add_executable(openmw
|
||||||
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
|
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
|
||||||
${COMPONENT_FILES}
|
|
||||||
${OPENMW_FILES}
|
${OPENMW_FILES}
|
||||||
${GAME} ${GAME_HEADER}
|
${GAME} ${GAME_HEADER}
|
||||||
${APPLE_BUNDLE_RESOURCES}
|
${APPLE_BUNDLE_RESOURCES}
|
||||||
@ -101,6 +102,9 @@ target_link_libraries(openmw
|
|||||||
${BULLET_LIBRARIES}
|
${BULLET_LIBRARIES}
|
||||||
${MYGUI_LIBRARIES}
|
${MYGUI_LIBRARIES}
|
||||||
${MYGUI_PLATFORM_LIBRARIES}
|
${MYGUI_PLATFORM_LIBRARIES}
|
||||||
|
"shiny"
|
||||||
|
"shiny.OgrePlatform"
|
||||||
|
"oics"
|
||||||
components
|
components
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -111,9 +115,16 @@ endif()
|
|||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
find_library(CARBON_FRAMEWORK Carbon)
|
find_library(CARBON_FRAMEWORK Carbon)
|
||||||
target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
find_library(COCOA_FRAMEWORK Cocoa)
|
||||||
|
find_library(IOKIT_FRAMEWORK IOKit)
|
||||||
|
target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK})
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
if(DPKG_PROGRAM)
|
if(DPKG_PROGRAM)
|
||||||
INSTALL(TARGETS openmw RUNTIME DESTINATION games COMPONENT openmw)
|
INSTALL(TARGETS openmw RUNTIME DESTINATION games COMPONENT openmw)
|
||||||
endif(DPKG_PROGRAM)
|
endif(DPKG_PROGRAM)
|
||||||
|
|
||||||
|
if (BUILD_WITH_CODE_COVERAGE)
|
||||||
|
add_definitions (--coverage)
|
||||||
|
target_link_libraries(openmw gcov)
|
||||||
|
endif()
|
||||||
|
@ -1,56 +1,38 @@
|
|||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
#include "components/esm/loadcell.hpp"
|
#include "components/esm/loadcell.hpp"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
#include <OgreRenderWindow.h>
|
#include <OgreRenderWindow.h>
|
||||||
|
|
||||||
#include <MyGUI_WidgetManager.h>
|
#include <MyGUI_WidgetManager.h>
|
||||||
|
|
||||||
#include <openengine/ogre/renderer.hpp>
|
|
||||||
#include <openengine/gui/manager.hpp>
|
|
||||||
|
|
||||||
#include <components/esm/records.hpp>
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
#include <components/bsa/bsa_archive.hpp>
|
#include <components/bsa/bsa_archive.hpp>
|
||||||
#include <components/esm/esm_reader.hpp>
|
|
||||||
#include <components/files/fixedpath.hpp>
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
|
||||||
#include <components/nifoverrides/nifoverrides.hpp>
|
#include <components/nifoverrides/nifoverrides.hpp>
|
||||||
|
|
||||||
#include <components/nifbullet/bullet_nif_loader.hpp>
|
#include <components/nifbullet/bullet_nif_loader.hpp>
|
||||||
#include <components/nifogre/ogre_nif_loader.hpp>
|
#include <components/nifogre/ogre_nif_loader.hpp>
|
||||||
|
|
||||||
#include "mwinput/inputmanager.hpp"
|
#include "mwinput/inputmanagerimp.hpp"
|
||||||
|
|
||||||
#include "mwgui/window_manager.hpp"
|
#include "mwgui/windowmanagerimp.hpp"
|
||||||
#include "mwgui/cursorreplace.hpp"
|
#include "mwgui/cursorreplace.hpp"
|
||||||
|
|
||||||
#include "mwscript/scriptmanager.hpp"
|
#include "mwscript/scriptmanagerimp.hpp"
|
||||||
#include "mwscript/compilercontext.hpp"
|
|
||||||
#include "mwscript/interpretercontext.hpp"
|
|
||||||
#include "mwscript/extensions.hpp"
|
#include "mwscript/extensions.hpp"
|
||||||
#include "mwscript/globalscripts.hpp"
|
|
||||||
|
|
||||||
#include "mwsound/soundmanager.hpp"
|
#include "mwsound/soundmanagerimp.hpp"
|
||||||
|
|
||||||
#include "mwworld/world.hpp"
|
|
||||||
#include "mwworld/class.hpp"
|
#include "mwworld/class.hpp"
|
||||||
#include "mwworld/player.hpp"
|
#include "mwworld/player.hpp"
|
||||||
|
#include "mwworld/worldimp.hpp"
|
||||||
|
|
||||||
#include "mwclass/classes.hpp"
|
#include "mwclass/classes.hpp"
|
||||||
|
|
||||||
#include "mwdialogue/dialoguemanager.hpp"
|
#include "mwdialogue/dialoguemanagerimp.hpp"
|
||||||
#include "mwdialogue/journal.hpp"
|
#include "mwdialogue/journalimp.hpp"
|
||||||
|
|
||||||
#include "mwmechanics/mechanicsmanager.hpp"
|
#include "mwmechanics/mechanicsmanagerimp.hpp"
|
||||||
|
|
||||||
#include "mwbase/environment.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
void OMW::Engine::executeLocalScripts()
|
void OMW::Engine::executeLocalScripts()
|
||||||
@ -74,11 +56,8 @@ void OMW::Engine::executeLocalScripts()
|
|||||||
localScripts.setIgnore (MWWorld::Ptr());
|
localScripts.setIgnore (MWWorld::Ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::setAnimationVerbose(bool animverbose){
|
void OMW::Engine::setAnimationVerbose(bool animverbose)
|
||||||
if(animverbose){
|
{
|
||||||
NifOgre::NIFLoader::getSingletonPtr()->setOutputAnimFiles(true);
|
|
||||||
NifOgre::NIFLoader::getSingletonPtr()->setVerbosePath(mCfgMgr.getLogPath().string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
@ -88,7 +67,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||||||
mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
|
mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
|
||||||
|
|
||||||
// update input
|
// update input
|
||||||
MWBase::Environment::get().getInputManager()->update();
|
MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame, false);
|
||||||
|
|
||||||
// sound
|
// sound
|
||||||
if (mUseSound)
|
if (mUseSound)
|
||||||
@ -150,6 +129,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
|||||||
, mCompileAll (false)
|
, mCompileAll (false)
|
||||||
, mScriptContext (0)
|
, mScriptContext (0)
|
||||||
, mFSStrict (false)
|
, mFSStrict (false)
|
||||||
|
, mScriptConsoleMode (false)
|
||||||
, mCfgMgr(configurationManager)
|
, mCfgMgr(configurationManager)
|
||||||
{
|
{
|
||||||
std::srand ( std::time(NULL) );
|
std::srand ( std::time(NULL) );
|
||||||
@ -182,6 +162,10 @@ void OMW::Engine::loadBSA()
|
|||||||
dataDirectory = iter->string();
|
dataDirectory = iter->string();
|
||||||
std::cout << "Data dir " << dataDirectory << std::endl;
|
std::cout << "Data dir " << dataDirectory << std::endl;
|
||||||
Bsa::addDir(dataDirectory, mFSStrict);
|
Bsa::addDir(dataDirectory, mFSStrict);
|
||||||
|
|
||||||
|
// Workaround: Mygui does not find textures in non-BSA subfolders, _unless_ they are explicitely added like this
|
||||||
|
// For splash screens, this is OK to do, but eventually we will need an investigation why this is necessary
|
||||||
|
Bsa::addDir(dataDirectory + "/Splash", mFSStrict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +274,10 @@ void OMW::Engine::go()
|
|||||||
else if (boost::filesystem::exists(globaldefault))
|
else if (boost::filesystem::exists(globaldefault))
|
||||||
settings.loadUser(globaldefault);
|
settings.loadUser(globaldefault);
|
||||||
|
|
||||||
|
// Get the path for the keybinder xml file
|
||||||
|
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
|
||||||
|
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
||||||
|
|
||||||
mFpsLevel = settings.getInt("fps", "HUD");
|
mFpsLevel = settings.getInt("fps", "HUD");
|
||||||
|
|
||||||
// load nif overrides
|
// load nif overrides
|
||||||
@ -310,8 +298,8 @@ void OMW::Engine::go()
|
|||||||
}
|
}
|
||||||
mOgre->configure(
|
mOgre->configure(
|
||||||
mCfgMgr.getLogPath().string(),
|
mCfgMgr.getLogPath().string(),
|
||||||
mCfgMgr.getPluginsConfigPath().string(),
|
|
||||||
renderSystem,
|
renderSystem,
|
||||||
|
Settings::Manager::getString("opengl rtt mode", "Video"),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
// This has to be added BEFORE MyGUI is initialized, as it needs
|
// This has to be added BEFORE MyGUI is initialized, as it needs
|
||||||
@ -319,6 +307,8 @@ void OMW::Engine::go()
|
|||||||
|
|
||||||
//addResourcesDirectory(mResDir);
|
//addResourcesDirectory(mResDir);
|
||||||
|
|
||||||
|
addResourcesDirectory(mCfgMgr.getCachePath ().string());
|
||||||
|
|
||||||
addResourcesDirectory(mResDir / "mygui");
|
addResourcesDirectory(mResDir / "mygui");
|
||||||
addResourcesDirectory(mResDir / "water");
|
addResourcesDirectory(mResDir / "water");
|
||||||
addResourcesDirectory(mResDir / "gbuffer");
|
addResourcesDirectory(mResDir / "gbuffer");
|
||||||
@ -342,13 +332,14 @@ void OMW::Engine::go()
|
|||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster,
|
mEnvironment.setWorld (new MWWorld::World (*mOgre, mFileCollections, mMaster,
|
||||||
mResDir, mNewGame, mEncoding, mFallbackMap));
|
mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoding, mFallbackMap));
|
||||||
|
|
||||||
// Create window manager - this manages all the MW-specific GUI windows
|
// Create window manager - this manages all the MW-specific GUI windows
|
||||||
MWScript::registerExtensions (mExtensions);
|
MWScript::registerExtensions (mExtensions);
|
||||||
|
|
||||||
mEnvironment.setWindowManager (new MWGui::WindowManager(
|
mEnvironment.setWindowManager (new MWGui::WindowManager(
|
||||||
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/")));
|
mExtensions, mFpsLevel, mNewGame, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
|
||||||
|
mCfgMgr.getCachePath ().string(), mScriptConsoleMode));
|
||||||
|
|
||||||
// Create sound system
|
// Create sound system
|
||||||
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
|
mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound));
|
||||||
@ -367,11 +358,18 @@ void OMW::Engine::go()
|
|||||||
mEnvironment.setJournal (new MWDialogue::Journal);
|
mEnvironment.setJournal (new MWDialogue::Journal);
|
||||||
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
|
mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions));
|
||||||
|
|
||||||
|
// Sets up the input system
|
||||||
|
mEnvironment.setInputManager (new MWInput::InputManager (*mOgre,
|
||||||
|
MWBase::Environment::get().getWorld()->getPlayer(),
|
||||||
|
*MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists));
|
||||||
|
|
||||||
// load cell
|
// load cell
|
||||||
ESM::Position pos;
|
ESM::Position pos;
|
||||||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||||
pos.pos[2] = 0;
|
pos.pos[2] = 0;
|
||||||
|
|
||||||
|
mEnvironment.getWorld()->renderPlayer();
|
||||||
|
|
||||||
if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName))
|
if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName))
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY,
|
MWBase::Environment::get().getWorld()->indexToPosition (exterior->data.gridX, exterior->data.gridY,
|
||||||
@ -384,12 +382,6 @@ void OMW::Engine::go()
|
|||||||
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
|
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets up the input system
|
|
||||||
|
|
||||||
mEnvironment.setInputManager (new MWInput::MWInputManager (*mOgre,
|
|
||||||
MWBase::Environment::get().getWorld()->getPlayer(),
|
|
||||||
*MWBase::Environment::get().getWindowManager(), mDebug, *this));
|
|
||||||
|
|
||||||
std::cout << "\nPress Q/ESC or close window to exit.\n";
|
std::cout << "\nPress Q/ESC or close window to exit.\n";
|
||||||
|
|
||||||
mOgre->getRoot()->addFrameListener (this);
|
mOgre->getRoot()->addFrameListener (this);
|
||||||
@ -410,6 +402,9 @@ void OMW::Engine::go()
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mStartupScript.empty())
|
||||||
|
MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript);
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
mOgre->start();
|
mOgre->start();
|
||||||
|
|
||||||
@ -512,3 +507,13 @@ void OMW::Engine::setFallbackValues(std::map<std::string,std::string> fallbackMa
|
|||||||
{
|
{
|
||||||
mFallbackMap = fallbackMap;
|
mFallbackMap = fallbackMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OMW::Engine::setScriptConsoleMode (bool enabled)
|
||||||
|
{
|
||||||
|
mScriptConsoleMode = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OMW::Engine::setStartupScript (const std::string& path)
|
||||||
|
{
|
||||||
|
mStartupScript = path;
|
||||||
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#ifndef ENGINE_H
|
#ifndef ENGINE_H
|
||||||
#define ENGINE_H
|
#define ENGINE_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
#include <OgreFrameListener.h>
|
#include <OgreFrameListener.h>
|
||||||
|
|
||||||
#include <components/compiler/extensions.hpp>
|
#include <components/compiler/extensions.hpp>
|
||||||
@ -77,6 +73,8 @@ namespace OMW
|
|||||||
bool mCompileAll;
|
bool mCompileAll;
|
||||||
std::string mFocusName;
|
std::string mFocusName;
|
||||||
std::map<std::string,std::string> mFallbackMap;
|
std::map<std::string,std::string> mFallbackMap;
|
||||||
|
bool mScriptConsoleMode;
|
||||||
|
std::string mStartupScript;
|
||||||
|
|
||||||
Compiler::Extensions mExtensions;
|
Compiler::Extensions mExtensions;
|
||||||
Compiler::Context *mScriptContext;
|
Compiler::Context *mScriptContext;
|
||||||
@ -162,6 +160,12 @@ namespace OMW
|
|||||||
|
|
||||||
void setFallbackValues(std::map<std::string,std::string> map);
|
void setFallbackValues(std::map<std::string,std::string> map);
|
||||||
|
|
||||||
|
/// Enable console-only script functionality
|
||||||
|
void setScriptConsoleMode (bool enabled);
|
||||||
|
|
||||||
|
/// Set path for a script that is run on startup in the console.
|
||||||
|
void setStartupScript (const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Files::ConfigurationManager& mCfgMgr;
|
Files::ConfigurationManager& mCfgMgr;
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,5 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
|
||||||
|
|
||||||
#include <components/files/fileops.hpp>
|
|
||||||
#include <components/files/fixedpath.hpp>
|
|
||||||
#include <components/files/collections.hpp>
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
@ -16,15 +8,10 @@
|
|||||||
#include <boost/iostreams/concepts.hpp>
|
#include <boost/iostreams/concepts.hpp>
|
||||||
#include <boost/iostreams/stream_buffer.hpp>
|
#include <boost/iostreams/stream_buffer.hpp>
|
||||||
|
|
||||||
# if !defined(_DEBUG)
|
|
||||||
# include <iostream>
|
|
||||||
# include <fstream>
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// For OutputDebugString
|
// For OutputDebugString
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
// makes __argc and __argv available on windows
|
// makes __argc and __argv available on windows
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -52,8 +39,6 @@ inline boost::filesystem::path lexical_cast<boost::filesystem::path, std::string
|
|||||||
} /* namespace boost */
|
} /* namespace boost */
|
||||||
#endif /* (BOOST_VERSION <= 104600) */
|
#endif /* (BOOST_VERSION <= 104600) */
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
struct FallbackMap {
|
struct FallbackMap {
|
||||||
std::map<std::string,std::string> mMap;
|
std::map<std::string,std::string> mMap;
|
||||||
};
|
};
|
||||||
@ -139,12 +124,20 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||||||
("script-verbose", bpo::value<bool>()->implicit_value(true)
|
("script-verbose", bpo::value<bool>()->implicit_value(true)
|
||||||
->default_value(false), "verbose script output")
|
->default_value(false), "verbose script output")
|
||||||
|
|
||||||
("new-game", bpo::value<bool>()->implicit_value(true)
|
|
||||||
->default_value(false), "activate char gen/new game mechanics")
|
|
||||||
|
|
||||||
("script-all", bpo::value<bool>()->implicit_value(true)
|
("script-all", bpo::value<bool>()->implicit_value(true)
|
||||||
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
|
->default_value(false), "compile all scripts (excluding dialogue scripts) at startup")
|
||||||
|
|
||||||
|
("script-console", bpo::value<bool>()->implicit_value(true)
|
||||||
|
->default_value(false), "enable console-only script functionality")
|
||||||
|
|
||||||
|
("script-run", bpo::value<std::string>()->default_value(""),
|
||||||
|
"select a file that is executed in the console on startup\n\n"
|
||||||
|
"Note: The file contains a list of script lines, but not a complete scripts. "
|
||||||
|
"That means no begin/end and no variable declarations.")
|
||||||
|
|
||||||
|
("new-game", bpo::value<bool>()->implicit_value(true)
|
||||||
|
->default_value(false), "activate char gen/new game mechanics")
|
||||||
|
|
||||||
("fs-strict", bpo::value<bool>()->implicit_value(true)
|
("fs-strict", bpo::value<bool>()->implicit_value(true)
|
||||||
->default_value(false), "strict file system handling (no case folding)")
|
->default_value(false), "strict file system handling (no case folding)")
|
||||||
|
|
||||||
@ -214,15 +207,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||||||
std::string local(variables["data-local"].as<std::string>());
|
std::string local(variables["data-local"].as<std::string>());
|
||||||
if (!local.empty())
|
if (!local.empty())
|
||||||
{
|
{
|
||||||
std::cout << "Ignoring data-local (currently not supported)" << std::endl;
|
dataDirs.push_back(Files::PathContainer::value_type(local));
|
||||||
// dataDirs.push_back(Files::PathContainer::value_type(local));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataDirs.size()>1)
|
|
||||||
{
|
|
||||||
dataDirs.resize (1);
|
|
||||||
std::cout << "Ignoring all but the first data path (multiple data paths currently not supported)"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgMgr.processPaths(dataDirs);
|
cfgMgr.processPaths(dataDirs);
|
||||||
@ -264,6 +249,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||||||
engine.setCompileAll(variables["script-all"].as<bool>());
|
engine.setCompileAll(variables["script-all"].as<bool>());
|
||||||
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
|
engine.setAnimationVerbose(variables["anim-verbose"].as<bool>());
|
||||||
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
|
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
|
||||||
|
engine.setScriptConsoleMode (variables["script-console"].as<bool>());
|
||||||
|
engine.setStartupScript (variables["script-run"].as<std::string>());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
46
apps/openmw/mwbase/dialoguemanager.hpp
Normal file
46
apps/openmw/mwbase/dialoguemanager.hpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef GAME_MWBASE_DIALOGUEMANAGER_H
|
||||||
|
#define GAME_MWBASE_DIALOGUEMANAGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class Ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for dialogue manager (implemented in MWDialogue)
|
||||||
|
class DialogueManager
|
||||||
|
{
|
||||||
|
DialogueManager (const DialogueManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
DialogueManager& operator= (const DialogueManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DialogueManager() {}
|
||||||
|
|
||||||
|
virtual ~DialogueManager() {}
|
||||||
|
|
||||||
|
virtual void startDialogue (const MWWorld::Ptr& actor) = 0;
|
||||||
|
|
||||||
|
virtual void addTopic (const std::string& topic) = 0;
|
||||||
|
|
||||||
|
virtual void askQuestion (const std::string& question,int choice) = 0;
|
||||||
|
|
||||||
|
virtual void goodbye() = 0;
|
||||||
|
|
||||||
|
///get the faction of the actor you are talking with
|
||||||
|
virtual std::string getFaction() const = 0;
|
||||||
|
|
||||||
|
//calbacks for the GUI
|
||||||
|
virtual void keywordSelected (const std::string& keyword) = 0;
|
||||||
|
virtual void goodbyeSelected() = 0;
|
||||||
|
virtual void questionAnswered (const std::string& answer) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -3,18 +3,14 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "../mwinput/inputmanager.hpp"
|
#include "world.hpp"
|
||||||
|
#include "scriptmanager.hpp"
|
||||||
#include "../mwscript/scriptmanager.hpp"
|
#include "dialoguemanager.hpp"
|
||||||
|
#include "journal.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "soundmanager.hpp"
|
||||||
|
#include "mechanicsmanager.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "inputmanager.hpp"
|
||||||
|
#include "windowmanager.hpp"
|
||||||
#include "../mwdialogue/dialoguemanager.hpp"
|
|
||||||
#include "../mwdialogue/journal.hpp"
|
|
||||||
|
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
|
||||||
|
|
||||||
MWBase::Environment *MWBase::Environment::sThis = 0;
|
MWBase::Environment *MWBase::Environment::sThis = 0;
|
||||||
|
|
||||||
@ -32,42 +28,42 @@ MWBase::Environment::~Environment()
|
|||||||
sThis = 0;
|
sThis = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setWorld (MWWorld::World *world)
|
void MWBase::Environment::setWorld (World *world)
|
||||||
{
|
{
|
||||||
mWorld = world;
|
mWorld = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager)
|
void MWBase::Environment::setSoundManager (SoundManager *soundManager)
|
||||||
{
|
{
|
||||||
mSoundManager = soundManager;
|
mSoundManager = soundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager)
|
void MWBase::Environment::setScriptManager (ScriptManager *scriptManager)
|
||||||
{
|
{
|
||||||
mScriptManager = scriptManager;
|
mScriptManager = scriptManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager)
|
void MWBase::Environment::setWindowManager (WindowManager *windowManager)
|
||||||
{
|
{
|
||||||
mWindowManager = windowManager;
|
mWindowManager = windowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager)
|
void MWBase::Environment::setMechanicsManager (MechanicsManager *mechanicsManager)
|
||||||
{
|
{
|
||||||
mMechanicsManager = mechanicsManager;
|
mMechanicsManager = mechanicsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setDialogueManager (MWDialogue::DialogueManager *dialogueManager)
|
void MWBase::Environment::setDialogueManager (DialogueManager *dialogueManager)
|
||||||
{
|
{
|
||||||
mDialogueManager = dialogueManager;
|
mDialogueManager = dialogueManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setJournal (MWDialogue::Journal *journal)
|
void MWBase::Environment::setJournal (Journal *journal)
|
||||||
{
|
{
|
||||||
mJournal = journal;
|
mJournal = journal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager)
|
void MWBase::Environment::setInputManager (InputManager *inputManager)
|
||||||
{
|
{
|
||||||
mInputManager = inputManager;
|
mInputManager = inputManager;
|
||||||
}
|
}
|
||||||
@ -77,49 +73,49 @@ void MWBase::Environment::setFrameDuration (float duration)
|
|||||||
mFrameDuration = duration;
|
mFrameDuration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::World *MWBase::Environment::getWorld() const
|
MWBase::World *MWBase::Environment::getWorld() const
|
||||||
{
|
{
|
||||||
assert (mWorld);
|
assert (mWorld);
|
||||||
return mWorld;
|
return mWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWSound::SoundManager *MWBase::Environment::getSoundManager() const
|
MWBase::SoundManager *MWBase::Environment::getSoundManager() const
|
||||||
{
|
{
|
||||||
assert (mSoundManager);
|
assert (mSoundManager);
|
||||||
return mSoundManager;
|
return mSoundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWScript::ScriptManager *MWBase::Environment::getScriptManager() const
|
MWBase::ScriptManager *MWBase::Environment::getScriptManager() const
|
||||||
{
|
{
|
||||||
assert (mScriptManager);
|
assert (mScriptManager);
|
||||||
return mScriptManager;
|
return mScriptManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWGui::WindowManager *MWBase::Environment::getWindowManager() const
|
MWBase::WindowManager *MWBase::Environment::getWindowManager() const
|
||||||
{
|
{
|
||||||
assert (mWindowManager);
|
assert (mWindowManager);
|
||||||
return mWindowManager;
|
return mWindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const
|
MWBase::MechanicsManager *MWBase::Environment::getMechanicsManager() const
|
||||||
{
|
{
|
||||||
assert (mMechanicsManager);
|
assert (mMechanicsManager);
|
||||||
return mMechanicsManager;
|
return mMechanicsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWDialogue::DialogueManager *MWBase::Environment::getDialogueManager() const
|
MWBase::DialogueManager *MWBase::Environment::getDialogueManager() const
|
||||||
{
|
{
|
||||||
assert (mDialogueManager);
|
assert (mDialogueManager);
|
||||||
return mDialogueManager;
|
return mDialogueManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWDialogue::Journal *MWBase::Environment::getJournal() const
|
MWBase::Journal *MWBase::Environment::getJournal() const
|
||||||
{
|
{
|
||||||
assert (mJournal);
|
assert (mJournal);
|
||||||
return mJournal;
|
return mJournal;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWInput::MWInputManager *MWBase::Environment::getInputManager() const
|
MWBase::InputManager *MWBase::Environment::getInputManager() const
|
||||||
{
|
{
|
||||||
assert (mInputManager);
|
assert (mInputManager);
|
||||||
return mInputManager;
|
return mInputManager;
|
||||||
@ -150,6 +146,9 @@ void MWBase::Environment::cleanup()
|
|||||||
delete mScriptManager;
|
delete mScriptManager;
|
||||||
mScriptManager = 0;
|
mScriptManager = 0;
|
||||||
|
|
||||||
|
delete mWindowManager;
|
||||||
|
mWindowManager = 0;
|
||||||
|
|
||||||
delete mWorld;
|
delete mWorld;
|
||||||
mWorld = 0;
|
mWorld = 0;
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,17 @@
|
|||||||
#ifndef GAME_BASE_INVIRONMENT_H
|
#ifndef GAME_BASE_INVIRONMENT_H
|
||||||
#define GAME_BASE_INVIRONMENT_H
|
#define GAME_BASE_INVIRONMENT_H
|
||||||
|
|
||||||
namespace MWSound
|
|
||||||
{
|
|
||||||
class SoundManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWScript
|
|
||||||
{
|
|
||||||
class ScriptManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWGui
|
|
||||||
{
|
|
||||||
class WindowManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWMechanics
|
|
||||||
{
|
|
||||||
class MechanicsManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWDialogue
|
|
||||||
{
|
|
||||||
class DialogueManager;
|
|
||||||
class Journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWInput
|
|
||||||
{
|
|
||||||
struct MWInputManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class World;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWBase
|
namespace MWBase
|
||||||
{
|
{
|
||||||
|
class World;
|
||||||
|
class ScriptManager;
|
||||||
|
class DialogueManager;
|
||||||
|
class Journal;
|
||||||
|
class SoundManager;
|
||||||
|
class MechanicsManager;
|
||||||
|
class InputManager;
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
/// \brief Central hub for mw-subsystems
|
/// \brief Central hub for mw-subsystems
|
||||||
///
|
///
|
||||||
/// This class allows each mw-subsystem to access any others subsystem's top-level manager class.
|
/// This class allows each mw-subsystem to access any others subsystem's top-level manager class.
|
||||||
@ -49,14 +22,14 @@ namespace MWBase
|
|||||||
{
|
{
|
||||||
static Environment *sThis;
|
static Environment *sThis;
|
||||||
|
|
||||||
MWWorld::World *mWorld;
|
World *mWorld;
|
||||||
MWSound::SoundManager *mSoundManager;
|
SoundManager *mSoundManager;
|
||||||
MWScript::ScriptManager *mScriptManager;
|
ScriptManager *mScriptManager;
|
||||||
MWGui::WindowManager *mWindowManager;
|
WindowManager *mWindowManager;
|
||||||
MWMechanics::MechanicsManager *mMechanicsManager;
|
MechanicsManager *mMechanicsManager;
|
||||||
MWDialogue::DialogueManager *mDialogueManager;
|
DialogueManager *mDialogueManager;
|
||||||
MWDialogue::Journal *mJournal;
|
Journal *mJournal;
|
||||||
MWInput::MWInputManager *mInputManager;
|
InputManager *mInputManager;
|
||||||
float mFrameDuration;
|
float mFrameDuration;
|
||||||
|
|
||||||
Environment (const Environment&);
|
Environment (const Environment&);
|
||||||
@ -71,40 +44,40 @@ namespace MWBase
|
|||||||
|
|
||||||
~Environment();
|
~Environment();
|
||||||
|
|
||||||
void setWorld (MWWorld::World *world);
|
void setWorld (World *world);
|
||||||
|
|
||||||
void setSoundManager (MWSound::SoundManager *soundManager);
|
void setSoundManager (SoundManager *soundManager);
|
||||||
|
|
||||||
void setScriptManager (MWScript::ScriptManager *scriptManager);
|
void setScriptManager (MWBase::ScriptManager *scriptManager);
|
||||||
|
|
||||||
void setWindowManager (MWGui::WindowManager *windowManager);
|
void setWindowManager (WindowManager *windowManager);
|
||||||
|
|
||||||
void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager);
|
void setMechanicsManager (MechanicsManager *mechanicsManager);
|
||||||
|
|
||||||
void setDialogueManager (MWDialogue::DialogueManager *dialogueManager);
|
void setDialogueManager (DialogueManager *dialogueManager);
|
||||||
|
|
||||||
void setJournal (MWDialogue::Journal *journal);
|
void setJournal (Journal *journal);
|
||||||
|
|
||||||
void setInputManager (MWInput::MWInputManager *inputManager);
|
void setInputManager (InputManager *inputManager);
|
||||||
|
|
||||||
void setFrameDuration (float duration);
|
void setFrameDuration (float duration);
|
||||||
///< Set length of current frame in seconds.
|
///< Set length of current frame in seconds.
|
||||||
|
|
||||||
MWWorld::World *getWorld() const;
|
World *getWorld() const;
|
||||||
|
|
||||||
MWSound::SoundManager *getSoundManager() const;
|
SoundManager *getSoundManager() const;
|
||||||
|
|
||||||
MWScript::ScriptManager *getScriptManager() const;
|
ScriptManager *getScriptManager() const;
|
||||||
|
|
||||||
MWGui::WindowManager *getWindowManager() const;
|
WindowManager *getWindowManager() const;
|
||||||
|
|
||||||
MWMechanics::MechanicsManager *getMechanicsManager() const;
|
MechanicsManager *getMechanicsManager() const;
|
||||||
|
|
||||||
MWDialogue::DialogueManager *getDialogueManager() const;
|
DialogueManager *getDialogueManager() const;
|
||||||
|
|
||||||
MWDialogue::Journal *getJournal() const;
|
Journal *getJournal() const;
|
||||||
|
|
||||||
MWInput::MWInputManager *getInputManager() const;
|
InputManager *getInputManager() const;
|
||||||
|
|
||||||
float getFrameDuration() const;
|
float getFrameDuration() const;
|
||||||
|
|
||||||
|
45
apps/openmw/mwbase/inputmanager.hpp
Normal file
45
apps/openmw/mwbase/inputmanager.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef GAME_MWBASE_INPUTMANAGER_H
|
||||||
|
#define GAME_MWBASE_INPUTMANAGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for input manager (implemented in MWInput)
|
||||||
|
class InputManager
|
||||||
|
{
|
||||||
|
InputManager (const InputManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
InputManager& operator= (const InputManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
InputManager() {}
|
||||||
|
|
||||||
|
virtual ~InputManager() {}
|
||||||
|
|
||||||
|
virtual void update(float dt, bool loading) = 0;
|
||||||
|
|
||||||
|
virtual void changeInputMode(bool guiMode) = 0;
|
||||||
|
|
||||||
|
virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0;
|
||||||
|
|
||||||
|
virtual void setDragDrop(bool dragDrop) = 0;
|
||||||
|
|
||||||
|
virtual void toggleControlSwitch (const std::string& sw, bool value) = 0;
|
||||||
|
virtual bool getControlSwitch (const std::string& sw) = 0;
|
||||||
|
|
||||||
|
virtual std::string getActionDescription (int action) = 0;
|
||||||
|
virtual std::string getActionBindingName (int action) = 0;
|
||||||
|
virtual std::vector<int> getActionSorting () = 0;
|
||||||
|
virtual int getNumActions() = 0;
|
||||||
|
virtual void enableDetectingBindingMode (int action) = 0;
|
||||||
|
virtual void resetToDefaultBindings() = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
73
apps/openmw/mwbase/journal.hpp
Normal file
73
apps/openmw/mwbase/journal.hpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#ifndef GAME_MWBASE_JOURNAL_H
|
||||||
|
#define GAME_MWBASE_JOURNAL_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <deque>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "../mwdialogue/journalentry.hpp"
|
||||||
|
#include "../mwdialogue/topic.hpp"
|
||||||
|
#include "../mwdialogue/quest.hpp"
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for the player's journal (implemented in MWDialogue)
|
||||||
|
class Journal
|
||||||
|
{
|
||||||
|
Journal (const Journal&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
Journal& operator= (const Journal&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef std::deque<MWDialogue::StampedJournalEntry> TEntryContainer;
|
||||||
|
typedef TEntryContainer::const_iterator TEntryIter;
|
||||||
|
typedef std::map<std::string, MWDialogue::Quest> TQuestContainer; // topc, quest
|
||||||
|
typedef TQuestContainer::const_iterator TQuestIter;
|
||||||
|
typedef std::map<std::string, MWDialogue::Topic> TTopicContainer; // topic-id, topic-content
|
||||||
|
typedef TTopicContainer::const_iterator TTopicIter;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Journal() {}
|
||||||
|
|
||||||
|
virtual ~Journal() {}
|
||||||
|
|
||||||
|
virtual void addEntry (const std::string& id, int index) = 0;
|
||||||
|
///< Add a journal entry.
|
||||||
|
|
||||||
|
virtual void setJournalIndex (const std::string& id, int index) = 0;
|
||||||
|
///< Set the journal index without adding an entry.
|
||||||
|
|
||||||
|
virtual int getJournalIndex (const std::string& id) const = 0;
|
||||||
|
///< Get the journal index.
|
||||||
|
|
||||||
|
virtual void addTopic (const std::string& topicId, const std::string& infoId) = 0;
|
||||||
|
|
||||||
|
virtual TEntryIter begin() const = 0;
|
||||||
|
///< Iterator pointing to the begin of the main journal.
|
||||||
|
///
|
||||||
|
/// \note Iterators to main journal entries will never become invalid.
|
||||||
|
|
||||||
|
virtual TEntryIter end() const = 0;
|
||||||
|
///< Iterator pointing past the end of the main journal.
|
||||||
|
|
||||||
|
virtual TQuestIter questBegin() const = 0;
|
||||||
|
///< Iterator pointing to the first quest (sorted by topic ID)
|
||||||
|
|
||||||
|
virtual TQuestIter questEnd() const = 0;
|
||||||
|
///< Iterator pointing past the last quest.
|
||||||
|
|
||||||
|
virtual TTopicIter topicBegin() const = 0;
|
||||||
|
///< Iterator pointing to the first topic (sorted by topic ID)
|
||||||
|
///
|
||||||
|
/// \note The topic ID is identical with the user-visible topic string.
|
||||||
|
|
||||||
|
virtual TTopicIter topicEnd() const = 0;
|
||||||
|
///< Iterator pointing past the last topic.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
80
apps/openmw/mwbase/mechanicsmanager.hpp
Normal file
80
apps/openmw/mwbase/mechanicsmanager.hpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#ifndef GAME_MWBASE_MECHANICSMANAGER_H
|
||||||
|
#define GAME_MWBASE_MECHANICSMANAGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Vector3;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct Class;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class Ptr;
|
||||||
|
class CellStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for game mechanics manager (implemented in MWMechanics)
|
||||||
|
class MechanicsManager
|
||||||
|
{
|
||||||
|
MechanicsManager (const MechanicsManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
MechanicsManager& operator= (const MechanicsManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
MechanicsManager() {}
|
||||||
|
|
||||||
|
virtual ~MechanicsManager() {}
|
||||||
|
|
||||||
|
virtual void addActor (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
///< Register an actor for stats management
|
||||||
|
|
||||||
|
virtual void removeActor (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
///< Deregister an actor for stats management
|
||||||
|
|
||||||
|
virtual void dropActors (const MWWorld::CellStore *cellStore) = 0;
|
||||||
|
///< Deregister all actors in the given cell.
|
||||||
|
|
||||||
|
virtual void watchActor (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
///< On each update look for changes in a previously registered actor and update the
|
||||||
|
/// GUI accordingly.
|
||||||
|
|
||||||
|
virtual void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
|
||||||
|
float duration, bool paused) = 0;
|
||||||
|
///< Update actor stats and store desired velocity vectors in \a movement
|
||||||
|
///
|
||||||
|
/// \param paused In game type does not currently advance (this usually means some GUI
|
||||||
|
/// component is up).
|
||||||
|
|
||||||
|
virtual void setPlayerName (const std::string& name) = 0;
|
||||||
|
///< Set player name.
|
||||||
|
|
||||||
|
virtual void setPlayerRace (const std::string& id, bool male) = 0;
|
||||||
|
///< Set player race.
|
||||||
|
|
||||||
|
virtual void setPlayerBirthsign (const std::string& id) = 0;
|
||||||
|
///< Set player birthsign.
|
||||||
|
|
||||||
|
virtual void setPlayerClass (const std::string& id) = 0;
|
||||||
|
///< Set player class to stock class.
|
||||||
|
|
||||||
|
virtual void setPlayerClass (const ESM::Class& class_) = 0;
|
||||||
|
///< Set player class to custom class.
|
||||||
|
|
||||||
|
virtual void restoreDynamicStats() = 0;
|
||||||
|
///< If the player is sleeping, this should be called every hour.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
62
apps/openmw/mwbase/scriptmanager.hpp
Normal file
62
apps/openmw/mwbase/scriptmanager.hpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#ifndef GAME_MWBASE_SCRIPTMANAGER_H
|
||||||
|
#define GAME_MWBASE_SCRIPTMANAGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Interpreter
|
||||||
|
{
|
||||||
|
class Context;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Compiler
|
||||||
|
{
|
||||||
|
class Locals;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
class GlobalScripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for script manager (implemented in MWScript)
|
||||||
|
class ScriptManager
|
||||||
|
{
|
||||||
|
ScriptManager (const ScriptManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
ScriptManager& operator= (const ScriptManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ScriptManager() {}
|
||||||
|
|
||||||
|
virtual ~ScriptManager() {}
|
||||||
|
|
||||||
|
virtual void run (const std::string& name, Interpreter::Context& interpreterContext) = 0;
|
||||||
|
///< Run the script with the given name (compile first, if not compiled yet)
|
||||||
|
|
||||||
|
virtual bool compile (const std::string& name) = 0;
|
||||||
|
///< Compile script with the given namen
|
||||||
|
/// \return Success?
|
||||||
|
|
||||||
|
virtual std::pair<int, int> compileAll() = 0;
|
||||||
|
///< Compile all scripts
|
||||||
|
/// \return count, success
|
||||||
|
|
||||||
|
virtual Compiler::Locals& getLocals (const std::string& name) = 0;
|
||||||
|
///< Return locals for script \a name.
|
||||||
|
|
||||||
|
virtual MWScript::GlobalScripts& getGlobalScripts() = 0;
|
||||||
|
|
||||||
|
virtual int getLocalIndex (const std::string& scriptId, const std::string& variable,
|
||||||
|
char type) = 0;
|
||||||
|
///< Return index of the variable of the given name and type in the given script. Will
|
||||||
|
/// throw an exception, if there is no such script or variable or the type does not match.
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
126
apps/openmw/mwbase/soundmanager.hpp
Normal file
126
apps/openmw/mwbase/soundmanager.hpp
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
#ifndef GAME_MWBASE_SOUNDMANAGER_H
|
||||||
|
#define GAME_MWBASE_SOUNDMANAGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Vector3;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class CellStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWSound
|
||||||
|
{
|
||||||
|
class Sound;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
typedef boost::shared_ptr<MWSound::Sound> SoundPtr;
|
||||||
|
|
||||||
|
/// \brief Interface for sound manager (implemented in MWSound)
|
||||||
|
class SoundManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum PlayMode {
|
||||||
|
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */
|
||||||
|
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
|
||||||
|
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
|
||||||
|
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position
|
||||||
|
* but do not keep it updated (the sound will not move with
|
||||||
|
* the object and will not stop when the object is deleted. */
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
SoundManager (const SoundManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
SoundManager& operator= (const SoundManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SoundManager() {}
|
||||||
|
|
||||||
|
virtual ~SoundManager() {}
|
||||||
|
|
||||||
|
virtual void processChangedSettings(const Settings::CategorySettingVector& settings) = 0;
|
||||||
|
|
||||||
|
virtual void stopMusic() = 0;
|
||||||
|
///< Stops music if it's playing
|
||||||
|
|
||||||
|
virtual void streamMusic(const std::string& filename) = 0;
|
||||||
|
///< Play a soundifle
|
||||||
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
||||||
|
|
||||||
|
virtual void startRandomTitle() = 0;
|
||||||
|
///< Starts a random track from the current playlist
|
||||||
|
|
||||||
|
virtual bool isMusicPlaying() = 0;
|
||||||
|
///< Returns true if music is playing
|
||||||
|
|
||||||
|
virtual void playPlaylist(const std::string &playlist) = 0;
|
||||||
|
///< Start playing music from the selected folder
|
||||||
|
/// \param name of the folder that contains the playlist
|
||||||
|
|
||||||
|
virtual void say(MWWorld::Ptr reference, const std::string& filename) = 0;
|
||||||
|
///< Make an actor say some text.
|
||||||
|
/// \param filename name of a sound file in "Sound/" in the data directory.
|
||||||
|
|
||||||
|
virtual void say(const std::string& filename) = 0;
|
||||||
|
///< Say some text, without an actor ref
|
||||||
|
/// \param filename name of a sound file in "Sound/" in the data directory.
|
||||||
|
|
||||||
|
virtual bool sayDone(MWWorld::Ptr reference=MWWorld::Ptr()) const = 0;
|
||||||
|
///< Is actor not speaking?
|
||||||
|
|
||||||
|
virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()) = 0;
|
||||||
|
///< Stop an actor speaking
|
||||||
|
|
||||||
|
virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
|
||||||
|
int mode=Play_Normal) = 0;
|
||||||
|
///< Play a sound, independently of 3D-position
|
||||||
|
|
||||||
|
virtual SoundPtr playSound3D(MWWorld::Ptr reference, const std::string& soundId,
|
||||||
|
float volume, float pitch, int mode=Play_Normal) = 0;
|
||||||
|
///< Play a sound from an object
|
||||||
|
|
||||||
|
virtual void stopSound3D(MWWorld::Ptr reference, const std::string& soundId) = 0;
|
||||||
|
///< Stop the given object from playing the given sound,
|
||||||
|
|
||||||
|
virtual void stopSound3D(MWWorld::Ptr reference) = 0;
|
||||||
|
///< Stop the given object from playing all sounds.
|
||||||
|
|
||||||
|
virtual void stopSound(const MWWorld::CellStore *cell) = 0;
|
||||||
|
///< Stop all sounds for the given cell.
|
||||||
|
|
||||||
|
virtual void stopSound(const std::string& soundId) = 0;
|
||||||
|
///< Stop a non-3d looping sound
|
||||||
|
|
||||||
|
virtual bool getSoundPlaying(MWWorld::Ptr reference, const std::string& soundId) const = 0;
|
||||||
|
///< Is the given sound currently playing on the given object?
|
||||||
|
|
||||||
|
virtual void update(float duration) = 0;
|
||||||
|
|
||||||
|
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline int operator|(SoundManager::PlayMode a, SoundManager::PlayMode b)
|
||||||
|
{ return static_cast<int> (a) | static_cast<int> (b); }
|
||||||
|
inline int operator&(SoundManager::PlayMode a, SoundManager::PlayMode b)
|
||||||
|
{ return static_cast<int> (a) & static_cast<int> (b); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
233
apps/openmw/mwbase/windowmanager.hpp
Normal file
233
apps/openmw/mwbase/windowmanager.hpp
Normal file
@ -0,0 +1,233 @@
|
|||||||
|
#ifndef GAME_MWBASE_WINDOWMANAGER_H
|
||||||
|
#define GAME_MWBASE_WINDOWMANAGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/mode.hpp"
|
||||||
|
|
||||||
|
namespace MyGUI
|
||||||
|
{
|
||||||
|
class Gui;
|
||||||
|
class Widget;
|
||||||
|
class UString;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace OEngine
|
||||||
|
{
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
class Layout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct Class;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class CellStore;
|
||||||
|
class Ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
class Console;
|
||||||
|
class SpellWindow;
|
||||||
|
class TradeWindow;
|
||||||
|
class SpellBuyingWindow;
|
||||||
|
class ConfirmationDialog;
|
||||||
|
class CountDialog;
|
||||||
|
class ScrollWindow;
|
||||||
|
class BookWindow;
|
||||||
|
class InventoryWindow;
|
||||||
|
class ContainerWindow;
|
||||||
|
class DialogueWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for widnow manager (implemented in MWGui)
|
||||||
|
class WindowManager
|
||||||
|
{
|
||||||
|
WindowManager (const WindowManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
WindowManager& operator= (const WindowManager&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef std::vector<int> SkillList;
|
||||||
|
|
||||||
|
WindowManager() {}
|
||||||
|
|
||||||
|
virtual ~WindowManager() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be called each frame to update windows/gui elements.
|
||||||
|
* This could mean updating sizes of gui elements or opening
|
||||||
|
* new dialogs.
|
||||||
|
*/
|
||||||
|
virtual void update() = 0;
|
||||||
|
|
||||||
|
virtual void pushGuiMode (MWGui::GuiMode mode) = 0;
|
||||||
|
virtual void popGuiMode() = 0;
|
||||||
|
|
||||||
|
virtual void removeGuiMode (MWGui::GuiMode mode) = 0;
|
||||||
|
///< can be anywhere in the stack
|
||||||
|
|
||||||
|
virtual MWGui::GuiMode getMode() const = 0;
|
||||||
|
|
||||||
|
virtual bool isGuiMode() const = 0;
|
||||||
|
|
||||||
|
virtual void toggleVisible (MWGui::GuiWindow wnd) = 0;
|
||||||
|
|
||||||
|
/// Disallow all inventory mode windows
|
||||||
|
virtual void disallowAll() = 0;
|
||||||
|
|
||||||
|
/// Allow one or more windows
|
||||||
|
virtual void allow (MWGui::GuiWindow wnd) = 0;
|
||||||
|
|
||||||
|
virtual bool isAllowed (MWGui::GuiWindow wnd) const = 0;
|
||||||
|
|
||||||
|
/// \todo investigate, if we really need to expose every single lousy UI element to the outside world
|
||||||
|
virtual MWGui::DialogueWindow* getDialogueWindow() = 0;
|
||||||
|
virtual MWGui::ContainerWindow* getContainerWindow() = 0;
|
||||||
|
virtual MWGui::InventoryWindow* getInventoryWindow() = 0;
|
||||||
|
virtual MWGui::BookWindow* getBookWindow() = 0;
|
||||||
|
virtual MWGui::ScrollWindow* getScrollWindow() = 0;
|
||||||
|
virtual MWGui::CountDialog* getCountDialog() = 0;
|
||||||
|
virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0;
|
||||||
|
virtual MWGui::TradeWindow* getTradeWindow() = 0;
|
||||||
|
virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow() = 0;
|
||||||
|
virtual MWGui::SpellWindow* getSpellWindow() = 0;
|
||||||
|
virtual MWGui::Console* getConsole() = 0;
|
||||||
|
|
||||||
|
virtual MyGUI::Gui* getGui() const = 0;
|
||||||
|
|
||||||
|
virtual void wmUpdateFps(float fps, unsigned int triangleCount, unsigned int batchCount) = 0;
|
||||||
|
|
||||||
|
/// Set value for the given ID.
|
||||||
|
virtual void setValue (const std::string& id, const MWMechanics::Stat<int>& value) = 0;
|
||||||
|
virtual void setValue (int parSkill, const MWMechanics::Stat<float>& value) = 0;
|
||||||
|
virtual void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value) = 0;
|
||||||
|
virtual void setValue (const std::string& id, const std::string& value) = 0;
|
||||||
|
virtual void setValue (const std::string& id, int value) = 0;
|
||||||
|
|
||||||
|
virtual void setPlayerClass (const ESM::Class &class_) = 0;
|
||||||
|
///< set current class of player
|
||||||
|
|
||||||
|
virtual void configureSkills (const SkillList& major, const SkillList& minor) = 0;
|
||||||
|
///< configure skill groups, each set contains the skill ID for that group.
|
||||||
|
|
||||||
|
virtual void setReputation (int reputation) = 0;
|
||||||
|
///< set the current reputation value
|
||||||
|
|
||||||
|
virtual void setBounty (int bounty) = 0;
|
||||||
|
///< set the current bounty value
|
||||||
|
|
||||||
|
virtual void updateSkillArea() = 0;
|
||||||
|
///< update display of skills, factions, birth sign, reputation and bounty
|
||||||
|
|
||||||
|
virtual void changeCell(MWWorld::CellStore* cell) = 0;
|
||||||
|
///< change the active cell
|
||||||
|
|
||||||
|
virtual void setPlayerPos(const float x, const float y) = 0;
|
||||||
|
///< set player position in map space
|
||||||
|
|
||||||
|
virtual void setPlayerDir(const float x, const float y) = 0;
|
||||||
|
///< set player view direction in map space
|
||||||
|
|
||||||
|
virtual void setFocusObject(const MWWorld::Ptr& focus) = 0;
|
||||||
|
virtual void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y) = 0;
|
||||||
|
|
||||||
|
virtual void setMouseVisible(bool visible) = 0;
|
||||||
|
virtual void getMousePosition(int &x, int &y) = 0;
|
||||||
|
virtual void getMousePosition(float &x, float &y) = 0;
|
||||||
|
virtual void setDragDrop(bool dragDrop) = 0;
|
||||||
|
virtual bool getWorldMouseOver() = 0;
|
||||||
|
|
||||||
|
virtual void toggleFogOfWar() = 0;
|
||||||
|
|
||||||
|
virtual void toggleFullHelp() = 0;
|
||||||
|
///< show extra info in item tooltips (owner, script)
|
||||||
|
|
||||||
|
virtual bool getFullHelp() const = 0;
|
||||||
|
|
||||||
|
virtual void setInteriorMapTexture(const int x, const int y) = 0;
|
||||||
|
///< set the index of the map texture that should be used (for interiors)
|
||||||
|
|
||||||
|
/// sets the visibility of the hud health/magicka/stamina bars
|
||||||
|
virtual void setHMSVisibility(bool visible) = 0;
|
||||||
|
|
||||||
|
/// sets the visibility of the hud minimap
|
||||||
|
virtual void setMinimapVisibility(bool visible) = 0;
|
||||||
|
virtual void setWeaponVisibility(bool visible) = 0;
|
||||||
|
virtual void setSpellVisibility(bool visible) = 0;
|
||||||
|
|
||||||
|
virtual void activateQuickKey (int index) = 0;
|
||||||
|
|
||||||
|
virtual void setSelectedSpell(const std::string& spellId, int successChancePercent) = 0;
|
||||||
|
virtual void setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent) = 0;
|
||||||
|
virtual void setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent) = 0;
|
||||||
|
virtual void unsetSelectedSpell() = 0;
|
||||||
|
virtual void unsetSelectedWeapon() = 0;
|
||||||
|
|
||||||
|
virtual void showCrosshair(bool show) = 0;
|
||||||
|
virtual bool getSubtitlesEnabled() = 0;
|
||||||
|
virtual void toggleHud() = 0;
|
||||||
|
|
||||||
|
virtual void disallowMouse() = 0;
|
||||||
|
virtual void allowMouse() = 0;
|
||||||
|
virtual void notifyInputActionBound() = 0;
|
||||||
|
|
||||||
|
virtual void addVisitedLocation(const std::string& name, int x, int y) = 0;
|
||||||
|
|
||||||
|
virtual void removeDialog(OEngine::GUI::Layout* dialog) = 0;
|
||||||
|
///< Hides dialog and schedules dialog to be deleted.
|
||||||
|
|
||||||
|
virtual void messageBox (const std::string& message, const std::vector<std::string>& buttons) = 0;
|
||||||
|
virtual int readPressedButton() = 0;
|
||||||
|
///< returns the index of the pressed button or -1 if no button was pressed (->MessageBoxmanager->InteractiveMessageBox)
|
||||||
|
|
||||||
|
virtual void onFrame (float frameDuration) = 0;
|
||||||
|
|
||||||
|
/// \todo get rid of this stuff. Move it to the respective UI element classes, if needed.
|
||||||
|
virtual std::map<int, MWMechanics::Stat<float> > getPlayerSkillValues() = 0;
|
||||||
|
virtual std::map<int, MWMechanics::Stat<int> > getPlayerAttributeValues() = 0;
|
||||||
|
virtual SkillList getPlayerMinorSkills() = 0;
|
||||||
|
virtual SkillList getPlayerMajorSkills() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches a GMST string from the store, if there is no setting with the given
|
||||||
|
* ID or it is not a string the default string is returned.
|
||||||
|
*
|
||||||
|
* @param id Identifier for the GMST setting, e.g. "aName"
|
||||||
|
* @param default Default value if the GMST setting cannot be used.
|
||||||
|
*/
|
||||||
|
virtual const std::string &getGameSettingString(const std::string &id, const std::string &default_) = 0;
|
||||||
|
|
||||||
|
virtual void processChangedSettings(const Settings::CategorySettingVector& changed) = 0;
|
||||||
|
|
||||||
|
virtual void executeInConsole (const std::string& path) = 0;
|
||||||
|
|
||||||
|
virtual void setLoadingProgress (const std::string& stage, int depth, int current, int total) = 0;
|
||||||
|
virtual void loadingDone() = 0;
|
||||||
|
|
||||||
|
virtual void enableRest() = 0;
|
||||||
|
virtual bool getRestEnabled() = 0;
|
||||||
|
|
||||||
|
virtual bool getPlayerSleeping() = 0;
|
||||||
|
virtual void wakeUpPlayer() = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
297
apps/openmw/mwbase/world.hpp
Normal file
297
apps/openmw/mwbase/world.hpp
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
#ifndef GAME_MWBASE_WORLD_H
|
||||||
|
#define GAME_MWBASE_WORLD_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/globals.hpp"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Vector2;
|
||||||
|
class Vector3;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace OEngine
|
||||||
|
{
|
||||||
|
namespace Render
|
||||||
|
{
|
||||||
|
class Fader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
class ESMReader;
|
||||||
|
struct Position;
|
||||||
|
struct Cell;
|
||||||
|
struct Class;
|
||||||
|
struct Potion;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ESMS
|
||||||
|
{
|
||||||
|
struct ESMStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
class ExternalRendering;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class CellStore;
|
||||||
|
class Player;
|
||||||
|
class LocalScripts;
|
||||||
|
class Ptr;
|
||||||
|
class TimeStamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWBase
|
||||||
|
{
|
||||||
|
/// \brief Interface for the World (implemented in MWWorld)
|
||||||
|
class World
|
||||||
|
{
|
||||||
|
World (const World&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
World& operator= (const World&);
|
||||||
|
///< not implemented
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum RenderMode
|
||||||
|
{
|
||||||
|
Render_CollisionDebug,
|
||||||
|
Render_Wireframe,
|
||||||
|
Render_Pathgrid,
|
||||||
|
Render_Compositors
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DoorMarker
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
float x, y; // world position
|
||||||
|
};
|
||||||
|
|
||||||
|
World() {}
|
||||||
|
|
||||||
|
virtual ~World() {}
|
||||||
|
|
||||||
|
virtual OEngine::Render::Fader* getFader() = 0;
|
||||||
|
///< \ŧodo remove this function. Rendering details should not be exposed.
|
||||||
|
|
||||||
|
virtual MWWorld::CellStore *getExterior (int x, int y) = 0;
|
||||||
|
|
||||||
|
virtual MWWorld::CellStore *getInterior (const std::string& name) = 0;
|
||||||
|
|
||||||
|
virtual void setWaterHeight(const float height) = 0;
|
||||||
|
|
||||||
|
virtual void toggleWater() = 0;
|
||||||
|
|
||||||
|
virtual void adjustSky() = 0;
|
||||||
|
|
||||||
|
virtual void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) = 0;
|
||||||
|
|
||||||
|
virtual void setFallbackValues (const std::map<std::string, std::string>& fallbackMap) = 0;
|
||||||
|
|
||||||
|
virtual std::string getFallback (const std::string& key) const = 0;
|
||||||
|
|
||||||
|
virtual std::string getFallback (const std::string& key, const std::string& def) const = 0;
|
||||||
|
|
||||||
|
virtual MWWorld::Player& getPlayer() = 0;
|
||||||
|
|
||||||
|
virtual const ESMS::ESMStore& getStore() const = 0;
|
||||||
|
|
||||||
|
virtual ESM::ESMReader& getEsmReader() = 0;
|
||||||
|
|
||||||
|
virtual MWWorld::LocalScripts& getLocalScripts() = 0;
|
||||||
|
|
||||||
|
virtual bool hasCellChanged() const = 0;
|
||||||
|
///< Has the player moved to a different cell, since the last frame?
|
||||||
|
|
||||||
|
virtual bool isCellExterior() const = 0;
|
||||||
|
|
||||||
|
virtual bool isCellQuasiExterior() const = 0;
|
||||||
|
|
||||||
|
virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0;
|
||||||
|
///< get north vector (OGRE coordinates) for given interior cell
|
||||||
|
|
||||||
|
virtual std::vector<DoorMarker> getDoorMarkers (MWWorld::CellStore* cell) = 0;
|
||||||
|
///< get a list of teleport door markers for a given cell, to be displayed on the local map
|
||||||
|
|
||||||
|
virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y) = 0;
|
||||||
|
///< see MWRender::LocalMap::getInteriorMapPosition
|
||||||
|
|
||||||
|
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior) = 0;
|
||||||
|
///< see MWRender::LocalMap::isPositionExplored
|
||||||
|
|
||||||
|
virtual MWWorld::Globals::Data& getGlobalVariable (const std::string& name) = 0;
|
||||||
|
|
||||||
|
virtual MWWorld::Globals::Data getGlobalVariable (const std::string& name) const = 0;
|
||||||
|
|
||||||
|
virtual char getGlobalVariableType (const std::string& name) const = 0;
|
||||||
|
///< Return ' ', if there is no global variable with this name.
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr getPtr (const std::string& name, bool activeOnly) = 0;
|
||||||
|
///< Return a pointer to a liveCellRef with the given name.
|
||||||
|
/// \param activeOnly do non search inactive cells.
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
|
||||||
|
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
||||||
|
|
||||||
|
/// \todo enable reference in the OGRE scene
|
||||||
|
virtual void enable (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
|
||||||
|
/// \todo disable reference in the OGRE scene
|
||||||
|
virtual void disable (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
|
||||||
|
virtual void advanceTime (double hours) = 0;
|
||||||
|
///< Advance in-game time.
|
||||||
|
|
||||||
|
virtual void setHour (double hour) = 0;
|
||||||
|
///< Set in-game time hour.
|
||||||
|
|
||||||
|
virtual void setMonth (int month) = 0;
|
||||||
|
///< Set in-game time month.
|
||||||
|
|
||||||
|
virtual void setDay (int day) = 0;
|
||||||
|
///< Set in-game time day.
|
||||||
|
|
||||||
|
virtual int getDay() = 0;
|
||||||
|
virtual int getMonth() = 0;
|
||||||
|
|
||||||
|
virtual MWWorld::TimeStamp getTimeStamp() const = 0;
|
||||||
|
///< Return current in-game time stamp.
|
||||||
|
|
||||||
|
virtual bool toggleSky() = 0;
|
||||||
|
///< \return Resulting mode
|
||||||
|
|
||||||
|
virtual void changeWeather(const std::string& region, unsigned int id) = 0;
|
||||||
|
|
||||||
|
virtual int getCurrentWeather() const = 0;
|
||||||
|
|
||||||
|
virtual int getMasserPhase() const = 0;
|
||||||
|
|
||||||
|
virtual int getSecundaPhase() const = 0;
|
||||||
|
|
||||||
|
virtual void setMoonColour (bool red) = 0;
|
||||||
|
|
||||||
|
virtual float getTimeScaleFactor() const = 0;
|
||||||
|
|
||||||
|
virtual void changeToInteriorCell (const std::string& cellName,
|
||||||
|
const ESM::Position& position) = 0;
|
||||||
|
///< Move to interior cell.
|
||||||
|
|
||||||
|
virtual void changeToExteriorCell (const ESM::Position& position) = 0;
|
||||||
|
///< Move to exterior cell.
|
||||||
|
|
||||||
|
virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0;
|
||||||
|
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
|
||||||
|
|
||||||
|
virtual void markCellAsUnchanged() = 0;
|
||||||
|
|
||||||
|
virtual std::string getFacedHandle() = 0;
|
||||||
|
///< Return handle of the object the player is looking at
|
||||||
|
|
||||||
|
virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
|
||||||
|
virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore &newCell, float x, float y, float z) = 0;
|
||||||
|
|
||||||
|
virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
|
||||||
|
|
||||||
|
virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0;
|
||||||
|
|
||||||
|
virtual void safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos) = 0;
|
||||||
|
///< place an object in a "safe" location (ie not in the void, etc).
|
||||||
|
|
||||||
|
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
|
||||||
|
const = 0;
|
||||||
|
///< Convert cell numbers to position.
|
||||||
|
|
||||||
|
virtual void positionToIndex (float x, float y, int &cellX, int &cellY) const = 0;
|
||||||
|
///< Convert position to cell numbers
|
||||||
|
|
||||||
|
virtual void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
|
||||||
|
float duration) = 0;
|
||||||
|
///< Run physics simulation and modify \a world accordingly.
|
||||||
|
|
||||||
|
virtual bool toggleCollisionMode() = 0;
|
||||||
|
///< Toggle collision mode for player. If disabled player object should ignore
|
||||||
|
/// collisions and gravity.
|
||||||
|
/// \return Resulting mode
|
||||||
|
|
||||||
|
virtual bool toggleRenderMode (RenderMode mode) = 0;
|
||||||
|
///< Toggle a render mode.
|
||||||
|
///< \return Resulting mode
|
||||||
|
|
||||||
|
virtual std::pair<std::string, const ESM::Potion *> createRecord (const ESM::Potion& record)
|
||||||
|
= 0;
|
||||||
|
///< Create a new recrod (of type potion) in the ESM store.
|
||||||
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record)
|
||||||
|
= 0;
|
||||||
|
///< Create a new recrod (of type class) in the ESM store.
|
||||||
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0;
|
||||||
|
///< Create a new recrod (of type cell) in the ESM store.
|
||||||
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
|
||||||
|
int mode, int number = 1) = 0;
|
||||||
|
///< Run animation for a MW-reference. Calls to this function for references that are
|
||||||
|
/// currently not in the rendered scene should be ignored.
|
||||||
|
///
|
||||||
|
/// \param mode: 0 normal, 1 immediate start, 2 immediate loop
|
||||||
|
/// \param number How offen the animation should be run
|
||||||
|
|
||||||
|
virtual void skipAnimation (const MWWorld::Ptr& ptr) = 0;
|
||||||
|
///< Skip the animation for the given MW-reference for one frame. Calls to this function for
|
||||||
|
/// references that are currently not in the rendered scene should be ignored.
|
||||||
|
|
||||||
|
virtual void update (float duration) = 0;
|
||||||
|
|
||||||
|
virtual bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0;
|
||||||
|
///< place an object into the gameworld at the specified cursor position
|
||||||
|
/// @param object
|
||||||
|
/// @param cursor X (relative 0-1)
|
||||||
|
/// @param cursor Y (relative 0-1)
|
||||||
|
/// @return true if the object was placed, or false if it was rejected because the position is too far away
|
||||||
|
|
||||||
|
virtual void dropObjectOnGround (const MWWorld::Ptr& object) = 0;
|
||||||
|
|
||||||
|
virtual bool canPlaceObject (float cursorX, float cursorY) = 0;
|
||||||
|
///< @return true if it is possible to place on object at specified cursor location
|
||||||
|
|
||||||
|
virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0;
|
||||||
|
|
||||||
|
virtual bool isSwimming(const MWWorld::Ptr &object) = 0;
|
||||||
|
virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos) = 0;
|
||||||
|
|
||||||
|
virtual void togglePOV() = 0;
|
||||||
|
virtual void togglePreviewMode(bool enable) = 0;
|
||||||
|
virtual bool toggleVanityMode(bool enable, bool force) = 0;
|
||||||
|
virtual void allowVanityMode(bool allow) = 0;
|
||||||
|
virtual void togglePlayerLooking(bool enable) = 0;
|
||||||
|
|
||||||
|
virtual void renderPlayer() = 0;
|
||||||
|
|
||||||
|
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0;
|
||||||
|
|
||||||
|
virtual int canRest() = 0;
|
||||||
|
///< check if the player is allowed to rest \n
|
||||||
|
/// 0 - yes \n
|
||||||
|
/// 1 - only waiting \n
|
||||||
|
/// 2 - player is underwater \n
|
||||||
|
/// 3 - enemies are nearby (not implemented)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -3,48 +3,54 @@
|
|||||||
|
|
||||||
#include <components/esm/loadacti.hpp>
|
#include <components/esm/loadacti.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
|
||||||
#include "../mwrender/objects.hpp"
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld//cellstore.hpp"
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Activator>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Activator>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Activator::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
|
ptr.get<ESM::Activator>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Activator::getName (const MWWorld::Ptr& ptr) const
|
std::string Activator::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
ptr.get<ESM::Activator>();
|
ptr.get<ESM::Activator>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -52,7 +58,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Activator::getScript (const MWWorld::Ptr& ptr) const
|
std::string Activator::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
ptr.get<ESM::Activator>();
|
ptr.get<ESM::Activator>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -67,7 +73,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Activator::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
ptr.get<ESM::Activator>();
|
ptr.get<ESM::Activator>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -75,7 +81,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
ptr.get<ESM::Activator>();
|
ptr.get<ESM::Activator>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -88,4 +94,13 @@ namespace MWClass
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Activator::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Activator> *ref =
|
||||||
|
ptr.get<ESM::Activator>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.activators.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Activator : public MWWorld::Class
|
class Activator : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -28,6 +32,8 @@ namespace MWClass
|
|||||||
///< Return name of the script attached to ptr
|
///< Return name of the script attached to ptr
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,57 +3,57 @@
|
|||||||
|
|
||||||
#include <components/esm/loadappa.hpp>
|
#include <components/esm/loadappa.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionalchemy.hpp"
|
#include "../mwworld/actionalchemy.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Apparatus::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Apparatus>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Apparatus>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
|
ptr.get<ESM::Apparatus>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Apparatus::getName (const MWWorld::Ptr& ptr) const
|
std::string Apparatus::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
ptr.get<ESM::Apparatus>();
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -62,15 +62,17 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(
|
||||||
|
new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const
|
std::string Apparatus::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
ptr.get<ESM::Apparatus>();
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -78,7 +80,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Apparatus::getValue (const MWWorld::Ptr& ptr) const
|
int Apparatus::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
ptr.get<ESM::Apparatus>();
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -103,7 +105,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Apparatus::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Apparatus::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
ptr.get<ESM::Apparatus>();
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -111,7 +113,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
ptr.get<ESM::Apparatus>();
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -119,19 +121,17 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
ptr.get<ESM::Apparatus>();
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality);
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -147,4 +147,13 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy());
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionAlchemy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Apparatus::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
|
||||||
|
ptr.get<ESM::Apparatus>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.appas.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,10 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Apparatus : public MWWorld::Class
|
class Apparatus : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -48,6 +52,8 @@ namespace MWClass
|
|||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,56 +5,58 @@
|
|||||||
#include <components/esm/loadskil.hpp>
|
#include <components/esm/loadskil.hpp>
|
||||||
#include <components/esm/loadgmst.hpp>
|
#include <components/esm/loadgmst.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Armor::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Armor>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Armor::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Armor::getName (const MWWorld::Ptr& ptr) const
|
std::string Armor::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -63,10 +65,11 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
|
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||||
@ -76,7 +79,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return ref->base->data.health;
|
return ref->base->data.health;
|
||||||
@ -84,7 +87,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Armor::getScript (const MWWorld::Ptr& ptr) const
|
std::string Armor::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -92,7 +95,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
std::vector<int> slots;
|
std::vector<int> slots;
|
||||||
@ -126,7 +129,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr) const
|
int Armor::getEquipmentSkill (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
std::string typeGmst;
|
std::string typeGmst;
|
||||||
@ -149,13 +152,13 @@ namespace MWClass
|
|||||||
if (typeGmst.empty())
|
if (typeGmst.empty())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->i;
|
float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->getInt();
|
||||||
|
|
||||||
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->f>=
|
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->getFloat()>=
|
||||||
ref->base->data.weight)
|
ref->base->data.weight)
|
||||||
return ESM::Skill::LightArmor;
|
return ESM::Skill::LightArmor;
|
||||||
|
|
||||||
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->f>=
|
if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->getFloat()>=
|
||||||
ref->base->data.weight)
|
ref->base->data.weight)
|
||||||
return ESM::Skill::MediumArmor;
|
return ESM::Skill::MediumArmor;
|
||||||
|
|
||||||
@ -164,7 +167,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Armor::getValue (const MWWorld::Ptr& ptr) const
|
int Armor::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -201,7 +204,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Armor::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Armor::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -209,7 +212,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -217,7 +220,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -226,25 +229,23 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
// get armor type string (light/medium/heavy)
|
// get armor type string (light/medium/heavy)
|
||||||
int armorType = getEquipmentSkill(ptr);
|
int armorType = getEquipmentSkill(ptr);
|
||||||
std::string typeText;
|
std::string typeText;
|
||||||
if (armorType == ESM::Skill::LightArmor)
|
if (armorType == ESM::Skill::LightArmor)
|
||||||
typeText = store.gameSettings.search("sLight")->str;
|
typeText = "#{sLight}";
|
||||||
else if (armorType == ESM::Skill::MediumArmor)
|
else if (armorType == ESM::Skill::MediumArmor)
|
||||||
typeText = store.gameSettings.search("sMedium")->str;
|
typeText = "#{sMedium}";
|
||||||
else
|
else
|
||||||
typeText = store.gameSettings.search("sHeavy")->str;
|
typeText = "#{sHeavy}";
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sArmorRating")->str + ": " + MWGui::ToolTips::toString(ref->base->data.armor);
|
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->base->data.armor);
|
||||||
|
|
||||||
/// \todo store the current armor health somewhere
|
/// \todo store the current armor health somewhere
|
||||||
text += "\n" + store.gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health);
|
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->data.health);
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight) + " (" + typeText + ")";
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight) + " (" + typeText + ")";
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -260,7 +261,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Armor::getEnchantment (const MWWorld::Ptr& ptr) const
|
std::string Armor::getEnchantment (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
ptr.get<ESM::Armor>();
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
return ref->base->enchant;
|
return ref->base->enchant;
|
||||||
@ -268,8 +269,19 @@ namespace MWClass
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
action->setSound(getUpSoundId(ptr));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Armor::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
||||||
|
ptr.get<ESM::Armor>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.armors.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Armor : public MWWorld::Class
|
class Armor : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -66,6 +69,7 @@ namespace MWClass
|
|||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,55 +3,57 @@
|
|||||||
|
|
||||||
#include <components/esm/loadbook.hpp>
|
#include <components/esm/loadbook.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actionread.hpp"
|
#include "../mwworld/actionread.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Book::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Book>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Book>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Book::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
|
ptr.get<ESM::Book>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Book::getName (const MWWorld::Ptr& ptr) const
|
std::string Book::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -66,7 +68,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Book::getScript (const MWWorld::Ptr& ptr) const
|
std::string Book::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -74,7 +76,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Book::getValue (const MWWorld::Ptr& ptr) const
|
int Book::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -99,7 +101,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Book::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Book::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -107,7 +109,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Book::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Book::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -115,19 +117,17 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -143,7 +143,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Book::getEnchantment (const MWWorld::Ptr& ptr) const
|
std::string Book::getEnchantment (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
ptr.get<ESM::Book>();
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
return ref->base->enchant;
|
return ref->base->enchant;
|
||||||
@ -154,4 +154,12 @@ namespace MWClass
|
|||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionRead(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Book::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Book> *ref =
|
||||||
|
ptr.get<ESM::Book>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.books.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Book : public MWWorld::Class
|
class Book : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -50,6 +53,8 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,75 +3,76 @@
|
|||||||
|
|
||||||
#include <components/esm/loadclot.hpp>
|
#include <components/esm/loadclot.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Clothing::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Clothing>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Clothing>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Clothing::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
|
ptr.get<ESM::Clothing>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Clothing::getName (const MWWorld::Ptr& ptr) const
|
std::string Clothing::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
|
std::string Clothing::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -79,7 +80,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
std::vector<int> slots;
|
std::vector<int> slots;
|
||||||
@ -119,7 +120,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr) const
|
int Clothing::getEquipmentSkill (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
if (ref->base->data.type==ESM::Clothing::Shoes)
|
if (ref->base->data.type==ESM::Clothing::Shoes)
|
||||||
@ -130,7 +131,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Clothing::getValue (const MWWorld::Ptr& ptr) const
|
int Clothing::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -145,7 +146,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr) const
|
std::string Clothing::getUpSoundId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
if (ref->base->data.type == 8)
|
if (ref->base->data.type == 8)
|
||||||
@ -157,7 +158,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr) const
|
std::string Clothing::getDownSoundId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
if (ref->base->data.type == 8)
|
if (ref->base->data.type == 8)
|
||||||
@ -169,7 +170,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Clothing::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Clothing::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -177,7 +178,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -185,19 +186,17 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -213,7 +212,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Clothing::getEnchantment (const MWWorld::Ptr& ptr) const
|
std::string Clothing::getEnchantment (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
ptr.get<ESM::Clothing>();
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
return ref->base->enchant;
|
return ref->base->enchant;
|
||||||
@ -221,8 +220,19 @@ namespace MWClass
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
action->setSound(getUpSoundId(ptr));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Clothing::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Clothing> *ref =
|
||||||
|
ptr.get<ESM::Clothing>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.clothes.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Clothing : public MWWorld::Class
|
class Clothing : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -59,6 +62,8 @@ namespace MWClass
|
|||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,23 +3,24 @@
|
|||||||
|
|
||||||
#include <components/esm/loadcont.hpp>
|
#include <components/esm/loadcont.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/customdata.hpp"
|
#include "../mwworld/customdata.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/actionopen.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
#include "../mwworld/actionopen.hpp"
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -53,32 +54,33 @@ namespace MWClass
|
|||||||
|
|
||||||
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Container>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Container>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Container::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
|
ptr.get<ESM::Container>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Container::activate (const MWWorld::Ptr& ptr,
|
||||||
@ -87,37 +89,58 @@ namespace MWClass
|
|||||||
const std::string lockedSound = "LockedChest";
|
const std::string lockedSound = "LockedChest";
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
|
||||||
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
|
|
||||||
if (ptr.getCellRef().lockLevel>0)
|
bool needKey = ptr.getCellRef().lockLevel>0;
|
||||||
|
bool hasKey = false;
|
||||||
|
std::string keyName;
|
||||||
|
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
||||||
{
|
{
|
||||||
// TODO check for key
|
if (it->getCellRef ().refID == ptr.getCellRef().key)
|
||||||
std::cout << "Locked container" << std::endl;
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
|
hasKey = true;
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
keyName = MWWorld::Class::get(*it).getName(*it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (needKey && hasKey)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}", std::vector<std::string>());
|
||||||
|
ptr.getCellRef().lockLevel = 0;
|
||||||
|
// using a key disarms the trap
|
||||||
|
ptr.getCellRef().trap = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!needKey || hasKey)
|
||||||
{
|
{
|
||||||
std::cout << "Unlocked container" << std::endl;
|
|
||||||
if(ptr.getCellRef().trap.empty())
|
if(ptr.getCellRef().trap.empty())
|
||||||
{
|
{
|
||||||
// Not trapped, Inventory GUI goes here
|
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionOpen(ptr));
|
||||||
//return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
return action;
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Trap activation goes here
|
// Trap activation goes here
|
||||||
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
|
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, trapActivationSound, 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||||
|
action->setSound(trapActivationSound);
|
||||||
ptr.getCellRef().trap = "";
|
ptr.getCellRef().trap = "";
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
return action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||||
|
action->setSound(lockedSound);
|
||||||
|
return action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Container::getName (const MWWorld::Ptr& ptr) const
|
std::string Container::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -133,7 +156,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Container::getScript (const MWWorld::Ptr& ptr) const
|
std::string Container::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -148,7 +171,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Container::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Container::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -156,19 +179,17 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name;
|
info.caption = ref->base->name;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
if (ref->ref.lockLevel > 0)
|
if (ref->ref.lockLevel > 0)
|
||||||
text += "\n" + store.gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel);
|
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.lockLevel);
|
||||||
if (ref->ref.trap != "")
|
if (ref->ref.trap != "")
|
||||||
text += "\n" + store.gameSettings.search("sTrapped")->str;
|
text += "\n#{sTrapped}";
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -182,7 +203,7 @@ namespace MWClass
|
|||||||
|
|
||||||
float Container::getCapacity (const MWWorld::Ptr& ptr) const
|
float Container::getCapacity (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
ptr.get<ESM::Container>();
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
return ref->base->weight;
|
return ref->base->weight;
|
||||||
@ -205,4 +226,13 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
ptr.getCellRef().lockLevel = 0;
|
ptr.getCellRef().lockLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Container::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Container> *ref =
|
||||||
|
ptr.get<ESM::Container>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.containers.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,10 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -51,6 +55,8 @@ namespace MWClass
|
|||||||
///< Unlock object
|
///< Unlock object
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,17 +4,21 @@
|
|||||||
#include <components/esm/loadcrea.hpp>
|
#include <components/esm/loadcrea.hpp>
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
|
||||||
#include "../mwmechanics/magiceffects.hpp"
|
#include "../mwmechanics/magiceffects.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontalk.hpp"
|
#include "../mwworld/actiontalk.hpp"
|
||||||
#include "../mwworld/customdata.hpp"
|
#include "../mwworld/customdata.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -40,27 +44,32 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
std::auto_ptr<CustomData> data (new CustomData);
|
std::auto_ptr<CustomData> data (new CustomData);
|
||||||
|
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref = ptr.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
// creature stats
|
// creature stats
|
||||||
data->mCreatureStats.mAttributes[0].set (ref->base->data.strength);
|
data->mCreatureStats.getAttribute(0).set (ref->base->data.strength);
|
||||||
data->mCreatureStats.mAttributes[1].set (ref->base->data.intelligence);
|
data->mCreatureStats.getAttribute(1).set (ref->base->data.intelligence);
|
||||||
data->mCreatureStats.mAttributes[2].set (ref->base->data.willpower);
|
data->mCreatureStats.getAttribute(2).set (ref->base->data.willpower);
|
||||||
data->mCreatureStats.mAttributes[3].set (ref->base->data.agility);
|
data->mCreatureStats.getAttribute(3).set (ref->base->data.agility);
|
||||||
data->mCreatureStats.mAttributes[4].set (ref->base->data.speed);
|
data->mCreatureStats.getAttribute(4).set (ref->base->data.speed);
|
||||||
data->mCreatureStats.mAttributes[5].set (ref->base->data.endurance);
|
data->mCreatureStats.getAttribute(5).set (ref->base->data.endurance);
|
||||||
data->mCreatureStats.mAttributes[6].set (ref->base->data.personality);
|
data->mCreatureStats.getAttribute(6).set (ref->base->data.personality);
|
||||||
data->mCreatureStats.mAttributes[7].set (ref->base->data.luck);
|
data->mCreatureStats.getAttribute(7).set (ref->base->data.luck);
|
||||||
data->mCreatureStats.mDynamic[0].set (ref->base->data.health);
|
data->mCreatureStats.getHealth().set (ref->base->data.health);
|
||||||
data->mCreatureStats.mDynamic[1].set (ref->base->data.mana);
|
data->mCreatureStats.getMagicka().set (ref->base->data.mana);
|
||||||
data->mCreatureStats.mDynamic[2].set (ref->base->data.fatigue);
|
data->mCreatureStats.getFatigue().set (ref->base->data.fatigue);
|
||||||
|
|
||||||
data->mCreatureStats.mLevel = ref->base->data.level;
|
data->mCreatureStats.setLevel(ref->base->data.level);
|
||||||
|
|
||||||
data->mCreatureStats.mHello = ref->base->AI.hello;
|
data->mCreatureStats.setHello(ref->base->mAiData.mHello);
|
||||||
data->mCreatureStats.mFight = ref->base->AI.fight;
|
data->mCreatureStats.setFight(ref->base->mAiData.mFight);
|
||||||
data->mCreatureStats.mFlee = ref->base->AI.flee;
|
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
||||||
data->mCreatureStats.mAlarm = ref->base->AI.alarm;
|
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
||||||
|
|
||||||
|
// spells
|
||||||
|
for (std::vector<std::string>::const_iterator iter (ref->base->mSpells.list.begin());
|
||||||
|
iter!=ref->base->mSpells.list.end(); ++iter)
|
||||||
|
data->mCreatureStats.getSpells().add (*iter);
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
@ -69,7 +78,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Creature::getId (const MWWorld::Ptr& ptr) const
|
std::string Creature::getId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
ptr.get<ESM::Creature>();
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
return ref->base->mId;
|
return ref->base->mId;
|
||||||
@ -83,21 +92,29 @@ namespace MWClass
|
|||||||
|
|
||||||
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
|
if(!model.empty()){
|
||||||
|
physics.insertActorPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Creature::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
ptr.get<ESM::Creature>();
|
ptr.get<ESM::Creature>();
|
||||||
|
assert (ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertActorPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
ptr.get<ESM::Creature>();
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -126,7 +143,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Creature::getScript (const MWWorld::Ptr& ptr) const
|
std::string Creature::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
ptr.get<ESM::Creature>();
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -148,7 +165,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
ptr.get<ESM::Creature>();
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -165,7 +182,7 @@ namespace MWClass
|
|||||||
float Creature::getCapacity (const MWWorld::Ptr& ptr) const
|
float Creature::getCapacity (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
return stats.mAttributes[0].getModified()*5;
|
return stats.getAttribute(0).getModified()*5;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const
|
float Creature::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||||
@ -174,13 +191,22 @@ namespace MWClass
|
|||||||
|
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
|
|
||||||
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
weight -= stats.getMagicEffects().get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
||||||
|
|
||||||
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
weight += stats.getMagicEffects().get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
||||||
|
|
||||||
if (weight<0)
|
if (weight<0)
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Creature::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Creature> *ref =
|
||||||
|
ptr.get<ESM::Creature>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.creatures.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef GAME_MWCLASS_CREATURE_H
|
#ifndef GAME_MWCLASS_CREATURE_H
|
||||||
#define GAME_MWCLASS_CREATURE_H
|
#define GAME_MWCLASS_CREATURE_H
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
|
||||||
#include "../mwrender/renderinginterface.hpp"
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwrender/actors.hpp"
|
#include "../mwrender/actors.hpp"
|
||||||
|
|
||||||
@ -12,6 +11,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||||
@ -55,6 +57,13 @@ namespace MWClass
|
|||||||
/// effects). Throws an exception, if the object can't hold other objects.
|
/// effects). Throws an exception, if the object can't hold other objects.
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
isActor() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,56 +3,59 @@
|
|||||||
|
|
||||||
#include <components/esm/loaddoor.hpp>
|
#include <components/esm/loaddoor.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
#include "../mwworld/actionteleport.hpp"
|
#include "../mwworld/actionteleport.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Door::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Door>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Door::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Door::getName (const MWWorld::Ptr& ptr) const
|
std::string Door::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
if (ref->ref.teleport && !ref->ref.destCell.empty()) // TODO doors that lead to exteriors
|
if (ref->ref.teleport && !ref->ref.destCell.empty()) // TODO doors that lead to exteriors
|
||||||
@ -64,7 +67,7 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
const std::string &openSound = ref->base->openSound;
|
const std::string &openSound = ref->base->openSound;
|
||||||
@ -72,50 +75,81 @@ namespace MWClass
|
|||||||
const std::string lockedSound = "LockedDoor";
|
const std::string lockedSound = "LockedDoor";
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
if (ptr.getCellRef().lockLevel>0)
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
|
||||||
{
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
// TODO check for key
|
|
||||||
// TODO report failure to player (message, sound?). Look up behaviour of original MW.
|
|
||||||
std::cout << "Locked!" << std::endl;
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, lockedSound, 1.0, 1.0);
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ptr.getCellRef().trap.empty())
|
bool needKey = ptr.getCellRef().lockLevel>0;
|
||||||
|
bool hasKey = false;
|
||||||
|
std::string keyName;
|
||||||
|
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
||||||
{
|
{
|
||||||
// Trap activation
|
if (it->getCellRef ().refID == ptr.getCellRef().key)
|
||||||
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, trapActivationSound, 1.0, 1.0);
|
|
||||||
ptr.getCellRef().trap = "";
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ref->ref.teleport)
|
|
||||||
{
|
|
||||||
// teleport door
|
|
||||||
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
|
|
||||||
{
|
{
|
||||||
// the player is using the door
|
hasKey = true;
|
||||||
// The reason this is not 3D is that it would get interrupted when you teleport
|
keyName = MWWorld::Class::get(*it).getName(*it);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(openSound, 1.0, 1.0);
|
}
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
}
|
||||||
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
|
|
||||||
|
if (needKey && hasKey)
|
||||||
|
{
|
||||||
|
MWBase::Environment::get().getWindowManager ()->messageBox (keyName + " #{sKeyUsed}", std::vector<std::string>());
|
||||||
|
ptr.getCellRef().lockLevel = 0;
|
||||||
|
// using a key disarms the trap
|
||||||
|
ptr.getCellRef().trap = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!needKey || hasKey)
|
||||||
|
{
|
||||||
|
if(!ptr.getCellRef().trap.empty())
|
||||||
|
{
|
||||||
|
// Trap activation
|
||||||
|
std::cout << "Activated trap: " << ptr.getCellRef().trap << std::endl;
|
||||||
|
|
||||||
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||||
|
|
||||||
|
action->setSound(trapActivationSound);
|
||||||
|
ptr.getCellRef().trap = "";
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ref->ref.teleport)
|
||||||
|
{
|
||||||
|
// teleport door
|
||||||
|
/// \todo remove this if clause once ActionTeleport can also support other actors
|
||||||
|
if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->ref.destCell, ref->ref.doorDest));
|
||||||
|
|
||||||
|
action->setSound(openSound);
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// another NPC or a creature is using the door
|
||||||
|
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// another NPC or a creature is using the door
|
// animated door
|
||||||
// TODO return action for teleporting other NPC/creature
|
// TODO return action for rotating the door
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
|
||||||
|
// This is a little pointless, but helps with testing
|
||||||
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||||
|
|
||||||
|
action->setSound(openSound);
|
||||||
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// animated door
|
// locked, and we can't open.
|
||||||
// TODO return action for rotating the door
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction);
|
||||||
|
action->setSound(lockedSound);
|
||||||
// This is a little pointless, but helps with testing
|
return action;
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, openSound, 1.0, 1.0);
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +168,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Door::getScript (const MWWorld::Ptr& ptr) const
|
std::string Door::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -149,7 +183,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Door::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Door::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -157,7 +191,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
ptr.get<ESM::Door>();
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -189,14 +223,14 @@ namespace MWClass
|
|||||||
dest = region->name;
|
dest = region->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text += "\n" + store.gameSettings.search("sTo")->str;
|
text += "\n#{sTo}";
|
||||||
text += "\n"+dest;
|
text += "\n"+dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref->ref.lockLevel > 0)
|
if (ref->ref.lockLevel > 0)
|
||||||
text += "\n" + store.gameSettings.search("sLockLevel")->str + ": " + MWGui::ToolTips::toString(ref->ref.lockLevel);
|
text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.lockLevel);
|
||||||
if (ref->ref.trap != "")
|
if (ref->ref.trap != "")
|
||||||
text += "\n" + store.gameSettings.search("sTrapped")->str;
|
text += "\n#{sTrapped}";
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
||||||
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
|
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
|
||||||
@ -205,4 +239,13 @@ namespace MWClass
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Door::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Door> *ref =
|
||||||
|
ptr.get<ESM::Door>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.doors.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Door : public MWWorld::Class
|
class Door : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -38,6 +41,8 @@ namespace MWClass
|
|||||||
///< Return name of the script attached to ptr
|
///< Return name of the script attached to ptr
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,54 +3,65 @@
|
|||||||
|
|
||||||
#include <components/esm/loadingr.hpp>
|
#include <components/esm/loadingr.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
#include "../mwworld/actioneat.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
std::string Ingredient::getId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
return ref->base->mId;
|
||||||
const std::string &model = ref->base->model;
|
}
|
||||||
|
|
||||||
if (!model.empty())
|
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
|
const std::string model = getModel(ptr);
|
||||||
|
if (!model.empty()) {
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Ingredient::getName (const MWWorld::Ptr& ptr) const
|
std::string Ingredient::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -59,15 +70,16 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const
|
std::string Ingredient::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -75,12 +87,22 @@ namespace MWClass
|
|||||||
|
|
||||||
int Ingredient::getValue (const MWWorld::Ptr& ptr) const
|
int Ingredient::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boost::shared_ptr<MWWorld::Action> Ingredient::use (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
boost::shared_ptr<MWWorld::Action> action (new MWWorld::ActionEat (ptr));
|
||||||
|
|
||||||
|
action->setSound ("Swallow");
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
void Ingredient::registerSelf()
|
void Ingredient::registerSelf()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Class> instance (new Ingredient);
|
boost::shared_ptr<Class> instance (new Ingredient);
|
||||||
@ -100,7 +122,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Ingredient::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Ingredient::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -108,7 +130,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -116,19 +138,17 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
ptr.get<ESM::Ingredient>();
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -152,4 +172,13 @@ namespace MWClass
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Ingredient::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
|
||||||
|
ptr.get<ESM::Ingredient>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.ingreds.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,14 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Ingredient : public MWWorld::Class
|
class Ingredient : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Return ID of \a ptr
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
@ -34,6 +40,10 @@ namespace MWClass
|
|||||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
|
const;
|
||||||
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
|
||||||
@ -44,6 +54,8 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return name of inventory icon.
|
///< Return name of inventory icon.
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,32 +3,32 @@
|
|||||||
|
|
||||||
#include <components/esm/loadligh.hpp>
|
#include <components/esm/loadligh.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwworld/nullaction.hpp"
|
#include "../mwworld/nullaction.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Light::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
assert (ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
@ -47,25 +47,36 @@ namespace MWClass
|
|||||||
|
|
||||||
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Light::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
assert (ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
|
|
||||||
if(!model.empty()){
|
if(!model.empty()) {
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
||||||
}
|
}
|
||||||
|
if (!ref->base->sound.empty()) {
|
||||||
if (!ref->base->sound.empty())
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->sound, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
|
||||||
{
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, ref->base->sound, 1.0, 1.0, MWSound::Play_Loop);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Light::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
|
ptr.get<ESM::Light>();
|
||||||
|
assert (ref->base != NULL);
|
||||||
|
|
||||||
|
const std::string &model = ref->base->model;
|
||||||
|
if (!model.empty()) {
|
||||||
|
return "meshes\\" + model;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
std::string Light::getName (const MWWorld::Ptr& ptr) const
|
std::string Light::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
if (ref->base->model.empty())
|
if (ref->base->model.empty())
|
||||||
@ -77,21 +88,22 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
if (!(ref->base->data.flags & ESM::Light::Carry))
|
if (!(ref->base->data.flags & ESM::Light::Carry))
|
||||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Light::getScript (const MWWorld::Ptr& ptr) const
|
std::string Light::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -99,7 +111,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
std::vector<int> slots;
|
std::vector<int> slots;
|
||||||
@ -112,7 +124,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Light::getValue (const MWWorld::Ptr& ptr) const
|
int Light::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -138,7 +150,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Light::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Light::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -146,7 +158,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Light::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Light::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -154,19 +166,17 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
ptr.get<ESM::Light>();
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -180,8 +190,19 @@ namespace MWClass
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Light::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
action->setSound(getUpSoundId(ptr));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Light::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Light> *ref =
|
||||||
|
ptr.get<ESM::Light>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.lights.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Light : public MWWorld::Class
|
class Light : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -52,6 +55,8 @@ namespace MWClass
|
|||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,58 +3,58 @@
|
|||||||
|
|
||||||
#include <components/esm/loadlocks.hpp>
|
#include <components/esm/loadlocks.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Lockpick::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Tool>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Tool>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
if(!model.empty()){
|
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
|
ptr.get<ESM::Tool>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
|
const std::string &model = ref->base->model;
|
||||||
|
if (!model.empty()) {
|
||||||
|
return "meshes\\" + model;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
|
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
ptr.get<ESM::Tool>();
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -63,15 +63,16 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
|
std::string Lockpick::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
ptr.get<ESM::Tool>();
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -88,7 +89,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Lockpick::getValue (const MWWorld::Ptr& ptr) const
|
int Lockpick::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
ptr.get<ESM::Tool>();
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -113,7 +114,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Lockpick::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Lockpick::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
ptr.get<ESM::Tool>();
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -121,7 +122,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
ptr.get<ESM::Tool>();
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -129,23 +130,21 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
ptr.get<ESM::Tool>();
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
/// \todo store remaining uses somewhere
|
/// \todo store remaining uses somewhere
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
|
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->data.uses);
|
||||||
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality);
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -159,8 +158,19 @@ namespace MWClass
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Lockpick::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
action->setSound(getUpSoundId(ptr));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Lockpick::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Tool> *ref =
|
||||||
|
ptr.get<ESM::Tool>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.lockpicks.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Lockpick : public MWWorld::Class
|
class Lockpick : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -52,6 +55,8 @@ namespace MWClass
|
|||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,20 +5,20 @@
|
|||||||
|
|
||||||
#include <components/esm/loadmisc.hpp>
|
#include <components/esm/loadmisc.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
#include "../mwworld/manualref.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
@ -26,37 +26,38 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Miscellaneous::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Miscellaneous>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Miscellaneous>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const
|
std::string Miscellaneous::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -65,15 +66,16 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const
|
std::string Miscellaneous::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -81,7 +83,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const
|
int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -96,10 +98,10 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const
|
std::string Miscellaneous::getUpSoundId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString())
|
||||||
{
|
{
|
||||||
return std::string("Item Gold Up");
|
return std::string("Item Gold Up");
|
||||||
}
|
}
|
||||||
@ -108,10 +110,10 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const
|
std::string Miscellaneous::getDownSoundId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
if (ref->base->name == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString())
|
||||||
{
|
{
|
||||||
return std::string("Item Gold Down");
|
return std::string("Item Gold Down");
|
||||||
}
|
}
|
||||||
@ -120,7 +122,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Miscellaneous::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Miscellaneous::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -128,7 +130,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -136,7 +138,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -145,7 +147,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int count = ptr.getRefData().getCount();
|
int count = ptr.getRefData().getCount();
|
||||||
|
|
||||||
bool isGold = (ref->base->name == store.gameSettings.search("sGold")->str);
|
bool isGold = (ref->base->name == store.gameSettings.find("sGold")->getString());
|
||||||
if (isGold && count == 1)
|
if (isGold && count == 1)
|
||||||
count = ref->base->data.value;
|
count = ref->base->data.value;
|
||||||
|
|
||||||
@ -168,8 +170,8 @@ namespace MWClass
|
|||||||
|
|
||||||
if (!isGold)
|
if (!isGold)
|
||||||
{
|
{
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
@ -181,4 +183,39 @@ namespace MWClass
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Miscellaneous::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::Ptr newPtr;
|
||||||
|
|
||||||
|
const ESMS::ESMStore &store =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
|
if (MWWorld::Class::get(ptr).getName(ptr) == store.gameSettings.find("sGold")->getString()) {
|
||||||
|
int goldAmount = ptr.getRefData().getCount();
|
||||||
|
|
||||||
|
std::string base = "Gold_001";
|
||||||
|
if (goldAmount >= 100)
|
||||||
|
base = "Gold_100";
|
||||||
|
else if (goldAmount >= 25)
|
||||||
|
base = "Gold_025";
|
||||||
|
else if (goldAmount >= 10)
|
||||||
|
base = "Gold_010";
|
||||||
|
else if (goldAmount >= 5)
|
||||||
|
base = "Gold_005";
|
||||||
|
|
||||||
|
// Really, I have no idea why moving ref out of conditional
|
||||||
|
// scope causes list::push_back throwing std::bad_alloc
|
||||||
|
MWWorld::ManualRef newRef(store, base);
|
||||||
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
|
newRef.getPtr().get<ESM::Miscellaneous>();
|
||||||
|
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell);
|
||||||
|
} else {
|
||||||
|
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
|
ptr.get<ESM::Miscellaneous>();
|
||||||
|
newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell);
|
||||||
|
}
|
||||||
|
return newPtr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Miscellaneous : public MWWorld::Class
|
class Miscellaneous : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
@ -44,6 +47,8 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return name of inventory icon.
|
///< Return name of inventory icon.
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,20 +9,25 @@
|
|||||||
|
|
||||||
#include <components/esm/loadnpc.hpp>
|
#include <components/esm/loadnpc.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
#include "../mwmechanics/movement.hpp"
|
#include "../mwmechanics/movement.hpp"
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontalk.hpp"
|
#include "../mwworld/actiontalk.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/customdata.hpp"
|
#include "../mwworld/customdata.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwrender/actors.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -53,7 +58,7 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
std::auto_ptr<CustomData> data (new CustomData);
|
std::auto_ptr<CustomData> data (new CustomData);
|
||||||
|
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref = ptr.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
// NPC stats
|
// NPC stats
|
||||||
if (!ref->base->faction.empty())
|
if (!ref->base->faction.empty())
|
||||||
@ -62,11 +67,11 @@ namespace MWClass
|
|||||||
boost::algorithm::to_lower(faction);
|
boost::algorithm::to_lower(faction);
|
||||||
if(ref->base->npdt52.gold != -10)
|
if(ref->base->npdt52.gold != -10)
|
||||||
{
|
{
|
||||||
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt52.rank;
|
data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt52.rank;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->mNpcStats.mFactionRank[faction] = (int)ref->base->npdt12.rank;
|
data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->npdt12.rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,31 +79,36 @@ namespace MWClass
|
|||||||
if(ref->base->npdt52.gold != -10)
|
if(ref->base->npdt52.gold != -10)
|
||||||
{
|
{
|
||||||
for (int i=0; i<27; ++i)
|
for (int i=0; i<27; ++i)
|
||||||
data->mNpcStats.mSkill[i].setBase (ref->base->npdt52.skills[i]);
|
data->mNpcStats.getSkill (i).setBase (ref->base->npdt52.skills[i]);
|
||||||
|
|
||||||
data->mCreatureStats.mAttributes[0].set (ref->base->npdt52.strength);
|
data->mCreatureStats.getAttribute(0).set (ref->base->npdt52.strength);
|
||||||
data->mCreatureStats.mAttributes[1].set (ref->base->npdt52.intelligence);
|
data->mCreatureStats.getAttribute(1).set (ref->base->npdt52.intelligence);
|
||||||
data->mCreatureStats.mAttributes[2].set (ref->base->npdt52.willpower);
|
data->mCreatureStats.getAttribute(2).set (ref->base->npdt52.willpower);
|
||||||
data->mCreatureStats.mAttributes[3].set (ref->base->npdt52.agility);
|
data->mCreatureStats.getAttribute(3).set (ref->base->npdt52.agility);
|
||||||
data->mCreatureStats.mAttributes[4].set (ref->base->npdt52.speed);
|
data->mCreatureStats.getAttribute(4).set (ref->base->npdt52.speed);
|
||||||
data->mCreatureStats.mAttributes[5].set (ref->base->npdt52.endurance);
|
data->mCreatureStats.getAttribute(5).set (ref->base->npdt52.endurance);
|
||||||
data->mCreatureStats.mAttributes[6].set (ref->base->npdt52.personality);
|
data->mCreatureStats.getAttribute(6).set (ref->base->npdt52.personality);
|
||||||
data->mCreatureStats.mAttributes[7].set (ref->base->npdt52.luck);
|
data->mCreatureStats.getAttribute(7).set (ref->base->npdt52.luck);
|
||||||
data->mCreatureStats.mDynamic[0].set (ref->base->npdt52.health);
|
data->mCreatureStats.getHealth().set (ref->base->npdt52.health);
|
||||||
data->mCreatureStats.mDynamic[1].set (ref->base->npdt52.mana);
|
data->mCreatureStats.getMagicka().set (ref->base->npdt52.mana);
|
||||||
data->mCreatureStats.mDynamic[2].set (ref->base->npdt52.fatigue);
|
data->mCreatureStats.getFatigue().set (ref->base->npdt52.fatigue);
|
||||||
|
|
||||||
data->mCreatureStats.mLevel = ref->base->npdt52.level;
|
data->mCreatureStats.setLevel(ref->base->npdt52.level);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/// \todo do something with npdt12 maybe:p
|
/// \todo do something with npdt12 maybe:p
|
||||||
}
|
}
|
||||||
|
|
||||||
data->mCreatureStats.mHello = ref->base->AI.hello;
|
data->mCreatureStats.setHello(ref->base->mAiData.mHello);
|
||||||
data->mCreatureStats.mFight = ref->base->AI.fight;
|
data->mCreatureStats.setFight(ref->base->mAiData.mFight);
|
||||||
data->mCreatureStats.mFlee = ref->base->AI.flee;
|
data->mCreatureStats.setFlee(ref->base->mAiData.mFlee);
|
||||||
data->mCreatureStats.mAlarm = ref->base->AI.alarm;
|
data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm);
|
||||||
|
|
||||||
|
// spells
|
||||||
|
for (std::vector<std::string>::const_iterator iter (ref->base->spells.list.begin());
|
||||||
|
iter!=ref->base->spells.list.end(); ++iter)
|
||||||
|
data->mCreatureStats.getSpells().add (*iter);
|
||||||
|
|
||||||
// store
|
// store
|
||||||
ptr.getRefData().setCustomData (data.release());
|
ptr.getRefData().setCustomData (data.release());
|
||||||
@ -107,7 +117,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Npc::getId (const MWWorld::Ptr& ptr) const
|
std::string Npc::getId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
return ref->base->mId;
|
return ref->base->mId;
|
||||||
@ -120,25 +130,36 @@ namespace MWClass
|
|||||||
|
|
||||||
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
physics.insertActorPhysics(ptr, getModel(ptr));
|
||||||
|
MWBase::Environment::get().getMechanicsManager()->addActor(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Npc::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
std::string headID = ref->base->head;
|
std::string headID = ref->base->head;
|
||||||
std::string bodyRaceID = headID.substr(0, headID.find_last_of("head_") - 4);
|
|
||||||
bool beast = bodyRaceID == "b_n_khajiit_m_" || bodyRaceID == "b_n_khajiit_f_" || bodyRaceID == "b_n_argonian_m_" || bodyRaceID == "b_n_argonian_f_";
|
|
||||||
|
|
||||||
std::string smodel = "meshes\\base_anim.nif";
|
int end = headID.find_last_of("head_") - 4;
|
||||||
if(beast)
|
std::string bodyRaceID = headID.substr(0, end);
|
||||||
smodel = "meshes\\base_animkna.nif";
|
|
||||||
physics.insertActorPhysics(ptr, smodel);
|
std::string model = "meshes\\base_anim.nif";
|
||||||
|
if (bodyRaceID == "b_n_khajiit_m_" ||
|
||||||
|
bodyRaceID == "b_n_khajiit_f_" ||
|
||||||
|
bodyRaceID == "b_n_argonian_m_" ||
|
||||||
|
bodyRaceID == "b_n_argonian_f_")
|
||||||
|
{
|
||||||
|
model = "meshes\\base_animkna.nif";
|
||||||
|
}
|
||||||
|
return model;
|
||||||
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->addActor (ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -182,7 +203,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Npc::getScript (const MWWorld::Ptr& ptr) const
|
std::string Npc::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -196,12 +217,12 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
case Run:
|
case Run:
|
||||||
|
|
||||||
stats.mForceRun = force;
|
stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceRun, force);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Sneak:
|
case Sneak:
|
||||||
|
|
||||||
stats.mForceSneak = force;
|
stats.setMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak, force);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Combat:
|
case Combat:
|
||||||
@ -218,17 +239,18 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
case Run:
|
case Run:
|
||||||
|
|
||||||
stats.mRun = set;
|
stats.setMovementFlag (MWMechanics::NpcStats::Flag_Run, set);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Sneak:
|
case Sneak:
|
||||||
|
|
||||||
stats.mSneak = set;
|
stats.setMovementFlag (MWMechanics::NpcStats::Flag_Sneak, set);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Combat:
|
case Combat:
|
||||||
|
|
||||||
stats.mCombat = set;
|
// Combat stance ignored for now; need to be determined based on draw state instead of
|
||||||
|
// being maunally set.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,21 +263,21 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
case Run:
|
case Run:
|
||||||
|
|
||||||
if (!ignoreForce && stats.mForceRun)
|
if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceRun))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return stats.mRun;
|
return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Run);
|
||||||
|
|
||||||
case Sneak:
|
case Sneak:
|
||||||
|
|
||||||
if (!ignoreForce && stats.mForceSneak)
|
if (!ignoreForce && stats.getMovementFlag (MWMechanics::NpcStats::Flag_ForceSneak))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return stats.mSneak;
|
return stats.getMovementFlag (MWMechanics::NpcStats::Flag_Sneak);
|
||||||
|
|
||||||
case Combat:
|
case Combat:
|
||||||
|
|
||||||
return stats.mCombat;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -277,7 +299,7 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
Ogre::Vector3 vector (0, 0, 0);
|
Ogre::Vector3 vector (0, 0, 0);
|
||||||
|
|
||||||
vector.x = - getMovementSettings (ptr).mLeftRight * 127;
|
vector.x = getMovementSettings (ptr).mLeftRight * 127;
|
||||||
vector.y = getMovementSettings (ptr).mForwardBackward * 127;
|
vector.y = getMovementSettings (ptr).mForwardBackward * 127;
|
||||||
vector.z = getMovementSettings(ptr).mUpDown * 127;
|
vector.z = getMovementSettings(ptr).mUpDown * 127;
|
||||||
|
|
||||||
@ -302,7 +324,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
ptr.get<ESM::NPC>();
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -319,7 +341,7 @@ namespace MWClass
|
|||||||
float Npc::getCapacity (const MWWorld::Ptr& ptr) const
|
float Npc::getCapacity (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
return stats.mAttributes[0].getModified()*5;
|
return stats.getAttribute(0).getModified()*5;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const
|
float Npc::getEncumbrance (const MWWorld::Ptr& ptr) const
|
||||||
@ -328,13 +350,50 @@ namespace MWClass
|
|||||||
|
|
||||||
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
const MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
|
|
||||||
weight -= stats.mMagicEffects.get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
weight -= stats.getMagicEffects().get (MWMechanics::EffectKey (8)).mMagnitude; // feather
|
||||||
|
|
||||||
weight += stats.mMagicEffects.get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
weight += stats.getMagicEffects().get (MWMechanics::EffectKey (7)).mMagnitude; // burden
|
||||||
|
|
||||||
if (weight<0)
|
if (weight<0)
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Npc::apply (const MWWorld::Ptr& ptr, const std::string& id,
|
||||||
|
const MWWorld::Ptr& actor) const
|
||||||
|
{
|
||||||
|
MWMechanics::CreatureStats& stats = getCreatureStats (ptr);
|
||||||
|
|
||||||
|
/// \todo consider instant effects
|
||||||
|
|
||||||
|
return stats.getActiveSpells().addSpell (id, actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Npc::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const
|
||||||
|
{
|
||||||
|
MWMechanics::NpcStats& stats = getNpcStats (ptr);
|
||||||
|
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
|
const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find (
|
||||||
|
ref->base->cls);
|
||||||
|
|
||||||
|
stats.useSkill (skill, *class_, usageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Npc::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
||||||
|
{
|
||||||
|
y = 0;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Npc::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||||
|
ptr.get<ESM::NPC>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.npcs.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
void ensureCustomData (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getId (const MWWorld::Ptr& ptr) const;
|
||||||
@ -48,7 +51,7 @@ namespace MWClass
|
|||||||
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
virtual std::string getScript (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return name of the script attached to ptr
|
///< Return name of the script attached to ptr
|
||||||
|
|
||||||
virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const;
|
virtual void setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const;
|
||||||
///< Force or unforce a stance.
|
///< Force or unforce a stance.
|
||||||
|
|
||||||
virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const;
|
virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const;
|
||||||
@ -76,7 +79,25 @@ namespace MWClass
|
|||||||
///< Returns total weight of objects inside this object (including modifications from magic
|
///< Returns total weight of objects inside this object (including modifications from magic
|
||||||
/// effects). Throws an exception, if the object can't hold other objects.
|
/// effects). Throws an exception, if the object can't hold other objects.
|
||||||
|
|
||||||
|
virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id,
|
||||||
|
const MWWorld::Ptr& actor) const;
|
||||||
|
///< Apply \a id on \a ptr.
|
||||||
|
/// \param actor Actor that is resposible for the ID being applied to \a ptr.
|
||||||
|
/// \return Any effect?
|
||||||
|
|
||||||
|
virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const;
|
||||||
|
///< Inform actor \a ptr that a skill use has succeeded.
|
||||||
|
|
||||||
|
virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
|
virtual bool
|
||||||
|
isActor() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,56 +3,58 @@
|
|||||||
|
|
||||||
#include <components/esm/loadalch.hpp>
|
#include <components/esm/loadalch.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/actionapply.hpp"
|
||||||
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Potion::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Potion>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Potion>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Potion::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
|
ptr.get<ESM::Potion>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Potion::getName (const MWWorld::Ptr& ptr) const
|
std::string Potion::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
ptr.get<ESM::Potion>();
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -61,15 +63,17 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(
|
||||||
|
new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound (getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Potion::getScript (const MWWorld::Ptr& ptr) const
|
std::string Potion::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
ptr.get<ESM::Potion>();
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -77,7 +81,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Potion::getValue (const MWWorld::Ptr& ptr) const
|
int Potion::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
ptr.get<ESM::Potion>();
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -102,7 +106,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Potion::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Potion::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
ptr.get<ESM::Potion>();
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -110,7 +114,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
ptr.get<ESM::Potion>();
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -118,21 +122,20 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
ptr.get<ESM::Potion>();
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->effects);
|
info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->effects);
|
||||||
|
info.isPotion = true;
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -143,4 +146,30 @@ namespace MWClass
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<MWWorld::Action> Potion::use (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
|
ptr.getRefData().setCount (ptr.getRefData().getCount()-1);
|
||||||
|
|
||||||
|
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
|
|
||||||
|
boost::shared_ptr<MWWorld::Action> action (
|
||||||
|
new MWWorld::ActionApply (actor, ref->base->mId));
|
||||||
|
|
||||||
|
action->setSound ("Drink");
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Potion::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Potion> *ref =
|
||||||
|
ptr.get<ESM::Potion>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.potions.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Potion : public MWWorld::Class
|
class Potion : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
@ -34,6 +37,9 @@ namespace MWClass
|
|||||||
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
virtual int getValue (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
///< Return trade value of the object. Throws an exception, if the object can't be traded.
|
||||||
|
|
||||||
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
|
virtual std::string getUpSoundId (const MWWorld::Ptr& ptr) const;
|
||||||
@ -44,6 +50,8 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return name of inventory icon.
|
///< Return name of inventory icon.
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,58 +3,58 @@
|
|||||||
|
|
||||||
#include <components/esm/loadlocks.hpp>
|
#include <components/esm/loadlocks.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Probe::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Probe>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Probe>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
if(!model.empty()){
|
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Probe::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
|
ptr.get<ESM::Probe>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
|
const std::string &model = ref->base->model;
|
||||||
|
if (!model.empty()) {
|
||||||
|
return "meshes\\" + model;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
std::string Probe::getName (const MWWorld::Ptr& ptr) const
|
std::string Probe::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -62,15 +62,16 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Probe::getScript (const MWWorld::Ptr& ptr) const
|
std::string Probe::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -87,7 +88,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Probe::getValue (const MWWorld::Ptr& ptr) const
|
int Probe::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -112,7 +113,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Probe::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Probe::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -120,7 +121,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -128,23 +129,21 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
ptr.get<ESM::Probe>();
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
info.caption = ref->base->name + MWGui::ToolTips::getCountString(ptr.getRefData().getCount());
|
||||||
info.icon = ref->base->icon;
|
info.icon = ref->base->icon;
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
||||||
|
|
||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
/// \todo store remaining uses somewhere
|
/// \todo store remaining uses somewhere
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
|
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->data.uses);
|
||||||
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality);
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -158,8 +157,19 @@ namespace MWClass
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Probe::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
action->setSound(getUpSoundId(ptr));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Probe::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.probes.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Probe : public MWWorld::Class
|
class Probe : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
@ -52,6 +55,8 @@ namespace MWClass
|
|||||||
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
virtual boost::shared_ptr<MWWorld::Action> use (const MWWorld::Ptr& ptr)
|
||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,55 +3,56 @@
|
|||||||
|
|
||||||
#include <components/esm/loadlocks.hpp>
|
#include <components/esm/loadlocks.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Repair::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Repair>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Repair>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Repair::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
|
ptr.get<ESM::Repair>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Repair::getName (const MWWorld::Ptr& ptr) const
|
std::string Repair::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -60,15 +61,16 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Repair::getScript (const MWWorld::Ptr& ptr) const
|
std::string Repair::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -76,7 +78,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Repair::getValue (const MWWorld::Ptr& ptr) const
|
int Repair::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -101,7 +103,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Repair::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Repair::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -109,7 +111,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -117,7 +119,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
ptr.get<ESM::Repair>();
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -128,11 +130,10 @@ namespace MWClass
|
|||||||
|
|
||||||
/// \todo store remaining uses somewhere
|
/// \todo store remaining uses somewhere
|
||||||
|
|
||||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->data.uses);
|
||||||
text += "\n" + store.gameSettings.search("sUses")->str + ": " + MWGui::ToolTips::toString(ref->base->data.uses);
|
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->data.quality);
|
||||||
text += "\n" + store.gameSettings.search("sQuality")->str + ": " + MWGui::ToolTips::toString(ref->base->data.quality);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
|
||||||
|
|
||||||
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
|
||||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||||
@ -143,4 +144,13 @@ namespace MWClass
|
|||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Repair::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Repair> *ref =
|
||||||
|
ptr.get<ESM::Repair>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.repairs.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Repair : public MWWorld::Class
|
class Repair : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
@ -44,6 +47,8 @@ namespace MWClass
|
|||||||
|
|
||||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return name of inventory icon.
|
///< Return name of inventory icon.
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,40 +4,44 @@
|
|||||||
#include <components/esm/loadstat.hpp>
|
#include <components/esm/loadstat.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Static::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Static>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), true);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Static>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if(!model.empty()){
|
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Static::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Static> *ref =
|
||||||
|
ptr.get<ESM::Static>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
|
const std::string &model = ref->base->model;
|
||||||
|
if (!model.empty()) {
|
||||||
|
return "meshes\\" + model;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
@ -49,4 +53,13 @@ namespace MWClass
|
|||||||
|
|
||||||
registerClass (typeid (ESM::Static).name(), instance);
|
registerClass (typeid (ESM::Static).name(), instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Static::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Static> *ref =
|
||||||
|
ptr.get<ESM::Static>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.statics.insert(*ref), &cell);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Static : public MWWorld::Class
|
class Static : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< Add reference into a cell for rendering
|
||||||
|
|
||||||
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
virtual void insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
|
||||||
@ -19,6 +22,8 @@ namespace MWClass
|
|||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,58 +3,58 @@
|
|||||||
|
|
||||||
#include <components/esm/loadweap.hpp>
|
#include <components/esm/loadweap.hpp>
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwworld/actionequip.hpp"
|
#include "../mwworld/actionequip.hpp"
|
||||||
#include "../mwworld/inventorystore.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
|
#include "../mwworld/physicssystem.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/tooltips.hpp"
|
#include "../mwgui/tooltips.hpp"
|
||||||
|
|
||||||
#include "../mwrender/objects.hpp"
|
#include "../mwrender/objects.hpp"
|
||||||
|
#include "../mwrender/renderinginterface.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
void Weapon::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Weapon>();
|
if (!model.empty()) {
|
||||||
|
|
||||||
assert (ref->base != NULL);
|
|
||||||
const std::string &model = ref->base->model;
|
|
||||||
|
|
||||||
if (!model.empty())
|
|
||||||
{
|
|
||||||
MWRender::Objects& objects = renderingInterface.getObjects();
|
MWRender::Objects& objects = renderingInterface.getObjects();
|
||||||
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
||||||
objects.insertMesh(ptr, "meshes\\" + model);
|
objects.insertMesh(ptr, model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
const std::string model = getModel(ptr);
|
||||||
ptr.get<ESM::Weapon>();
|
if(!model.empty()) {
|
||||||
|
physics.insertObjectPhysics(ptr, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Weapon::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
|
ptr.get<ESM::Weapon>();
|
||||||
|
assert(ref->base != NULL);
|
||||||
|
|
||||||
const std::string &model = ref->base->model;
|
const std::string &model = ref->base->model;
|
||||||
assert (ref->base != NULL);
|
if (!model.empty()) {
|
||||||
if(!model.empty()){
|
return "meshes\\" + model;
|
||||||
physics.insertObjectPhysics(ptr, "meshes\\" + model);
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Weapon::getName (const MWWorld::Ptr& ptr) const
|
std::string Weapon::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return ref->base->name;
|
return ref->base->name;
|
||||||
@ -63,10 +63,11 @@ namespace MWClass
|
|||||||
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
|
boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr,
|
||||||
const MWWorld::Ptr& actor) const
|
const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, getUpSoundId(ptr), 1.0, 1.0, MWSound::Play_NoTrack);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
action->setSound(getUpSoundId(ptr));
|
||||||
new MWWorld::ActionTake (ptr));
|
|
||||||
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
|
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||||
@ -76,7 +77,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return ref->base->data.health;
|
return ref->base->data.health;
|
||||||
@ -84,7 +85,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Weapon::getScript (const MWWorld::Ptr& ptr) const
|
std::string Weapon::getScript (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
@ -92,7 +93,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
std::vector<int> slots;
|
std::vector<int> slots;
|
||||||
@ -116,7 +117,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr) const
|
int Weapon::getEquipmentSkill (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
const int size = 12;
|
const int size = 12;
|
||||||
@ -146,7 +147,7 @@ namespace MWClass
|
|||||||
|
|
||||||
int Weapon::getValue (const MWWorld::Ptr& ptr) const
|
int Weapon::getValue (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return ref->base->data.value;
|
return ref->base->data.value;
|
||||||
@ -161,7 +162,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const
|
std::string Weapon::getUpSoundId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
int type = ref->base->data.type;
|
int type = ref->base->data.type;
|
||||||
@ -207,7 +208,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const
|
std::string Weapon::getDownSoundId (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
int type = ref->base->data.type;
|
int type = ref->base->data.type;
|
||||||
@ -253,7 +254,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Weapon::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
std::string Weapon::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return ref->base->icon;
|
return ref->base->icon;
|
||||||
@ -261,7 +262,7 @@ namespace MWClass
|
|||||||
|
|
||||||
bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const
|
bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return (ref->base->name != "");
|
return (ref->base->name != "");
|
||||||
@ -269,7 +270,7 @@ namespace MWClass
|
|||||||
|
|
||||||
MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
MWGui::ToolTipInfo info;
|
MWGui::ToolTipInfo info;
|
||||||
@ -283,7 +284,7 @@ namespace MWClass
|
|||||||
// weapon type & damage. arrows / bolts don't have his info.
|
// weapon type & damage. arrows / bolts don't have his info.
|
||||||
if (ref->base->data.type < 12)
|
if (ref->base->data.type < 12)
|
||||||
{
|
{
|
||||||
text += "\n" + store.gameSettings.search("sType")->str + " ";
|
text += "\n#{sType} ";
|
||||||
|
|
||||||
std::map <int, std::pair <std::string, std::string> > mapping;
|
std::map <int, std::pair <std::string, std::string> > mapping;
|
||||||
mapping[ESM::Weapon::ShortBladeOneHand] = std::make_pair("sSkillShortblade", "sOneHanded");
|
mapping[ESM::Weapon::ShortBladeOneHand] = std::make_pair("sSkillShortblade", "sOneHanded");
|
||||||
@ -302,29 +303,29 @@ namespace MWClass
|
|||||||
std::string type = mapping[ref->base->data.type].first;
|
std::string type = mapping[ref->base->data.type].first;
|
||||||
std::string oneOrTwoHanded = mapping[ref->base->data.type].second;
|
std::string oneOrTwoHanded = mapping[ref->base->data.type].second;
|
||||||
|
|
||||||
text += store.gameSettings.search(type)->str +
|
text += store.gameSettings.find(type)->getString() +
|
||||||
((oneOrTwoHanded != "") ? ", " + store.gameSettings.search(oneOrTwoHanded)->str : "");
|
((oneOrTwoHanded != "") ? ", " + store.gameSettings.find(oneOrTwoHanded)->getString() : "");
|
||||||
|
|
||||||
// weapon damage
|
// weapon damage
|
||||||
if (ref->base->data.type >= 9)
|
if (ref->base->data.type >= 9)
|
||||||
{
|
{
|
||||||
// marksman
|
// marksman
|
||||||
text += "\n" + store.gameSettings.search("sAttack")->str + ": "
|
text += "\n#{sAttack}: "
|
||||||
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[0]))
|
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[0]))
|
||||||
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[1]));
|
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[1]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Chop
|
// Chop
|
||||||
text += "\n" + store.gameSettings.search("sChop")->str + ": "
|
text += "\n#{sChop}: "
|
||||||
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[0]))
|
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[0]))
|
||||||
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[1]));
|
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.chop[1]));
|
||||||
// Slash
|
// Slash
|
||||||
text += "\n" + store.gameSettings.search("sSlash")->str + ": "
|
text += "\n#{sSlash}: "
|
||||||
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.slash[0]))
|
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.slash[0]))
|
||||||
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.slash[1]));
|
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.slash[1]));
|
||||||
// Thrust
|
// Thrust
|
||||||
text += "\n" + store.gameSettings.search("sThrust")->str + ": "
|
text += "\n#{sThrust}: "
|
||||||
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.thrust[0]))
|
+ MWGui::ToolTips::toString(static_cast<int>(ref->base->data.thrust[0]))
|
||||||
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.thrust[1]));
|
+ " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->data.thrust[1]));
|
||||||
}
|
}
|
||||||
@ -332,10 +333,10 @@ namespace MWClass
|
|||||||
|
|
||||||
/// \todo store the current weapon health somewhere
|
/// \todo store the current weapon health somewhere
|
||||||
if (ref->base->data.type < 11) // thrown weapons and arrows/bolts don't have health, only quantity
|
if (ref->base->data.type < 11) // thrown weapons and arrows/bolts don't have health, only quantity
|
||||||
text += "\n" + store.gameSettings.search("sCondition")->str + ": " + MWGui::ToolTips::toString(ref->base->data.health);
|
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->data.health);
|
||||||
|
|
||||||
text += "\n" + store.gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, store.gameSettings.search("sValue")->str);
|
text += MWGui::ToolTips::getValueString(ref->base->data.value, "#{sValue}");
|
||||||
|
|
||||||
info.enchant = ref->base->enchant;
|
info.enchant = ref->base->enchant;
|
||||||
|
|
||||||
@ -351,7 +352,7 @@ namespace MWClass
|
|||||||
|
|
||||||
std::string Weapon::getEnchantment (const MWWorld::Ptr& ptr) const
|
std::string Weapon::getEnchantment (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
ptr.get<ESM::Weapon>();
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
return ref->base->enchant;
|
return ref->base->enchant;
|
||||||
@ -359,8 +360,19 @@ namespace MWClass
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (getUpSoundId(ptr), 1.0, 1.0);
|
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionEquip(ptr));
|
||||||
|
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionEquip(ptr));
|
action->setSound(getUpSoundId(ptr));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr
|
||||||
|
Weapon::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Weapon> *ref =
|
||||||
|
ptr.get<ESM::Weapon>();
|
||||||
|
|
||||||
|
return MWWorld::Ptr(&cell.weapons.insert(*ref), &cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ namespace MWClass
|
|||||||
{
|
{
|
||||||
class Weapon : public MWWorld::Class
|
class Weapon : public MWWorld::Class
|
||||||
{
|
{
|
||||||
|
virtual MWWorld::Ptr
|
||||||
|
copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
@ -66,6 +69,7 @@ namespace MWClass
|
|||||||
const;
|
const;
|
||||||
///< Generate action for using via inventory menu
|
///< Generate action for using via inventory menu
|
||||||
|
|
||||||
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "dialoguemanager.hpp"
|
#include "dialoguemanagerimp.hpp"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -10,34 +10,31 @@
|
|||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/scriptmanager.hpp"
|
||||||
|
#include "../mwbase/journal.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "../mwworld/refdata.hpp"
|
#include "../mwworld/refdata.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
|
|
||||||
#include "../mwinput/inputmanager.hpp"
|
|
||||||
#include "../mwgui/dialogue.hpp"
|
#include "../mwgui/dialogue.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
|
|
||||||
#include "journal.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "../mwscript/extensions.hpp"
|
|
||||||
#include "../mwscript/scriptmanager.hpp"
|
|
||||||
|
|
||||||
#include <components/compiler/exception.hpp>
|
#include <components/compiler/exception.hpp>
|
||||||
#include <components/compiler/errorhandler.hpp>
|
#include <components/compiler/errorhandler.hpp>
|
||||||
#include <components/compiler/scanner.hpp>
|
#include <components/compiler/scanner.hpp>
|
||||||
#include <components/compiler/locals.hpp>
|
#include <components/compiler/locals.hpp>
|
||||||
#include <components/compiler/output.hpp>
|
#include <components/compiler/output.hpp>
|
||||||
|
#include <components/compiler/scriptparser.hpp>
|
||||||
#include <components/interpreter/interpreter.hpp>
|
#include <components/interpreter/interpreter.hpp>
|
||||||
|
|
||||||
#include "../mwscript/compilercontext.hpp"
|
#include "../mwscript/compilercontext.hpp"
|
||||||
#include "../mwscript/interpretercontext.hpp"
|
#include "../mwscript/interpretercontext.hpp"
|
||||||
#include <components/compiler/scriptparser.hpp>
|
#include "../mwscript/extensions.hpp"
|
||||||
|
|
||||||
#include "../mwclass/npc.hpp"
|
#include "../mwclass/npc.hpp"
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
@ -121,24 +118,24 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool checkGlobal (char comp, const std::string& name, T value, MWWorld::World& world)
|
bool checkGlobal (char comp, const std::string& name, T value)
|
||||||
{
|
{
|
||||||
switch (world.getGlobalVariableType (name))
|
switch (MWBase::Environment::get().getWorld()->getGlobalVariableType (name))
|
||||||
{
|
{
|
||||||
case 's':
|
case 's':
|
||||||
return selectCompare (comp, world.getGlobalVariable (name).mShort, value);
|
return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort, value);
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
|
|
||||||
return selectCompare (comp, world.getGlobalVariable (name).mLong, value);
|
return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong, value);
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
|
|
||||||
return selectCompare (comp, world.getGlobalVariable (name).mFloat, value);
|
return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat, value);
|
||||||
|
|
||||||
case ' ':
|
case ' ':
|
||||||
|
|
||||||
world.getGlobalVariable (name); // trigger exception
|
MWBase::Environment::get().getWorld()->getGlobalVariable (name); // trigger exception
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -203,10 +200,10 @@ namespace MWDialogue
|
|||||||
MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor);
|
MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor);
|
||||||
int sameFaction = 0;
|
int sameFaction = 0;
|
||||||
if(!NPCstats.mFactionRank.empty())
|
if(!NPCstats.getFactionRanks().empty())
|
||||||
{
|
{
|
||||||
std::string NPCFaction = NPCstats.mFactionRank.begin()->first;
|
std::string NPCFaction = NPCstats.getFactionRanks().begin()->first;
|
||||||
if(PCstats.mFactionRank.find(toLower(NPCFaction)) != PCstats.mFactionRank.end()) sameFaction = 1;
|
if(PCstats.getFactionRanks().find(toLower(NPCFaction)) != PCstats.getFactionRanks().end()) sameFaction = 1;
|
||||||
}
|
}
|
||||||
if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false;
|
if(!selectCompare<int,int>(comp,sameFaction,select.i)) return false;
|
||||||
}
|
}
|
||||||
@ -309,12 +306,12 @@ namespace MWDialogue
|
|||||||
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
|
if (select.type==ESM::VT_Short || select.type==ESM::VT_Int ||
|
||||||
select.type==ESM::VT_Long)
|
select.type==ESM::VT_Long)
|
||||||
{
|
{
|
||||||
if (!checkGlobal (comp, toLower (name), select.i, *MWBase::Environment::get().getWorld()))
|
if (!checkGlobal (comp, toLower (name), select.i))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (select.type==ESM::VT_Float)
|
else if (select.type==ESM::VT_Float)
|
||||||
{
|
{
|
||||||
if (!checkGlobal (comp, toLower (name), select.f, *MWBase::Environment::get().getWorld()))
|
if (!checkGlobal (comp, toLower (name), select.f))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -392,7 +389,7 @@ namespace MWDialogue
|
|||||||
|
|
||||||
if(select.type==ESM::VT_Int)
|
if(select.type==ESM::VT_Int)
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
|
||||||
int isFaction = int(toLower(npc->base->faction) == toLower(name));
|
int isFaction = int(toLower(npc->base->faction) == toLower(name));
|
||||||
if(selectCompare<int,int>(comp,!isFaction,select.i))
|
if(selectCompare<int,int>(comp,!isFaction,select.i))
|
||||||
return false;
|
return false;
|
||||||
@ -409,7 +406,7 @@ namespace MWDialogue
|
|||||||
|
|
||||||
if(select.type==ESM::VT_Int)
|
if(select.type==ESM::VT_Int)
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
|
||||||
int isClass = int(toLower(npc->base->cls) == toLower(name));
|
int isClass = int(toLower(npc->base->cls) == toLower(name));
|
||||||
if(selectCompare<int,int>(comp,!isClass,select.i))
|
if(selectCompare<int,int>(comp,!isClass,select.i))
|
||||||
return false;
|
return false;
|
||||||
@ -426,7 +423,7 @@ namespace MWDialogue
|
|||||||
|
|
||||||
if(select.type==ESM::VT_Int)
|
if(select.type==ESM::VT_Int)
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
|
||||||
int isRace = int(toLower(npc->base->race) == toLower(name));
|
int isRace = int(toLower(npc->base->race) == toLower(name));
|
||||||
if(selectCompare<int,int>(comp,!isRace,select.i))
|
if(selectCompare<int,int>(comp,!isRace,select.i))
|
||||||
return false;
|
return false;
|
||||||
@ -493,7 +490,7 @@ namespace MWDialogue
|
|||||||
if (isCreature)
|
if (isCreature)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC> *cellRef = actor.get<ESM::NPC>();
|
||||||
|
|
||||||
if (!cellRef)
|
if (!cellRef)
|
||||||
return false;
|
return false;
|
||||||
@ -508,7 +505,7 @@ namespace MWDialogue
|
|||||||
if (isCreature)
|
if (isCreature)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *cellRef = actor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC> *cellRef = actor.get<ESM::NPC>();
|
||||||
|
|
||||||
if (!cellRef)
|
if (!cellRef)
|
||||||
return false;
|
return false;
|
||||||
@ -525,8 +522,8 @@ namespace MWDialogue
|
|||||||
|
|
||||||
//MWWorld::Class npcClass = MWWorld::Class::get(actor);
|
//MWWorld::Class npcClass = MWWorld::Class::get(actor);
|
||||||
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor);
|
MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor);
|
||||||
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.npcFaction));
|
std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.npcFaction));
|
||||||
if(it!=stats.mFactionRank.end())
|
if(it!=stats.getFactionRanks().end())
|
||||||
{
|
{
|
||||||
//check rank
|
//check rank
|
||||||
if(it->second < (int)info.data.rank) return false;
|
if(it->second < (int)info.data.rank) return false;
|
||||||
@ -542,8 +539,8 @@ namespace MWDialogue
|
|||||||
if(!info.pcFaction.empty())
|
if(!info.pcFaction.empty())
|
||||||
{
|
{
|
||||||
MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
std::map<std::string,int>::iterator it = stats.mFactionRank.find(toLower(info.pcFaction));
|
std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.pcFaction));
|
||||||
if(it!=stats.mFactionRank.end())
|
if(it!=stats.getFactionRanks().end())
|
||||||
{
|
{
|
||||||
//check rank
|
//check rank
|
||||||
if(it->second < (int)info.data.PCrank) return false;
|
if(it->second < (int)info.data.PCrank) return false;
|
||||||
@ -558,7 +555,7 @@ namespace MWDialogue
|
|||||||
//check gender
|
//check gender
|
||||||
if (!isCreature)
|
if (!isCreature)
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* npc = actor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>();
|
||||||
if(npc->base->flags&npc->base->Female)
|
if(npc->base->flags&npc->base->Female)
|
||||||
{
|
{
|
||||||
if(static_cast<int> (info.data.gender)==0) return false;
|
if(static_cast<int> (info.data.gender)==0) return false;
|
||||||
@ -591,7 +588,7 @@ namespace MWDialogue
|
|||||||
mIsInChoice = false;
|
mIsInChoice = false;
|
||||||
mCompilerContext.setExtensions (&extensions);
|
mCompilerContext.setExtensions (&extensions);
|
||||||
mDialogueMap.clear();
|
mDialogueMap.clear();
|
||||||
actorKnownTopics.clear();
|
mActorKnownTopics.clear();
|
||||||
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
|
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
|
||||||
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||||
{
|
{
|
||||||
@ -599,26 +596,26 @@ namespace MWDialogue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::addTopic(std::string topic)
|
void DialogueManager::addTopic (const std::string& topic)
|
||||||
{
|
{
|
||||||
knownTopics[toLower(topic)] = true;
|
mKnownTopics[toLower(topic)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::parseText(std::string text)
|
void DialogueManager::parseText (std::string text)
|
||||||
{
|
{
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
for(it = actorKnownTopics.begin();it != actorKnownTopics.end();++it)
|
for(it = mActorKnownTopics.begin();it != mActorKnownTopics.end();++it)
|
||||||
{
|
{
|
||||||
size_t pos = find_str_ci(text,*it,0);
|
size_t pos = find_str_ci(text,*it,0);
|
||||||
if(pos !=std::string::npos)
|
if(pos !=std::string::npos)
|
||||||
{
|
{
|
||||||
if(pos==0)
|
if(pos==0)
|
||||||
{
|
{
|
||||||
knownTopics[*it] = true;
|
mKnownTopics[*it] = true;
|
||||||
}
|
}
|
||||||
else if(text.substr(pos -1,1) == " ")
|
else if(text.substr(pos -1,1) == " ")
|
||||||
{
|
{
|
||||||
knownTopics[*it] = true;
|
mKnownTopics[*it] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -632,7 +629,7 @@ namespace MWDialogue
|
|||||||
|
|
||||||
mActor = actor;
|
mActor = actor;
|
||||||
|
|
||||||
actorKnownTopics.clear();
|
mActorKnownTopics.clear();
|
||||||
|
|
||||||
//initialise the GUI
|
//initialise the GUI
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Dialogue);
|
||||||
@ -706,7 +703,7 @@ namespace MWDialogue
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch (const Compiler::SourceException& error)
|
catch (const Compiler::SourceException& /* error */)
|
||||||
{
|
{
|
||||||
// error has already been reported via error handler
|
// error has already been reported via error handler
|
||||||
}
|
}
|
||||||
@ -742,7 +739,7 @@ namespace MWDialogue
|
|||||||
std::list<std::string> keywordList;
|
std::list<std::string> keywordList;
|
||||||
int choice = mChoice;
|
int choice = mChoice;
|
||||||
mChoice = -1;
|
mChoice = -1;
|
||||||
actorKnownTopics.clear();
|
mActorKnownTopics.clear();
|
||||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
|
ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list;
|
||||||
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++)
|
||||||
@ -755,9 +752,9 @@ namespace MWDialogue
|
|||||||
{
|
{
|
||||||
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
|
if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true))
|
||||||
{
|
{
|
||||||
actorKnownTopics.push_back(toLower(it->first));
|
mActorKnownTopics.push_back(toLower(it->first));
|
||||||
//does the player know the topic?
|
//does the player know the topic?
|
||||||
if(knownTopics.find(toLower(it->first)) != knownTopics.end())
|
if(mKnownTopics.find(toLower(it->first)) != mKnownTopics.end())
|
||||||
{
|
{
|
||||||
keywordList.push_back(it->first);
|
keywordList.push_back(it->first);
|
||||||
break;
|
break;
|
||||||
@ -771,15 +768,15 @@ namespace MWDialogue
|
|||||||
int services = 0;
|
int services = 0;
|
||||||
if (mActor.getTypeName() == typeid(ESM::NPC).name())
|
if (mActor.getTypeName() == typeid(ESM::NPC).name())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* ref = mActor.get<ESM::NPC>();
|
MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>();
|
||||||
if (ref->base->hasAI)
|
if (ref->base->mHasAI)
|
||||||
services = ref->base->AI.services;
|
services = ref->base->mAiData.mServices;
|
||||||
}
|
}
|
||||||
else if (mActor.getTypeName() == typeid(ESM::Creature).name())
|
else if (mActor.getTypeName() == typeid(ESM::Creature).name())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData>* ref = mActor.get<ESM::Creature>();
|
MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>();
|
||||||
if (ref->base->hasAI)
|
if (ref->base->mHasAI)
|
||||||
services = ref->base->AI.services;
|
services = ref->base->mAiData.mServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (services & ESM::NPC::Weapon
|
if (services & ESM::NPC::Weapon
|
||||||
@ -797,6 +794,11 @@ namespace MWDialogue
|
|||||||
else
|
else
|
||||||
win->setShowTrade(false);
|
win->setShowTrade(false);
|
||||||
|
|
||||||
|
if (services & ESM::NPC::Spells)
|
||||||
|
win->setShowSpells(true);
|
||||||
|
else
|
||||||
|
win->setShowSpells(false);
|
||||||
|
|
||||||
// sort again, because the previous sort was case-sensitive
|
// sort again, because the previous sort was case-sensitive
|
||||||
keywordList.sort(stringCompareNoCase);
|
keywordList.sort(stringCompareNoCase);
|
||||||
win->setKeywords(keywordList);
|
win->setKeywords(keywordList);
|
||||||
@ -804,7 +806,7 @@ namespace MWDialogue
|
|||||||
mChoice = choice;
|
mChoice = choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::keywordSelected(std::string keyword)
|
void DialogueManager::keywordSelected (const std::string& keyword)
|
||||||
{
|
{
|
||||||
if(!mIsInChoice)
|
if(!mIsInChoice)
|
||||||
{
|
{
|
||||||
@ -846,11 +848,11 @@ namespace MWDialogue
|
|||||||
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
|
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::questionAnswered(std::string answere)
|
void DialogueManager::questionAnswered (const std::string& answer)
|
||||||
{
|
{
|
||||||
if(mChoiceMap.find(answere) != mChoiceMap.end())
|
if(mChoiceMap.find(answer) != mChoiceMap.end())
|
||||||
{
|
{
|
||||||
mChoice = mChoiceMap[answere];
|
mChoice = mChoiceMap[answer];
|
||||||
|
|
||||||
std::vector<ESM::DialInfo>::const_iterator iter;
|
std::vector<ESM::DialInfo>::const_iterator iter;
|
||||||
if(mDialogueMap.find(mLastTopic) != mDialogueMap.end())
|
if(mDialogueMap.find(mLastTopic) != mDialogueMap.end())
|
||||||
@ -882,13 +884,13 @@ namespace MWDialogue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::printError(std::string error)
|
void DialogueManager::printError (std::string error)
|
||||||
{
|
{
|
||||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
win->addText(error);
|
win->addText(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueManager::askQuestion(std::string question, int choice)
|
void DialogueManager::askQuestion (const std::string& question, int choice)
|
||||||
{
|
{
|
||||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
win->askQuestion(question);
|
win->askQuestion(question);
|
||||||
@ -896,20 +898,20 @@ namespace MWDialogue
|
|||||||
mIsInChoice = true;
|
mIsInChoice = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DialogueManager::getFaction()
|
std::string DialogueManager::getFaction() const
|
||||||
{
|
{
|
||||||
if (mActor.getTypeName() != typeid(ESM::NPC).name())
|
if (mActor.getTypeName() != typeid(ESM::NPC).name())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
std::string factionID("");
|
std::string factionID("");
|
||||||
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
|
MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor);
|
||||||
if(stats.mFactionRank.empty())
|
if(stats.getFactionRanks().empty())
|
||||||
{
|
{
|
||||||
std::cout << "No faction for this actor!";
|
std::cout << "No faction for this actor!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
factionID = stats.mFactionRank.begin()->first;
|
factionID = stats.getFactionRanks().begin()->first;
|
||||||
}
|
}
|
||||||
return factionID;
|
return factionID;
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
#ifndef GAME_MMDIALOG_DIALOGUEMANAGER_H
|
#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
|
||||||
#define GAME_MWDIALOG_DIALOGUEMANAGER_H
|
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
|
||||||
|
|
||||||
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
|
||||||
#include <components/esm/loadinfo.hpp>
|
#include <components/esm/loadinfo.hpp>
|
||||||
|
|
||||||
@ -9,11 +11,12 @@
|
|||||||
#include <components/compiler/output.hpp>
|
#include <components/compiler/output.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
class DialogueManager
|
class DialogueManager : public MWBase::DialogueManager
|
||||||
{
|
{
|
||||||
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const;
|
bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const;
|
||||||
|
|
||||||
@ -26,8 +29,8 @@ namespace MWDialogue
|
|||||||
void updateTopics();
|
void updateTopics();
|
||||||
|
|
||||||
std::map<std::string,ESM::Dialogue> mDialogueMap;
|
std::map<std::string,ESM::Dialogue> mDialogueMap;
|
||||||
std::map<std::string,bool> knownTopics;// Those are the topics the player knows.
|
std::map<std::string,bool> mKnownTopics;// Those are the topics the player knows.
|
||||||
std::list<std::string> actorKnownTopics;
|
std::list<std::string> mActorKnownTopics;
|
||||||
|
|
||||||
MWScript::CompilerContext mCompilerContext;
|
MWScript::CompilerContext mCompilerContext;
|
||||||
std::ostream mErrorStream;
|
std::ostream mErrorStream;
|
||||||
@ -50,21 +53,21 @@ namespace MWDialogue
|
|||||||
|
|
||||||
DialogueManager (const Compiler::Extensions& extensions);
|
DialogueManager (const Compiler::Extensions& extensions);
|
||||||
|
|
||||||
void startDialogue (const MWWorld::Ptr& actor);
|
virtual void startDialogue (const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
void addTopic(std::string topic);
|
virtual void addTopic (const std::string& topic);
|
||||||
|
|
||||||
void askQuestion(std::string question,int choice);
|
virtual void askQuestion (const std::string& question,int choice);
|
||||||
|
|
||||||
void goodbye();
|
virtual void goodbye();
|
||||||
|
|
||||||
///get the faction of the actor you are talking with
|
///get the faction of the actor you are talking with
|
||||||
std::string getFaction();
|
virtual std::string getFaction() const;
|
||||||
|
|
||||||
//calbacks for the GUI
|
//calbacks for the GUI
|
||||||
void keywordSelected(std::string keyword);
|
virtual void keywordSelected (const std::string& keyword);
|
||||||
void goodbyeSelected();
|
virtual void goodbyeSelected();
|
||||||
void questionAnswered(std::string answere);
|
virtual void questionAnswered (const std::string& answer);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
@ -27,16 +28,14 @@ namespace MWDialogue
|
|||||||
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic);
|
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic);
|
||||||
}
|
}
|
||||||
|
|
||||||
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index,
|
JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index)
|
||||||
const MWWorld::World& world)
|
|
||||||
{
|
{
|
||||||
return JournalEntry (topic, idFromIndex (topic, index, world));
|
return JournalEntry (topic, idFromIndex (topic, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string JournalEntry::idFromIndex (const std::string& topic, int index,
|
std::string JournalEntry::idFromIndex (const std::string& topic, int index)
|
||||||
const MWWorld::World& world)
|
|
||||||
{
|
{
|
||||||
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic);
|
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (topic);
|
||||||
|
|
||||||
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
||||||
iter!=dialogue->mInfo.end(); ++iter)
|
iter!=dialogue->mInfo.end(); ++iter)
|
||||||
@ -57,13 +56,12 @@ namespace MWDialogue
|
|||||||
: JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth)
|
: JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index,
|
StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index)
|
||||||
const MWWorld::World& world)
|
|
||||||
{
|
{
|
||||||
int day = world.getGlobalVariable ("dayspassed").mLong;
|
int day = MWBase::Environment::get().getWorld()->getGlobalVariable ("dayspassed").mLong;
|
||||||
int month = world.getGlobalVariable ("day").mLong;
|
int month = MWBase::Environment::get().getWorld()->getGlobalVariable ("day").mLong;
|
||||||
int dayOfMonth = world.getGlobalVariable ("month").mLong;
|
int dayOfMonth = MWBase::Environment::get().getWorld()->getGlobalVariable ("month").mLong;
|
||||||
|
|
||||||
return StampedJournalEntry (topic, idFromIndex (topic, index, world), day, month, dayOfMonth);
|
return StampedJournalEntry (topic, idFromIndex (topic, index), day, month, dayOfMonth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef GAME_MMDIALOGUE_JOURNALENTRY_H
|
#ifndef GAME_MWDIALOGUE_JOURNALENTRY_H
|
||||||
#define GAME_MMDIALOGUE_JOURNALENTRY_H
|
#define GAME_MWDIALOGUE_JOURNALENTRY_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -8,11 +8,6 @@ namespace ESMS
|
|||||||
struct ESMStore;
|
struct ESMStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class World;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
/// \brief A quest or dialogue entry
|
/// \brief A quest or dialogue entry
|
||||||
@ -27,11 +22,9 @@ namespace MWDialogue
|
|||||||
|
|
||||||
std::string getText (const ESMS::ESMStore& store) const;
|
std::string getText (const ESMS::ESMStore& store) const;
|
||||||
|
|
||||||
static JournalEntry makeFromQuest (const std::string& topic, int index,
|
static JournalEntry makeFromQuest (const std::string& topic, int index);
|
||||||
const MWWorld::World& world);
|
|
||||||
|
|
||||||
static std::string idFromIndex (const std::string& topic, int index,
|
static std::string idFromIndex (const std::string& topic, int index);
|
||||||
const MWWorld::World& world);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \biref A quest entry with a timestamp.
|
/// \biref A quest entry with a timestamp.
|
||||||
@ -46,8 +39,7 @@ namespace MWDialogue
|
|||||||
StampedJournalEntry (const std::string& topic, const std::string& infoId,
|
StampedJournalEntry (const std::string& topic, const std::string& infoId,
|
||||||
int day, int month, int dayOfMonth);
|
int day, int month, int dayOfMonth);
|
||||||
|
|
||||||
static StampedJournalEntry makeFromQuest (const std::string& topic, int index,
|
static StampedJournalEntry makeFromQuest (const std::string& topic, int index);
|
||||||
const MWWorld::World& world);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
|
||||||
#include "journal.hpp"
|
#include "journalimp.hpp"
|
||||||
|
|
||||||
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwgui/window_manager.hpp"
|
|
||||||
#include "../mwgui/messagebox.hpp"
|
#include "../mwgui/messagebox.hpp"
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
Quest& Journal::getQuest (const std::string& id)
|
Quest& Journal::getQuest (const std::string& id)
|
||||||
@ -30,17 +31,16 @@ namespace MWDialogue
|
|||||||
|
|
||||||
void Journal::addEntry (const std::string& id, int index)
|
void Journal::addEntry (const std::string& id, int index)
|
||||||
{
|
{
|
||||||
StampedJournalEntry entry =
|
StampedJournalEntry entry = StampedJournalEntry::makeFromQuest (id, index);
|
||||||
StampedJournalEntry::makeFromQuest (id, index, *MWBase::Environment::get().getWorld());
|
|
||||||
|
|
||||||
mJournal.push_back (entry);
|
mJournal.push_back (entry);
|
||||||
|
|
||||||
Quest& quest = getQuest (id);
|
Quest& quest = getQuest (id);
|
||||||
|
|
||||||
quest.addEntry (entry, *MWBase::Environment::get().getWorld()); // we are doing slicing on purpose here
|
quest.addEntry (entry); // we are doing slicing on purpose here
|
||||||
|
|
||||||
std::vector<std::string> empty;
|
std::vector<std::string> empty;
|
||||||
std::string notification = MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sJournalEntry")->str;
|
std::string notification = "#{sJournalEntry}";
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox (notification, empty);
|
MWBase::Environment::get().getWindowManager()->messageBox (notification, empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ namespace MWDialogue
|
|||||||
{
|
{
|
||||||
Quest& quest = getQuest (id);
|
Quest& quest = getQuest (id);
|
||||||
|
|
||||||
quest.setIndex (index, *MWBase::Environment::get().getWorld());
|
quest.setIndex (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Journal::addTopic (const std::string& topicId, const std::string& infoId)
|
void Journal::addTopic (const std::string& topicId, const std::string& infoId)
|
||||||
@ -63,7 +63,7 @@ namespace MWDialogue
|
|||||||
iter = result.first;
|
iter = result.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
iter->second.addEntry (JournalEntry (topicId, infoId), *MWBase::Environment::get().getWorld());
|
iter->second.addEntry (JournalEntry (topicId, infoId));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Journal::getJournalIndex (const std::string& id) const
|
int Journal::getJournalIndex (const std::string& id) const
|
@ -1,9 +1,7 @@
|
|||||||
#ifndef GAME_MMDIALOG_JOURNAL_H
|
#ifndef GAME_MWDIALOG_JOURNAL_H
|
||||||
#define GAME_MWDIALOG_JOURNAL_H
|
#define GAME_MWDIALOG_JOURNAL_H
|
||||||
|
|
||||||
#include <string>
|
#include "../mwbase/journal.hpp"
|
||||||
#include <deque>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "journalentry.hpp"
|
#include "journalentry.hpp"
|
||||||
#include "quest.hpp"
|
#include "quest.hpp"
|
||||||
@ -11,19 +9,8 @@
|
|||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
/// \brief The player's journal
|
/// \brief The player's journal
|
||||||
class Journal
|
class Journal : public MWBase::Journal
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
|
|
||||||
typedef std::deque<StampedJournalEntry> TEntryContainer;
|
|
||||||
typedef TEntryContainer::const_iterator TEntryIter;
|
|
||||||
typedef std::map<std::string, Quest> TQuestContainer; // topc, quest
|
|
||||||
typedef TQuestContainer::const_iterator TQuestIter;
|
|
||||||
typedef std::map<std::string, Topic> TTopicContainer; // topic-id, topic-content
|
|
||||||
typedef TTopicContainer::const_iterator TTopicIter;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
TEntryContainer mJournal;
|
TEntryContainer mJournal;
|
||||||
TQuestContainer mQuests;
|
TQuestContainer mQuests;
|
||||||
TTopicContainer mTopics;
|
TTopicContainer mTopics;
|
||||||
@ -34,37 +21,37 @@ namespace MWDialogue
|
|||||||
|
|
||||||
Journal();
|
Journal();
|
||||||
|
|
||||||
void addEntry (const std::string& id, int index);
|
virtual void addEntry (const std::string& id, int index);
|
||||||
///< Add a journal entry.
|
///< Add a journal entry.
|
||||||
|
|
||||||
void setJournalIndex (const std::string& id, int index);
|
virtual void setJournalIndex (const std::string& id, int index);
|
||||||
///< Set the journal index without adding an entry.
|
///< Set the journal index without adding an entry.
|
||||||
|
|
||||||
int getJournalIndex (const std::string& id) const;
|
virtual int getJournalIndex (const std::string& id) const;
|
||||||
///< Get the journal index.
|
///< Get the journal index.
|
||||||
|
|
||||||
void addTopic (const std::string& topicId, const std::string& infoId);
|
virtual void addTopic (const std::string& topicId, const std::string& infoId);
|
||||||
|
|
||||||
TEntryIter begin() const;
|
virtual TEntryIter begin() const;
|
||||||
///< Iterator pointing to the begin of the main journal.
|
///< Iterator pointing to the begin of the main journal.
|
||||||
///
|
///
|
||||||
/// \note Iterators to main journal entries will never become invalid.
|
/// \note Iterators to main journal entries will never become invalid.
|
||||||
|
|
||||||
TEntryIter end() const;
|
virtual TEntryIter end() const;
|
||||||
///< Iterator pointing past the end of the main journal.
|
///< Iterator pointing past the end of the main journal.
|
||||||
|
|
||||||
TQuestIter questBegin() const;
|
virtual TQuestIter questBegin() const;
|
||||||
///< Iterator pointing to the first quest (sorted by topic ID)
|
///< Iterator pointing to the first quest (sorted by topic ID)
|
||||||
|
|
||||||
TQuestIter questEnd() const;
|
virtual TQuestIter questEnd() const;
|
||||||
///< Iterator pointing past the last quest.
|
///< Iterator pointing past the last quest.
|
||||||
|
|
||||||
TTopicIter topicBegin() const;
|
virtual TTopicIter topicBegin() const;
|
||||||
///< Iterator pointing to the first topic (sorted by topic ID)
|
///< Iterator pointing to the first topic (sorted by topic ID)
|
||||||
///
|
///
|
||||||
/// \note The topic ID is identical with the user-visible topic string.
|
/// \note The topic ID is identical with the user-visible topic string.
|
||||||
|
|
||||||
TTopicIter topicEnd() const;
|
virtual TTopicIter topicEnd() const;
|
||||||
///< Iterator pointing past the last topic.
|
///< Iterator pointing past the last topic.
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
@ -15,9 +16,9 @@ namespace MWDialogue
|
|||||||
: Topic (topic), mIndex (0), mFinished (false)
|
: Topic (topic), mIndex (0), mFinished (false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const std::string Quest::getName (const MWWorld::World& world) const
|
const std::string Quest::getName() const
|
||||||
{
|
{
|
||||||
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic);
|
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic);
|
||||||
|
|
||||||
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
||||||
iter!=dialogue->mInfo.end(); ++iter)
|
iter!=dialogue->mInfo.end(); ++iter)
|
||||||
@ -32,9 +33,9 @@ namespace MWDialogue
|
|||||||
return mIndex;
|
return mIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quest::setIndex (int index, const MWWorld::World& world)
|
void Quest::setIndex (int index)
|
||||||
{
|
{
|
||||||
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (mTopic);
|
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic);
|
||||||
|
|
||||||
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
||||||
iter!=dialogue->mInfo.end(); ++iter)
|
iter!=dialogue->mInfo.end(); ++iter)
|
||||||
@ -58,11 +59,11 @@ namespace MWDialogue
|
|||||||
return mFinished;
|
return mFinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quest::addEntry (const JournalEntry& entry, const MWWorld::World& world)
|
void Quest::addEntry (const JournalEntry& entry)
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
|
||||||
const ESM::Dialogue *dialogue = world.getStore().dialogs.find (entry.mTopic);
|
const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (entry.mTopic);
|
||||||
|
|
||||||
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
|
||||||
iter!=dialogue->mInfo.end(); ++iter)
|
iter!=dialogue->mInfo.end(); ++iter)
|
||||||
@ -75,7 +76,7 @@ namespace MWDialogue
|
|||||||
if (index==-1)
|
if (index==-1)
|
||||||
throw std::runtime_error ("unknown journal entry for topic " + mTopic);
|
throw std::runtime_error ("unknown journal entry for topic " + mTopic);
|
||||||
|
|
||||||
setIndex (index, world);
|
setIndex (index);
|
||||||
|
|
||||||
for (TEntryIter iter (mEntries.begin()); iter!=mEntries.end(); ++iter)
|
for (TEntryIter iter (mEntries.begin()); iter!=mEntries.end(); ++iter)
|
||||||
if (*iter==entry.mInfoId)
|
if (*iter==entry.mInfoId)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef GAME_MMDIALOG_QUEST_H
|
#ifndef GAME_MWDIALOG_QUEST_H
|
||||||
#define GAME_MWDIALOG_QUEST_H
|
#define GAME_MWDIALOG_QUEST_H
|
||||||
|
|
||||||
#include "topic.hpp"
|
#include "topic.hpp"
|
||||||
@ -17,17 +17,17 @@ namespace MWDialogue
|
|||||||
|
|
||||||
Quest (const std::string& topic);
|
Quest (const std::string& topic);
|
||||||
|
|
||||||
const std::string getName (const MWWorld::World& world) const;
|
const std::string getName() const;
|
||||||
///< May be an empty string
|
///< May be an empty string
|
||||||
|
|
||||||
int getIndex() const;
|
int getIndex() const;
|
||||||
|
|
||||||
void setIndex (int index, const MWWorld::World& world);
|
void setIndex (int index);
|
||||||
///< Calling this function with a non-existant index while throw an exception.
|
///< Calling this function with a non-existant index while throw an exception.
|
||||||
|
|
||||||
bool isFinished() const;
|
bool isFinished() const;
|
||||||
|
|
||||||
virtual void addEntry (const JournalEntry& entry, const MWWorld::World& world);
|
virtual void addEntry (const JournalEntry& entry);
|
||||||
///< Add entry and adjust index accordingly.
|
///< Add entry and adjust index accordingly.
|
||||||
///
|
///
|
||||||
/// \note Redundant entries are ignored, but the index is still adjusted.
|
/// \note Redundant entries are ignored, but the index is still adjusted.
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
Topic::Topic()
|
Topic::Topic()
|
||||||
@ -17,7 +15,7 @@ namespace MWDialogue
|
|||||||
Topic::~Topic()
|
Topic::~Topic()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Topic::addEntry (const JournalEntry& entry, const MWWorld::World& world)
|
void Topic::addEntry (const JournalEntry& entry)
|
||||||
{
|
{
|
||||||
if (entry.mTopic!=mTopic)
|
if (entry.mTopic!=mTopic)
|
||||||
throw std::runtime_error ("topic does not match: " + mTopic);
|
throw std::runtime_error ("topic does not match: " + mTopic);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#ifndef GAME_MMDIALOG_TOPIC_H
|
#ifndef GAME_MWDIALOG_TOPIC_H
|
||||||
#define GAME_MWDIALOG_TOPIC_H
|
#define GAME_MWDIALOG_TOPIC_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -6,11 +6,6 @@
|
|||||||
|
|
||||||
#include "journalentry.hpp"
|
#include "journalentry.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class World;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWDialogue
|
namespace MWDialogue
|
||||||
{
|
{
|
||||||
/// \brief Collection of seen responses for a topic
|
/// \brief Collection of seen responses for a topic
|
||||||
@ -34,7 +29,7 @@ namespace MWDialogue
|
|||||||
|
|
||||||
virtual ~Topic();
|
virtual ~Topic();
|
||||||
|
|
||||||
virtual void addEntry (const JournalEntry& entry, const MWWorld::World& world);
|
virtual void addEntry (const JournalEntry& entry);
|
||||||
///< Add entry
|
///< Add entry
|
||||||
///
|
///
|
||||||
/// \note Redundant entries are ignored.
|
/// \note Redundant entries are ignored.
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/manualref.hpp"
|
#include "../mwworld/manualref.hpp"
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
#include "window_manager.hpp"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -26,8 +26,8 @@ namespace
|
|||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
AlchemyWindow::AlchemyWindow(WindowManager& parWindowManager)
|
AlchemyWindow::AlchemyWindow(MWBase::WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_alchemy_window_layout.xml", parWindowManager)
|
: WindowBase("openmw_alchemy_window.layout", parWindowManager)
|
||||||
, ContainerBase(0)
|
, ContainerBase(0)
|
||||||
{
|
{
|
||||||
getWidget(mCreateButton, "CreateButton");
|
getWidget(mCreateButton, "CreateButton");
|
||||||
@ -48,14 +48,6 @@ namespace MWGui
|
|||||||
mIngredient3->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected);
|
mIngredient3->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected);
|
||||||
mIngredient4->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected);
|
mIngredient4->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected);
|
||||||
|
|
||||||
MyGUI::Widget* buttonBox = mCancelButton->getParent();
|
|
||||||
int cancelButtonWidth = mCancelButton->getTextSize().width + 24;
|
|
||||||
mCancelButton->setCoord(buttonBox->getWidth() - cancelButtonWidth,
|
|
||||||
mCancelButton->getTop(), cancelButtonWidth, mCancelButton->getHeight());
|
|
||||||
int createButtonWidth = mCreateButton->getTextSize().width + 24;
|
|
||||||
mCreateButton->setCoord(buttonBox->getWidth() - createButtonWidth - cancelButtonWidth - 4,
|
|
||||||
mCreateButton->getTop(), createButtonWidth, mCreateButton->getHeight());
|
|
||||||
|
|
||||||
mCreateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCreateButtonClicked);
|
mCreateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCreateButtonClicked);
|
||||||
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCancelButtonClicked);
|
mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCancelButtonClicked);
|
||||||
|
|
||||||
@ -275,7 +267,7 @@ namespace MWGui
|
|||||||
for (MWWorld::ContainerStoreIterator it(store.begin(MWWorld::ContainerStore::Type_Apparatus));
|
for (MWWorld::ContainerStoreIterator it(store.begin(MWWorld::ContainerStore::Type_Apparatus));
|
||||||
it != store.end(); ++it)
|
it != store.end(); ++it)
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData>* ref = it->get<ESM::Apparatus>();
|
MWWorld::LiveCellRef<ESM::Apparatus>* ref = it->get<ESM::Apparatus>();
|
||||||
if (ref->base->data.type == ESM::Apparatus::Albemic
|
if (ref->base->data.type == ESM::Apparatus::Albemic
|
||||||
&& (bestAlbemic.isEmpty() || ref->base->data.quality > bestAlbemic.get<ESM::Apparatus>()->base->data.quality))
|
&& (bestAlbemic.isEmpty() || ref->base->data.quality > bestAlbemic.get<ESM::Apparatus>()->base->data.quality))
|
||||||
bestAlbemic = *it;
|
bestAlbemic = *it;
|
||||||
@ -420,7 +412,7 @@ namespace MWGui
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// add the effects of this ingredient to list of effects
|
// add the effects of this ingredient to list of effects
|
||||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData>* ref = ingredient->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>();
|
MWWorld::LiveCellRef<ESM::Ingredient>* ref = ingredient->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>();
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
{
|
{
|
||||||
if (ref->base->data.effectID[i] < 0)
|
if (ref->base->data.effectID[i] < 0)
|
||||||
@ -493,7 +485,7 @@ namespace MWGui
|
|||||||
|
|
||||||
MyGUI::IntCoord coord(0, 0, mEffectsBox->getWidth(), 24);
|
MyGUI::IntCoord coord(0, 0, mEffectsBox->getWidth(), 24);
|
||||||
Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget<Widgets::MWEffectList>
|
Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget<Widgets::MWEffectList>
|
||||||
("MW_StatName", coord, Align::Left | Align::Top);
|
("MW_StatName", coord, MyGUI::Align::Left | MyGUI::Align::Top);
|
||||||
effectsWidget->setWindowManager(&mWindowManager);
|
effectsWidget->setWindowManager(&mWindowManager);
|
||||||
effectsWidget->setEffectList(effects);
|
effectsWidget->setEffectList(effects);
|
||||||
|
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
#include "container.hpp"
|
#include "container.hpp"
|
||||||
|
#include "widgets.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class AlchemyWindow : public WindowBase, public ContainerBase
|
class AlchemyWindow : public WindowBase, public ContainerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AlchemyWindow(WindowManager& parWindowManager);
|
AlchemyWindow(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
||||||
|
@ -1,29 +1,34 @@
|
|||||||
#include "birth.hpp"
|
#include "birth.hpp"
|
||||||
#include "window_manager.hpp"
|
|
||||||
#include "widgets.hpp"
|
|
||||||
#include "components/esm_store/store.hpp"
|
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include "components/esm_store/store.hpp"
|
||||||
|
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "widgets.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
BirthDialog::BirthDialog(WindowManager& parWindowManager)
|
BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_birth_layout.xml", parWindowManager)
|
: WindowBase("openmw_chargen_birth.layout", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
getWidget(spellArea, "SpellArea");
|
getWidget(mSpellArea, "SpellArea");
|
||||||
|
|
||||||
getWidget(birthImage, "BirthsignImage");
|
getWidget(mBirthImage, "BirthsignImage");
|
||||||
|
|
||||||
getWidget(birthList, "BirthsignList");
|
getWidget(mBirthList, "BirthsignList");
|
||||||
birthList->setScrollVisible(true);
|
mBirthList->setScrollVisible(true);
|
||||||
birthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
mBirthList->eventListSelectAccept += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||||
birthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
mBirthList->eventListMouseItemActivate += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||||
birthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
mBirthList->eventListChangePosition += MyGUI::newDelegate(this, &BirthDialog::onSelectBirth);
|
||||||
|
|
||||||
MyGUI::ButtonPtr backButton;
|
MyGUI::ButtonPtr backButton;
|
||||||
getWidget(backButton, "BackButton");
|
getWidget(backButton, "BackButton");
|
||||||
@ -40,9 +45,6 @@ BirthDialog::BirthDialog(WindowManager& parWindowManager)
|
|||||||
|
|
||||||
void BirthDialog::setNextButtonShow(bool shown)
|
void BirthDialog::setNextButtonShow(bool shown)
|
||||||
{
|
{
|
||||||
MyGUI::ButtonPtr backButton;
|
|
||||||
getWidget(backButton, "BackButton");
|
|
||||||
|
|
||||||
MyGUI::ButtonPtr okButton;
|
MyGUI::ButtonPtr okButton;
|
||||||
getWidget(okButton, "OKButton");
|
getWidget(okButton, "OKButton");
|
||||||
|
|
||||||
@ -50,32 +52,26 @@ void BirthDialog::setNextButtonShow(bool shown)
|
|||||||
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
|
okButton->setCaption(mWindowManager.getGameSettingString("sNext", ""));
|
||||||
else
|
else
|
||||||
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
|
okButton->setCaption(mWindowManager.getGameSettingString("sOK", ""));
|
||||||
|
|
||||||
int okButtonWidth = okButton->getTextSize().width + 24;
|
|
||||||
int backButtonWidth = backButton->getTextSize().width + 24;
|
|
||||||
|
|
||||||
okButton->setCoord(473 - okButtonWidth, 340, okButtonWidth, 23);
|
|
||||||
backButton->setCoord(473 - okButtonWidth - backButtonWidth - 6, 340, backButtonWidth, 23);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BirthDialog::open()
|
void BirthDialog::open()
|
||||||
{
|
{
|
||||||
|
WindowBase::open();
|
||||||
updateBirths();
|
updateBirths();
|
||||||
updateSpells();
|
updateSpells();
|
||||||
setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BirthDialog::setBirthId(const std::string &birthId)
|
void BirthDialog::setBirthId(const std::string &birthId)
|
||||||
{
|
{
|
||||||
currentBirthId = birthId;
|
mCurrentBirthId = birthId;
|
||||||
birthList->setIndexSelected(MyGUI::ITEM_NONE);
|
mBirthList->setIndexSelected(MyGUI::ITEM_NONE);
|
||||||
size_t count = birthList->getItemCount();
|
size_t count = mBirthList->getItemCount();
|
||||||
for (size_t i = 0; i < count; ++i)
|
for (size_t i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
if (boost::iequals(*birthList->getItemDataAt<std::string>(i), birthId))
|
if (boost::iequals(*mBirthList->getItemDataAt<std::string>(i), birthId))
|
||||||
{
|
{
|
||||||
birthList->setIndexSelected(i);
|
mBirthList->setIndexSelected(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,11 +96,11 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
|
|||||||
if (_index == MyGUI::ITEM_NONE)
|
if (_index == MyGUI::ITEM_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::string *birthId = birthList->getItemDataAt<std::string>(_index);
|
const std::string *birthId = mBirthList->getItemDataAt<std::string>(_index);
|
||||||
if (boost::iequals(currentBirthId, *birthId))
|
if (boost::iequals(mCurrentBirthId, *birthId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentBirthId = *birthId;
|
mCurrentBirthId = *birthId;
|
||||||
updateSpells();
|
updateSpells();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,9 +108,9 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index)
|
|||||||
|
|
||||||
void BirthDialog::updateBirths()
|
void BirthDialog::updateBirths()
|
||||||
{
|
{
|
||||||
birthList->removeAllItems();
|
mBirthList->removeAllItems();
|
||||||
|
|
||||||
const ESMS::ESMStore &store = mWindowManager.getStore();
|
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
|
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin();
|
||||||
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
|
ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end();
|
||||||
@ -122,34 +118,34 @@ void BirthDialog::updateBirths()
|
|||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
{
|
{
|
||||||
const ESM::BirthSign &birth = it->second;
|
const ESM::BirthSign &birth = it->second;
|
||||||
birthList->addItem(birth.name, it->first);
|
mBirthList->addItem(birth.name, it->first);
|
||||||
if (boost::iequals(it->first, currentBirthId))
|
if (boost::iequals(it->first, mCurrentBirthId))
|
||||||
birthList->setIndexSelected(index);
|
mBirthList->setIndexSelected(index);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BirthDialog::updateSpells()
|
void BirthDialog::updateSpells()
|
||||||
{
|
{
|
||||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = spellItems.begin(); it != spellItems.end(); ++it)
|
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSpellItems.begin(); it != mSpellItems.end(); ++it)
|
||||||
{
|
{
|
||||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||||
}
|
}
|
||||||
spellItems.clear();
|
mSpellItems.clear();
|
||||||
|
|
||||||
if (currentBirthId.empty())
|
if (mCurrentBirthId.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MWSpellPtr spellWidget;
|
MWSpellPtr spellWidget;
|
||||||
const int lineHeight = 18;
|
const int lineHeight = 18;
|
||||||
MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18);
|
MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18);
|
||||||
|
|
||||||
const ESMS::ESMStore &store = mWindowManager.getStore();
|
const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||||
const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId);
|
const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId);
|
||||||
|
|
||||||
std::string texturePath = std::string("textures\\") + birth->texture;
|
std::string texturePath = std::string("textures\\") + birth->texture;
|
||||||
fixTexturePath(texturePath);
|
fixTexturePath(texturePath);
|
||||||
birthImage->setImageTexture(texturePath);
|
mBirthImage->setImageTexture(texturePath);
|
||||||
|
|
||||||
std::vector<std::string> abilities, powers, spells;
|
std::vector<std::string> abilities, powers, spells;
|
||||||
|
|
||||||
@ -183,25 +179,25 @@ void BirthDialog::updateSpells()
|
|||||||
{
|
{
|
||||||
if (!categories[category].spells.empty())
|
if (!categories[category].spells.empty())
|
||||||
{
|
{
|
||||||
MyGUI::TextBox* label = spellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
|
MyGUI::TextBox* label = mSpellArea->createWidget<MyGUI::TextBox>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
|
||||||
label->setCaption(mWindowManager.getGameSettingString(categories[category].label, ""));
|
label->setCaption(mWindowManager.getGameSettingString(categories[category].label, ""));
|
||||||
spellItems.push_back(label);
|
mSpellItems.push_back(label);
|
||||||
coord.top += lineHeight;
|
coord.top += lineHeight;
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator end = categories[category].spells.end();
|
std::vector<std::string>::const_iterator end = categories[category].spells.end();
|
||||||
for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != end; ++it)
|
for (std::vector<std::string>::const_iterator it = categories[category].spells.begin(); it != end; ++it)
|
||||||
{
|
{
|
||||||
const std::string &spellId = *it;
|
const std::string &spellId = *it;
|
||||||
spellWidget = spellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i));
|
spellWidget = mSpellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i));
|
||||||
spellWidget->setWindowManager(&mWindowManager);
|
spellWidget->setWindowManager(&mWindowManager);
|
||||||
spellWidget->setSpellId(spellId);
|
spellWidget->setSpellId(spellId);
|
||||||
|
|
||||||
spellItems.push_back(spellWidget);
|
mSpellItems.push_back(spellWidget);
|
||||||
coord.top += lineHeight;
|
coord.top += lineHeight;
|
||||||
|
|
||||||
MyGUI::IntCoord spellCoord = coord;
|
MyGUI::IntCoord spellCoord = coord;
|
||||||
spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template?
|
spellCoord.height = 24; // TODO: This should be fetched from the skin somehow, or perhaps a widget in the layout as a template?
|
||||||
spellWidget->createEffectWidgets(spellItems, spellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0);
|
spellWidget->createEffectWidgets(mSpellItems, mSpellArea, spellCoord, (category == 0) ? MWEffectList::EF_Constant : 0);
|
||||||
coord.top = spellCoord.top;
|
coord.top = spellCoord.top;
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
|
@ -5,19 +5,15 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains the dialog for choosing a birth sign.
|
This file contains the dialog for choosing a birth sign.
|
||||||
Layout is defined by resources/mygui/openmw_chargen_race_layout.xml.
|
Layout is defined by resources/mygui/openmw_chargen_race.layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
using namespace MyGUI;
|
|
||||||
|
|
||||||
class WindowManager;
|
|
||||||
|
|
||||||
class BirthDialog : public WindowBase
|
class BirthDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BirthDialog(WindowManager& parWindowManager);
|
BirthDialog(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
enum Gender
|
enum Gender
|
||||||
{
|
{
|
||||||
@ -25,14 +21,14 @@ namespace MWGui
|
|||||||
GM_Female
|
GM_Female
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string &getBirthId() const { return currentBirthId; }
|
const std::string &getBirthId() const { return mCurrentBirthId; }
|
||||||
void setBirthId(const std::string &raceId);
|
void setBirthId(const std::string &raceId);
|
||||||
|
|
||||||
void setNextButtonShow(bool shown);
|
void setNextButtonShow(bool shown);
|
||||||
void open();
|
virtual void open();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Back button clicked.\n
|
/** Event : Back button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -49,12 +45,12 @@ namespace MWGui
|
|||||||
void updateBirths();
|
void updateBirths();
|
||||||
void updateSpells();
|
void updateSpells();
|
||||||
|
|
||||||
MyGUI::ListBox* birthList;
|
MyGUI::ListBox* mBirthList;
|
||||||
MyGUI::WidgetPtr spellArea;
|
MyGUI::WidgetPtr mSpellArea;
|
||||||
MyGUI::ImageBox* birthImage;
|
MyGUI::ImageBox* mBirthImage;
|
||||||
std::vector<MyGUI::WidgetPtr> spellItems;
|
std::vector<MyGUI::WidgetPtr> mSpellItems;
|
||||||
|
|
||||||
std::string currentBirthId;
|
std::string mCurrentBirthId;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,17 +3,19 @@
|
|||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwinput/inputmanager.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "formatting.hpp"
|
#include "formatting.hpp"
|
||||||
#include "window_manager.hpp"
|
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
BookWindow::BookWindow (WindowManager& parWindowManager) :
|
BookWindow::BookWindow (MWBase::WindowManager& parWindowManager) :
|
||||||
WindowBase("openmw_book_layout.xml", parWindowManager)
|
WindowBase("openmw_book.layout", parWindowManager)
|
||||||
{
|
{
|
||||||
getWidget(mCloseButton, "CloseButton");
|
getWidget(mCloseButton, "CloseButton");
|
||||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
|
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
|
||||||
@ -55,8 +57,7 @@ void BookWindow::open (MWWorld::Ptr book)
|
|||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0);
|
||||||
|
|
||||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
MWWorld::LiveCellRef<ESM::Book> *ref = mBook.get<ESM::Book>();
|
||||||
mBook.get<ESM::Book>();
|
|
||||||
|
|
||||||
BookTextParser parser;
|
BookTextParser parser;
|
||||||
std::vector<std::string> results = parser.split(ref->base->text, mLeftPage->getSize().width, mLeftPage->getSize().height);
|
std::vector<std::string> results = parser.split(ref->base->text, mLeftPage->getSize().width, mLeftPage->getSize().height);
|
||||||
@ -97,10 +98,10 @@ void BookWindow::onCloseButtonClicked (MyGUI::Widget* _sender)
|
|||||||
|
|
||||||
void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
void BookWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWSound::Play_NoTrack);
|
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
||||||
|
|
||||||
MWWorld::ActionTake take(mBook);
|
MWWorld::ActionTake take(mBook);
|
||||||
take.execute();
|
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
|
|
||||||
mWindowManager.removeGuiMode(GM_Book);
|
mWindowManager.removeGuiMode(GM_Book);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace MWGui
|
|||||||
class BookWindow : public WindowBase
|
class BookWindow : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BookWindow(WindowManager& parWindowManager);
|
BookWindow(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
void open(MWWorld::Ptr book);
|
void open(MWWorld::Ptr book);
|
||||||
void setTakeButtonShow(bool show);
|
void setTakeButtonShow(bool show);
|
||||||
@ -43,4 +43,3 @@ namespace MWGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
#include "mode.hpp"
|
#include "mode.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -103,11 +104,19 @@ namespace
|
|||||||
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
|
{ESM::Class::Combat, ESM::Class::Magic, ESM::Class::Stealth}
|
||||||
}
|
}
|
||||||
} };
|
} };
|
||||||
|
|
||||||
|
struct ClassPoint
|
||||||
|
{
|
||||||
|
const char *id;
|
||||||
|
// Specialization points to match, in order: Stealth, Combat, Magic
|
||||||
|
// Note: Order is taken from http://www.uesp.net/wiki/Morrowind:Class_Quiz
|
||||||
|
unsigned int points[3];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
CharacterCreation::CharacterCreation(WindowManager* _wm)
|
CharacterCreation::CharacterCreation(MWBase::WindowManager* _wm)
|
||||||
: mNameDialog(0)
|
: mNameDialog(0)
|
||||||
, mRaceDialog(0)
|
, mRaceDialog(0)
|
||||||
, mClassChoiceDialog(0)
|
, mClassChoiceDialog(0)
|
||||||
@ -142,7 +151,7 @@ void CharacterCreation::setValue (const std::string& id, const MWMechanics::Stat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
void CharacterCreation::setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
if (mReviewDialog)
|
||||||
{
|
{
|
||||||
@ -178,64 +187,64 @@ void CharacterCreation::spawnDialog(const char id)
|
|||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case GM_Name:
|
case GM_Name:
|
||||||
if(mNameDialog)
|
mWM->removeDialog(mNameDialog);
|
||||||
mWM->removeDialog(mNameDialog);
|
mNameDialog = 0;
|
||||||
mNameDialog = new TextInputDialog(*mWM);
|
mNameDialog = new TextInputDialog(*mWM);
|
||||||
mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
|
mNameDialog->setTextLabel(mWM->getGameSettingString("sName", "Name"));
|
||||||
mNameDialog->setTextInput(mPlayerName);
|
mNameDialog->setTextInput(mPlayerName);
|
||||||
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
|
mNameDialog->setNextButtonShow(mCreationStage >= CSE_NameChosen);
|
||||||
mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
|
mNameDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onNameDialogDone);
|
||||||
mNameDialog->open();
|
mNameDialog->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GM_Race:
|
case GM_Race:
|
||||||
if (mRaceDialog)
|
mWM->removeDialog(mRaceDialog);
|
||||||
mWM->removeDialog(mRaceDialog);
|
mRaceDialog = 0;
|
||||||
mRaceDialog = new RaceDialog(*mWM);
|
mRaceDialog = new RaceDialog(*mWM);
|
||||||
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
|
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
|
||||||
mRaceDialog->setRaceId(mPlayerRaceId);
|
mRaceDialog->setRaceId(mPlayerRaceId);
|
||||||
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
||||||
mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
|
mRaceDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogBack);
|
||||||
mRaceDialog->open();
|
mRaceDialog->setVisible(true);;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GM_Class:
|
case GM_Class:
|
||||||
if (mClassChoiceDialog)
|
mWM->removeDialog(mClassChoiceDialog);
|
||||||
mWM->removeDialog(mClassChoiceDialog);
|
mClassChoiceDialog = 0;
|
||||||
mClassChoiceDialog = new ClassChoiceDialog(*mWM);
|
mClassChoiceDialog = new ClassChoiceDialog(*mWM);
|
||||||
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
|
mClassChoiceDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassChoice);
|
||||||
mClassChoiceDialog->open();
|
mClassChoiceDialog->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GM_ClassPick:
|
case GM_ClassPick:
|
||||||
if (mPickClassDialog)
|
mWM->removeDialog(mPickClassDialog);
|
||||||
mWM->removeDialog(mPickClassDialog);
|
mPickClassDialog = 0;
|
||||||
mPickClassDialog = new PickClassDialog(*mWM);
|
mPickClassDialog = new PickClassDialog(*mWM);
|
||||||
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
mPickClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
||||||
mPickClassDialog->setClassId(mPlayerClass.name);
|
mPickClassDialog->setClassId(mPlayerClass.name);
|
||||||
mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
|
mPickClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogDone);
|
||||||
mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
|
mPickClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onPickClassDialogBack);
|
||||||
mPickClassDialog->open();
|
mPickClassDialog->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GM_Birth:
|
case GM_Birth:
|
||||||
if (mBirthSignDialog)
|
mWM->removeDialog(mBirthSignDialog);
|
||||||
mWM->removeDialog(mBirthSignDialog);
|
mBirthSignDialog = 0;
|
||||||
mBirthSignDialog = new BirthDialog(*mWM);
|
mBirthSignDialog = new BirthDialog(*mWM);
|
||||||
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
|
mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen);
|
||||||
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
|
mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone);
|
||||||
mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
|
mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack);
|
||||||
mBirthSignDialog->open();
|
mBirthSignDialog->setVisible(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GM_ClassCreate:
|
case GM_ClassCreate:
|
||||||
if (mCreateClassDialog)
|
mWM->removeDialog(mCreateClassDialog);
|
||||||
mWM->removeDialog(mCreateClassDialog);
|
mCreateClassDialog = 0;
|
||||||
mCreateClassDialog = new CreateClassDialog(*mWM);
|
mCreateClassDialog = new CreateClassDialog(*mWM);
|
||||||
mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
|
||||||
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
|
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
|
||||||
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
|
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
|
||||||
mCreateClassDialog->open();
|
mCreateClassDialog->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case GM_ClassGenerate:
|
case GM_ClassGenerate:
|
||||||
mGenerateClassStep = 0;
|
mGenerateClassStep = 0;
|
||||||
@ -246,8 +255,8 @@ void CharacterCreation::spawnDialog(const char id)
|
|||||||
showClassQuestionDialog();
|
showClassQuestionDialog();
|
||||||
break;
|
break;
|
||||||
case GM_Review:
|
case GM_Review:
|
||||||
if (mReviewDialog)
|
mWM->removeDialog(mReviewDialog);
|
||||||
mWM->removeDialog(mReviewDialog);
|
mReviewDialog = 0;
|
||||||
mReviewDialog = new ReviewDialog(*mWM);
|
mReviewDialog = new ReviewDialog(*mWM);
|
||||||
mReviewDialog->setPlayerName(mPlayerName);
|
mReviewDialog->setPlayerName(mPlayerName);
|
||||||
mReviewDialog->setRace(mPlayerRaceId);
|
mReviewDialog->setRace(mPlayerRaceId);
|
||||||
@ -259,20 +268,20 @@ void CharacterCreation::spawnDialog(const char id)
|
|||||||
mReviewDialog->setFatigue(mPlayerFatigue);
|
mReviewDialog->setFatigue(mPlayerFatigue);
|
||||||
|
|
||||||
{
|
{
|
||||||
std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> > attributes = mWM->getPlayerAttributeValues();
|
std::map<int, MWMechanics::Stat<int> > attributes = mWM->getPlayerAttributeValues();
|
||||||
for (std::map<ESM::Attribute::AttributeID, MWMechanics::Stat<int> >::iterator it = attributes.begin();
|
for (std::map<int, MWMechanics::Stat<int> >::iterator it = attributes.begin();
|
||||||
it != attributes.end(); ++it)
|
it != attributes.end(); ++it)
|
||||||
{
|
{
|
||||||
mReviewDialog->setAttribute(it->first, it->second);
|
mReviewDialog->setAttribute(static_cast<ESM::Attribute::AttributeID> (it->first), it->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> > skills = mWM->getPlayerSkillValues();
|
std::map<int, MWMechanics::Stat<float> > skills = mWM->getPlayerSkillValues();
|
||||||
for (std::map<ESM::Skill::SkillEnum, MWMechanics::Stat<float> >::iterator it = skills.begin();
|
for (std::map<int, MWMechanics::Stat<float> >::iterator it = skills.begin();
|
||||||
it != skills.end(); ++it)
|
it != skills.end(); ++it)
|
||||||
{
|
{
|
||||||
mReviewDialog->setSkillValue(it->first, it->second);
|
mReviewDialog->setSkillValue(static_cast<ESM::Skill::SkillEnum> (it->first), it->second);
|
||||||
}
|
}
|
||||||
mReviewDialog->configureSkills(mWM->getPlayerMajorSkills(), mWM->getPlayerMinorSkills());
|
mReviewDialog->configureSkills(mWM->getPlayerMajorSkills(), mWM->getPlayerMinorSkills());
|
||||||
}
|
}
|
||||||
@ -280,46 +289,46 @@ void CharacterCreation::spawnDialog(const char id)
|
|||||||
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
mReviewDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogDone);
|
||||||
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
mReviewDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onReviewDialogBack);
|
||||||
mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
|
mReviewDialog->eventActivateDialog += MyGUI::newDelegate(this, &CharacterCreation::onReviewActivateDialog);
|
||||||
mReviewDialog->open();
|
mReviewDialog->setVisible(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::setPlayerHealth (const MWMechanics::DynamicStat<int>& value)
|
void CharacterCreation::setPlayerHealth (const MWMechanics::DynamicStat<float>& value)
|
||||||
{
|
{
|
||||||
mPlayerHealth = value;
|
mPlayerHealth = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::setPlayerMagicka (const MWMechanics::DynamicStat<int>& value)
|
void CharacterCreation::setPlayerMagicka (const MWMechanics::DynamicStat<float>& value)
|
||||||
{
|
{
|
||||||
mPlayerMagicka = value;
|
mPlayerMagicka = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::setPlayerFatigue (const MWMechanics::DynamicStat<int>& value)
|
void CharacterCreation::setPlayerFatigue (const MWMechanics::DynamicStat<float>& value)
|
||||||
{
|
{
|
||||||
mPlayerFatigue = value;
|
mPlayerFatigue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
|
void CharacterCreation::onReviewDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
mWM->removeDialog(mReviewDialog);
|
||||||
mWM->removeDialog(mReviewDialog);
|
mReviewDialog = 0;
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onReviewDialogBack()
|
void CharacterCreation::onReviewDialogBack()
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
mWM->removeDialog(mReviewDialog);
|
||||||
mWM->removeDialog(mReviewDialog);
|
mReviewDialog = 0;
|
||||||
|
|
||||||
mWM->pushGuiMode(GM_Birth);
|
mWM->pushGuiMode(GM_Birth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterCreation::onReviewActivateDialog(int parDialog)
|
void CharacterCreation::onReviewActivateDialog(int parDialog)
|
||||||
{
|
{
|
||||||
if (mReviewDialog)
|
mWM->removeDialog(mReviewDialog);
|
||||||
mWM->removeDialog(mReviewDialog);
|
mReviewDialog = 0;
|
||||||
mCreationStage = CSE_ReviewNext;
|
mCreationStage = CSE_ReviewNext;
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
@ -354,6 +363,7 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow)
|
|||||||
mWM->setPlayerClass(mPlayerClass);
|
mWM->setPlayerClass(mPlayerClass);
|
||||||
}
|
}
|
||||||
mWM->removeDialog(mPickClassDialog);
|
mWM->removeDialog(mPickClassDialog);
|
||||||
|
mPickClassDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO This bit gets repeated a few times; wrap it in a function
|
//TODO This bit gets repeated a few times; wrap it in a function
|
||||||
@ -382,6 +392,7 @@ void CharacterCreation::onPickClassDialogBack()
|
|||||||
if (!classId.empty())
|
if (!classId.empty())
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId);
|
||||||
mWM->removeDialog(mPickClassDialog);
|
mWM->removeDialog(mPickClassDialog);
|
||||||
|
mPickClassDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
@ -390,10 +401,8 @@ void CharacterCreation::onPickClassDialogBack()
|
|||||||
|
|
||||||
void CharacterCreation::onClassChoice(int _index)
|
void CharacterCreation::onClassChoice(int _index)
|
||||||
{
|
{
|
||||||
if (mClassChoiceDialog)
|
mWM->removeDialog(mClassChoiceDialog);
|
||||||
{
|
mClassChoiceDialog = 0;
|
||||||
mWM->removeDialog(mClassChoiceDialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
|
|
||||||
@ -423,6 +432,7 @@ void CharacterCreation::onNameDialogDone(WindowBase* parWindow)
|
|||||||
mWM->setValue("name", mPlayerName);
|
mWM->setValue("name", mPlayerName);
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerName(mPlayerName);
|
||||||
mWM->removeDialog(mNameDialog);
|
mWM->removeDialog(mNameDialog);
|
||||||
|
mNameDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCreationStage == CSE_ReviewNext)
|
if (mCreationStage == CSE_ReviewNext)
|
||||||
@ -450,6 +460,7 @@ void CharacterCreation::onRaceDialogBack()
|
|||||||
if (!mPlayerRaceId.empty())
|
if (!mPlayerRaceId.empty())
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
|
||||||
mWM->removeDialog(mRaceDialog);
|
mWM->removeDialog(mRaceDialog);
|
||||||
|
mRaceDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
@ -465,6 +476,7 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow)
|
|||||||
if (!mPlayerRaceId.empty())
|
if (!mPlayerRaceId.empty())
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male);
|
||||||
mWM->removeDialog(mRaceDialog);
|
mWM->removeDialog(mRaceDialog);
|
||||||
|
mRaceDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCreationStage == CSE_ReviewNext)
|
if (mCreationStage == CSE_ReviewNext)
|
||||||
@ -492,6 +504,7 @@ void CharacterCreation::onBirthSignDialogDone(WindowBase* parWindow)
|
|||||||
if (!mPlayerBirthSignId.empty())
|
if (!mPlayerBirthSignId.empty())
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mPlayerBirthSignId);
|
||||||
mWM->removeDialog(mBirthSignDialog);
|
mWM->removeDialog(mBirthSignDialog);
|
||||||
|
mBirthSignDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCreationStage >= CSE_BirthSignChosen)
|
if (mCreationStage >= CSE_BirthSignChosen)
|
||||||
@ -512,6 +525,7 @@ void CharacterCreation::onBirthSignDialogBack()
|
|||||||
{
|
{
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId());
|
MWBase::Environment::get().getMechanicsManager()->setPlayerBirthsign(mBirthSignDialog->getBirthId());
|
||||||
mWM->removeDialog(mBirthSignDialog);
|
mWM->removeDialog(mBirthSignDialog);
|
||||||
|
mBirthSignDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
@ -547,6 +561,7 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
|
|||||||
mWM->setPlayerClass(klass);
|
mWM->setPlayerClass(klass);
|
||||||
|
|
||||||
mWM->removeDialog(mCreateClassDialog);
|
mWM->removeDialog(mCreateClassDialog);
|
||||||
|
mCreateClassDialog = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCreationStage == CSE_ReviewNext)
|
if (mCreationStage == CSE_ReviewNext)
|
||||||
@ -568,8 +583,8 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow)
|
|||||||
|
|
||||||
void CharacterCreation::onCreateClassDialogBack()
|
void CharacterCreation::onCreateClassDialogBack()
|
||||||
{
|
{
|
||||||
if (mCreateClassDialog)
|
mWM->removeDialog(mCreateClassDialog);
|
||||||
mWM->removeDialog(mCreateClassDialog);
|
mCreateClassDialog = 0;
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
mWM->pushGuiMode(GM_Class);
|
mWM->pushGuiMode(GM_Class);
|
||||||
@ -579,8 +594,9 @@ void CharacterCreation::onClassQuestionChosen(int _index)
|
|||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->stopSay();
|
MWBase::Environment::get().getSoundManager()->stopSay();
|
||||||
|
|
||||||
if (mGenerateClassQuestionDialog)
|
mWM->removeDialog(mGenerateClassQuestionDialog);
|
||||||
mWM->removeDialog(mGenerateClassQuestionDialog);
|
mGenerateClassQuestionDialog = 0;
|
||||||
|
|
||||||
if (_index < 0 || _index >= 3)
|
if (_index < 0 || _index >= 3)
|
||||||
{
|
{
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
@ -657,13 +673,14 @@ void CharacterCreation::showClassQuestionDialog()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGenerateClassResultDialog)
|
mWM->removeDialog(mGenerateClassResultDialog);
|
||||||
mWM->removeDialog(mGenerateClassResultDialog);
|
mGenerateClassResultDialog = 0;
|
||||||
|
|
||||||
mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
|
mGenerateClassResultDialog = new GenerateClassResultDialog(*mWM);
|
||||||
mGenerateClassResultDialog->setClassId(mGenerateClass);
|
mGenerateClassResultDialog->setClassId(mGenerateClass);
|
||||||
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
|
mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
|
||||||
mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
|
mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
|
||||||
mGenerateClassResultDialog->open();
|
mGenerateClassResultDialog->setVisible(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -674,8 +691,9 @@ void CharacterCreation::showClassQuestionDialog()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGenerateClassQuestionDialog)
|
mWM->removeDialog(mGenerateClassQuestionDialog);
|
||||||
mWM->removeDialog(mGenerateClassQuestionDialog);
|
mGenerateClassQuestionDialog = 0;
|
||||||
|
|
||||||
mGenerateClassQuestionDialog = new InfoBoxDialog(*mWM);
|
mGenerateClassQuestionDialog = new InfoBoxDialog(*mWM);
|
||||||
|
|
||||||
InfoBoxDialog::ButtonList buttons;
|
InfoBoxDialog::ButtonList buttons;
|
||||||
@ -685,7 +703,7 @@ void CharacterCreation::showClassQuestionDialog()
|
|||||||
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
|
buttons.push_back(sGenerateClassSteps[mGenerateClassStep].mButtons[2]);
|
||||||
mGenerateClassQuestionDialog->setButtons(buttons);
|
mGenerateClassQuestionDialog->setButtons(buttons);
|
||||||
mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
|
mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
|
||||||
mGenerateClassQuestionDialog->open();
|
mGenerateClassQuestionDialog->setVisible(true);
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound);
|
MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps[mGenerateClassStep].mSound);
|
||||||
}
|
}
|
||||||
@ -695,8 +713,9 @@ void CharacterCreation::onGenerateClassBack()
|
|||||||
if(mCreationStage < CSE_ClassChosen)
|
if(mCreationStage < CSE_ClassChosen)
|
||||||
mCreationStage = CSE_ClassChosen;
|
mCreationStage = CSE_ClassChosen;
|
||||||
|
|
||||||
if (mGenerateClassResultDialog)
|
mWM->removeDialog(mGenerateClassResultDialog);
|
||||||
mWM->removeDialog(mGenerateClassResultDialog);
|
mGenerateClassResultDialog = 0;
|
||||||
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
|
||||||
|
|
||||||
mWM->popGuiMode();
|
mWM->popGuiMode();
|
||||||
@ -705,8 +724,9 @@ void CharacterCreation::onGenerateClassBack()
|
|||||||
|
|
||||||
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
|
void CharacterCreation::onGenerateClassDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (mGenerateClassResultDialog)
|
mWM->removeDialog(mGenerateClassResultDialog);
|
||||||
mWM->removeDialog(mGenerateClassResultDialog);
|
mGenerateClassResultDialog = 0;
|
||||||
|
|
||||||
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
|
MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass);
|
||||||
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass);
|
const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass);
|
||||||
mPlayerClass = *klass;
|
mPlayerClass = *klass;
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
#ifndef CHARACTER_CREATION_HPP
|
#ifndef CHARACTER_CREATION_HPP
|
||||||
#define CHARACTER_CREATION_HPP
|
#define CHARACTER_CREATION_HPP
|
||||||
|
|
||||||
#include "window_manager.hpp"
|
|
||||||
|
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class WindowManager;
|
|
||||||
class WindowBase;
|
class WindowBase;
|
||||||
|
|
||||||
class TextInputDialog;
|
class TextInputDialog;
|
||||||
@ -30,20 +29,20 @@ namespace MWGui
|
|||||||
public:
|
public:
|
||||||
typedef std::vector<int> SkillList;
|
typedef std::vector<int> SkillList;
|
||||||
|
|
||||||
CharacterCreation(WindowManager* _wm);
|
CharacterCreation(MWBase::WindowManager* _wm);
|
||||||
~CharacterCreation();
|
~CharacterCreation();
|
||||||
|
|
||||||
//Show a dialog
|
//Show a dialog
|
||||||
void spawnDialog(const char id);
|
void spawnDialog(const char id);
|
||||||
|
|
||||||
void setPlayerHealth (const MWMechanics::DynamicStat<int>& value);
|
void setPlayerHealth (const MWMechanics::DynamicStat<float>& value);
|
||||||
|
|
||||||
void setPlayerMagicka (const MWMechanics::DynamicStat<int>& value);
|
void setPlayerMagicka (const MWMechanics::DynamicStat<float>& value);
|
||||||
|
|
||||||
void setPlayerFatigue (const MWMechanics::DynamicStat<int>& value);
|
void setPlayerFatigue (const MWMechanics::DynamicStat<float>& value);
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value);
|
||||||
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
||||||
void configureSkills (const SkillList& major, const SkillList& minor);
|
void configureSkills (const SkillList& major, const SkillList& minor);
|
||||||
|
|
||||||
@ -59,16 +58,16 @@ namespace MWGui
|
|||||||
BirthDialog* mBirthSignDialog;
|
BirthDialog* mBirthSignDialog;
|
||||||
ReviewDialog* mReviewDialog;
|
ReviewDialog* mReviewDialog;
|
||||||
|
|
||||||
WindowManager* mWM;
|
MWBase::WindowManager* mWM;
|
||||||
|
|
||||||
//Player data
|
//Player data
|
||||||
std::string mPlayerName;
|
std::string mPlayerName;
|
||||||
std::string mPlayerRaceId;
|
std::string mPlayerRaceId;
|
||||||
std::string mPlayerBirthSignId;
|
std::string mPlayerBirthSignId;
|
||||||
ESM::Class mPlayerClass;
|
ESM::Class mPlayerClass;
|
||||||
MWMechanics::DynamicStat<int> mPlayerHealth;
|
MWMechanics::DynamicStat<float> mPlayerHealth;
|
||||||
MWMechanics::DynamicStat<int> mPlayerMagicka;
|
MWMechanics::DynamicStat<float> mPlayerMagicka;
|
||||||
MWMechanics::DynamicStat<int> mPlayerFatigue;
|
MWMechanics::DynamicStat<float> mPlayerFatigue;
|
||||||
|
|
||||||
//Class generation vars
|
//Class generation vars
|
||||||
unsigned mGenerateClassStep; // Keeps track of current step in Generate Class dialog
|
unsigned mGenerateClassStep; // Keeps track of current step in Generate Class dialog
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,19 +7,15 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains the dialogs for choosing a class.
|
This file contains the dialogs for choosing a class.
|
||||||
Layout is defined by resources/mygui/openmw_chargen_class_layout.xml.
|
Layout is defined by resources/mygui/openmw_chargen_class.layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
using namespace MyGUI;
|
|
||||||
|
|
||||||
class WindowManager;
|
|
||||||
|
|
||||||
class InfoBoxDialog : public WindowBase
|
class InfoBoxDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InfoBoxDialog(WindowManager& parWindowManager);
|
InfoBoxDialog(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
typedef std::vector<std::string> ButtonList;
|
typedef std::vector<std::string> ButtonList;
|
||||||
|
|
||||||
@ -27,11 +23,11 @@ namespace MWGui
|
|||||||
std::string getText() const;
|
std::string getText() const;
|
||||||
void setButtons(ButtonList &buttons);
|
void setButtons(ButtonList &buttons);
|
||||||
|
|
||||||
void open();
|
virtual void open();
|
||||||
int getChosenButton() const;
|
int getChosenButton() const;
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate1<int> EventHandle_Int;
|
typedef MyGUI::delegates::CMultiDelegate1<int> EventHandle_Int;
|
||||||
|
|
||||||
/** Event : Button was clicked.\n
|
/** Event : Button was clicked.\n
|
||||||
signature : void method(int index)\n
|
signature : void method(int index)\n
|
||||||
@ -45,11 +41,11 @@ namespace MWGui
|
|||||||
|
|
||||||
void fitToText(MyGUI::TextBox* widget);
|
void fitToText(MyGUI::TextBox* widget);
|
||||||
void layoutVertically(MyGUI::WidgetPtr widget, int margin);
|
void layoutVertically(MyGUI::WidgetPtr widget, int margin);
|
||||||
int currentButton;
|
int mCurrentButton;
|
||||||
MyGUI::WidgetPtr textBox;
|
MyGUI::WidgetPtr mTextBox;
|
||||||
MyGUI::TextBox* text;
|
MyGUI::TextBox* mText;
|
||||||
MyGUI::WidgetPtr buttonBar;
|
MyGUI::WidgetPtr mButtonBar;
|
||||||
std::vector<MyGUI::ButtonPtr> buttons;
|
std::vector<MyGUI::ButtonPtr> mButtons;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lets the player choose between 3 ways of creating a class
|
// Lets the player choose between 3 ways of creating a class
|
||||||
@ -64,21 +60,19 @@ namespace MWGui
|
|||||||
Class_Create = 2,
|
Class_Create = 2,
|
||||||
Class_Back = 3
|
Class_Back = 3
|
||||||
};
|
};
|
||||||
ClassChoiceDialog(WindowManager& parWindowManager);
|
ClassChoiceDialog(MWBase::WindowManager& parWindowManager);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GenerateClassResultDialog : public WindowBase
|
class GenerateClassResultDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GenerateClassResultDialog(WindowManager& parWindowManager);
|
GenerateClassResultDialog(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
std::string getClassId() const;
|
std::string getClassId() const;
|
||||||
void setClassId(const std::string &classId);
|
void setClassId(const std::string &classId);
|
||||||
|
|
||||||
void open();
|
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Back button clicked.\n
|
/** Event : Back button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -90,25 +84,25 @@ namespace MWGui
|
|||||||
void onBackClicked(MyGUI::Widget* _sender);
|
void onBackClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyGUI::ImageBox* classImage;
|
MyGUI::ImageBox* mClassImage;
|
||||||
MyGUI::TextBox* className;
|
MyGUI::TextBox* mClassName;
|
||||||
|
|
||||||
std::string currentClassId;
|
std::string mCurrentClassId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PickClassDialog : public WindowBase
|
class PickClassDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PickClassDialog(WindowManager& parWindowManager);
|
PickClassDialog(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
const std::string &getClassId() const { return currentClassId; }
|
const std::string &getClassId() const { return mCurrentClassId; }
|
||||||
void setClassId(const std::string &classId);
|
void setClassId(const std::string &classId);
|
||||||
|
|
||||||
void setNextButtonShow(bool shown);
|
void setNextButtonShow(bool shown);
|
||||||
void open();
|
virtual void open();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Back button clicked.\n
|
/** Event : Back button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -125,26 +119,26 @@ namespace MWGui
|
|||||||
void updateClasses();
|
void updateClasses();
|
||||||
void updateStats();
|
void updateStats();
|
||||||
|
|
||||||
MyGUI::ImageBox* classImage;
|
MyGUI::ImageBox* mClassImage;
|
||||||
MyGUI::ListBox* classList;
|
MyGUI::ListBox* mClassList;
|
||||||
MyGUI::TextBox* specializationName;
|
MyGUI::TextBox* mSpecializationName;
|
||||||
Widgets::MWAttributePtr favoriteAttribute[2];
|
Widgets::MWAttributePtr mFavoriteAttribute[2];
|
||||||
Widgets::MWSkillPtr majorSkill[5];
|
Widgets::MWSkillPtr mMajorSkill[5];
|
||||||
Widgets::MWSkillPtr minorSkill[5];
|
Widgets::MWSkillPtr mMinorSkill[5];
|
||||||
|
|
||||||
std::string currentClassId;
|
std::string mCurrentClassId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectSpecializationDialog : public WindowBase
|
class SelectSpecializationDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectSpecializationDialog(WindowManager& parWindowManager);
|
SelectSpecializationDialog(MWBase::WindowManager& parWindowManager);
|
||||||
~SelectSpecializationDialog();
|
~SelectSpecializationDialog();
|
||||||
|
|
||||||
ESM::Class::Specialization getSpecializationId() const { return specializationId; }
|
ESM::Class::Specialization getSpecializationId() const { return mSpecializationId; }
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Cancel button clicked.\n
|
/** Event : Cancel button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -161,23 +155,23 @@ namespace MWGui
|
|||||||
void onCancelClicked(MyGUI::Widget* _sender);
|
void onCancelClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyGUI::TextBox *specialization0, *specialization1, *specialization2;
|
MyGUI::TextBox *mSpecialization0, *mSpecialization1, *mSpecialization2;
|
||||||
|
|
||||||
ESM::Class::Specialization specializationId;
|
ESM::Class::Specialization mSpecializationId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectAttributeDialog : public WindowBase
|
class SelectAttributeDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectAttributeDialog(WindowManager& parWindowManager);
|
SelectAttributeDialog(MWBase::WindowManager& parWindowManager);
|
||||||
~SelectAttributeDialog();
|
~SelectAttributeDialog();
|
||||||
|
|
||||||
ESM::Attribute::AttributeID getAttributeId() const { return attributeId; }
|
ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; }
|
||||||
Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; }
|
Widgets::MWAttributePtr getAffectedWidget() const { return mAffectedWidget; }
|
||||||
void setAffectedWidget(Widgets::MWAttributePtr widget) { affectedWidget = widget; }
|
void setAffectedWidget(Widgets::MWAttributePtr widget) { mAffectedWidget = widget; }
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Cancel button clicked.\n
|
/** Event : Cancel button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -194,23 +188,23 @@ namespace MWGui
|
|||||||
void onCancelClicked(MyGUI::Widget* _sender);
|
void onCancelClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Widgets::MWAttributePtr affectedWidget;
|
Widgets::MWAttributePtr mAffectedWidget;
|
||||||
|
|
||||||
ESM::Attribute::AttributeID attributeId;
|
ESM::Attribute::AttributeID mAttributeId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SelectSkillDialog : public WindowBase
|
class SelectSkillDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectSkillDialog(WindowManager& parWindowManager);
|
SelectSkillDialog(MWBase::WindowManager& parWindowManager);
|
||||||
~SelectSkillDialog();
|
~SelectSkillDialog();
|
||||||
|
|
||||||
ESM::Skill::SkillEnum getSkillId() const { return skillId; }
|
ESM::Skill::SkillEnum getSkillId() const { return mSkillId; }
|
||||||
Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; }
|
Widgets::MWSkillPtr getAffectedWidget() const { return mAffectedWidget; }
|
||||||
void setAffectedWidget(Widgets::MWSkillPtr widget) { affectedWidget = widget; }
|
void setAffectedWidget(Widgets::MWSkillPtr widget) { mAffectedWidget = widget; }
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Cancel button clicked.\n
|
/** Event : Cancel button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -227,34 +221,34 @@ namespace MWGui
|
|||||||
void onCancelClicked(MyGUI::Widget* _sender);
|
void onCancelClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Widgets::MWSkillPtr combatSkill[9];
|
Widgets::MWSkillPtr mCombatSkill[9];
|
||||||
Widgets::MWSkillPtr magicSkill[9];
|
Widgets::MWSkillPtr mMagicSkill[9];
|
||||||
Widgets::MWSkillPtr stealthSkill[9];
|
Widgets::MWSkillPtr mStealthSkill[9];
|
||||||
Widgets::MWSkillPtr affectedWidget;
|
Widgets::MWSkillPtr mAffectedWidget;
|
||||||
|
|
||||||
ESM::Skill::SkillEnum skillId;
|
ESM::Skill::SkillEnum mSkillId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DescriptionDialog : public WindowBase
|
class DescriptionDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DescriptionDialog(WindowManager& parWindowManager);
|
DescriptionDialog(MWBase::WindowManager& parWindowManager);
|
||||||
~DescriptionDialog();
|
~DescriptionDialog();
|
||||||
|
|
||||||
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
|
std::string getTextInput() const { return mTextEdit ? mTextEdit->getOnlyText() : ""; }
|
||||||
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }
|
void setTextInput(const std::string &text) { if (mTextEdit) mTextEdit->setOnlyText(text); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOkClicked(MyGUI::Widget* _sender);
|
void onOkClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyGUI::EditPtr textEdit;
|
MyGUI::EditPtr mTextEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CreateClassDialog : public WindowBase
|
class CreateClassDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CreateClassDialog(WindowManager& parWindowManager);
|
CreateClassDialog(MWBase::WindowManager& parWindowManager);
|
||||||
virtual ~CreateClassDialog();
|
virtual ~CreateClassDialog();
|
||||||
|
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
@ -265,10 +259,9 @@ namespace MWGui
|
|||||||
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
|
std::vector<ESM::Skill::SkillEnum> getMinorSkills() const;
|
||||||
|
|
||||||
void setNextButtonShow(bool shown);
|
void setNextButtonShow(bool shown);
|
||||||
void open();
|
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
|
||||||
/** Event : Back button clicked.\n
|
/** Event : Back button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
@ -294,20 +287,20 @@ namespace MWGui
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MyGUI::EditPtr editName;
|
MyGUI::EditPtr mEditName;
|
||||||
MyGUI::TextBox* specializationName;
|
MyGUI::TextBox* mSpecializationName;
|
||||||
Widgets::MWAttributePtr favoriteAttribute0, favoriteAttribute1;
|
Widgets::MWAttributePtr mFavoriteAttribute0, mFavoriteAttribute1;
|
||||||
Widgets::MWSkillPtr majorSkill[5];
|
Widgets::MWSkillPtr mMajorSkill[5];
|
||||||
Widgets::MWSkillPtr minorSkill[5];
|
Widgets::MWSkillPtr mMinorSkill[5];
|
||||||
std::vector<Widgets::MWSkillPtr> skills;
|
std::vector<Widgets::MWSkillPtr> mSkills;
|
||||||
std::string description;
|
std::string mDescription;
|
||||||
|
|
||||||
SelectSpecializationDialog *specDialog;
|
SelectSpecializationDialog *mSpecDialog;
|
||||||
SelectAttributeDialog *attribDialog;
|
SelectAttributeDialog *mAttribDialog;
|
||||||
SelectSkillDialog *skillDialog;
|
SelectSkillDialog *mSkillDialog;
|
||||||
DescriptionDialog *descDialog;
|
DescriptionDialog *mDescDialog;
|
||||||
|
|
||||||
ESM::Class::Specialization specializationId;
|
ESM::Class::Specialization mSpecializationId;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
ConfirmationDialog::ConfirmationDialog(WindowManager& parWindowManager) :
|
ConfirmationDialog::ConfirmationDialog(MWBase::WindowManager& parWindowManager) :
|
||||||
WindowBase("openmw_confirmation_dialog_layout.xml", parWindowManager)
|
WindowModal("openmw_confirmation_dialog.layout", parWindowManager)
|
||||||
{
|
{
|
||||||
getWidget(mMessage, "Message");
|
getWidget(mMessage, "Message");
|
||||||
getWidget(mOkButton, "OkButton");
|
getWidget(mOkButton, "OkButton");
|
||||||
@ -31,40 +31,19 @@ namespace MWGui
|
|||||||
mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height+24);
|
mMessage->setSize(mMessage->getWidth(), mMessage->getTextSize().height+24);
|
||||||
|
|
||||||
center();
|
center();
|
||||||
|
|
||||||
// make other gui elements inaccessible while this dialog is open
|
|
||||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
|
||||||
|
|
||||||
int okButtonWidth = mOkButton->getTextSize().width + 24;
|
|
||||||
mOkButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth,
|
|
||||||
mOkButton->getTop(),
|
|
||||||
okButtonWidth,
|
|
||||||
mOkButton->getHeight());
|
|
||||||
|
|
||||||
int cancelButtonWidth = mCancelButton->getTextSize().width + 24;
|
|
||||||
mCancelButton->setCoord(mMainWidget->getWidth() - 30 - okButtonWidth - cancelButtonWidth - 8,
|
|
||||||
mCancelButton->getTop(),
|
|
||||||
cancelButtonWidth,
|
|
||||||
mCancelButton->getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
void ConfirmationDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventCancelClicked();
|
eventCancelClicked();
|
||||||
|
|
||||||
close();
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
void ConfirmationDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventOkClicked();
|
eventOkClicked();
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfirmationDialog::close()
|
|
||||||
{
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class ConfirmationDialog : public WindowBase
|
class ConfirmationDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfirmationDialog(WindowManager& parWindowManager);
|
ConfirmationDialog(MWBase::WindowManager& parWindowManager);
|
||||||
void open(const std::string& message);
|
void open(const std::string& message);
|
||||||
|
|
||||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
@ -26,8 +26,6 @@ namespace MWGui
|
|||||||
|
|
||||||
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
void onCancelButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
void close();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <components/esm_store/reclists.hpp>
|
||||||
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include <components/compiler/exception.hpp>
|
#include <components/compiler/exception.hpp>
|
||||||
|
|
||||||
@ -102,9 +106,10 @@ namespace MWGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console::Console(int w, int h, const Compiler::Extensions& extensions)
|
Console::Console(int w, int h, bool consoleOnlyScripts)
|
||||||
: Layout("openmw_console_layout.xml"),
|
: Layout("openmw_console.layout"),
|
||||||
mCompilerContext (MWScript::CompilerContext::Type_Console)
|
mCompilerContext (MWScript::CompilerContext::Type_Console),
|
||||||
|
mConsoleOnlyScripts (consoleOnlyScripts)
|
||||||
{
|
{
|
||||||
setCoord(10,10, w-10, h/2);
|
setCoord(10,10, w-10, h/2);
|
||||||
|
|
||||||
@ -123,7 +128,8 @@ namespace MWGui
|
|||||||
history->setVisibleVScroll(true);
|
history->setVisibleVScroll(true);
|
||||||
|
|
||||||
// compiler
|
// compiler
|
||||||
mCompilerContext.setExtensions (&extensions);
|
MWScript::registerExtensions (mExtensions, mConsoleOnlyScripts);
|
||||||
|
mCompilerContext.setExtensions (&mExtensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Console::enable()
|
void Console::enable()
|
||||||
@ -170,6 +176,47 @@ namespace MWGui
|
|||||||
print("#FF2222" + msg + "\n");
|
print("#FF2222" + msg + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Console::execute (const std::string& command)
|
||||||
|
{
|
||||||
|
// Log the command
|
||||||
|
print("#FFFFFF> " + command + "\n");
|
||||||
|
|
||||||
|
Compiler::Locals locals;
|
||||||
|
Compiler::Output output (locals);
|
||||||
|
|
||||||
|
if (compile (command + "\n", output))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ConsoleInterpreterContext interpreterContext (*this, mPtr);
|
||||||
|
Interpreter::Interpreter interpreter;
|
||||||
|
MWScript::installOpcodes (interpreter, mConsoleOnlyScripts);
|
||||||
|
std::vector<Interpreter::Type_Code> code;
|
||||||
|
output.getCode (code);
|
||||||
|
interpreter.run (&code[0], code.size(), interpreterContext);
|
||||||
|
}
|
||||||
|
catch (const std::exception& error)
|
||||||
|
{
|
||||||
|
printError (std::string ("An exception has been thrown: ") + error.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Console::executeFile (const std::string& path)
|
||||||
|
{
|
||||||
|
std::ifstream stream (path.c_str());
|
||||||
|
|
||||||
|
if (!stream.is_open())
|
||||||
|
printError ("failed to open file: " + path);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string line;
|
||||||
|
|
||||||
|
while (std::getline (stream, line))
|
||||||
|
execute (line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Console::keyPress(MyGUI::WidgetPtr _sender,
|
void Console::keyPress(MyGUI::WidgetPtr _sender,
|
||||||
MyGUI::KeyCode key,
|
MyGUI::KeyCode key,
|
||||||
MyGUI::Char _char)
|
MyGUI::Char _char)
|
||||||
@ -231,28 +278,7 @@ namespace MWGui
|
|||||||
current = command_history.end();
|
current = command_history.end();
|
||||||
editString.clear();
|
editString.clear();
|
||||||
|
|
||||||
// Log the command
|
execute (cm);
|
||||||
print("#FFFFFF> " + cm + "\n");
|
|
||||||
|
|
||||||
Compiler::Locals locals;
|
|
||||||
Compiler::Output output (locals);
|
|
||||||
|
|
||||||
if (compile (cm + "\n", output))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ConsoleInterpreterContext interpreterContext (*this, mPtr);
|
|
||||||
Interpreter::Interpreter interpreter;
|
|
||||||
MWScript::installOpcodes (interpreter);
|
|
||||||
std::vector<Interpreter::Type_Code> code;
|
|
||||||
output.getCode (code);
|
|
||||||
interpreter.run (&code[0], code.size(), interpreterContext);
|
|
||||||
}
|
|
||||||
catch (const std::exception& error)
|
|
||||||
{
|
|
||||||
printError (std::string ("An exception has been thrown: ") + error.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
command->setCaption("");
|
command->setCaption("");
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <components/compiler/scanner.hpp>
|
#include <components/compiler/scanner.hpp>
|
||||||
#include <components/compiler/locals.hpp>
|
#include <components/compiler/locals.hpp>
|
||||||
#include <components/compiler/output.hpp>
|
#include <components/compiler/output.hpp>
|
||||||
|
#include <components/compiler/extensions.hpp>
|
||||||
#include <components/interpreter/interpreter.hpp>
|
#include <components/interpreter/interpreter.hpp>
|
||||||
|
|
||||||
#include "../mwscript/compilercontext.hpp"
|
#include "../mwscript/compilercontext.hpp"
|
||||||
@ -24,8 +25,10 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Compiler::Extensions mExtensions;
|
||||||
MWScript::CompilerContext mCompilerContext;
|
MWScript::CompilerContext mCompilerContext;
|
||||||
std::vector<std::string> mNames;
|
std::vector<std::string> mNames;
|
||||||
|
bool mConsoleOnlyScripts;
|
||||||
|
|
||||||
bool compile (const std::string& cmd, Compiler::Output& output);
|
bool compile (const std::string& cmd, Compiler::Output& output);
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ namespace MWGui
|
|||||||
StringList::iterator current;
|
StringList::iterator current;
|
||||||
std::string editString;
|
std::string editString;
|
||||||
|
|
||||||
Console(int w, int h, const Compiler::Extensions& extensions);
|
Console(int w, int h, bool consoleOnlyScripts);
|
||||||
|
|
||||||
void enable();
|
void enable();
|
||||||
|
|
||||||
@ -86,6 +89,10 @@ namespace MWGui
|
|||||||
/// Error message
|
/// Error message
|
||||||
void printError(const std::string &msg);
|
void printError(const std::string &msg);
|
||||||
|
|
||||||
|
void execute (const std::string& command);
|
||||||
|
|
||||||
|
void executeFile (const std::string& command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void keyPress(MyGUI::WidgetPtr _sender,
|
void keyPress(MyGUI::WidgetPtr _sender,
|
||||||
|
@ -3,22 +3,23 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/manualref.hpp"
|
#include "../mwworld/manualref.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwclass/container.hpp"
|
|
||||||
#include "../mwinput/inputmanager.hpp"
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
|
||||||
|
|
||||||
#include "window_manager.hpp"
|
#include "../mwclass/container.hpp"
|
||||||
|
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "countdialog.hpp"
|
#include "countdialog.hpp"
|
||||||
#include "tradewindow.hpp"
|
#include "tradewindow.hpp"
|
||||||
@ -75,7 +76,7 @@ ContainerBase::ContainerBase(DragAndDrop* dragAndDrop) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContainerBase::setWidgets(Widget* containerWidget, ScrollView* itemView)
|
void ContainerBase::setWidgets(MyGUI::Widget* containerWidget, MyGUI::ScrollView* itemView)
|
||||||
{
|
{
|
||||||
mContainerWidget = containerWidget;
|
mContainerWidget = containerWidget;
|
||||||
mItemView = itemView;
|
mItemView = itemView;
|
||||||
@ -109,7 +110,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string message = MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sTake")->str;
|
std::string message = "#{sTake}";
|
||||||
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
CountDialog* dialog = MWBase::Environment::get().getWindowManager()->getCountDialog();
|
||||||
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
dialog->open(MWWorld::Class::get(object).getName(object), message, count);
|
||||||
dialog->eventOkClicked.clear();
|
dialog->eventOkClicked.clear();
|
||||||
@ -129,18 +130,17 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender)
|
|||||||
// the player is trying to sell an item, check if the merchant accepts it
|
// the player is trying to sell an item, check if the merchant accepts it
|
||||||
// also, don't allow selling gold (let's be better than Morrowind at this, can we?)
|
// also, don't allow selling gold (let's be better than Morrowind at this, can we?)
|
||||||
if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object)
|
if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object)
|
||||||
|| MWWorld::Class::get(object).getName(object) == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGold")->str)
|
|| MWWorld::Class::get(object).getName(object) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString())
|
||||||
{
|
{
|
||||||
// user notification "i don't buy this item"
|
// user notification "i don't buy this item"
|
||||||
MWBase::Environment::get().getWindowManager()->
|
MWBase::Environment::get().getWindowManager()->
|
||||||
messageBox(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarterDialog4")->str, std::vector<std::string>());
|
messageBox("#{sBarterDialog4}", std::vector<std::string>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool buying = isTradeWindow(); // buying or selling?
|
bool buying = isTradeWindow(); // buying or selling?
|
||||||
std::string message = buying ? MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sQuanityMenuMessage02")->str
|
std::string message = buying ? "#{sQuanityMenuMessage02}" : "#{sQuanityMenuMessage01}";
|
||||||
: MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sQuanityMenuMessage01")->str;
|
|
||||||
|
|
||||||
if (std::find(mBoughtItems.begin(), mBoughtItems.end(), object) != mBoughtItems.end())
|
if (std::find(mBoughtItems.begin(), mBoughtItems.end(), object) != mBoughtItems.end())
|
||||||
{
|
{
|
||||||
@ -273,12 +273,12 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
|||||||
// check the container's Organic flag (if this is a container). container with Organic flag doesn't allow putting items inside
|
// check the container's Organic flag (if this is a container). container with Organic flag doesn't allow putting items inside
|
||||||
if (mPtr.getTypeName() == typeid(ESM::Container).name())
|
if (mPtr.getTypeName() == typeid(ESM::Container).name())
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData>* ref = mPtr.get<ESM::Container>();
|
MWWorld::LiveCellRef<ESM::Container>* ref = mPtr.get<ESM::Container>();
|
||||||
if (ref->base->flags & ESM::Container::Organic)
|
if (ref->base->flags & ESM::Container::Organic)
|
||||||
{
|
{
|
||||||
// user notification
|
// user notification
|
||||||
MWBase::Environment::get().getWindowManager()->
|
MWBase::Environment::get().getWindowManager()->
|
||||||
messageBox(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sContentsMessage2")->str, std::vector<std::string>());
|
messageBox("#{sContentsMessage2}", std::vector<std::string>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender)
|
|||||||
object.getRefData().setCount(origCount);
|
object.getRefData().setCount(origCount);
|
||||||
// user notification
|
// user notification
|
||||||
MWBase::Environment::get().getWindowManager()->
|
MWBase::Environment::get().getWindowManager()->
|
||||||
messageBox(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sContentsMessage3")->str, std::vector<std::string>());
|
messageBox("#{sContentsMessage3}", std::vector<std::string>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -362,7 +362,7 @@ void ContainerBase::drawItems()
|
|||||||
int maxHeight = mItemView->getSize().height - 58;
|
int maxHeight = mItemView->getSize().height - 58;
|
||||||
|
|
||||||
bool onlyMagic = false;
|
bool onlyMagic = false;
|
||||||
int categories;
|
int categories = 0;
|
||||||
if (mFilter == Filter_All)
|
if (mFilter == Filter_All)
|
||||||
categories = MWWorld::ContainerStore::Type_All;
|
categories = MWWorld::ContainerStore::Type_All;
|
||||||
else if (mFilter == Filter_Weapon)
|
else if (mFilter == Filter_Weapon)
|
||||||
@ -470,7 +470,7 @@ void ContainerBase::drawItems()
|
|||||||
|
|
||||||
// background widget (for the "equipped" frame and magic item background image)
|
// background widget (for the "equipped" frame and magic item background image)
|
||||||
bool isMagic = (MWWorld::Class::get(*iter).getEnchantment(*iter) != "");
|
bool isMagic = (MWWorld::Class::get(*iter).getEnchantment(*iter) != "");
|
||||||
MyGUI::ImageBox* backgroundWidget = mContainerWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(x, y, 42, 42), MyGUI::Align::Default);
|
MyGUI::ImageBox* backgroundWidget = mContainerWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(x, y, 42, 42), MyGUI::Align::Default);
|
||||||
backgroundWidget->setUserString("ToolTipType", "ItemPtr");
|
backgroundWidget->setUserString("ToolTipType", "ItemPtr");
|
||||||
backgroundWidget->setUserData(*iter);
|
backgroundWidget->setUserData(*iter);
|
||||||
|
|
||||||
@ -502,7 +502,7 @@ void ContainerBase::drawItems()
|
|||||||
backgroundWidget->eventMouseWheel += MyGUI::newDelegate(this, &ContainerBase::onMouseWheel);
|
backgroundWidget->eventMouseWheel += MyGUI::newDelegate(this, &ContainerBase::onMouseWheel);
|
||||||
|
|
||||||
// image
|
// image
|
||||||
ImageBox* image = backgroundWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = backgroundWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
@ -590,9 +590,9 @@ MWWorld::ContainerStore& ContainerBase::getContainerStore()
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
|
ContainerWindow::ContainerWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
|
||||||
: ContainerBase(dragAndDrop)
|
: ContainerBase(dragAndDrop)
|
||||||
, WindowBase("openmw_container_window_layout.xml", parWindowManager)
|
, WindowBase("openmw_container_window.layout", parWindowManager)
|
||||||
{
|
{
|
||||||
getWidget(mTakeButton, "TakeButton");
|
getWidget(mTakeButton, "TakeButton");
|
||||||
getWidget(mCloseButton, "CloseButton");
|
getWidget(mCloseButton, "CloseButton");
|
||||||
@ -606,18 +606,9 @@ ContainerWindow::ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dr
|
|||||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
|
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onCloseButtonClicked);
|
||||||
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
|
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ContainerWindow::onTakeAllButtonClicked);
|
||||||
|
|
||||||
// adjust buttons size to fit text
|
|
||||||
int closeButtonWidth = mCloseButton->getTextSize().width+24;
|
|
||||||
int takeButtonWidth = mTakeButton->getTextSize().width+24;
|
|
||||||
mCloseButton->setCoord(600-20-closeButtonWidth, mCloseButton->getCoord().top, closeButtonWidth, mCloseButton->getCoord().height);
|
|
||||||
mTakeButton->setCoord(600-20-closeButtonWidth-takeButtonWidth-8, mTakeButton->getCoord().top, takeButtonWidth, mTakeButton->getCoord().height);
|
|
||||||
|
|
||||||
int w = MyGUI::RenderManager::getInstance().getViewSize().width;
|
|
||||||
//int h = MyGUI::RenderManager::getInstance().getViewSize().height;
|
|
||||||
|
|
||||||
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ContainerWindow::onWindowResize);
|
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &ContainerWindow::onWindowResize);
|
||||||
|
|
||||||
setCoord(w-600,0,600,300);
|
setCoord(200,0,600,300);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerWindow::~ContainerWindow()
|
ContainerWindow::~ContainerWindow()
|
||||||
|
@ -127,7 +127,7 @@ namespace MWGui
|
|||||||
class ContainerWindow : public ContainerBase, public WindowBase
|
class ContainerWindow : public ContainerBase, public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContainerWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
|
ContainerWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
|
||||||
|
|
||||||
virtual ~ContainerWindow();
|
virtual ~ContainerWindow();
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
CountDialog::CountDialog(WindowManager& parWindowManager) :
|
CountDialog::CountDialog(MWBase::WindowManager& parWindowManager) :
|
||||||
WindowBase("openmw_count_window_layout.xml", parWindowManager)
|
WindowModal("openmw_count_window.layout", parWindowManager)
|
||||||
{
|
{
|
||||||
getWidget(mSlider, "CountSlider");
|
getWidget(mSlider, "CountSlider");
|
||||||
getWidget(mItemEdit, "ItemEdit");
|
getWidget(mItemEdit, "ItemEdit");
|
||||||
@ -27,7 +27,7 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
|
||||||
mLabelText->setCaption(message);
|
mLabelText->setCaptionWithReplacing(message);
|
||||||
|
|
||||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||||
|
|
||||||
@ -40,37 +40,22 @@ namespace MWGui
|
|||||||
width,
|
width,
|
||||||
mMainWidget->getHeight());
|
mMainWidget->getHeight());
|
||||||
|
|
||||||
// make other gui elements inaccessible while this dialog is open
|
|
||||||
MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget);
|
|
||||||
|
|
||||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(mItemEdit);
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(mItemEdit);
|
||||||
|
|
||||||
mSlider->setScrollPosition(maxCount-1);
|
mSlider->setScrollPosition(maxCount-1);
|
||||||
mItemEdit->setCaption(boost::lexical_cast<std::string>(maxCount));
|
mItemEdit->setCaption(boost::lexical_cast<std::string>(maxCount));
|
||||||
|
|
||||||
int okButtonWidth = mOkButton->getTextSize().width + 24;
|
|
||||||
mOkButton->setCoord(width - 30 - okButtonWidth,
|
|
||||||
mOkButton->getTop(),
|
|
||||||
okButtonWidth,
|
|
||||||
mOkButton->getHeight());
|
|
||||||
|
|
||||||
int cancelButtonWidth = mCancelButton->getTextSize().width + 24;
|
|
||||||
mCancelButton->setCoord(width - 30 - okButtonWidth - cancelButtonWidth - 8,
|
|
||||||
mCancelButton->getTop(),
|
|
||||||
cancelButtonWidth,
|
|
||||||
mCancelButton->getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
void CountDialog::onCancelButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
close();
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
void CountDialog::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventOkClicked(NULL, mSlider->getScrollPosition()+1);
|
eventOkClicked(NULL, mSlider->getScrollPosition()+1);
|
||||||
|
|
||||||
close();
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CountDialog::onEditTextChange(MyGUI::EditBox* _sender)
|
void CountDialog::onEditTextChange(MyGUI::EditBox* _sender)
|
||||||
@ -99,10 +84,4 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
mItemEdit->setCaption(boost::lexical_cast<std::string>(_position+1));
|
mItemEdit->setCaption(boost::lexical_cast<std::string>(_position+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CountDialog::close()
|
|
||||||
{
|
|
||||||
setVisible(false);
|
|
||||||
MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class CountDialog : public WindowBase
|
class CountDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CountDialog(WindowManager& parWindowManager);
|
CountDialog(MWBase::WindowManager& parWindowManager);
|
||||||
void open(const std::string& item, const std::string& message, const int maxCount);
|
void open(const std::string& item, const std::string& message, const int maxCount);
|
||||||
|
|
||||||
typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt;
|
typedef MyGUI::delegates::CMultiDelegate2<MyGUI::Widget*, int> EventHandle_WidgetInt;
|
||||||
@ -30,8 +30,6 @@ namespace MWGui
|
|||||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||||
void onEditTextChange(MyGUI::EditBox* _sender);
|
void onEditTextChange(MyGUI::EditBox* _sender);
|
||||||
void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position);
|
void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position);
|
||||||
|
|
||||||
void close();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,5 @@ CursorReplace::CursorReplace()
|
|||||||
OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_dresize2.png", 45);
|
OEngine::Render::ImageRotate::rotate("textures\\tx_cursormove.dds", "mwpointer_dresize2.png", 45);
|
||||||
|
|
||||||
OEngine::Render::Atlas::createFromFile("atlas1.cfg", "mwgui1", "textures\\");
|
OEngine::Render::Atlas::createFromFile("atlas1.cfg", "mwgui1", "textures\\");
|
||||||
|
OEngine::Render::Atlas::createFromFile("mainmenu.cfg", "mwgui2", "textures\\");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "dialogue.hpp"
|
#include "dialogue.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
@ -10,13 +9,15 @@
|
|||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwdialogue/dialoguemanager.hpp"
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "dialogue_history.hpp"
|
#include "dialogue_history.hpp"
|
||||||
#include "window_manager.hpp"
|
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "list.hpp"
|
#include "list.hpp"
|
||||||
#include "tradewindow.hpp"
|
#include "tradewindow.hpp"
|
||||||
|
#include "spellbuyingwindow.hpp"
|
||||||
#include "inventorywindow.hpp"
|
#include "inventorywindow.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
@ -42,19 +43,20 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
|
: WindowBase("openmw_dialogue_window.layout", parWindowManager)
|
||||||
, mEnabled(true)
|
, mEnabled(true)
|
||||||
, mShowTrade(false)
|
, mShowTrade(false)
|
||||||
|
, mShowSpells(false)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
//History view
|
//History view
|
||||||
getWidget(history, "History");
|
getWidget(mHistory, "History");
|
||||||
history->setOverflowToTheLeft(true);
|
mHistory->setOverflowToTheLeft(true);
|
||||||
history->setMaxTextLength(1000000);
|
mHistory->setMaxTextLength(1000000);
|
||||||
Widget* eventbox;
|
MyGUI::Widget* eventbox;
|
||||||
|
|
||||||
//An EditBox cannot receive mouse click events, so we use an
|
//An EditBox cannot receive mouse click events, so we use an
|
||||||
//invisible widget on top of the editbox to receive them
|
//invisible widget on top of the editbox to receive them
|
||||||
@ -63,36 +65,36 @@ DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
|||||||
eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel);
|
eventbox->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel);
|
||||||
|
|
||||||
//Topics list
|
//Topics list
|
||||||
getWidget(topicsList, "TopicsList");
|
getWidget(mTopicsList, "TopicsList");
|
||||||
topicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
mTopicsList->eventItemSelected += MyGUI::newDelegate(this, &DialogueWindow::onSelectTopic);
|
||||||
|
|
||||||
MyGUI::ButtonPtr byeButton;
|
MyGUI::ButtonPtr byeButton;
|
||||||
getWidget(byeButton, "ByeButton");
|
getWidget(byeButton, "ByeButton");
|
||||||
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
byeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &DialogueWindow::onByeClicked);
|
||||||
|
|
||||||
getWidget(pDispositionBar, "Disposition");
|
getWidget(mDispositionBar, "Disposition");
|
||||||
getWidget(pDispositionText,"DispositionText");
|
getWidget(mDispositionText,"DispositionText");
|
||||||
|
|
||||||
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
|
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
ISubWidgetText* t = history->getClient()->getSubWidgetText();
|
MyGUI::ISubWidgetText* t = mHistory->getClient()->getSubWidgetText();
|
||||||
if(t == nullptr)
|
if(t == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const IntPoint& lastPressed = InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
const MyGUI::IntPoint& lastPressed = MyGUI::InputManager::getInstance().getLastPressedPosition(MyGUI::MouseButton::Left);
|
||||||
|
|
||||||
size_t cursorPosition = t->getCursorPosition(lastPressed);
|
size_t cursorPosition = t->getCursorPosition(lastPressed);
|
||||||
MyGUI::UString color = history->getColorAtPos(cursorPosition);
|
MyGUI::UString color = mHistory->getColorAtPos(cursorPosition);
|
||||||
|
|
||||||
if (!mEnabled && color == "#572D21")
|
if (!mEnabled && color == "#572D21")
|
||||||
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
|
||||||
|
|
||||||
if(color != "#B29154")
|
if(color != "#B29154")
|
||||||
{
|
{
|
||||||
UString key = history->getColorTextAt(cursorPosition);
|
MyGUI::UString key = mHistory->getColorTextAt(cursorPosition);
|
||||||
if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key));
|
if(color == "#686EBA") MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(key));
|
||||||
|
|
||||||
if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key));
|
if(color == "#572D21") MWBase::Environment::get().getDialogueManager()->questionAnswered(lower_string(key));
|
||||||
@ -101,15 +103,15 @@ void DialogueWindow::onHistoryClicked(MyGUI::Widget* _sender)
|
|||||||
|
|
||||||
void DialogueWindow::onWindowResize(MyGUI::Window* _sender)
|
void DialogueWindow::onWindowResize(MyGUI::Window* _sender)
|
||||||
{
|
{
|
||||||
topicsList->adjustSize();
|
mTopicsList->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
||||||
{
|
{
|
||||||
if (history->getVScrollPosition() - _rel*0.3 < 0)
|
if (mHistory->getVScrollPosition() - _rel*0.3 < 0)
|
||||||
history->setVScrollPosition(0);
|
mHistory->setVScrollPosition(0);
|
||||||
else
|
else
|
||||||
history->setVScrollPosition(history->getVScrollPosition() - _rel*0.3);
|
mHistory->setVScrollPosition(mHistory->getVScrollPosition() - _rel*0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
|
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
|
||||||
@ -121,12 +123,17 @@ void DialogueWindow::onSelectTopic(std::string topic)
|
|||||||
{
|
{
|
||||||
if (!mEnabled) return;
|
if (!mEnabled) return;
|
||||||
|
|
||||||
if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str)
|
if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString())
|
||||||
{
|
{
|
||||||
/// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)?
|
/// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)?
|
||||||
mWindowManager.pushGuiMode(GM_Barter);
|
mWindowManager.pushGuiMode(GM_Barter);
|
||||||
mWindowManager.getTradeWindow()->startTrade(mPtr);
|
mWindowManager.getTradeWindow()->startTrade(mPtr);
|
||||||
}
|
}
|
||||||
|
else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString())
|
||||||
|
{
|
||||||
|
mWindowManager.pushGuiMode(GM_SpellBuying);
|
||||||
|
mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic));
|
||||||
@ -136,40 +143,43 @@ void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName)
|
|||||||
{
|
{
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
mPtr = actor;
|
mPtr = actor;
|
||||||
topicsList->setEnabled(true);
|
mTopicsList->setEnabled(true);
|
||||||
setTitle(npcName);
|
setTitle(npcName);
|
||||||
|
|
||||||
topicsList->clear();
|
mTopicsList->clear();
|
||||||
history->eraseText(0,history->getTextLength());
|
mHistory->eraseText(0,mHistory->getTextLength());
|
||||||
updateOptions();
|
updateOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::setKeywords(std::list<std::string> keyWords)
|
void DialogueWindow::setKeywords(std::list<std::string> keyWords)
|
||||||
{
|
{
|
||||||
topicsList->clear();
|
mTopicsList->clear();
|
||||||
|
|
||||||
bool anyService = mShowTrade;
|
bool anyService = mShowTrade||mShowSpells;
|
||||||
|
|
||||||
if (mShowTrade)
|
if (mShowTrade)
|
||||||
topicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str);
|
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString());
|
||||||
|
|
||||||
|
if (mShowSpells)
|
||||||
|
mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString());
|
||||||
|
|
||||||
if (anyService)
|
if (anyService)
|
||||||
topicsList->addSeparator();
|
mTopicsList->addSeparator();
|
||||||
|
|
||||||
for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); ++it)
|
for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); ++it)
|
||||||
{
|
{
|
||||||
topicsList->addItem(*it);
|
mTopicsList->addItem(*it);
|
||||||
}
|
}
|
||||||
topicsList->adjustSize();
|
mTopicsList->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::removeKeyword(std::string keyWord)
|
void DialogueWindow::removeKeyword(std::string keyWord)
|
||||||
{
|
{
|
||||||
if(topicsList->hasItem(keyWord))
|
if(mTopicsList->hasItem(keyWord))
|
||||||
{
|
{
|
||||||
topicsList->removeItem(keyWord);
|
mTopicsList->removeItem(keyWord);
|
||||||
}
|
}
|
||||||
topicsList->adjustSize();
|
mTopicsList->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2)
|
void addColorInString(std::string& str, const std::string& keyword,std::string color1, std::string color2)
|
||||||
@ -206,9 +216,9 @@ void addColorInString(std::string& str, const std::string& keyword,std::string c
|
|||||||
std::string DialogueWindow::parseText(std::string text)
|
std::string DialogueWindow::parseText(std::string text)
|
||||||
{
|
{
|
||||||
bool separatorReached = false; // only parse topics that are below the separator (this prevents actions like "Barter" that are not topics from getting blue-colored)
|
bool separatorReached = false; // only parse topics that are below the separator (this prevents actions like "Barter" that are not topics from getting blue-colored)
|
||||||
for(unsigned int i = 0;i<topicsList->getItemCount();i++)
|
for(unsigned int i = 0;i<mTopicsList->getItemCount();i++)
|
||||||
{
|
{
|
||||||
std::string keyWord = topicsList->getItemNameAt(i);
|
std::string keyWord = mTopicsList->getItemNameAt(i);
|
||||||
if (separatorReached && keyWord != "")
|
if (separatorReached && keyWord != "")
|
||||||
addColorInString(text,keyWord,"#686EBA","#B29154");
|
addColorInString(text,keyWord,"#686EBA","#B29154");
|
||||||
else
|
else
|
||||||
@ -219,7 +229,7 @@ std::string DialogueWindow::parseText(std::string text)
|
|||||||
|
|
||||||
void DialogueWindow::addText(std::string text)
|
void DialogueWindow::addText(std::string text)
|
||||||
{
|
{
|
||||||
history->addDialogText("#B29154"+parseText(text)+"#B29154");
|
mHistory->addDialogText("#B29154"+parseText(text)+"#B29154");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::addTitle(std::string text)
|
void DialogueWindow::addTitle(std::string text)
|
||||||
@ -227,37 +237,37 @@ void DialogueWindow::addTitle(std::string text)
|
|||||||
// This is called from the dialogue manager, so text is
|
// This is called from the dialogue manager, so text is
|
||||||
// case-smashed - thus we have to retrieve the correct case
|
// case-smashed - thus we have to retrieve the correct case
|
||||||
// of the text through the topic list.
|
// of the text through the topic list.
|
||||||
for (size_t i=0; i<topicsList->getItemCount(); ++i)
|
for (size_t i=0; i<mTopicsList->getItemCount(); ++i)
|
||||||
{
|
{
|
||||||
std::string item = topicsList->getItemNameAt(i);
|
std::string item = mTopicsList->getItemNameAt(i);
|
||||||
if (lower_string(item) == text)
|
if (lower_string(item) == text)
|
||||||
text = item;
|
text = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
history->addDialogHeading(text);
|
mHistory->addDialogHeading(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::askQuestion(std::string question)
|
void DialogueWindow::askQuestion(std::string question)
|
||||||
{
|
{
|
||||||
history->addDialogText("#572D21"+question+"#B29154"+" ");
|
mHistory->addDialogText("#572D21"+question+"#B29154"+" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::updateOptions()
|
void DialogueWindow::updateOptions()
|
||||||
{
|
{
|
||||||
//Clear the list of topics
|
//Clear the list of topics
|
||||||
topicsList->clear();
|
mTopicsList->clear();
|
||||||
history->eraseText(0,history->getTextLength());
|
mHistory->eraseText(0, mHistory->getTextLength());
|
||||||
|
|
||||||
pDispositionBar->setProgressRange(100);
|
mDispositionBar->setProgressRange(100);
|
||||||
pDispositionBar->setProgressPosition(40);
|
mDispositionBar->setProgressPosition(40);
|
||||||
pDispositionText->eraseText(0,pDispositionText->getTextLength());
|
mDispositionText->eraseText(0, mDispositionText->getTextLength());
|
||||||
pDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
mDispositionText->addText("#B29154"+std::string("40/100")+"#B29154");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueWindow::goodbye()
|
void DialogueWindow::goodbye()
|
||||||
{
|
{
|
||||||
history->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sGoodbye")->str);
|
mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGoodbye")->getString());
|
||||||
topicsList->setEnabled(false);
|
mTopicsList->setEnabled(false);
|
||||||
mEnabled = false;
|
mEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace MWGui
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains the dialouge window
|
This file contains the dialouge window
|
||||||
Layout is defined by resources/mygui/openmw_dialogue_window_layout.xml.
|
Layout is defined by resources/mygui/openmw_dialogue_window.layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
@ -29,7 +29,7 @@ namespace MWGui
|
|||||||
class DialogueWindow: public WindowBase, public ReferenceInterface
|
class DialogueWindow: public WindowBase, public ReferenceInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DialogueWindow(WindowManager& parWindowManager);
|
DialogueWindow(MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
@ -51,6 +51,7 @@ namespace MWGui
|
|||||||
// various service button visibilities, depending if the npc/creature talked to has these services
|
// various service button visibilities, depending if the npc/creature talked to has these services
|
||||||
// make sure to call these before setKeywords()
|
// make sure to call these before setKeywords()
|
||||||
void setShowTrade(bool show) { mShowTrade = show; }
|
void setShowTrade(bool show) { mShowTrade = show; }
|
||||||
|
void setShowSpells(bool show) { mShowSpells = show; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSelectTopic(std::string topic);
|
void onSelectTopic(std::string topic);
|
||||||
@ -70,13 +71,14 @@ namespace MWGui
|
|||||||
|
|
||||||
// various service button visibilities, depending if the npc/creature talked to has these services
|
// various service button visibilities, depending if the npc/creature talked to has these services
|
||||||
bool mShowTrade;
|
bool mShowTrade;
|
||||||
|
bool mShowSpells;
|
||||||
|
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
DialogueHistory* history;
|
DialogueHistory* mHistory;
|
||||||
Widgets::MWList* topicsList;
|
Widgets::MWList* mTopicsList;
|
||||||
MyGUI::ProgressPtr pDispositionBar;
|
MyGUI::ProgressPtr mDispositionBar;
|
||||||
MyGUI::EditPtr pDispositionText;
|
MyGUI::EditPtr mDispositionText;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "dialogue_history.hpp"
|
#include "dialogue_history.hpp"
|
||||||
#include "window_manager.hpp"
|
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
@ -13,10 +14,10 @@
|
|||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
UString DialogueHistory::getColorAtPos(size_t _pos)
|
MyGUI::UString DialogueHistory::getColorAtPos(size_t _pos)
|
||||||
{
|
{
|
||||||
UString colour = TextIterator::convertTagColour(getTextColour());
|
MyGUI::UString colour = MyGUI::TextIterator::convertTagColour(getTextColour());
|
||||||
TextIterator iterator(getCaption());
|
MyGUI::TextIterator iterator(getCaption());
|
||||||
while(iterator.moveNext())
|
while(iterator.moveNext())
|
||||||
{
|
{
|
||||||
size_t pos = iterator.getPosition();
|
size_t pos = iterator.getPosition();
|
||||||
@ -29,13 +30,13 @@ UString DialogueHistory::getColorAtPos(size_t _pos)
|
|||||||
return colour;
|
return colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
UString DialogueHistory::getColorTextAt(size_t _pos)
|
MyGUI::UString DialogueHistory::getColorTextAt(size_t _pos)
|
||||||
{
|
{
|
||||||
bool breakOnNext = false;
|
bool breakOnNext = false;
|
||||||
UString colour = TextIterator::convertTagColour(getTextColour());
|
MyGUI::UString colour = MyGUI::TextIterator::convertTagColour(getTextColour());
|
||||||
UString colour2 = colour;
|
MyGUI::UString colour2 = colour;
|
||||||
TextIterator iterator(getCaption());
|
MyGUI::TextIterator iterator(getCaption());
|
||||||
TextIterator col_start = iterator;
|
MyGUI::TextIterator col_start = iterator;
|
||||||
while(iterator.moveNext())
|
while(iterator.moveNext())
|
||||||
{
|
{
|
||||||
size_t pos = iterator.getPosition();
|
size_t pos = iterator.getPosition();
|
||||||
@ -59,17 +60,16 @@ UString DialogueHistory::getColorTextAt(size_t _pos)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueHistory::addDialogHeading(const UString& parText)
|
void DialogueHistory::addDialogHeading(const MyGUI::UString& parText)
|
||||||
{
|
{
|
||||||
UString head("\n#D8C09A");
|
MyGUI::UString head("\n#D8C09A");
|
||||||
head.append(parText);
|
head.append(parText);
|
||||||
head.append("#B29154\n");
|
head.append("#B29154\n");
|
||||||
addText(head);
|
addText(head);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogueHistory::addDialogText(const UString& parText)
|
void DialogueHistory::addDialogText(const MyGUI::UString& parText)
|
||||||
{
|
{
|
||||||
addText(parText);
|
addText(parText);
|
||||||
addText("\n");
|
addText("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,16 +4,15 @@
|
|||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
using namespace MyGUI;
|
|
||||||
class DialogueHistory : public MyGUI::EditBox
|
class DialogueHistory : public MyGUI::EditBox
|
||||||
{
|
{
|
||||||
MYGUI_RTTI_DERIVED( DialogueHistory )
|
MYGUI_RTTI_DERIVED( DialogueHistory )
|
||||||
public:
|
public:
|
||||||
Widget* getClient() { return mClient; }
|
Widget* getClient() { return mClient; }
|
||||||
UString getColorAtPos(size_t _pos);
|
MyGUI::UString getColorAtPos(size_t _pos);
|
||||||
UString getColorTextAt(size_t _pos);
|
MyGUI::UString getColorTextAt(size_t _pos);
|
||||||
void addDialogHeading(const UString& parText);
|
void addDialogHeading(const MyGUI::UString& parText);
|
||||||
void addDialogText(const UString& parText);
|
void addDialogText(const MyGUI::UString& parText);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,41 +7,44 @@
|
|||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
|
#include "../mwgui/widgets.hpp"
|
||||||
|
|
||||||
#include "inventorywindow.hpp"
|
#include "inventorywindow.hpp"
|
||||||
#include "window_manager.hpp"
|
|
||||||
#include "container.hpp"
|
#include "container.hpp"
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
||||||
: Layout("openmw_hud_layout.xml")
|
: Layout("openmw_hud.layout")
|
||||||
, health(NULL)
|
, mHealth(NULL)
|
||||||
, magicka(NULL)
|
, mMagicka(NULL)
|
||||||
, stamina(NULL)
|
, mStamina(NULL)
|
||||||
, weapImage(NULL)
|
, mWeapImage(NULL)
|
||||||
, spellImage(NULL)
|
, mSpellImage(NULL)
|
||||||
, weapStatus(NULL)
|
, mWeapStatus(NULL)
|
||||||
, spellStatus(NULL)
|
, mSpellStatus(NULL)
|
||||||
, effectBox(NULL)
|
, mEffectBox(NULL)
|
||||||
, effect1(NULL)
|
, mEffect1(NULL)
|
||||||
, minimap(NULL)
|
, mMinimap(NULL)
|
||||||
, compass(NULL)
|
, mCompass(NULL)
|
||||||
, crosshair(NULL)
|
, mCrosshair(NULL)
|
||||||
, fpsbox(NULL)
|
, mFpsBox(NULL)
|
||||||
, fpscounter(NULL)
|
, mFpsCounter(NULL)
|
||||||
, trianglecounter(NULL)
|
, mTriangleCounter(NULL)
|
||||||
, batchcounter(NULL)
|
, mBatchCounter(NULL)
|
||||||
, hmsBaseLeft(0)
|
, mHealthManaStaminaBaseLeft(0)
|
||||||
, weapBoxBaseLeft(0)
|
, mWeapBoxBaseLeft(0)
|
||||||
, spellBoxBaseLeft(0)
|
, mSpellBoxBaseLeft(0)
|
||||||
, effectBoxBaseRight(0)
|
, mEffectBoxBaseRight(0)
|
||||||
, minimapBoxBaseRight(0)
|
, mMinimapBoxBaseRight(0)
|
||||||
, mDragAndDrop(dragAndDrop)
|
, mDragAndDrop(dragAndDrop)
|
||||||
, mCellNameTimer(0.0f)
|
, mCellNameTimer(0.0f)
|
||||||
, mCellNameBox(NULL)
|
, mCellNameBox(NULL)
|
||||||
@ -54,11 +57,10 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||||||
|
|
||||||
// Energy bars
|
// Energy bars
|
||||||
getWidget(mHealthFrame, "HealthFrame");
|
getWidget(mHealthFrame, "HealthFrame");
|
||||||
getWidget(health, "Health");
|
getWidget(mHealth, "Health");
|
||||||
getWidget(magicka, "Magicka");
|
getWidget(mMagicka, "Magicka");
|
||||||
getWidget(stamina, "Stamina");
|
getWidget(mStamina, "Stamina");
|
||||||
|
mHealthManaStaminaBaseLeft = mHealthFrame->getLeft();
|
||||||
hmsBaseLeft = mHealthFrame->getLeft();
|
|
||||||
|
|
||||||
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
|
MyGUI::Widget *healthFrame, *magickaFrame, *fatigueFrame;
|
||||||
getWidget(healthFrame, "HealthFrame");
|
getWidget(healthFrame, "HealthFrame");
|
||||||
@ -71,42 +73,43 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||||
|
|
||||||
// Item and spell images and status bars
|
// Item and spell images and status bars
|
||||||
getWidget(weapBox, "WeapBox");
|
getWidget(mWeapBox, "WeapBox");
|
||||||
getWidget(weapImage, "WeapImage");
|
getWidget(mWeapImage, "WeapImage");
|
||||||
getWidget(weapStatus, "WeapStatus");
|
getWidget(mWeapStatus, "WeapStatus");
|
||||||
weapBoxBaseLeft = weapBox->getLeft();
|
mWeapBoxBaseLeft = mWeapBox->getLeft();
|
||||||
weapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked);
|
mWeapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWeaponClicked);
|
||||||
|
|
||||||
getWidget(spellBox, "SpellBox");
|
getWidget(mSpellBox, "SpellBox");
|
||||||
getWidget(spellImage, "SpellImage");
|
getWidget(mSpellImage, "SpellImage");
|
||||||
getWidget(spellStatus, "SpellStatus");
|
getWidget(mSpellStatus, "SpellStatus");
|
||||||
spellBoxBaseLeft = spellBox->getLeft();
|
mSpellBoxBaseLeft = mSpellBox->getLeft();
|
||||||
spellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
mSpellBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
||||||
|
|
||||||
getWidget(effectBox, "EffectBox");
|
getWidget(mEffectBox, "EffectBox");
|
||||||
getWidget(effect1, "Effect1");
|
getWidget(mEffect1, "Effect1");
|
||||||
effectBoxBaseRight = viewSize.width - effectBox->getRight();
|
mEffectBoxBaseRight = viewSize.width - mEffectBox->getRight();
|
||||||
effectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
mEffectBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMagicClicked);
|
||||||
|
|
||||||
getWidget(minimapBox, "MiniMapBox");
|
getWidget(mMinimapBox, "MiniMapBox");
|
||||||
minimapBoxBaseRight = viewSize.width - minimapBox->getRight();
|
mMinimapBoxBaseRight = viewSize.width - mMinimapBox->getRight();
|
||||||
minimapBox->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
getWidget(mMinimap, "MiniMap");
|
||||||
getWidget(minimap, "MiniMap");
|
getWidget(mCompass, "Compass");
|
||||||
getWidget(compass, "Compass");
|
getWidget(mMinimapButton, "MiniMapButton");
|
||||||
|
mMinimapButton->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onMapClicked);
|
||||||
|
|
||||||
getWidget(mCellNameBox, "CellName");
|
getWidget(mCellNameBox, "CellName");
|
||||||
getWidget(mWeaponSpellBox, "WeaponSpellName");
|
getWidget(mWeaponSpellBox, "WeaponSpellName");
|
||||||
|
|
||||||
getWidget(crosshair, "Crosshair");
|
getWidget(mCrosshair, "Crosshair");
|
||||||
|
|
||||||
setFpsLevel(fpsLevel);
|
setFpsLevel(fpsLevel);
|
||||||
|
|
||||||
getWidget(trianglecounter, "TriangleCounter");
|
getWidget(mTriangleCounter, "TriangleCounter");
|
||||||
getWidget(batchcounter, "BatchCounter");
|
getWidget(mBatchCounter, "BatchCounter");
|
||||||
|
|
||||||
setEffect("icons\\s\\tx_s_chameleon.dds");
|
setEffect("icons\\s\\tx_s_chameleon.dds");
|
||||||
|
|
||||||
LocalMapBase::init(minimap, compass, this);
|
LocalMapBase::init(mMinimap, mCompass, this);
|
||||||
|
|
||||||
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
|
mMainWidget->eventMouseButtonClick += MyGUI::newDelegate(this, &HUD::onWorldClicked);
|
||||||
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
mMainWidget->eventMouseMove += MyGUI::newDelegate(this, &HUD::onWorldMouseOver);
|
||||||
@ -115,7 +118,7 @@ HUD::HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop)
|
|||||||
|
|
||||||
void HUD::setFpsLevel(int level)
|
void HUD::setFpsLevel(int level)
|
||||||
{
|
{
|
||||||
fpscounter = 0;
|
mFpsCounter = 0;
|
||||||
|
|
||||||
MyGUI::Widget* fps;
|
MyGUI::Widget* fps;
|
||||||
getWidget(fps, "FPSBoxAdv");
|
getWidget(fps, "FPSBoxAdv");
|
||||||
@ -125,40 +128,40 @@ void HUD::setFpsLevel(int level)
|
|||||||
|
|
||||||
if (level == 2)
|
if (level == 2)
|
||||||
{
|
{
|
||||||
getWidget(fpsbox, "FPSBoxAdv");
|
getWidget(mFpsBox, "FPSBoxAdv");
|
||||||
fpsbox->setVisible(true);
|
mFpsBox->setVisible(true);
|
||||||
getWidget(fpscounter, "FPSCounterAdv");
|
getWidget(mFpsCounter, "FPSCounterAdv");
|
||||||
}
|
}
|
||||||
else if (level == 1)
|
else if (level == 1)
|
||||||
{
|
{
|
||||||
getWidget(fpsbox, "FPSBox");
|
getWidget(mFpsBox, "FPSBox");
|
||||||
fpsbox->setVisible(true);
|
mFpsBox->setVisible(true);
|
||||||
getWidget(fpscounter, "FPSCounter");
|
getWidget(mFpsCounter, "FPSCounter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setFPS(float fps)
|
void HUD::setFPS(float fps)
|
||||||
{
|
{
|
||||||
if (fpscounter)
|
if (mFpsCounter)
|
||||||
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
mFpsCounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setTriangleCount(unsigned int count)
|
void HUD::setTriangleCount(unsigned int count)
|
||||||
{
|
{
|
||||||
trianglecounter->setCaption(boost::lexical_cast<std::string>(count));
|
mTriangleCounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setBatchCount(unsigned int count)
|
void HUD::setBatchCount(unsigned int count)
|
||||||
{
|
{
|
||||||
batchcounter->setCaption(boost::lexical_cast<std::string>(count));
|
mBatchCounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setEffect(const char *img)
|
void HUD::setEffect(const char *img)
|
||||||
{
|
{
|
||||||
effect1->setImageTexture(img);
|
mEffect1->setImageTexture(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<float>& value)
|
||||||
{
|
{
|
||||||
static const char *ids[] =
|
static const char *ids[] =
|
||||||
{
|
{
|
||||||
@ -173,20 +176,20 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
health->setProgressRange (value.getModified());
|
mHealth->setProgressRange (value.getModified());
|
||||||
health->setProgressPosition (value.getCurrent());
|
mHealth->setProgressPosition (value.getCurrent());
|
||||||
getWidget(w, "HealthFrame");
|
getWidget(w, "HealthFrame");
|
||||||
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
magicka->setProgressRange (value.getModified());
|
mMagicka->setProgressRange (value.getModified());
|
||||||
magicka->setProgressPosition (value.getCurrent());
|
mMagicka->setProgressPosition (value.getCurrent());
|
||||||
getWidget(w, "MagickaFrame");
|
getWidget(w, "MagickaFrame");
|
||||||
w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
|
w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
stamina->setProgressRange (value.getModified());
|
mStamina->setProgressRange (value.getModified());
|
||||||
stamina->setProgressPosition (value.getCurrent());
|
mStamina->setProgressPosition (value.getCurrent());
|
||||||
getWidget(w, "FatigueFrame");
|
getWidget(w, "FatigueFrame");
|
||||||
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
||||||
break;
|
break;
|
||||||
@ -194,52 +197,17 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible)
|
|
||||||
{
|
|
||||||
int weapDx = 0, spellDx = 0;
|
|
||||||
if (!hmsVisible)
|
|
||||||
spellDx = weapDx = weapBoxBaseLeft - hmsBaseLeft;
|
|
||||||
|
|
||||||
if (!weapVisible)
|
|
||||||
spellDx += spellBoxBaseLeft - weapBoxBaseLeft;
|
|
||||||
|
|
||||||
mWeaponVisible = weapVisible;
|
|
||||||
mSpellVisible = spellVisible;
|
|
||||||
if (!mWeaponVisible && !mSpellVisible)
|
|
||||||
mWeaponSpellBox->setVisible(false);
|
|
||||||
|
|
||||||
health->setVisible(hmsVisible);
|
|
||||||
stamina->setVisible(hmsVisible);
|
|
||||||
magicka->setVisible(hmsVisible);
|
|
||||||
weapBox->setPosition(weapBoxBaseLeft - weapDx, weapBox->getTop());
|
|
||||||
weapBox->setVisible(weapVisible);
|
|
||||||
spellBox->setPosition(spellBoxBaseLeft - spellDx, spellBox->getTop());
|
|
||||||
spellBox->setVisible(spellVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HUD::setBottomRightVisibility(bool effectBoxVisible, bool minimapBoxVisible)
|
|
||||||
{
|
|
||||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
|
||||||
|
|
||||||
// effect box can have variable width -> variable left coordinate
|
|
||||||
int effectsDx = 0;
|
|
||||||
if (!minimapBoxVisible)
|
|
||||||
effectsDx = (viewSize.width - minimapBoxBaseRight) - (viewSize.width - effectBoxBaseRight);
|
|
||||||
|
|
||||||
mMapVisible = minimapBoxVisible;
|
|
||||||
minimapBox->setVisible(minimapBoxVisible);
|
|
||||||
effectBox->setPosition((viewSize.width - effectBoxBaseRight) - effectBox->getWidth() + effectsDx, effectBox->getTop());
|
|
||||||
effectBox->setVisible(effectBoxVisible);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
|
if (!MWBase::Environment::get().getWindowManager ()->isGuiMode ())
|
||||||
|
return;
|
||||||
|
|
||||||
if (mDragAndDrop->mIsOnDragAndDrop)
|
if (mDragAndDrop->mIsOnDragAndDrop)
|
||||||
{
|
{
|
||||||
// drop item into the gameworld
|
// drop item into the gameworld
|
||||||
MWWorld::Ptr object = *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>();
|
MWWorld::Ptr object = *mDragAndDrop->mDraggedWidget->getUserData<MWWorld::Ptr>();
|
||||||
|
|
||||||
MWWorld::World* world = MWBase::Environment::get().getWorld();
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||||
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
MyGUI::IntPoint cursorPosition = MyGUI::InputManager::getInstance().getMousePosition();
|
||||||
@ -282,7 +250,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
|||||||
{
|
{
|
||||||
object = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle);
|
object = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& /* e */)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -308,7 +276,7 @@ void HUD::onWorldMouseOver(MyGUI::Widget* _sender, int x, int y)
|
|||||||
float mouseX = cursorPosition.left / float(viewSize.width);
|
float mouseX = cursorPosition.left / float(viewSize.width);
|
||||||
float mouseY = cursorPosition.top / float(viewSize.height);
|
float mouseY = cursorPosition.top / float(viewSize.height);
|
||||||
|
|
||||||
MWWorld::World* world = MWBase::Environment::get().getWorld();
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
// if we can't drop the object at the wanted position, show the "drop on ground" cursor.
|
// if we can't drop the object at the wanted position, show the "drop on ground" cursor.
|
||||||
bool canDrop = world->canPlaceObject(mouseX, mouseY);
|
bool canDrop = world->canPlaceObject(mouseX, mouseY);
|
||||||
@ -391,14 +359,14 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
|
|||||||
mWeaponSpellBox->setVisible(true);
|
mWeaponSpellBox->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
spellStatus->setProgressRange(100);
|
mSpellStatus->setProgressRange(100);
|
||||||
spellStatus->setProgressPosition(successChancePercent);
|
mSpellStatus->setProgressPosition(successChancePercent);
|
||||||
|
|
||||||
if (spellImage->getChildCount())
|
if (mSpellImage->getChildCount())
|
||||||
MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||||
|
|
||||||
spellBox->setUserString("ToolTipType", "Spell");
|
mSpellBox->setUserString("ToolTipType", "Spell");
|
||||||
spellBox->setUserString("Spell", spellId);
|
mSpellBox->setUserString("Spell", spellId);
|
||||||
|
|
||||||
// use the icon of the first effect
|
// use the icon of the first effect
|
||||||
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID);
|
const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->effects.list.front().effectID);
|
||||||
@ -407,7 +375,7 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent)
|
|||||||
icon.insert(slashPos+1, "b_");
|
icon.insert(slashPos+1, "b_");
|
||||||
icon = std::string("icons\\") + icon;
|
icon = std::string("icons\\") + icon;
|
||||||
Widgets::fixTexturePath(icon);
|
Widgets::fixTexturePath(icon);
|
||||||
spellImage->setImageTexture(icon);
|
mSpellImage->setImageTexture(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
||||||
@ -421,17 +389,17 @@ void HUD::setSelectedEnchantItem(const MWWorld::Ptr& item, int chargePercent)
|
|||||||
mWeaponSpellBox->setVisible(true);
|
mWeaponSpellBox->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
spellStatus->setProgressRange(100);
|
mSpellStatus->setProgressRange(100);
|
||||||
spellStatus->setProgressPosition(chargePercent);
|
mSpellStatus->setProgressPosition(chargePercent);
|
||||||
|
|
||||||
if (spellImage->getChildCount())
|
if (mSpellImage->getChildCount())
|
||||||
MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||||
|
|
||||||
spellBox->setUserString("ToolTipType", "ItemPtr");
|
mSpellBox->setUserString("ToolTipType", "ItemPtr");
|
||||||
spellBox->setUserData(item);
|
mSpellBox->setUserData(item);
|
||||||
|
|
||||||
spellImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
mSpellImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||||
MyGUI::ImageBox* itemBox = spellImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
MyGUI::ImageBox* itemBox = mSpellImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||||
, MyGUI::Align::Stretch);
|
, MyGUI::Align::Stretch);
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
@ -452,14 +420,14 @@ void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
|||||||
mWeaponSpellBox->setVisible(true);
|
mWeaponSpellBox->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
weapBox->setUserString("ToolTipType", "ItemPtr");
|
mWeapBox->setUserString("ToolTipType", "ItemPtr");
|
||||||
weapBox->setUserData(item);
|
mWeapBox->setUserData(item);
|
||||||
|
|
||||||
weapStatus->setProgressRange(100);
|
mWeapStatus->setProgressRange(100);
|
||||||
weapStatus->setProgressPosition(durabilityPercent);
|
mWeapStatus->setProgressPosition(durabilityPercent);
|
||||||
|
|
||||||
if (weapImage->getChildCount())
|
if (mWeapImage->getChildCount())
|
||||||
MyGUI::Gui::getInstance().destroyWidget(weapImage->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path+=MWWorld::Class::get(item).getInventoryIcon(item);
|
path+=MWWorld::Class::get(item).getInventoryIcon(item);
|
||||||
@ -467,14 +435,14 @@ void HUD::setSelectedWeapon(const MWWorld::Ptr& item, int durabilityPercent)
|
|||||||
|
|
||||||
if (MWWorld::Class::get(item).getEnchantment(item) != "")
|
if (MWWorld::Class::get(item).getEnchantment(item) != "")
|
||||||
{
|
{
|
||||||
weapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
mWeapImage->setImageTexture("textures\\menu_icon_magic_mini.dds");
|
||||||
MyGUI::ImageBox* itemBox = weapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
MyGUI::ImageBox* itemBox = mWeapImage->createWidgetReal<MyGUI::ImageBox>("ImageBox", MyGUI::FloatCoord(0,0,1,1)
|
||||||
, MyGUI::Align::Stretch);
|
, MyGUI::Align::Stretch);
|
||||||
itemBox->setImageTexture(path);
|
itemBox->setImageTexture(path);
|
||||||
itemBox->setNeedMouseFocus(false);
|
itemBox->setNeedMouseFocus(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
weapImage->setImageTexture(path);
|
mWeapImage->setImageTexture(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::unsetSelectedSpell()
|
void HUD::unsetSelectedSpell()
|
||||||
@ -488,12 +456,12 @@ void HUD::unsetSelectedSpell()
|
|||||||
mWeaponSpellBox->setVisible(true);
|
mWeaponSpellBox->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spellImage->getChildCount())
|
if (mSpellImage->getChildCount())
|
||||||
MyGUI::Gui::getInstance().destroyWidget(spellImage->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mSpellImage->getChildAt(0));
|
||||||
spellStatus->setProgressRange(100);
|
mSpellStatus->setProgressRange(100);
|
||||||
spellStatus->setProgressPosition(0);
|
mSpellStatus->setProgressPosition(0);
|
||||||
spellImage->setImageTexture("");
|
mSpellImage->setImageTexture("");
|
||||||
spellBox->clearUserStrings();
|
mSpellBox->clearUserStrings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HUD::unsetSelectedWeapon()
|
void HUD::unsetSelectedWeapon()
|
||||||
@ -507,10 +475,75 @@ void HUD::unsetSelectedWeapon()
|
|||||||
mWeaponSpellBox->setVisible(true);
|
mWeaponSpellBox->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (weapImage->getChildCount())
|
if (mWeapImage->getChildCount())
|
||||||
MyGUI::Gui::getInstance().destroyWidget(weapImage->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mWeapImage->getChildAt(0));
|
||||||
weapStatus->setProgressRange(100);
|
mWeapStatus->setProgressRange(100);
|
||||||
weapStatus->setProgressPosition(0);
|
mWeapStatus->setProgressPosition(0);
|
||||||
weapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
mWeapImage->setImageTexture("icons\\k\\stealth_handtohand.dds");
|
||||||
weapBox->clearUserStrings();
|
mWeapBox->clearUserStrings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setCrosshairVisible(bool visible)
|
||||||
|
{
|
||||||
|
mCrosshair->setVisible (visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setHmsVisible(bool visible)
|
||||||
|
{
|
||||||
|
mHealth->setVisible(visible);
|
||||||
|
mMagicka->setVisible(visible);
|
||||||
|
mStamina->setVisible(visible);
|
||||||
|
updatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setWeapVisible(bool visible)
|
||||||
|
{
|
||||||
|
mWeapBox->setVisible(visible);
|
||||||
|
updatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setSpellVisible(bool visible)
|
||||||
|
{
|
||||||
|
mSpellBox->setVisible(visible);
|
||||||
|
updatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setEffectVisible(bool visible)
|
||||||
|
{
|
||||||
|
mEffectBox->setVisible (visible);
|
||||||
|
updatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::setMinimapVisible(bool visible)
|
||||||
|
{
|
||||||
|
mMinimapBox->setVisible (visible);
|
||||||
|
updatePositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HUD::updatePositions()
|
||||||
|
{
|
||||||
|
int weapDx = 0, spellDx = 0;
|
||||||
|
if (!mHealth->getVisible())
|
||||||
|
spellDx = weapDx = mWeapBoxBaseLeft - mHealthManaStaminaBaseLeft;
|
||||||
|
|
||||||
|
if (!mWeapBox->getVisible())
|
||||||
|
spellDx += mSpellBoxBaseLeft - mWeapBoxBaseLeft;
|
||||||
|
|
||||||
|
mWeaponVisible = mWeapBox->getVisible();
|
||||||
|
mSpellVisible = mSpellBox->getVisible();
|
||||||
|
if (!mWeaponVisible && !mSpellVisible)
|
||||||
|
mWeaponSpellBox->setVisible(false);
|
||||||
|
|
||||||
|
mWeapBox->setPosition(mWeapBoxBaseLeft - weapDx, mWeapBox->getTop());
|
||||||
|
mSpellBox->setPosition(mSpellBoxBaseLeft - spellDx, mSpellBox->getTop());
|
||||||
|
|
||||||
|
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||||
|
|
||||||
|
// effect box can have variable width -> variable left coordinate
|
||||||
|
int effectsDx = 0;
|
||||||
|
if (!mMinimapBox->getVisible ())
|
||||||
|
effectsDx = (viewSize.width - mMinimapBoxBaseRight) - (viewSize.width - mEffectBoxBaseRight);
|
||||||
|
|
||||||
|
mMapVisible = mMinimapBox->getVisible ();
|
||||||
|
mEffectBox->setPosition((viewSize.width - mEffectBoxBaseRight) - mEffectBox->getWidth() + effectsDx, mEffectBox->getTop());
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,18 @@ namespace MWGui
|
|||||||
public:
|
public:
|
||||||
HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop);
|
HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop);
|
||||||
void setEffect(const char *img);
|
void setEffect(const char *img);
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<float>& value);
|
||||||
void setFPS(float fps);
|
void setFPS(float fps);
|
||||||
void setTriangleCount(unsigned int count);
|
void setTriangleCount(unsigned int count);
|
||||||
void setBatchCount(unsigned int count);
|
void setBatchCount(unsigned int count);
|
||||||
void setBottomLeftVisibility(bool hmsVisible, bool weapVisible, bool spellVisible);
|
|
||||||
void setBottomRightVisibility(bool effectBoxVisible, bool minimapVisible);
|
void setHmsVisible(bool visible);
|
||||||
|
void setWeapVisible(bool visible);
|
||||||
|
void setSpellVisible(bool visible);
|
||||||
|
|
||||||
|
void setEffectVisible(bool visible);
|
||||||
|
void setMinimapVisible(bool visible);
|
||||||
|
|
||||||
void setFpsLevel(const int level);
|
void setFpsLevel(const int level);
|
||||||
|
|
||||||
void setSelectedSpell(const std::string& spellId, int successChancePercent);
|
void setSelectedSpell(const std::string& spellId, int successChancePercent);
|
||||||
@ -28,6 +34,8 @@ namespace MWGui
|
|||||||
void unsetSelectedSpell();
|
void unsetSelectedSpell();
|
||||||
void unsetSelectedWeapon();
|
void unsetSelectedWeapon();
|
||||||
|
|
||||||
|
void setCrosshairVisible(bool visible);
|
||||||
|
|
||||||
void onFrame(float dt);
|
void onFrame(float dt);
|
||||||
void onResChange(int width, int height);
|
void onResChange(int width, int height);
|
||||||
|
|
||||||
@ -35,29 +43,32 @@ namespace MWGui
|
|||||||
|
|
||||||
bool getWorldMouseOver() { return mWorldMouseOver; }
|
bool getWorldMouseOver() { return mWorldMouseOver; }
|
||||||
|
|
||||||
MyGUI::ProgressPtr health, magicka, stamina;
|
private:
|
||||||
|
MyGUI::ProgressPtr mHealth, mMagicka, mStamina;
|
||||||
MyGUI::Widget* mHealthFrame;
|
MyGUI::Widget* mHealthFrame;
|
||||||
MyGUI::Widget *weapBox, *spellBox;
|
MyGUI::Widget *mWeapBox, *mSpellBox;
|
||||||
MyGUI::ImageBox *weapImage, *spellImage;
|
MyGUI::ImageBox *mWeapImage, *mSpellImage;
|
||||||
MyGUI::ProgressPtr weapStatus, spellStatus;
|
MyGUI::ProgressPtr mWeapStatus, mSpellStatus;
|
||||||
MyGUI::Widget *effectBox, *minimapBox;
|
MyGUI::Widget *mEffectBox, *mMinimapBox;
|
||||||
MyGUI::ImageBox* effect1;
|
MyGUI::Button* mMinimapButton;
|
||||||
MyGUI::ScrollView* minimap;
|
MyGUI::ImageBox* mEffect1;
|
||||||
MyGUI::ImageBox* compass;
|
MyGUI::ScrollView* mMinimap;
|
||||||
MyGUI::ImageBox* crosshair;
|
MyGUI::ImageBox* mCompass;
|
||||||
|
MyGUI::ImageBox* mCrosshair;
|
||||||
MyGUI::TextBox* mCellNameBox;
|
MyGUI::TextBox* mCellNameBox;
|
||||||
MyGUI::TextBox* mWeaponSpellBox;
|
MyGUI::TextBox* mWeaponSpellBox;
|
||||||
|
|
||||||
MyGUI::WidgetPtr fpsbox;
|
MyGUI::Widget* mDummy;
|
||||||
MyGUI::TextBox* fpscounter;
|
|
||||||
MyGUI::TextBox* trianglecounter;
|
MyGUI::WidgetPtr mFpsBox;
|
||||||
MyGUI::TextBox* batchcounter;
|
MyGUI::TextBox* mFpsCounter;
|
||||||
|
MyGUI::TextBox* mTriangleCounter;
|
||||||
|
MyGUI::TextBox* mBatchCounter;
|
||||||
|
|
||||||
private:
|
|
||||||
// bottom left elements
|
// bottom left elements
|
||||||
int hmsBaseLeft, weapBoxBaseLeft, spellBoxBaseLeft;
|
int mHealthManaStaminaBaseLeft, mWeapBoxBaseLeft, mSpellBoxBaseLeft;
|
||||||
// bottom right elements
|
// bottom right elements
|
||||||
int minimapBoxBaseRight, effectBoxBaseRight;
|
int mMinimapBoxBaseRight, mEffectBoxBaseRight;
|
||||||
|
|
||||||
DragAndDrop* mDragAndDrop;
|
DragAndDrop* mDragAndDrop;
|
||||||
|
|
||||||
@ -81,5 +92,7 @@ namespace MWGui
|
|||||||
void onWeaponClicked(MyGUI::Widget* _sender);
|
void onWeaponClicked(MyGUI::Widget* _sender);
|
||||||
void onMagicClicked(MyGUI::Widget* _sender);
|
void onMagicClicked(MyGUI::Widget* _sender);
|
||||||
void onMapClicked(MyGUI::Widget* _sender);
|
void onMapClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
|
void updatePositions();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -3,22 +3,22 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwclass/container.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
#include "../mwworld/containerstore.hpp"
|
#include "../mwworld/containerstore.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwbase/environment.hpp"
|
|
||||||
#include "../mwworld/manualref.hpp"
|
#include "../mwworld/manualref.hpp"
|
||||||
#include "../mwworld/actiontake.hpp"
|
#include "../mwworld/actiontake.hpp"
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwworld/inventorystore.hpp"
|
||||||
|
|
||||||
#include "window_manager.hpp"
|
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "bookwindow.hpp"
|
#include "bookwindow.hpp"
|
||||||
#include "scrollwindow.hpp"
|
#include "scrollwindow.hpp"
|
||||||
@ -40,14 +40,18 @@ namespace
|
|||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
InventoryWindow::InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
|
InventoryWindow::InventoryWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop)
|
||||||
: ContainerBase(dragAndDrop)
|
: ContainerBase(dragAndDrop)
|
||||||
, WindowPinnableBase("openmw_inventory_window_layout.xml", parWindowManager)
|
, WindowPinnableBase("openmw_inventory_window.layout", parWindowManager)
|
||||||
, mTrading(false)
|
, mTrading(false)
|
||||||
|
, mLastXSize(0)
|
||||||
|
, mLastYSize(0)
|
||||||
|
, mPreview(MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ())
|
||||||
{
|
{
|
||||||
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
|
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);
|
||||||
|
|
||||||
getWidget(mAvatar, "Avatar");
|
getWidget(mAvatar, "Avatar");
|
||||||
|
getWidget(mAvatarImage, "AvatarImage");
|
||||||
getWidget(mEncumbranceBar, "EncumbranceBar");
|
getWidget(mEncumbranceBar, "EncumbranceBar");
|
||||||
getWidget(mEncumbranceText, "EncumbranceBarT");
|
getWidget(mEncumbranceText, "EncumbranceBarT");
|
||||||
getWidget(mFilterAll, "AllButton");
|
getWidget(mFilterAll, "AllButton");
|
||||||
@ -66,26 +70,6 @@ namespace MWGui
|
|||||||
getWidget(itemView, "ItemView");
|
getWidget(itemView, "ItemView");
|
||||||
setWidgets(containerWidget, itemView);
|
setWidgets(containerWidget, itemView);
|
||||||
|
|
||||||
// adjust size of buttons to fit text
|
|
||||||
int curX = 0;
|
|
||||||
mFilterAll->setSize( mFilterAll->getTextSize().width + 24, mFilterAll->getSize().height );
|
|
||||||
curX += mFilterAll->getTextSize().width + 24 + 4;
|
|
||||||
|
|
||||||
mFilterWeapon->setPosition(curX, mFilterWeapon->getPosition().top);
|
|
||||||
mFilterWeapon->setSize( mFilterWeapon->getTextSize().width + 24, mFilterWeapon->getSize().height );
|
|
||||||
curX += mFilterWeapon->getTextSize().width + 24 + 4;
|
|
||||||
|
|
||||||
mFilterApparel->setPosition(curX, mFilterApparel->getPosition().top);
|
|
||||||
mFilterApparel->setSize( mFilterApparel->getTextSize().width + 24, mFilterApparel->getSize().height );
|
|
||||||
curX += mFilterApparel->getTextSize().width + 24 + 4;
|
|
||||||
|
|
||||||
mFilterMagic->setPosition(curX, mFilterMagic->getPosition().top);
|
|
||||||
mFilterMagic->setSize( mFilterMagic->getTextSize().width + 24, mFilterMagic->getSize().height );
|
|
||||||
curX += mFilterMagic->getTextSize().width + 24 + 4;
|
|
||||||
|
|
||||||
mFilterMisc->setPosition(curX, mFilterMisc->getPosition().top);
|
|
||||||
mFilterMisc->setSize( mFilterMisc->getTextSize().width + 24, mFilterMisc->getSize().height );
|
|
||||||
|
|
||||||
mFilterAll->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
mFilterAll->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
||||||
mFilterWeapon->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
mFilterWeapon->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
||||||
mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
|
||||||
@ -96,6 +80,8 @@ namespace MWGui
|
|||||||
|
|
||||||
setCoord(0, 342, 498, 258);
|
setCoord(0, 342, 498, 258);
|
||||||
|
|
||||||
|
MWBase::Environment::get().getWorld ()->setupExternalRendering (mPreview);
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||||
openContainer(player);
|
openContainer(player);
|
||||||
}
|
}
|
||||||
@ -109,6 +95,7 @@ namespace MWGui
|
|||||||
mBoughtItems.clear();
|
mBoughtItems.clear();
|
||||||
|
|
||||||
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
||||||
|
drawItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
|
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
|
||||||
@ -119,7 +106,13 @@ namespace MWGui
|
|||||||
mRightPane->getPosition().top,
|
mRightPane->getPosition().top,
|
||||||
_sender->getSize().width - 12 - (_sender->getSize().height-44) * aspect - 15,
|
_sender->getSize().width - 12 - (_sender->getSize().height-44) * aspect - 15,
|
||||||
_sender->getSize().height-44 );
|
_sender->getSize().height-44 );
|
||||||
drawItems();
|
|
||||||
|
if (mMainWidget->getSize().width != mLastXSize || mMainWidget->getSize().height != mLastYSize)
|
||||||
|
{
|
||||||
|
drawItems();
|
||||||
|
mLastXSize = mMainWidget->getSize().width;
|
||||||
|
mLastYSize = mMainWidget->getSize().height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryWindow::onFilterChanged(MyGUI::Widget* _sender)
|
void InventoryWindow::onFilterChanged(MyGUI::Widget* _sender)
|
||||||
@ -172,7 +165,7 @@ namespace MWGui
|
|||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr);
|
boost::shared_ptr<MWWorld::Action> action = MWWorld::Class::get(ptr).use(ptr);
|
||||||
|
|
||||||
action->execute();
|
action->execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
|
|
||||||
// this is necessary for books/scrolls: if they are already in the player's inventory,
|
// this is necessary for books/scrolls: if they are already in the player's inventory,
|
||||||
// the "Take" button should not be visible.
|
// the "Take" button should not be visible.
|
||||||
@ -191,15 +184,45 @@ namespace MWGui
|
|||||||
|
|
||||||
drawItems();
|
drawItems();
|
||||||
|
|
||||||
// update selected weapon icon
|
notifyContentChanged();
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(mPtr).getInventoryStore(mPtr);
|
|
||||||
MWWorld::ContainerStoreIterator weaponSlot = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
||||||
if (weaponSlot == invStore.end())
|
|
||||||
mWindowManager.unsetSelectedWeapon();
|
|
||||||
else
|
|
||||||
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MyGUI::IntPoint mousePos = MyGUI::InputManager::getInstance ().getLastPressedPosition (MyGUI::MouseButton::Left);
|
||||||
|
MyGUI::IntPoint relPos = mousePos - mAvatar->getAbsolutePosition ();
|
||||||
|
int realX = int(float(relPos.left) / float(mAvatar->getSize().width) * 512.f );
|
||||||
|
int realY = int(float(relPos.top) / float(mAvatar->getSize().height) * 1024.f );
|
||||||
|
|
||||||
|
MWWorld::Ptr itemSelected = getAvatarSelectedItem (realX, realY);
|
||||||
|
if (itemSelected.isEmpty ())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (unsigned int i=0; i < mContainerWidget->getChildCount (); ++i)
|
||||||
|
{
|
||||||
|
MyGUI::Widget* w = mContainerWidget->getChildAt (i);
|
||||||
|
|
||||||
|
if (*w->getUserData<MWWorld::Ptr>() == itemSelected)
|
||||||
|
{
|
||||||
|
onSelectedItem(w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr InventoryWindow::getAvatarSelectedItem(int x, int y)
|
||||||
|
{
|
||||||
|
int slot = mPreview.getSlotSelected (x, y);
|
||||||
|
|
||||||
|
if (slot == -1)
|
||||||
|
return MWWorld::Ptr();
|
||||||
|
|
||||||
|
MWWorld::Ptr player = mPtr;
|
||||||
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(player).getInventoryStore(player);
|
||||||
|
if (invStore.getSlot(slot) != invStore.end())
|
||||||
|
return *invStore.getSlot (slot);
|
||||||
|
else
|
||||||
|
return MWWorld::Ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> InventoryWindow::getEquippedItems()
|
std::vector<MWWorld::Ptr> InventoryWindow::getEquippedItems()
|
||||||
@ -285,6 +308,12 @@ namespace MWGui
|
|||||||
mWindowManager.unsetSelectedWeapon();
|
mWindowManager.unsetSelectedWeapon();
|
||||||
else
|
else
|
||||||
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
mWindowManager.setSelectedWeapon(*weaponSlot, 100); /// \todo track weapon durability
|
||||||
|
|
||||||
|
MyGUI::IntSize size = mAvatar->getSize();
|
||||||
|
|
||||||
|
mPreview.update (size.width, size.height);
|
||||||
|
mAvatarImage->setSize(MyGUI::IntSize(std::max(mAvatar->getSize().width, 512), std::max(mAvatar->getSize().height, 1024)));
|
||||||
|
mAvatarImage->setImageTexture("CharacterPreview");
|
||||||
}
|
}
|
||||||
|
|
||||||
void InventoryWindow::pickUpObject (MWWorld::Ptr object)
|
void InventoryWindow::pickUpObject (MWWorld::Ptr object)
|
||||||
@ -307,6 +336,9 @@ namespace MWGui
|
|||||||
&& (type != typeid(ESM::Potion).name()))
|
&& (type != typeid(ESM::Potion).name()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (MWWorld::Class::get(object).getName(object) == "") // objects without name presented to user can never be picked up
|
||||||
|
return;
|
||||||
|
|
||||||
// sound
|
// sound
|
||||||
std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
|
std::string sound = MWWorld::Class::get(object).getUpSoundId(object);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1);
|
MWBase::Environment::get().getSoundManager()->playSound(sound, 1, 1);
|
||||||
@ -325,12 +357,12 @@ namespace MWGui
|
|||||||
|
|
||||||
std::string path = std::string("icons\\");
|
std::string path = std::string("icons\\");
|
||||||
path += MWWorld::Class::get(newObject).getInventoryIcon(newObject);
|
path += MWWorld::Class::get(newObject).getInventoryIcon(newObject);
|
||||||
MyGUI::ImageBox* baseWidget = mContainerWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
MyGUI::ImageBox* baseWidget = mContainerWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(0, 0, 42, 42), MyGUI::Align::Default);
|
||||||
baseWidget->detachFromWidget();
|
baseWidget->detachFromWidget();
|
||||||
baseWidget->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
baseWidget->attachToWidget(mDragAndDrop->mDragAndDropWidget);
|
||||||
baseWidget->setUserData(newObject);
|
baseWidget->setUserData(newObject);
|
||||||
mDragAndDrop->mDraggedWidget = baseWidget;
|
mDragAndDrop->mDraggedWidget = baseWidget;
|
||||||
ImageBox* image = baseWidget->createWidget<ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
MyGUI::ImageBox* image = baseWidget->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default);
|
||||||
int pos = path.rfind(".");
|
int pos = path.rfind(".");
|
||||||
path.erase(pos);
|
path.erase(pos);
|
||||||
path.append(".dds");
|
path.append(".dds");
|
||||||
@ -346,4 +378,9 @@ namespace MWGui
|
|||||||
text->setCaption(getCountString(count));
|
text->setCaption(getCountString(count));
|
||||||
mDragAndDrop->mDraggedFrom = this;
|
mDragAndDrop->mDraggedFrom = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyGUI::IntCoord InventoryWindow::getAvatarScreenCoord ()
|
||||||
|
{
|
||||||
|
return mAvatar->getAbsoluteCoord ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef MGUI_Inventory_H
|
#ifndef MGUI_Inventory_H
|
||||||
#define MGUI_Inventory_H
|
#define MGUI_Inventory_H
|
||||||
|
|
||||||
|
#include "../mwrender/characterpreview.hpp"
|
||||||
|
|
||||||
#include "container.hpp"
|
#include "container.hpp"
|
||||||
#include "window_pinnable_base.hpp"
|
#include "window_pinnable_base.hpp"
|
||||||
|
|
||||||
@ -9,7 +11,7 @@ namespace MWGui
|
|||||||
class InventoryWindow : public ContainerBase, public WindowPinnableBase
|
class InventoryWindow : public ContainerBase, public WindowPinnableBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InventoryWindow(WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
|
InventoryWindow(MWBase::WindowManager& parWindowManager,DragAndDrop* dragAndDrop);
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
||||||
@ -22,8 +24,13 @@ namespace MWGui
|
|||||||
|
|
||||||
int getPlayerGold();
|
int getPlayerGold();
|
||||||
|
|
||||||
|
MyGUI::IntCoord getAvatarScreenCoord();
|
||||||
|
|
||||||
|
MWWorld::Ptr getAvatarSelectedItem(int x, int y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MyGUI::Widget* mAvatar;
|
MyGUI::Widget* mAvatar;
|
||||||
|
MyGUI::ImageBox* mAvatarImage;
|
||||||
MyGUI::TextBox* mArmorRating;
|
MyGUI::TextBox* mArmorRating;
|
||||||
MyGUI::ProgressBar* mEncumbranceBar;
|
MyGUI::ProgressBar* mEncumbranceBar;
|
||||||
MyGUI::TextBox* mEncumbranceText;
|
MyGUI::TextBox* mEncumbranceText;
|
||||||
@ -37,6 +44,11 @@ namespace MWGui
|
|||||||
MyGUI::Button* mFilterMagic;
|
MyGUI::Button* mFilterMagic;
|
||||||
MyGUI::Button* mFilterMisc;
|
MyGUI::Button* mFilterMisc;
|
||||||
|
|
||||||
|
int mLastXSize;
|
||||||
|
int mLastYSize;
|
||||||
|
|
||||||
|
MWRender::InventoryPreview mPreview;
|
||||||
|
|
||||||
bool mTrading;
|
bool mTrading;
|
||||||
|
|
||||||
void onWindowResize(MyGUI::Window* _sender);
|
void onWindowResize(MyGUI::Window* _sender);
|
||||||
|
39
apps/openmw/mwgui/itemselection.cpp
Normal file
39
apps/openmw/mwgui/itemselection.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include "itemselection.hpp"
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
|
||||||
|
ItemSelectionDialog::ItemSelectionDialog(const std::string &label, ContainerBase::Filter filter, MWBase::WindowManager& parWindowManager)
|
||||||
|
: ContainerBase(NULL)
|
||||||
|
, WindowModal("openmw_itemselection_dialog.layout", parWindowManager)
|
||||||
|
{
|
||||||
|
mFilter = filter;
|
||||||
|
|
||||||
|
MyGUI::ScrollView* itemView;
|
||||||
|
MyGUI::Widget* containerWidget;
|
||||||
|
getWidget(containerWidget, "Items");
|
||||||
|
getWidget(itemView, "ItemView");
|
||||||
|
setWidgets(containerWidget, itemView);
|
||||||
|
|
||||||
|
MyGUI::TextBox* l;
|
||||||
|
getWidget(l, "Label");
|
||||||
|
l->setCaptionWithReplacing (label);
|
||||||
|
|
||||||
|
MyGUI::Button* cancelButton;
|
||||||
|
getWidget(cancelButton, "CancelButton");
|
||||||
|
cancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &ItemSelectionDialog::onCancelButtonClicked);
|
||||||
|
|
||||||
|
center();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemSelectionDialog::onSelectedItemImpl(MWWorld::Ptr item)
|
||||||
|
{
|
||||||
|
eventItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ItemSelectionDialog::onCancelButtonClicked(MyGUI::Widget* sender)
|
||||||
|
{
|
||||||
|
eventDialogCanceled();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
apps/openmw/mwgui/itemselection.hpp
Normal file
28
apps/openmw/mwgui/itemselection.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "container.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
|
||||||
|
class ItemSelectionDialog : public ContainerBase, public WindowModal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ItemSelectionDialog(const std::string& label, ContainerBase::Filter filter, MWBase::WindowManager& parWindowManager);
|
||||||
|
|
||||||
|
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void;
|
||||||
|
typedef MyGUI::delegates::CMultiDelegate1<MWWorld::Ptr> EventHandle_Item;
|
||||||
|
|
||||||
|
EventHandle_Item eventItemSelected;
|
||||||
|
EventHandle_Void eventDialogCanceled;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void onReferenceUnavailable() { ; }
|
||||||
|
|
||||||
|
virtual void onSelectedItemImpl(MWWorld::Ptr item);
|
||||||
|
|
||||||
|
void onCancelButtonClicked(MyGUI::Widget* sender);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
#include "journalwindow.hpp"
|
#include "journalwindow.hpp"
|
||||||
#include "window_manager.hpp"
|
|
||||||
#include "../mwdialogue/journal.hpp"
|
|
||||||
#include "../mwbase/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
#include "../mwbase/world.hpp"
|
||||||
|
#include "../mwbase/journal.hpp"
|
||||||
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/windowmanager.hpp"
|
||||||
|
|
||||||
|
#include "../mwdialogue/journalentry.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -79,9 +81,9 @@ book formatText(std::string text,book mBook,int maxLine, int lineSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager)
|
MWGui::JournalWindow::JournalWindow (MWBase::WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_journal_layout.xml", parWindowManager)
|
: WindowBase("openmw_journal.layout", parWindowManager)
|
||||||
, lastPos(0)
|
, mLastPos(0)
|
||||||
, mVisible(false)
|
, mVisible(false)
|
||||||
{
|
{
|
||||||
//setCoord(0,0,498, 342);
|
//setCoord(0,0,498, 342);
|
||||||
@ -145,19 +147,19 @@ void MWGui::JournalWindow::open()
|
|||||||
{
|
{
|
||||||
if(left)
|
if(left)
|
||||||
{
|
{
|
||||||
leftPages.push_back(*it);
|
mLeftPages.push_back(*it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rightPages.push_back(*it);
|
mRightPages.push_back(*it);
|
||||||
}
|
}
|
||||||
left = !left;
|
left = !left;
|
||||||
}
|
}
|
||||||
if(!left) rightPages.push_back("");
|
if(!left) mRightPages.push_back("");
|
||||||
|
|
||||||
mPageNumber = leftPages.size()-1;
|
mPageNumber = mLeftPages.size()-1;
|
||||||
displayLeftText(leftPages[mPageNumber]);
|
displayLeftText(mLeftPages[mPageNumber]);
|
||||||
displayRightText(rightPages[mPageNumber]);
|
displayRightText(mRightPages[mPageNumber]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -181,13 +183,13 @@ void MWGui::JournalWindow::displayRightText(std::string text)
|
|||||||
|
|
||||||
void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
|
void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender)
|
||||||
{
|
{
|
||||||
if(mPageNumber < int(leftPages.size())-1)
|
if(mPageNumber < int(mLeftPages.size())-1)
|
||||||
{
|
{
|
||||||
std::string nextSound = "book page2";
|
std::string nextSound = "book page2";
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (nextSound, 1.0, 1.0);
|
||||||
mPageNumber = mPageNumber + 1;
|
mPageNumber = mPageNumber + 1;
|
||||||
displayLeftText(leftPages[mPageNumber]);
|
displayLeftText(mLeftPages[mPageNumber]);
|
||||||
displayRightText(rightPages[mPageNumber]);
|
displayRightText(mRightPages[mPageNumber]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +200,7 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender)
|
|||||||
std::string prevSound = "book page";
|
std::string prevSound = "book page";
|
||||||
MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0);
|
MWBase::Environment::get().getSoundManager()->playSound (prevSound, 1.0, 1.0);
|
||||||
mPageNumber = mPageNumber - 1;
|
mPageNumber = mPageNumber - 1;
|
||||||
displayLeftText(leftPages[mPageNumber]);
|
displayLeftText(mLeftPages[mPageNumber]);
|
||||||
displayRightText(rightPages[mPageNumber]);
|
displayRightText(mRightPages[mPageNumber]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user