mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 19:19:40 +00:00
te
This commit is contained in:
commit
2236f69645
158 changed files with 6176 additions and 4793 deletions
4
.gitmodules
vendored
4
.gitmodules
vendored
|
@ -1,6 +1,6 @@
|
||||||
[submodule "libs/mangle"]
|
[submodule "libs/mangle"]
|
||||||
path = libs/mangle
|
path = libs/mangle
|
||||||
url = git://github.com/korslund/mangle.git
|
url = git://github.com/zinnschlag/mangle.git
|
||||||
[submodule "libs/openengine"]
|
[submodule "libs/openengine"]
|
||||||
path = libs/openengine
|
path = libs/openengine
|
||||||
url = git://github.com/korslund/OpenEngine
|
url = git://github.com/zinnschlag/OpenEngine
|
||||||
|
|
157
CMakeLists.txt
157
CMakeLists.txt
|
@ -5,9 +5,22 @@ option(USE_AUDIERE "use Audiere for sound" OFF)
|
||||||
option(USE_FFMPEG "use ffmpeg for sound" OFF)
|
option(USE_FFMPEG "use ffmpeg for sound" OFF)
|
||||||
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
|
option(USE_MPG123 "use mpg123 + libsndfile for sound" ON)
|
||||||
|
|
||||||
|
find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems")
|
||||||
|
|
||||||
# Location of morrowind data files
|
# Location of morrowind data files
|
||||||
set(MORROWIND_DATA_FILES "data"
|
if(DPKG_PROGRAM)
|
||||||
CACHE PATH "location of Morrowind data files")
|
set(MORROWIND_DATA_FILES "/usr/share/games/openmw/data/" CACHE PATH "location of Morrowind data files")
|
||||||
|
set(MORROWIND_RESOURCE_FILES "/usr/share/games/openmw/resources/" CACHE PATH "location of Morrowind data files")
|
||||||
|
else()
|
||||||
|
if (APPLE)
|
||||||
|
# set path inside bundle
|
||||||
|
set(MORROWIND_DATA_FILES "Contents/Resources/data" CACHE PATH "location of Morrowind data files")
|
||||||
|
set(MORROWIND_RESOURCE_FILES "Contents/Resources/resources" CACHE PATH "location of Morrowind data files")
|
||||||
|
else()
|
||||||
|
set(MORROWIND_DATA_FILES "data" CACHE PATH "location of Morrowind data files")
|
||||||
|
set(MORROWIND_RESOURCE_FILES "resources" CACHE PATH "location of Morrowind data files")
|
||||||
|
endif(APPLE)
|
||||||
|
endif(DPKG_PROGRAM)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
option(USE_DEBUG_CONSOLE "whether a debug console should be enabled for debug builds, if false debug output is redirected to Visual Studio output" ON)
|
option(USE_DEBUG_CONSOLE "whether a debug console should be enabled for debug builds, if false debug output is redirected to Visual Studio output" ON)
|
||||||
|
@ -16,7 +29,6 @@ endif()
|
||||||
# We probably support older versions than this.
|
# We probably support older versions than this.
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Pre-built binaries being used?
|
# Pre-built binaries being used?
|
||||||
#
|
#
|
||||||
|
@ -81,6 +93,12 @@ set(NIFOGRE_HEADER
|
||||||
${COMP_DIR}/nifogre/ogre_nif_loader.hpp)
|
${COMP_DIR}/nifogre/ogre_nif_loader.hpp)
|
||||||
source_group(components\\nifogre FILES ${NIFOGRE} ${NIFOGRE_HEADER})
|
source_group(components\\nifogre FILES ${NIFOGRE} ${NIFOGRE_HEADER})
|
||||||
|
|
||||||
|
set(NIFBULLET
|
||||||
|
${COMP_DIR}/nifbullet/bullet_nif_loader.cpp)
|
||||||
|
set(NIFBULLET_HEADER
|
||||||
|
${COMP_DIR}/nifbullet/bullet_nif_loader.hpp)
|
||||||
|
source_group(components\\nifbullet FILES ${NIFBULLET} ${NIFBULLET_HEADER})
|
||||||
|
|
||||||
set(TO_UTF8
|
set(TO_UTF8
|
||||||
${COMP_DIR}/to_utf8/to_utf8.cpp)
|
${COMP_DIR}/to_utf8/to_utf8.cpp)
|
||||||
set(TO_UTF8_HEADER
|
set(TO_UTF8_HEADER
|
||||||
|
@ -130,10 +148,10 @@ file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp)
|
||||||
source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER})
|
source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER})
|
||||||
|
|
||||||
set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8}
|
set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8}
|
||||||
${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER})
|
${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET})
|
||||||
set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER}
|
set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER}
|
||||||
${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER}
|
${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER}
|
||||||
${INTERPRETER_HEADER} ${FILE_FINDER_HEADER})
|
${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER})
|
||||||
|
|
||||||
# source directory: libs
|
# source directory: libs
|
||||||
|
|
||||||
|
@ -153,6 +171,21 @@ set(OENGINE_GUI
|
||||||
${LIBDIR}/openengine/gui/manager.cpp
|
${LIBDIR}/openengine/gui/manager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(OENGINE_BULLET
|
||||||
|
${LIBDIR}/openengine/bullet/btKinematicCharacterController.cpp
|
||||||
|
${LIBDIR}/openengine/bullet/btKinematicCharacterController.h
|
||||||
|
${LIBDIR}/openengine/bullet/BtOgre.cpp
|
||||||
|
${LIBDIR}/openengine/bullet/BtOgreExtras.h
|
||||||
|
${LIBDIR}/openengine/bullet/BtOgreGP.h
|
||||||
|
${LIBDIR}/openengine/bullet/BtOgrePG.h
|
||||||
|
${LIBDIR}/openengine/bullet/CMotionState.cpp
|
||||||
|
${LIBDIR}/openengine/bullet/CMotionState.h
|
||||||
|
${LIBDIR}/openengine/bullet/physic.cpp
|
||||||
|
${LIBDIR}/openengine/bullet/physic.hpp
|
||||||
|
${LIBDIR}/openengine/bullet/BulletShapeLoader.cpp
|
||||||
|
${LIBDIR}/openengine/bullet/BulletShapeLoader.h
|
||||||
|
)
|
||||||
|
|
||||||
# Sound setup
|
# Sound setup
|
||||||
if (USE_AUDIERE)
|
if (USE_AUDIERE)
|
||||||
set(MANGLE_SOUND_OUTPUT
|
set(MANGLE_SOUND_OUTPUT
|
||||||
|
@ -193,7 +226,7 @@ set(OENGINE_SOUND
|
||||||
${LIBDIR}/mangle/sound/outputs/openal_out.cpp
|
${LIBDIR}/mangle/sound/outputs/openal_out.cpp
|
||||||
${MANGLE_SOUND_OUTPUT}
|
${MANGLE_SOUND_OUTPUT}
|
||||||
)
|
)
|
||||||
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_SOUND})
|
set(OENGINE_ALL ${OENGINE_OGRE} ${OENGINE_GUI} ${OENGINE_SOUND} ${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 ${MANGLE_ALL} ${OENGINE_ALL})
|
||||||
|
@ -205,25 +238,34 @@ if (WIN32)
|
||||||
add_definitions(-DBOOST_ALL_NO_LIB)
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||||
else (WIN32)
|
else (WIN32)
|
||||||
set(PLATFORM_INCLUDE_DIR "")
|
set(PLATFORM_INCLUDE_DIR "")
|
||||||
|
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
|
||||||
|
include_directories(${UUID_INCLUDE_DIR})
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
if (MSVC10)
|
if (MSVC10)
|
||||||
set(PLATFORM_INCLUDE_DIR "")
|
set(PLATFORM_INCLUDE_DIR "")
|
||||||
|
add_definitions(-DMYGUI_DONT_REPLACE_NULLPTR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
set(Boost_USE_STATIC_LIBS ON)
|
||||||
|
endif (APPLE)
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
find_package(OGRE REQUIRED)
|
find_package(OGRE REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
|
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
|
||||||
find_package(OIS REQUIRED)
|
find_package(OIS REQUIRED)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
|
find_package(Bullet REQUIRED)
|
||||||
include_directories("."
|
include_directories("."
|
||||||
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre
|
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE
|
||||||
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
||||||
${PLATFORM_INCLUDE_DIR}
|
${PLATFORM_INCLUDE_DIR}
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
|
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
|
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
|
${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/OgrePlatform/include
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
|
${UUID_INCLUDE_DIR}
|
||||||
${LIBDIR}
|
${LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -251,21 +293,19 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OpenMW_BINARY_DIR}")
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32
|
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.win32
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
|
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
|
||||||
else (WIN32)
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux
|
|
||||||
"${OpenMW_BINARY_DIR}/plugins.cfg" COPYONLY)
|
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.linux
|
||||||
|
"${OpenMW_BINARY_DIR}/plugins.cfg")
|
||||||
|
endif()
|
||||||
|
if (APPLE)
|
||||||
|
configure_file(${OpenMW_SOURCE_DIR}/files/plugins.cfg.mac
|
||||||
|
"${OpenMW_BINARY_DIR}/plugins.cfg")
|
||||||
|
endif (APPLE)
|
||||||
|
|
||||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
||||||
"${OpenMW_BINARY_DIR}/openmw.cfg")
|
"${OpenMW_BINARY_DIR}/openmw.cfg")
|
||||||
|
|
||||||
if (APPLE)
|
|
||||||
set(APPLE_BUNDLE_RESOURCES
|
|
||||||
${CMAKE_SOURCE_DIR}/files/openmw.cfg
|
|
||||||
${CMAKE_SOURCE_DIR}/files/mac/plugins.cfg
|
|
||||||
)
|
|
||||||
endif (APPLE)
|
|
||||||
|
|
||||||
# Compiler settings
|
# Compiler settings
|
||||||
if (CMAKE_COMPILER_IS_GNUCC)
|
if (CMAKE_COMPILER_IS_GNUCC)
|
||||||
#add_definitions (-Wall -Werror)
|
#add_definitions (-Wall -Werror)
|
||||||
|
@ -275,21 +315,17 @@ endif (CMAKE_COMPILER_IS_GNUCC)
|
||||||
# Apple bundling
|
# Apple bundling
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
set(MISC_FILES
|
set(MISC_FILES
|
||||||
${CMAKE_SOURCE_DIR}/files/openmw.cfg
|
${OpenMW_BINARY_DIR}/openmw.cfg
|
||||||
${CMAKE_SOURCE_DIR}/files/mac/plugins.cfg
|
${OpenMW_BINARY_DIR}/plugins.cfg)
|
||||||
${CMAKE_SOURCE_DIR}/files/mac/ogre.cfg)
|
|
||||||
install(TARGETS openmw
|
|
||||||
BUNDLE DESTINATION .
|
|
||||||
RUNTIME DESTINATION ../MacOS
|
|
||||||
COMPONENT Runtime)
|
|
||||||
install(FILES ${MISC_FILES} DESTINATION ../MacOS)
|
install(FILES ${MISC_FILES} DESTINATION ../MacOS)
|
||||||
|
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION ../Resources)
|
||||||
set(CPACK_GENERATOR "Bundle")
|
set(CPACK_GENERATOR "Bundle")
|
||||||
set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist")
|
set(CPACK_BUNDLE_PLIST "${CMAKE_SOURCE_DIR}/files/mac/Info.plist")
|
||||||
set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns")
|
set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/files/mac/openmw.icns")
|
||||||
set(CPACK_BUNDLE_NAME "OpenMW")
|
set(CPACK_BUNDLE_NAME "OpenMW")
|
||||||
set(CPACK_PACKAGE_VERSION "0.07")
|
set(CPACK_PACKAGE_VERSION "0.10")
|
||||||
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_MINOR "07")
|
set(CPACK_PACKAGE_VERSION_MINOR "10")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "")
|
set(CPACK_PACKAGE_VERSION_PATCH "")
|
||||||
|
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
@ -299,6 +335,57 @@ set(CMAKE_CXX_FLAGS "-arch i386")
|
||||||
|
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
|
|
||||||
|
if(DPKG_PROGRAM)
|
||||||
|
SET(CMAKE_INSTALL_PREFIX "/usr")
|
||||||
|
|
||||||
|
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
|
exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe" OUTPUT_VARIABLE GIT_VERSION )
|
||||||
|
STRING(REGEX REPLACE "openmw-" "" VERSION_STRING "${GIT_VERSION}")
|
||||||
|
exec_program("git" ARGS "config --get user.name" OUTPUT_VARIABLE GIT_NAME )
|
||||||
|
exec_program("git" ARGS "config --get user.email" OUTPUT_VARIABLE GIT_EMAIL)
|
||||||
|
set(PACKAGE_MAINTAINER "${GIT_NAME} <${GIT_EMAIL}>")
|
||||||
|
else()
|
||||||
|
#FIXME this should probably be read from some file like ${CMAKE_CURRENT_SOURCE_DIR}/VERSION or something that gets updated when changing version
|
||||||
|
set(VERSION_STRING "0.10.0")
|
||||||
|
set(PACKAGE_MAINTAINER "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#Install global configuration files
|
||||||
|
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg" DESTINATION "../etc/openmw/" 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(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources")
|
||||||
|
INSTALL(DIRECTORY DESTINATION "share/games/openmw/data/" COMPONENT "Resources")
|
||||||
|
|
||||||
|
SET(CPACK_GENERATOR "DEB")
|
||||||
|
SET(CPACK_PACKAGE_NAME "openmw")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://openmw.com")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${PACKAGE_MAINTAINER}")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A reimplementation of The Elder Scrolls III: Morrowind
|
||||||
|
OpenMW is a reimplementation of the Bethesda Game Studios game The Elder Scrolls III: Morrowind.
|
||||||
|
Data files from the original game is required to run it.")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_NAME "openmw")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_VERSION "${VERSION_STRING}")
|
||||||
|
SET(CPACK_PACKAGE_EXECUTABLES "openmw;OpenMW")
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libogremain-1.7.1 (>= 1.7.1-1), libbullet2.77 (>= 2.77), libboost-filesystem1.42.0 (>= 1.42.0), libboost-program-options1.42.0 (>= 1.42.0), libboost-system1.42.0 (>= 1.42.0), libboost-thread1.42.0 (>= 1.42.0), libc6 (>= 2.11.2), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:4.1.1), libmpg123-0 (>= 1.12.1), libois-1.2.0 (>= 1.2.0), libopenal1 (>= 1:1.12.854), libsndfile1 (>= 1.0.23), libstdc++6 (>= 4.4.5), libuuid1 (>= 2.17.2)")
|
||||||
|
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_SECTION "Games")
|
||||||
|
|
||||||
|
string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${DPKG_PROGRAM} --print-architecture
|
||||||
|
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
|
||||||
|
|
||||||
|
|
||||||
|
include(CPack)
|
||||||
|
endif(DPKG_PROGRAM)
|
||||||
|
|
||||||
# Apps and tools
|
# Apps and tools
|
||||||
add_subdirectory( apps/openmw )
|
add_subdirectory( apps/openmw )
|
||||||
|
|
||||||
|
@ -308,6 +395,7 @@ if (BUILD_ESMTOOL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
if (MSVC)
|
||||||
if (USE_DEBUG_CONSOLE)
|
if (USE_DEBUG_CONSOLE)
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
|
||||||
|
@ -322,6 +410,23 @@ if (WIN32)
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
|
||||||
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
|
# Same for MinGW
|
||||||
|
if (MINGW)
|
||||||
|
if (USE_DEBUG_CONSOLE)
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
|
||||||
|
else(USE_DEBUG_CONSOLE)
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "-Wl,-subsystem,windows")
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "-Wl,-subsystem,windows")
|
||||||
|
endif(USE_DEBUG_CONSOLE)
|
||||||
|
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "-Wl,-subsystem,console")
|
||||||
|
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS_RELEASE "_CONSOLE")
|
||||||
|
endif(MINGW)
|
||||||
|
|
||||||
# TODO: At some point release builds should not use the console but rather write to a log file
|
# TODO: At some point release builds should not use the console but rather write to a log file
|
||||||
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
|
||||||
|
|
117
README_Mac.md
117
README_Mac.md
|
@ -29,22 +29,28 @@ Getting OpenMW Working
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
1. Clone this repository.
|
1. Clone this repository.
|
||||||
2. Install `bjam` through MacPorts.
|
2. Note about libs: I prefer not to install them globally (i. e. in /usr/local/), so I installing them in directory in my home directory. If OpenMW sources is in $HOME/path/openmw, I'm using $HOME/path/libs/root as prefix for boost and other libs.
|
||||||
3. Download [boost][] 1.43 and install it with the following command:
|
It's useful to create env var for lib install prefix:
|
||||||
|
$ export OMW_LIB_PREFIX=$HOME/path/libs/root
|
||||||
|
|
||||||
$ mkdir build && sudo bjam --build-dir=build \
|
3. First of all, set for current terminal some env vars:
|
||||||
--layout=versioned --toolset=darwin architecture=i386 \
|
$ export CFLAGS="-arch i386"
|
||||||
address-model=32 --link=shared,static install
|
$ export CXXFLAGS="-arch i386"
|
||||||
|
$ export LDFLAGS="-arch i386"
|
||||||
|
All libs will build with correct architecture.
|
||||||
|
If you close your terminal, you should set env vars again before pcoceeding to next steps!
|
||||||
|
|
||||||
|
4. Download [boost][] (tested with 1.45) and install it with the following command:
|
||||||
|
|
||||||
|
$ cd /path/to/boost/source
|
||||||
|
$ ./bootstrap.sh --prefix=$OMW_LIB_PREFIX
|
||||||
|
$ ./bjam --build-dir=build --layout=versioned \
|
||||||
|
--toolset=darwin architecture=x86 address-model=32 \
|
||||||
|
--link-shared,static --prefix=$OMW_LIB_PREFIX install
|
||||||
|
|
||||||
|
|
||||||
4. Download [Ogre][] 1.7.1 and build and Xcode project with CMake:
|
5. Download [Ogre][] SDK (tested with 1.7.2) and move `lib/Release/Ogre.framework` into
|
||||||
|
`Library/Frameworks`.
|
||||||
$ mdkir build && cd build && \
|
|
||||||
BOOST_INCLUDEDIR=/usr/local/include/boost-1_43 \
|
|
||||||
BOOST_LIBRARYDIR=/usr/local/lib cmake -G Xcode ..
|
|
||||||
|
|
||||||
5. Once the build completes, move `lib/Release/Ogre.framework` into
|
|
||||||
`/Library/Frameworks`.
|
|
||||||
|
|
||||||
6. Download [OIS][] and use the XCode project provided in
|
6. Download [OIS][] and use the XCode project provided in
|
||||||
`ois/Mac/XCode-2.2`. Be sure to set your build architecture to
|
`ois/Mac/XCode-2.2`. Be sure to set your build architecture to
|
||||||
|
@ -52,20 +58,89 @@ Getting OpenMW Working
|
||||||
builds, move `ois/Mac/XCode-2.2/build/Debug/OIS.framework` to
|
builds, move `ois/Mac/XCode-2.2/build/Debug/OIS.framework` to
|
||||||
`/Library/Frameworks`.
|
`/Library/Frameworks`.
|
||||||
|
|
||||||
7. Generate the Makefile for OpenMW as follows:
|
7. Download [mpg123][] and build it:
|
||||||
|
$ cd /path/to/mpg123/source
|
||||||
|
$ ./configure --prefix=$OMW_LIB_PREFIX --disable-debug \
|
||||||
|
--disable-dependency-tracking \
|
||||||
|
--with-optimization=4 \
|
||||||
|
--with-audio=coreaudio \
|
||||||
|
--with-default-audio=coreaudio \
|
||||||
|
--with-cpu=sse_alone \
|
||||||
|
$ make install
|
||||||
|
|
||||||
$ mkdir build && cd build && \
|
8. Download [libsndfile][] and build it:
|
||||||
BOOST_INCLUDEDIR=/usr/local/include/boost-1_43 \
|
$ cd /path/to/libsndfile/source
|
||||||
BOOST_LIBRARYDIR=/usr/local/lib CMAKE_OSX_ARCHITECTURES=i386 \
|
$ ./configure --prefix=$OMW_LIB_PREFIX \
|
||||||
cmake ..
|
--disable-dependency-tracking
|
||||||
|
$ make install
|
||||||
|
|
||||||
8. Move your Morrowind `Data Files` directory into the root `openmw`
|
9. Download [Bullet][] and build it:
|
||||||
directory with the name `data`. Symlink it into the build directory.
|
$ cd /path/to/bullet/source
|
||||||
|
$ mkdir build
|
||||||
|
$ cd build
|
||||||
|
$ cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=$OMW_LIB_PREFIX \
|
||||||
|
-DBUILD_EXTRAS=OFF \
|
||||||
|
-DBUILD_DEMOS=OFF \
|
||||||
|
-DCMAKE_OSX_ARCHITECTURES=i386 \
|
||||||
|
-DCMAKE_INSTALL_NAME_DIR=$OMW_LIB_RPEFIX/lib \
|
||||||
|
-G"Unix Makefiles" ../
|
||||||
|
$ make install
|
||||||
|
|
||||||
|
10. Generate the Makefile for OpenMW as follows and build OpenMW:
|
||||||
|
$ mkdir /path/to/openmw/build/dir
|
||||||
|
$ cd /path/to/open/build/dir
|
||||||
|
$ cmake \
|
||||||
|
-D CMAKE_OSX_ARCHITECTURES=i386 \
|
||||||
|
-D BOOST_INCLUDEDIR=$OMW_LIB_PREFIX/include/boost-1_45 \
|
||||||
|
-D BOOST_LIBRARYDIR=$OMW_LIB_PREFIX/lib \
|
||||||
|
-D SNDFILE_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
|
||||||
|
-D SNDFILE_LIBRARY=$OMW_LIB_PREFIX/lib/libsndfile.a \
|
||||||
|
-D MPG123_LIBRARY=$OMW_LIB_PREFIX/lib/libmpg123.a \
|
||||||
|
-D MPG123_INCLUDE_DIR=$OMW_LIB_PREFIX/include \
|
||||||
|
-D BULLET_DYNAMICS_LIBRARY=$OMW_LIB_PREFIX/lib/libBulletDynamics.a \
|
||||||
|
-D BULLET_COLLISION_LIBRARY=$OMW_LIB_PREFIX/lib/libBulletCollision.a \
|
||||||
|
-D BULLET_MATH_LIBRARY=$OMW_LIB_PREFIX/lib/libLinearMath.a \
|
||||||
|
-D BULLET_SOFTBODY_LIBRARY=$OMW_LIB_PREFIX/lib/libBulletSoftBody.a \
|
||||||
|
-D BULLET_INCLUDE_DIR=$OMW_LIB_PREFIX/include/bullet/ \
|
||||||
|
-G "Unix Makefiles" /path/to/openmw/source/dir
|
||||||
|
$ make
|
||||||
|
You can use -G"Xcode" if you prefer Xcode, or -G"Eclipse CDT4 - Unix Makefiles"
|
||||||
|
if you prefer Eclipse. You also can specify -D CMAKE_BUILD_TYPE=Debug for debug
|
||||||
|
build.
|
||||||
|
|
||||||
|
11. In build directory create directory for game resources:
|
||||||
|
$ cd /path/to/openmw/build/dir
|
||||||
|
$ mkdir Contents
|
||||||
|
$ mkdir Contents/Resources
|
||||||
|
$ mkdir Contents/Plugins
|
||||||
|
Copy Ogre plugins from Ogre SDK to Plugins subdir:
|
||||||
|
$ cp /path/to/ogre/sdk/lib/*.dylib Contents/Plugins
|
||||||
|
Create symlink to resources subdirectory:
|
||||||
|
$ ln -s resources Contents/Resources/resources
|
||||||
|
Create symlinks for *.cfg files:
|
||||||
|
$ ln -s plugins.cfg Contents/MacOS/plugins.cfg
|
||||||
|
$ ln -s openmw.cfg Contents/MacOS/openmw.cfg
|
||||||
|
|
||||||
|
12. Move your Morrowind `Data Files` directory into the `Contents/Resources`
|
||||||
|
with the name `data` or create symlink:
|
||||||
|
$ ln -s /path/to/morrowind/data/files Contents/Resources/data
|
||||||
|
|
||||||
|
13. From your build directory run:
|
||||||
|
$ ./openmw
|
||||||
|
Enjoy!
|
||||||
|
|
||||||
|
14. Optionally you can create .app bundle:
|
||||||
|
$ make package
|
||||||
|
But for now you shold manually copy Contents directory from build directory to bundle
|
||||||
|
(because there is no plugins and resources in generated .app).
|
||||||
|
|
||||||
$ cd build && ln -s ../data data
|
|
||||||
|
|
||||||
[boost]: http://www.boost.org
|
[boost]: http://www.boost.org
|
||||||
[Ogre]: http://www.ogre3d.org
|
[Ogre]: http://www.ogre3d.org
|
||||||
|
[Bullet]: http://bulletphysics.org
|
||||||
[OIS]: http://wgois.sf.net
|
[OIS]: http://wgois.sf.net
|
||||||
|
[mpg123]: http://www.mpg123.de
|
||||||
|
[libsndfile]: http://www.mega-nerd.com/libsndfile
|
||||||
[official website]: http://openmw.com
|
[official website]: http://openmw.com
|
||||||
[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/
|
[Will Thimbleby's Ogre Framework]: http://www.thimbleby.net/ogre/
|
||||||
|
|
|
@ -4,7 +4,8 @@ project(OpenMW)
|
||||||
|
|
||||||
set(GAME
|
set(GAME
|
||||||
main.cpp
|
main.cpp
|
||||||
engine.cpp)
|
engine.cpp
|
||||||
|
path.cpp)
|
||||||
set(GAME_HEADER
|
set(GAME_HEADER
|
||||||
engine.hpp)
|
engine.hpp)
|
||||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||||
|
@ -14,16 +15,18 @@ set(GAMEREND
|
||||||
mwrender/cellimp.cpp
|
mwrender/cellimp.cpp
|
||||||
mwrender/interior.cpp
|
mwrender/interior.cpp
|
||||||
mwrender/exterior.cpp
|
mwrender/exterior.cpp
|
||||||
mwrender/playerpos.cpp
|
mwrender/sky.cpp
|
||||||
mwrender/sky.cpp)
|
mwrender/player.cpp
|
||||||
|
)
|
||||||
set(GAMEREND_HEADER
|
set(GAMEREND_HEADER
|
||||||
mwrender/cell.hpp
|
mwrender/cell.hpp
|
||||||
mwrender/cellimp.hpp
|
mwrender/cellimp.hpp
|
||||||
mwrender/mwscene.hpp
|
mwrender/mwscene.hpp
|
||||||
mwrender/interior.hpp
|
mwrender/interior.hpp
|
||||||
mwrender/exterior.hpp
|
mwrender/exterior.hpp
|
||||||
mwrender/playerpos.hpp
|
mwrender/sky.hpp
|
||||||
mwrender/sky.hpp)
|
mwrender/player.hpp
|
||||||
|
)
|
||||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||||
|
|
||||||
set(GAMEINPUT
|
set(GAMEINPUT
|
||||||
|
@ -46,6 +49,7 @@ set(GAMEGUI_HEADER
|
||||||
mwgui/dialogue.hpp
|
mwgui/dialogue.hpp
|
||||||
mwgui/dialogue_history.hpp
|
mwgui/dialogue_history.hpp
|
||||||
mwgui/window_base.hpp
|
mwgui/window_base.hpp
|
||||||
|
mwgui/stats_window.hpp
|
||||||
)
|
)
|
||||||
set(GAMEGUI
|
set(GAMEGUI
|
||||||
mwgui/window_manager.cpp
|
mwgui/window_manager.cpp
|
||||||
|
@ -60,6 +64,7 @@ set(GAMEGUI
|
||||||
mwgui/dialogue.cpp
|
mwgui/dialogue.cpp
|
||||||
mwgui/dialogue_history.cpp
|
mwgui/dialogue_history.cpp
|
||||||
mwgui/window_base.cpp
|
mwgui/window_base.cpp
|
||||||
|
mwgui/stats_window.cpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI})
|
source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI})
|
||||||
|
|
||||||
|
@ -103,6 +108,7 @@ set(GAMESCRIPT_HEADER
|
||||||
mwscript/controlextensions.hpp
|
mwscript/controlextensions.hpp
|
||||||
mwscript/extensions.hpp
|
mwscript/extensions.hpp
|
||||||
mwscript/globalscripts.hpp
|
mwscript/globalscripts.hpp
|
||||||
|
mwscript/ref.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||||
|
|
||||||
|
@ -120,6 +126,8 @@ set(GAMEWORLD
|
||||||
mwworld/actiontalk.cpp
|
mwworld/actiontalk.cpp
|
||||||
mwworld/actiontake.cpp
|
mwworld/actiontake.cpp
|
||||||
mwworld/containerutil.cpp
|
mwworld/containerutil.cpp
|
||||||
|
mwworld/player.cpp
|
||||||
|
mwworld/doingphysics.cpp
|
||||||
)
|
)
|
||||||
set(GAMEWORLD_HEADER
|
set(GAMEWORLD_HEADER
|
||||||
mwworld/refdata.hpp
|
mwworld/refdata.hpp
|
||||||
|
@ -137,6 +145,9 @@ set(GAMEWORLD_HEADER
|
||||||
mwworld/containerstore.hpp
|
mwworld/containerstore.hpp
|
||||||
mwworld/manualref.hpp
|
mwworld/manualref.hpp
|
||||||
mwworld/containerutil.hpp
|
mwworld/containerutil.hpp
|
||||||
|
mwworld/player.hpp
|
||||||
|
mwworld/doingphysics.hpp
|
||||||
|
mwworld/cellfunctors.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||||
|
|
||||||
|
@ -198,6 +209,7 @@ set(GAMEMECHANICS_HEADER
|
||||||
mwmechanics/stat.hpp
|
mwmechanics/stat.hpp
|
||||||
mwmechanics/creaturestats.hpp
|
mwmechanics/creaturestats.hpp
|
||||||
mwmechanics/magiceffects.hpp
|
mwmechanics/magiceffects.hpp
|
||||||
|
mwmechanics/movement.hpp
|
||||||
)
|
)
|
||||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||||
|
|
||||||
|
@ -219,7 +231,7 @@ add_executable(openmw
|
||||||
|
|
||||||
# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
|
# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
|
||||||
# when we change the backend.
|
# when we change the backend.
|
||||||
include_directories(${SOUND_INPUT_INCLUDES})
|
include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS})
|
||||||
add_definitions(${SOUND_DEFINE})
|
add_definitions(${SOUND_DEFINE})
|
||||||
|
|
||||||
target_link_libraries(openmw
|
target_link_libraries(openmw
|
||||||
|
@ -228,6 +240,7 @@ target_link_libraries(openmw
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${SOUND_INPUT_LIBRARY}
|
${SOUND_INPUT_LIBRARY}
|
||||||
|
${BULLET_LIBRARIES}
|
||||||
caelum
|
caelum
|
||||||
MyGUIEngine
|
MyGUIEngine
|
||||||
MyGUIOgrePlatform
|
MyGUIOgrePlatform
|
||||||
|
@ -236,4 +249,12 @@ target_link_libraries(openmw
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
find_library(CARBON_FRAMEWORK Carbon)
|
find_library(CARBON_FRAMEWORK Carbon)
|
||||||
target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
target_link_libraries(openmw ${CARBON_FRAMEWORK})
|
||||||
|
install(TARGETS openmw
|
||||||
|
BUNDLE DESTINATION .
|
||||||
|
RUNTIME DESTINATION ../MacOS
|
||||||
|
COMPONENT Runtime)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
|
if(DPKG_PROGRAM)
|
||||||
|
INSTALL(TARGETS openmw RUNTIME DESTINATION games COMPONENT openmw)
|
||||||
|
endif()
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <OgreVector3.h>
|
||||||
|
|
||||||
#include "components/esm/records.hpp"
|
#include "components/esm/records.hpp"
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
#include <components/misc/fileops.hpp>
|
#include <components/misc/fileops.hpp>
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
#include "mwworld/ptr.hpp"
|
#include "mwworld/ptr.hpp"
|
||||||
#include "mwworld/environment.hpp"
|
#include "mwworld/environment.hpp"
|
||||||
#include "mwworld/class.hpp"
|
#include "mwworld/class.hpp"
|
||||||
|
#include "mwworld/player.hpp"
|
||||||
|
|
||||||
#include "mwclass/classes.hpp"
|
#include "mwclass/classes.hpp"
|
||||||
|
|
||||||
|
@ -38,11 +41,15 @@
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
#include <OSX/macUtils.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <MyGUI_WidgetManager.h>
|
#include <MyGUI_WidgetManager.h>
|
||||||
#include "mwgui/class.hpp"
|
#include "mwgui/class.hpp"
|
||||||
|
#include "path.hpp"
|
||||||
|
|
||||||
|
#include "components/nifbullet/bullet_nif_loader.hpp"
|
||||||
|
|
||||||
|
|
||||||
//using namespace ESM;
|
//using namespace ESM;
|
||||||
|
|
||||||
|
@ -69,7 +76,12 @@ void OMW::Engine::executeLocalScripts()
|
||||||
|
|
||||||
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
{
|
{
|
||||||
if(! (mEnvironment.mSoundManager->isMusicPlaying()))
|
if(mShowFPS)
|
||||||
|
{
|
||||||
|
mEnvironment.mWindowManager->wmSetFPS(mOgre.getFPS());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying()))
|
||||||
{
|
{
|
||||||
// Play some good 'ol tunes
|
// Play some good 'ol tunes
|
||||||
mEnvironment.mSoundManager->startRandomTitle();
|
mEnvironment.mSoundManager->startRandomTitle();
|
||||||
|
@ -77,9 +89,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
|
|
||||||
std::string effect;
|
std::string effect;
|
||||||
|
|
||||||
|
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
||||||
|
|
||||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell();
|
|
||||||
//If the region has changed
|
//If the region has changed
|
||||||
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
||||||
timer.restart();
|
timer.restart();
|
||||||
|
@ -160,7 +170,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
mEnvironment.mWorld->markCellAsUnchanged();
|
mEnvironment.mWorld->markCellAsUnchanged();
|
||||||
|
|
||||||
// update actors
|
// update actors
|
||||||
mEnvironment.mMechanicsManager->update();
|
std::vector<std::pair<std::string, Ogre::Vector3> > movement;
|
||||||
|
mEnvironment.mMechanicsManager->update (movement);
|
||||||
|
|
||||||
if (focusFrameCounter++ == focusUpdateFrame)
|
if (focusFrameCounter++ == focusUpdateFrame)
|
||||||
{
|
{
|
||||||
|
@ -181,6 +192,9 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
|
|
||||||
focusFrameCounter = 0;
|
focusFrameCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
||||||
|
mEnvironment.mWorld->doPhysics (movement, mEnvironment.mFrameDuration);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -192,10 +206,13 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
OMW::Engine::Engine()
|
OMW::Engine::Engine()
|
||||||
: mDebug (false)
|
: mPhysicEngine (0)
|
||||||
|
, mShowFPS (false)
|
||||||
|
, mDebug (false)
|
||||||
, mVerboseScripts (false)
|
, mVerboseScripts (false)
|
||||||
, mNewGame (false)
|
, mNewGame (false)
|
||||||
, mUseSound (true)
|
, mUseSound (true)
|
||||||
|
, mCompileAll (false)
|
||||||
, mScriptManager (0)
|
, mScriptManager (0)
|
||||||
, mScriptContext (0)
|
, mScriptContext (0)
|
||||||
, mGuiManager (0)
|
, mGuiManager (0)
|
||||||
|
@ -213,6 +230,7 @@ OMW::Engine::~Engine()
|
||||||
delete mEnvironment.mDialogueManager;
|
delete mEnvironment.mDialogueManager;
|
||||||
delete mScriptManager;
|
delete mScriptManager;
|
||||||
delete mScriptContext;
|
delete mScriptContext;
|
||||||
|
delete mPhysicEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all BSA files in data directory.
|
// Load all BSA files in data directory.
|
||||||
|
@ -226,7 +244,7 @@ void OMW::Engine::loadBSA()
|
||||||
if (boost::filesystem::extension (iter->path())==".bsa")
|
if (boost::filesystem::extension (iter->path())==".bsa")
|
||||||
{
|
{
|
||||||
std::cout << "Adding " << iter->path().string() << std::endl;
|
std::cout << "Adding " << iter->path().string() << std::endl;
|
||||||
addBSA(iter->path().file_string());
|
addBSA(iter->path().string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +254,7 @@ void OMW::Engine::loadBSA()
|
||||||
|
|
||||||
void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
|
void OMW::Engine::addResourcesDirectory (const boost::filesystem::path& path)
|
||||||
{
|
{
|
||||||
mOgre.getRoot()->addResourceLocation (path.file_string(), "FileSystem",
|
mOgre.getRoot()->addResourceLocation (path.string(), "FileSystem",
|
||||||
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +265,12 @@ void OMW::Engine::setDataDir (const boost::filesystem::path& dataDir)
|
||||||
mDataDir = boost::filesystem::system_complete (dataDir);
|
mDataDir = boost::filesystem::system_complete (dataDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set resource dir
|
||||||
|
void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir)
|
||||||
|
{
|
||||||
|
mResDir = boost::filesystem::system_complete(parResDir);
|
||||||
|
}
|
||||||
|
|
||||||
// Set start cell name (only interiors for now)
|
// Set start cell name (only interiors for now)
|
||||||
|
|
||||||
void OMW::Engine::setCell (const std::string& cellName)
|
void OMW::Engine::setCell (const std::string& cellName)
|
||||||
|
@ -302,48 +326,53 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
std::cout << "Data directory: " << mDataDir << "\n";
|
std::cout << "Data directory: " << mDataDir << "\n";
|
||||||
|
|
||||||
const char* plugCfg = "plugins.cfg";
|
std::string cfgDir = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "");
|
||||||
|
std::string cfgUserDir = OMW::Path::getPath(OMW::Path::USER_CFG_PATH, "openmw", "");
|
||||||
|
std::string plugCfg = "plugins.cfg";
|
||||||
|
std::string ogreCfg = "ogre.cfg";
|
||||||
|
ogreCfg.insert(0, cfgUserDir);
|
||||||
|
|
||||||
mOgre.configure(!isFile("ogre.cfg"), plugCfg, false);
|
//A local plugins.cfg will be used if it exist, otherwise look in the default path
|
||||||
|
if(!isFile(plugCfg.c_str()))
|
||||||
|
{
|
||||||
|
plugCfg.insert(0, cfgDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
mOgre.configure(!isFile(ogreCfg.c_str()), cfgUserDir, plugCfg, false);
|
||||||
|
|
||||||
addResourcesDirectory (mDataDir / "Meshes");
|
addResourcesDirectory (mDataDir / "Meshes");
|
||||||
addResourcesDirectory (mDataDir / "Textures");
|
addResourcesDirectory (mDataDir / "Textures");
|
||||||
//boost::filesystem::copy_file("meshes\\b\\B_N_Argonian_F_Skins.nif",mDataDir / "b2\\B_N_Argonian_F_Skins.nif",boost::filesystem::copy_option::overwrite_if_exists);
|
|
||||||
/*CFileOperation fo; // create object
|
|
||||||
|
|
||||||
fo.SetOverwriteMode(false); // reset OverwriteMode flag (optional)
|
|
||||||
|
|
||||||
if (!fo.Copy("c:\\source", "c:\\dest")) // do Copy
|
|
||||||
{
|
|
||||||
fo.ShowError(); // if copy fails show error message
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
// This has to be added BEFORE MyGUI is initialized, as it needs
|
// This has to be added BEFORE MyGUI is initialized, as it needs
|
||||||
// to find core.xml here.
|
// to find core.xml here.
|
||||||
addResourcesDirectory("resources/mygui/");
|
addResourcesDirectory(mResDir / "mygui");
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
mOgre.createWindow("OpenMW");
|
mOgre.createWindow("OpenMW");
|
||||||
|
|
||||||
loadBSA();
|
loadBSA();
|
||||||
|
|
||||||
|
// Create physics. shapeLoader is deleted by the physic engine
|
||||||
|
ManualBulletShapeLoader* shapeLoader = new ManualBulletShapeLoader();
|
||||||
|
mPhysicEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
mEnvironment.mWorld = new MWWorld::World (mOgre, mDataDir, mMaster, mNewGame, mEnvironment);
|
mEnvironment.mWorld = new MWWorld::World (mOgre, mPhysicEngine, mDataDir, mMaster, mResDir, mNewGame, mEnvironment);
|
||||||
|
|
||||||
|
|
||||||
// Set up the GUI system
|
// Set up the GUI system
|
||||||
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(),
|
mGuiManager = new OEngine::GUI::MyGUIManager(mOgre.getWindow(), mOgre.getScene(), false, cfgDir);
|
||||||
mOgre.getScene());
|
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWAttribute>("Widget");
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpell>("Widget");
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSpellEffect>("Widget");
|
||||||
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWDynamicStat>("Widget");
|
||||||
|
|
||||||
// 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.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
||||||
mExtensions, mNewGame);
|
mExtensions, mShowFPS, mNewGame);
|
||||||
|
|
||||||
// Create sound system
|
// Create sound system
|
||||||
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),
|
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),
|
||||||
|
@ -371,12 +400,23 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
// load cell
|
// load cell
|
||||||
ESM::Position pos;
|
ESM::Position pos;
|
||||||
pos.pos[0] = pos.pos[1] = pos.pos[2] = 0;
|
|
||||||
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
|
||||||
mEnvironment.mWorld->changeCell (mCellName, pos);
|
pos.pos[2] = 0;
|
||||||
|
|
||||||
|
if (const ESM::Cell *exterior = mEnvironment.mWorld->getExterior (mCellName))
|
||||||
|
{
|
||||||
|
mEnvironment.mWorld->indexToPosition (exterior->data.gridX, exterior->data.gridY,
|
||||||
|
pos.pos[0], pos.pos[1], true);
|
||||||
|
mEnvironment.mWorld->changeToExteriorCell (pos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pos.pos[0] = pos.pos[1] = 0;
|
||||||
|
mEnvironment.mWorld->changeToInteriorCell (mCellName, pos);
|
||||||
|
}
|
||||||
|
|
||||||
// Sets up the input system
|
// Sets up the input system
|
||||||
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(),
|
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayer(),
|
||||||
*mEnvironment.mWindowManager, mDebug, *this);
|
*mEnvironment.mWindowManager, mDebug, *this);
|
||||||
mEnvironment.mInputManager = &input;
|
mEnvironment.mInputManager = &input;
|
||||||
|
|
||||||
|
@ -389,6 +429,29 @@ void OMW::Engine::go()
|
||||||
// Play some good 'ol tunes
|
// Play some good 'ol tunes
|
||||||
mEnvironment.mSoundManager->startRandomTitle();
|
mEnvironment.mSoundManager->startRandomTitle();
|
||||||
|
|
||||||
|
// scripts
|
||||||
|
if (mCompileAll)
|
||||||
|
{
|
||||||
|
typedef ESMS::ScriptListT<ESM::Script>::MapType Container;
|
||||||
|
|
||||||
|
Container scripts = mEnvironment.mWorld->getStore().scripts.list;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
int success = 0;
|
||||||
|
|
||||||
|
for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count)
|
||||||
|
if (mScriptManager->compile (iter->first))
|
||||||
|
++success;
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
std::cout
|
||||||
|
<< "compiled " << success << " of " << count << " scripts ("
|
||||||
|
<< 100*static_cast<double> (success)/count
|
||||||
|
<< "%)"
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
mOgre.start();
|
mOgre.start();
|
||||||
|
|
||||||
|
@ -396,6 +459,10 @@ void OMW::Engine::go()
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::activate()
|
void OMW::Engine::activate()
|
||||||
|
{
|
||||||
|
// TODO: This is only a workaround. The input dispatcher should catch any exceptions thrown inside
|
||||||
|
// the input handling functions. Looks like this will require an OpenEngine modification.
|
||||||
|
try
|
||||||
{
|
{
|
||||||
std::string handle = mEnvironment.mWorld->getFacedHandle();
|
std::string handle = mEnvironment.mWorld->getFacedHandle();
|
||||||
|
|
||||||
|
@ -411,7 +478,7 @@ void OMW::Engine::activate()
|
||||||
&ptr.getRefData().getLocals(), ptr);
|
&ptr.getRefData().getLocals(), ptr);
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> action =
|
boost::shared_ptr<MWWorld::Action> action =
|
||||||
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayerPos().getPlayer(),
|
MWWorld::Class::get (ptr).activate (ptr, mEnvironment.mWorld->getPlayer().getPlayer(),
|
||||||
mEnvironment);
|
mEnvironment);
|
||||||
|
|
||||||
interpreterContext.activate (ptr, action);
|
interpreterContext.activate (ptr, action);
|
||||||
|
@ -429,3 +496,13 @@ void OMW::Engine::activate()
|
||||||
interpreterContext.executeActivation();
|
interpreterContext.executeActivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << "Activation failed: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OMW::Engine::setCompileAll (bool all)
|
||||||
|
{
|
||||||
|
mCompileAll = all;
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <OgreFrameListener.h>
|
#include <OgreFrameListener.h>
|
||||||
|
|
||||||
#include <openengine/ogre/renderer.hpp>
|
#include <openengine/ogre/renderer.hpp>
|
||||||
|
#include <openengine/bullet/physic.hpp>
|
||||||
#include <components/compiler/extensions.hpp>
|
#include <components/compiler/extensions.hpp>
|
||||||
|
|
||||||
#include "mwworld/environment.hpp"
|
#include "mwworld/environment.hpp"
|
||||||
|
@ -57,9 +58,12 @@ namespace OMW
|
||||||
|
|
||||||
//int nFiles;
|
//int nFiles;
|
||||||
boost::filesystem::path mDataDir;
|
boost::filesystem::path mDataDir;
|
||||||
|
boost::filesystem::path mResDir;
|
||||||
OEngine::Render::OgreRenderer mOgre;
|
OEngine::Render::OgreRenderer mOgre;
|
||||||
|
OEngine::Physic::PhysicEngine* mPhysicEngine;
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
std::string mMaster;
|
std::string mMaster;
|
||||||
|
bool mShowFPS;
|
||||||
bool mDebug;
|
bool mDebug;
|
||||||
bool mVerboseScripts;
|
bool mVerboseScripts;
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
|
@ -107,6 +111,9 @@ namespace OMW
|
||||||
/// Set data dir
|
/// Set data dir
|
||||||
void setDataDir (const boost::filesystem::path& dataDir);
|
void setDataDir (const boost::filesystem::path& dataDir);
|
||||||
|
|
||||||
|
/// Set resource dir
|
||||||
|
void setResourceDir (const boost::filesystem::path& parResDir);
|
||||||
|
|
||||||
/// Set start cell name (only interiors for now)
|
/// Set start cell name (only interiors for now)
|
||||||
void setCell (const std::string& cellName);
|
void setCell (const std::string& cellName);
|
||||||
|
|
||||||
|
@ -115,6 +122,9 @@ namespace OMW
|
||||||
/// - Currently OpenMW only supports one master at the same time.
|
/// - Currently OpenMW only supports one master at the same time.
|
||||||
void addMaster (const std::string& master);
|
void addMaster (const std::string& master);
|
||||||
|
|
||||||
|
/// Enable fps counter
|
||||||
|
void showFPS() { mShowFPS = true; }
|
||||||
|
|
||||||
/// Enable debug mode:
|
/// Enable debug mode:
|
||||||
/// - non-exclusive input
|
/// - non-exclusive input
|
||||||
void enableDebugMode();
|
void enableDebugMode();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <components/misc/fileops.hpp>
|
#include <components/misc/fileops.hpp>
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
|
#include "path.hpp"
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_CONSOLE)
|
#if defined(_WIN32) && !defined(_CONSOLE)
|
||||||
#include <boost/iostreams/concepts.hpp>
|
#include <boost/iostreams/concepts.hpp>
|
||||||
|
@ -42,10 +43,13 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
("help", "print help message")
|
("help", "print help message")
|
||||||
("data", bpo::value<std::string>()->default_value ("data"),
|
("data", bpo::value<std::string>()->default_value ("data"),
|
||||||
"set data directory")
|
"set data directory")
|
||||||
|
("resources", bpo::value<std::string>()->default_value ("resources"),
|
||||||
|
"set resources directory")
|
||||||
("start", bpo::value<std::string>()->default_value ("Beshara"),
|
("start", bpo::value<std::string>()->default_value ("Beshara"),
|
||||||
"set initial cell")
|
"set initial cell")
|
||||||
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
||||||
"master file")
|
"master file")
|
||||||
|
( "showfps", "show fps counter")
|
||||||
( "debug", "debug mode" )
|
( "debug", "debug mode" )
|
||||||
( "nosound", "disable all sound" )
|
( "nosound", "disable all sound" )
|
||||||
( "script-verbose", "verbose script output" )
|
( "script-verbose", "verbose script output" )
|
||||||
|
@ -55,20 +59,23 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
|
|
||||||
bpo::variables_map variables;
|
bpo::variables_map variables;
|
||||||
|
|
||||||
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
std::string cfgFile = OMW::Path::getPath(OMW::Path::GLOBAL_CFG_PATH, "openmw", "openmw.cfg");
|
||||||
std::string configFilePath(macBundlePath() + "/Contents/MacOS/openmw.cfg");
|
std::cout << "Using global config file: " << cfgFile << std::endl;
|
||||||
std::ifstream configFile (configFilePath.c_str());
|
std::ifstream globalConfigFile(cfgFile.c_str());
|
||||||
#else
|
|
||||||
std::ifstream configFile ("openmw.cfg");
|
cfgFile = OMW::Path::getPath(OMW::Path::USER_CFG_PATH, "openmw", "openmw.cfg");
|
||||||
#endif
|
std::cout << "Using user config file: " << cfgFile << std::endl;
|
||||||
|
std::ifstream userConfigFile(cfgFile.c_str());
|
||||||
|
|
||||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
|
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
|
||||||
|
|
||||||
bpo::store(valid_opts, variables);
|
bpo::store(valid_opts, variables);
|
||||||
bpo::notify(variables);
|
bpo::notify(variables);
|
||||||
|
|
||||||
if (configFile.is_open())
|
if (userConfigFile.is_open())
|
||||||
bpo::store ( bpo::parse_config_file (configFile, desc), variables);
|
bpo::store ( bpo::parse_config_file (userConfigFile, desc), variables);
|
||||||
|
if (globalConfigFile.is_open())
|
||||||
|
bpo::store ( bpo::parse_config_file (globalConfigFile, desc), variables);
|
||||||
|
|
||||||
if (variables.count ("help"))
|
if (variables.count ("help"))
|
||||||
{
|
{
|
||||||
|
@ -77,9 +84,13 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
}
|
}
|
||||||
|
|
||||||
engine.setDataDir (variables["data"].as<std::string>());
|
engine.setDataDir (variables["data"].as<std::string>());
|
||||||
|
engine.setResourceDir (variables["resources"].as<std::string>());
|
||||||
engine.setCell (variables["start"].as<std::string>());
|
engine.setCell (variables["start"].as<std::string>());
|
||||||
engine.addMaster (variables["master"].as<std::string>());
|
engine.addMaster (variables["master"].as<std::string>());
|
||||||
|
|
||||||
|
if (variables.count ("showfps"))
|
||||||
|
engine.showFPS();
|
||||||
|
|
||||||
if (variables.count ("debug"))
|
if (variables.count ("debug"))
|
||||||
engine.enableDebugMode();
|
engine.enableDebugMode();
|
||||||
|
|
||||||
|
@ -100,6 +111,11 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
|
|
||||||
int main(int argc, char**argv)
|
int main(int argc, char**argv)
|
||||||
{
|
{
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
// set current dir to bundle path
|
||||||
|
boost::filesystem::path bundlePath = boost::filesystem::path(Ogre::macBundlePath());
|
||||||
|
boost::filesystem::current_path(bundlePath);
|
||||||
|
#endif
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertActorPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
|
||||||
#include "../mwrender/playerpos.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"
|
||||||
|
@ -31,6 +30,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace MWClass
|
||||||
if (ref->ref.teleport)
|
if (ref->ref.teleport)
|
||||||
{
|
{
|
||||||
// teleport door
|
// teleport door
|
||||||
if (environment.mWorld->getPlayerPos().getPlayer()==actor)
|
if (environment.mWorld->getPlayer().getPlayer()==actor)
|
||||||
{
|
{
|
||||||
// the player is using the door
|
// the player is using the door
|
||||||
return boost::shared_ptr<MWWorld::Action> (
|
return boost::shared_ptr<MWWorld::Action> (
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace MWClass
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
|
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
|
|
||||||
// Extract the color and convert to floating point
|
// Extract the color and convert to floating point
|
||||||
const int color = ref->base->data.color;
|
const int color = ref->base->data.color;
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const Ogre::Radian kOgrePi (Ogre::Math::PI);
|
||||||
|
const Ogre::Radian kOgrePiOverTwo (Ogre::Math::PI / Ogre::Real(2.0));
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
std::string Npc::getId (const MWWorld::Ptr& ptr) const
|
std::string Npc::getId (const MWWorld::Ptr& ptr) const
|
||||||
|
@ -40,7 +46,14 @@ namespace MWClass
|
||||||
|
|
||||||
std::string hairID = ref->base->hair;
|
std::string hairID = ref->base->hair;
|
||||||
std::string headID = ref->base->head;
|
std::string headID = ref->base->head;
|
||||||
std::string npcName = ref->base->name;
|
|
||||||
|
// very ugly workaround to stop OGRE from chocking on non-unique scene node handles
|
||||||
|
static int uniqueId = 0;
|
||||||
|
|
||||||
|
std::ostringstream stream;
|
||||||
|
stream << "npc$" << uniqueId++;
|
||||||
|
|
||||||
|
std::string npcName = stream.str(); // ref->base->name;
|
||||||
//std::cout << "NPC: " << npcName << "\n";
|
//std::cout << "NPC: " << npcName << "\n";
|
||||||
|
|
||||||
//get the part of the bodypart id which describes the race and the gender
|
//get the part of the bodypart id which describes the race and the gender
|
||||||
|
@ -53,6 +66,9 @@ namespace MWClass
|
||||||
|
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the
|
||||||
|
// right place
|
||||||
const ESM::BodyPart *bodyPart =
|
const ESM::BodyPart *bodyPart =
|
||||||
environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
|
environment.mWorld->getStore().bodyParts.search (bodyRaceID + "chest");
|
||||||
|
|
||||||
|
@ -66,7 +82,6 @@ namespace MWClass
|
||||||
std::string upperleft[5] = {"", "", "", "", ""};
|
std::string upperleft[5] = {"", "", "", "", ""};
|
||||||
std::string upperright[5] = {"", "", "", "", ""};
|
std::string upperright[5] = {"", "", "", "", ""};
|
||||||
std::string neckandup[5] = {"", "", "","",""};
|
std::string neckandup[5] = {"", "", "","",""};
|
||||||
std::string empty[6] = {"", "", "", "","", ""};
|
|
||||||
int numbers = 0;
|
int numbers = 0;
|
||||||
int uppernumbers = 0;
|
int uppernumbers = 0;
|
||||||
int neckNumbers = 0;
|
int neckNumbers = 0;
|
||||||
|
@ -101,21 +116,20 @@ namespace MWClass
|
||||||
//std::cout << "RACE" << bodyRaceID << "\n";
|
//std::cout << "RACE" << bodyRaceID << "\n";
|
||||||
|
|
||||||
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
|
Ogre::Vector3 pos2 = Ogre::Vector3( 0, .5, 75);
|
||||||
std::string upperarmpath[2] = {npcName + "chest", npcName + "upper arm"};
|
|
||||||
|
|
||||||
if (groin){
|
if (groin){
|
||||||
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, Ogre::Radian(3.14), npcName + "groin", addresses, numbers);
|
cellRender.insertMesh("meshes\\" + groin->model, pos2, axis, kOgrePi, npcName + "groin", addresses, numbers);
|
||||||
addresses2[numbers] = npcName + "groin";
|
addresses2[numbers] = npcName + "groin";
|
||||||
addresses[numbers++] = npcName + "groin";
|
addresses[numbers++] = npcName + "groin";
|
||||||
}
|
}
|
||||||
if (tail) {
|
if (tail) {
|
||||||
cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, Ogre::Radian(3.14), npcName + "tail", addresses, numbers, "tail");
|
cellRender.insertMesh("tail\\" + tail->model, Ogre::Vector3(0 , 0, -76), axis, kOgrePi, npcName + "tail", addresses, numbers, "tail");
|
||||||
//std::cout << "TAIL\n";
|
//std::cout << "TAIL\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//addresses[1] = npcName + "groin";
|
//addresses[1] = npcName + "groin";
|
||||||
if(upperleg){
|
if(upperleg){
|
||||||
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, Ogre::Radian(3.14), npcName + "upper leg", addresses, numbers); //-18
|
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( 6, 0, -16), axis, kOgrePi, npcName + "upper leg", addresses, numbers); //-18
|
||||||
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers);
|
cellRender.insertMesh ("meshes\\" + upperleg->model, Ogre::Vector3( -6, 0, -16), axis, Ogre::Radian(0), npcName + "upper leg2", addresses2, numbers);
|
||||||
addresses2[numbers] = npcName + "upper leg2";
|
addresses2[numbers] = npcName + "upper leg2";
|
||||||
addresses[numbers++] = npcName + "upper leg";
|
addresses[numbers++] = npcName + "upper leg";
|
||||||
|
@ -155,9 +169,9 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
if(feet){
|
if(feet){
|
||||||
|
|
||||||
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot", addresses, numbers); //9, 0, -14
|
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, kOgrePi, npcName + "foot", addresses, numbers); //9, 0, -14
|
||||||
|
|
||||||
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, Ogre::Radian(3.14), npcName + "foot2", addresses2, numbers);
|
cellRender.insertMesh ("foot\\" + feet->model, Ogre::Vector3( 7, 4, -16), axis, kOgrePi, npcName + "foot2", addresses2, numbers);
|
||||||
addresses2[numbers] = npcName + "foot2";
|
addresses2[numbers] = npcName + "foot2";
|
||||||
addresses[numbers++] = npcName + "foot";
|
addresses[numbers++] = npcName + "foot";
|
||||||
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
|
//cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), addresses, numbers);
|
||||||
|
@ -166,20 +180,20 @@ namespace MWClass
|
||||||
|
|
||||||
if (arm){
|
if (arm){
|
||||||
//010
|
//010
|
||||||
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), Ogre::Radian(-3.14 / 2), npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
|
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(-12.5, 0, 104), Ogre::Vector3(0, 1, 0), -kOgrePiOverTwo, npcName + "upper arm", upperleft, uppernumbers); //1, 0,.75
|
||||||
//cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75
|
//cellRender.rotateMesh(Ogre::Vector3(1, 0, 0), Ogre::Radian (.45), upperarmpath, 2); //-.5, 0, -.75
|
||||||
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), Ogre::Radian(3.14), npcName + "upper arm2", upperright, uppernumbers);
|
cellRender.insertMesh("meshes\\" + arm->model, Ogre::Vector3(12.5, 0, 105), Ogre::Vector3(-.5, 0, -.75), kOgrePi, npcName + "upper arm2", upperright, uppernumbers);
|
||||||
upperleft[uppernumbers] = npcName + "upper arm";
|
upperleft[uppernumbers] = npcName + "upper arm";
|
||||||
upperright[uppernumbers++] = npcName + "upper arm2";
|
upperright[uppernumbers++] = npcName + "upper arm2";
|
||||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1
|
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers); //1 -1 1
|
||||||
cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), Ogre::Radian(3.14/2), upperleft, uppernumbers);
|
cellRender.rotateMesh(Ogre::Vector3(0, .1, 0), kOgrePiOverTwo, upperleft, uppernumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forearm)
|
if (forearm)
|
||||||
{
|
{
|
||||||
//addresses[1] = npcName + "upper arm";
|
//addresses[1] = npcName + "upper arm";
|
||||||
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers);
|
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm", upperleft, uppernumbers);
|
||||||
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers);
|
cellRender.insertMesh("meshes\\" + forearm->model, Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm2", upperright, uppernumbers);
|
||||||
upperleft[uppernumbers] = npcName + "forearm";
|
upperleft[uppernumbers] = npcName + "forearm";
|
||||||
upperright[uppernumbers++] = npcName + "forearm2";
|
upperright[uppernumbers++] = npcName + "forearm2";
|
||||||
}
|
}
|
||||||
|
@ -189,14 +203,14 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0)
|
if(upperleft[uppernumbers - 1].compare(npcName + "upper arm") == 0)
|
||||||
{
|
{
|
||||||
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm", upperleft, uppernumbers);
|
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm", upperleft, uppernumbers);
|
||||||
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "forearm2", upperright, uppernumbers);
|
cellRender.insertMesh("meshes\\b\\B_N_Argonian_M_Forearm.nif", Ogre::Vector3(-12.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "forearm2", upperright, uppernumbers);
|
||||||
upperleft[uppernumbers] = npcName + "forearm";
|
upperleft[uppernumbers] = npcName + "forearm";
|
||||||
upperright[uppernumbers++] = npcName + "forearm2";
|
upperright[uppernumbers++] = npcName + "forearm2";
|
||||||
|
|
||||||
}
|
}
|
||||||
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist", upperleft, uppernumbers);
|
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "wrist", upperleft, uppernumbers);
|
||||||
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "wrist2", upperright, uppernumbers);
|
cellRender.insertMesh("meshes\\" + wrist->model, Ogre::Vector3(-9.5, 0, 0), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "wrist2", upperright, uppernumbers);
|
||||||
upperleft[uppernumbers] = npcName + "wrist";
|
upperleft[uppernumbers] = npcName + "wrist";
|
||||||
upperright[uppernumbers++] = npcName + "wrist2";
|
upperright[uppernumbers++] = npcName + "wrist2";
|
||||||
}
|
}
|
||||||
|
@ -212,11 +226,11 @@ namespace MWClass
|
||||||
pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF";
|
pass = "b\\B_N_Dark Elf_M_Hands.1st.NIF";
|
||||||
else
|
else
|
||||||
pass = hand->model;
|
pass = hand->model;
|
||||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120
|
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers,false); //0, 100, -100 0,0,120
|
||||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
|
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0,0), kOgrePi, npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
|
||||||
upperleft[uppernumbers] = npcName + "hand";
|
upperleft[uppernumbers] = npcName + "hand";
|
||||||
upperright[uppernumbers++] = npcName + "hand2";
|
upperright[uppernumbers++] = npcName + "hand2";
|
||||||
//cellRender.rotateMesh(Ogre::Vector3(0, 0,0), Ogre::Radian(3.14), upperleft, uppernumbers);
|
//cellRender.rotateMesh(Ogre::Vector3(0, 0,0), kOgrePi, upperleft, uppernumbers);
|
||||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
|
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
|
||||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
|
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
|
||||||
}
|
}
|
||||||
|
@ -229,26 +243,27 @@ namespace MWClass
|
||||||
pass = "b\\B_N_Nord_M_Hands.1st.nif";
|
pass = "b\\B_N_Nord_M_Hands.1st.nif";
|
||||||
else
|
else
|
||||||
pass =hands->model; //-50, 0, -120
|
pass =hands->model; //-50, 0, -120
|
||||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
|
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1,-110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
|
||||||
//cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), Ogre::Radian(3.14), npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
|
//cellRender.insertMesh("meshes\\" + hands->model, Ogre::Vector3(42, 0,110), Ogre::Vector3(1, 0, 0), kOgrePi, npcName + "hand", upperleft, uppernumbers, false); //0, 100, -100 42, 0, -110
|
||||||
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), Ogre::Radian(3.14), npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
|
cellRender.insertMesh("meshes\\" + pass, Ogre::Vector3(42, 1, -110), Ogre::Vector3(0, 0, 0), kOgrePi, npcName + "hand2", upperright, uppernumbers, false); //0, 100, -100 0,0,120
|
||||||
upperleft[uppernumbers] = npcName + "hand";
|
upperleft[uppernumbers] = npcName + "hand";
|
||||||
upperright[uppernumbers++] = npcName + "hand2";
|
upperright[uppernumbers++] = npcName + "hand2";
|
||||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
|
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperleft, uppernumbers);
|
||||||
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
|
cellRender.scaleMesh(Ogre::Vector3(1, -1, 1), upperright, uppernumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//neck will reset chest counter
|
||||||
if(neck)
|
if(neck)
|
||||||
{
|
{
|
||||||
cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, Ogre::Radian(3.14), npcName + "neck", neckandup, neckNumbers);
|
cellRender.insertMesh ("meshes\\" + neck->model, Ogre::Vector3( 0, 0, 120), axis, kOgrePi, npcName + "neck", neckandup, neckNumbers);
|
||||||
neckandup[neckNumbers++] = npcName + "neck";
|
neckandup[neckNumbers++] = npcName + "neck";
|
||||||
}
|
}
|
||||||
cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers);
|
cellRender.insertMesh (headModel, Ogre::Vector3( 0, 0, 5), axis, Ogre::Radian(0), npcName + "head", neckandup, neckNumbers);
|
||||||
neckandup[neckNumbers++] = npcName + "head";
|
neckandup[neckNumbers++] = npcName + "head";
|
||||||
cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers);
|
cellRender.insertMesh (hairModel, Ogre::Vector3( 0, -1, 0), axis, Ogre::Radian(0), npcName + "hair", neckandup, neckNumbers);
|
||||||
cellRender.insertMesh("meshes\\base_anim.nif");
|
|
||||||
|
cellRender.insertActorPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||||
|
@ -302,7 +317,6 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
if (!ptr.getRefData().getNpcStats().get())
|
if (!ptr.getRefData().getNpcStats().get())
|
||||||
{
|
{
|
||||||
// xxx
|
|
||||||
boost::shared_ptr<MWMechanics::NpcStats> stats (
|
boost::shared_ptr<MWMechanics::NpcStats> stats (
|
||||||
new MWMechanics::NpcStats);
|
new MWMechanics::NpcStats);
|
||||||
|
|
||||||
|
@ -354,6 +368,113 @@ namespace MWClass
|
||||||
return ref->base->script;
|
return ref->base->script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const
|
||||||
|
{
|
||||||
|
MWMechanics::NpcStats& stats = getNpcStats (ptr);
|
||||||
|
|
||||||
|
switch (stance)
|
||||||
|
{
|
||||||
|
case Run:
|
||||||
|
|
||||||
|
stats.mForceRun = force;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Sneak:
|
||||||
|
|
||||||
|
stats.mForceSneak = force;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Combat:
|
||||||
|
|
||||||
|
throw std::runtime_error ("combat stance not enforcable for NPCs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Npc::setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const
|
||||||
|
{
|
||||||
|
MWMechanics::NpcStats& stats = getNpcStats (ptr);
|
||||||
|
|
||||||
|
switch (stance)
|
||||||
|
{
|
||||||
|
case Run:
|
||||||
|
|
||||||
|
stats.mRun = set;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Sneak:
|
||||||
|
|
||||||
|
stats.mSneak = set;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Combat:
|
||||||
|
|
||||||
|
stats.mCombat = set;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Npc::getStance (const MWWorld::Ptr& ptr, Stance stance, bool ignoreForce) const
|
||||||
|
{
|
||||||
|
MWMechanics::NpcStats& stats = getNpcStats (ptr);
|
||||||
|
|
||||||
|
switch (stance)
|
||||||
|
{
|
||||||
|
case Run:
|
||||||
|
|
||||||
|
if (!ignoreForce && stats.mForceRun)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return stats.mRun;
|
||||||
|
|
||||||
|
case Sneak:
|
||||||
|
|
||||||
|
if (!ignoreForce && stats.mForceSneak)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return stats.mSneak;
|
||||||
|
|
||||||
|
case Combat:
|
||||||
|
|
||||||
|
return stats.mCombat;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Npc::getSpeed (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
return getStance (ptr, Run) ? 600 : 300; // TODO calculate these values from stats
|
||||||
|
}
|
||||||
|
|
||||||
|
MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
if (!ptr.getRefData().getMovement().get())
|
||||||
|
{
|
||||||
|
boost::shared_ptr<MWMechanics::Movement> movement (
|
||||||
|
new MWMechanics::Movement);
|
||||||
|
|
||||||
|
ptr.getRefData().getMovement() = movement;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *ptr.getRefData().getMovement();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
Ogre::Vector3 vector (0, 0, 0);
|
||||||
|
|
||||||
|
if (ptr.getRefData().getMovement().get())
|
||||||
|
{
|
||||||
|
vector.x = - ptr.getRefData().getMovement()->mLeftRight * 200;
|
||||||
|
vector.y = ptr.getRefData().getMovement()->mForwardBackward * 200;
|
||||||
|
|
||||||
|
if (getStance (ptr, Run, false))
|
||||||
|
vector *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vector;
|
||||||
|
}
|
||||||
|
|
||||||
void Npc::registerSelf()
|
void Npc::registerSelf()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Class> instance (new Npc);
|
boost::shared_ptr<Class> instance (new Npc);
|
||||||
|
|
|
@ -43,6 +43,26 @@ 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;
|
||||||
|
///< Force or unforce a stance.
|
||||||
|
|
||||||
|
virtual void setStance (const MWWorld::Ptr& ptr, Stance stance, bool set) const;
|
||||||
|
///< Set or unset a stance.
|
||||||
|
|
||||||
|
virtual bool getStance (const MWWorld::Ptr& ptr, Stance stance, bool ignoreForce = false)
|
||||||
|
const;
|
||||||
|
////< Check if a stance is active or not.
|
||||||
|
|
||||||
|
virtual float getSpeed (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Return movement speed.
|
||||||
|
|
||||||
|
virtual MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Return desired movement.
|
||||||
|
|
||||||
|
virtual Ogre::Vector3 getMovementVector (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Return desired movement vector (determined based on movement settings,
|
||||||
|
/// stance and stats).
|
||||||
|
|
||||||
static void registerSelf();
|
static void registerSelf();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
MWRender::Rendering rendering (cellRender, ref->ref);
|
MWRender::Rendering rendering (cellRender, ref->ref);
|
||||||
cellRender.insertMesh ("meshes\\" + model);
|
cellRender.insertMesh ("meshes\\" + model);
|
||||||
|
cellRender.insertObjectPhysics();
|
||||||
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
#include "../mwworld/refdata.hpp"
|
#include "../mwworld/refdata.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "../mwinput/inputmanager.hpp"
|
#include "../mwinput/inputmanager.hpp"
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ namespace MWDialogue
|
||||||
|
|
||||||
// check cell
|
// check cell
|
||||||
if (!info.cell.empty())
|
if (!info.cell.empty())
|
||||||
if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell)
|
if (mEnvironment.mWorld->getPlayer().getPlayer().getCell()->cell->name != info.cell)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO check DATAstruct
|
// TODO check DATAstruct
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "birth.hpp"
|
#include "birth.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
@ -11,8 +9,8 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
BirthDialog::BirthDialog(MWWorld::Environment& environment)
|
BirthDialog::BirthDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_birth_layout.xml", environment)
|
: WindowBase("openmw_chargen_birth_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
@ -94,7 +92,7 @@ void BirthDialog::setBirthId(const std::string &birthId)
|
||||||
|
|
||||||
void BirthDialog::onOkClicked(MyGUI::Widget* _sender)
|
void BirthDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BirthDialog::onBackClicked(MyGUI::Widget* _sender)
|
void BirthDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
@ -121,7 +119,7 @@ void BirthDialog::updateBirths()
|
||||||
{
|
{
|
||||||
birthList->removeAllItems();
|
birthList->removeAllItems();
|
||||||
|
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager.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();
|
||||||
|
@ -151,7 +149,7 @@ void BirthDialog::updateSpells()
|
||||||
const int lineHeight = 18;
|
const int lineHeight = 18;
|
||||||
MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18);
|
MyGUI::IntCoord coord(0, 0, spellArea->getWidth(), 18);
|
||||||
|
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId);
|
const ESM::BirthSign *birth = store.birthSigns.find(currentBirthId);
|
||||||
|
|
||||||
std::string texturePath = std::string("textures\\") + birth->texture;
|
std::string texturePath = std::string("textures\\") + birth->texture;
|
||||||
|
@ -191,7 +189,7 @@ void BirthDialog::updateSpells()
|
||||||
if (!categories[category].spells.empty())
|
if (!categories[category].spells.empty())
|
||||||
{
|
{
|
||||||
MyGUI::StaticTextPtr label = spellArea->createWidget<MyGUI::StaticText>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
|
MyGUI::StaticTextPtr label = spellArea->createWidget<MyGUI::StaticText>("SandBrightText", coord, MyGUI::Align::Default, std::string("Label"));
|
||||||
label->setCaption(environment.mWindowManager->getGameSettingString(categories[category].label, ""));
|
label->setCaption(mWindowManager.getGameSettingString(categories[category].label, ""));
|
||||||
spellItems.push_back(label);
|
spellItems.push_back(label);
|
||||||
coord.top += lineHeight;
|
coord.top += lineHeight;
|
||||||
|
|
||||||
|
@ -200,7 +198,7 @@ void BirthDialog::updateSpells()
|
||||||
{
|
{
|
||||||
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 = spellArea->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("Spell") + boost::lexical_cast<std::string>(i));
|
||||||
spellWidget->setEnvironment(&environment);
|
spellWidget->setWindowManager(&mWindowManager);
|
||||||
spellWidget->setSpellId(spellId);
|
spellWidget->setSpellId(spellId);
|
||||||
|
|
||||||
spellItems.push_back(spellWidget);
|
spellItems.push_back(spellWidget);
|
||||||
|
|
|
@ -3,11 +3,6 @@
|
||||||
|
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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.xml.
|
||||||
|
@ -17,10 +12,12 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
using namespace MyGUI;
|
using namespace MyGUI;
|
||||||
|
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
class BirthDialog : public WindowBase
|
class BirthDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BirthDialog(MWWorld::Environment& environment);
|
BirthDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
enum Gender
|
enum Gender
|
||||||
{
|
{
|
||||||
|
@ -42,11 +39,6 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
EventHandle_Void eventBack;
|
EventHandle_Void eventBack;
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSelectBirth(MyGUI::List* _sender, size_t _index);
|
void onSelectBirth(MyGUI::List* _sender, size_t _index);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
|
||||||
|
@ -10,18 +8,20 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
/* GenerateClassResultDialog */
|
/* GenerateClassResultDialog */
|
||||||
|
|
||||||
GenerateClassResultDialog::GenerateClassResultDialog(MWWorld::Environment& environment)
|
GenerateClassResultDialog::GenerateClassResultDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_generate_class_result_layout.xml", environment)
|
: WindowBase("openmw_chargen_generate_class_result_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("ReflectT", mWindowManager.getGameSettingString("sMessageQuestionAnswer1", ""));
|
||||||
setText("ReflectT", wm->getGameSettingString("sMessageQuestionAnswer1", ""));
|
|
||||||
|
|
||||||
getWidget(classImage, "ClassImage");
|
getWidget(classImage, "ClassImage");
|
||||||
getWidget(className, "ClassName");
|
getWidget(className, "ClassName");
|
||||||
|
@ -50,7 +50,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId)
|
||||||
{
|
{
|
||||||
currentClassId = classId;
|
currentClassId = classId;
|
||||||
classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds");
|
classImage->setImageTexture(std::string("textures\\levelup\\") + currentClassId + ".dds");
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
className->setCaption(store.classes.find(currentClassId)->name);
|
className->setCaption(store.classes.find(currentClassId)->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId)
|
||||||
|
|
||||||
void GenerateClassResultDialog::onOkClicked(MyGUI::Widget* _sender)
|
void GenerateClassResultDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender)
|
void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
@ -68,31 +68,30 @@ void GenerateClassResultDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
/* PickClassDialog */
|
/* PickClassDialog */
|
||||||
|
|
||||||
PickClassDialog::PickClassDialog(MWWorld::Environment& environment)
|
PickClassDialog::PickClassDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_class_layout.xml", environment)
|
: WindowBase("openmw_chargen_class_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
|
||||||
setText("SpecializationT", wm->getGameSettingString("sChooseClassMenu1", "Specialization"));
|
|
||||||
getWidget(specializationName, "SpecializationName");
|
getWidget(specializationName, "SpecializationName");
|
||||||
|
|
||||||
setText("FavoriteAttributesT", wm->getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
|
setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
|
||||||
getWidget(favoriteAttribute[0], "FavoriteAttribute0");
|
getWidget(favoriteAttribute[0], "FavoriteAttribute0");
|
||||||
getWidget(favoriteAttribute[1], "FavoriteAttribute1");
|
getWidget(favoriteAttribute[1], "FavoriteAttribute1");
|
||||||
favoriteAttribute[0]->setWindowManager(wm);
|
favoriteAttribute[0]->setWindowManager(&mWindowManager);
|
||||||
favoriteAttribute[1]->setWindowManager(wm);
|
favoriteAttribute[1]->setWindowManager(&mWindowManager);
|
||||||
|
|
||||||
setText("MajorSkillT", wm->getGameSettingString("sChooseClassMenu3", "Major Skills:"));
|
setText("MajorSkillT", mWindowManager.getGameSettingString("sChooseClassMenu3", "Major Skills:"));
|
||||||
setText("MinorSkillT", wm->getGameSettingString("sChooseClassMenu4", "Minor Skills:"));
|
setText("MinorSkillT", mWindowManager.getGameSettingString("sChooseClassMenu4", "Minor Skills:"));
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
char theIndex = '0'+i;
|
char theIndex = '0'+i;
|
||||||
getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex));
|
getWidget(majorSkill[i], std::string("MajorSkill").append(1, theIndex));
|
||||||
getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex));
|
getWidget(minorSkill[i], std::string("MinorSkill").append(1, theIndex));
|
||||||
majorSkill[i]->setWindowManager(wm);
|
majorSkill[i]->setWindowManager(&mWindowManager);
|
||||||
minorSkill[i]->setWindowManager(wm);
|
minorSkill[i]->setWindowManager(&mWindowManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
getWidget(classList, "ClassList");
|
getWidget(classList, "ClassList");
|
||||||
|
@ -170,7 +169,7 @@ void PickClassDialog::setClassId(const std::string &classId)
|
||||||
|
|
||||||
void PickClassDialog::onOkClicked(MyGUI::Widget* _sender)
|
void PickClassDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
void PickClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
@ -197,7 +196,7 @@ void PickClassDialog::updateClasses()
|
||||||
{
|
{
|
||||||
classList->removeAllItems();
|
classList->removeAllItems();
|
||||||
|
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
|
|
||||||
ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin();
|
ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin();
|
||||||
ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end();
|
ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end();
|
||||||
|
@ -221,8 +220,7 @@ void PickClassDialog::updateStats()
|
||||||
{
|
{
|
||||||
if (currentClassId.empty())
|
if (currentClassId.empty())
|
||||||
return;
|
return;
|
||||||
WindowManager *wm = environment.mWindowManager;
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
|
||||||
const ESM::Class *klass = store.classes.search(currentClassId);
|
const ESM::Class *klass = store.classes.search(currentClassId);
|
||||||
if (!klass)
|
if (!klass)
|
||||||
return;
|
return;
|
||||||
|
@ -234,7 +232,7 @@ void PickClassDialog::updateStats()
|
||||||
"sSpecializationMagic",
|
"sSpecializationMagic",
|
||||||
"sSpecializationStealth"
|
"sSpecializationStealth"
|
||||||
};
|
};
|
||||||
specializationName->setCaption(wm->getGameSettingString(specIds[specialization], specIds[specialization]));
|
specializationName->setCaption(mWindowManager.getGameSettingString(specIds[specialization], specIds[specialization]));
|
||||||
|
|
||||||
favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]);
|
favoriteAttribute[0]->setAttributeId(klass->data.attribute[0]);
|
||||||
favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]);
|
favoriteAttribute[1]->setAttributeId(klass->data.attribute[1]);
|
||||||
|
@ -280,8 +278,8 @@ void InfoBoxDialog::layoutVertically(MyGUI::WidgetPtr widget, int margin)
|
||||||
widget->setSize(width, pos);
|
widget->setSize(width, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoBoxDialog::InfoBoxDialog(MWWorld::Environment& environment)
|
InfoBoxDialog::InfoBoxDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_infobox_layout.xml", environment)
|
: WindowBase("openmw_infobox_layout.xml", parWindowManager)
|
||||||
, currentButton(-1)
|
, currentButton(-1)
|
||||||
{
|
{
|
||||||
getWidget(textBox, "TextBox");
|
getWidget(textBox, "TextBox");
|
||||||
|
@ -355,7 +353,7 @@ void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender)
|
||||||
if (*it == _sender)
|
if (*it == _sender)
|
||||||
{
|
{
|
||||||
currentButton = i;
|
currentButton = i;
|
||||||
eventButtonSelected(_sender, i);
|
eventButtonSelected(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
|
@ -364,23 +362,22 @@ void InfoBoxDialog::onButtonClicked(MyGUI::WidgetPtr _sender)
|
||||||
|
|
||||||
/* ClassChoiceDialog */
|
/* ClassChoiceDialog */
|
||||||
|
|
||||||
ClassChoiceDialog::ClassChoiceDialog(MWWorld::Environment& environment)
|
ClassChoiceDialog::ClassChoiceDialog(WindowManager& parWindowManager)
|
||||||
: InfoBoxDialog(environment)
|
: InfoBoxDialog(parWindowManager)
|
||||||
{
|
{
|
||||||
WindowManager *mw = environment.mWindowManager;
|
|
||||||
setText("");
|
setText("");
|
||||||
ButtonList buttons;
|
ButtonList buttons;
|
||||||
buttons.push_back(mw->getGameSettingString("sClassChoiceMenu1", ""));
|
buttons.push_back(mWindowManager.getGameSettingString("sClassChoiceMenu1", ""));
|
||||||
buttons.push_back(mw->getGameSettingString("sClassChoiceMenu2", ""));
|
buttons.push_back(mWindowManager.getGameSettingString("sClassChoiceMenu2", ""));
|
||||||
buttons.push_back(mw->getGameSettingString("sClassChoiceMenu3", ""));
|
buttons.push_back(mWindowManager.getGameSettingString("sClassChoiceMenu3", ""));
|
||||||
buttons.push_back(mw->getGameSettingString("sBack", ""));
|
buttons.push_back(mWindowManager.getGameSettingString("sBack", ""));
|
||||||
setButtons(buttons);
|
setButtons(buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CreateClassDialog */
|
/* CreateClassDialog */
|
||||||
|
|
||||||
CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment)
|
CreateClassDialog::CreateClassDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_create_class_layout.xml", environment)
|
: WindowBase("openmw_chargen_create_class_layout.xml", parWindowManager)
|
||||||
, specDialog(nullptr)
|
, specDialog(nullptr)
|
||||||
, attribDialog(nullptr)
|
, attribDialog(nullptr)
|
||||||
, skillDialog(nullptr)
|
, skillDialog(nullptr)
|
||||||
|
@ -389,22 +386,21 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment)
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("SpecializationT", mWindowManager.getGameSettingString("sChooseClassMenu1", "Specialization"));
|
||||||
setText("SpecializationT", wm->getGameSettingString("sChooseClassMenu1", "Specialization"));
|
|
||||||
getWidget(specializationName, "SpecializationName");
|
getWidget(specializationName, "SpecializationName");
|
||||||
specializationName->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
|
specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
|
||||||
specializationName->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked);
|
specializationName->eventMouseButtonClick = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationClicked);
|
||||||
|
|
||||||
setText("FavoriteAttributesT", wm->getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
|
setText("FavoriteAttributesT", mWindowManager.getGameSettingString("sChooseClassMenu2", "Favorite Attributes:"));
|
||||||
getWidget(favoriteAttribute0, "FavoriteAttribute0");
|
getWidget(favoriteAttribute0, "FavoriteAttribute0");
|
||||||
getWidget(favoriteAttribute1, "FavoriteAttribute1");
|
getWidget(favoriteAttribute1, "FavoriteAttribute1");
|
||||||
favoriteAttribute0->setWindowManager(wm);
|
favoriteAttribute0->setWindowManager(&mWindowManager);
|
||||||
favoriteAttribute1->setWindowManager(wm);
|
favoriteAttribute1->setWindowManager(&mWindowManager);
|
||||||
favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
favoriteAttribute0->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
||||||
favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
favoriteAttribute1->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeClicked);
|
||||||
|
|
||||||
setText("MajorSkillT", wm->getGameSettingString("sSkillClassMajor", ""));
|
setText("MajorSkillT", mWindowManager.getGameSettingString("sSkillClassMajor", ""));
|
||||||
setText("MinorSkillT", wm->getGameSettingString("sSkillClassMinor", ""));
|
setText("MinorSkillT", mWindowManager.getGameSettingString("sSkillClassMinor", ""));
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
char theIndex = '0'+i;
|
char theIndex = '0'+i;
|
||||||
|
@ -417,11 +413,11 @@ CreateClassDialog::CreateClassDialog(MWWorld::Environment& environment)
|
||||||
std::vector<Widgets::MWSkillPtr>::const_iterator end = skills.end();
|
std::vector<Widgets::MWSkillPtr>::const_iterator end = skills.end();
|
||||||
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it)
|
for (std::vector<Widgets::MWSkillPtr>::const_iterator it = skills.begin(); it != end; ++it)
|
||||||
{
|
{
|
||||||
(*it)->setWindowManager(wm);
|
(*it)->setWindowManager(&mWindowManager);
|
||||||
(*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
|
(*it)->eventClicked = MyGUI::newDelegate(this, &CreateClassDialog::onSkillClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
setText("LabelT", wm->getGameSettingString("sName", ""));
|
setText("LabelT", mWindowManager.getGameSettingString("sName", ""));
|
||||||
getWidget(editName, "EditName");
|
getWidget(editName, "EditName");
|
||||||
|
|
||||||
// Make sure the edit box has focus
|
// Make sure the edit box has focus
|
||||||
|
@ -563,7 +559,7 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
|
||||||
{
|
{
|
||||||
if (specDialog)
|
if (specDialog)
|
||||||
delete specDialog;
|
delete specDialog;
|
||||||
specDialog = new SelectSpecializationDialog(environment, environment.mWindowManager->getGui()->getViewSize());
|
specDialog = new SelectSpecializationDialog(mWindowManager);
|
||||||
specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
specDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||||
specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
|
specDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSpecializationSelected);
|
||||||
specDialog->setVisible(true);
|
specDialog->setVisible(true);
|
||||||
|
@ -572,7 +568,7 @@ void CreateClassDialog::onSpecializationClicked(MyGUI::WidgetPtr _sender)
|
||||||
void CreateClassDialog::onSpecializationSelected()
|
void CreateClassDialog::onSpecializationSelected()
|
||||||
{
|
{
|
||||||
specializationId = specDialog->getSpecializationId();
|
specializationId = specDialog->getSpecializationId();
|
||||||
specializationName->setCaption(environment.mWindowManager->getGameSettingString(ESM::Class::gmstSpecializationIds[specializationId], ""));
|
specializationName->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[specializationId], ""));
|
||||||
specDialog->setVisible(false);
|
specDialog->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +576,7 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender)
|
||||||
{
|
{
|
||||||
if (attribDialog)
|
if (attribDialog)
|
||||||
delete attribDialog;
|
delete attribDialog;
|
||||||
attribDialog = new SelectAttributeDialog(environment, environment.mWindowManager->getGui()->getViewSize());
|
attribDialog = new SelectAttributeDialog(mWindowManager);
|
||||||
attribDialog->setAffectedWidget(_sender);
|
attribDialog->setAffectedWidget(_sender);
|
||||||
attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
attribDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||||
attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
|
attribDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected);
|
||||||
|
@ -609,7 +605,7 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender)
|
||||||
{
|
{
|
||||||
if (skillDialog)
|
if (skillDialog)
|
||||||
delete skillDialog;
|
delete skillDialog;
|
||||||
skillDialog = new SelectSkillDialog(environment, environment.mWindowManager->getGui()->getViewSize());
|
skillDialog = new SelectSkillDialog(mWindowManager);
|
||||||
skillDialog->setAffectedWidget(_sender);
|
skillDialog->setAffectedWidget(_sender);
|
||||||
skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
skillDialog->eventCancel = MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel);
|
||||||
skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
|
skillDialog->eventItemSelected = MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected);
|
||||||
|
@ -640,21 +636,21 @@ void CreateClassDialog::onSkillSelected()
|
||||||
|
|
||||||
void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
|
void CreateClassDialog::onDescriptionClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
descDialog = new DescriptionDialog(environment, environment.mWindowManager->getGui()->getViewSize());
|
descDialog = new DescriptionDialog(mWindowManager);
|
||||||
descDialog->setTextInput(description);
|
descDialog->setTextInput(description);
|
||||||
descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
|
descDialog->eventDone = MyGUI::newDelegate(this, &CreateClassDialog::onDescriptionEntered);
|
||||||
descDialog->setVisible(true);
|
descDialog->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateClassDialog::onDescriptionEntered()
|
void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
description = descDialog->getTextInput();
|
description = descDialog->getTextInput();
|
||||||
environment.mWindowManager->removeDialog(descDialog);
|
mWindowManager.removeDialog(descDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender)
|
void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
@ -664,31 +660,29 @@ void CreateClassDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
/* SelectSpecializationDialog */
|
/* SelectSpecializationDialog */
|
||||||
|
|
||||||
SelectSpecializationDialog::SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize)
|
SelectSpecializationDialog::SelectSpecializationDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_select_specialization_layout.xml", environment)
|
: WindowBase("openmw_chargen_select_specialization_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("LabelT", mWindowManager.getGameSettingString("sSpecializationMenu1", ""));
|
||||||
|
|
||||||
setText("LabelT", wm->getGameSettingString("sSpecializationMenu1", ""));
|
|
||||||
|
|
||||||
getWidget(specialization0, "Specialization0");
|
getWidget(specialization0, "Specialization0");
|
||||||
getWidget(specialization1, "Specialization1");
|
getWidget(specialization1, "Specialization1");
|
||||||
getWidget(specialization2, "Specialization2");
|
getWidget(specialization2, "Specialization2");
|
||||||
specialization0->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
|
specialization0->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Combat], ""));
|
||||||
specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
specialization0->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
||||||
specialization1->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""));
|
specialization1->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Magic], ""));
|
||||||
specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
specialization1->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
||||||
specialization2->setCaption(wm->getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""));
|
specialization2->setCaption(mWindowManager.getGameSettingString(ESM::Class::gmstSpecializationIds[ESM::Class::Stealth], ""));
|
||||||
specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
specialization2->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onSpecializationClicked);
|
||||||
specializationId = ESM::Class::Combat;
|
specializationId = ESM::Class::Combat;
|
||||||
|
|
||||||
// TODO: These buttons should be managed by a Dialog class
|
// TODO: These buttons should be managed by a Dialog class
|
||||||
MyGUI::ButtonPtr cancelButton;
|
MyGUI::ButtonPtr cancelButton;
|
||||||
getWidget(cancelButton, "CancelButton");
|
getWidget(cancelButton, "CancelButton");
|
||||||
cancelButton->setCaption(wm->getGameSettingString("sCancel", ""));
|
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||||
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
|
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSpecializationDialog::onCancelClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,15 +709,13 @@ void SelectSpecializationDialog::onCancelClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
/* SelectAttributeDialog */
|
/* SelectAttributeDialog */
|
||||||
|
|
||||||
SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize)
|
SelectAttributeDialog::SelectAttributeDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_select_attribute_layout.xml", environment)
|
: WindowBase("openmw_chargen_select_attribute_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("LabelT", mWindowManager.getGameSettingString("sAttributesMenu1", ""));
|
||||||
|
|
||||||
setText("LabelT", wm->getGameSettingString("sAttributesMenu1", ""));
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
|
@ -731,7 +723,7 @@ SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment,
|
||||||
char theIndex = '0'+i;
|
char theIndex = '0'+i;
|
||||||
|
|
||||||
getWidget(attribute, std::string("Attribute").append(1, theIndex));
|
getWidget(attribute, std::string("Attribute").append(1, theIndex));
|
||||||
attribute->setWindowManager(wm);
|
attribute->setWindowManager(&parWindowManager);
|
||||||
attribute->setAttributeId(ESM::Attribute::attributeIds[i]);
|
attribute->setAttributeId(ESM::Attribute::attributeIds[i]);
|
||||||
attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
|
attribute->eventClicked = MyGUI::newDelegate(this, &SelectAttributeDialog::onAttributeClicked);
|
||||||
}
|
}
|
||||||
|
@ -739,7 +731,7 @@ SelectAttributeDialog::SelectAttributeDialog(MWWorld::Environment& environment,
|
||||||
// TODO: These buttons should be managed by a Dialog class
|
// TODO: These buttons should be managed by a Dialog class
|
||||||
MyGUI::ButtonPtr cancelButton;
|
MyGUI::ButtonPtr cancelButton;
|
||||||
getWidget(cancelButton, "CancelButton");
|
getWidget(cancelButton, "CancelButton");
|
||||||
cancelButton->setCaption(wm->getGameSettingString("sCancel", ""));
|
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||||
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
|
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectAttributeDialog::onCancelClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,18 +752,16 @@ void SelectAttributeDialog::onCancelClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
/* SelectSkillDialog */
|
/* SelectSkillDialog */
|
||||||
|
|
||||||
SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize)
|
SelectSkillDialog::SelectSkillDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_select_skill_layout.xml", environment)
|
: WindowBase("openmw_chargen_select_skill_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("LabelT", mWindowManager.getGameSettingString("sSkillsMenu1", ""));
|
||||||
|
setText("CombatLabelT", mWindowManager.getGameSettingString("sSpecializationCombat", ""));
|
||||||
setText("LabelT", wm->getGameSettingString("sSkillsMenu1", ""));
|
setText("MagicLabelT", mWindowManager.getGameSettingString("sSpecializationMagic", ""));
|
||||||
setText("CombatLabelT", wm->getGameSettingString("sSpecializationCombat", ""));
|
setText("StealthLabelT", mWindowManager.getGameSettingString("sSpecializationStealth", ""));
|
||||||
setText("MagicLabelT", wm->getGameSettingString("sSpecializationMagic", ""));
|
|
||||||
setText("StealthLabelT", wm->getGameSettingString("sSpecializationStealth", ""));
|
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++)
|
for(int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
|
@ -821,7 +811,7 @@ SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::I
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 9; ++i)
|
for (int i = 0; i < 9; ++i)
|
||||||
{
|
{
|
||||||
skills[spec][i].widget->setWindowManager(wm);
|
skills[spec][i].widget->setWindowManager(&mWindowManager);
|
||||||
skills[spec][i].widget->setSkillId(skills[spec][i].skillId);
|
skills[spec][i].widget->setSkillId(skills[spec][i].skillId);
|
||||||
skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked);
|
skills[spec][i].widget->eventClicked = MyGUI::newDelegate(this, &SelectSkillDialog::onSkillClicked);
|
||||||
}
|
}
|
||||||
|
@ -830,7 +820,7 @@ SelectSkillDialog::SelectSkillDialog(MWWorld::Environment& environment, MyGUI::I
|
||||||
// TODO: These buttons should be managed by a Dialog class
|
// TODO: These buttons should be managed by a Dialog class
|
||||||
MyGUI::ButtonPtr cancelButton;
|
MyGUI::ButtonPtr cancelButton;
|
||||||
getWidget(cancelButton, "CancelButton");
|
getWidget(cancelButton, "CancelButton");
|
||||||
cancelButton->setCaption(wm->getGameSettingString("sCancel", ""));
|
cancelButton->setCaption(mWindowManager.getGameSettingString("sCancel", ""));
|
||||||
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
|
cancelButton->eventMouseButtonClick = MyGUI::newDelegate(this, &SelectSkillDialog::onCancelClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,8 +839,8 @@ void SelectSkillDialog::onCancelClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
/* DescriptionDialog */
|
/* DescriptionDialog */
|
||||||
|
|
||||||
DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize)
|
DescriptionDialog::DescriptionDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_class_description_layout.xml", environment)
|
: WindowBase("openmw_chargen_class_description_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
@ -861,7 +851,7 @@ DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::I
|
||||||
MyGUI::ButtonPtr okButton;
|
MyGUI::ButtonPtr okButton;
|
||||||
getWidget(okButton, "OKButton");
|
getWidget(okButton, "OKButton");
|
||||||
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
|
okButton->eventMouseButtonClick = MyGUI::newDelegate(this, &DescriptionDialog::onOkClicked);
|
||||||
okButton->setCaption(environment.mWindowManager->getGameSettingString("sInputMenu1", ""));
|
okButton->setCaption(mWindowManager.getGameSettingString("sInputMenu1", ""));
|
||||||
|
|
||||||
// Make sure the edit box has focus
|
// Make sure the edit box has focus
|
||||||
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);
|
MyGUI::InputManager::getInstance().setKeyFocusWidget(textEdit);
|
||||||
|
@ -871,5 +861,5 @@ DescriptionDialog::DescriptionDialog(MWWorld::Environment& environment, MyGUI::I
|
||||||
|
|
||||||
void DescriptionDialog::onOkClicked(MyGUI::Widget* _sender)
|
void DescriptionDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,6 @@
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
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.xml.
|
||||||
|
@ -19,10 +14,12 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
using namespace MyGUI;
|
using namespace MyGUI;
|
||||||
|
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
class InfoBoxDialog : public WindowBase
|
class InfoBoxDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InfoBoxDialog(MWWorld::Environment& environment);
|
InfoBoxDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
typedef std::vector<std::string> ButtonList;
|
typedef std::vector<std::string> ButtonList;
|
||||||
|
|
||||||
|
@ -34,12 +31,12 @@ namespace MWGui
|
||||||
int getChosenButton() const;
|
int getChosenButton() const;
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CDelegate2<MyGUI::WidgetPtr, int> EventHandle_WidgetInt;
|
typedef delegates::CDelegate1<int> EventHandle_Int;
|
||||||
|
|
||||||
/** Event : Button was clicked.\n
|
/** Event : Button was clicked.\n
|
||||||
signature : void method(MyGUI::WidgetPtr widget, int index)\n
|
signature : void method(MyGUI::WidgetPtr widget, int index)\n
|
||||||
*/
|
*/
|
||||||
EventHandle_WidgetInt eventButtonSelected;
|
EventHandle_Int eventButtonSelected;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onButtonClicked(MyGUI::WidgetPtr _sender);
|
void onButtonClicked(MyGUI::WidgetPtr _sender);
|
||||||
|
@ -67,13 +64,13 @@ namespace MWGui
|
||||||
Class_Create = 2,
|
Class_Create = 2,
|
||||||
Class_Back = 3
|
Class_Back = 3
|
||||||
};
|
};
|
||||||
ClassChoiceDialog(MWWorld::Environment& environment);
|
ClassChoiceDialog(WindowManager& parWindowManager);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GenerateClassResultDialog : public WindowBase
|
class GenerateClassResultDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GenerateClassResultDialog(MWWorld::Environment& environment);
|
GenerateClassResultDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
std::string getClassId() const;
|
std::string getClassId() const;
|
||||||
void setClassId(const std::string &classId);
|
void setClassId(const std::string &classId);
|
||||||
|
@ -88,11 +85,6 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
EventHandle_Void eventBack;
|
EventHandle_Void eventBack;
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOkClicked(MyGUI::Widget* _sender);
|
void onOkClicked(MyGUI::Widget* _sender);
|
||||||
void onBackClicked(MyGUI::Widget* _sender);
|
void onBackClicked(MyGUI::Widget* _sender);
|
||||||
|
@ -107,7 +99,7 @@ namespace MWGui
|
||||||
class PickClassDialog : public WindowBase
|
class PickClassDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PickClassDialog(MWWorld::Environment& environment);
|
PickClassDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
const std::string &getClassId() const { return currentClassId; }
|
const std::string &getClassId() const { return currentClassId; }
|
||||||
void setClassId(const std::string &classId);
|
void setClassId(const std::string &classId);
|
||||||
|
@ -123,11 +115,6 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
EventHandle_Void eventBack;
|
EventHandle_Void eventBack;
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onSelectClass(MyGUI::List* _sender, size_t _index);
|
void onSelectClass(MyGUI::List* _sender, size_t _index);
|
||||||
|
|
||||||
|
@ -151,7 +138,7 @@ namespace MWGui
|
||||||
class SelectSpecializationDialog : public WindowBase
|
class SelectSpecializationDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectSpecializationDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize);
|
SelectSpecializationDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
ESM::Class::Specialization getSpecializationId() const { return specializationId; }
|
ESM::Class::Specialization getSpecializationId() const { return specializationId; }
|
||||||
|
|
||||||
|
@ -181,7 +168,7 @@ namespace MWGui
|
||||||
class SelectAttributeDialog : public WindowBase
|
class SelectAttributeDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectAttributeDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize);
|
SelectAttributeDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
ESM::Attribute::AttributeID getAttributeId() const { return attributeId; }
|
ESM::Attribute::AttributeID getAttributeId() const { return attributeId; }
|
||||||
Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; }
|
Widgets::MWAttributePtr getAffectedWidget() const { return affectedWidget; }
|
||||||
|
@ -213,7 +200,7 @@ namespace MWGui
|
||||||
class SelectSkillDialog : public WindowBase
|
class SelectSkillDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SelectSkillDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize);
|
SelectSkillDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
ESM::Skill::SkillEnum getSkillId() const { return skillId; }
|
ESM::Skill::SkillEnum getSkillId() const { return skillId; }
|
||||||
Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; }
|
Widgets::MWSkillPtr getAffectedWidget() const { return affectedWidget; }
|
||||||
|
@ -248,19 +235,11 @@ namespace MWGui
|
||||||
class DescriptionDialog : public WindowBase
|
class DescriptionDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DescriptionDialog(MWWorld::Environment& environment, MyGUI::IntSize gameWindowSize);
|
DescriptionDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
|
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
|
||||||
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }
|
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }
|
||||||
|
|
||||||
// Events
|
|
||||||
typedef delegates::CDelegate0 EventHandle_Void;
|
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOkClicked(MyGUI::Widget* _sender);
|
void onOkClicked(MyGUI::Widget* _sender);
|
||||||
|
|
||||||
|
@ -271,7 +250,7 @@ namespace MWGui
|
||||||
class CreateClassDialog : public WindowBase
|
class CreateClassDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CreateClassDialog(MWWorld::Environment& environment);
|
CreateClassDialog(WindowManager& parWindowManager);
|
||||||
virtual ~CreateClassDialog();
|
virtual ~CreateClassDialog();
|
||||||
|
|
||||||
std::string getName() const;
|
std::string getName() const;
|
||||||
|
@ -292,11 +271,6 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
EventHandle_Void eventBack;
|
EventHandle_Void eventBack;
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOkClicked(MyGUI::Widget* _sender);
|
void onOkClicked(MyGUI::Widget* _sender);
|
||||||
void onBackClicked(MyGUI::Widget* _sender);
|
void onBackClicked(MyGUI::Widget* _sender);
|
||||||
|
@ -308,7 +282,7 @@ namespace MWGui
|
||||||
void onSkillClicked(Widgets::MWSkillPtr _sender);
|
void onSkillClicked(Widgets::MWSkillPtr _sender);
|
||||||
void onSkillSelected();
|
void onSkillSelected();
|
||||||
void onDescriptionClicked(MyGUI::Widget* _sender);
|
void onDescriptionClicked(MyGUI::Widget* _sender);
|
||||||
void onDescriptionEntered();
|
void onDescriptionEntered(WindowBase* parWindow);
|
||||||
void onDialogCancel();
|
void onDialogCancel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <components/compiler/exception.hpp>
|
#include <components/compiler/exception.hpp>
|
||||||
|
|
||||||
#include "../mwscript/extensions.hpp"
|
#include "../mwscript/extensions.hpp"
|
||||||
|
@ -67,6 +69,31 @@ namespace MWGui
|
||||||
printError ((type==ErrorMessage ? "error: " : "warning: ") + message);
|
printError ((type==ErrorMessage ? "error: " : "warning: ") + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Console::listNames()
|
||||||
|
{
|
||||||
|
if (mNames.empty())
|
||||||
|
{
|
||||||
|
// keywords
|
||||||
|
std::istringstream input ("");
|
||||||
|
|
||||||
|
Compiler::Scanner scanner (*this, input, mCompilerContext.getExtensions());
|
||||||
|
|
||||||
|
scanner.listKeywords (mNames);
|
||||||
|
|
||||||
|
// identifier
|
||||||
|
const ESMS::ESMStore& store = mEnvironment.mWorld->getStore();
|
||||||
|
|
||||||
|
for (ESMS::RecListList::const_iterator iter (store.recLists.begin());
|
||||||
|
iter!=store.recLists.end(); ++iter)
|
||||||
|
{
|
||||||
|
iter->second->listIdentifier (mNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort
|
||||||
|
std::sort (mNames.begin(), mNames.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Console::Console(int w, int h, MWWorld::Environment& environment,
|
Console::Console(int w, int h, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions)
|
const Compiler::Extensions& extensions)
|
||||||
: Layout("openmw_console_layout.xml"),
|
: Layout("openmw_console_layout.xml"),
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace MWGui
|
||||||
|
|
||||||
MWScript::CompilerContext mCompilerContext;
|
MWScript::CompilerContext mCompilerContext;
|
||||||
MWWorld::Environment& mEnvironment;
|
MWWorld::Environment& mEnvironment;
|
||||||
|
std::vector<std::string> mNames;
|
||||||
|
|
||||||
bool compile (const std::string& cmd, Compiler::Output& output);
|
bool compile (const std::string& cmd, Compiler::Output& output);
|
||||||
|
|
||||||
|
@ -33,6 +34,12 @@ namespace MWGui
|
||||||
/// Report a file related error
|
/// Report a file related error
|
||||||
virtual void report (const std::string& message, Type type);
|
virtual void report (const std::string& message, Type type);
|
||||||
|
|
||||||
|
void listNames();
|
||||||
|
///< Write all valid identifiers and keywords into mNames and sort them.
|
||||||
|
/// \note If mNames is not empty, this function is a no-op.
|
||||||
|
/// \note The list may contain duplicates (if a name is a keyword and an identifier at the same
|
||||||
|
/// time).
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyGUI::EditPtr command;
|
MyGUI::EditPtr command;
|
||||||
MyGUI::EditPtr history;
|
MyGUI::EditPtr history;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "dialogue.hpp"
|
#include "dialogue.hpp"
|
||||||
#include "dialogue_history.hpp"
|
#include "dialogue_history.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
@ -16,8 +14,8 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
DialogueWindow::DialogueWindow(MWWorld::Environment& environment)
|
DialogueWindow::DialogueWindow(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_dialogue_window_layout.xml", environment)
|
: WindowBase("openmw_dialogue_window_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class Environment;
|
class WindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -23,7 +23,7 @@ namespace MWGui
|
||||||
class DialogueWindow: public WindowBase
|
class DialogueWindow: public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DialogueWindow(MWWorld::Environment& environment);
|
DialogueWindow(WindowManager& parWindowManager);
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "dialogue_history.hpp"
|
#include "dialogue_history.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
|
|
@ -1,412 +1,126 @@
|
||||||
#include "layouts.hpp"
|
#include "layouts.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
#include "../mwgui/window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
const int StatsWindow::lineHeight = 18;
|
|
||||||
|
|
||||||
StatsWindow::StatsWindow (MWWorld::Environment& environment)
|
HUD::HUD(int width, int height, bool fpsSwitch)
|
||||||
: WindowBase("openmw_stats_window_layout.xml", environment)
|
: Layout("openmw_hud_layout.xml")
|
||||||
, lastPos(0)
|
|
||||||
, reputation(0)
|
|
||||||
, bounty(0)
|
|
||||||
{
|
{
|
||||||
setCoord(0,0,498, 342);
|
setCoord(0,0, width, height);
|
||||||
|
|
||||||
const char *names[][2] =
|
// Energy bars
|
||||||
{
|
getWidget(health, "Health");
|
||||||
{ "Attrib1", "sAttributeStrength" },
|
getWidget(magicka, "Magicka");
|
||||||
{ "Attrib2", "sAttributeIntelligence" },
|
getWidget(stamina, "Stamina");
|
||||||
{ "Attrib3", "sAttributeWillpower" },
|
|
||||||
{ "Attrib4", "sAttributeAgility" },
|
|
||||||
{ "Attrib5", "sAttributeSpeed" },
|
|
||||||
{ "Attrib6", "sAttributeEndurance" },
|
|
||||||
{ "Attrib7", "sAttributePersonality" },
|
|
||||||
{ "Attrib8", "sAttributeLuck" },
|
|
||||||
{ "Health_str", "sHealth" },
|
|
||||||
{ "Magicka_str", "sMagic" },
|
|
||||||
{ "Fatigue_str", "sFatigue" },
|
|
||||||
{ "Level_str", "sLevel" },
|
|
||||||
{ "Race_str", "sRace" },
|
|
||||||
{ "Class_str", "sClass" },
|
|
||||||
{ 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
const ESMS::ESMStore &store = environment.mWorld->getStore();
|
// Item and spell images and status bars
|
||||||
for (int i=0; names[i][0]; ++i)
|
getWidget(weapImage, "WeapImage");
|
||||||
{
|
getWidget(weapStatus, "WeapStatus");
|
||||||
setText (names[i][0], store.gameSettings.find (names[i][1])->str);
|
getWidget(spellImage, "SpellImage");
|
||||||
|
getWidget(spellStatus, "SpellStatus");
|
||||||
|
|
||||||
|
getWidget(effectBox, "EffectBox");
|
||||||
|
getWidget(effect1, "Effect1");
|
||||||
|
|
||||||
|
getWidget(minimap, "MiniMap");
|
||||||
|
getWidget(compass, "Compass");
|
||||||
|
|
||||||
|
getWidget(crosshair, "Crosshair");
|
||||||
|
|
||||||
|
getWidget(fpsbox, "FPSBox");
|
||||||
|
getWidget(fpscounter, "FPSCounter");
|
||||||
|
|
||||||
|
fpsbox->setVisible(fpsSwitch);
|
||||||
|
|
||||||
|
compass->setImageTexture("textures\\compass.dds");
|
||||||
|
crosshair->setImageTexture("textures\\target.dds");
|
||||||
|
|
||||||
|
// These are just demo values, you should replace these with
|
||||||
|
// real calls from outside the class later.
|
||||||
|
setWeapIcon("icons\\w\\tx_knife_iron.dds");
|
||||||
|
setWeapStatus(90, 100);
|
||||||
|
setSpellIcon("icons\\s\\b_tx_s_rstor_health.dds");
|
||||||
|
setSpellStatus(65, 100);
|
||||||
|
setEffect("icons\\s\\tx_s_chameleon.dds");
|
||||||
}
|
}
|
||||||
|
|
||||||
getWidget(skillAreaWidget, "Skills");
|
void HUD::setFPS(float fps)
|
||||||
getWidget(skillClientWidget, "SkillClient");
|
|
||||||
getWidget(skillScrollerWidget, "SkillScroller");
|
|
||||||
|
|
||||||
skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
|
|
||||||
updateScroller();
|
|
||||||
|
|
||||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
|
||||||
{
|
{
|
||||||
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
|
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
||||||
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, (MyGUI::StaticTextPtr) nullptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
|
|
||||||
t->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos)
|
void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
||||||
{
|
{
|
||||||
int diff = lastPos - pos;
|
health->setProgressRange(hmax);
|
||||||
// Adjust position of all widget according to difference
|
health->setProgressPosition(h);
|
||||||
if (diff == 0)
|
magicka->setProgressRange(mmax);
|
||||||
return;
|
magicka->setProgressPosition(m);
|
||||||
lastPos = pos;
|
stamina->setProgressRange(smax);
|
||||||
|
stamina->setProgressPosition(s);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<MyGUI::WidgetPtr>::const_iterator end = skillWidgets.end();
|
void HUD::setWeapIcon(const char *str)
|
||||||
for (std::vector<MyGUI::WidgetPtr>::const_iterator it = skillWidgets.begin(); it != end; ++it)
|
|
||||||
{
|
{
|
||||||
(*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff));
|
weapImage->setImageTexture(str);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::onWindowResize(MyGUI::WidgetPtr window)
|
void HUD::setSpellIcon(const char *str)
|
||||||
{
|
{
|
||||||
updateScroller();
|
spellImage->setImageTexture(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
|
void HUD::setWeapStatus(int s, int smax)
|
||||||
{
|
{
|
||||||
MyGUI::ProgressPtr pt;
|
weapStatus->setProgressRange(smax);
|
||||||
getWidget(pt, name);
|
weapStatus->setProgressPosition(s);
|
||||||
pt->setProgressRange(max);
|
|
||||||
pt->setProgressPosition(val);
|
|
||||||
|
|
||||||
std::stringstream out;
|
|
||||||
out << val << "/" << max;
|
|
||||||
setText(tname, out.str().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::setPlayerName(const std::string& playerName)
|
void HUD::setSpellStatus(int s, int smax)
|
||||||
{
|
{
|
||||||
mMainWidget->setCaption(playerName);
|
spellStatus->setProgressRange(smax);
|
||||||
|
spellStatus->setProgressPosition(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value)
|
void HUD::setEffect(const char *img)
|
||||||
{
|
{
|
||||||
widget->setCaption(value);
|
effect1->setImageTexture(img);
|
||||||
if (style == CS_Super)
|
|
||||||
widget->setTextColour(MyGUI::Colour(0, 1, 0));
|
|
||||||
else if (style == CS_Sub)
|
|
||||||
widget->setTextColour(MyGUI::Colour(1, 0, 0));
|
|
||||||
else
|
|
||||||
widget->setTextColour(MyGUI::Colour(1, 1, 1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
|
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||||
{
|
{
|
||||||
static const char *ids[] =
|
static const char *ids[] =
|
||||||
{
|
{
|
||||||
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
"HBar", "MBar", "FBar", 0
|
||||||
"AttribVal6", "AttribVal7", "AttribVal8",
|
|
||||||
0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i=0; ids[i]; ++i)
|
for (int i=0; ids[i]; ++i)
|
||||||
if (ids[i]==id)
|
if (ids[i]==id)
|
||||||
{
|
{
|
||||||
std::ostringstream valueString;
|
switch (i)
|
||||||
valueString << value.getModified();
|
{
|
||||||
setText (id, valueString.str());
|
case 0:
|
||||||
|
health->setProgressRange (value.getModified());
|
||||||
if (value.getModified()>value.getBase())
|
health->setProgressPosition (value.getCurrent());
|
||||||
setTextColor (id, 0, 1, 0);
|
|
||||||
else if (value.getModified()<value.getBase())
|
|
||||||
setTextColor (id, 1, 0, 0);
|
|
||||||
else
|
|
||||||
setTextColor (id, 1, 1, 1);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
case 1:
|
||||||
}
|
magicka->setProgressRange (value.getModified());
|
||||||
|
magicka->setProgressPosition (value.getCurrent());
|
||||||
void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
break;
|
||||||
{
|
case 2:
|
||||||
static const char *ids[] =
|
stamina->setProgressRange (value.getModified());
|
||||||
{
|
stamina->setProgressPosition (value.getCurrent());
|
||||||
"HBar", "MBar", "FBar",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i=0; ids[i]; ++i)
|
|
||||||
if (ids[i]==id)
|
|
||||||
{
|
|
||||||
std::string id (ids[i]);
|
|
||||||
setBar (id, id + "T", value.getCurrent(), value.getModified());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::setValue (const std::string& id, const std::string& value)
|
|
||||||
{
|
|
||||||
if (id=="name")
|
|
||||||
setPlayerName (value);
|
|
||||||
else if (id=="race")
|
|
||||||
setText ("RaceText", value);
|
|
||||||
else if (id=="class")
|
|
||||||
setText ("ClassText", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::setValue (const std::string& id, int value)
|
|
||||||
{
|
|
||||||
if (id=="level")
|
|
||||||
{
|
|
||||||
std::ostringstream text;
|
|
||||||
text << value;
|
|
||||||
setText("LevelText", text.str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<float>& value)
|
|
||||||
{
|
|
||||||
static struct {const char *id; ESM::Skill::SkillEnum skillId; } skillMap[] =
|
|
||||||
{
|
|
||||||
{"SkillBlock", ESM::Skill::Block},
|
|
||||||
{"SkillArmorer", ESM::Skill::Armorer},
|
|
||||||
{"SkillMediumArmor", ESM::Skill::MediumArmor},
|
|
||||||
{"SkillHeavyArmor", ESM::Skill::HeavyArmor},
|
|
||||||
{"SkillBluntWeapon", ESM::Skill::BluntWeapon},
|
|
||||||
{"SkillLongBlade", ESM::Skill::LongBlade},
|
|
||||||
{"SkillAxe", ESM::Skill::Axe},
|
|
||||||
{"SkillSpear", ESM::Skill::Spear},
|
|
||||||
{"SkillAthletics", ESM::Skill::Athletics},
|
|
||||||
{"SkillEnchant", ESM::Skill::Armorer},
|
|
||||||
{"SkillDestruction", ESM::Skill::Destruction},
|
|
||||||
{"SkillAlteration", ESM::Skill::Alteration},
|
|
||||||
{"SkillIllusion", ESM::Skill::Illusion},
|
|
||||||
{"SkillConjuration", ESM::Skill::Conjuration},
|
|
||||||
{"SkillMysticism", ESM::Skill::Mysticism},
|
|
||||||
{"SkillRestoration", ESM::Skill::Restoration},
|
|
||||||
{"SkillAlchemy", ESM::Skill::Alchemy},
|
|
||||||
{"SkillUnarmored", ESM::Skill::Unarmored},
|
|
||||||
{"SkillSecurity", ESM::Skill::Security},
|
|
||||||
{"SkillSneak", ESM::Skill::Sneak},
|
|
||||||
{"SkillAcrobatics", ESM::Skill::Acrobatics},
|
|
||||||
{"SkillLightArmor", ESM::Skill::LightArmor},
|
|
||||||
{"SkillShortBlade", ESM::Skill::ShortBlade},
|
|
||||||
{"SkillMarksman", ESM::Skill::Marksman},
|
|
||||||
{"SkillMercantile", ESM::Skill::Mercantile},
|
|
||||||
{"SkillSpeechcraft", ESM::Skill::Speechcraft},
|
|
||||||
{"SkillHandToHand", ESM::Skill::HandToHand},
|
|
||||||
};
|
|
||||||
for (size_t i = 0; i < sizeof(skillMap)/sizeof(skillMap[0]); ++i)
|
|
||||||
{
|
|
||||||
if (skillMap[i].id == id)
|
|
||||||
{
|
|
||||||
int skillId = skillMap[i].skillId;
|
|
||||||
skillValues[skillId] = value;
|
|
||||||
MyGUI::StaticTextPtr widget = skillWidgetMap[skillId];
|
|
||||||
if (widget)
|
|
||||||
{
|
|
||||||
float modified = value.getModified(), base = value.getBase();
|
|
||||||
std::string text = boost::lexical_cast<std::string>(std::floor(modified));
|
|
||||||
ColorStyle style = CS_Normal;
|
|
||||||
if (modified > base)
|
|
||||||
style = CS_Super;
|
|
||||||
else if (modified < base)
|
|
||||||
style = CS_Sub;
|
|
||||||
|
|
||||||
setStyledText(widget, style, text);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor)
|
|
||||||
{
|
|
||||||
majorSkills = major;
|
|
||||||
minorSkills = minor;
|
|
||||||
|
|
||||||
// Update misc skills with the remaining skills not in major or minor
|
|
||||||
std::set<int> skillSet;
|
|
||||||
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
|
|
||||||
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
|
|
||||||
boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::skillIds.end();
|
|
||||||
miscSkills.clear();
|
|
||||||
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it)
|
|
||||||
{
|
|
||||||
int skill = *it;
|
|
||||||
if (skillSet.find(skill) == skillSet.end())
|
|
||||||
miscSkills.push_back(skill);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::setFactions (const std::vector<Faction>& factions)
|
|
||||||
{
|
|
||||||
this->factions = factions;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::setBirthSign (const std::string& signId)
|
|
||||||
{
|
|
||||||
birthSignId = signId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
||||||
{
|
|
||||||
MyGUI::StaticImagePtr separator = skillClientWidget->createWidget<MyGUI::StaticImage>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default);
|
|
||||||
skillWidgets.push_back(separator);
|
|
||||||
|
|
||||||
coord1.top += separator->getHeight();
|
|
||||||
coord2.top += separator->getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
||||||
{
|
|
||||||
MyGUI::StaticTextPtr groupWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
|
|
||||||
groupWidget->setCaption(label);
|
|
||||||
skillWidgets.push_back(groupWidget);
|
|
||||||
|
|
||||||
coord1.top += lineHeight;
|
|
||||||
coord2.top += lineHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
||||||
{
|
|
||||||
MyGUI::StaticTextPtr skillNameWidget, skillValueWidget;
|
|
||||||
|
|
||||||
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1, MyGUI::Align::Default);
|
|
||||||
skillNameWidget->setCaption(text);
|
|
||||||
|
|
||||||
skillValueWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default);
|
|
||||||
setStyledText(skillValueWidget, style, value);
|
|
||||||
|
|
||||||
skillWidgets.push_back(skillNameWidget);
|
|
||||||
skillWidgets.push_back(skillValueWidget);
|
|
||||||
|
|
||||||
coord1.top += lineHeight;
|
|
||||||
coord2.top += lineHeight;
|
|
||||||
|
|
||||||
return skillValueWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
||||||
{
|
|
||||||
MyGUI::StaticTextPtr skillNameWidget;
|
|
||||||
|
|
||||||
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
|
|
||||||
skillNameWidget->setCaption(text);
|
|
||||||
|
|
||||||
skillWidgets.push_back(skillNameWidget);
|
|
||||||
|
|
||||||
coord1.top += lineHeight;
|
|
||||||
coord2.top += lineHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
||||||
{
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
|
||||||
|
|
||||||
// Add a line separator if there are items above
|
|
||||||
if (!skillWidgets.empty())
|
|
||||||
{
|
|
||||||
addSeparator(coord1, coord2);
|
|
||||||
}
|
|
||||||
|
|
||||||
addGroup(wm->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
|
||||||
|
|
||||||
SkillList::const_iterator end = skills.end();
|
|
||||||
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
|
|
||||||
{
|
|
||||||
int skillId = *it;
|
|
||||||
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
|
|
||||||
continue;
|
|
||||||
assert(skillId >= 0 && skillId < ESM::Skill::Length);
|
|
||||||
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId];
|
|
||||||
const MWMechanics::Stat<float> &stat = skillValues.find(skillId)->second;
|
|
||||||
float base = stat.getBase();
|
|
||||||
float modified = stat.getModified();
|
|
||||||
|
|
||||||
ColorStyle style = CS_Normal;
|
|
||||||
if (modified > base)
|
|
||||||
style = CS_Super;
|
|
||||||
else if (modified < base)
|
|
||||||
style = CS_Sub;
|
|
||||||
MyGUI::StaticTextPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
|
|
||||||
skillWidgetMap[skillId] = widget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::updateSkillArea()
|
|
||||||
{
|
|
||||||
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it)
|
|
||||||
{
|
|
||||||
MyGUI::Gui::getInstance().destroyWidget(*it);
|
|
||||||
}
|
|
||||||
skillWidgets.clear();
|
|
||||||
|
|
||||||
const int valueSize = 40;
|
|
||||||
MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18);
|
|
||||||
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
|
|
||||||
|
|
||||||
if (!majorSkills.empty())
|
|
||||||
addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
|
|
||||||
|
|
||||||
if (!minorSkills.empty())
|
|
||||||
addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
|
|
||||||
|
|
||||||
if (!miscSkills.empty())
|
|
||||||
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
|
||||||
|
|
||||||
if (!factions.empty())
|
|
||||||
{
|
|
||||||
// Add a line separator if there are items above
|
|
||||||
if (!skillWidgets.empty())
|
|
||||||
addSeparator(coord1, coord2);
|
|
||||||
|
|
||||||
addGroup(wm->getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
|
||||||
FactionList::const_iterator end = factions.end();
|
|
||||||
for (FactionList::const_iterator it = factions.begin(); it != end; ++it)
|
|
||||||
{
|
|
||||||
const ESM::Faction *faction = store.factions.find(it->first);
|
|
||||||
addItem(faction->name, coord1, coord2);
|
|
||||||
// TODO: Faction rank should be placed in tooltip
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!birthSignId.empty())
|
|
||||||
{
|
|
||||||
// Add a line separator if there are items above
|
|
||||||
if (!skillWidgets.empty())
|
|
||||||
addSeparator(coord1, coord2);
|
|
||||||
|
|
||||||
addGroup(wm->getGameSettingString("sSign", "Sign"), coord1, coord2);
|
|
||||||
const ESM::BirthSign *sign = store.birthSigns.find(birthSignId);
|
|
||||||
addItem(sign->name, coord1, coord2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a line separator if there are items above
|
|
||||||
if (!skillWidgets.empty())
|
|
||||||
addSeparator(coord1, coord2);
|
|
||||||
|
|
||||||
addValueItem(wm->getGameSettingString("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2);
|
|
||||||
addValueItem(wm->getGameSettingString("sBounty", "Bounty"), boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2);
|
|
||||||
|
|
||||||
clientHeight = coord1.top;
|
|
||||||
updateScroller();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatsWindow::updateScroller()
|
|
||||||
{
|
|
||||||
skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0));
|
|
||||||
skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0));
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include <openengine/gui/layout.hpp>
|
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -13,12 +12,10 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains classes corresponding to all the window layouts
|
This file contains classes corresponding to window layouts
|
||||||
defined in resources/mygui/ *.xml.
|
defined in resources/mygui/ *.xml.
|
||||||
|
|
||||||
Each class inherites GUI::Layout and loads the XML file, and
|
Each class inherites GUI::Layout and loads the XML file, and
|
||||||
|
@ -35,117 +32,27 @@ namespace MWGui
|
||||||
class HUD : public OEngine::GUI::Layout
|
class HUD : public OEngine::GUI::Layout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HUD(int width, int height)
|
HUD(int width, int height, bool fpsSwitch);
|
||||||
: Layout("openmw_hud_layout.xml")
|
void setStats(int h, int hmax, int m, int mmax, int s, int smax);
|
||||||
{
|
void setWeapIcon(const char *str);
|
||||||
setCoord(0,0, width, height);
|
void setSpellIcon(const char *str);
|
||||||
|
void setWeapStatus(int s, int smax);
|
||||||
// Energy bars
|
void setSpellStatus(int s, int smax);
|
||||||
getWidget(health, "Health");
|
void setEffect(const char *img);
|
||||||
getWidget(magicka, "Magicka");
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||||
getWidget(stamina, "Stamina");
|
void setFPS(float fps);
|
||||||
|
|
||||||
// Item and spell images and status bars
|
|
||||||
getWidget(weapImage, "WeapImage");
|
|
||||||
getWidget(weapStatus, "WeapStatus");
|
|
||||||
getWidget(spellImage, "SpellImage");
|
|
||||||
getWidget(spellStatus, "SpellStatus");
|
|
||||||
|
|
||||||
getWidget(effectBox, "EffectBox");
|
|
||||||
getWidget(effect1, "Effect1");
|
|
||||||
|
|
||||||
getWidget(minimap, "MiniMap");
|
|
||||||
getWidget(compass, "Compass");
|
|
||||||
|
|
||||||
getWidget(crosshair, "Crosshair");
|
|
||||||
|
|
||||||
compass->setImageTexture("textures\\compass.dds");
|
|
||||||
crosshair->setImageTexture("textures\\target.dds");
|
|
||||||
|
|
||||||
// These are just demo values, you should replace these with
|
|
||||||
// real calls from outside the class later.
|
|
||||||
setWeapIcon("icons\\w\\tx_knife_iron.dds");
|
|
||||||
setWeapStatus(90, 100);
|
|
||||||
setSpellIcon("icons\\s\\b_tx_s_rstor_health.dds");
|
|
||||||
setSpellStatus(65, 100);
|
|
||||||
setEffect("icons\\s\\tx_s_chameleon.dds");
|
|
||||||
}
|
|
||||||
|
|
||||||
void setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
|
||||||
{
|
|
||||||
health->setProgressRange(hmax);
|
|
||||||
health->setProgressPosition(h);
|
|
||||||
magicka->setProgressRange(mmax);
|
|
||||||
magicka->setProgressPosition(m);
|
|
||||||
stamina->setProgressRange(smax);
|
|
||||||
stamina->setProgressPosition(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setWeapIcon(const char *str)
|
|
||||||
{ weapImage->setImageTexture(str); }
|
|
||||||
void setSpellIcon(const char *str)
|
|
||||||
{ spellImage->setImageTexture(str); }
|
|
||||||
|
|
||||||
void setWeapStatus(int s, int smax)
|
|
||||||
{
|
|
||||||
weapStatus->setProgressRange(smax);
|
|
||||||
weapStatus->setProgressPosition(s);
|
|
||||||
}
|
|
||||||
void setSpellStatus(int s, int smax)
|
|
||||||
{
|
|
||||||
spellStatus->setProgressRange(smax);
|
|
||||||
spellStatus->setProgressPosition(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEffect(const char *img)
|
|
||||||
{ effect1->setImageTexture(img); }
|
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
|
||||||
{
|
|
||||||
static const char *ids[] =
|
|
||||||
{
|
|
||||||
"HBar", "MBar", "FBar",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i=0; ids[i]; ++i)
|
|
||||||
if (ids[i]==id)
|
|
||||||
{
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
|
|
||||||
health->setProgressRange (value.getModified());
|
|
||||||
health->setProgressPosition (value.getCurrent());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
|
|
||||||
magicka->setProgressRange (value.getModified());
|
|
||||||
magicka->setProgressPosition (value.getCurrent());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
|
|
||||||
stamina->setProgressRange (value.getModified());
|
|
||||||
stamina->setProgressPosition (value.getCurrent());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MyGUI::ProgressPtr health, magicka, stamina;
|
MyGUI::ProgressPtr health, magicka, stamina;
|
||||||
|
|
||||||
MyGUI::StaticImagePtr weapImage, spellImage;
|
MyGUI::StaticImagePtr weapImage, spellImage;
|
||||||
MyGUI::ProgressPtr weapStatus, spellStatus;
|
MyGUI::ProgressPtr weapStatus, spellStatus;
|
||||||
|
|
||||||
MyGUI::WidgetPtr effectBox;
|
MyGUI::WidgetPtr effectBox;
|
||||||
MyGUI::StaticImagePtr effect1;
|
MyGUI::StaticImagePtr effect1;
|
||||||
|
|
||||||
MyGUI::StaticImagePtr minimap;
|
MyGUI::StaticImagePtr minimap;
|
||||||
MyGUI::StaticImagePtr compass;
|
MyGUI::StaticImagePtr compass;
|
||||||
|
|
||||||
MyGUI::StaticImagePtr crosshair;
|
MyGUI::StaticImagePtr crosshair;
|
||||||
|
|
||||||
|
MyGUI::WidgetPtr fpsbox;
|
||||||
|
MyGUI::StaticTextPtr fpscounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapWindow : public OEngine::GUI::Layout
|
class MapWindow : public OEngine::GUI::Layout
|
||||||
|
@ -178,68 +85,6 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class StatsWindow : public WindowBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef std::pair<std::string, int> Faction;
|
|
||||||
typedef std::vector<Faction> FactionList;
|
|
||||||
|
|
||||||
typedef std::vector<int> SkillList;
|
|
||||||
|
|
||||||
StatsWindow (MWWorld::Environment& environment);
|
|
||||||
|
|
||||||
void setBar(const std::string& name, const std::string& tname, int val, int max);
|
|
||||||
void setPlayerName(const std::string& playerName);
|
|
||||||
|
|
||||||
/// Set value for the given ID.
|
|
||||||
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 std::string& value);
|
|
||||||
void setValue (const std::string& id, int value);
|
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<float>& value);
|
|
||||||
|
|
||||||
void configureSkills (const SkillList& major, const SkillList& minor);
|
|
||||||
void setFactions (const std::vector<Faction>& factions);
|
|
||||||
void setBirthSign (const std::string &signId);
|
|
||||||
void setReputation (int reputation) { this->reputation = reputation; }
|
|
||||||
void setBounty (int bounty) { this->bounty = bounty; }
|
|
||||||
void updateSkillArea();
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum ColorStyle
|
|
||||||
{
|
|
||||||
CS_Sub,
|
|
||||||
CS_Normal,
|
|
||||||
CS_Super
|
|
||||||
};
|
|
||||||
void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value);
|
|
||||||
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
|
||||||
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
|
||||||
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
|
||||||
MyGUI::StaticTextPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
|
||||||
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
|
||||||
void updateScroller();
|
|
||||||
|
|
||||||
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos);
|
|
||||||
void onWindowResize(MyGUI::WidgetPtr window);
|
|
||||||
|
|
||||||
static const int lineHeight;
|
|
||||||
|
|
||||||
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
|
|
||||||
MyGUI::VScrollPtr skillScrollerWidget;
|
|
||||||
int lastPos, clientHeight;
|
|
||||||
|
|
||||||
SkillList majorSkills, minorSkills, miscSkills;
|
|
||||||
std::map<int, MWMechanics::Stat<float> > skillValues;
|
|
||||||
std::map<int, MyGUI::StaticTextPtr> skillWidgetMap;
|
|
||||||
std::map<std::string, MyGUI::WidgetPtr> factionWidgetMap;
|
|
||||||
FactionList factions; ///< Stores a list of factions and the current rank
|
|
||||||
std::string birthSignId;
|
|
||||||
int reputation, bounty;
|
|
||||||
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information
|
|
||||||
};
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
class InventoryWindow : public OEngine::GUI::Layout
|
class InventoryWindow : public OEngine::GUI::Layout
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "race.hpp"
|
#include "race.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
@ -15,8 +13,8 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
RaceDialog::RaceDialog(MWWorld::Environment& environment)
|
RaceDialog::RaceDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_race_layout.xml", environment)
|
: WindowBase("openmw_chargen_race_layout.xml", parWindowManager)
|
||||||
, genderIndex(0)
|
, genderIndex(0)
|
||||||
, faceIndex(0)
|
, faceIndex(0)
|
||||||
, hairIndex(0)
|
, hairIndex(0)
|
||||||
|
@ -29,8 +27,7 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment)
|
||||||
// These are just demo values, you should replace these with
|
// These are just demo values, you should replace these with
|
||||||
// real calls from outside the class later.
|
// real calls from outside the class later.
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
setText("AppearanceT", mWindowManager.getGameSettingString("sRaceMenu1", "Appearance"));
|
||||||
setText("AppearanceT", wm->getGameSettingString("sRaceMenu1", "Appearance"));
|
|
||||||
getWidget(appearanceBox, "AppearanceBox");
|
getWidget(appearanceBox, "AppearanceBox");
|
||||||
|
|
||||||
getWidget(headRotate, "HeadRotate");
|
getWidget(headRotate, "HeadRotate");
|
||||||
|
@ -42,34 +39,34 @@ RaceDialog::RaceDialog(MWWorld::Environment& environment)
|
||||||
// Set up next/previous buttons
|
// Set up next/previous buttons
|
||||||
MyGUI::ButtonPtr prevButton, nextButton;
|
MyGUI::ButtonPtr prevButton, nextButton;
|
||||||
|
|
||||||
setText("GenderChoiceT", wm->getGameSettingString("sRaceMenu2", "Change Sex"));
|
setText("GenderChoiceT", mWindowManager.getGameSettingString("sRaceMenu2", "Change Sex"));
|
||||||
getWidget(prevButton, "PrevGenderButton");
|
getWidget(prevButton, "PrevGenderButton");
|
||||||
getWidget(nextButton, "NextGenderButton");
|
getWidget(nextButton, "NextGenderButton");
|
||||||
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
|
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
|
||||||
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
|
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
|
||||||
|
|
||||||
setText("FaceChoiceT", wm->getGameSettingString("sRaceMenu3", "Change Face"));
|
setText("FaceChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Face"));
|
||||||
getWidget(prevButton, "PrevFaceButton");
|
getWidget(prevButton, "PrevFaceButton");
|
||||||
getWidget(nextButton, "NextFaceButton");
|
getWidget(nextButton, "NextFaceButton");
|
||||||
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
|
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
|
||||||
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
|
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
|
||||||
|
|
||||||
setText("HairChoiceT", wm->getGameSettingString("sRaceMenu3", "Change Hair"));
|
setText("HairChoiceT", mWindowManager.getGameSettingString("sRaceMenu3", "Change Hair"));
|
||||||
getWidget(prevButton, "PrevHairButton");
|
getWidget(prevButton, "PrevHairButton");
|
||||||
getWidget(nextButton, "NextHairButton");
|
getWidget(nextButton, "NextHairButton");
|
||||||
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
|
prevButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
|
||||||
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
|
nextButton->eventMouseButtonClick = MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
|
||||||
|
|
||||||
setText("RaceT", wm->getGameSettingString("sRaceMenu4", "Race"));
|
setText("RaceT", mWindowManager.getGameSettingString("sRaceMenu4", "Race"));
|
||||||
getWidget(raceList, "RaceList");
|
getWidget(raceList, "RaceList");
|
||||||
raceList->setScrollVisible(true);
|
raceList->setScrollVisible(true);
|
||||||
raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
raceList->eventListSelectAccept = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||||
raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
raceList->eventListMouseItemActivate = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||||
raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
raceList->eventListChangePosition = MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
||||||
|
|
||||||
setText("SkillsT", wm->getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
|
setText("SkillsT", mWindowManager.getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
|
||||||
getWidget(skillList, "SkillList");
|
getWidget(skillList, "SkillList");
|
||||||
setText("SpellPowerT", wm->getGameSettingString("sRaceMenu7", "Specials"));
|
setText("SpellPowerT", mWindowManager.getGameSettingString("sRaceMenu7", "Specials"));
|
||||||
getWidget(spellPowerList, "SpellPowerList");
|
getWidget(spellPowerList, "SpellPowerList");
|
||||||
|
|
||||||
// TODO: These buttons should be managed by a Dialog class
|
// TODO: These buttons should be managed by a Dialog class
|
||||||
|
@ -152,7 +149,7 @@ int wrap(int index, int max)
|
||||||
|
|
||||||
void RaceDialog::onOkClicked(MyGUI::Widget* _sender)
|
void RaceDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RaceDialog::onBackClicked(MyGUI::Widget* _sender)
|
void RaceDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
@ -215,7 +212,7 @@ void RaceDialog::updateRaces()
|
||||||
{
|
{
|
||||||
raceList->removeAllItems();
|
raceList->removeAllItems();
|
||||||
|
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
|
|
||||||
ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin();
|
ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin();
|
||||||
ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end();
|
ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end();
|
||||||
|
@ -249,8 +246,7 @@ void RaceDialog::updateSkills()
|
||||||
const int lineHeight = 18;
|
const int lineHeight = 18;
|
||||||
MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18);
|
MyGUI::IntCoord coord1(0, 0, skillList->getWidth(), 18);
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
|
||||||
const ESM::Race *race = store.races.find(currentRaceId);
|
const ESM::Race *race = store.races.find(currentRaceId);
|
||||||
int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
|
int count = sizeof(race->data.bonus)/sizeof(race->data.bonus[0]); // TODO: Find a portable macro for this ARRAYSIZE?
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
|
@ -261,7 +257,7 @@ void RaceDialog::updateSkills()
|
||||||
|
|
||||||
skillWidget = skillList->createWidget<MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default,
|
skillWidget = skillList->createWidget<MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default,
|
||||||
std::string("Skill") + boost::lexical_cast<std::string>(i));
|
std::string("Skill") + boost::lexical_cast<std::string>(i));
|
||||||
skillWidget->setWindowManager(wm);
|
skillWidget->setWindowManager(&mWindowManager);
|
||||||
skillWidget->setSkillNumber(skillId);
|
skillWidget->setSkillNumber(skillId);
|
||||||
skillWidget->setSkillValue(MWSkill::SkillValue(race->data.bonus[i].bonus));
|
skillWidget->setSkillValue(MWSkill::SkillValue(race->data.bonus[i].bonus));
|
||||||
|
|
||||||
|
@ -286,7 +282,7 @@ void RaceDialog::updateSpellPowers()
|
||||||
const int lineHeight = 18;
|
const int lineHeight = 18;
|
||||||
MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18);
|
MyGUI::IntCoord coord(0, 0, spellPowerList->getWidth(), 18);
|
||||||
|
|
||||||
ESMS::ESMStore &store = environment.mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
const ESM::Race *race = store.races.find(currentRaceId);
|
const ESM::Race *race = store.races.find(currentRaceId);
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator it = race->powers.list.begin();
|
std::vector<std::string>::const_iterator it = race->powers.list.begin();
|
||||||
|
@ -295,7 +291,7 @@ void RaceDialog::updateSpellPowers()
|
||||||
{
|
{
|
||||||
const std::string &spellpower = *it;
|
const std::string &spellpower = *it;
|
||||||
spellPowerWidget = spellPowerList->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast<std::string>(i));
|
spellPowerWidget = spellPowerList->createWidget<MWSpell>("MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + boost::lexical_cast<std::string>(i));
|
||||||
spellPowerWidget->setEnvironment(&environment);
|
spellPowerWidget->setWindowManager(&mWindowManager);
|
||||||
spellPowerWidget->setSpellId(spellpower);
|
spellPowerWidget->setSpellId(spellpower);
|
||||||
|
|
||||||
spellPowerItems.push_back(spellPowerWidget);
|
spellPowerItems.push_back(spellPowerWidget);
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class Environment;
|
class WindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -24,7 +24,7 @@ namespace MWGui
|
||||||
class RaceDialog : public WindowBase
|
class RaceDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RaceDialog(MWWorld::Environment& environment);
|
RaceDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
enum Gender
|
enum Gender
|
||||||
{
|
{
|
||||||
|
@ -53,11 +53,6 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
EventHandle_Void eventBack;
|
EventHandle_Void eventBack;
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onHeadRotate(MyGUI::VScroll* _sender, size_t _position);
|
void onHeadRotate(MyGUI::VScroll* _sender, size_t _position);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "review.hpp"
|
#include "review.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
@ -8,53 +6,56 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
|
||||||
const int ReviewDialog::lineHeight = 18;
|
const int ReviewDialog::lineHeight = 18;
|
||||||
|
|
||||||
ReviewDialog::ReviewDialog(MWWorld::Environment& environment)
|
ReviewDialog::ReviewDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_chargen_review_layout.xml", environment)
|
: WindowBase("openmw_chargen_review_layout.xml", parWindowManager)
|
||||||
, lastPos(0)
|
, lastPos(0)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
|
||||||
WindowManager *wm = environment.mWindowManager;
|
|
||||||
|
|
||||||
// Setup static stats
|
// Setup static stats
|
||||||
ButtonPtr button;
|
ButtonPtr button;
|
||||||
getWidget(nameWidget, "NameText");
|
getWidget(nameWidget, "NameText");
|
||||||
getWidget(button, "NameButton");
|
getWidget(button, "NameButton");
|
||||||
button->setCaption(wm->getGameSettingString("sName", ""));
|
button->setCaption(mWindowManager.getGameSettingString("sName", ""));
|
||||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
|
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onNameClicked);;
|
||||||
|
|
||||||
getWidget(raceWidget, "RaceText");
|
getWidget(raceWidget, "RaceText");
|
||||||
getWidget(button, "RaceButton");
|
getWidget(button, "RaceButton");
|
||||||
button->setCaption(wm->getGameSettingString("sRace", ""));
|
button->setCaption(mWindowManager.getGameSettingString("sRace", ""));
|
||||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
|
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onRaceClicked);;
|
||||||
|
|
||||||
getWidget(classWidget, "ClassText");
|
getWidget(classWidget, "ClassText");
|
||||||
getWidget(button, "ClassButton");
|
getWidget(button, "ClassButton");
|
||||||
button->setCaption(wm->getGameSettingString("sClass", ""));
|
button->setCaption(mWindowManager.getGameSettingString("sClass", ""));
|
||||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
|
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onClassClicked);;
|
||||||
|
|
||||||
getWidget(birthSignWidget, "SignText");
|
getWidget(birthSignWidget, "SignText");
|
||||||
getWidget(button, "SignButton");
|
getWidget(button, "SignButton");
|
||||||
button->setCaption(wm->getGameSettingString("sBirthSign", ""));
|
button->setCaption(mWindowManager.getGameSettingString("sBirthSign", ""));
|
||||||
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
|
button->eventMouseButtonClick = MyGUI::newDelegate(this, &ReviewDialog::onBirthSignClicked);;
|
||||||
|
|
||||||
// Setup dynamic stats
|
// Setup dynamic stats
|
||||||
getWidget(health, "Health");
|
getWidget(health, "Health");
|
||||||
health->setTitle(wm->getGameSettingString("sHealth", ""));
|
health->setTitle(mWindowManager.getGameSettingString("sHealth", ""));
|
||||||
health->setValue(45, 45);
|
health->setValue(45, 45);
|
||||||
|
|
||||||
getWidget(magicka, "Magicka");
|
getWidget(magicka, "Magicka");
|
||||||
magicka->setTitle(wm->getGameSettingString("sMagic", ""));
|
magicka->setTitle(mWindowManager.getGameSettingString("sMagic", ""));
|
||||||
magicka->setValue(50, 50);
|
magicka->setValue(50, 50);
|
||||||
|
|
||||||
getWidget(fatigue, "Fatigue");
|
getWidget(fatigue, "Fatigue");
|
||||||
fatigue->setTitle(wm->getGameSettingString("sFatigue", ""));
|
fatigue->setTitle(mWindowManager.getGameSettingString("sFatigue", ""));
|
||||||
fatigue->setValue(160, 160);
|
fatigue->setValue(160, 160);
|
||||||
|
|
||||||
// Setup attributes
|
// Setup attributes
|
||||||
|
@ -64,7 +65,7 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment)
|
||||||
{
|
{
|
||||||
getWidget(attribute, std::string("Attribute") + boost::lexical_cast<std::string>(idx));
|
getWidget(attribute, std::string("Attribute") + boost::lexical_cast<std::string>(idx));
|
||||||
attributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::attributeIds[idx]), attribute));
|
attributeWidgets.insert(std::make_pair(static_cast<int>(ESM::Attribute::attributeIds[idx]), attribute));
|
||||||
attribute->setWindowManager(wm);
|
attribute->setWindowManager(&mWindowManager);
|
||||||
attribute->setAttributeId(ESM::Attribute::attributeIds[idx]);
|
attribute->setAttributeId(ESM::Attribute::attributeIds[idx]);
|
||||||
attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0));
|
attribute->setAttributeValue(MWAttribute::AttributeValue(0, 0));
|
||||||
}
|
}
|
||||||
|
@ -79,8 +80,8 @@ ReviewDialog::ReviewDialog(MWWorld::Environment& environment)
|
||||||
|
|
||||||
for (int i = 0; i < ESM::Skill::Length; ++i)
|
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||||
{
|
{
|
||||||
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
|
skillValues.insert(std::make_pair(i, MWMechanics::Stat<float>()));
|
||||||
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, (MyGUI::StaticTextPtr)nullptr));
|
skillWidgetMap.insert(std::make_pair(i, static_cast<MyGUI::StaticText*> (0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);
|
static_cast<MyGUI::WindowPtr>(mMainWidget)->eventWindowChangeCoord = MyGUI::newDelegate(this, &ReviewDialog::onWindowResize);
|
||||||
|
@ -116,7 +117,7 @@ void ReviewDialog::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::onWindowResize(MyGUI::WidgetPtr window)
|
void ReviewDialog::onWindowResize(MyGUI::Window* window)
|
||||||
{
|
{
|
||||||
updateScroller();
|
updateScroller();
|
||||||
}
|
}
|
||||||
|
@ -129,7 +130,7 @@ void ReviewDialog::setPlayerName(const std::string &name)
|
||||||
void ReviewDialog::setRace(const std::string &raceId_)
|
void ReviewDialog::setRace(const std::string &raceId_)
|
||||||
{
|
{
|
||||||
raceId = raceId_;
|
raceId = raceId_;
|
||||||
const ESM::Race *race = environment.mWorld->getStore().races.search(raceId);
|
const ESM::Race *race = mWindowManager.getStore().races.search(raceId);
|
||||||
if (race)
|
if (race)
|
||||||
raceWidget->setCaption(race->name);
|
raceWidget->setCaption(race->name);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +144,7 @@ void ReviewDialog::setClass(const ESM::Class& class_)
|
||||||
void ReviewDialog::setBirthSign(const std::string& signId)
|
void ReviewDialog::setBirthSign(const std::string& signId)
|
||||||
{
|
{
|
||||||
birthSignId = signId;
|
birthSignId = signId;
|
||||||
const ESM::BirthSign *sign = environment.mWorld->getStore().birthSigns.search(birthSignId);
|
const ESM::BirthSign *sign = mWindowManager.getStore().birthSigns.search(birthSignId);
|
||||||
if (sign)
|
if (sign)
|
||||||
birthSignWidget->setCaption(sign->name);
|
birthSignWidget->setCaption(sign->name);
|
||||||
}
|
}
|
||||||
|
@ -273,15 +274,13 @@ void ReviewDialog::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGU
|
||||||
|
|
||||||
void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
{
|
{
|
||||||
WindowManager *wm = environment.mWindowManager;
|
|
||||||
|
|
||||||
// Add a line separator if there are items above
|
// Add a line separator if there are items above
|
||||||
if (!skillWidgets.empty())
|
if (!skillWidgets.empty())
|
||||||
{
|
{
|
||||||
addSeparator(coord1, coord2);
|
addSeparator(coord1, coord2);
|
||||||
}
|
}
|
||||||
|
|
||||||
addGroup(wm->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
addGroup(mWindowManager.getGameSettingString(titleId, titleDefault), coord1, coord2);
|
||||||
|
|
||||||
SkillList::const_iterator end = skills.end();
|
SkillList::const_iterator end = skills.end();
|
||||||
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
|
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
|
||||||
|
@ -300,7 +299,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId
|
||||||
style = CS_Super;
|
style = CS_Super;
|
||||||
else if (modified < base)
|
else if (modified < base)
|
||||||
style = CS_Sub;
|
style = CS_Sub;
|
||||||
MyGUI::StaticTextPtr widget = addValueItem(wm->getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
|
MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
|
||||||
skillWidgetMap[skillId] = widget;
|
skillWidgetMap[skillId] = widget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,7 +339,7 @@ void ReviewDialog::updateScroller()
|
||||||
|
|
||||||
void ReviewDialog::onOkClicked(MyGUI::Widget* _sender)
|
void ReviewDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::onBackClicked(MyGUI::Widget* _sender)
|
void ReviewDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
@ -350,20 +349,20 @@ void ReviewDialog::onBackClicked(MyGUI::Widget* _sender)
|
||||||
|
|
||||||
void ReviewDialog::onNameClicked(MyGUI::Widget* _sender)
|
void ReviewDialog::onNameClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventNameActivated();
|
eventActivateDialog(NAME_DIALOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::onRaceClicked(MyGUI::Widget* _sender)
|
void ReviewDialog::onRaceClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventRaceActivated();
|
eventActivateDialog(RACE_DIALOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::onClassClicked(MyGUI::Widget* _sender)
|
void ReviewDialog::onClassClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventClassActivated();
|
eventActivateDialog(CLASS_DIALOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReviewDialog::onBirthSignClicked(MyGUI::Widget* _sender)
|
void ReviewDialog::onBirthSignClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventBirthSignActivated();
|
eventActivateDialog(BIRTHSIGN_DIALOG);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class Environment;
|
class WindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -22,9 +22,15 @@ namespace MWGui
|
||||||
class ReviewDialog : public WindowBase
|
class ReviewDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum Dialogs {
|
||||||
|
NAME_DIALOG,
|
||||||
|
RACE_DIALOG,
|
||||||
|
CLASS_DIALOG,
|
||||||
|
BIRTHSIGN_DIALOG
|
||||||
|
};
|
||||||
typedef std::vector<int> SkillList;
|
typedef std::vector<int> SkillList;
|
||||||
|
|
||||||
ReviewDialog(MWWorld::Environment& environment);
|
ReviewDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
void setPlayerName(const std::string &name);
|
void setPlayerName(const std::string &name);
|
||||||
void setRace(const std::string &raceId);
|
void setRace(const std::string &raceId);
|
||||||
|
@ -44,36 +50,14 @@ namespace MWGui
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
typedef delegates::CDelegate0 EventHandle_Void;
|
typedef delegates::CDelegate0 EventHandle_Void;
|
||||||
|
typedef delegates::CDelegate1<int> EventHandle_Int;
|
||||||
|
|
||||||
/** Event : Back button clicked.\n
|
/** Event : Back button clicked.\n
|
||||||
signature : void method()\n
|
signature : void method()\n
|
||||||
*/
|
*/
|
||||||
EventHandle_Void eventBack;
|
EventHandle_Void eventBack;
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
EventHandle_Int eventActivateDialog;
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
/** Event : Activate name dialog.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventNameActivated;
|
|
||||||
|
|
||||||
/** Event : Activate race dialog.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventRaceActivated;
|
|
||||||
|
|
||||||
/** Event : Activate class dialog.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventClassActivated;
|
|
||||||
|
|
||||||
/** Event : Activate birth sign dialog.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventBirthSignActivated;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOkClicked(MyGUI::Widget* _sender);
|
void onOkClicked(MyGUI::Widget* _sender);
|
||||||
|
@ -101,7 +85,7 @@ namespace MWGui
|
||||||
void updateSkillArea();
|
void updateSkillArea();
|
||||||
|
|
||||||
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos);
|
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos);
|
||||||
void onWindowResize(MyGUI::WidgetPtr window);
|
void onWindowResize(MyGUI::Window* window);
|
||||||
|
|
||||||
static const int lineHeight;
|
static const int lineHeight;
|
||||||
|
|
||||||
|
|
370
apps/openmw/mwgui/stats_window.cpp
Normal file
370
apps/openmw/mwgui/stats_window.cpp
Normal file
|
@ -0,0 +1,370 @@
|
||||||
|
#include "stats_window.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
#include "window_manager.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
using namespace MWGui;
|
||||||
|
const int StatsWindow::lineHeight = 18;
|
||||||
|
|
||||||
|
StatsWindow::StatsWindow (WindowManager& parWindowManager)
|
||||||
|
: WindowBase("openmw_stats_window_layout.xml", parWindowManager)
|
||||||
|
, lastPos(0)
|
||||||
|
, reputation(0)
|
||||||
|
, bounty(0)
|
||||||
|
{
|
||||||
|
setCoord(0,0,498, 342);
|
||||||
|
|
||||||
|
const char *names[][2] =
|
||||||
|
{
|
||||||
|
{ "Attrib1", "sAttributeStrength" },
|
||||||
|
{ "Attrib2", "sAttributeIntelligence" },
|
||||||
|
{ "Attrib3", "sAttributeWillpower" },
|
||||||
|
{ "Attrib4", "sAttributeAgility" },
|
||||||
|
{ "Attrib5", "sAttributeSpeed" },
|
||||||
|
{ "Attrib6", "sAttributeEndurance" },
|
||||||
|
{ "Attrib7", "sAttributePersonality" },
|
||||||
|
{ "Attrib8", "sAttributeLuck" },
|
||||||
|
{ "Health_str", "sHealth" },
|
||||||
|
{ "Magicka_str", "sMagic" },
|
||||||
|
{ "Fatigue_str", "sFatigue" },
|
||||||
|
{ "Level_str", "sLevel" },
|
||||||
|
{ "Race_str", "sRace" },
|
||||||
|
{ "Class_str", "sClass" },
|
||||||
|
{ 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
|
for (int i=0; names[i][0]; ++i)
|
||||||
|
{
|
||||||
|
setText (names[i][0], store.gameSettings.find (names[i][1])->str);
|
||||||
|
}
|
||||||
|
|
||||||
|
getWidget(skillAreaWidget, "Skills");
|
||||||
|
getWidget(skillClientWidget, "SkillClient");
|
||||||
|
getWidget(skillScrollerWidget, "SkillScroller");
|
||||||
|
|
||||||
|
skillScrollerWidget->eventScrollChangePosition = MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
|
||||||
|
updateScroller();
|
||||||
|
|
||||||
|
for (int i = 0; i < ESM::Skill::Length; ++i)
|
||||||
|
{
|
||||||
|
skillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
|
||||||
|
skillWidgetMap.insert(std::pair<int, MyGUI::StaticTextPtr>(i, nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
|
||||||
|
t->eventWindowChangeCoord = MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos)
|
||||||
|
{
|
||||||
|
int diff = lastPos - pos;
|
||||||
|
// Adjust position of all widget according to difference
|
||||||
|
if (diff == 0)
|
||||||
|
return;
|
||||||
|
lastPos = pos;
|
||||||
|
|
||||||
|
std::vector<MyGUI::WidgetPtr>::const_iterator end = skillWidgets.end();
|
||||||
|
for (std::vector<MyGUI::WidgetPtr>::const_iterator it = skillWidgets.begin(); it != end; ++it)
|
||||||
|
{
|
||||||
|
(*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::onWindowResize(MyGUI::Window* window)
|
||||||
|
{
|
||||||
|
updateScroller();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
|
||||||
|
{
|
||||||
|
MyGUI::ProgressPtr pt;
|
||||||
|
getWidget(pt, name);
|
||||||
|
pt->setProgressRange(max);
|
||||||
|
pt->setProgressPosition(val);
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
|
out << val << "/" << max;
|
||||||
|
setText(tname, out.str().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setPlayerName(const std::string& playerName)
|
||||||
|
{
|
||||||
|
mMainWidget->setCaption(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value)
|
||||||
|
{
|
||||||
|
widget->setCaption(value);
|
||||||
|
if (style == CS_Super)
|
||||||
|
widget->setTextColour(MyGUI::Colour(0, 1, 0));
|
||||||
|
else if (style == CS_Sub)
|
||||||
|
widget->setTextColour(MyGUI::Colour(1, 0, 0));
|
||||||
|
else
|
||||||
|
widget->setTextColour(MyGUI::Colour(1, 1, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
|
||||||
|
{
|
||||||
|
static const char *ids[] =
|
||||||
|
{
|
||||||
|
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
||||||
|
"AttribVal6", "AttribVal7", "AttribVal8",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i=0; ids[i]; ++i)
|
||||||
|
if (ids[i]==id)
|
||||||
|
{
|
||||||
|
std::ostringstream valueString;
|
||||||
|
valueString << value.getModified();
|
||||||
|
setText (id, valueString.str());
|
||||||
|
|
||||||
|
if (value.getModified()>value.getBase())
|
||||||
|
setTextColor (id, 0, 1, 0);
|
||||||
|
else if (value.getModified()<value.getBase())
|
||||||
|
setTextColor (id, 1, 0, 0);
|
||||||
|
else
|
||||||
|
setTextColor (id, 1, 1, 1);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||||
|
{
|
||||||
|
static const char *ids[] =
|
||||||
|
{
|
||||||
|
"HBar", "MBar", "FBar",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i=0; ids[i]; ++i)
|
||||||
|
if (ids[i]==id)
|
||||||
|
{
|
||||||
|
std::string id (ids[i]);
|
||||||
|
setBar (id, id + "T", value.getCurrent(), value.getModified());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setValue (const std::string& id, const std::string& value)
|
||||||
|
{
|
||||||
|
if (id=="name")
|
||||||
|
setPlayerName (value);
|
||||||
|
else if (id=="race")
|
||||||
|
setText ("RaceText", value);
|
||||||
|
else if (id=="class")
|
||||||
|
setText ("ClassText", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setValue (const std::string& id, int value)
|
||||||
|
{
|
||||||
|
if (id=="level")
|
||||||
|
{
|
||||||
|
std::ostringstream text;
|
||||||
|
text << value;
|
||||||
|
setText("LevelText", text.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
||||||
|
{
|
||||||
|
skillValues[parSkill] = value;
|
||||||
|
MyGUI::StaticTextPtr widget = skillWidgetMap[(int)parSkill];
|
||||||
|
if (widget)
|
||||||
|
{
|
||||||
|
float modified = value.getModified(), base = value.getBase();
|
||||||
|
std::string text = boost::lexical_cast<std::string>(std::floor(modified));
|
||||||
|
ColorStyle style = CS_Normal;
|
||||||
|
if (modified > base)
|
||||||
|
style = CS_Super;
|
||||||
|
else if (modified < base)
|
||||||
|
style = CS_Sub;
|
||||||
|
|
||||||
|
setStyledText(widget, style, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor)
|
||||||
|
{
|
||||||
|
majorSkills = major;
|
||||||
|
minorSkills = minor;
|
||||||
|
|
||||||
|
// Update misc skills with the remaining skills not in major or minor
|
||||||
|
std::set<int> skillSet;
|
||||||
|
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
|
||||||
|
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
|
||||||
|
boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::skillIds.end();
|
||||||
|
miscSkills.clear();
|
||||||
|
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it)
|
||||||
|
{
|
||||||
|
int skill = *it;
|
||||||
|
if (skillSet.find(skill) == skillSet.end())
|
||||||
|
miscSkills.push_back(skill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setFactions (const std::vector<Faction>& factions)
|
||||||
|
{
|
||||||
|
this->factions = factions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::setBirthSign (const std::string& signId)
|
||||||
|
{
|
||||||
|
birthSignId = signId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
|
{
|
||||||
|
MyGUI::StaticImagePtr separator = skillClientWidget->createWidget<MyGUI::StaticImage>("MW_HLine", MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18), MyGUI::Align::Default);
|
||||||
|
skillWidgets.push_back(separator);
|
||||||
|
|
||||||
|
coord1.top += separator->getHeight();
|
||||||
|
coord2.top += separator->getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
|
{
|
||||||
|
MyGUI::StaticTextPtr groupWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandBrightText", MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
|
||||||
|
groupWidget->setCaption(label);
|
||||||
|
skillWidgets.push_back(groupWidget);
|
||||||
|
|
||||||
|
coord1.top += lineHeight;
|
||||||
|
coord2.top += lineHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyGUI::StaticTextPtr StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
|
{
|
||||||
|
MyGUI::StaticTextPtr skillNameWidget, skillValueWidget;
|
||||||
|
|
||||||
|
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1, MyGUI::Align::Default);
|
||||||
|
skillNameWidget->setCaption(text);
|
||||||
|
|
||||||
|
skillValueWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default);
|
||||||
|
setStyledText(skillValueWidget, style, value);
|
||||||
|
|
||||||
|
skillWidgets.push_back(skillNameWidget);
|
||||||
|
skillWidgets.push_back(skillValueWidget);
|
||||||
|
|
||||||
|
coord1.top += lineHeight;
|
||||||
|
coord2.top += lineHeight;
|
||||||
|
|
||||||
|
return skillValueWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
|
{
|
||||||
|
MyGUI::StaticTextPtr skillNameWidget;
|
||||||
|
|
||||||
|
skillNameWidget = skillClientWidget->createWidget<MyGUI::StaticText>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
|
||||||
|
skillNameWidget->setCaption(text);
|
||||||
|
|
||||||
|
skillWidgets.push_back(skillNameWidget);
|
||||||
|
|
||||||
|
coord1.top += lineHeight;
|
||||||
|
coord2.top += lineHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
|
{
|
||||||
|
// Add a line separator if there are items above
|
||||||
|
if (!skillWidgets.empty())
|
||||||
|
{
|
||||||
|
addSeparator(coord1, coord2);
|
||||||
|
}
|
||||||
|
|
||||||
|
addGroup(mWindowManager.getGameSettingString(titleId, titleDefault), coord1, coord2);
|
||||||
|
|
||||||
|
SkillList::const_iterator end = skills.end();
|
||||||
|
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
|
||||||
|
{
|
||||||
|
int skillId = *it;
|
||||||
|
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
|
||||||
|
continue;
|
||||||
|
assert(skillId >= 0 && skillId < ESM::Skill::Length);
|
||||||
|
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId];
|
||||||
|
const MWMechanics::Stat<float> &stat = skillValues.find(skillId)->second;
|
||||||
|
float base = stat.getBase();
|
||||||
|
float modified = stat.getModified();
|
||||||
|
|
||||||
|
ColorStyle style = CS_Normal;
|
||||||
|
if (modified > base)
|
||||||
|
style = CS_Super;
|
||||||
|
else if (modified < base)
|
||||||
|
style = CS_Sub;
|
||||||
|
MyGUI::StaticTextPtr widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
|
||||||
|
skillWidgetMap[skillId] = widget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::updateSkillArea()
|
||||||
|
{
|
||||||
|
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it)
|
||||||
|
{
|
||||||
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||||
|
}
|
||||||
|
skillWidgets.clear();
|
||||||
|
|
||||||
|
const int valueSize = 40;
|
||||||
|
MyGUI::IntCoord coord1(10, 0, skillClientWidget->getWidth() - (10 + valueSize), 18);
|
||||||
|
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
|
||||||
|
|
||||||
|
if (!majorSkills.empty())
|
||||||
|
addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
|
||||||
|
|
||||||
|
if (!minorSkills.empty())
|
||||||
|
addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
|
||||||
|
|
||||||
|
if (!miscSkills.empty())
|
||||||
|
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
||||||
|
|
||||||
|
ESMS::ESMStore &store = mWindowManager.getStore();
|
||||||
|
|
||||||
|
if (!factions.empty())
|
||||||
|
{
|
||||||
|
// Add a line separator if there are items above
|
||||||
|
if (!skillWidgets.empty())
|
||||||
|
addSeparator(coord1, coord2);
|
||||||
|
|
||||||
|
addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
||||||
|
FactionList::const_iterator end = factions.end();
|
||||||
|
for (FactionList::const_iterator it = factions.begin(); it != end; ++it)
|
||||||
|
{
|
||||||
|
const ESM::Faction *faction = store.factions.find(it->first);
|
||||||
|
addItem(faction->name, coord1, coord2);
|
||||||
|
// TODO: Faction rank should be placed in tooltip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!birthSignId.empty())
|
||||||
|
{
|
||||||
|
// Add a line separator if there are items above
|
||||||
|
if (!skillWidgets.empty())
|
||||||
|
addSeparator(coord1, coord2);
|
||||||
|
|
||||||
|
addGroup(mWindowManager.getGameSettingString("sSign", "Sign"), coord1, coord2);
|
||||||
|
const ESM::BirthSign *sign = store.birthSigns.find(birthSignId);
|
||||||
|
addItem(sign->name, coord1, coord2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a line separator if there are items above
|
||||||
|
if (!skillWidgets.empty())
|
||||||
|
addSeparator(coord1, coord2);
|
||||||
|
|
||||||
|
addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2);
|
||||||
|
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2);
|
||||||
|
|
||||||
|
clientHeight = coord1.top;
|
||||||
|
updateScroller();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::updateScroller()
|
||||||
|
{
|
||||||
|
skillScrollerWidget->setScrollRange(std::max(clientHeight - skillClientWidget->getHeight(), 0));
|
||||||
|
skillScrollerWidget->setScrollPage(std::max(skillClientWidget->getHeight() - lineHeight, 0));
|
||||||
|
}
|
80
apps/openmw/mwgui/stats_window.hpp
Normal file
80
apps/openmw/mwgui/stats_window.hpp
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
#ifndef MWGUI_STATS_WINDOW_H
|
||||||
|
#define MWGUI_STATS_WINDOW_H
|
||||||
|
|
||||||
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
#include "window_base.hpp"
|
||||||
|
|
||||||
|
namespace MWGui
|
||||||
|
{
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
|
class StatsWindow : public WindowBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::pair<std::string, int> Faction;
|
||||||
|
typedef std::vector<Faction> FactionList;
|
||||||
|
|
||||||
|
typedef std::vector<int> SkillList;
|
||||||
|
|
||||||
|
StatsWindow(WindowManager& parWindowManager);
|
||||||
|
|
||||||
|
void setBar(const std::string& name, const std::string& tname, int val, int max);
|
||||||
|
void setPlayerName(const std::string& playerName);
|
||||||
|
|
||||||
|
/// Set value for the given ID.
|
||||||
|
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 std::string& value);
|
||||||
|
void setValue (const std::string& id, int value);
|
||||||
|
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
||||||
|
|
||||||
|
void configureSkills (const SkillList& major, const SkillList& minor);
|
||||||
|
void setFactions (const std::vector<Faction>& factions);
|
||||||
|
void setBirthSign (const std::string &signId);
|
||||||
|
void setReputation (int reputation) { this->reputation = reputation; }
|
||||||
|
void setBounty (int bounty) { this->bounty = bounty; }
|
||||||
|
void updateSkillArea();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum ColorStyle
|
||||||
|
{
|
||||||
|
CS_Sub,
|
||||||
|
CS_Normal,
|
||||||
|
CS_Super
|
||||||
|
};
|
||||||
|
void setStyledText(MyGUI::StaticTextPtr widget, ColorStyle style, const std::string &value);
|
||||||
|
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||||
|
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||||
|
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||||
|
MyGUI::StaticTextPtr addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||||
|
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||||
|
void updateScroller();
|
||||||
|
|
||||||
|
void onScrollChangePosition(MyGUI::VScrollPtr scroller, size_t pos);
|
||||||
|
void onWindowResize(MyGUI::Window* window);
|
||||||
|
|
||||||
|
static const int lineHeight;
|
||||||
|
|
||||||
|
MyGUI::WidgetPtr skillAreaWidget, skillClientWidget;
|
||||||
|
MyGUI::VScrollPtr skillScrollerWidget;
|
||||||
|
int lastPos, clientHeight;
|
||||||
|
|
||||||
|
SkillList majorSkills, minorSkills, miscSkills;
|
||||||
|
std::map<int, MWMechanics::Stat<float> > skillValues;
|
||||||
|
std::map<int, MyGUI::StaticTextPtr> skillWidgetMap;
|
||||||
|
std::map<std::string, MyGUI::WidgetPtr> factionWidgetMap;
|
||||||
|
FactionList factions; ///< Stores a list of factions and the current rank
|
||||||
|
std::string birthSignId;
|
||||||
|
int reputation, bounty;
|
||||||
|
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
#include "text_input.hpp"
|
#include "text_input.hpp"
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
TextInputDialog::TextInputDialog(MWWorld::Environment& environment)
|
TextInputDialog::TextInputDialog(WindowManager& parWindowManager)
|
||||||
: WindowBase("openmw_text_input_layout.xml", environment)
|
: WindowBase("openmw_text_input_layout.xml", parWindowManager)
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
center();
|
center();
|
||||||
|
@ -55,10 +53,10 @@ void TextInputDialog::open()
|
||||||
|
|
||||||
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
|
void TextInputDialog::onOkClicked(MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
|
void TextInputDialog::onTextAccepted(MyGUI::Edit* _sender)
|
||||||
{
|
{
|
||||||
eventDone();
|
eventDone(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWGui
|
||||||
{
|
{
|
||||||
class Environment;
|
class WindowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -18,7 +18,7 @@ namespace MWGui
|
||||||
class TextInputDialog : public WindowBase
|
class TextInputDialog : public WindowBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextInputDialog(MWWorld::Environment& environment);
|
TextInputDialog(WindowManager& parWindowManager);
|
||||||
|
|
||||||
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
|
std::string getTextInput() const { return textEdit ? textEdit->getOnlyText() : ""; }
|
||||||
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }
|
void setTextInput(const std::string &text) { if (textEdit) textEdit->setOnlyText(text); }
|
||||||
|
@ -27,14 +27,6 @@ namespace MWGui
|
||||||
void setTextLabel(const std::string &label);
|
void setTextLabel(const std::string &label);
|
||||||
void open();
|
void open();
|
||||||
|
|
||||||
// Events
|
|
||||||
typedef delegates::CDelegate0 EventHandle_Void;
|
|
||||||
|
|
||||||
/** Event : Dialog finished, OK button clicked.\n
|
|
||||||
signature : void method()\n
|
|
||||||
*/
|
|
||||||
EventHandle_Void eventDone;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOkClicked(MyGUI::Widget* _sender);
|
void onOkClicked(MyGUI::Widget* _sender);
|
||||||
void onTextAccepted(MyGUI::Edit* _sender);
|
void onTextAccepted(MyGUI::Edit* _sender);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#include "widgets.hpp"
|
#include "widgets.hpp"
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
#include "components/esm_store/store.hpp"
|
#include "components/esm_store/store.hpp"
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
using namespace MWGui::Widgets;
|
using namespace MWGui::Widgets;
|
||||||
|
|
||||||
|
@ -264,7 +265,7 @@ void MWAttribute::shutdownWidgetSkin()
|
||||||
/* MWSpell */
|
/* MWSpell */
|
||||||
|
|
||||||
MWSpell::MWSpell()
|
MWSpell::MWSpell()
|
||||||
: env(nullptr)
|
: mWindowManager(nullptr)
|
||||||
, spellNameWidget(nullptr)
|
, spellNameWidget(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -277,7 +278,7 @@ void MWSpell::setSpellId(const std::string &spellId)
|
||||||
|
|
||||||
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord)
|
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord)
|
||||||
{
|
{
|
||||||
ESMS::ESMStore &store = env->mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager->getStore();
|
||||||
const ESM::Spell *spell = store.spells.search(id);
|
const ESM::Spell *spell = store.spells.search(id);
|
||||||
MYGUI_ASSERT(spell, "spell with id '" << id << "' not found");
|
MYGUI_ASSERT(spell, "spell with id '" << id << "' not found");
|
||||||
|
|
||||||
|
@ -286,7 +287,7 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
|
||||||
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
|
for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
|
||||||
{
|
{
|
||||||
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
|
effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
|
||||||
effect->setEnvironment(env);
|
effect->setWindowManager(mWindowManager);
|
||||||
effect->setSpellEffect(*it);
|
effect->setSpellEffect(*it);
|
||||||
effects.push_back(effect);
|
effects.push_back(effect);
|
||||||
coord.top += effect->getHeight();
|
coord.top += effect->getHeight();
|
||||||
|
@ -295,9 +296,9 @@ void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI:
|
||||||
|
|
||||||
void MWSpell::updateWidgets()
|
void MWSpell::updateWidgets()
|
||||||
{
|
{
|
||||||
if (spellNameWidget && env)
|
if (spellNameWidget && mWindowManager)
|
||||||
{
|
{
|
||||||
ESMS::ESMStore &store = env->mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager->getStore();
|
||||||
const ESM::Spell *spell = store.spells.search(id);
|
const ESM::Spell *spell = store.spells.search(id);
|
||||||
if (spell)
|
if (spell)
|
||||||
spellNameWidget->setCaption(spell->name);
|
spellNameWidget->setCaption(spell->name);
|
||||||
|
@ -345,7 +346,7 @@ void MWSpell::shutdownWidgetSkin()
|
||||||
/* MWSpellEffect */
|
/* MWSpellEffect */
|
||||||
|
|
||||||
MWSpellEffect::MWSpellEffect()
|
MWSpellEffect::MWSpellEffect()
|
||||||
: env(nullptr)
|
: mWindowManager(nullptr)
|
||||||
, imageWidget(nullptr)
|
, imageWidget(nullptr)
|
||||||
, textWidget(nullptr)
|
, textWidget(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -359,11 +360,10 @@ void MWSpellEffect::setSpellEffect(SpellEffectValue value)
|
||||||
|
|
||||||
void MWSpellEffect::updateWidgets()
|
void MWSpellEffect::updateWidgets()
|
||||||
{
|
{
|
||||||
if (!env)
|
if (!mWindowManager)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ESMS::ESMStore &store = env->mWorld->getStore();
|
ESMS::ESMStore &store = mWindowManager->getStore();
|
||||||
WindowManager *wm = env->mWindowManager;
|
|
||||||
const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID);
|
const ESM::MagicEffect *magicEffect = store.magicEffects.search(effect.effectID);
|
||||||
if (textWidget)
|
if (textWidget)
|
||||||
{
|
{
|
||||||
|
@ -373,7 +373,7 @@ void MWSpellEffect::updateWidgets()
|
||||||
std::string spellLine = "";
|
std::string spellLine = "";
|
||||||
if (effect.skill >= 0 && effect.skill < ESM::Skill::Length)
|
if (effect.skill >= 0 && effect.skill < ESM::Skill::Length)
|
||||||
{
|
{
|
||||||
spellLine += " " + wm->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], "");
|
spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[effect.skill], "");
|
||||||
}
|
}
|
||||||
if (effect.attribute >= 0 && effect.attribute < 8)
|
if (effect.attribute >= 0 && effect.attribute < 8)
|
||||||
{
|
{
|
||||||
|
@ -387,7 +387,7 @@ void MWSpellEffect::updateWidgets()
|
||||||
"sAttributePersonality",
|
"sAttributePersonality",
|
||||||
"sAttributeLuck"
|
"sAttributeLuck"
|
||||||
};
|
};
|
||||||
spellLine += " " + wm->getGameSettingString(attributes[effect.attribute], "");
|
spellLine += " " + mWindowManager->getGameSettingString(attributes[effect.attribute], "");
|
||||||
}
|
}
|
||||||
if (effect.magnMin >= 0 || effect.magnMax >= 0)
|
if (effect.magnMin >= 0 || effect.magnMax >= 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,11 +7,6 @@
|
||||||
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains various custom widgets used in OpenMW.
|
This file contains various custom widgets used in OpenMW.
|
||||||
*/
|
*/
|
||||||
|
@ -129,11 +124,10 @@ namespace MWGui
|
||||||
|
|
||||||
typedef MWMechanics::Stat<int> SpellValue;
|
typedef MWMechanics::Stat<int> SpellValue;
|
||||||
|
|
||||||
void setEnvironment(MWWorld::Environment *env_) { env = env_; }
|
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
|
||||||
void setSpellId(const std::string &id);
|
void setSpellId(const std::string &id);
|
||||||
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord);
|
void createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord);
|
||||||
|
|
||||||
MWWorld::Environment *getEnvironment() const { return env; }
|
|
||||||
const std::string &getSpellId() const { return id; }
|
const std::string &getSpellId() const { return id; }
|
||||||
|
|
||||||
/*internal:*/
|
/*internal:*/
|
||||||
|
@ -150,7 +144,7 @@ namespace MWGui
|
||||||
|
|
||||||
void updateWidgets();
|
void updateWidgets();
|
||||||
|
|
||||||
MWWorld::Environment *env;
|
WindowManager* mWindowManager;
|
||||||
std::string id;
|
std::string id;
|
||||||
MyGUI::StaticTextPtr spellNameWidget;
|
MyGUI::StaticTextPtr spellNameWidget;
|
||||||
};
|
};
|
||||||
|
@ -164,10 +158,9 @@ namespace MWGui
|
||||||
|
|
||||||
typedef ESM::ENAMstruct SpellEffectValue;
|
typedef ESM::ENAMstruct SpellEffectValue;
|
||||||
|
|
||||||
void setEnvironment(MWWorld::Environment *env_) { env = env_; }
|
void setWindowManager(WindowManager* parWindowManager) { mWindowManager = parWindowManager; }
|
||||||
void setSpellEffect(SpellEffectValue value);
|
void setSpellEffect(SpellEffectValue value);
|
||||||
|
|
||||||
MWWorld::Environment *getEnvironment() const { return env; }
|
|
||||||
const SpellEffectValue &getSpellEffect() const { return effect; }
|
const SpellEffectValue &getSpellEffect() const { return effect; }
|
||||||
|
|
||||||
/*internal:*/
|
/*internal:*/
|
||||||
|
@ -184,7 +177,7 @@ namespace MWGui
|
||||||
|
|
||||||
void updateWidgets();
|
void updateWidgets();
|
||||||
|
|
||||||
MWWorld::Environment *env;
|
WindowManager* mWindowManager;
|
||||||
SpellEffectValue effect;
|
SpellEffectValue effect;
|
||||||
MyGUI::StaticImagePtr imageWidget;
|
MyGUI::StaticImagePtr imageWidget;
|
||||||
MyGUI::StaticTextPtr textWidget;
|
MyGUI::StaticTextPtr textWidget;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#include "window_base.hpp"
|
#include "window_base.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
|
||||||
#include "window_manager.hpp"
|
#include "window_manager.hpp"
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
WindowBase::WindowBase(const std::string& parLayout, MWWorld::Environment& parEnvironment)
|
WindowBase::WindowBase(const std::string& parLayout, WindowManager& parWindowManager)
|
||||||
: Layout(parLayout)
|
: Layout(parLayout)
|
||||||
, environment(parEnvironment)
|
, mWindowManager(parWindowManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ void WindowBase::open()
|
||||||
void WindowBase::center()
|
void WindowBase::center()
|
||||||
{
|
{
|
||||||
// Centre dialog
|
// Centre dialog
|
||||||
MyGUI::IntSize gameWindowSize = environment.mWindowManager->getGui()->getViewSize();
|
MyGUI::IntSize gameWindowSize = mWindowManager.getGui()->getViewSize();
|
||||||
MyGUI::IntCoord coord = mMainWidget->getCoord();
|
MyGUI::IntCoord coord = mMainWidget->getCoord();
|
||||||
coord.left = (gameWindowSize.width - coord.width)/2;
|
coord.left = (gameWindowSize.width - coord.width)/2;
|
||||||
coord.top = (gameWindowSize.height - coord.height)/2;
|
coord.top = (gameWindowSize.height - coord.height)/2;
|
||||||
|
|
|
@ -3,23 +3,28 @@
|
||||||
|
|
||||||
#include <openengine/gui/layout.hpp>
|
#include <openengine/gui/layout.hpp>
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class Environment;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
class WindowManager;
|
||||||
|
|
||||||
class WindowBase: public OEngine::GUI::Layout
|
class WindowBase: public OEngine::GUI::Layout
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindowBase(const std::string& parLayout, MWWorld::Environment& parEnvironment);
|
WindowBase(const std::string& parLayout, WindowManager& parWindowManager);
|
||||||
|
|
||||||
|
// Events
|
||||||
|
typedef MyGUI::delegates::CDelegate1<WindowBase*> EventHandle_WindowBase;
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
void center();
|
void center();
|
||||||
|
|
||||||
|
/** Event : Dialog finished, OK button clicked.\n
|
||||||
|
signature : void method()\n
|
||||||
|
*/
|
||||||
|
EventHandle_WindowBase eventDone;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MWWorld::Environment& environment;
|
WindowManager& mWindowManager;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "review.hpp"
|
#include "review.hpp"
|
||||||
#include "dialogue.hpp"
|
#include "dialogue.hpp"
|
||||||
#include "dialogue_history.hpp"
|
#include "dialogue_history.hpp"
|
||||||
|
#include "stats_window.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
#include "../mwinput/inputmanager.hpp"
|
#include "../mwinput/inputmanager.hpp"
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool newGame)
|
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame)
|
||||||
: environment(environment)
|
: environment(environment)
|
||||||
, nameDialog(nullptr)
|
, nameDialog(nullptr)
|
||||||
, raceDialog(nullptr)
|
, raceDialog(nullptr)
|
||||||
|
@ -32,11 +33,6 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
, createClassDialog(nullptr)
|
, createClassDialog(nullptr)
|
||||||
, birthSignDialog(nullptr)
|
, birthSignDialog(nullptr)
|
||||||
, reviewDialog(nullptr)
|
, reviewDialog(nullptr)
|
||||||
, nameChosen(false)
|
|
||||||
, raceChosen(false)
|
|
||||||
, classChosen(false)
|
|
||||||
, birthSignChosen(false)
|
|
||||||
, reviewNext(false)
|
|
||||||
, gui(_gui)
|
, gui(_gui)
|
||||||
, mode(GM_Game)
|
, mode(GM_Game)
|
||||||
, nextMode(GM_Game)
|
, nextMode(GM_Game)
|
||||||
|
@ -44,6 +40,9 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
, shown(GW_ALL)
|
, shown(GW_ALL)
|
||||||
, allowed(newGame ? GW_None : GW_ALL)
|
, allowed(newGame ? GW_None : GW_ALL)
|
||||||
{
|
{
|
||||||
|
showFPSCounter = fpsSwitch;
|
||||||
|
|
||||||
|
creationStage = NotStarted;
|
||||||
|
|
||||||
//Register own widgets with MyGUI
|
//Register own widgets with MyGUI
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
||||||
|
@ -53,10 +52,10 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
int w = gui->getViewSize().width;
|
int w = gui->getViewSize().width;
|
||||||
int h = gui->getViewSize().height;
|
int h = gui->getViewSize().height;
|
||||||
|
|
||||||
hud = new HUD(w,h);
|
hud = new HUD(w,h, showFPSCounter);
|
||||||
menu = new MainMenu(w,h);
|
menu = new MainMenu(w,h);
|
||||||
map = new MapWindow();
|
map = new MapWindow();
|
||||||
stats = new StatsWindow (environment);
|
stats = new StatsWindow(*this);
|
||||||
#if 0
|
#if 0
|
||||||
inventory = new InventoryWindow ();
|
inventory = new InventoryWindow ();
|
||||||
#endif
|
#endif
|
||||||
|
@ -127,6 +126,10 @@ void WindowManager::update()
|
||||||
environment.mInputManager->setGuiMode(nextMode);
|
environment.mInputManager->setGuiMode(nextMode);
|
||||||
nextMode = GM_Game;
|
nextMode = GM_Game;
|
||||||
}
|
}
|
||||||
|
if (showFPSCounter)
|
||||||
|
{
|
||||||
|
hud->setFPS(mFPS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setNextMode(GuiMode newMode)
|
void WindowManager::setNextMode(GuiMode newMode)
|
||||||
|
@ -177,11 +180,11 @@ void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
if (nameDialog)
|
if (nameDialog)
|
||||||
removeDialog(nameDialog);
|
removeDialog(nameDialog);
|
||||||
nameDialog = new TextInputDialog(environment);
|
nameDialog = new TextInputDialog(*this);
|
||||||
std::string sName = getGameSettingString("sName", "Name");
|
std::string sName = getGameSettingString("sName", "Name");
|
||||||
nameDialog->setTextLabel(sName);
|
nameDialog->setTextLabel(sName);
|
||||||
nameDialog->setTextInput(playerName);
|
nameDialog->setTextInput(playerName);
|
||||||
nameDialog->setNextButtonShow(nameChosen || reviewNext);
|
nameDialog->setNextButtonShow(creationStage >= NameChosen);
|
||||||
nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone);
|
nameDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onNameDialogDone);
|
||||||
nameDialog->open();
|
nameDialog->open();
|
||||||
return;
|
return;
|
||||||
|
@ -191,8 +194,8 @@ void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
if (raceDialog)
|
if (raceDialog)
|
||||||
removeDialog(raceDialog);
|
removeDialog(raceDialog);
|
||||||
raceDialog = new RaceDialog(environment);
|
raceDialog = new RaceDialog(*this);
|
||||||
raceDialog->setNextButtonShow(raceChosen || reviewNext);
|
raceDialog->setNextButtonShow(creationStage >= RaceChosen);
|
||||||
raceDialog->setRaceId(playerRaceId);
|
raceDialog->setRaceId(playerRaceId);
|
||||||
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
|
raceDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onRaceDialogDone);
|
||||||
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
|
raceDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onRaceDialogBack);
|
||||||
|
@ -204,7 +207,7 @@ void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
if (classChoiceDialog)
|
if (classChoiceDialog)
|
||||||
removeDialog(classChoiceDialog);
|
removeDialog(classChoiceDialog);
|
||||||
classChoiceDialog = new ClassChoiceDialog(environment);
|
classChoiceDialog = new ClassChoiceDialog(*this);
|
||||||
classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice);
|
classChoiceDialog->eventButtonSelected = MyGUI::newDelegate(this, &WindowManager::onClassChoice);
|
||||||
classChoiceDialog->open();
|
classChoiceDialog->open();
|
||||||
return;
|
return;
|
||||||
|
@ -225,8 +228,8 @@ void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
if (pickClassDialog)
|
if (pickClassDialog)
|
||||||
removeDialog(pickClassDialog);
|
removeDialog(pickClassDialog);
|
||||||
pickClassDialog = new PickClassDialog(environment);
|
pickClassDialog = new PickClassDialog(*this);
|
||||||
pickClassDialog->setNextButtonShow(classChosen || reviewNext);
|
pickClassDialog->setNextButtonShow(creationStage >= ClassChosen);
|
||||||
pickClassDialog->setClassId(playerClass.name);
|
pickClassDialog->setClassId(playerClass.name);
|
||||||
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
|
pickClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogDone);
|
||||||
pickClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogBack);
|
pickClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onPickClassDialogBack);
|
||||||
|
@ -238,7 +241,7 @@ void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
if (createClassDialog)
|
if (createClassDialog)
|
||||||
removeDialog(createClassDialog);
|
removeDialog(createClassDialog);
|
||||||
createClassDialog = new CreateClassDialog(environment);
|
createClassDialog = new CreateClassDialog(*this);
|
||||||
createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone);
|
createClassDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogDone);
|
||||||
createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack);
|
createClassDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onCreateClassDialogBack);
|
||||||
createClassDialog->open();
|
createClassDialog->open();
|
||||||
|
@ -249,8 +252,8 @@ void WindowManager::updateVisible()
|
||||||
{
|
{
|
||||||
if (birthSignDialog)
|
if (birthSignDialog)
|
||||||
removeDialog(birthSignDialog);
|
removeDialog(birthSignDialog);
|
||||||
birthSignDialog = new BirthDialog(environment);
|
birthSignDialog = new BirthDialog(*this);
|
||||||
birthSignDialog->setNextButtonShow(birthSignChosen || reviewNext);
|
birthSignDialog->setNextButtonShow(creationStage >= BirthSignChosen);
|
||||||
birthSignDialog->setBirthId(playerBirthSignId);
|
birthSignDialog->setBirthId(playerBirthSignId);
|
||||||
birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
|
birthSignDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogDone);
|
||||||
birthSignDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogBack);
|
birthSignDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogBack);
|
||||||
|
@ -260,10 +263,9 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_Review)
|
if (mode == GM_Review)
|
||||||
{
|
{
|
||||||
reviewNext = false;
|
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
removeDialog(reviewDialog);
|
removeDialog(reviewDialog);
|
||||||
reviewDialog = new ReviewDialog(environment);
|
reviewDialog = new ReviewDialog(*this);
|
||||||
reviewDialog->setPlayerName(playerName);
|
reviewDialog->setPlayerName(playerName);
|
||||||
reviewDialog->setRace(playerRaceId);
|
reviewDialog->setRace(playerRaceId);
|
||||||
reviewDialog->setClass(playerClass);
|
reviewDialog->setClass(playerClass);
|
||||||
|
@ -292,12 +294,7 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
reviewDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onReviewDialogDone);
|
reviewDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onReviewDialogDone);
|
||||||
reviewDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onReviewDialogBack);
|
reviewDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onReviewDialogBack);
|
||||||
|
reviewDialog->eventActivateDialog = MyGUI::newDelegate(this, &WindowManager::onReviewActivateDialog);
|
||||||
reviewDialog->eventNameActivated = MyGUI::newDelegate(this, &WindowManager::onNameDialogActivate);
|
|
||||||
reviewDialog->eventRaceActivated = MyGUI::newDelegate(this, &WindowManager::onRaceDialogActivate);
|
|
||||||
reviewDialog->eventClassActivated = MyGUI::newDelegate(this, &WindowManager::onClassDialogActivate);
|
|
||||||
reviewDialog->eventBirthSignActivated = MyGUI::newDelegate(this, &WindowManager::onBirthSignDialogActivate);
|
|
||||||
|
|
||||||
reviewDialog->open();
|
reviewDialog->open();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -321,10 +318,11 @@ void WindowManager::updateVisible()
|
||||||
|
|
||||||
if (mode == GM_Dialogue)
|
if (mode == GM_Dialogue)
|
||||||
{
|
{
|
||||||
if (dialogueWindow)
|
if (!dialogueWindow)
|
||||||
removeDialog(dialogueWindow);
|
{
|
||||||
dialogueWindow = new DialogueWindow(environment);
|
dialogueWindow = new DialogueWindow(*this);
|
||||||
dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye);
|
dialogueWindow->eventBye = MyGUI::newDelegate(this, &WindowManager::onDialogueWindowBye);
|
||||||
|
}
|
||||||
dialogueWindow->open();
|
dialogueWindow->open();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -365,49 +363,11 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<float>& value)
|
|
||||||
{
|
|
||||||
stats->setValue (id, value);
|
|
||||||
|
|
||||||
static struct {const char *id; ESM::Skill::SkillEnum skillId; } skillMap[] =
|
void WindowManager::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
||||||
{
|
{
|
||||||
{"SkillBlock", ESM::Skill::Block},
|
stats->setValue(parSkill, value);
|
||||||
{"SkillArmorer", ESM::Skill::Armorer},
|
playerSkillValues[parSkill] = value;
|
||||||
{"SkillMediumArmor", ESM::Skill::MediumArmor},
|
|
||||||
{"SkillHeavyArmor", ESM::Skill::HeavyArmor},
|
|
||||||
{"SkillBluntWeapon", ESM::Skill::BluntWeapon},
|
|
||||||
{"SkillLongBlade", ESM::Skill::LongBlade},
|
|
||||||
{"SkillAxe", ESM::Skill::Axe},
|
|
||||||
{"SkillSpear", ESM::Skill::Spear},
|
|
||||||
{"SkillAthletics", ESM::Skill::Athletics},
|
|
||||||
{"SkillEnchant", ESM::Skill::Armorer},
|
|
||||||
{"SkillDestruction", ESM::Skill::Destruction},
|
|
||||||
{"SkillAlteration", ESM::Skill::Alteration},
|
|
||||||
{"SkillIllusion", ESM::Skill::Illusion},
|
|
||||||
{"SkillConjuration", ESM::Skill::Conjuration},
|
|
||||||
{"SkillMysticism", ESM::Skill::Mysticism},
|
|
||||||
{"SkillRestoration", ESM::Skill::Restoration},
|
|
||||||
{"SkillAlchemy", ESM::Skill::Alchemy},
|
|
||||||
{"SkillUnarmored", ESM::Skill::Unarmored},
|
|
||||||
{"SkillSecurity", ESM::Skill::Security},
|
|
||||||
{"SkillSneak", ESM::Skill::Sneak},
|
|
||||||
{"SkillAcrobatics", ESM::Skill::Acrobatics},
|
|
||||||
{"SkillLightArmor", ESM::Skill::LightArmor},
|
|
||||||
{"SkillShortBlade", ESM::Skill::ShortBlade},
|
|
||||||
{"SkillMarksman", ESM::Skill::Marksman},
|
|
||||||
{"SkillMercantile", ESM::Skill::Mercantile},
|
|
||||||
{"SkillSpeechcraft", ESM::Skill::Speechcraft},
|
|
||||||
{"SkillHandToHand", ESM::Skill::HandToHand},
|
|
||||||
};
|
|
||||||
for (size_t i = 0; i < sizeof(skillMap)/sizeof(skillMap[0]); ++i)
|
|
||||||
{
|
|
||||||
if (skillMap[i].id == id)
|
|
||||||
{
|
|
||||||
ESM::Skill::SkillEnum skillId = skillMap[i].skillId;
|
|
||||||
playerSkillValues[skillId] = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||||
|
@ -504,7 +464,7 @@ const std::string &WindowManager::getGameSettingString(const std::string &id, co
|
||||||
return default_;
|
return default_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onNameDialogDone()
|
void WindowManager::onNameDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (nameDialog)
|
if (nameDialog)
|
||||||
{
|
{
|
||||||
|
@ -513,18 +473,19 @@ void WindowManager::onNameDialogDone()
|
||||||
removeDialog(nameDialog);
|
removeDialog(nameDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = nameChosen; // Go to next dialog if name was previously chosen
|
// Go to next dialog if name was previously chosen
|
||||||
nameChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= NameChosen)
|
||||||
setGuiMode(GM_Race);
|
setGuiMode(GM_Race);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = NameChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::onRaceDialogDone()
|
void WindowManager::onRaceDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (raceDialog)
|
if (raceDialog)
|
||||||
{
|
{
|
||||||
|
@ -534,16 +495,17 @@ void WindowManager::onRaceDialogDone()
|
||||||
removeDialog(raceDialog);
|
removeDialog(raceDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = raceChosen; // Go to next dialog if race was previously chosen
|
// Go to next dialog if race was previously chosen
|
||||||
raceChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if(creationStage >= RaceChosen)
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = RaceChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::onDialogueWindowBye()
|
void WindowManager::onDialogueWindowBye()
|
||||||
{
|
{
|
||||||
|
@ -568,29 +530,29 @@ void WindowManager::onRaceDialogBack()
|
||||||
setGuiMode(GM_Name);
|
setGuiMode(GM_Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onClassChoice(MyGUI::WidgetPtr, int _index)
|
void WindowManager::onClassChoice(int _index)
|
||||||
{
|
{
|
||||||
if (classChoiceDialog)
|
if (classChoiceDialog)
|
||||||
{
|
{
|
||||||
removeDialog(classChoiceDialog);
|
removeDialog(classChoiceDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_index == ClassChoiceDialog::Class_Generate)
|
switch(_index)
|
||||||
{
|
{
|
||||||
|
case ClassChoiceDialog::Class_Generate:
|
||||||
setGuiMode(GM_ClassGenerate);
|
setGuiMode(GM_ClassGenerate);
|
||||||
}
|
break;
|
||||||
else if (_index == ClassChoiceDialog::Class_Pick)
|
case ClassChoiceDialog::Class_Pick:
|
||||||
{
|
|
||||||
setGuiMode(GM_ClassPick);
|
setGuiMode(GM_ClassPick);
|
||||||
}
|
break;
|
||||||
else if (_index == ClassChoiceDialog::Class_Create)
|
case ClassChoiceDialog::Class_Create:
|
||||||
{
|
|
||||||
setGuiMode(GM_ClassCreate);
|
setGuiMode(GM_ClassCreate);
|
||||||
}
|
break;
|
||||||
else if (_index == ClassChoiceDialog::Class_Back)
|
case ClassChoiceDialog::Class_Back:
|
||||||
{
|
|
||||||
setGuiMode(GM_Race);
|
setGuiMode(GM_Race);
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
|
@ -678,18 +640,6 @@ namespace MWGui
|
||||||
} };
|
} };
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWGui
|
|
||||||
{
|
|
||||||
|
|
||||||
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
|
|
||||||
int points[3];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowManager::showClassQuestionDialog()
|
void WindowManager::showClassQuestionDialog()
|
||||||
{
|
{
|
||||||
if (generateClassStep == generateClassSteps.size())
|
if (generateClassStep == generateClassSteps.size())
|
||||||
|
@ -753,7 +703,7 @@ void WindowManager::showClassQuestionDialog()
|
||||||
|
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
removeDialog(generateClassResultDialog);
|
removeDialog(generateClassResultDialog);
|
||||||
generateClassResultDialog = new GenerateClassResultDialog(environment);
|
generateClassResultDialog = new GenerateClassResultDialog(*this);
|
||||||
generateClassResultDialog->setClassId(generateClass);
|
generateClassResultDialog->setClassId(generateClass);
|
||||||
generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack);
|
generateClassResultDialog->eventBack = MyGUI::newDelegate(this, &WindowManager::onGenerateClassBack);
|
||||||
generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone);
|
generateClassResultDialog->eventDone = MyGUI::newDelegate(this, &WindowManager::onGenerateClassDone);
|
||||||
|
@ -769,7 +719,7 @@ void WindowManager::showClassQuestionDialog()
|
||||||
|
|
||||||
if (generateClassQuestionDialog)
|
if (generateClassQuestionDialog)
|
||||||
removeDialog(generateClassQuestionDialog);
|
removeDialog(generateClassQuestionDialog);
|
||||||
generateClassQuestionDialog = new InfoBoxDialog(environment);
|
generateClassQuestionDialog = new InfoBoxDialog(*this);
|
||||||
|
|
||||||
InfoBoxDialog::ButtonList buttons;
|
InfoBoxDialog::ButtonList buttons;
|
||||||
generateClassQuestionDialog->setText(generateClassSteps[generateClassStep].text);
|
generateClassQuestionDialog->setText(generateClassSteps[generateClassStep].text);
|
||||||
|
@ -781,7 +731,7 @@ void WindowManager::showClassQuestionDialog()
|
||||||
generateClassQuestionDialog->open();
|
generateClassQuestionDialog->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
|
void WindowManager::onClassQuestionChosen(int _index)
|
||||||
{
|
{
|
||||||
if (generateClassQuestionDialog)
|
if (generateClassQuestionDialog)
|
||||||
removeDialog(generateClassQuestionDialog);
|
removeDialog(generateClassQuestionDialog);
|
||||||
|
@ -804,7 +754,8 @@ void WindowManager::onClassQuestionChosen(MyGUI::Widget* _sender, int _index)
|
||||||
|
|
||||||
void WindowManager::onGenerateClassBack()
|
void WindowManager::onGenerateClassBack()
|
||||||
{
|
{
|
||||||
classChosen = true;
|
if(creationStage < ClassChosen)
|
||||||
|
creationStage = ClassChosen;
|
||||||
|
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
removeDialog(generateClassResultDialog);
|
removeDialog(generateClassResultDialog);
|
||||||
|
@ -813,25 +764,26 @@ void WindowManager::onGenerateClassBack()
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onGenerateClassDone()
|
void WindowManager::onGenerateClassDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
|
||||||
classChosen = true;
|
|
||||||
|
|
||||||
if (generateClassResultDialog)
|
if (generateClassResultDialog)
|
||||||
removeDialog(generateClassResultDialog);
|
removeDialog(generateClassResultDialog);
|
||||||
environment.mMechanicsManager->setPlayerClass(generateClass);
|
environment.mMechanicsManager->setPlayerClass(generateClass);
|
||||||
|
|
||||||
if (reviewNext)
|
// Go to next dialog if class was previously chosen
|
||||||
|
if (creationStage == ReviewNext)
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= ClassChosen)
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = ClassChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void WindowManager::onPickClassDialogDone()
|
void WindowManager::onPickClassDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (pickClassDialog)
|
if (pickClassDialog)
|
||||||
{
|
{
|
||||||
|
@ -844,16 +796,17 @@ void WindowManager::onPickClassDialogDone()
|
||||||
removeDialog(pickClassDialog);
|
removeDialog(pickClassDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
// Go to next dialog if class was previously chosen
|
||||||
classChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= ClassChosen)
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = ClassChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::onPickClassDialogBack()
|
void WindowManager::onPickClassDialogBack()
|
||||||
{
|
{
|
||||||
|
@ -868,7 +821,7 @@ void WindowManager::onPickClassDialogBack()
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onCreateClassDialogDone()
|
void WindowManager::onCreateClassDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (createClassDialog)
|
if (createClassDialog)
|
||||||
{
|
{
|
||||||
|
@ -898,16 +851,17 @@ void WindowManager::onCreateClassDialogDone()
|
||||||
removeDialog(createClassDialog);
|
removeDialog(createClassDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = classChosen; // Go to next dialog if class was previously chosen
|
// Go to next dialog if class was previously chosen
|
||||||
classChosen = true;
|
if (creationStage == ReviewNext)
|
||||||
|
|
||||||
if (reviewNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else if (goNext)
|
else if (creationStage >= ClassChosen)
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = ClassChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::onCreateClassDialogBack()
|
void WindowManager::onCreateClassDialogBack()
|
||||||
{
|
{
|
||||||
|
@ -917,7 +871,7 @@ void WindowManager::onCreateClassDialogBack()
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onBirthSignDialogDone()
|
void WindowManager::onBirthSignDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (birthSignDialog)
|
if (birthSignDialog)
|
||||||
{
|
{
|
||||||
|
@ -927,14 +881,15 @@ void WindowManager::onBirthSignDialogDone()
|
||||||
removeDialog(birthSignDialog);
|
removeDialog(birthSignDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goNext = birthSignChosen; // Go to next dialog if birth sign was previously chosen
|
// Go to next dialog if birth sign was previously chosen
|
||||||
birthSignChosen = true;
|
if (creationStage >= BirthSignChosen)
|
||||||
|
|
||||||
if (reviewNext || goNext)
|
|
||||||
setGuiMode(GM_Review);
|
setGuiMode(GM_Review);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
creationStage = BirthSignChosen;
|
||||||
setGuiMode(GM_Game);
|
setGuiMode(GM_Game);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::onBirthSignDialogBack()
|
void WindowManager::onBirthSignDialogBack()
|
||||||
{
|
{
|
||||||
|
@ -947,7 +902,7 @@ void WindowManager::onBirthSignDialogBack()
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onReviewDialogDone()
|
void WindowManager::onReviewDialogDone(WindowBase* parWindow)
|
||||||
{
|
{
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
removeDialog(reviewDialog);
|
removeDialog(reviewDialog);
|
||||||
|
@ -963,38 +918,29 @@ void WindowManager::onReviewDialogBack()
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::onNameDialogActivate()
|
void WindowManager::onReviewActivateDialog(int parDialog)
|
||||||
{
|
{
|
||||||
if (reviewDialog)
|
if (reviewDialog)
|
||||||
removeDialog(reviewDialog);
|
removeDialog(reviewDialog);
|
||||||
|
creationStage = ReviewNext;
|
||||||
|
|
||||||
reviewNext = true;
|
switch(parDialog)
|
||||||
|
{
|
||||||
|
case ReviewDialog::NAME_DIALOG:
|
||||||
setGuiMode(GM_Name);
|
setGuiMode(GM_Name);
|
||||||
}
|
break;
|
||||||
|
case ReviewDialog::RACE_DIALOG:
|
||||||
void WindowManager::onRaceDialogActivate()
|
|
||||||
{
|
|
||||||
if (reviewDialog)
|
|
||||||
removeDialog(reviewDialog);
|
|
||||||
|
|
||||||
reviewNext = true;
|
|
||||||
setGuiMode(GM_Race);
|
setGuiMode(GM_Race);
|
||||||
}
|
break;
|
||||||
|
case ReviewDialog::CLASS_DIALOG:
|
||||||
void WindowManager::onClassDialogActivate()
|
|
||||||
{
|
|
||||||
if (reviewDialog)
|
|
||||||
removeDialog(reviewDialog);
|
|
||||||
|
|
||||||
reviewNext = true;
|
|
||||||
setGuiMode(GM_Class);
|
setGuiMode(GM_Class);
|
||||||
}
|
break;
|
||||||
|
case ReviewDialog::BIRTHSIGN_DIALOG:
|
||||||
void WindowManager::onBirthSignDialogActivate()
|
|
||||||
{
|
|
||||||
if (reviewDialog)
|
|
||||||
removeDialog(reviewDialog);
|
|
||||||
|
|
||||||
reviewNext = true;
|
|
||||||
setGuiMode(GM_Birth);
|
setGuiMode(GM_Birth);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ESMS::ESMStore& WindowManager::getStore()
|
||||||
|
{
|
||||||
|
return environment.mWorld->getStore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace OEngine
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
class WindowBase;
|
||||||
class HUD;
|
class HUD;
|
||||||
class MapWindow;
|
class MapWindow;
|
||||||
class MainMenu;
|
class MainMenu;
|
||||||
|
@ -62,6 +63,14 @@ namespace MWGui
|
||||||
class BirthDialog;
|
class BirthDialog;
|
||||||
class ReviewDialog;
|
class ReviewDialog;
|
||||||
|
|
||||||
|
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];
|
||||||
|
};
|
||||||
|
|
||||||
class WindowManager
|
class WindowManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -92,14 +101,6 @@ namespace MWGui
|
||||||
BirthDialog *birthSignDialog;
|
BirthDialog *birthSignDialog;
|
||||||
ReviewDialog *reviewDialog;
|
ReviewDialog *reviewDialog;
|
||||||
|
|
||||||
// Which dialogs have been shown, controls back/next/ok buttons
|
|
||||||
bool nameChosen;
|
|
||||||
bool raceChosen;
|
|
||||||
bool classChosen;
|
|
||||||
bool birthSignChosen;
|
|
||||||
bool reviewNext;
|
|
||||||
///< If true then any click on Next will cause the summary to be shown
|
|
||||||
|
|
||||||
// Keeps track of current step in Generate Class dialogs
|
// Keeps track of current step in Generate Class dialogs
|
||||||
unsigned generateClassStep;
|
unsigned generateClassStep;
|
||||||
// A counter for each specialization which is increased when an answer is chosen, in order: Stealth, Combat, Magic
|
// A counter for each specialization which is increased when an answer is chosen, in order: Stealth, Combat, Magic
|
||||||
|
@ -153,10 +154,13 @@ namespace MWGui
|
||||||
|
|
||||||
void setGuiMode(GuiMode newMode);
|
void setGuiMode(GuiMode newMode);
|
||||||
|
|
||||||
|
bool showFPSCounter;
|
||||||
|
float mFPS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The constructor needs the main Gui object
|
/// The constructor needs the main Gui object
|
||||||
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool newGame);
|
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,10 +201,12 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::Gui* getGui() const { return gui; }
|
MyGUI::Gui* getGui() const { return gui; }
|
||||||
|
|
||||||
|
void wmSetFPS(float fps) { mFPS = fps; }
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||||
///< Set value for the given ID.
|
///< Set value for the given ID.
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<float>& value);
|
void setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value);
|
||||||
///< Set value for the given ID.
|
///< Set value for the given ID.
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||||
|
@ -251,45 +257,57 @@ namespace MWGui
|
||||||
*/
|
*/
|
||||||
const std::string &getGameSettingString(const std::string &id, const std::string &default_);
|
const std::string &getGameSettingString(const std::string &id, const std::string &default_);
|
||||||
|
|
||||||
|
ESMS::ESMStore& getStore();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void onDialogueWindowBye();
|
void onDialogueWindowBye();
|
||||||
|
|
||||||
// Character generation: Name dialog
|
// Character generation: Name dialog
|
||||||
void onNameDialogDone();
|
void onNameDialogDone(WindowBase* parWindow);
|
||||||
|
|
||||||
// Character generation: Race dialog
|
// Character generation: Race dialog
|
||||||
void onRaceDialogDone();
|
void onRaceDialogDone(WindowBase* parWindow);
|
||||||
void onRaceDialogBack();
|
void onRaceDialogBack();
|
||||||
|
|
||||||
// Character generation: Choose class process
|
// Character generation: Choose class process
|
||||||
void onClassChoice(MyGUI::Widget* _sender, int _index);
|
void onClassChoice(int _index);
|
||||||
|
|
||||||
// Character generation: Generate Class
|
// Character generation: Generate Class
|
||||||
void showClassQuestionDialog();
|
void showClassQuestionDialog();
|
||||||
void onClassQuestionChosen(MyGUI::Widget* _sender, int _index);
|
void onClassQuestionChosen(int _index);
|
||||||
void onGenerateClassBack();
|
void onGenerateClassBack();
|
||||||
void onGenerateClassDone();
|
void onGenerateClassDone(WindowBase* parWindow);
|
||||||
|
|
||||||
// Character generation: Pick Class dialog
|
// Character generation: Pick Class dialog
|
||||||
void onPickClassDialogDone();
|
void onPickClassDialogDone(WindowBase* parWindow);
|
||||||
void onPickClassDialogBack();
|
void onPickClassDialogBack();
|
||||||
|
|
||||||
// Character generation: Create Class dialog
|
// Character generation: Create Class dialog
|
||||||
void onCreateClassDialogDone();
|
void onCreateClassDialogDone(WindowBase* parWindow);
|
||||||
void onCreateClassDialogBack();
|
void onCreateClassDialogBack();
|
||||||
|
|
||||||
// Character generation: Birth sign dialog
|
// Character generation: Birth sign dialog
|
||||||
void onBirthSignDialogDone();
|
void onBirthSignDialogDone(WindowBase* parWindow);
|
||||||
void onBirthSignDialogBack();
|
void onBirthSignDialogBack();
|
||||||
|
|
||||||
// Character generation: Review dialog
|
// Character generation: Review dialog
|
||||||
void onReviewDialogDone();
|
void onReviewDialogDone(WindowBase* parWindow);
|
||||||
void onReviewDialogBack();
|
void onReviewDialogBack();
|
||||||
void onNameDialogActivate();
|
void onReviewActivateDialog(int parDialog);
|
||||||
void onRaceDialogActivate();
|
|
||||||
void onClassDialogActivate();
|
enum CreationStageEnum
|
||||||
void onBirthSignDialogActivate();
|
{
|
||||||
|
NotStarted,
|
||||||
|
NameChosen,
|
||||||
|
RaceChosen,
|
||||||
|
ClassChosen,
|
||||||
|
BirthSignChosen,
|
||||||
|
ReviewNext
|
||||||
|
};
|
||||||
|
|
||||||
|
// Which state the character creating is in, controls back/next/ok buttons
|
||||||
|
CreationStageEnum creationStage;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -15,10 +15,13 @@
|
||||||
#include <mangle/input/filters/eventlist.hpp>
|
#include <mangle/input/filters/eventlist.hpp>
|
||||||
|
|
||||||
#include <libs/platform/strings.h>
|
#include <libs/platform/strings.h>
|
||||||
#include "../mwrender/playerpos.hpp"
|
|
||||||
|
|
||||||
#include "../engine.hpp"
|
#include "../engine.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
|
#include "../mwrender/player.hpp"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
@ -38,13 +41,31 @@ namespace MWInput
|
||||||
|
|
||||||
A_MoveLeft, // Move player left / right
|
A_MoveLeft, // Move player left / right
|
||||||
A_MoveRight,
|
A_MoveRight,
|
||||||
A_MoveUp, // Move up / down
|
|
||||||
A_MoveDown,
|
|
||||||
A_MoveForward, // Forward / Backward
|
A_MoveForward, // Forward / Backward
|
||||||
A_MoveBackward,
|
A_MoveBackward,
|
||||||
|
|
||||||
A_Activate,
|
A_Activate,
|
||||||
|
|
||||||
|
A_Use, //Use weapon, spell, etc.
|
||||||
|
A_Jump,
|
||||||
|
A_AutoMove, //Toggle Auto-move forward
|
||||||
|
A_Rest, //Rest
|
||||||
|
A_Journal, //Journal
|
||||||
|
A_Weapon, //Draw/Sheath weapon
|
||||||
|
A_Spell, //Ready/Unready Casting
|
||||||
|
A_AlwaysRun, //Toggle Always Run
|
||||||
|
A_CycleSpellLeft, //cycling through spells
|
||||||
|
A_CycleSpellRight,
|
||||||
|
A_CycleWeaponLeft,//Cycling through weapons
|
||||||
|
A_CycleWeaponRight,
|
||||||
|
A_ToggleSneak, //Toggles Sneak, add Push-Sneak later
|
||||||
|
A_ToggleWalk, //Toggle Walking/Running
|
||||||
|
|
||||||
|
A_QuickSave,
|
||||||
|
A_QuickLoad,
|
||||||
|
A_QuickMenu,
|
||||||
|
A_GameMenu,
|
||||||
|
|
||||||
A_LAST // Marker for the last item
|
A_LAST // Marker for the last item
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,18 +79,21 @@ namespace MWInput
|
||||||
OEngine::Input::Poller poller;
|
OEngine::Input::Poller poller;
|
||||||
OEngine::Render::MouseLookEventPtr mouse;
|
OEngine::Render::MouseLookEventPtr mouse;
|
||||||
OEngine::GUI::EventInjectorPtr guiEvents;
|
OEngine::GUI::EventInjectorPtr guiEvents;
|
||||||
MWRender::PlayerPos &player;
|
MWWorld::Player &player;
|
||||||
MWGui::WindowManager &windows;
|
MWGui::WindowManager &windows;
|
||||||
OMW::Engine& mEngine;
|
OMW::Engine& mEngine;
|
||||||
|
|
||||||
// Count screenshots.
|
// Count screenshots.
|
||||||
int shotCount;
|
int shotCount;
|
||||||
|
|
||||||
|
|
||||||
|
/* InputImpl Methods */
|
||||||
|
|
||||||
// Write screenshot to file.
|
// Write screenshot to file.
|
||||||
void screenshot()
|
void screenshot()
|
||||||
{
|
{
|
||||||
// Find the first unused filename.
|
|
||||||
//
|
// Find the first unused filename with a do-while
|
||||||
char buf[50];
|
char buf[50];
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -79,8 +103,8 @@ namespace MWInput
|
||||||
ogre.screenshot(buf);
|
ogre.screenshot(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the user presses the button to toggle the inventory
|
|
||||||
// screen.
|
/* toggleInventory() is called when the user presses the button to toggle the inventory screen. */
|
||||||
void toggleInventory()
|
void toggleInventory()
|
||||||
{
|
{
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
@ -115,6 +139,16 @@ namespace MWInput
|
||||||
mEngine.activate();
|
mEngine.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggleAutoMove()
|
||||||
|
{
|
||||||
|
player.setAutoMove (!player.getAutoMove());
|
||||||
|
}
|
||||||
|
|
||||||
|
void toggleWalking()
|
||||||
|
{
|
||||||
|
player.toggleRunning();
|
||||||
|
}
|
||||||
|
|
||||||
// Exit program now button (which is disabled in GUI mode)
|
// Exit program now button (which is disabled in GUI mode)
|
||||||
void exitNow()
|
void exitNow()
|
||||||
{
|
{
|
||||||
|
@ -124,7 +158,7 @@ namespace MWInput
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InputImpl(OEngine::Render::OgreRenderer &_ogre,
|
InputImpl(OEngine::Render::OgreRenderer &_ogre,
|
||||||
MWRender::PlayerPos &_player,
|
MWWorld::Player &_player,
|
||||||
MWGui::WindowManager &_windows,
|
MWGui::WindowManager &_windows,
|
||||||
bool debug,
|
bool debug,
|
||||||
OMW::Engine& engine)
|
OMW::Engine& engine)
|
||||||
|
@ -156,7 +190,10 @@ namespace MWInput
|
||||||
"Toggle console");
|
"Toggle console");
|
||||||
disp->funcs.bind(A_Activate, boost::bind(&InputImpl::activate, this),
|
disp->funcs.bind(A_Activate, boost::bind(&InputImpl::activate, this),
|
||||||
"Activate");
|
"Activate");
|
||||||
|
disp->funcs.bind(A_AutoMove, boost::bind(&InputImpl::toggleAutoMove, this),
|
||||||
|
"Auto Move");
|
||||||
|
disp->funcs.bind(A_ToggleWalk, boost::bind(&InputImpl::toggleWalking, this),
|
||||||
|
"Toggle Walk/Run");
|
||||||
|
|
||||||
// Add the exit listener
|
// Add the exit listener
|
||||||
ogre.getRoot()->addFrameListener(&exit);
|
ogre.getRoot()->addFrameListener(&exit);
|
||||||
|
@ -164,7 +201,7 @@ namespace MWInput
|
||||||
ogre.getRoot()->addFrameListener(this);
|
ogre.getRoot()->addFrameListener(this);
|
||||||
|
|
||||||
// Set up the mouse handler and tell it about the player camera
|
// Set up the mouse handler and tell it about the player camera
|
||||||
mouse = MouseLookEventPtr(new MouseLookEvent(player.getCamera()));
|
mouse = MouseLookEventPtr(new MouseLookEvent(player.getRenderer()->getCamera()));
|
||||||
|
|
||||||
// This event handler pumps events into MyGUI
|
// This event handler pumps events into MyGUI
|
||||||
guiEvents = EventInjectorPtr(new EventInjector(windows.getGui()));
|
guiEvents = EventInjectorPtr(new EventInjector(windows.getGui()));
|
||||||
|
@ -192,6 +229,7 @@ namespace MWInput
|
||||||
**********************************/
|
**********************************/
|
||||||
|
|
||||||
// Key bindings for keypress events
|
// Key bindings for keypress events
|
||||||
|
// NOTE: These keys do not require constant polling - use in conjuction with variables in loops.
|
||||||
|
|
||||||
disp->bind(A_Quit, KC_Q);
|
disp->bind(A_Quit, KC_Q);
|
||||||
disp->bind(A_Quit, KC_ESCAPE);
|
disp->bind(A_Quit, KC_ESCAPE);
|
||||||
|
@ -199,8 +237,12 @@ namespace MWInput
|
||||||
disp->bind(A_Inventory, KC_I);
|
disp->bind(A_Inventory, KC_I);
|
||||||
disp->bind(A_Console, KC_F1);
|
disp->bind(A_Console, KC_F1);
|
||||||
disp->bind(A_Activate, KC_SPACE);
|
disp->bind(A_Activate, KC_SPACE);
|
||||||
|
disp->bind(A_AutoMove, KC_Z);
|
||||||
|
disp->bind(A_ToggleSneak, KC_X);
|
||||||
|
disp->bind(A_ToggleWalk, KC_C);
|
||||||
|
|
||||||
// Key bindings for polled keys
|
// Key bindings for polled keys
|
||||||
|
// NOTE: These keys are constantly being polled. Only add keys that must be checked each frame.
|
||||||
|
|
||||||
// Arrow keys
|
// Arrow keys
|
||||||
poller.bind(A_MoveLeft, KC_LEFT);
|
poller.bind(A_MoveLeft, KC_LEFT);
|
||||||
|
@ -213,13 +255,9 @@ namespace MWInput
|
||||||
poller.bind(A_MoveRight, KC_D);
|
poller.bind(A_MoveRight, KC_D);
|
||||||
poller.bind(A_MoveForward, KC_W);
|
poller.bind(A_MoveForward, KC_W);
|
||||||
poller.bind(A_MoveBackward, KC_S);
|
poller.bind(A_MoveBackward, KC_S);
|
||||||
|
|
||||||
// Use shift and ctrl for up and down
|
|
||||||
poller.bind(A_MoveUp, KC_LSHIFT);
|
|
||||||
poller.bind(A_MoveDown, KC_LCONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to check for movement keys
|
//NOTE: Used to check for movement keys
|
||||||
bool frameStarted(const Ogre::FrameEvent &evt)
|
bool frameStarted(const Ogre::FrameEvent &evt)
|
||||||
{
|
{
|
||||||
// Tell OIS to handle all input events
|
// Tell OIS to handle all input events
|
||||||
|
@ -236,22 +274,33 @@ namespace MWInput
|
||||||
// Disable movement in Gui mode
|
// Disable movement in Gui mode
|
||||||
if (windows.isGuiMode()) return true;
|
if (windows.isGuiMode()) return true;
|
||||||
|
|
||||||
float speed = 300 * evt.timeSinceLastFrame;
|
// Configure player movement according to keyboard input. Actual movement will
|
||||||
float moveX = 0, moveY = 0, moveZ = 0;
|
// be done in the physics system.
|
||||||
|
if (poller.isDown(A_MoveLeft))
|
||||||
if(poller.isDown(A_MoveLeft)) moveX -= speed;
|
{
|
||||||
if(poller.isDown(A_MoveRight)) moveX += speed;
|
player.setAutoMove (false);
|
||||||
if(poller.isDown(A_MoveForward)) moveZ -= speed;
|
player.setLeftRight (1);
|
||||||
if(poller.isDown(A_MoveBackward)) moveZ += speed;
|
}
|
||||||
|
else if (poller.isDown(A_MoveRight))
|
||||||
// TODO: These should be enabled for floating modes (like
|
{
|
||||||
// swimming and levitation) and disabled for everything else.
|
player.setAutoMove (false);
|
||||||
if(poller.isDown(A_MoveUp)) moveY += speed;
|
player.setLeftRight (-1);
|
||||||
if(poller.isDown(A_MoveDown)) moveY -= speed;
|
}
|
||||||
|
else
|
||||||
if(moveX != 0 || moveY != 0 || moveZ != 0)
|
player.setLeftRight (0);
|
||||||
player.moveRel(moveX, moveY, moveZ);
|
|
||||||
|
|
||||||
|
if (poller.isDown(A_MoveForward))
|
||||||
|
{
|
||||||
|
player.setAutoMove (false);
|
||||||
|
player.setForwardBackward (1);
|
||||||
|
}
|
||||||
|
else if (poller.isDown(A_MoveBackward))
|
||||||
|
{
|
||||||
|
player.setAutoMove (false);
|
||||||
|
player.setForwardBackward (-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
player.setForwardBackward (0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +326,7 @@ namespace MWInput
|
||||||
{
|
{
|
||||||
// Start mouse-looking again. TODO: This should also allow
|
// Start mouse-looking again. TODO: This should also allow
|
||||||
// for other ways to disable mouselook, like paralyzation.
|
// for other ways to disable mouselook, like paralyzation.
|
||||||
mouse->setCamera(player.getCamera());
|
mouse->setCamera(player.getRenderer()->getCamera());
|
||||||
|
|
||||||
// Disable GUI events
|
// Disable GUI events
|
||||||
guiEvents->enabled = false;
|
guiEvents->enabled = false;
|
||||||
|
@ -285,8 +334,9 @@ namespace MWInput
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/***CONSTRUCTOR***/
|
||||||
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
|
MWInputManager::MWInputManager(OEngine::Render::OgreRenderer &ogre,
|
||||||
MWRender::PlayerPos &player,
|
MWWorld::Player &player,
|
||||||
MWGui::WindowManager &windows,
|
MWGui::WindowManager &windows,
|
||||||
bool debug,
|
bool debug,
|
||||||
OMW::Engine& engine)
|
OMW::Engine& engine)
|
||||||
|
@ -294,6 +344,7 @@ namespace MWInput
|
||||||
impl = new InputImpl(ogre,player,windows,debug, engine);
|
impl = new InputImpl(ogre,player,windows,debug, engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***DESTRUCTOR***/
|
||||||
MWInputManager::~MWInputManager()
|
MWInputManager::~MWInputManager()
|
||||||
{
|
{
|
||||||
delete impl;
|
delete impl;
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace OEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class PlayerPos;
|
class Player;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
|
@ -42,7 +42,7 @@ namespace MWInput
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
MWInputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||||
MWRender::PlayerPos &_player,
|
MWWorld::Player&_player,
|
||||||
MWGui::WindowManager &_windows,
|
MWGui::WindowManager &_windows,
|
||||||
bool debug,
|
bool debug,
|
||||||
OMW::Engine& engine);
|
OMW::Engine& engine);
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
void MechanicsManager::buildPlayer()
|
void MechanicsManager::buildPlayer()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayerPos().getPlayer();
|
MWWorld::Ptr ptr = mEnvironment.mWorld->getPlayer().getPlayer();
|
||||||
|
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
||||||
|
@ -33,9 +34,9 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
const ESM::Race *race =
|
const ESM::Race *race =
|
||||||
mEnvironment.mWorld->getStore().races.find (
|
mEnvironment.mWorld->getStore().races.find (
|
||||||
mEnvironment.mWorld->getPlayerPos().getRace());
|
mEnvironment.mWorld->getPlayer().getRace());
|
||||||
|
|
||||||
bool male = mEnvironment.mWorld->getPlayerPos().isMale();
|
bool male = mEnvironment.mWorld->getPlayer().isMale();
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
|
@ -75,11 +76,11 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
// birthsign
|
// birthsign
|
||||||
if (!mEnvironment.mWorld->getPlayerPos().getBirthsign().empty())
|
if (!mEnvironment.mWorld->getPlayer().getBirthsign().empty())
|
||||||
{
|
{
|
||||||
const ESM::BirthSign *sign =
|
const ESM::BirthSign *sign =
|
||||||
mEnvironment.mWorld->getStore().birthSigns.find (
|
mEnvironment.mWorld->getStore().birthSigns.find (
|
||||||
mEnvironment.mWorld->getPlayerPos().getBirthsign());
|
mEnvironment.mWorld->getPlayer().getBirthsign());
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
for (std::vector<std::string>::const_iterator iter (sign->powers.list.begin());
|
||||||
iter!=sign->powers.list.end(); ++iter)
|
iter!=sign->powers.list.end(); ++iter)
|
||||||
|
@ -91,7 +92,7 @@ namespace MWMechanics
|
||||||
// class
|
// class
|
||||||
if (mClassSelected)
|
if (mClassSelected)
|
||||||
{
|
{
|
||||||
const ESM::Class& class_ = mEnvironment.mWorld->getPlayerPos().getClass();
|
const ESM::Class& class_ = mEnvironment.mWorld->getPlayer().getClass();
|
||||||
|
|
||||||
for (int i=0; i<2; ++i)
|
for (int i=0; i<2; ++i)
|
||||||
{
|
{
|
||||||
|
@ -233,11 +234,17 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::removeActor (const MWWorld::Ptr& ptr)
|
void MechanicsManager::removeActor (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
|
if (ptr==mWatched)
|
||||||
|
mWatched = MWWorld::Ptr();
|
||||||
|
|
||||||
mActors.erase (ptr);
|
mActors.erase (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
void MechanicsManager::dropActors (const MWWorld::Ptr::CellStore *cellStore)
|
||||||
{
|
{
|
||||||
|
if (!mWatched.isEmpty() && mWatched.getCell()==cellStore)
|
||||||
|
mWatched = MWWorld::Ptr();
|
||||||
|
|
||||||
std::set<MWWorld::Ptr>::iterator iter = mActors.begin();
|
std::set<MWWorld::Ptr>::iterator iter = mActors.begin();
|
||||||
|
|
||||||
while (iter!=mActors.end())
|
while (iter!=mActors.end())
|
||||||
|
@ -254,7 +261,7 @@ namespace MWMechanics
|
||||||
mWatched = ptr;
|
mWatched = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::update()
|
void MechanicsManager::update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement)
|
||||||
{
|
{
|
||||||
if (!mWatched.isEmpty())
|
if (!mWatched.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -275,17 +282,6 @@ namespace MWMechanics
|
||||||
"HBar", "MBar", "FBar"
|
"HBar", "MBar", "FBar"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *skillNames[27] =
|
|
||||||
{
|
|
||||||
"SkillBlock", "SkillArmorer", "SkillMediumArmor", "SkillHeavyArmor",
|
|
||||||
"SkillBluntWeapon", "SkillLongBlade", "SkillAxe", "SkillSpear",
|
|
||||||
"SkillAthletics", "SkillEnchant", "SkillDestruction", "SkillAlteration",
|
|
||||||
"SkillIllusion", "SkillConjuration", "SkillMysticism", "SkillRestoration",
|
|
||||||
"SkillAlchemy", "SkillUnarmored", "SkillSecurity", "SkillSneak",
|
|
||||||
"SkillAcrobatics", "SkillLightArmor", "SkillShortBlade", "SkillMarksman",
|
|
||||||
"SkillMercantile", "SkillSpeechcraft", "SkillHandToHand",
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i])
|
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i])
|
||||||
|
@ -308,16 +304,14 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool update = false;
|
bool update = false;
|
||||||
|
|
||||||
|
//Loop over ESM::Skill::SkillEnum
|
||||||
for(int i = 0; i < 27; ++i)
|
for(int i = 0; i < 27; ++i)
|
||||||
{
|
{
|
||||||
if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i])
|
if(npcStats.mSkill[i] != mWatchedNpc.mSkill[i])
|
||||||
{
|
{
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
mWatchedNpc.mSkill[i] = npcStats.mSkill[i];
|
mWatchedNpc.mSkill[i] = npcStats.mSkill[i];
|
||||||
|
mEnvironment.mWindowManager->setValue((ESM::Skill::SkillEnum)i, npcStats.mSkill[i]);
|
||||||
mEnvironment.mWindowManager->setValue (skillNames[i], npcStats.mSkill[i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +324,12 @@ namespace MWMechanics
|
||||||
if (mUpdatePlayer)
|
if (mUpdatePlayer)
|
||||||
{
|
{
|
||||||
// basic player profile; should not change anymore after the creation phase is finished.
|
// basic player profile; should not change anymore after the creation phase is finished.
|
||||||
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayerPos().getName());
|
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayer().getName());
|
||||||
mEnvironment.mWindowManager->setValue ("race",
|
mEnvironment.mWindowManager->setValue ("race",
|
||||||
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayerPos().
|
mEnvironment.mWorld->getStore().races.find (mEnvironment.mWorld->getPlayer().
|
||||||
getRace())->name);
|
getRace())->name);
|
||||||
mEnvironment.mWindowManager->setValue ("class",
|
mEnvironment.mWindowManager->setValue ("class",
|
||||||
mEnvironment.mWorld->getPlayerPos().getClass().name);
|
mEnvironment.mWorld->getPlayer().getClass().name);
|
||||||
mUpdatePlayer = false;
|
mUpdatePlayer = false;
|
||||||
|
|
||||||
MWGui::WindowManager::SkillList majorSkills (5);
|
MWGui::WindowManager::SkillList majorSkills (5);
|
||||||
|
@ -343,24 +337,33 @@ namespace MWMechanics
|
||||||
|
|
||||||
for (int i=0; i<5; ++i)
|
for (int i=0; i<5; ++i)
|
||||||
{
|
{
|
||||||
minorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][0];
|
minorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][0];
|
||||||
majorSkills[i] = mEnvironment.mWorld->getPlayerPos().getClass().data.skills[i][1];
|
majorSkills[i] = mEnvironment.mWorld->getPlayer().getClass().data.skills[i][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
|
mEnvironment.mWindowManager->configureSkills (majorSkills, minorSkills);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end();
|
||||||
|
++iter)
|
||||||
|
{
|
||||||
|
Ogre::Vector3 vector = MWWorld::Class::get (*iter).getMovementVector (*iter);
|
||||||
|
|
||||||
|
if (vector!=Ogre::Vector3::ZERO)
|
||||||
|
movement.push_back (std::make_pair (iter->getRefData().getHandle(), vector));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerName (const std::string& name)
|
void MechanicsManager::setPlayerName (const std::string& name)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setName (name);
|
mEnvironment.mWorld->getPlayer().setName (name);
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setGender (male);
|
mEnvironment.mWorld->getPlayer().setGender (male);
|
||||||
mEnvironment.mWorld->getPlayerPos().setRace (race);
|
mEnvironment.mWorld->getPlayer().setRace (race);
|
||||||
mRaceSelected = true;
|
mRaceSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
|
@ -368,14 +371,14 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setBirthsign (id);
|
mEnvironment.mWorld->getPlayer().setBirthsign (id);
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerClass (const std::string& id)
|
void MechanicsManager::setPlayerClass (const std::string& id)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
|
mEnvironment.mWorld->getPlayer().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
|
||||||
mClassSelected = true;
|
mClassSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
|
@ -383,7 +386,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
|
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
|
||||||
{
|
{
|
||||||
mEnvironment.mWorld->getPlayerPos().setClass (class_);
|
mEnvironment.mWorld->getPlayer().setClass (class_);
|
||||||
mClassSelected = true;
|
mClassSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
|
|
|
@ -2,12 +2,19 @@
|
||||||
#define GAME_MWMECHANICS_MECHANICSMANAGER_H
|
#define GAME_MWMECHANICS_MECHANICSMANAGER_H
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include "creaturestats.hpp"
|
#include "creaturestats.hpp"
|
||||||
#include "npcstats.hpp"
|
#include "npcstats.hpp"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Vector3;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Environment;
|
class Environment;
|
||||||
|
@ -53,8 +60,8 @@ namespace MWMechanics
|
||||||
///< On each update look for changes in a previously registered actor and update the
|
///< On each update look for changes in a previously registered actor and update the
|
||||||
/// GUI accordingly.
|
/// GUI accordingly.
|
||||||
|
|
||||||
void update();
|
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement);
|
||||||
///< Update actor stats
|
///< Update actor stats and store desired velocity vectors in \a movement
|
||||||
|
|
||||||
void setPlayerName (const std::string& name);
|
void setPlayerName (const std::string& name);
|
||||||
///< Set player name.
|
///< Set player name.
|
||||||
|
|
16
apps/openmw/mwmechanics/movement.hpp
Normal file
16
apps/openmw/mwmechanics/movement.hpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef GAME_MWMECHANICS_MOVEMENT_H
|
||||||
|
#define GAME_MWMECHANICS_MOVEMENT_H
|
||||||
|
|
||||||
|
namespace MWMechanics
|
||||||
|
{
|
||||||
|
/// Desired movement for an actor
|
||||||
|
struct Movement
|
||||||
|
{
|
||||||
|
signed char mLeftRight; // 1: wants to move left, -1: wants to move right
|
||||||
|
signed char mForwardBackward; // 1:wants to move forward, -1: wants to move backward
|
||||||
|
|
||||||
|
Movement() : mLeftRight (0), mForwardBackward (0) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -18,6 +18,15 @@ namespace MWMechanics
|
||||||
std::map<std::string, int> mFactionRank;
|
std::map<std::string, int> mFactionRank;
|
||||||
|
|
||||||
Stat<float> mSkill[27];
|
Stat<float> mSkill[27];
|
||||||
|
|
||||||
|
bool mForceRun;
|
||||||
|
bool mForceSneak;
|
||||||
|
bool mRun;
|
||||||
|
bool mSneak;
|
||||||
|
bool mCombat;
|
||||||
|
|
||||||
|
NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false),
|
||||||
|
mCombat (false) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#ifndef GAME_MWMECHANICS_STAT_H
|
#ifndef GAME_MWMECHANICS_STAT_H
|
||||||
#define GAME_MWMECHANICS_STAT_H
|
#define GAME_MWMECHANICS_STAT_H
|
||||||
|
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
|
|
|
@ -45,6 +45,9 @@ namespace MWRender
|
||||||
|
|
||||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0;
|
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements) = 0;
|
||||||
|
|
||||||
|
virtual void insertObjectPhysics() = 0;
|
||||||
|
|
||||||
|
virtual void insertActorPhysics() = 0;
|
||||||
|
|
||||||
/// insert a light related to the most recent insertBegin call.
|
/// insert a light related to the most recent insertBegin call.
|
||||||
virtual void insertLight(float r, float g, float b, float radius) = 0;
|
virtual void insertLight(float r, float g, float b, float radius) = 0;
|
||||||
|
|
|
@ -35,14 +35,14 @@ bool ExteriorCellRender::lightOutQuadInLin = false;
|
||||||
|
|
||||||
void ExteriorCellRender::insertBegin (ESM::CellRef &ref)
|
void ExteriorCellRender::insertBegin (ESM::CellRef &ref)
|
||||||
{
|
{
|
||||||
assert (!insert);
|
assert (!mInsert);
|
||||||
|
|
||||||
// Create and place scene node for this object
|
// Create and place scene node for this object
|
||||||
insert = base->createChildSceneNode();
|
mInsert = mBase->createChildSceneNode();
|
||||||
|
|
||||||
const float *f = ref.pos.pos;
|
const float *f = ref.pos.pos;
|
||||||
insert->setPosition(f[0], f[1], f[2]);
|
mInsert->setPosition(f[0], f[1], f[2]);
|
||||||
insert->setScale(ref.scale, ref.scale, ref.scale);
|
mInsert->setScale(ref.scale, ref.scale, ref.scale);
|
||||||
|
|
||||||
// Convert MW rotation to a quaternion:
|
// Convert MW rotation to a quaternion:
|
||||||
f = ref.pos.rot;
|
f = ref.pos.rot;
|
||||||
|
@ -57,14 +57,16 @@ void ExteriorCellRender::insertBegin (ESM::CellRef &ref)
|
||||||
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z);
|
Quaternion zr(Radian(-f[2]), Vector3::UNIT_Z);
|
||||||
|
|
||||||
// Rotates first around z, then y, then x
|
// Rotates first around z, then y, then x
|
||||||
insert->setOrientation(xr*yr*zr);
|
mInsert->setOrientation(xr*yr*zr);
|
||||||
|
|
||||||
|
mInsertMesh.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
|
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
|
||||||
{
|
{
|
||||||
assert(insert);
|
assert(mInsert);
|
||||||
Ogre::SceneNode *parent = insert;
|
Ogre::SceneNode *parent = mInsert;
|
||||||
//std::cout << "ELEMENTS:" << elements;
|
//std::cout << "ELEMENTS:" << elements;
|
||||||
for (int i = 0; i < elements; i++){
|
for (int i = 0; i < elements; i++){
|
||||||
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
||||||
|
@ -74,24 +76,24 @@ void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){
|
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements){
|
||||||
assert (insert);
|
assert (mInsert);
|
||||||
//insert->
|
//mInsert->
|
||||||
Ogre::SceneNode *parent = insert;
|
Ogre::SceneNode *parent = mInsert;
|
||||||
for (int i = 0; i < elements; i++){
|
for (int i = 0; i < elements; i++){
|
||||||
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
npcPart = parent->createChildSceneNode(sceneNodeName);
|
mNpcPart = parent->createChildSceneNode(sceneNodeName);
|
||||||
NIFLoader::load(mesh);
|
NIFLoader::load(mesh);
|
||||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
|
||||||
|
|
||||||
npcPart->translate(vec);
|
mNpcPart->translate(vec);
|
||||||
npcPart->rotate(axis, angle);
|
mNpcPart->rotate(axis, angle);
|
||||||
// npcPart->translate(vec);
|
// mNpcPart->translate(vec);
|
||||||
//npcPart->rotate(axis, angle);
|
//mNpcPart->rotate(axis, angle);
|
||||||
npcPart->attachObject(ent);
|
mNpcPart->attachObject(ent);
|
||||||
//npcPart->
|
//mNpcPart->
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -101,30 +103,30 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
|
||||||
}
|
}
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
|
void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst){
|
||||||
|
|
||||||
assert (insert);
|
assert (mInsert);
|
||||||
//insert->
|
//mInsert->
|
||||||
Ogre::SceneNode *parent = insert;
|
Ogre::SceneNode *parent = mInsert;
|
||||||
for (int i = 0; i < elements; i++){
|
for (int i = 0; i < elements; i++){
|
||||||
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
if(sceneParent[i] != "" && parent->getChild(sceneParent[i]))
|
||||||
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneParent[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
npcPart = parent->createChildSceneNode(sceneNodeName);
|
mNpcPart = parent->createChildSceneNode(sceneNodeName);
|
||||||
MeshPtr good2 = NIFLoader::load(mesh);
|
MeshPtr good2 = NIFLoader::load(mesh);
|
||||||
|
|
||||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
|
||||||
|
|
||||||
|
|
||||||
if(translateFirst){
|
if(translateFirst){
|
||||||
npcPart->translate(vec);
|
mNpcPart->translate(vec);
|
||||||
npcPart->rotate(axis, angle);
|
mNpcPart->rotate(axis, angle);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
||||||
npcPart->rotate(axis, angle);
|
mNpcPart->rotate(axis, angle);
|
||||||
npcPart->translate(vec);
|
mNpcPart->translate(vec);
|
||||||
}
|
}
|
||||||
npcPart->attachObject(ent);
|
mNpcPart->attachObject(ent);
|
||||||
|
|
||||||
Ogre::MeshManager *m = MeshManager::getSingletonPtr();
|
Ogre::MeshManager *m = MeshManager::getSingletonPtr();
|
||||||
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
|
const std::string beast1 ="meshes\\b\\B_N_Khajiit_F_Skins.nif";
|
||||||
|
@ -182,8 +184,8 @@ void ExteriorCellRender::insertMesh(const std::string &mesh, Ogre::Vector3 vec,
|
||||||
|
|
||||||
void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
|
void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements)
|
||||||
{
|
{
|
||||||
assert(insert);
|
assert(mInsert);
|
||||||
Ogre::SceneNode *parent = insert;
|
Ogre::SceneNode *parent = mInsert;
|
||||||
//std::cout << "ELEMENTS:" << elements;
|
//std::cout << "ELEMENTS:" << elements;
|
||||||
for (int i = 0; i < elements; i++){
|
for (int i = 0; i < elements; i++){
|
||||||
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
|
||||||
|
@ -197,19 +199,34 @@ void ExteriorCellRender::scaleMesh(Ogre::Vector3 axis, std::string sceneNodeNam
|
||||||
|
|
||||||
void ExteriorCellRender::insertMesh(const std::string &mesh)
|
void ExteriorCellRender::insertMesh(const std::string &mesh)
|
||||||
{
|
{
|
||||||
assert (insert);
|
assert (mInsert);
|
||||||
|
|
||||||
NIFLoader::load(mesh);
|
NIFLoader::load(mesh);
|
||||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
MovableObject *ent = mScene.getMgr()->createEntity(mesh);
|
||||||
insert->attachObject(ent);
|
mInsert->attachObject(ent);
|
||||||
|
|
||||||
|
if (mInsertMesh.empty())
|
||||||
|
mInsertMesh = mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExteriorCellRender::insertObjectPhysics()
|
||||||
|
{
|
||||||
|
if (!mInsertMesh.empty())
|
||||||
|
mScene.addObject (mInsert->getName(), mInsertMesh, mInsert->getOrientation(),
|
||||||
|
mInsert->getScale().x, mInsert->getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExteriorCellRender::insertActorPhysics()
|
||||||
|
{
|
||||||
|
mScene.addActor (mInsert->getName(), mInsertMesh, mInsert->getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert a light related to the most recent insertBegin call.
|
// insert a light related to the most recent insertBegin call.
|
||||||
void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
|
void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
|
||||||
{
|
{
|
||||||
assert (insert);
|
assert (mInsert);
|
||||||
|
|
||||||
Ogre::Light *light = scene.getMgr()->createLight();
|
Ogre::Light *light = mScene.getMgr()->createLight();
|
||||||
light->setDiffuseColour (r, g, b);
|
light->setDiffuseColour (r, g, b);
|
||||||
|
|
||||||
float cval=0.0f, lval=0.0f, qval=0.0f;
|
float cval=0.0f, lval=0.0f, qval=0.0f;
|
||||||
|
@ -237,21 +254,21 @@ void ExteriorCellRender::insertLight(float r, float g, float b, float radius)
|
||||||
|
|
||||||
light->setAttenuation(10*radius, cval, lval, qval);
|
light->setAttenuation(10*radius, cval, lval, qval);
|
||||||
|
|
||||||
insert->attachObject(light);
|
mInsert->attachObject(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish inserting a new reference and return a handle to it.
|
// finish inserting a new reference and return a handle to it.
|
||||||
|
|
||||||
std::string ExteriorCellRender::insertEnd (bool enable)
|
std::string ExteriorCellRender::insertEnd (bool enable)
|
||||||
{
|
{
|
||||||
assert (insert);
|
assert (mInsert);
|
||||||
|
|
||||||
std::string handle = insert->getName();
|
std::string handle = mInsert->getName();
|
||||||
|
|
||||||
if (!enable)
|
if (!enable)
|
||||||
insert->setVisible (false);
|
mInsert->setVisible (false);
|
||||||
|
|
||||||
insert = 0;
|
mInsert = 0;
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -260,14 +277,14 @@ std::string ExteriorCellRender::insertEnd (bool enable)
|
||||||
|
|
||||||
void ExteriorCellRender::configureAmbient()
|
void ExteriorCellRender::configureAmbient()
|
||||||
{
|
{
|
||||||
ambientColor.setAsABGR (cell.cell->ambi.ambient);
|
mAmbientColor.setAsABGR (mCell.cell->ambi.ambient);
|
||||||
setAmbientMode();
|
setAmbientMode();
|
||||||
|
|
||||||
// Create a "sun" that shines light downwards. It doesn't look
|
// Create a "sun" that shines light downwards. It doesn't look
|
||||||
// completely right, but leave it for now.
|
// completely right, but leave it for now.
|
||||||
Ogre::Light *light = scene.getMgr()->createLight();
|
Ogre::Light *light = mScene.getMgr()->createLight();
|
||||||
Ogre::ColourValue colour;
|
Ogre::ColourValue colour;
|
||||||
colour.setAsABGR (cell.cell->ambi.sunlight);
|
colour.setAsABGR (mCell.cell->ambi.sunlight);
|
||||||
light->setDiffuseColour (colour);
|
light->setDiffuseColour (colour);
|
||||||
light->setType(Ogre::Light::LT_DIRECTIONAL);
|
light->setType(Ogre::Light::LT_DIRECTIONAL);
|
||||||
light->setDirection(0,-1,0);
|
light->setDirection(0,-1,0);
|
||||||
|
@ -277,74 +294,74 @@ void ExteriorCellRender::configureAmbient()
|
||||||
void ExteriorCellRender::configureFog()
|
void ExteriorCellRender::configureFog()
|
||||||
{
|
{
|
||||||
Ogre::ColourValue color;
|
Ogre::ColourValue color;
|
||||||
color.setAsABGR (cell.cell->ambi.fog);
|
color.setAsABGR (mCell.cell->ambi.fog);
|
||||||
|
|
||||||
float high = 4500 + 9000 * (1-cell.cell->ambi.fogDensity);
|
float high = 4500 + 9000 * (1-mCell.cell->ambi.fogDensity);
|
||||||
float low = 200;
|
float low = 200;
|
||||||
|
|
||||||
scene.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
|
mScene.getMgr()->setFog (FOG_LINEAR, color, 0, low, high);
|
||||||
scene.getCamera()->setFarClipDistance (high + 10);
|
mScene.getCamera()->setFarClipDistance (high + 10);
|
||||||
scene.getViewport()->setBackgroundColour (color);
|
mScene.getViewport()->setBackgroundColour (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExteriorCellRender::setAmbientMode()
|
void ExteriorCellRender::setAmbientMode()
|
||||||
{
|
{
|
||||||
switch (ambientMode)
|
switch (mAmbientMode)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
scene.getMgr()->setAmbientLight(ambientColor);
|
mScene.getMgr()->setAmbientLight(mAmbientColor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
||||||
scene.getMgr()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1));
|
mScene.getMgr()->setAmbientLight(0.7f*mAmbientColor + 0.3f*ColourValue(1,1,1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
scene.getMgr()->setAmbientLight(ColourValue(1,1,1));
|
mScene.getMgr()->setAmbientLight(ColourValue(1,1,1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExteriorCellRender::show()
|
void ExteriorCellRender::show()
|
||||||
{
|
{
|
||||||
base = scene.getRoot()->createChildSceneNode();
|
mBase = mScene.getRoot()->createChildSceneNode();
|
||||||
|
|
||||||
configureAmbient();
|
configureAmbient();
|
||||||
configureFog();
|
configureFog();
|
||||||
|
|
||||||
insertCell(cell, mEnvironment);
|
insertCell(mCell, mEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExteriorCellRender::hide()
|
void ExteriorCellRender::hide()
|
||||||
{
|
{
|
||||||
if(base)
|
if(mBase)
|
||||||
base->setVisible(false);
|
mBase->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExteriorCellRender::destroy()
|
void ExteriorCellRender::destroy()
|
||||||
{
|
{
|
||||||
if(base)
|
if(mBase)
|
||||||
{
|
{
|
||||||
base->removeAndDestroyAllChildren();
|
mBase->removeAndDestroyAllChildren();
|
||||||
scene.getMgr()->destroySceneNode(base);
|
mScene.getMgr()->destroySceneNode(mBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
base = NULL;
|
mBase = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch through lighting modes.
|
// Switch through lighting modes.
|
||||||
|
|
||||||
void ExteriorCellRender::toggleLight()
|
void ExteriorCellRender::toggleLight()
|
||||||
{
|
{
|
||||||
if (ambientMode==2)
|
if (mAmbientMode==2)
|
||||||
ambientMode = 0;
|
mAmbientMode = 0;
|
||||||
else
|
else
|
||||||
++ambientMode;
|
++mAmbientMode;
|
||||||
|
|
||||||
switch (ambientMode)
|
switch (mAmbientMode)
|
||||||
{
|
{
|
||||||
case 0: std::cout << "Setting lights to normal\n"; break;
|
case 0: std::cout << "Setting lights to normal\n"; break;
|
||||||
case 1: std::cout << "Turning the lights up\n"; break;
|
case 1: std::cout << "Turning the lights up\n"; break;
|
||||||
|
@ -357,21 +374,21 @@ void ExteriorCellRender::toggleLight()
|
||||||
void ExteriorCellRender::enable (const std::string& handle)
|
void ExteriorCellRender::enable (const std::string& handle)
|
||||||
{
|
{
|
||||||
if (!handle.empty())
|
if (!handle.empty())
|
||||||
scene.getMgr()->getSceneNode (handle)->setVisible (true);
|
mScene.getMgr()->getSceneNode (handle)->setVisible (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExteriorCellRender::disable (const std::string& handle)
|
void ExteriorCellRender::disable (const std::string& handle)
|
||||||
{
|
{
|
||||||
if (!handle.empty())
|
if (!handle.empty())
|
||||||
scene.getMgr()->getSceneNode (handle)->setVisible (false);
|
mScene.getMgr()->getSceneNode (handle)->setVisible (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExteriorCellRender::deleteObject (const std::string& handle)
|
void ExteriorCellRender::deleteObject (const std::string& handle)
|
||||||
{
|
{
|
||||||
if (!handle.empty())
|
if (!handle.empty())
|
||||||
{
|
{
|
||||||
Ogre::SceneNode *node = scene.getMgr()->getSceneNode (handle);
|
Ogre::SceneNode *node = mScene.getMgr()->getSceneNode (handle);
|
||||||
node->removeAndDestroyAllChildren();
|
node->removeAndDestroyAllChildren();
|
||||||
scene.getMgr()->destroySceneNode (node);
|
mScene.getMgr()->destroySceneNode (node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,21 +45,22 @@ namespace MWRender
|
||||||
|
|
||||||
static bool lightOutQuadInLin;
|
static bool lightOutQuadInLin;
|
||||||
|
|
||||||
ESMS::CellStore<MWWorld::RefData> &cell;
|
ESMS::CellStore<MWWorld::RefData> &mCell;
|
||||||
MWWorld::Environment &mEnvironment;
|
MWWorld::Environment &mEnvironment;
|
||||||
MWScene &scene;
|
MWScene &mScene;
|
||||||
|
|
||||||
/// The scene node that contains all objects belonging to this
|
/// The scene node that contains all objects belonging to this
|
||||||
/// cell.
|
/// cell.
|
||||||
Ogre::SceneNode *base;
|
Ogre::SceneNode *mBase;
|
||||||
|
|
||||||
Ogre::SceneNode *insert;
|
Ogre::SceneNode *mInsert;
|
||||||
Ogre::SceneNode *npcPart;
|
std::string mInsertMesh;
|
||||||
|
Ogre::SceneNode *mNpcPart;
|
||||||
|
|
||||||
// 0 normal, 1 more bright, 2 max
|
// 0 normal, 1 more bright, 2 max
|
||||||
int ambientMode;
|
int mAmbientMode;
|
||||||
|
|
||||||
Ogre::ColourValue ambientColor;
|
Ogre::ColourValue mAmbientColor;
|
||||||
|
|
||||||
/// start inserting a new reference.
|
/// start inserting a new reference.
|
||||||
virtual void insertBegin (ESM::CellRef &ref);
|
virtual void insertBegin (ESM::CellRef &ref);
|
||||||
|
@ -72,6 +73,10 @@ namespace MWRender
|
||||||
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
|
||||||
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
|
||||||
|
|
||||||
|
virtual void insertObjectPhysics();
|
||||||
|
|
||||||
|
virtual void insertActorPhysics();
|
||||||
|
|
||||||
/// insert a light related to the most recent insertBegin call.
|
/// insert a light related to the most recent insertBegin call.
|
||||||
virtual void insertLight(float r, float g, float b, float radius);
|
virtual void insertLight(float r, float g, float b, float radius);
|
||||||
|
|
||||||
|
@ -91,7 +96,7 @@ namespace MWRender
|
||||||
|
|
||||||
ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
|
ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell, MWWorld::Environment& environment,
|
||||||
MWScene &_scene)
|
MWScene &_scene)
|
||||||
: cell(_cell), mEnvironment (environment), scene(_scene), base(NULL), insert(NULL), ambientMode (0) {}
|
: mCell(_cell), mEnvironment (environment), mScene(_scene), mBase(NULL), mInsert(NULL), mAmbientMode (0) {}
|
||||||
|
|
||||||
virtual ~ExteriorCellRender() { destroy(); }
|
virtual ~ExteriorCellRender() { destroy(); }
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ void InteriorCellRender::insertBegin (ESM::CellRef &ref)
|
||||||
|
|
||||||
// Rotates first around z, then y, then x
|
// Rotates first around z, then y, then x
|
||||||
insert->setOrientation(xr*yr*zr);
|
insert->setOrientation(xr*yr*zr);
|
||||||
|
|
||||||
|
mInsertMesh.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert a mesh related to the most recent insertBegin call.
|
// insert a mesh related to the most recent insertBegin call.
|
||||||
|
@ -185,6 +187,21 @@ void InteriorCellRender::insertMesh(const std::string &mesh)
|
||||||
NIFLoader::load(mesh);
|
NIFLoader::load(mesh);
|
||||||
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
MovableObject *ent = scene.getMgr()->createEntity(mesh);
|
||||||
insert->attachObject(ent);
|
insert->attachObject(ent);
|
||||||
|
|
||||||
|
if (mInsertMesh.empty())
|
||||||
|
mInsertMesh = mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteriorCellRender::insertObjectPhysics()
|
||||||
|
{
|
||||||
|
if (!mInsertMesh.empty())
|
||||||
|
scene.addObject (insert->getName(), mInsertMesh, insert->getOrientation(),
|
||||||
|
insert->getScale().x, insert->getPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
void InteriorCellRender::insertActorPhysics()
|
||||||
|
{
|
||||||
|
scene.addActor (insert->getName(), mInsertMesh, insert->getPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert a light related to the most recent insertBegin call.
|
// insert a light related to the most recent insertBegin call.
|
||||||
|
|
|
@ -54,6 +54,7 @@ namespace MWRender
|
||||||
Ogre::SceneNode *base;
|
Ogre::SceneNode *base;
|
||||||
|
|
||||||
Ogre::SceneNode *insert;
|
Ogre::SceneNode *insert;
|
||||||
|
std::string mInsertMesh;
|
||||||
Ogre::SceneNode *npcPart;
|
Ogre::SceneNode *npcPart;
|
||||||
|
|
||||||
// 0 normal, 1 more bright, 2 max
|
// 0 normal, 1 more bright, 2 max
|
||||||
|
@ -69,6 +70,11 @@ namespace MWRender
|
||||||
virtual void insertMesh(const std::string &mesh);
|
virtual void insertMesh(const std::string &mesh);
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
|
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);
|
||||||
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
|
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements, bool translateFirst);
|
||||||
|
|
||||||
|
virtual void insertObjectPhysics();
|
||||||
|
|
||||||
|
virtual void insertActorPhysics();
|
||||||
|
|
||||||
/// insert a light related to the most recent insertBegin call.
|
/// insert a light related to the most recent insertBegin call.
|
||||||
virtual void insertLight(float r, float g, float b, float radius);
|
virtual void insertLight(float r, float g, float b, float radius);
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,18 @@
|
||||||
|
|
||||||
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
|
#include "../mwworld/world.hpp" // these includes can be removed once the static-hack is gone
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include "../mwworld/doingphysics.hpp"
|
||||||
#include <components/esm/loadstat.hpp>
|
#include <components/esm/loadstat.hpp>
|
||||||
|
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
using namespace MWRender;
|
using namespace MWRender;
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
|
|
||||||
MWScene::MWScene(OEngine::Render::OgreRenderer &_rend)
|
MWScene::MWScene(OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng)
|
||||||
: rend(_rend)
|
: rend(_rend)
|
||||||
{
|
{
|
||||||
|
eng = physEng;
|
||||||
rend.createScene("PlayerCam", 55, 5);
|
rend.createScene("PlayerCam", 55, 5);
|
||||||
|
|
||||||
// Set default mipmap level (NB some APIs ignore this)
|
// Set default mipmap level (NB some APIs ignore this)
|
||||||
|
@ -38,53 +42,187 @@ MWScene::MWScene(OEngine::Render::OgreRenderer &_rend)
|
||||||
|
|
||||||
//used to obtain ingame information of ogre objects (which are faced or selected)
|
//used to obtain ingame information of ogre objects (which are faced or selected)
|
||||||
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
mRaySceneQuery = rend.getScene()->createRayQuery(Ray());
|
||||||
|
|
||||||
|
Ogre::SceneNode *playerNode = mwRoot->createChildSceneNode();
|
||||||
|
playerNode->pitch(Degree(90));
|
||||||
|
Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode();
|
||||||
|
Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode();
|
||||||
|
cameraPitchNode->attachObject(getCamera());
|
||||||
|
|
||||||
|
|
||||||
|
mPlayer = new MWRender::Player (getCamera(), playerNode->getName());
|
||||||
|
|
||||||
|
mFreeFly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWScene::~MWScene()
|
||||||
|
{
|
||||||
|
delete mPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
|
std::pair<std::string, float> MWScene::getFacedHandle (MWWorld::World& world)
|
||||||
{
|
{
|
||||||
std::string handle = "";
|
std::string handle = "";
|
||||||
float distance = -1;
|
|
||||||
|
|
||||||
//get a ray pointing to the center of the viewport
|
//get a ray pointing to the center of the viewport
|
||||||
Ray centerRay = getCamera()->getCameraToViewportRay(
|
Ray centerRay = getCamera()->getCameraToViewportRay(
|
||||||
getViewport()->getWidth()/2,
|
getViewport()->getWidth()/2,
|
||||||
getViewport()->getHeight()/2);
|
getViewport()->getHeight()/2);
|
||||||
|
//let's avoid the capsule shape of the player.
|
||||||
|
centerRay.setOrigin(centerRay.getOrigin() + 20*centerRay.getDirection());
|
||||||
|
btVector3 from(centerRay.getOrigin().x,-centerRay.getOrigin().z,centerRay.getOrigin().y);
|
||||||
|
btVector3 to(centerRay.getPoint(500).x,-centerRay.getPoint(500).z,centerRay.getPoint(500).y);
|
||||||
|
|
||||||
// get all objects touched by the ray
|
return eng->rayTest(from,to);
|
||||||
getRaySceneQuery()->setRay (centerRay );
|
}
|
||||||
RaySceneQueryResult &result = getRaySceneQuery()->execute();
|
|
||||||
|
|
||||||
RaySceneQueryResult::iterator nearest = result.end();
|
void MWScene::doPhysics (float duration, MWWorld::World& world,
|
||||||
|
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
|
||||||
for (RaySceneQueryResult::iterator itr = result.begin();
|
|
||||||
itr != result.end(); itr++ )
|
|
||||||
{
|
{
|
||||||
// there seem to be omnipresent objects like the caelum sky dom,
|
// stop changes to world from being reported back to the physics system
|
||||||
// the distance of these objects is always 0 so this if excludes these
|
MWWorld::DoingPhysics scopeGuard;
|
||||||
if ( itr->movable && itr->distance >= 0.1)
|
|
||||||
|
//set the DebugRenderingMode. To disable it,set it to 0
|
||||||
|
//eng->setDebugRenderingMode(1);
|
||||||
|
|
||||||
|
//set the walkdirection to 0 (no movement) for every actor)
|
||||||
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
|
||||||
{
|
{
|
||||||
// horrible hack to exclude statics. this must be removed as soon as a replacement for the
|
OEngine::Physic::PhysicActor* act = it->second;
|
||||||
// AABB raycasting is implemented (we should not ignore statics)
|
act->setWalkDirection(btVector3(0,0,0));
|
||||||
MWWorld::Ptr ptr = world.getPtrViaHandle (itr->movable->getParentSceneNode()->getName());
|
}
|
||||||
if (ptr.getType()==typeid (ESM::Static))
|
|
||||||
|
for (std::vector<std::pair<std::string, Ogre::Vector3> >::const_iterator iter (actors.begin());
|
||||||
|
iter!=actors.end(); ++iter)
|
||||||
|
{
|
||||||
|
OEngine::Physic::PhysicActor* act = eng->getCharacter(iter->first);
|
||||||
|
|
||||||
|
//dirty stuff to get the camera orientation. Must be changed!
|
||||||
|
|
||||||
|
Ogre::SceneNode *sceneNode = rend.getScene()->getSceneNode (iter->first);
|
||||||
|
Ogre::Vector3 dir;
|
||||||
|
Ogre::Node* yawNode = sceneNode->getChildIterator().getNext();
|
||||||
|
Ogre::Node* pitchNode = yawNode->getChildIterator().getNext();
|
||||||
|
if(mFreeFly)
|
||||||
|
{
|
||||||
|
Ogre::Quaternion yawQuat = yawNode->getOrientation();
|
||||||
|
Ogre::Quaternion pitchQuat = pitchNode->getOrientation();
|
||||||
|
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
|
||||||
|
dir = 0.07*(yawQuat*pitchQuat*dir1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ogre::Quaternion quat = yawNode->getOrientation();
|
||||||
|
Ogre::Vector3 dir1(iter->second.x,iter->second.z,-iter->second.y);
|
||||||
|
dir = 0.025*(quat*dir1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//set the walk direction
|
||||||
|
act->setWalkDirection(btVector3(dir.x,-dir.z,dir.y));
|
||||||
|
}
|
||||||
|
eng->stepSimulation(duration);
|
||||||
|
|
||||||
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
|
||||||
|
{
|
||||||
|
OEngine::Physic::PhysicActor* act = it->second;
|
||||||
|
btVector3 newPos = act->getPosition();
|
||||||
|
MWWorld::Ptr ptr = world.getPtrViaHandle (it->first);
|
||||||
|
world.moveObject (ptr, newPos.x(), newPos.y(), newPos.z());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::addObject (const std::string& handle, const std::string& mesh,
|
||||||
|
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position)
|
||||||
|
{
|
||||||
|
OEngine::Physic::RigidBody* body = eng->createRigidBody(mesh,handle);
|
||||||
|
eng->addRigidBody(body);
|
||||||
|
btTransform tr;
|
||||||
|
tr.setOrigin(btVector3(position.x,position.y,position.z));
|
||||||
|
tr.setRotation(btQuaternion(rotation.x,rotation.y,rotation.z,rotation.w));
|
||||||
|
body->setWorldTransform(tr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::addActor (const std::string& handle, const std::string& mesh,
|
||||||
|
const Ogre::Vector3& position)
|
||||||
|
{
|
||||||
|
//TODO:optimize this. Searching the std::map isn't very efficient i think.
|
||||||
|
eng->addCharacter(handle);
|
||||||
|
OEngine::Physic::PhysicActor* act = eng->getCharacter(handle);
|
||||||
|
act->setPosition(btVector3(position.x,position.y,position.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::removeObject (const std::string& handle)
|
||||||
|
{
|
||||||
|
//TODO:check if actor???
|
||||||
|
eng->removeCharacter(handle);
|
||||||
|
eng->removeRigidBody(handle);
|
||||||
|
eng->deleteRigidBody(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics)
|
||||||
|
{
|
||||||
|
rend.getScene()->getSceneNode(handle)->setPosition(position);
|
||||||
|
|
||||||
|
if(updatePhysics)//TODO: is it an actor? Done?
|
||||||
|
{
|
||||||
|
if (OEngine::Physic::RigidBody* body = eng->getRigidBody(handle))
|
||||||
|
{
|
||||||
|
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||||
|
// start positions others than 0, 0, 0
|
||||||
|
btTransform tr = body->getWorldTransform();
|
||||||
|
tr.setOrigin(btVector3(position.x,position.y,position.z));
|
||||||
|
body->setWorldTransform(tr);
|
||||||
|
}
|
||||||
|
if (OEngine::Physic::PhysicActor* act = eng->getCharacter(handle))
|
||||||
|
{
|
||||||
|
// TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow
|
||||||
|
// start positions others than 0, 0, 0
|
||||||
|
act->setPosition(btVector3(position.x,position.y,position.z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::scaleObject (const std::string& handle, float scale)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::toggleCollisionMode()
|
||||||
|
{
|
||||||
|
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = eng->PhysicActorMap.begin(); it != eng->PhysicActorMap.end();it++)
|
||||||
|
{
|
||||||
|
OEngine::Physic::PhysicActor* act = it->second;
|
||||||
|
bool cmode = act->getCollisionMode();
|
||||||
|
if(cmode)
|
||||||
|
{
|
||||||
|
act->enableCollisions(false);
|
||||||
|
act->setGravity(0.);
|
||||||
|
act->setVerticalVelocity(0);
|
||||||
|
mFreeFly = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mFreeFly = false;
|
||||||
|
act->enableCollisions(true);
|
||||||
|
act->setGravity(4.);
|
||||||
|
act->setVerticalVelocity(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MWScene::toggleRenderMode (int mode)
|
||||||
|
{
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case MWWorld::World::Render_CollisionDebug:
|
||||||
|
|
||||||
|
// TODO use a proper function instead of accessing the member variable
|
||||||
|
// directly.
|
||||||
|
eng->setDebugRenderingMode (!eng->isDebugCreated);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( nearest == result.end() ) //if no object is set
|
|
||||||
{
|
|
||||||
nearest = itr;
|
|
||||||
}
|
|
||||||
else if ( itr->distance < nearest->distance )
|
|
||||||
{
|
|
||||||
nearest = itr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( nearest != result.end() )
|
|
||||||
{
|
|
||||||
handle = nearest->movable->getParentSceneNode()->getName();
|
|
||||||
distance = nearest->distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::pair<std::string, float>(handle, distance);
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <openengine/ogre/renderer.hpp>
|
#include <openengine/ogre/renderer.hpp>
|
||||||
|
#include <openengine/bullet/physic.hpp>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
|
@ -11,6 +15,8 @@ namespace Ogre
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
class SceneNode;
|
class SceneNode;
|
||||||
class RaySceneQuery;
|
class RaySceneQuery;
|
||||||
|
class Quaternion;
|
||||||
|
class Vector3;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
|
@ -20,35 +26,77 @@ namespace MWWorld
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
/** Class responsible for Morrowind-specific interfaces to OGRE.
|
class Player;
|
||||||
|
|
||||||
|
/// \brief 3D-scene (rendering and physics)
|
||||||
|
|
||||||
This might be refactored partially into a non-mw specific
|
|
||||||
counterpart in ogre/ at some point.
|
|
||||||
*/
|
|
||||||
class MWScene
|
class MWScene
|
||||||
{
|
{
|
||||||
OEngine::Render::OgreRenderer &rend;
|
OEngine::Render::OgreRenderer &rend;
|
||||||
|
|
||||||
// Root node for all objects added to the scene. This is rotated so
|
/// Root node for all objects added to the scene. This is rotated so
|
||||||
// that the OGRE coordinate system matches that used internally in
|
/// that the OGRE coordinate system matches that used internally in
|
||||||
// Morrowind.
|
/// Morrowind.
|
||||||
Ogre::SceneNode *mwRoot;
|
Ogre::SceneNode *mwRoot;
|
||||||
Ogre::RaySceneQuery *mRaySceneQuery;
|
Ogre::RaySceneQuery *mRaySceneQuery;
|
||||||
|
|
||||||
|
OEngine::Physic::PhysicEngine* eng;
|
||||||
|
|
||||||
|
MWRender::Player *mPlayer;
|
||||||
|
|
||||||
|
bool mFreeFly;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MWScene(OEngine::Render::OgreRenderer &_rend);
|
|
||||||
|
MWScene (OEngine::Render::OgreRenderer &_rend , OEngine::Physic::PhysicEngine* physEng);
|
||||||
|
|
||||||
|
~MWScene();
|
||||||
|
|
||||||
Ogre::Camera *getCamera() { return rend.getCamera(); }
|
Ogre::Camera *getCamera() { return rend.getCamera(); }
|
||||||
Ogre::SceneNode *getRoot() { return mwRoot; }
|
Ogre::SceneNode *getRoot() { return mwRoot; }
|
||||||
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
Ogre::SceneManager *getMgr() { return rend.getScene(); }
|
||||||
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
Ogre::Viewport *getViewport() { return rend.getViewport(); }
|
||||||
Ogre::RaySceneQuery *getRaySceneQuery() { return mRaySceneQuery; }
|
Ogre::RaySceneQuery *getRaySceneQuery() { return mRaySceneQuery; }
|
||||||
|
MWRender::Player *getPlayer() { return mPlayer; }
|
||||||
|
|
||||||
//gets the handle of the object the player is looking at
|
/// Gets the handle of the object the player is looking at
|
||||||
//pair<name, distance>
|
/// pair<name, distance>
|
||||||
//name is empty and distance = -1 if there is no object which
|
/// name is empty and distance = -1 if there is no object which
|
||||||
//can be faced
|
/// can be faced
|
||||||
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
std::pair<std::string, float> getFacedHandle (MWWorld::World& world);
|
||||||
|
|
||||||
|
/// Run physics simulation and modify \a world accordingly.
|
||||||
|
void doPhysics (float duration, MWWorld::World& world,
|
||||||
|
const std::vector<std::pair<std::string, Ogre::Vector3> >& actors);
|
||||||
|
|
||||||
|
/// Add object to physics system.
|
||||||
|
void addObject (const std::string& handle, const std::string& mesh,
|
||||||
|
const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position);
|
||||||
|
|
||||||
|
/// Add actor to physics system.
|
||||||
|
void addActor (const std::string& handle, const std::string& mesh,
|
||||||
|
const Ogre::Vector3& position);
|
||||||
|
|
||||||
|
/// Remove object from physic systems.
|
||||||
|
void removeObject (const std::string& handle);
|
||||||
|
|
||||||
|
/// Move object.
|
||||||
|
void moveObject (const std::string& handle, const Ogre::Vector3& position, bool updatePhysics);
|
||||||
|
|
||||||
|
/// Change object's orientation.
|
||||||
|
void rotateObject (const std::string& handle, const Ogre::Quaternion& rotation);
|
||||||
|
|
||||||
|
/// Change object's scale.
|
||||||
|
void scaleObject (const std::string& handle, float scale);
|
||||||
|
|
||||||
|
/// Toggle collision mode for player. If disabled player object should ignore
|
||||||
|
/// collisions and gravity.
|
||||||
|
void toggleCollisionMode();
|
||||||
|
|
||||||
|
/// Toggle render mode
|
||||||
|
/// \todo Using an int instead of a enum here to avoid cyclic includes. Will be fixed
|
||||||
|
/// when the mw*-refactoring is done.
|
||||||
|
void toggleRenderMode (int mode);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
apps/openmw/mwrender/player.cpp
Normal file
9
apps/openmw/mwrender/player.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
Player::Player (Ogre::Camera *camera, const std::string& handle)
|
||||||
|
: mCamera (camera), mHandle (handle)
|
||||||
|
{}
|
||||||
|
}
|
29
apps/openmw/mwrender/player.hpp
Normal file
29
apps/openmw/mwrender/player.hpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef GAME_MWRENDER_PLAYER_H
|
||||||
|
#define GAME_MWRENDER_PLAYER_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Camera;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
/// \brief Player character rendering and camera control
|
||||||
|
class Player
|
||||||
|
{
|
||||||
|
Ogre::Camera *mCamera;
|
||||||
|
std::string mHandle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Player (Ogre::Camera *camera, const std::string& handle);
|
||||||
|
|
||||||
|
Ogre::Camera *getCamera() { return mCamera; }
|
||||||
|
|
||||||
|
std::string getHandle() const { return mHandle; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,41 +0,0 @@
|
||||||
|
|
||||||
#include "playerpos.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
PlayerPos::PlayerPos (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
|
|
||||||
mCellStore (0), camera(cam), mWorld (world), mClass (0)
|
|
||||||
{
|
|
||||||
mPlayer.base = player;
|
|
||||||
mName = player->name;
|
|
||||||
mMale = !(player->flags & ESM::NPC::Female);
|
|
||||||
mRace = player->race;
|
|
||||||
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
|
|
||||||
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerPos::~PlayerPos()
|
|
||||||
{
|
|
||||||
delete mClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerPos::setPos(float x, float y, float z, bool updateCamera)
|
|
||||||
{
|
|
||||||
mWorld.moveObject (getPlayer(), x, y, z);
|
|
||||||
|
|
||||||
if (updateCamera)
|
|
||||||
camera->setPosition (Ogre::Vector3 (
|
|
||||||
mPlayer.ref.pos.pos[0],
|
|
||||||
mPlayer.ref.pos.pos[2],
|
|
||||||
-mPlayer.ref.pos.pos[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerPos::setClass (const ESM::Class& class_)
|
|
||||||
{
|
|
||||||
ESM::Class *new_class = new ESM::Class (class_);
|
|
||||||
delete mClass;
|
|
||||||
mClass = new_class;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,128 +0,0 @@
|
||||||
#ifndef _MWRENDER_PLAYERPOS_H
|
|
||||||
#define _MWRENDER_PLAYERPOS_H
|
|
||||||
|
|
||||||
#include "OgreCamera.h"
|
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
|
||||||
|
|
||||||
#include "../mwworld/refdata.hpp"
|
|
||||||
#include "../mwworld/ptr.hpp"
|
|
||||||
|
|
||||||
namespace MWWorld
|
|
||||||
{
|
|
||||||
class World;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWRender
|
|
||||||
{
|
|
||||||
// This class keeps track of the player position. It takes care of
|
|
||||||
// camera movement, sound listener updates, and collision handling
|
|
||||||
// (to be done).
|
|
||||||
class PlayerPos
|
|
||||||
{
|
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
|
|
||||||
MWWorld::Ptr::CellStore *mCellStore;
|
|
||||||
Ogre::Camera *camera;
|
|
||||||
MWWorld::World& mWorld;
|
|
||||||
std::string mName;
|
|
||||||
bool mMale;
|
|
||||||
std::string mRace;
|
|
||||||
std::string mBirthsign;
|
|
||||||
ESM::Class *mClass;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world);
|
|
||||||
|
|
||||||
~PlayerPos();
|
|
||||||
|
|
||||||
// Set the player position. Uses Morrowind coordinates.
|
|
||||||
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
|
||||||
|
|
||||||
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
|
||||||
{
|
|
||||||
mCellStore = cellStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Camera *getCamera() { return camera; }
|
|
||||||
|
|
||||||
// Move the player relative to her own position and
|
|
||||||
// orientation. After the call, the new position is returned.
|
|
||||||
void moveRel(float &relX, float &relY, float &relZ)
|
|
||||||
{
|
|
||||||
using namespace Ogre;
|
|
||||||
|
|
||||||
// Move camera relative to its own direction
|
|
||||||
camera->moveRelative(Vector3(relX,0,relZ));
|
|
||||||
|
|
||||||
// Up/down movement is always done relative the world axis.
|
|
||||||
camera->move(Vector3(0,relY,0));
|
|
||||||
|
|
||||||
// Get new camera position, converting back to MW coords.
|
|
||||||
Vector3 pos = camera->getPosition();
|
|
||||||
relX = pos[0];
|
|
||||||
relY = -pos[2];
|
|
||||||
relZ = pos[1];
|
|
||||||
|
|
||||||
// TODO: Collision detection must be used to find the REAL new
|
|
||||||
// position.
|
|
||||||
|
|
||||||
// Set the position
|
|
||||||
setPos(relX, relY, relZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Ptr getPlayer()
|
|
||||||
{
|
|
||||||
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setName (const std::string& name)
|
|
||||||
{
|
|
||||||
mName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setGender (bool male)
|
|
||||||
{
|
|
||||||
mMale = male;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRace (const std::string& race)
|
|
||||||
{
|
|
||||||
mRace = race;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBirthsign (const std::string& birthsign)
|
|
||||||
{
|
|
||||||
mBirthsign = birthsign;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setClass (const ESM::Class& class_);
|
|
||||||
|
|
||||||
std::string getName() const
|
|
||||||
{
|
|
||||||
return mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMale() const
|
|
||||||
{
|
|
||||||
return mMale;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getRace() const
|
|
||||||
{
|
|
||||||
return mRace;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getBirthsign() const
|
|
||||||
{
|
|
||||||
return mBirthsign;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ESM::Class& getClass() const
|
|
||||||
{
|
|
||||||
return *mClass;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -19,7 +19,8 @@ namespace MWRender
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CaelumManager (Ogre::RenderWindow* pRenderWindow,
|
CaelumManager (Ogre::RenderWindow* pRenderWindow,
|
||||||
Ogre::Camera* pCamera);
|
Ogre::Camera* pCamera,
|
||||||
|
const boost::filesystem::path& resDir);
|
||||||
virtual ~CaelumManager ();
|
virtual ~CaelumManager ();
|
||||||
|
|
||||||
virtual void enable() {}
|
virtual void enable() {}
|
||||||
|
@ -44,7 +45,8 @@ namespace MWRender
|
||||||
};
|
};
|
||||||
|
|
||||||
CaelumManager::CaelumManager (Ogre::RenderWindow* pRenderWindow,
|
CaelumManager::CaelumManager (Ogre::RenderWindow* pRenderWindow,
|
||||||
Ogre::Camera* pCamera)
|
Ogre::Camera* pCamera,
|
||||||
|
const boost::filesystem::path& resDir)
|
||||||
: mpCaelumSystem (NULL)
|
: mpCaelumSystem (NULL)
|
||||||
{
|
{
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
|
@ -55,7 +57,7 @@ namespace MWRender
|
||||||
|
|
||||||
// Load the Caelum resources
|
// Load the Caelum resources
|
||||||
//
|
//
|
||||||
ResourceGroupManager::getSingleton().addResourceLocation("resources/caelum", "FileSystem", "Caelum");
|
ResourceGroupManager::getSingleton().addResourceLocation((resDir / "caelum").string(), "FileSystem", "Caelum");
|
||||||
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
||||||
|
|
||||||
// Load the Caelum resources
|
// Load the Caelum resources
|
||||||
|
@ -89,13 +91,14 @@ namespace MWRender
|
||||||
/// \return NULL on failure.
|
/// \return NULL on failure.
|
||||||
///
|
///
|
||||||
SkyManager* SkyManager::create (Ogre::RenderWindow* pRenderWindow,
|
SkyManager* SkyManager::create (Ogre::RenderWindow* pRenderWindow,
|
||||||
Ogre::Camera* pCamera)
|
Ogre::Camera* pCamera,
|
||||||
|
const boost::filesystem::path& resDir)
|
||||||
{
|
{
|
||||||
SkyManager* pSkyManager = NULL;
|
SkyManager* pSkyManager = NULL;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pSkyManager = new CaelumManager(pRenderWindow, pCamera);
|
pSkyManager = new CaelumManager(pRenderWindow, pCamera, resDir);
|
||||||
}
|
}
|
||||||
catch (Ogre::Exception& e)
|
catch (Ogre::Exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef _GAME_RENDER_SKY_H
|
#ifndef _GAME_RENDER_SKY_H
|
||||||
#define _GAME_RENDER_SKY_H
|
#define _GAME_RENDER_SKY_H
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
class RenderWindow;
|
class RenderWindow;
|
||||||
|
@ -16,7 +18,8 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static SkyManager* create (Ogre::RenderWindow* pRenderWindow,
|
static SkyManager* create (Ogre::RenderWindow* pRenderWindow,
|
||||||
Ogre::Camera* pCamera);
|
Ogre::Camera* pCamera,
|
||||||
|
const boost::filesystem::path& resDir);
|
||||||
virtual ~SkyManager() {}
|
virtual ~SkyManager() {}
|
||||||
|
|
||||||
virtual void enable() = 0;
|
virtual void enable() = 0;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -15,46 +16,14 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Ai
|
namespace Ai
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpAiTravel : public Interpreter::Opcode1
|
class OpAiTravel : public Interpreter::Opcode1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float y = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float z = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
|
||||||
|
|
||||||
std::cout << "AiTravel: " << x << ", " << y << ", " << z << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpAiTravelExplicit : public Interpreter::Opcode1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
Interpreter::Type_Float x = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
@ -72,56 +41,14 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpAiEscort : public Interpreter::Opcode1
|
class OpAiEscort : public Interpreter::Opcode1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float duration = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float x = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float y = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float z = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
// discard additional arguments (reset), because we have no idea what they mean.
|
|
||||||
for (unsigned int i=0; i<arg0; ++i) runtime.pop();
|
|
||||||
|
|
||||||
std::cout << "AiEscort: " << x << ", " << y << ", " << z << ", " << duration
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpAiEscortExplicit : public Interpreter::Opcode1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string actor = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
@ -146,16 +73,14 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpGetAiPackageDone : public Interpreter::Opcode0
|
class OpGetAiPackageDone : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = 0;
|
Interpreter::Type_Integer value = 0;
|
||||||
|
|
||||||
|
@ -163,25 +88,6 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpGetAiPackageDoneExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = 0;
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const int opcodeAiTravel = 0x20000;
|
const int opcodeAiTravel = 0x20000;
|
||||||
|
@ -204,12 +110,13 @@ namespace MWScript
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel);
|
interpreter.installSegment3 (opcodeAiTravel, new OpAiTravel<ImplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravelExplicit);
|
interpreter.installSegment3 (opcodeAiTravelExplicit, new OpAiTravel<ExplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort);
|
interpreter.installSegment3 (opcodeAiEscort, new OpAiEscort<ImplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscortExplicit);
|
interpreter.installSegment3 (opcodeAiEscortExplicit, new OpAiEscort<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone);
|
interpreter.installSegment5 (opcodeGetAiPackageDone, new OpGetAiPackageDone<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit, new OpGetAiPackageDoneExplicit);
|
interpreter.installSegment5 (opcodeGetAiPackageDoneExplicit,
|
||||||
|
new OpGetAiPackageDone<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ namespace MWScript
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pos.pos[0] = pos.pos[1] = 0;
|
pos.pos[0] = pos.pos[1] = 0;
|
||||||
context.getWorld().changeCell (cell, pos);
|
context.getWorld().changeToInteriorCell (cell, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -84,9 +85,27 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpGetInterior : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
InterpreterContext& context
|
||||||
|
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
bool interior =
|
||||||
|
context.getWorld().getPlayer().getPlayer().getCell()->cell->data.flags &
|
||||||
|
ESM::Cell::Interior;
|
||||||
|
|
||||||
|
runtime.push (interior ? 1 : 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int opcodeCellChanged = 0x2000000;
|
const int opcodeCellChanged = 0x2000000;
|
||||||
const int opcodeCOC = 0x2000026;
|
const int opcodeCOC = 0x2000026;
|
||||||
const int opcodeCOE = 0x200008e;
|
const int opcodeCOE = 0x200008e;
|
||||||
|
const int opcodeGetInterior = 0x2000131;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +114,7 @@ namespace MWScript
|
||||||
extensions.registerInstruction ("centeroncell", "S", opcodeCOC);
|
extensions.registerInstruction ("centeroncell", "S", opcodeCOC);
|
||||||
extensions.registerInstruction ("coe", "ll", opcodeCOE);
|
extensions.registerInstruction ("coe", "ll", opcodeCOE);
|
||||||
extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE);
|
extensions.registerInstruction ("centeronexterior", "ll", opcodeCOE);
|
||||||
|
extensions.registerFunction ("getinterior", 'l', "", opcodeGetInterior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -102,6 +122,7 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeCellChanged, new OpCellChanged);
|
interpreter.installSegment5 (opcodeCellChanged, new OpCellChanged);
|
||||||
interpreter.installSegment5 (opcodeCOC, new OpCOC);
|
interpreter.installSegment5 (opcodeCOC, new OpCOC);
|
||||||
interpreter.installSegment5 (opcodeCOE, new OpCOE);
|
interpreter.installSegment5 (opcodeCOE, new OpCOE);
|
||||||
|
interpreter.installSegment5 (opcodeGetInterior, new OpGetInterior);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,17 +14,21 @@
|
||||||
#include "../mwworld/containerutil.hpp"
|
#include "../mwworld/containerutil.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Container
|
namespace Container
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpAddItem : public Interpreter::Opcode0
|
class OpAddItem : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
@ -37,40 +41,6 @@ namespace MWScript
|
||||||
if (count<0)
|
if (count<0)
|
||||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
|
||||||
|
|
||||||
ref.getPtr().getRefData().setCount (count);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ref.getPtr()).insertIntoContainer (ref.getPtr(),
|
|
||||||
MWWorld::Class::get (ptr).getContainerStore (ptr));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpAddItemExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
if (count<0)
|
|
||||||
throw std::runtime_error ("second argument for AddItem must be non-negative");
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
MWWorld::ManualRef ref (context.getWorld().getStore(), item);
|
||||||
|
|
||||||
ref.getPtr().getRefData().setCount (count);
|
ref.getPtr().getRefData().setCount (count);
|
||||||
|
@ -80,55 +50,21 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpGetItemCount : public Interpreter::Opcode0
|
class OpGetItemCount : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
|
||||||
MWWorld::Class::get (ptr).getContainerStore (ptr),
|
|
||||||
context.getWorld().getStore(), list);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer sum = 0;
|
|
||||||
|
|
||||||
for (std::vector<MWWorld::Ptr>::iterator iter (list.begin()); iter!=list.end();
|
|
||||||
++iter)
|
|
||||||
{
|
|
||||||
sum += iter->getRefData().getCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
runtime.push (sum);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetItemCountExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
std::vector<MWWorld::Ptr> list;
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
MWWorld::listItemsInContainer (item,
|
||||||
|
@ -147,12 +83,15 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpRemoveItem : public Interpreter::Opcode0
|
class OpRemoveItem : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
@ -165,58 +104,6 @@ namespace MWScript
|
||||||
if (count<0)
|
if (count<0)
|
||||||
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
|
||||||
MWWorld::Class::get (ptr).getContainerStore (ptr),
|
|
||||||
context.getWorld().getStore(), list);
|
|
||||||
|
|
||||||
for (std::vector<MWWorld::Ptr>::iterator iter (list.begin());
|
|
||||||
iter!=list.end() && count;
|
|
||||||
++iter)
|
|
||||||
{
|
|
||||||
if (iter->getRefData().getCount()<=count)
|
|
||||||
{
|
|
||||||
count -= iter->getRefData().getCount();
|
|
||||||
iter->getRefData().setCount (0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter->getRefData().setCount (iter->getRefData().getCount()-count);
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// To be fully compatible with original Morrowind, we would need to check if
|
|
||||||
// count is >= 0 here and throw an exception. But let's be tollerant instead.
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpRemoveItemExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string item = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer count = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
if (count<0)
|
|
||||||
throw std::runtime_error ("second argument for RemoveItem must be non-negative");
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
std::vector<MWWorld::Ptr> list;
|
std::vector<MWWorld::Ptr> list;
|
||||||
|
|
||||||
MWWorld::listItemsInContainer (item,
|
MWWorld::listItemsInContainer (item,
|
||||||
|
@ -262,12 +149,12 @@ namespace MWScript
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeAddItem, new OpAddItem);
|
interpreter.installSegment5 (opcodeAddItem, new OpAddItem<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItemExplicit);
|
interpreter.installSegment5 (opcodeAddItemExplicit, new OpAddItem<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount);
|
interpreter.installSegment5 (opcodeGetItemCount, new OpGetItemCount<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCountExplicit);
|
interpreter.installSegment5 (opcodeGetItemCountExplicit, new OpGetItemCount<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem);
|
interpreter.installSegment5 (opcodeRemoveItem, new OpRemoveItem<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItemExplicit);
|
interpreter.installSegment5 (opcodeRemoveItemExplicit, new OpRemoveItem<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -35,10 +37,24 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class OpToggleCollision : public Interpreter::Opcode0
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
|
{
|
||||||
|
InterpreterContext& context
|
||||||
|
= static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
context.getWorld().toggleCollisionMode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const int numberOfControls = 7;
|
const int numberOfControls = 7;
|
||||||
|
|
||||||
const int opcodeEnable = 0x200007e;
|
const int opcodeEnable = 0x200007e;
|
||||||
const int opcodeDisable = 0x2000085;
|
const int opcodeDisable = 0x2000085;
|
||||||
|
const int opcodeToggleCollision = 0x2000130;
|
||||||
|
|
||||||
const char *controls[numberOfControls] =
|
const char *controls[numberOfControls] =
|
||||||
{
|
{
|
||||||
|
@ -56,6 +72,8 @@ namespace MWScript
|
||||||
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
extensions.registerInstruction (enable + controls[i], "", opcodeEnable+i);
|
||||||
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
extensions.registerInstruction (disable + controls[i], "", opcodeDisable+i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extensions.registerInstruction ("togglecollision", "", opcodeToggleCollision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -65,6 +83,8 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
interpreter.installSegment5 (opcodeEnable+i, new OpSetControl (controls[i], true));
|
||||||
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
interpreter.installSegment5 (opcodeDisable+i, new OpSetControl (controls[i], false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interpreter.installSegment5 (opcodeToggleCollision, new OpToggleCollision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,4 +101,7 @@ op 0x20000c4-0x20000de: SetSkill
|
||||||
op 0x20000df-0x20000f9: SetSkill, explicit reference
|
op 0x20000df-0x20000f9: SetSkill, explicit reference
|
||||||
op 0x20000fa-0x2000114: ModSkill
|
op 0x20000fa-0x2000114: ModSkill
|
||||||
op 0x2000115-0x200012f: ModSKill, explicit reference
|
op 0x2000115-0x200012f: ModSKill, explicit reference
|
||||||
opcodes 0x2000130-0x3ffffff unused
|
op 0x2000130: ToggleCollision
|
||||||
|
op 0x2000131: GetInterior
|
||||||
|
op 0x2000132: ToggleCollsionDebug
|
||||||
|
opcodes 0x2000133-0x3ffffff unused
|
||||||
|
|
|
@ -7,10 +7,11 @@
|
||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Misc
|
namespace Misc
|
||||||
|
@ -55,42 +56,14 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpLock : public Interpreter::Opcode1
|
class OpLock : public Interpreter::Opcode1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer lockLevel = 100;
|
|
||||||
|
|
||||||
if (arg0==1)
|
|
||||||
{
|
|
||||||
lockLevel = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).lock (ptr, lockLevel);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpLockExplicit : public Interpreter::Opcode1
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0)
|
|
||||||
{
|
|
||||||
InterpreterContext& context =
|
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer lockLevel = 100;
|
Interpreter::Type_Integer lockLevel = 100;
|
||||||
|
|
||||||
|
@ -104,22 +77,20 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpUnlock : public Interpreter::Opcode0
|
class OpUnlock : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
InterpreterContext& context =
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).unlock (ptr);
|
MWWorld::Class::get (ptr).unlock (ptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpUnlockExplicit : public Interpreter::Opcode0
|
class OpToggleCollisionDebug : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -128,16 +99,10 @@ namespace MWScript
|
||||||
InterpreterContext& context =
|
InterpreterContext& context =
|
||||||
static_cast<InterpreterContext&> (runtime.getContext());
|
static_cast<InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
context.getWorld().toggleRenderMode (MWWorld::World::Render_CollisionDebug);
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).unlock (ptr);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const int opcodeXBox = 0x200000c;
|
const int opcodeXBox = 0x200000c;
|
||||||
const int opcodeOnActivate = 0x200000d;
|
const int opcodeOnActivate = 0x200000d;
|
||||||
const int opcodeActivate = 0x2000075;
|
const int opcodeActivate = 0x2000075;
|
||||||
|
@ -145,6 +110,7 @@ namespace MWScript
|
||||||
const int opcodeLockExplicit = 0x20005;
|
const int opcodeLockExplicit = 0x20005;
|
||||||
const int opcodeUnlock = 0x200008c;
|
const int opcodeUnlock = 0x200008c;
|
||||||
const int opcodeUnlockExplicit = 0x200008d;
|
const int opcodeUnlockExplicit = 0x200008d;
|
||||||
|
const int opcodeToggleCollisionDebug = 0x2000132;
|
||||||
|
|
||||||
void registerExtensions (Compiler::Extensions& extensions)
|
void registerExtensions (Compiler::Extensions& extensions)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +119,10 @@ namespace MWScript
|
||||||
extensions.registerInstruction ("activate", "", opcodeActivate);
|
extensions.registerInstruction ("activate", "", opcodeActivate);
|
||||||
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
|
extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit);
|
||||||
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
|
extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit);
|
||||||
|
extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionDebug);
|
||||||
|
extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug);
|
||||||
|
extensions.registerInstruction ("tcb", "", opcodeToggleCollisionDebug);
|
||||||
|
extensions.registerInstruction ("tcg", "", opcodeToggleCollisionDebug);
|
||||||
}
|
}
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
|
@ -160,10 +130,11 @@ namespace MWScript
|
||||||
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
interpreter.installSegment5 (opcodeXBox, new OpXBox);
|
||||||
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
interpreter.installSegment5 (opcodeOnActivate, new OpOnActivate);
|
||||||
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
interpreter.installSegment5 (opcodeActivate, new OpActivate);
|
||||||
interpreter.installSegment3 (opcodeLock, new OpLock);
|
interpreter.installSegment3 (opcodeLock, new OpLock<ImplicitRef>);
|
||||||
interpreter.installSegment3 (opcodeLockExplicit, new OpLockExplicit);
|
interpreter.installSegment3 (opcodeLockExplicit, new OpLock<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeUnlock, new OpUnlock);
|
interpreter.installSegment5 (opcodeUnlock, new OpUnlock<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlockExplicit);
|
interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock<ExplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeToggleCollisionDebug, new OpToggleCollisionDebug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
41
apps/openmw/mwscript/ref.hpp
Normal file
41
apps/openmw/mwscript/ref.hpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef GAME_MWSCRIPT_REF_H
|
||||||
|
#define GAME_MWSCRIPT_REF_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <components/interpreter/runtime.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
struct ExplicitRef
|
||||||
|
{
|
||||||
|
MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const
|
||||||
|
{
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
|
runtime.pop();
|
||||||
|
|
||||||
|
return context.getWorld().getPtr (id, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImplicitRef
|
||||||
|
{
|
||||||
|
MWWorld::Ptr operator() (Interpreter::Runtime& runtime) const
|
||||||
|
{
|
||||||
|
MWScript::InterpreterContext& context
|
||||||
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
return context.getReference();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,22 +7,26 @@
|
||||||
#include <components/interpreter/runtime.hpp>
|
#include <components/interpreter/runtime.hpp>
|
||||||
#include <components/interpreter/opcodes.hpp>
|
#include <components/interpreter/opcodes.hpp>
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
|
||||||
|
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
#include "../mwsound/soundmanager.hpp"
|
#include "../mwsound/soundmanager.hpp"
|
||||||
|
|
||||||
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Sound
|
namespace Sound
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpSay : public Interpreter::Opcode0
|
class OpSay : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
@ -32,21 +36,24 @@ namespace MWScript
|
||||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().say (context.getReference(), file);
|
context.getSoundManager().say (ptr, file);
|
||||||
context.messageBox (text);
|
context.messageBox (text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSayDone : public Interpreter::Opcode0
|
class OpSayDone : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().sayDone (context.getReference()));
|
runtime.push (context.getSoundManager().sayDone (ptr));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,6 +111,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpPlaySound3D : public Interpreter::Opcode0
|
class OpPlaySound3D : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
bool mLoop;
|
bool mLoop;
|
||||||
|
@ -114,17 +122,19 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (context.getReference(), sound,
|
context.getSoundManager().playSound3D (ptr, sound, 1.0, 1.0, mLoop);
|
||||||
1.0, 1.0, mLoop);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpPlaySoundVP3D : public Interpreter::Opcode0
|
class OpPlaySoundVP3D : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
bool mLoop;
|
bool mLoop;
|
||||||
|
@ -135,6 +145,8 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
@ -147,34 +159,39 @@ namespace MWScript
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (context.getReference(), sound, volume,
|
context.getSoundManager().playSound3D (ptr, sound, volume, pitch, mLoop);
|
||||||
pitch, mLoop);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpStopSound : public Interpreter::Opcode0
|
class OpStopSound : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
context.getSoundManager().stopSound3D (context.getReference(), sound);
|
context.getSoundManager().stopSound3D (ptr, sound);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpGetSoundPlaying : public Interpreter::Opcode0
|
class OpGetSoundPlaying : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
|
|
||||||
MWScript::InterpreterContext& context
|
MWScript::InterpreterContext& context
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||||
|
|
||||||
|
@ -182,143 +199,7 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||||
context.getReference(), runtime.getStringLiteral (index)));
|
ptr, runtime.getStringLiteral (index)));
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSayExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string file = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string text = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().say (context.getWorld().getPtr (id, true),
|
|
||||||
file);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSayDoneExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().sayDone (
|
|
||||||
context.getWorld().getPtr (id, true)));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpPlaySound3DExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
bool mLoop;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpPlaySound3DExplicit (bool loop) : mLoop (loop) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (
|
|
||||||
context.getWorld().getPtr (id, true), sound, 1.0, 1.0, mLoop);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpPlaySoundVP3DExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
bool mLoop;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpPlaySoundVP3DExplicit (bool loop) : mLoop (loop) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float volume = runtime[0].mFloat;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().playSound3D (
|
|
||||||
context.getWorld().getPtr (id, true), sound, volume, pitch, mLoop);
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpStopSoundExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
context.getSoundManager().stopSound3D (
|
|
||||||
context.getWorld().getPtr (id, true), sound);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetSoundPlayingExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
int index = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
|
||||||
context.getWorld().getPtr (id, true),
|
|
||||||
runtime.getStringLiteral (index)));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -366,32 +247,32 @@ namespace MWScript
|
||||||
|
|
||||||
void installOpcodes (Interpreter::Interpreter& interpreter)
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeSay, new OpSay);
|
interpreter.installSegment5 (opcodeSay, new OpSay<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeSayDone, new OpSayDone);
|
interpreter.installSegment5 (opcodeSayDone, new OpSayDone<ImplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic);
|
interpreter.installSegment5 (opcodeStreamMusic, new OpStreamMusic);
|
||||||
interpreter.installSegment5 (opcodePlaySound, new OpPlaySound);
|
interpreter.installSegment5 (opcodePlaySound, new OpPlaySound);
|
||||||
interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP);
|
interpreter.installSegment5 (opcodePlaySoundVP, new OpPlaySoundVP);
|
||||||
interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D (false));
|
interpreter.installSegment5 (opcodePlaySound3D, new OpPlaySound3D<ImplicitRef> (false));
|
||||||
interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D (false));
|
interpreter.installSegment5 (opcodePlaySound3DVP, new OpPlaySoundVP3D<ImplicitRef> (false));
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D (true));
|
interpreter.installSegment5 (opcodePlayLoopSound3D, new OpPlaySound3D<ImplicitRef> (true));
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3DVP, new OpPlaySoundVP3D (true));
|
interpreter.installSegment5 (opcodePlayLoopSound3DVP,
|
||||||
interpreter.installSegment5 (opcodeStopSound, new OpStopSound);
|
new OpPlaySoundVP3D<ImplicitRef> (true));
|
||||||
interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying);
|
interpreter.installSegment5 (opcodeStopSound, new OpStopSound<ImplicitRef>);
|
||||||
|
interpreter.installSegment5 (opcodeGetSoundPlaying, new OpGetSoundPlaying<ImplicitRef>);
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSayExplicit, new OpSayExplicit);
|
interpreter.installSegment5 (opcodeSayExplicit, new OpSay<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDoneExplicit);
|
interpreter.installSegment5 (opcodeSayDoneExplicit, new OpSayDone<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodePlaySound3DExplicit,
|
interpreter.installSegment5 (opcodePlaySound3DExplicit,
|
||||||
new OpPlaySound3DExplicit (false));
|
new OpPlaySound3D<ExplicitRef> (false));
|
||||||
interpreter.installSegment5 (opcodePlaySound3DVPExplicit,
|
interpreter.installSegment5 (opcodePlaySound3DVPExplicit,
|
||||||
new OpPlaySoundVP3DExplicit (false));
|
new OpPlaySoundVP3D<ExplicitRef> (false));
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3DExplicit,
|
interpreter.installSegment5 (opcodePlayLoopSound3DExplicit,
|
||||||
new OpPlaySound3DExplicit (true));
|
new OpPlaySound3D<ExplicitRef> (true));
|
||||||
interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit,
|
interpreter.installSegment5 (opcodePlayLoopSound3DVPExplicit,
|
||||||
new OpPlaySoundVP3DExplicit (true));
|
new OpPlaySoundVP3D<ExplicitRef> (true));
|
||||||
interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSoundExplicit);
|
interpreter.installSegment5 (opcodeStopSoundExplicit, new OpStopSound<ExplicitRef>);
|
||||||
interpreter.installSegment5 (opcodeGetSoundPlayingExplicit,
|
interpreter.installSegment5 (opcodeGetSoundPlayingExplicit,
|
||||||
new OpGetSoundPlayingExplicit);
|
new OpGetSoundPlaying<ExplicitRef>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,13 @@
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
|
#include "ref.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
namespace Stats
|
namespace Stats
|
||||||
{
|
{
|
||||||
|
template<class R>
|
||||||
class OpGetAttribute : public Interpreter::Opcode0
|
class OpGetAttribute : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -27,36 +29,7 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetAttributeExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetAttributeExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
Interpreter::Type_Integer value =
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||||
|
@ -66,6 +39,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSetAttribute : public Interpreter::Opcode0
|
class OpSetAttribute : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -76,45 +50,17 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
setModified (value, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSetAttributeExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpSetAttributeExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||||
setModified (value, 0);
|
setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpModAttribute : public Interpreter::Opcode0
|
class OpModAttribute : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -125,14 +71,11 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
value += MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
||||||
getModified();
|
getModified();
|
||||||
|
|
||||||
|
@ -141,36 +84,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModAttributeExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModAttributeExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
value +=
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mAttributes[mIndex].
|
|
||||||
setModified (value, 0, 100);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDynamic : public Interpreter::Opcode0
|
class OpGetDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -181,46 +95,7 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
|
||||||
{
|
|
||||||
// health is a special case
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getItemMaxHealth (ptr);
|
|
||||||
runtime.push (value);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
|
||||||
getCurrent();
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDynamicExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr))
|
||||||
{
|
{
|
||||||
|
@ -240,6 +115,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSetDynamic : public Interpreter::Opcode0
|
class OpSetDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -250,45 +126,17 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
|
||||||
setModified (value, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSetDynamicExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpSetDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
MWWorld::Class::get (ptr).getCreatureStats (ptr).mDynamic[mIndex].
|
||||||
setModified (value, 0);
|
setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpModDynamic : public Interpreter::Opcode0
|
class OpModDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -299,14 +147,11 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||||
|
@ -318,40 +163,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModDynamicExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setModified (
|
|
||||||
diff + stats.mDynamic[mIndex].getModified(), 0);
|
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class OpModCurrentDynamic : public Interpreter::Opcode0
|
class OpModCurrentDynamic : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -362,14 +174,11 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
||||||
|
@ -378,36 +187,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModCurrentDynamicExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModCurrentDynamicExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer diff = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer current = stats.mDynamic[mIndex].getCurrent();
|
|
||||||
|
|
||||||
stats.mDynamic[mIndex].setCurrent (diff + current);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetDynamicGetRatio : public Interpreter::Opcode0
|
class OpGetDynamicGetRatio : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -418,10 +198,7 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
|
||||||
|
@ -436,38 +213,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpGetDynamicGetRatioExplicit : public Interpreter::Opcode0
|
template<class R>
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetDynamicGetRatioExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats =
|
|
||||||
MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
|
||||||
|
|
||||||
Interpreter::Type_Float value = 0;
|
|
||||||
|
|
||||||
Interpreter::Type_Float max = stats.mDynamic[mIndex].getModified();
|
|
||||||
|
|
||||||
if (max>0)
|
|
||||||
value = stats.mDynamic[mIndex].getCurrent() / max;
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetSkill : public Interpreter::Opcode0
|
class OpGetSkill : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -478,36 +224,7 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
runtime.push (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpGetSkillExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpGetSkillExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value =
|
Interpreter::Type_Integer value =
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||||
|
@ -517,6 +234,7 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpSetSkill : public Interpreter::Opcode0
|
class OpSetSkill : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -527,45 +245,17 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
setModified (value, 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpSetSkillExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpSetSkillExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||||
setModified (value, 0);
|
setModified (value, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<class R>
|
||||||
class OpModSkill : public Interpreter::Opcode0
|
class OpModSkill : public Interpreter::Opcode0
|
||||||
{
|
{
|
||||||
int mIndex;
|
int mIndex;
|
||||||
|
@ -576,14 +266,11 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWScript::InterpreterContext& context
|
MWWorld::Ptr ptr = R()(runtime);
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
Interpreter::Type_Integer value = runtime[0].mInteger;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getReference();
|
|
||||||
|
|
||||||
value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
value += MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
||||||
getModified();
|
getModified();
|
||||||
|
|
||||||
|
@ -592,36 +279,6 @@ namespace MWScript
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpModSkillExplicit : public Interpreter::Opcode0
|
|
||||||
{
|
|
||||||
int mIndex;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
OpModSkillExplicit (int index) : mIndex (index) {}
|
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
|
||||||
{
|
|
||||||
MWScript::InterpreterContext& context
|
|
||||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
|
||||||
|
|
||||||
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
Interpreter::Type_Integer value = runtime[0].mInteger;
|
|
||||||
runtime.pop();
|
|
||||||
|
|
||||||
MWWorld::Ptr ptr = context.getWorld().getPtr (id, false);
|
|
||||||
|
|
||||||
value +=
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
getModified();
|
|
||||||
|
|
||||||
MWWorld::Class::get (ptr).getNpcStats (ptr).mSkill[mIndex].
|
|
||||||
setModified (value, 0, 100);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const int numberOfAttributes = 8;
|
const int numberOfAttributes = 8;
|
||||||
|
|
||||||
const int opcodeGetAttribute = 0x2000027;
|
const int opcodeGetAttribute = 0x2000027;
|
||||||
|
@ -729,53 +386,54 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
for (int i=0; i<numberOfAttributes; ++i)
|
for (int i=0; i<numberOfAttributes; ++i)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeGetAttribute+i, new OpGetAttribute (i));
|
interpreter.installSegment5 (opcodeGetAttribute+i, new OpGetAttribute<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetAttributeExplicit+i,
|
interpreter.installSegment5 (opcodeGetAttributeExplicit+i,
|
||||||
new OpGetAttributeExplicit (i));
|
new OpGetAttribute<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute (i));
|
interpreter.installSegment5 (opcodeSetAttribute+i, new OpSetAttribute<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeSetAttributeExplicit+i,
|
interpreter.installSegment5 (opcodeSetAttributeExplicit+i,
|
||||||
new OpSetAttributeExplicit (i));
|
new OpSetAttribute<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute (i));
|
interpreter.installSegment5 (opcodeModAttribute+i, new OpModAttribute<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModAttributeExplicit+i,
|
interpreter.installSegment5 (opcodeModAttributeExplicit+i,
|
||||||
new OpModAttributeExplicit (i));
|
new OpModAttribute<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<numberOfDynamics; ++i)
|
for (int i=0; i<numberOfDynamics; ++i)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeGetDynamic+i, new OpGetDynamic (i));
|
interpreter.installSegment5 (opcodeGetDynamic+i, new OpGetDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeGetDynamicExplicit+i,
|
||||||
new OpGetDynamicExplicit (i));
|
new OpGetDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic (i));
|
interpreter.installSegment5 (opcodeSetDynamic+i, new OpSetDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeSetDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeSetDynamicExplicit+i,
|
||||||
new OpSetDynamicExplicit (i));
|
new OpSetDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic (i));
|
interpreter.installSegment5 (opcodeModDynamic+i, new OpModDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeModDynamicExplicit+i,
|
||||||
new OpModDynamicExplicit (i));
|
new OpModDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModCurrentDynamic+i, new OpModCurrentDynamic (i));
|
interpreter.installSegment5 (opcodeModCurrentDynamic+i,
|
||||||
|
new OpModCurrentDynamic<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i,
|
interpreter.installSegment5 (opcodeModCurrentDynamicExplicit+i,
|
||||||
new OpModCurrentDynamicExplicit (i));
|
new OpModCurrentDynamic<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeGetDynamicGetRatio+i,
|
interpreter.installSegment5 (opcodeGetDynamicGetRatio+i,
|
||||||
new OpGetDynamicGetRatio (i));
|
new OpGetDynamicGetRatio<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i,
|
interpreter.installSegment5 (opcodeGetDynamicGetRatioExplicit+i,
|
||||||
new OpGetDynamicGetRatioExplicit (i));
|
new OpGetDynamicGetRatio<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<numberOfSkills; ++i)
|
for (int i=0; i<numberOfSkills; ++i)
|
||||||
{
|
{
|
||||||
interpreter.installSegment5 (opcodeGetSkill+i, new OpGetSkill (i));
|
interpreter.installSegment5 (opcodeGetSkill+i, new OpGetSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkillExplicit (i));
|
interpreter.installSegment5 (opcodeGetSkillExplicit+i, new OpGetSkill<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill (i));
|
interpreter.installSegment5 (opcodeSetSkill+i, new OpSetSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkillExplicit (i));
|
interpreter.installSegment5 (opcodeSetSkillExplicit+i, new OpSetSkill<ExplicitRef> (i));
|
||||||
|
|
||||||
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill (i));
|
interpreter.installSegment5 (opcodeModSkill+i, new OpModSkill<ImplicitRef> (i));
|
||||||
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkillExplicit (i));
|
interpreter.installSegment5 (opcodeModSkillExplicit+i, new OpModSkill<ExplicitRef> (i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,7 +312,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
MP3Lookup(dataDir / "Music/Explore/");
|
MP3Lookup(dataDir / "Music/Explore/");
|
||||||
if(useSound)
|
if(useSound)
|
||||||
mData = new SoundImpl(root, camera, store, (dataDir / "Sound").file_string());
|
mData = new SoundImpl(root, camera, store, (dataDir / "Sound").string());
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundManager::~SoundManager()
|
SoundManager::~SoundManager()
|
||||||
|
@ -349,7 +349,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
fileIter++;
|
fileIter++;
|
||||||
}
|
}
|
||||||
std::string music = fileIter->file_string();
|
std::string music = fileIter->string();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::cout << "Playing " << music << "\n";
|
std::cout << "Playing " << music << "\n";
|
||||||
|
@ -365,7 +365,11 @@ namespace MWSound
|
||||||
|
|
||||||
bool SoundManager::isMusicPlaying()
|
bool SoundManager::isMusicPlaying()
|
||||||
{
|
{
|
||||||
bool test = mData->music->isPlaying();
|
bool test = false;
|
||||||
|
if(mData && mData->music)
|
||||||
|
{
|
||||||
|
test = mData->music->isPlaying();
|
||||||
|
}
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,6 @@ namespace MWWorld
|
||||||
if (mCellName.empty())
|
if (mCellName.empty())
|
||||||
environment.mWorld->changeToExteriorCell (mPosition);
|
environment.mWorld->changeToExteriorCell (mPosition);
|
||||||
else
|
else
|
||||||
environment.mWorld->changeCell (mCellName, mPosition);
|
environment.mWorld->changeToInteriorCell (mCellName, mPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
31
apps/openmw/mwworld/cellfunctors.hpp
Normal file
31
apps/openmw/mwworld/cellfunctors.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef GAME_MWWORLD_CELLFUNCTORS_H
|
||||||
|
#define GAME_MWWORLD_CELLFUNCTORS_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "refdata.hpp"
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
class CellRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
/// List all (Ogre-)handles.
|
||||||
|
struct ListHandles
|
||||||
|
{
|
||||||
|
std::vector<std::string> mHandles;
|
||||||
|
|
||||||
|
bool operator() (ESM::CellRef& ref, RefData& data)
|
||||||
|
{
|
||||||
|
std::string handle = data.getHandle();
|
||||||
|
if (!handle.empty())
|
||||||
|
mHandles.push_back (handle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <OgreVector3.h>
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "nullaction.hpp"
|
#include "nullaction.hpp"
|
||||||
|
|
||||||
|
@ -92,6 +94,36 @@ namespace MWWorld
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Class::setForceStance (const Ptr& ptr, Stance stance, bool force) const
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("stance not supported by class");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Class::setStance (const Ptr& ptr, Stance stance, bool set) const
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("stance not supported by class");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Class::getStance (const Ptr& ptr, Stance stance, bool ignoreForce) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Class::getSpeed (const Ptr& ptr) const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWMechanics::Movement& Class::getMovementSettings (const Ptr& ptr) const
|
||||||
|
{
|
||||||
|
throw std::runtime_error ("movement settings not supported by class");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ogre::Vector3 Class::getMovementVector (const Ptr& ptr) const
|
||||||
|
{
|
||||||
|
return Ogre::Vector3 (0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
const Class& Class::get (const std::string& key)
|
const Class& Class::get (const std::string& key)
|
||||||
{
|
{
|
||||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
#include "containerstore.hpp"
|
#include "containerstore.hpp"
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Vector3;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
class CellRenderImp;
|
class CellRenderImp;
|
||||||
|
@ -19,6 +24,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
struct CreatureStats;
|
struct CreatureStats;
|
||||||
struct NpcStats;
|
struct NpcStats;
|
||||||
|
struct Movement;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
|
@ -41,6 +47,12 @@ namespace MWWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// NPC-stances.
|
||||||
|
enum Stance
|
||||||
|
{
|
||||||
|
Run, Sneak, Combat
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~Class();
|
virtual ~Class();
|
||||||
|
|
||||||
virtual std::string getId (const Ptr& ptr) const;
|
virtual std::string getId (const Ptr& ptr) const;
|
||||||
|
@ -108,6 +120,25 @@ namespace MWWorld
|
||||||
///< Return name of the script attached to ptr (default implementation: return an empty
|
///< Return name of the script attached to ptr (default implementation: return an empty
|
||||||
/// string).
|
/// string).
|
||||||
|
|
||||||
|
virtual void setForceStance (const Ptr& ptr, Stance stance, bool force) const;
|
||||||
|
///< Force or unforce a stance.
|
||||||
|
|
||||||
|
virtual void setStance (const Ptr& ptr, Stance stance, bool set) const;
|
||||||
|
///< Set or unset a stance.
|
||||||
|
|
||||||
|
virtual bool getStance (const Ptr& ptr, Stance stance, bool ignoreForce = false) const;
|
||||||
|
////< Check if a stance is active or not.
|
||||||
|
|
||||||
|
virtual float getSpeed (const Ptr& ptr) const;
|
||||||
|
///< Return movement speed.
|
||||||
|
|
||||||
|
virtual MWMechanics::Movement& getMovementSettings (const Ptr& ptr) const;
|
||||||
|
///< Return desired movement.
|
||||||
|
|
||||||
|
virtual Ogre::Vector3 getMovementVector (const Ptr& ptr) const;
|
||||||
|
///< Return desired movement vector (determined based on movement settings,
|
||||||
|
/// stance and stats).
|
||||||
|
|
||||||
static const Class& get (const std::string& key);
|
static const Class& get (const std::string& key);
|
||||||
///< If there is no class for this \a key, an exception is thrown.
|
///< If there is no class for this \a key, an exception is thrown.
|
||||||
|
|
||||||
|
|
33
apps/openmw/mwworld/doingphysics.cpp
Normal file
33
apps/openmw/mwworld/doingphysics.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
#include "doingphysics.hpp"
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
int DoingPhysics::sCounter = 0;
|
||||||
|
int DoingPhysics::sSuppress = 0;
|
||||||
|
|
||||||
|
DoingPhysics::DoingPhysics()
|
||||||
|
{
|
||||||
|
++sCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
DoingPhysics::~DoingPhysics()
|
||||||
|
{
|
||||||
|
--sCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DoingPhysics::isDoingPhysics()
|
||||||
|
{
|
||||||
|
return sCounter>0 && sSuppress==0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SuppressDoingPhysics::SuppressDoingPhysics()
|
||||||
|
{
|
||||||
|
++DoingPhysics::sSuppress;
|
||||||
|
}
|
||||||
|
|
||||||
|
SuppressDoingPhysics::~SuppressDoingPhysics()
|
||||||
|
{
|
||||||
|
--DoingPhysics::sSuppress;
|
||||||
|
}
|
||||||
|
}
|
46
apps/openmw/mwworld/doingphysics.hpp
Normal file
46
apps/openmw/mwworld/doingphysics.hpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef GAME_MWWORLD_DOINGPHYSICS_H
|
||||||
|
#define GAME_MWWORLD_DOINGPHYSICS_H
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class SuppressDoingPhysics;
|
||||||
|
|
||||||
|
/// Scope guard for blocking physics updates during physics simulation.
|
||||||
|
class DoingPhysics
|
||||||
|
{
|
||||||
|
static int sCounter;
|
||||||
|
static int sSuppress;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
DoingPhysics (const DoingPhysics&);
|
||||||
|
DoingPhysics& operator= (const DoingPhysics&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
DoingPhysics();
|
||||||
|
|
||||||
|
~DoingPhysics();
|
||||||
|
|
||||||
|
static bool isDoingPhysics();
|
||||||
|
|
||||||
|
friend class SuppressDoingPhysics;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Scope guard for temporarily lifting the block issues by DoingPhysics
|
||||||
|
class SuppressDoingPhysics
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
SuppressDoingPhysics (const SuppressDoingPhysics&);
|
||||||
|
SuppressDoingPhysics& operator= (const SuppressDoingPhysics&);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SuppressDoingPhysics();
|
||||||
|
|
||||||
|
~SuppressDoingPhysics();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
88
apps/openmw/mwworld/player.cpp
Normal file
88
apps/openmw/mwworld/player.cpp
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
|
#include "../mwrender/player.hpp"
|
||||||
|
|
||||||
|
#include "world.hpp"
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
Player::Player (MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world) :
|
||||||
|
mCellStore (0), mRenderer (renderer), mWorld (world), mClass (0),
|
||||||
|
mAutoMove (false), mForwardBackward (0)
|
||||||
|
{
|
||||||
|
mPlayer.base = player;
|
||||||
|
mName = player->name;
|
||||||
|
mMale = !(player->flags & ESM::NPC::Female);
|
||||||
|
mRace = player->race;
|
||||||
|
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
|
||||||
|
mPlayer.mData.setHandle (renderer->getHandle());
|
||||||
|
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
|
||||||
|
}
|
||||||
|
|
||||||
|
Player::~Player()
|
||||||
|
{
|
||||||
|
delete mClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setPos(float x, float y, float z, bool updateCamera)
|
||||||
|
{
|
||||||
|
mWorld.moveObject (getPlayer(), x, y, z);
|
||||||
|
|
||||||
|
if (updateCamera)
|
||||||
|
mRenderer->getCamera()->setPosition (Ogre::Vector3 (
|
||||||
|
mPlayer.ref.pos.pos[0],
|
||||||
|
mPlayer.ref.pos.pos[2],
|
||||||
|
-mPlayer.ref.pos.pos[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setClass (const ESM::Class& class_)
|
||||||
|
{
|
||||||
|
ESM::Class *new_class = new ESM::Class (class_);
|
||||||
|
delete mClass;
|
||||||
|
mClass = new_class;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setAutoMove (bool enable)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
|
|
||||||
|
mAutoMove = enable;
|
||||||
|
|
||||||
|
int value = mForwardBackward;
|
||||||
|
|
||||||
|
if (mAutoMove)
|
||||||
|
value = 1;
|
||||||
|
|
||||||
|
MWWorld::Class::get (ptr).getMovementSettings (ptr).mForwardBackward = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setLeftRight (int value)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
|
|
||||||
|
MWWorld::Class::get (ptr).getMovementSettings (ptr).mLeftRight = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::setForwardBackward (int value)
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
|
|
||||||
|
mForwardBackward = value;
|
||||||
|
|
||||||
|
if (mAutoMove)
|
||||||
|
value = 1;
|
||||||
|
|
||||||
|
MWWorld::Class::get (ptr).getMovementSettings (ptr).mForwardBackward = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::toggleRunning()
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
|
|
||||||
|
bool running = MWWorld::Class::get (ptr).getStance (ptr, MWWorld::Class::Run, true);
|
||||||
|
|
||||||
|
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running);
|
||||||
|
}
|
||||||
|
}
|
118
apps/openmw/mwworld/player.hpp
Normal file
118
apps/openmw/mwworld/player.hpp
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
#ifndef GAME_MWWORLD_PLAYER_H
|
||||||
|
#define GAME_MWWORLD_PLAYER_H
|
||||||
|
|
||||||
|
#include "OgreCamera.h"
|
||||||
|
|
||||||
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
|
||||||
|
#include "../mwworld/refdata.hpp"
|
||||||
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
|
namespace MWRender
|
||||||
|
{
|
||||||
|
class Player;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class World;
|
||||||
|
|
||||||
|
/// \brief NPC object representing the player and additional player data
|
||||||
|
class Player
|
||||||
|
{
|
||||||
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
|
||||||
|
MWWorld::Ptr::CellStore *mCellStore;
|
||||||
|
MWRender::Player *mRenderer;
|
||||||
|
MWWorld::World& mWorld;
|
||||||
|
std::string mName;
|
||||||
|
bool mMale;
|
||||||
|
std::string mRace;
|
||||||
|
std::string mBirthsign;
|
||||||
|
ESM::Class *mClass;
|
||||||
|
bool mAutoMove;
|
||||||
|
int mForwardBackward;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Player(MWRender::Player *renderer, const ESM::NPC *player, MWWorld::World& world);
|
||||||
|
|
||||||
|
~Player();
|
||||||
|
|
||||||
|
/// Set the player position. Uses Morrowind coordinates.
|
||||||
|
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
||||||
|
|
||||||
|
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
||||||
|
{
|
||||||
|
mCellStore = cellStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWWorld::Ptr getPlayer()
|
||||||
|
{
|
||||||
|
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWRender::Player *getRenderer() { return mRenderer; }
|
||||||
|
|
||||||
|
void setName (const std::string& name)
|
||||||
|
{
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setGender (bool male)
|
||||||
|
{
|
||||||
|
mMale = male;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRace (const std::string& race)
|
||||||
|
{
|
||||||
|
mRace = race;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBirthsign (const std::string& birthsign)
|
||||||
|
{
|
||||||
|
mBirthsign = birthsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setClass (const ESM::Class& class_);
|
||||||
|
|
||||||
|
std::string getName() const
|
||||||
|
{
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMale() const
|
||||||
|
{
|
||||||
|
return mMale;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getRace() const
|
||||||
|
{
|
||||||
|
return mRace;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getBirthsign() const
|
||||||
|
{
|
||||||
|
return mBirthsign;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ESM::Class& getClass() const
|
||||||
|
{
|
||||||
|
return *mClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getAutoMove()
|
||||||
|
{
|
||||||
|
return mAutoMove;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAutoMove (bool enable);
|
||||||
|
|
||||||
|
void setLeftRight (int value);
|
||||||
|
|
||||||
|
void setForwardBackward (int value);
|
||||||
|
|
||||||
|
void toggleRunning();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
|
#include "../mwmechanics/movement.hpp"
|
||||||
|
|
||||||
#include "containerstore.hpp"
|
#include "containerstore.hpp"
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ namespace MWWorld
|
||||||
// are never copied outside of container operations.
|
// are never copied outside of container operations.
|
||||||
boost::shared_ptr<MWMechanics::CreatureStats> mCreatureStats;
|
boost::shared_ptr<MWMechanics::CreatureStats> mCreatureStats;
|
||||||
boost::shared_ptr<MWMechanics::NpcStats> mNpcStats;
|
boost::shared_ptr<MWMechanics::NpcStats> mNpcStats;
|
||||||
|
boost::shared_ptr<MWMechanics::Movement> mMovement;
|
||||||
|
|
||||||
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
|
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
|
||||||
|
|
||||||
|
@ -102,6 +104,11 @@ namespace MWWorld
|
||||||
return mNpcStats;
|
return mNpcStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<MWMechanics::Movement>& getMovement()
|
||||||
|
{
|
||||||
|
return mMovement;
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore()
|
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore()
|
||||||
{
|
{
|
||||||
return mContainerStore;
|
return mContainerStore;
|
||||||
|
|
|
@ -17,10 +17,12 @@
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "environment.hpp"
|
#include "environment.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
#include "player.hpp"
|
||||||
|
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
|
#include "doingphysics.hpp"
|
||||||
|
#include "cellfunctors.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -270,6 +272,15 @@ namespace MWWorld
|
||||||
|
|
||||||
void World::unloadCell (CellRenderCollection::iterator iter)
|
void World::unloadCell (CellRenderCollection::iterator iter)
|
||||||
{
|
{
|
||||||
|
ListHandles functor;
|
||||||
|
iter->first->forEach<ListHandles>(functor);
|
||||||
|
|
||||||
|
{ // silence annoying g++ warning
|
||||||
|
for (std::vector<std::string>::const_iterator iter (functor.mHandles.begin());
|
||||||
|
iter!=functor.mHandles.end(); ++iter)
|
||||||
|
mScene.removeObject (*iter);
|
||||||
|
}
|
||||||
|
|
||||||
removeScripts (iter->first);
|
removeScripts (iter->first);
|
||||||
mEnvironment.mMechanicsManager->dropActors (iter->first);
|
mEnvironment.mMechanicsManager->dropActors (iter->first);
|
||||||
iter->second->destroy();
|
iter->second->destroy();
|
||||||
|
@ -294,14 +305,16 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position)
|
void World::playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
|
||||||
|
bool adjustPlayerPos)
|
||||||
{
|
{
|
||||||
mPlayerPos->setPos (position.pos[0], position.pos[1], position.pos[2], true);
|
if (adjustPlayerPos)
|
||||||
mPlayerPos->setCell (cell);
|
mPlayer->setPos (position.pos[0], position.pos[1], position.pos[2], false);
|
||||||
// TODO orientation
|
|
||||||
|
|
||||||
mEnvironment.mMechanicsManager->addActor (mPlayerPos->getPlayer());
|
mPlayer->setCell (cell);
|
||||||
mEnvironment.mMechanicsManager->watchActor (mPlayerPos->getPlayer());
|
// TODO orientation
|
||||||
|
mEnvironment.mMechanicsManager->addActor (mPlayer->getPlayer());
|
||||||
|
mEnvironment.mMechanicsManager->watchActor (mPlayer->getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -315,21 +328,102 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
void World::changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos)
|
||||||
const std::string& master, bool newGame, Environment& environment)
|
{
|
||||||
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
|
SuppressDoingPhysics scopeGuard;
|
||||||
|
|
||||||
|
// remove active
|
||||||
|
mEnvironment.mMechanicsManager->removeActor (mPlayer->getPlayer());
|
||||||
|
|
||||||
|
CellRenderCollection::iterator active = mActiveCells.begin();
|
||||||
|
|
||||||
|
while (active!=mActiveCells.end())
|
||||||
|
{
|
||||||
|
if (!(active->first->cell->data.flags & ESM::Cell::Interior))
|
||||||
|
{
|
||||||
|
if (std::abs (X-active->first->cell->data.gridX)<=1 &&
|
||||||
|
std::abs (Y-active->first->cell->data.gridY)<=1)
|
||||||
|
{
|
||||||
|
// keep cells within the new 3x3 grid
|
||||||
|
++active;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unloadCell (active++);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load cells
|
||||||
|
for (int x=X-1; x<=X+1; ++x)
|
||||||
|
for (int y=Y-1; y<=Y+1; ++y)
|
||||||
|
{
|
||||||
|
CellRenderCollection::iterator iter = mActiveCells.begin();
|
||||||
|
|
||||||
|
while (iter!=mActiveCells.end())
|
||||||
|
{
|
||||||
|
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
|
||||||
|
|
||||||
|
if (x==iter->first->cell->data.gridX &&
|
||||||
|
y==iter->first->cell->data.gridY)
|
||||||
|
break;
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iter==mActiveCells.end())
|
||||||
|
{
|
||||||
|
mExteriors[std::make_pair (x, y)].loadExt (x, y, mStore, mEsm);
|
||||||
|
Ptr::CellStore *cell = &mExteriors[std::make_pair (x, y)];
|
||||||
|
|
||||||
|
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mScene));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// find current cell
|
||||||
|
CellRenderCollection::iterator iter = mActiveCells.begin();
|
||||||
|
|
||||||
|
while (iter!=mActiveCells.end())
|
||||||
|
{
|
||||||
|
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
|
||||||
|
|
||||||
|
if (X==iter->first->cell->data.gridX &&
|
||||||
|
Y==iter->first->cell->data.gridY)
|
||||||
|
break;
|
||||||
|
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert (iter!=mActiveCells.end());
|
||||||
|
|
||||||
|
mCurrentCell = iter->first;
|
||||||
|
|
||||||
|
// adjust player
|
||||||
|
playerCellChange (&mExteriors[std::make_pair (X, Y)], position, adjustPlayerPos);
|
||||||
|
|
||||||
|
// Sky system
|
||||||
|
adjustSky();
|
||||||
|
|
||||||
|
mCellChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
World::World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, const boost::filesystem::path& dataDir,
|
||||||
|
const std::string& master, const boost::filesystem::path& resDir,
|
||||||
|
bool newGame, Environment& environment)
|
||||||
|
: mSkyManager (0), mScene (renderer,physEng), mPlayer (0), mCurrentCell (0), mGlobalVariables (0),
|
||||||
mSky (false), mCellChanged (false), mEnvironment (environment)
|
mSky (false), mCellChanged (false), mEnvironment (environment)
|
||||||
{
|
{
|
||||||
|
mPhysEngine = physEng;
|
||||||
boost::filesystem::path masterPath (dataDir);
|
boost::filesystem::path masterPath (dataDir);
|
||||||
masterPath /= master;
|
masterPath /= master;
|
||||||
|
|
||||||
std::cout << "Loading ESM " << masterPath.string() << "\n";
|
std::cout << "Loading ESM " << masterPath.string() << "\n";
|
||||||
|
|
||||||
// This parses the ESM file and loads a sample cell
|
// This parses the ESM file and loads a sample cell
|
||||||
mEsm.open (masterPath.file_string());
|
mEsm.open (masterPath.string());
|
||||||
mStore.load (mEsm);
|
mStore.load (mEsm);
|
||||||
|
|
||||||
mPlayerPos = new MWRender::PlayerPos (mScene.getCamera(), mStore.npcs.find ("player"), *this);
|
mPlayer = new MWWorld::Player (mScene.getPlayer(), mStore.npcs.find ("player"), *this);
|
||||||
|
mScene.addActor (mPlayer->getPlayer().getRefData().getHandle(), "", Ogre::Vector3 (0, 0, 0));
|
||||||
|
|
||||||
// global variables
|
// global variables
|
||||||
mGlobalVariables = new Globals (mStore);
|
mGlobalVariables = new Globals (mStore);
|
||||||
|
@ -341,7 +435,9 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
mSkyManager =
|
mSkyManager =
|
||||||
MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera());
|
MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera(), resDir);
|
||||||
|
|
||||||
|
mPhysEngine = physEng;
|
||||||
}
|
}
|
||||||
|
|
||||||
World::~World()
|
World::~World()
|
||||||
|
@ -354,14 +450,14 @@ namespace MWWorld
|
||||||
iter!=mBufferedCells.end(); ++iter)
|
iter!=mBufferedCells.end(); ++iter)
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
|
|
||||||
delete mPlayerPos;
|
delete mPlayer;
|
||||||
delete mSkyManager;
|
delete mSkyManager;
|
||||||
delete mGlobalVariables;
|
delete mGlobalVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWRender::PlayerPos& World::getPlayerPos()
|
MWWorld::Player& World::getPlayer()
|
||||||
{
|
{
|
||||||
return *mPlayerPos;
|
return *mPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ESMS::ESMStore& World::getStore()
|
ESMS::ESMStore& World::getStore()
|
||||||
|
@ -394,7 +490,7 @@ namespace MWWorld
|
||||||
// the player is always in an active cell.
|
// the player is always in an active cell.
|
||||||
if (name=="player")
|
if (name=="player")
|
||||||
{
|
{
|
||||||
return mPlayerPos->getPlayer();
|
return mPlayer->getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// active cells
|
// active cells
|
||||||
|
@ -417,7 +513,8 @@ namespace MWWorld
|
||||||
|
|
||||||
Ptr World::getPtrViaHandle (const std::string& handle)
|
Ptr World::getPtrViaHandle (const std::string& handle)
|
||||||
{
|
{
|
||||||
// TODO player
|
if (mPlayer->getPlayer().getRefData().getHandle()==handle)
|
||||||
|
return mPlayer->getPlayer();
|
||||||
|
|
||||||
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
for (CellRenderCollection::iterator iter (mActiveCells.begin());
|
||||||
iter!=mActiveCells.end(); ++iter)
|
iter!=mActiveCells.end(); ++iter)
|
||||||
|
@ -586,8 +683,10 @@ namespace MWWorld
|
||||||
return mGlobalVariables->getInt ("timescale");
|
return mGlobalVariables->getInt ("timescale");
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::changeCell (const std::string& cellName, const ESM::Position& position)
|
void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position)
|
||||||
{
|
{
|
||||||
|
SuppressDoingPhysics scopeGuard;
|
||||||
|
|
||||||
// remove active
|
// remove active
|
||||||
CellRenderCollection::iterator active = mActiveCells.begin();
|
CellRenderCollection::iterator active = mActiveCells.begin();
|
||||||
|
|
||||||
|
@ -613,81 +712,6 @@ namespace MWWorld
|
||||||
//currentRegion->name = "";
|
//currentRegion->name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::changeCell (int X, int Y, const ESM::Position& position)
|
|
||||||
{
|
|
||||||
// remove active
|
|
||||||
CellRenderCollection::iterator active = mActiveCells.begin();
|
|
||||||
|
|
||||||
while (active!=mActiveCells.end())
|
|
||||||
{
|
|
||||||
if (!(active->first->cell->data.flags & ESM::Cell::Interior))
|
|
||||||
{
|
|
||||||
if (std::abs (X-active->first->cell->data.gridX)<=1 &&
|
|
||||||
std::abs (Y-active->first->cell->data.gridY)<=1)
|
|
||||||
{
|
|
||||||
// keep cells within the new 3x3 grid
|
|
||||||
++active;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unloadCell (active++);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load cells
|
|
||||||
for (int x=X-1; x<=X+1; ++x)
|
|
||||||
for (int y=Y-1; y<=Y+1; ++y)
|
|
||||||
{
|
|
||||||
CellRenderCollection::iterator iter = mActiveCells.begin();
|
|
||||||
|
|
||||||
while (iter!=mActiveCells.end())
|
|
||||||
{
|
|
||||||
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
|
|
||||||
|
|
||||||
if (x==iter->first->cell->data.gridX &&
|
|
||||||
y==iter->first->cell->data.gridY)
|
|
||||||
break;
|
|
||||||
|
|
||||||
++iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iter==mActiveCells.end())
|
|
||||||
{
|
|
||||||
mExteriors[std::make_pair (x, y)].loadExt (x, y, mStore, mEsm);
|
|
||||||
Ptr::CellStore *cell = &mExteriors[std::make_pair (x, y)];
|
|
||||||
|
|
||||||
loadCell (cell, new MWRender::ExteriorCellRender (*cell, mEnvironment, mScene));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// find current cell
|
|
||||||
CellRenderCollection::iterator iter = mActiveCells.begin();
|
|
||||||
|
|
||||||
while (iter!=mActiveCells.end())
|
|
||||||
{
|
|
||||||
assert (!(iter->first->cell->data.flags & ESM::Cell::Interior));
|
|
||||||
|
|
||||||
if (X==iter->first->cell->data.gridX &&
|
|
||||||
Y==iter->first->cell->data.gridY)
|
|
||||||
break;
|
|
||||||
|
|
||||||
++iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
assert (iter!=mActiveCells.end());
|
|
||||||
|
|
||||||
mCurrentCell = iter->first;
|
|
||||||
|
|
||||||
// adjust player
|
|
||||||
playerCellChange (&mExteriors[std::make_pair (X, Y)], position);
|
|
||||||
|
|
||||||
// Sky system
|
|
||||||
adjustSky();
|
|
||||||
|
|
||||||
mCellChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void World::changeToExteriorCell (const ESM::Position& position)
|
void World::changeToExteriorCell (const ESM::Position& position)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
@ -695,7 +719,7 @@ namespace MWWorld
|
||||||
|
|
||||||
positionToIndex (position.pos[0], position.pos[1], x, y);
|
positionToIndex (position.pos[0], position.pos[1], x, y);
|
||||||
|
|
||||||
changeCell (x, y, position);
|
changeCell (x, y, position, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ESM::Cell *World::getExterior (const std::string& cellName) const
|
const ESM::Cell *World::getExterior (const std::string& cellName) const
|
||||||
|
@ -721,6 +745,7 @@ namespace MWWorld
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::markCellAsUnchanged()
|
void World::markCellAsUnchanged()
|
||||||
{
|
{
|
||||||
mCellChanged = false;
|
mCellChanged = false;
|
||||||
|
@ -745,14 +770,17 @@ namespace MWWorld
|
||||||
|
|
||||||
if (MWRender::CellRender *render = searchRender (ptr.getCell()))
|
if (MWRender::CellRender *render = searchRender (ptr.getCell()))
|
||||||
{
|
{
|
||||||
render->deleteObject (ptr.getRefData().getHandle());
|
|
||||||
ptr.getRefData().setHandle ("");
|
|
||||||
|
|
||||||
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
|
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
|
||||||
{
|
{
|
||||||
Class::get (ptr).disable (ptr, mEnvironment);
|
Class::get (ptr).disable (ptr, mEnvironment);
|
||||||
mEnvironment.mSoundManager->stopSound3D (ptr);
|
mEnvironment.mSoundManager->stopSound3D (ptr);
|
||||||
|
|
||||||
|
if (!DoingPhysics::isDoingPhysics())
|
||||||
|
mScene.removeObject (ptr.getRefData().getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render->deleteObject (ptr.getRefData().getHandle());
|
||||||
|
ptr.getRefData().setHandle ("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -763,7 +791,7 @@ namespace MWWorld
|
||||||
ptr.getCellRef().pos.pos[1] = y;
|
ptr.getCellRef().pos.pos[1] = y;
|
||||||
ptr.getCellRef().pos.pos[2] = z;
|
ptr.getCellRef().pos.pos[2] = z;
|
||||||
|
|
||||||
if (ptr==mPlayerPos->getPlayer())
|
if (ptr==mPlayer->getPlayer())
|
||||||
{
|
{
|
||||||
if (mCurrentCell)
|
if (mCurrentCell)
|
||||||
{
|
{
|
||||||
|
@ -777,12 +805,16 @@ namespace MWWorld
|
||||||
|
|
||||||
if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY)
|
if (mCurrentCell->cell->data.gridX!=cellX || mCurrentCell->cell->data.gridY!=cellY)
|
||||||
{
|
{
|
||||||
changeCell (cellX, cellY, mPlayerPos->getPlayer().getCellRef().pos);
|
changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mScene.moveObject (ptr.getRefData().getHandle(), Ogre::Vector3 (x, y, z),
|
||||||
|
!DoingPhysics::isDoingPhysics());
|
||||||
|
|
||||||
// TODO cell change for non-player ref
|
// TODO cell change for non-player ref
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,8 +832,6 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void World::positionToIndex (float x, float y, int &cellX, int &cellY) const
|
void World::positionToIndex (float x, float y, int &cellX, int &cellY) const
|
||||||
{
|
{
|
||||||
const int cellSize = 8192;
|
const int cellSize = 8192;
|
||||||
|
@ -816,4 +846,20 @@ namespace MWWorld
|
||||||
if (y<0)
|
if (y<0)
|
||||||
--cellY;
|
--cellY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
|
||||||
|
float duration)
|
||||||
|
{
|
||||||
|
mScene.doPhysics (duration, *this, actors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::toggleCollisionMode()
|
||||||
|
{
|
||||||
|
mScene.toggleCollisionMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::toggleRenderMode (RenderMode mode)
|
||||||
|
{
|
||||||
|
mScene.toggleRenderMode (mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,19 @@
|
||||||
|
|
||||||
#include <components/esm_store/cell_store.hpp>
|
#include <components/esm_store/cell_store.hpp>
|
||||||
|
|
||||||
#include "../mwrender/playerpos.hpp"
|
|
||||||
#include "../mwrender/mwscene.hpp"
|
#include "../mwrender/mwscene.hpp"
|
||||||
|
|
||||||
#include "refdata.hpp"
|
#include "refdata.hpp"
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "globals.hpp"
|
#include "globals.hpp"
|
||||||
|
|
||||||
|
#include <openengine/bullet/physic.hpp>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Vector3;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
struct Position;
|
struct Position;
|
||||||
|
@ -34,6 +40,7 @@ namespace MWRender
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Environment;
|
class Environment;
|
||||||
|
class Player;
|
||||||
|
|
||||||
/// \brief The game world and its visual representation
|
/// \brief The game world and its visual representation
|
||||||
|
|
||||||
|
@ -43,13 +50,18 @@ namespace MWWorld
|
||||||
public:
|
public:
|
||||||
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
|
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
|
||||||
|
|
||||||
|
enum RenderMode
|
||||||
|
{
|
||||||
|
Render_CollisionDebug
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
|
||||||
|
|
||||||
MWRender::SkyManager* mSkyManager;
|
MWRender::SkyManager* mSkyManager;
|
||||||
MWRender::MWScene mScene;
|
MWRender::MWScene mScene;
|
||||||
MWRender::PlayerPos *mPlayerPos;
|
MWWorld::Player *mPlayer;
|
||||||
Ptr::CellStore *mCurrentCell; // the cell, the player is in
|
Ptr::CellStore *mCurrentCell; // the cell, the player is in
|
||||||
CellRenderCollection mActiveCells;
|
CellRenderCollection mActiveCells;
|
||||||
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
|
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
|
||||||
|
@ -63,6 +75,8 @@ namespace MWWorld
|
||||||
bool mCellChanged;
|
bool mCellChanged;
|
||||||
Environment& mEnvironment;
|
Environment& mEnvironment;
|
||||||
|
|
||||||
|
OEngine::Physic::PhysicEngine* mPhysEngine;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
World (const World&);
|
World (const World&);
|
||||||
World& operator= (const World&);
|
World& operator= (const World&);
|
||||||
|
@ -83,18 +97,23 @@ namespace MWWorld
|
||||||
|
|
||||||
void loadCell (Ptr::CellStore *cell, MWRender::CellRender *render);
|
void loadCell (Ptr::CellStore *cell, MWRender::CellRender *render);
|
||||||
|
|
||||||
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position);
|
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position,
|
||||||
|
bool adjustPlayerPos = true);
|
||||||
|
|
||||||
void adjustSky();
|
void adjustSky();
|
||||||
|
|
||||||
|
void changeCell (int X, int Y, const ESM::Position& position, bool adjustPlayerPos);
|
||||||
|
///< Move from exterior to interior or from interior cell to a different
|
||||||
|
/// interior cell.
|
||||||
public:
|
public:
|
||||||
|
|
||||||
World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& master,
|
World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng, const boost::filesystem::path& dataDir,
|
||||||
const std::string& dataDir, bool newGame, Environment& environment);
|
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
|
||||||
|
Environment& environment);
|
||||||
|
|
||||||
~World();
|
~World();
|
||||||
|
|
||||||
MWRender::PlayerPos& getPlayerPos();
|
MWWorld::Player& getPlayer();
|
||||||
|
|
||||||
ESMS::ESMStore& getStore();
|
ESMS::ESMStore& getStore();
|
||||||
|
|
||||||
|
@ -138,12 +157,11 @@ namespace MWWorld
|
||||||
|
|
||||||
float getTimeScaleFactor() const;
|
float getTimeScaleFactor() const;
|
||||||
|
|
||||||
void changeCell (const std::string& cellName, const ESM::Position& position);
|
void changeToInteriorCell (const std::string& cellName, const ESM::Position& position);
|
||||||
///< works only for interior cells currently.
|
///< Move to interior cell.
|
||||||
|
|
||||||
void changeCell (int X, int Y, const ESM::Position& position);
|
|
||||||
|
|
||||||
void changeToExteriorCell (const ESM::Position& position);
|
void changeToExteriorCell (const ESM::Position& position);
|
||||||
|
///< Move to exterior cell.
|
||||||
|
|
||||||
const ESM::Cell *getExterior (const std::string& cellName) const;
|
const ESM::Cell *getExterior (const std::string& cellName) const;
|
||||||
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
|
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
|
||||||
|
@ -162,6 +180,17 @@ namespace MWWorld
|
||||||
|
|
||||||
void positionToIndex (float x, float y, int &cellX, int &cellY) const;
|
void positionToIndex (float x, float y, int &cellX, int &cellY) const;
|
||||||
///< Convert position to cell numbers
|
///< Convert position to cell numbers
|
||||||
|
|
||||||
|
void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
|
||||||
|
float duration);
|
||||||
|
///< Run physics simulation and modify \a world accordingly.
|
||||||
|
|
||||||
|
void toggleCollisionMode();
|
||||||
|
///< Toggle collision mode for player. If disabled player object should ignore
|
||||||
|
/// collisions and gravity.
|
||||||
|
|
||||||
|
void toggleRenderMode (RenderMode mode);
|
||||||
|
///< Toggle a render mode.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
56
apps/openmw/path.cpp
Normal file
56
apps/openmw/path.cpp
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#include "path.hpp"
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||||
|
#include <stdlib.h> //getenv
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
std::string OMW::Path::getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile)
|
||||||
|
{
|
||||||
|
std::string theBasePath;
|
||||||
|
if(parType == GLOBAL_CFG_PATH)
|
||||||
|
{
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
theBasePath = Ogre::macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX?
|
||||||
|
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||||
|
theBasePath = "/etc/"+parApp+"/";
|
||||||
|
#else
|
||||||
|
theBasePath = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
theBasePath = Ogre::macBundlePath() + "/Contents/MacOS/"; //FIXME do we have global/local with OSX?
|
||||||
|
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
||||||
|
const char* theDir;
|
||||||
|
if ((theDir = getenv("OPENMW_HOME")) != NULL)
|
||||||
|
{
|
||||||
|
theBasePath = std::string(theDir)+"/";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((theDir = getenv("XDG_CONFIG_HOME")))
|
||||||
|
{
|
||||||
|
theBasePath = std::string(theDir)+"/"+parApp+"/";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((theDir = getenv("HOME")) == NULL)
|
||||||
|
return parFile;
|
||||||
|
theBasePath = std::string(theDir)+"/.config/"+parApp+"/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boost::filesystem::create_directories(boost::filesystem::path(theBasePath));
|
||||||
|
#else
|
||||||
|
theBasePath = "";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
theBasePath.append(parFile);
|
||||||
|
return theBasePath;
|
||||||
|
}
|
||||||
|
|
25
apps/openmw/path.hpp
Normal file
25
apps/openmw/path.hpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef PATH__HPP
|
||||||
|
#define PATH__HPP
|
||||||
|
|
||||||
|
#include <OgrePlatform.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
|
#include <OSX/macUtils.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace OMW
|
||||||
|
{
|
||||||
|
class Path
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum PathTypeEnum
|
||||||
|
{
|
||||||
|
USER_CFG_PATH,
|
||||||
|
GLOBAL_CFG_PATH
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string getPath(PathTypeEnum parType, const std::string parApp, const std::string parFile);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
76
cmake/FindBullet.cmake
Normal file
76
cmake/FindBullet.cmake
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
# - Try to find the Bullet physics engine
|
||||||
|
#
|
||||||
|
# This module defines the following variables
|
||||||
|
#
|
||||||
|
# BULLET_FOUND - Was bullet found
|
||||||
|
# BULLET_INCLUDE_DIRS - the Bullet include directories
|
||||||
|
# BULLET_LIBRARIES - Link to this, by default it includes
|
||||||
|
# all bullet components (Dynamics,
|
||||||
|
# Collision, LinearMath, & SoftBody)
|
||||||
|
#
|
||||||
|
# This module accepts the following variables
|
||||||
|
#
|
||||||
|
# BULLET_ROOT - Can be set to bullet install path or Windows build path
|
||||||
|
#
|
||||||
|
|
||||||
|
# Copyright (c) 2009, Philip Lowman <philip at yhbt.com>
|
||||||
|
#
|
||||||
|
# Redistribution AND use is allowed according to the terms of the New
|
||||||
|
# BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
macro(_FIND_BULLET_LIBRARY _var)
|
||||||
|
find_library(${_var}
|
||||||
|
NAMES
|
||||||
|
${ARGN}
|
||||||
|
PATHS
|
||||||
|
${BULLET_ROOT}
|
||||||
|
${BULLET_ROOT}/out/release8/libs
|
||||||
|
${BULLET_ROOT}/out/debug8/libs
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
)
|
||||||
|
mark_as_advanced(${_var})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(_BULLET_APPEND_LIBRARIES _list _release)
|
||||||
|
set(_debug ${_release}_DEBUG)
|
||||||
|
if(${_debug})
|
||||||
|
set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
|
||||||
|
else()
|
||||||
|
set(${_list} ${${_list}} ${${_release}})
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
|
||||||
|
PATHS
|
||||||
|
${BULLET_ROOT}/include
|
||||||
|
${BULLET_ROOT}/src
|
||||||
|
PATH_SUFFIXES bullet
|
||||||
|
)
|
||||||
|
|
||||||
|
# Find the libraries
|
||||||
|
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_d)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_d)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY LinearMath BulletMath)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG LinearMath_d BulletMath_d)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody)
|
||||||
|
_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_d)
|
||||||
|
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if
|
||||||
|
# all listed variables are TRUE
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG
|
||||||
|
BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY
|
||||||
|
BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR)
|
||||||
|
|
||||||
|
set(BULLET_INCLUDE_DIRS ${BULLET_INCLUDE_DIR})
|
||||||
|
if(BULLET_FOUND)
|
||||||
|
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_DYNAMICS_LIBRARY)
|
||||||
|
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_COLLISION_LIBRARY)
|
||||||
|
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_MATH_LIBRARY)
|
||||||
|
_BULLET_APPEND_LIBRARIES(BULLET_LIBRARIES BULLET_SOFTBODY_LIBRARY)
|
||||||
|
endif()
|
|
@ -38,10 +38,13 @@ ENDIF (WIN32)
|
||||||
IF (UNIX AND NOT APPLE)
|
IF (UNIX AND NOT APPLE)
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR)
|
||||||
FIND_PACKAGE(PkgConfig REQUIRED)
|
FIND_PACKAGE(PkgConfig REQUIRED)
|
||||||
PKG_SEARCH_MODULE(OGRE REQUIRED OGRE)
|
# Don't mark REQUIRED, but use PKG_CHECK_MODULES below (otherwise PkgConfig
|
||||||
|
# complains even if OGRE_* are set by hand).
|
||||||
|
PKG_SEARCH_MODULE(OGRE OGRE)
|
||||||
SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
|
SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
|
||||||
SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
|
SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
|
||||||
SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
|
SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
|
||||||
|
PKG_CHECK_MODULES(OGRE OGRE)
|
||||||
ENDIF (UNIX AND NOT APPLE)
|
ENDIF (UNIX AND NOT APPLE)
|
||||||
|
|
||||||
IF (APPLE)
|
IF (APPLE)
|
||||||
|
@ -66,6 +69,14 @@ SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "")
|
||||||
SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
|
SET(OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
|
||||||
SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "")
|
SET(OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "")
|
||||||
|
|
||||||
|
if(OGRE_LIB_DIR)
|
||||||
|
CMAKE_POLICY(SET CMP0009 NEW)
|
||||||
|
FILE(GLOB_RECURSE OGRE_PLUGINS "${OGRE_LIB_DIR}/Plugin_*.so")
|
||||||
|
FOREACH (OGRE_PLUGINS_FILE ${OGRE_PLUGINS})
|
||||||
|
STRING(REGEX REPLACE "/[^/]*$" "" OGRE_PLUGIN_DIR ${OGRE_PLUGINS_FILE})
|
||||||
|
ENDFOREACH(OGRE_PLUGINS_FILE)
|
||||||
|
endif()
|
||||||
|
|
||||||
IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES)
|
IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES)
|
||||||
SET(OGRE_FOUND TRUE)
|
SET(OGRE_FOUND TRUE)
|
||||||
ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES)
|
ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES)
|
||||||
|
|
|
@ -207,4 +207,11 @@ namespace Compiler
|
||||||
throw std::logic_error ("unsupported code segment");
|
throw std::logic_error ("unsupported code segment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Extensions::listKeywords (std::vector<std::string>& keywords) const
|
||||||
|
{
|
||||||
|
for (std::map<std::string, int>::const_iterator iter (mKeywords.begin());
|
||||||
|
iter!=mKeywords.end(); ++iter)
|
||||||
|
keywords.push_back (iter->first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,9 @@ namespace Compiler
|
||||||
void generateInstructionCode (int keyword, std::vector<Interpreter::Type_Code>& code,
|
void generateInstructionCode (int keyword, std::vector<Interpreter::Type_Code>& code,
|
||||||
Literals& literals, const std::string& id, int optionalArguments) const;
|
Literals& literals, const std::string& id, int optionalArguments) const;
|
||||||
///< Append code for function to \a code.
|
///< Append code for function to \a code.
|
||||||
|
|
||||||
|
void listKeywords (std::vector<std::string>& keywords) const;
|
||||||
|
///< Append all known keywords to \æ kaywords.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,8 +230,6 @@ namespace Compiler
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scanner::scanName (char c, Parser& parser, bool& cont)
|
|
||||||
{
|
|
||||||
static const char *keywords[] =
|
static const char *keywords[] =
|
||||||
{
|
{
|
||||||
"begin", "end",
|
"begin", "end",
|
||||||
|
@ -251,6 +249,8 @@ namespace Compiler
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scanner::scanName (char c, Parser& parser, bool& cont)
|
||||||
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
if (!scanName (c, name))
|
if (!scanName (c, name))
|
||||||
|
@ -513,4 +513,13 @@ namespace Compiler
|
||||||
mPutbackCode = keyword;
|
mPutbackCode = keyword;
|
||||||
mPutbackLoc = loc;
|
mPutbackLoc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Scanner::listKeywords (std::vector<std::string>& keywords)
|
||||||
|
{
|
||||||
|
for (int i=0; Compiler::keywords[i]; ++i)
|
||||||
|
keywords.push_back (Compiler::keywords[i]);
|
||||||
|
|
||||||
|
if (mExtensions)
|
||||||
|
mExtensions->listKeywords (keywords);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue