diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..25cc3fffc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*.cpp] +indent_style = space +indent_size = 4 +insert_final_newline = true + +[*.hpp] +indent_style = space +indent_size = 4 +insert_final_newline = true \ No newline at end of file diff --git a/.gitignore b/.gitignore index ca2c6502e..9fbb82dba 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ Doxygen .settings .directory .idea +files/windows/*.aps ## qt-creator CMakeLists.txt.user* diff --git a/.travis.yml b/.travis.yml index c3f1cdfb6..6606b0290 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ os: - linux - osx -osx_image: xcode8.2 +osx_image: xcode8.3 language: cpp sudo: required dist: trusty @@ -15,11 +15,7 @@ env: # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created # via the "travis encrypt" command using the project repo's public key - secure: "jybGzAdUbqt9vWR/GEnRd96BgAi/7Zd1+2HK68j/i/8+/1YH2XxLOy4Jv/DUBhBlJIkxs/Xv8dRcUlFOclZDHX1d/9Qnsqd3oUVkD7k1y7cTOWy9TBQaE/v/kZo3LpzA3xPwwthrb0BvqIbOfIELi5fS5s8ba85WFRg3AX70wWE=" - # macOS builds FTP upload login - - secure: "MegynKyJpyL7XDwdWVEbypQh7CLjqOqOi9lGF97G7Fq0HosVZTmnwjHhmIPZspTP7ES4UbxM3rs/f3ce7sp9JN2ShRJpduD6UEFc8egQXBte9J3obUBIdUxPTRdhnht7VJ+u+pksK1S/Bm1Cs6l0eEluP3vmcaXWMykVQcZsPhY=" - # macOS builds FTP upload password - - secure: "jQcAaWAdDy0+vlNu4POMX8322HanCOQEUTdpviWTAUjWQTjMa0UTM4+zVVgrtEaHMpBaVYYbTT3Rg5BQ9oG+2SiVLJBQQ2XoMcos/YrjPVT6inB02Gs0vFjP29LdPAQVrB8CkAcfQr6u+Z2C+RqAtwhE09LsBUMXjRDzPAtr1CM=" - - macos_qt_formula=qt@5.5 + - macos_qt_formula=qt addons: apt: sources: @@ -32,7 +28,7 @@ addons: # Tests libgtest-dev, google-mock, # Boost - libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, libboost-thread-dev, + libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, # FFmpeg libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev, # Audio & Video diff --git a/AUTHORS.md b/AUTHORS.md index a37975d24..c48647f4e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -50,6 +50,7 @@ Programmers Edmondo Tommasina (edmondo) Eduard Cot (trombonecot) Eli2 + elsid Emanuel Guével (potatoesmaster) eroen escondida @@ -61,8 +62,8 @@ Programmers Hallfaer Tuilinn hristoast Internecine - Jacob Essex (Yacoby) - Jannik Heller (scrawl) + Jacob Essex (Yacoby) + Jake Westrip (16bitint) Jason Hooks (jhooks) jeaye Jeffrey Haines (Jyby) @@ -74,6 +75,7 @@ Programmers Jordan Ayers Jordan Milne Jules Blok (Armada651) + julianko Julien Voisin (jvoisin/ap0) Karl-Felix Glatzer (k1ll) Kevin Poitra (PuppyKevin) @@ -108,6 +110,7 @@ Programmers Narmo Nathan Jeffords (blunted2night) NeveHanter + Nialsy Nikolay Kasyanov (corristo) nobrakal Nolan Poe (nopoe) @@ -117,6 +120,7 @@ Programmers Pi03k Pieter van der Kloet (pvdk) pkubik + PlutonicOverkill Radu-Marius Popovici (rpopovici) Rafael Moura (dhustkoder) rdimesio @@ -128,11 +132,14 @@ Programmers Roman Proskuryakov (kpp) Sandy Carter (bwrsandman) Scott Howard + scrawl Sebastian Wick (swick) Sergey Shambir ShadowRadiance + Siimacore sir_herrbatka smbas + spycrab Stefan Galowicz (bogglez) Stanislav Bobrov (Jiub) stil-t @@ -141,6 +148,7 @@ Programmers t6 terrorfisch Thomas Luppi (Digmaster) + Will Herrmann (Thunderforge) Tom Mason (wheybags) Torben Leif Carrington (TorbenC) viadanna diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d826753..b390169c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,82 @@ +0.42.0 +------ + + Bug #1956: Duplicate objects after loading the game, when a mod was edited + Bug #2100: Falling leaves in Vurt's Leafy West Gash II not rendered correctly + Bug #2116: Cant fit through some doorways pressed against staircases + Bug #2289: Some modal dialogs are not centered on the screen when the window resizes + Bug #2409: Softlock when pressing weapon/magic switch keys during chargen, afterwards switches weapons even though a text field is selected + Bug #2483: Previous/Next Weapon hotkeys triggered while typing the name of game save + Bug #2629: centeroncell, coc causes death / fall damage time to time when teleporting from high + Bug #2645: Cycling weapons is possible while console/pause menu is open + Bug #2678: Combat with water creatures do not end upon exiting water + Bug #2759: Light Problems in Therana's Chamber in Tel Branora + Bug #2771: unhandled sdl event of type 0x302 + Bug #2777: (constant/on cast) disintegrate armor/weapon on self is seemingly not working + Bug #2838: Editor: '.' in a record name should be allowed + Bug #2909: NPCs appear floating when standing on a slope + Bug #3093: Controller movement cannot be used while mouse is moving + Bug #3134: Crash possible when using console with open container + Bug #3254: AI enemies hit between them. + Bug #3344: Editor: Verification results sorting by Type is not alphabetical. + Bug #3345: Editor: Cloned and added pathgrids are lost after reopen of saved omwgame file + Bug #3355: [MGSO] Physics maxing out in south cornerclub Balmora + Bug #3484: Editor: camera position is not set when changing cell via drag&drop + Bug #3508: Slowfall kills Jump momentum + Bug #3580: Crash: Error ElementBufferObject::remove BufferData<0> out of range + Bug #3581: NPCs wander too much + Bug #3601: Menu Titles not centered vertically + Bug #3607: [Mac OS] Beginning of NPC speech cut off (same issue as closed bug #3453) + Bug #3613: Can not map "next weapon" or "next spell" to controller + Bug #3617: Enchanted arrows don't explode when hitting the ground + Bug #3645: Unable to use steps in Vivec, Palace of Vivec + Bug #3650: Tamriel Rebuilt 16.09.1 – Hist Cuirass GND nif is rendered inside a Pink Box + Bug #3652: Item icon shadows get stuck in the alchemy GUI + Bug #3653: Incorrect swish sounds + Bug #3666: NPC collision should not be disabled until death animation has finished + Bug #3669: Editor: Text field was missing from book object editing dialogue + Bug #3670: Unhandled SDL event of type 0x304 + Bug #3671: Incorrect local variable value after picking up bittercup + Bug #3686: Travelling followers doesn't increase travel fee + Bug #3689: Problematic greetings from Antares Big Mod that override the appropriate ones. + Bug #3690: Certain summoned creatures do not engage in combat with underwater creatures + Bug #3691: Enemies do not initiate combat with player followers on sight + Bug #3695: [Regression] Dispel does not always dispel spell effects in 0.41 + Bug #3699: Crash on MWWorld::ProjectileManager::moveMagicBolts + Bug #3700: Climbing on rocks and mountains + Bug #3704: Creatures don't auto-equip their shields on creation + Bug #3705: AI combat engagement logic differs from vanilla + Bug #3707: Animation playing does some very odd things if pc comes in contact with the animated mesh + Bug #3712: [Mod] Freeze upon entering Adanumuran with mod Adanumuran Reclaimed + Bug #3713: [Regression] Cancelling dialogue or using travel with creatures throws a (possibly game-breaking) exception + Bug #3719: Dropped identification papers can't be picked up again + Bug #3722: Command spell doesn't bring enemies out of combat + Bug #3727: Using "Activate" mid-script-execution invalidates interpreter context + Bug #3746: Editor: Book records show attribute IDs instead of skill IDs for teached skills entry. + Bug #3755: Followers stop following after loading from savegame + Bug #3772: ModStat lowers attribute to 100 if it was greater + Bug #3781: Guns in Clean Hunter Rifles mod use crossbow sounds + Bug #3797: NPC and creature names don't show up in combat when RMB windows are displayed + Bug #3800: Wrong tooltip maximum width + Bug #3801: Drowning widget is bugged + Bug #3802: BarterOffer shouldn't limit pcMercantile + Bug #3813: Some fatal error + Bug #3816: Expression parser thinks the -> token is unexpected when a given explicit refID clashes with a journal ID + Bug #3822: Custom added creatures are not animated + Feature #451: Water sounds + Feature #2691: Light particles sometimes not shown in inventory character preview + Feature #3523: Light source on magic projectiles + Feature #3644: Nif NiSphericalCollider Unknown Record Type + Feature #3675: ess-Importer: convert mark location + Feature #3693: ess-Importer: convert last known exterior cell + Feature #3748: Editor: Replace "Scroll" check box in Book records with "Book Type" combo box. + Feature #3751: Editor: Replace "Xyz Blood" check boxes in NPC and Creature records with "Blood Type" combo box + Feature #3752: Editor: Replace emitter check boxes in Light records with "Emitter Type" combo box + Feature #3756: Editor: Replace "Female" check box in NPC records with "Gender" combo box + Feature #3757: Editor: Replace "Female" check box in BodyPart records with "Gender" combo box + Task #3092: const version of ContainerStoreIterator + Task #3795: /deps folder not in .gitignore + 0.41.0 ------ diff --git a/CI/before_install.osx.sh b/CI/before_install.osx.sh index 2d20eb9a0..25e1c9517 100755 --- a/CI/before_install.osx.sh +++ b/CI/before_install.osx.sh @@ -2,10 +2,9 @@ brew update -brew rm cmake || true -brew rm pkgconfig || true -brew rm qt5 || true -brew install cmake pkgconfig $macos_qt_formula +brew outdated cmake || brew upgrade cmake +brew outdated pkgconfig || brew upgrade pkgconfig +brew install $macos_qt_formula -curl https://downloads.openmw.org/osx/dependencies/openmw-deps-c79172d.zip -o ~/openmw-deps.zip +curl https://downloads.openmw.org/osx/dependencies/openmw-deps-5e144e2.zip -o ~/openmw-deps.zip unzip ~/openmw-deps.zip -d /private/tmp/openmw-deps > /dev/null diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index aa8c565ba..14998a3c6 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -75,7 +75,7 @@ Options: Set the build platform, can also be set with environment variable PLATFORM. -u Configure for unity builds. - -v <2013/2015> + -v <2013/2015/2017> Choose the Visual Studio version to use. -V Run verbosely @@ -213,20 +213,28 @@ if [ -z $VS_VERSION ]; then fi case $VS_VERSION in + 15|15.0|2017 ) + GENERATOR="Visual Studio 15 2017" + TOOLSET="vc140" + MSVC_VER="14" + MSVC_YEAR="2015" + MSVC_DISPLAY_YEAR="2017" + ;; + 14|14.0|2015 ) GENERATOR="Visual Studio 14 2015" - XP_TOOLSET="v140_xp" - TOOLSET="v140" + TOOLSET="vc140" MSVC_VER="14" MSVC_YEAR="2015" + MSVC_DISPLAY_YEAR="2015" ;; 12|12.0|2013 ) GENERATOR="Visual Studio 12 2013" - XP_TOOLSET="v120_xp" - TOOLSET="v120" + TOOLSET="vc120" MSVC_VER="12" MSVC_YEAR="2013" + MSVC_DISPLAY_YEAR="2013" ;; esac @@ -278,7 +286,7 @@ fi echo echo "===================================" -echo "Starting prebuild on MSVC${MSVC_YEAR} WIN${BITS}" +echo "Starting prebuild on MSVC${MSVC_DISPLAY_YEAR} WIN${BITS}" echo "===================================" echo @@ -305,11 +313,11 @@ if [ -z $SKIP_DOWNLOAD ]; then "Bullet-2.86-msvc${MSVC_YEAR}-win${BITS}.7z" # FFmpeg - download "FFmpeg 3.0.1" \ - "http://ffmpeg.zeranoe.com/builds/win${BITS}/shared/ffmpeg-3.0.1-win${BITS}-shared.7z" \ - "ffmpeg-3.0.1-win${BITS}.7z" \ - "http://ffmpeg.zeranoe.com/builds/win${BITS}/dev/ffmpeg-3.0.1-win${BITS}-dev.7z" \ - "ffmpeg-3.0.1-dev-win${BITS}.7z" + download "FFmpeg 3.2.4" \ + "http://ffmpeg.zeranoe.com/builds/win${BITS}/shared/ffmpeg-3.2.4-win${BITS}-shared.zip" \ + "ffmpeg-3.2.4-win${BITS}.zip" \ + "http://ffmpeg.zeranoe.com/builds/win${BITS}/dev/ffmpeg-3.2.4-win${BITS}-dev.zip" \ + "ffmpeg-3.2.4-dev-win${BITS}.zip" # MyGUI download "MyGUI 3.2.3-git" \ @@ -350,7 +358,7 @@ fi cd .. #/.. # Set up dependencies -BUILD_DIR="MSVC${MSVC_YEAR}_${BITS}" +BUILD_DIR="MSVC${MSVC_DISPLAY_YEAR}_${BITS}" if [ -z $KEEP ]; then echo echo "(Re)Creating build directory." @@ -395,6 +403,7 @@ fi add_cmake_opts -DBOOST_ROOT="$BOOST_SDK" \ -DBOOST_LIBRARYDIR="${BOOST_SDK}/lib${BITS}-msvc-${MSVC_VER}.0" + add_cmake_opts -DBoost_COMPILER="-${TOOLSET}" echo Done. else @@ -406,6 +415,7 @@ fi fi add_cmake_opts -DBOOST_ROOT="$BOOST_SDK" \ -DBOOST_LIBRARYDIR="${BOOST_SDK}/lib${BITS}-msvc-${MSVC_VER}.0" + add_cmake_opts -DBoost_COMPILER="-${TOOLSET}" echo Done. fi @@ -434,21 +444,21 @@ cd $DEPS echo # FFmpeg -printf "FFmpeg 3.0.1... " +printf "FFmpeg 3.2.4... " { cd $DEPS_INSTALL - if [ -d FFmpeg ] && grep "FFmpeg version: 3.0.1" FFmpeg/README.txt > /dev/null; then + if [ -d FFmpeg ] && grep "FFmpeg version: 3.2.4" FFmpeg/README.txt > /dev/null; then printf "Exists. " elif [ -z $SKIP_EXTRACT ]; then rm -rf FFmpeg - eval 7z x -y "${DEPS}/ffmpeg-3.0.1-win${BITS}.7z" $STRIP - eval 7z x -y "${DEPS}/ffmpeg-3.0.1-dev-win${BITS}.7z" $STRIP + eval 7z x -y "${DEPS}/ffmpeg-3.2.4-win${BITS}.zip" $STRIP + eval 7z x -y "${DEPS}/ffmpeg-3.2.4-dev-win${BITS}.zip" $STRIP - mv "ffmpeg-3.0.1-win${BITS}-shared" FFmpeg - cp -r "ffmpeg-3.0.1-win${BITS}-dev/"* FFmpeg/ - rm -rf "ffmpeg-3.0.1-win${BITS}-dev" + mv "ffmpeg-3.2.4-win${BITS}-shared" FFmpeg + cp -r "ffmpeg-3.2.4-win${BITS}-dev/"* FFmpeg/ + rm -rf "ffmpeg-3.2.4-win${BITS}-dev" fi export FFMPEG_HOME="$(real_pwd)/FFmpeg" @@ -755,4 +765,4 @@ if [ -z $CI ]; then echo fi -exit $RET \ No newline at end of file +exit $RET diff --git a/CI/before_script.osx.sh b/CI/before_script.osx.sh index bec26caf1..806b545e3 100755 --- a/CI/before_script.osx.sh +++ b/CI/before_script.osx.sh @@ -5,13 +5,12 @@ export CC=clang DEPENDENCIES_ROOT="/private/tmp/openmw-deps/openmw-deps" QT_PATH=`brew --prefix $macos_qt_formula` - mkdir build cd build cmake \ -D CMAKE_PREFIX_PATH="$DEPENDENCIES_ROOT;$QT_PATH" \ --D CMAKE_OSX_DEPLOYMENT_TARGET="10.8" \ +-D CMAKE_OSX_DEPLOYMENT_TARGET="10.9" \ -D CMAKE_OSX_SYSROOT="macosx10.12" \ -D CMAKE_BUILD_TYPE=Release \ -D OPENMW_OSX_DEPLOYMENT=TRUE \ diff --git a/CI/build.msvc.sh b/CI/build.msvc.sh index f8d5a2f24..eac969b0d 100644 --- a/CI/build.msvc.sh +++ b/CI/build.msvc.sh @@ -77,9 +77,9 @@ if [ $? -ne 0 ]; then fi if [ -z $APPVEYOR ]; then - msbuild OpenMW.sln //t:Build //m:8 + msbuild OpenMW.sln //t:Build //p:Configuration=${CONFIGURATION} //m:8 else - msbuild OpenMW.sln //t:Build //m:8 //logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + msbuild OpenMW.sln //t:Build //p:Configuration=${CONFIGURATION} //m:8 //logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" fi RET=$? diff --git a/CI/deploy.osx.sh b/CI/deploy.osx.sh index 1ff6f89c3..53bfa18b5 100755 --- a/CI/deploy.osx.sh +++ b/CI/deploy.osx.sh @@ -6,4 +6,4 @@ DATE=`date +'%d%m%Y'` SHORT_COMMIT=`git rev-parse --short ${TRAVIS_COMMIT}` TARGET_FILENAME="OpenMW-${DATE}-${SHORT_COMMIT}.dmg" -curl --ssl --ftp-create-dirs -T *.dmg -u $OSX_FTP_USER:$OSX_FTP_PASSWORD "ftp://s3.mydevil.net:21/nightly/${TARGET_FILENAME}" +curl --ssl --ftp-create-dirs -T *.dmg -u $OSX_FTP_USER:$OSX_FTP_PASSWORD "${OSX_FTP_URL}${TARGET_FILENAME}" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c8e8cd16..884dd622d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ endif() message(STATUS "Configuring OpenMW...") set(OPENMW_VERSION_MAJOR 0) -set(OPENMW_VERSION_MINOR 41) +set(OPENMW_VERSION_MINOR 42) set(OPENMW_VERSION_RELEASE 0) set(OPENMW_VERSION_COMMITHASH "") @@ -343,7 +343,13 @@ endif() # CXX Compiler settings if (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef -Wno-unused-parameter -std=c++98 -pedantic -Wno-long-long") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wundef -Wno-unused-parameter -std=c++11 -pedantic -Wno-long-long") + add_definitions( -DBOOST_NO_CXX11_SCOPED_ENUMS=ON ) + + if (APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") + endif() if (CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT APPLE) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.6 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 3.6) @@ -407,7 +413,7 @@ IF(NOT WIN32 AND NOT APPLE) # Install icon and desktop file INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.desktop" DESTINATION "${DATAROOTDIR}/applications" COMPONENT "openmw") INSTALL(FILES "${OpenMW_SOURCE_DIR}/files/launcher/images/openmw.png" DESTINATION "${ICONDIR}" COMPONENT "openmw") - INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.appdata.xml" DESTINATION "${DATAROOTDIR}/appdata" COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.appdata.xml" DESTINATION "${DATAROOTDIR}/metainfo" COMPONENT "openmw") IF(BUILD_OPENCS) INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw-cs.desktop" DESTINATION "${DATAROOTDIR}/applications" COMPONENT "opencs") INSTALL(FILES "${OpenMW_SOURCE_DIR}/files/opencs/openmw-cs.png" DESTINATION "${ICONDIR}" COMPONENT "opencs") @@ -620,6 +626,7 @@ if (WIN32) 4510 4512 # Unable to generate copy constructor/assignment operator as it's not public in the base 4706 # Assignment in conditional expression 4738 # Storing 32-bit float result in memory, possible loss of performance + 4774 # Format string expected in argument is not a string literal 4986 # Undocumented warning that occurs in the crtdbg.h file 4987 # nonstandard extension used (triggered by setjmp.h) 4996 # Function was declared deprecated @@ -711,17 +718,19 @@ if (WIN32) endif() # Apple bundling -if (APPLE) +if (OPENMW_OSX_DEPLOYMENT AND APPLE AND DESIRED_QT_VERSION MATCHES 5) get_property(QT_COCOA_PLUGIN_PATH TARGET Qt5::QCocoaIntegrationPlugin PROPERTY LOCATION_RELEASE) get_filename_component(QT_COCOA_PLUGIN_DIR "${QT_COCOA_PLUGIN_PATH}" DIRECTORY) get_filename_component(QT_COCOA_PLUGIN_GROUP "${QT_COCOA_PLUGIN_DIR}" NAME) get_filename_component(QT_COCOA_PLUGIN_NAME "${QT_COCOA_PLUGIN_PATH}" NAME) - configure_file("${QT_COCOA_PLUGIN_PATH}" "${APP_BUNDLE_DIR}/Contents/MacOS/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY) + configure_file("${QT_COCOA_PLUGIN_PATH}" "${APP_BUNDLE_DIR}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY) + configure_file("${OpenMW_SOURCE_DIR}/files/mac/qt.conf" "${APP_BUNDLE_DIR}/Contents/Resources/qt.conf" COPYONLY) if (BUILD_OPENCS) get_property(OPENCS_BUNDLE_NAME_TMP TARGET openmw-cs PROPERTY OUTPUT_NAME) set(OPENCS_BUNDLE_NAME "${OPENCS_BUNDLE_NAME_TMP}.app") - configure_file("${QT_COCOA_PLUGIN_PATH}" "${OPENCS_BUNDLE_NAME}/Contents/MacOS/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY) + configure_file("${QT_COCOA_PLUGIN_PATH}" "${OPENCS_BUNDLE_NAME}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY) + configure_file("${OpenMW_SOURCE_DIR}/files/mac/qt.conf" "${OPENCS_BUNDLE_NAME}/Contents/Resources/qt.conf" COPYONLY) endif () install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "." COMPONENT Runtime) @@ -780,8 +789,8 @@ if (APPLE) install_plugins_for_bundle("${APP_BUNDLE_NAME}" PLUGINS) install_plugins_for_bundle("${OPENCS_BUNDLE_NAME}" OPENCS_PLUGINS) - set(PLUGINS ${PLUGINS} "${INSTALLED_OPENMW_APP}/Contents/MacOS/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}") - set(OPENCS_PLUGINS ${OPENCS_PLUGINS} "${INSTALLED_OPENCS_APP}/Contents/MacOS/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}") + set(PLUGINS ${PLUGINS} "${INSTALLED_OPENMW_APP}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}") + set(OPENCS_PLUGINS ${OPENCS_PLUGINS} "${INSTALLED_OPENCS_APP}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}") install(CODE " function(gp_item_default_embedded_path_override item default_embedded_path_var) @@ -791,12 +800,11 @@ if (APPLE) endif() endfunction() - cmake_policy(SET CMP0009 OLD) fixup_bundle(\"${INSTALLED_OPENMW_APP}\" \"${PLUGINS}\" \"\") fixup_bundle(\"${INSTALLED_OPENCS_APP}\" \"${OPENCS_PLUGINS}\" \"\") " COMPONENT Runtime) include(CPack) -endif (APPLE) +endif () # Doxygen Target -- simply run 'make doc' or 'make doc_pages' # output directory for 'make doc' is "${OpenMW_BINARY_DIR}/docs/Doxygen" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a9cd6a690..b5a7423d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,16 +1,70 @@ -Description -=========== +How to contribute to OpenMW +======================= -Your pull request description should include (if applicable): +Not sure what to do with all your free time? Pick out a task from here: + +http://bugs.openmw.org/ + +Currently, we are focused on completing the MW game experience and general polishing. Features out of this scope may be approved in some cases, but you should probably start a discussion first. + +Note: +- Tasks set to 'openmw-future' are usually out of the current scope of the project and can't be started yet. +- Bugs that are not 'Confirmed' should be confirmed first. +- Larger Features should have a discussion before you start implementing. +- In many cases, it's best to have a discussion about possible solutions before you jump into coding. + +Aside from coding, you can also help by triaging the issues list. Check for bugs that are 'Unconfirmed' and try to confirm them on your end, working out any details that may be necessary. Check for bugs that do not conform to [Bug reporting guidelines](https://wiki.openmw.org/index.php?title=Bug_Reporting_Guidelines) and improve them to do so! + +There are various [Tools](https://wiki.openmw.org/index.php?title=Tools) to facilitate testing/development. + +Pull Request Guidelines +======================= + +Thought of a change? Great! To facilitate the review process, your pull request description should include the following (if applicable): * A link back to the bug report or forum discussion that prompted the change * Summary of the changes made * Reasoning / motivation behind the change * What testing you have carried out to verify the change -Other notes -=========== +Furthermore, we advise to: * Separate your work into multiple pull requests whenever possible. As a rule of thumb, each feature and each bugfix should go into a separate PR, unless they are closely related or dependent upon each other. Small pull requests are easier to review, and are less likely to require further changes before we can merge them. A "mega" pull request with lots of unrelated commits in it is likely to get held up in review for a long time. * Feel free to submit incomplete pull requests. Even if the work can not be merged yet, pull requests are a great place to collect early feedback. Just make sure to mark it as *[Incomplete]* or *[Do not merge yet]* in the title. * If you plan on contributing often, please read the [Developer Reference](https://wiki.openmw.org/index.php?title=Developer_Reference) on our wiki, especially the [Policies and Standards](https://wiki.openmw.org/index.php?title=Policies_and_Standards). +* Make sure each of your changes has a clear objective. Unnecessary changes may lead to merge conflicts, clutter the commit history and slow down review. Code formatting 'fixes' should be avoided, unless you were already changing that particular line anyway. + +Guidelines for original engine "fixes" +================================= + +From time to time you may be tempted to "fix" what you think was a "bug" in the original game engine. + +Unfortunately, the definition of what is a "bug" is not so clear. Consider that your "bug" is actually a feature unless proven otherwise: + +* We have no way of knowing what the original developers really intended (short of asking them, good luck with that). +* What may seem like an illogical mechanic can actually be part of an attempt to balance the game. +* Many people will actually like these "bugs" because that is what they remember the game for. +* Exploits may be part of the fun of an open-world game - they reward knowledge with power. There are too many of them to plug them all, anyway. + +OpenMW, in its default configuration, is meant to be a faithful reimplementation of Morrowind, minus things like crash bugs, stability issues and design errors. However, we try to avoid touching anything that affects the core gameplay, the balancing of the game or introduces incompatibilities with existing mod content. + +That said, we may sometimes evaluate such issues on an individual basis. Common exceptions to the above would be: + +* Issues so glaring that they would severely limit the capabilities of the engine in the future (for example, the scripting engine not being allowed to access objects in remote cells) +* Bugs where the intent is very obvious, and that have little to no balancing impact (e.g. the bug were being tired made it easier to repair items, instead of harder) +* Bugs that were fixed in an official patch for Morrowind + +Feature additions policy +===================== + +We get it, you have waited so long for feature XYZ to be available in Morrowind and now that OpenMW is here you can not wait to implement your ingenious idea and share it with the world. + +Unfortunately, since maintaining features comes at a cost and our resources are limited, we have to be a little selective in what features we allow into the main repository. Generally: + +- Features should be as generic and non-redundant as possible. +- Any feature that is also possible with modding should be done as a mod instead. +- In the future, OpenMW plans to expand the scope of what is possible with modding, e.g. by moving certain game logic into editable scripts. +- Currently, modders can edit OpenMW's GUI skins and layout XML files, although there are still a few missing hooks (e.g. scripting support) in order to make this into a powerful way of modding. +- If a feature introduces new game UI strings, that reduces its chance of being accepted because we do not currently have any way of localizing these to the user's Morrowind installation language. + +If you are in doubt of your feature being within our scope, it is probably best to start a forum discussion first. See the [settings documentation](https://openmw.readthedocs.io/en/stable/reference/modding/settings/index.html) and [Features list](https://wiki.openmw.org/index.php?title=Features) for some examples of features that were deemed acceptable. diff --git a/README.md b/README.md index d38dfaeb2..aa6ae47b4 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ OpenMW is a recreation of the engine for the popular role-playing game Morrowind OpenMW also comes with OpenMW-CS, a replacement for Morrowind's TES Construction Set. -* Version: 0.41.0 +* Version: 0.42.0 * License: GPLv3 (see [docs/license/GPL3.txt](https://github.com/OpenMW/openmw/blob/master/docs/license/GPL3.txt) for more information) * Website: http://www.openmw.org * IRC: #openmw on irc.freenode.net @@ -18,7 +18,7 @@ Font Licenses: Current Status -------------- -The main quests in Morrowind, Tribunal and Bloodmoon are all completable. Some issues with side quests are to be expected (but rare). Check the [bug tracker](https://bugs.openmw.org/versions/21) for a list of issues we need to resolve before the "1.0" release. Even before the "1.0" release however, OpenMW boasts some new [features](https://wiki.openmw.org/index.php?title=Features), such as improved graphics and user interfaces. +The main quests in Morrowind, Tribunal and Bloodmoon are all completable. Some issues with side quests are to be expected (but rare). Check the [bug tracker](https://bugs.openmw.org/) for a list of issues we need to resolve before the "1.0" release. Even before the "1.0" release however, OpenMW boasts some new [features](https://wiki.openmw.org/index.php?title=Features), such as improved graphics and user interfaces. Pre-existing modifications created for the original Morrowind engine can be hit-and-miss. The OpenMW script compiler performs more thorough error-checking than Morrowind does, meaning that a mod created for Morrowind may not necessarily run in OpenMW. Some mods also rely on quirky behaviour or engine bugs in order to work. We are considering such compatibility issues on a case-by-case basis - in some cases adding a workaround to OpenMW may be feasible, in other cases fixing the mod will be the only option. If you know of any mods that work or don't work, feel free to add them to the [Mod status](https://wiki.openmw.org/index.php?title=Mod_status) wiki page. diff --git a/apps/bsatool/bsatool.cpp b/apps/bsatool/bsatool.cpp index 7f305052b..54e946cbc 100644 --- a/apps/bsatool/bsatool.cpp +++ b/apps/bsatool/bsatool.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp index 883a9e728..ea7b50129 100644 --- a/apps/esmtool/labels.cpp +++ b/apps/esmtool/labels.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include diff --git a/apps/essimporter/importer.cpp b/apps/essimporter/importer.cpp index c27e15a3e..d38069d89 100644 --- a/apps/essimporter/importer.cpp +++ b/apps/essimporter/importer.cpp @@ -2,7 +2,7 @@ #include -#include +#include #include #include @@ -272,37 +272,37 @@ namespace ESSImport const unsigned int recGAME = ESM::FourCC<'G','A','M','E'>::value; const unsigned int recJOUR = ESM::FourCC<'J','O','U','R'>::value; - std::map > converters; - converters[ESM::REC_GLOB] = boost::shared_ptr(new ConvertGlobal()); - converters[ESM::REC_BOOK] = boost::shared_ptr(new ConvertBook()); - converters[ESM::REC_NPC_] = boost::shared_ptr(new ConvertNPC()); - converters[ESM::REC_CREA] = boost::shared_ptr(new ConvertCREA()); - converters[ESM::REC_NPCC] = boost::shared_ptr(new ConvertNPCC()); - converters[ESM::REC_CREC] = boost::shared_ptr(new ConvertCREC()); - converters[recREFR ] = boost::shared_ptr(new ConvertREFR()); - converters[recPCDT ] = boost::shared_ptr(new ConvertPCDT()); - converters[recFMAP ] = boost::shared_ptr(new ConvertFMAP()); - converters[recKLST ] = boost::shared_ptr(new ConvertKLST()); - converters[recSTLN ] = boost::shared_ptr(new ConvertSTLN()); - converters[recGAME ] = boost::shared_ptr(new ConvertGAME()); - converters[ESM::REC_CELL] = boost::shared_ptr(new ConvertCell()); - converters[ESM::REC_ALCH] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_CLAS] = boost::shared_ptr(new ConvertClass()); - converters[ESM::REC_SPEL] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_ARMO] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_WEAP] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_CLOT] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_ENCH] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_WEAP] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_LEVC] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_LEVI] = boost::shared_ptr(new DefaultConverter()); - converters[ESM::REC_CNTC] = boost::shared_ptr(new ConvertCNTC()); - converters[ESM::REC_FACT] = boost::shared_ptr(new ConvertFACT()); - converters[ESM::REC_INFO] = boost::shared_ptr(new ConvertINFO()); - converters[ESM::REC_DIAL] = boost::shared_ptr(new ConvertDIAL()); - converters[ESM::REC_QUES] = boost::shared_ptr(new ConvertQUES()); - converters[recJOUR ] = boost::shared_ptr(new ConvertJOUR()); - converters[ESM::REC_SCPT] = boost::shared_ptr(new ConvertSCPT()); + std::map > converters; + converters[ESM::REC_GLOB] = std::shared_ptr(new ConvertGlobal()); + converters[ESM::REC_BOOK] = std::shared_ptr(new ConvertBook()); + converters[ESM::REC_NPC_] = std::shared_ptr(new ConvertNPC()); + converters[ESM::REC_CREA] = std::shared_ptr(new ConvertCREA()); + converters[ESM::REC_NPCC] = std::shared_ptr(new ConvertNPCC()); + converters[ESM::REC_CREC] = std::shared_ptr(new ConvertCREC()); + converters[recREFR ] = std::shared_ptr(new ConvertREFR()); + converters[recPCDT ] = std::shared_ptr(new ConvertPCDT()); + converters[recFMAP ] = std::shared_ptr(new ConvertFMAP()); + converters[recKLST ] = std::shared_ptr(new ConvertKLST()); + converters[recSTLN ] = std::shared_ptr(new ConvertSTLN()); + converters[recGAME ] = std::shared_ptr(new ConvertGAME()); + converters[ESM::REC_CELL] = std::shared_ptr(new ConvertCell()); + converters[ESM::REC_ALCH] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_CLAS] = std::shared_ptr(new ConvertClass()); + converters[ESM::REC_SPEL] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_ARMO] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_WEAP] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_CLOT] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_ENCH] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_WEAP] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_LEVC] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_LEVI] = std::shared_ptr(new DefaultConverter()); + converters[ESM::REC_CNTC] = std::shared_ptr(new ConvertCNTC()); + converters[ESM::REC_FACT] = std::shared_ptr(new ConvertFACT()); + converters[ESM::REC_INFO] = std::shared_ptr(new ConvertINFO()); + converters[ESM::REC_DIAL] = std::shared_ptr(new ConvertDIAL()); + converters[ESM::REC_QUES] = std::shared_ptr(new ConvertQUES()); + converters[recJOUR ] = std::shared_ptr(new ConvertJOUR()); + converters[ESM::REC_SCPT] = std::shared_ptr(new ConvertSCPT()); // TODO: // - REGN (weather in certain regions?) @@ -312,7 +312,7 @@ namespace ESSImport std::set unknownRecords; - for (std::map >::const_iterator it = converters.begin(); + for (std::map >::const_iterator it = converters.begin(); it != converters.end(); ++it) { it->second->setContext(context); @@ -323,7 +323,7 @@ namespace ESSImport ESM::NAME n = esm.getRecName(); esm.getRecHeader(); - std::map >::iterator it = converters.find(n.intval); + std::map >::iterator it = converters.find(n.intval); if (it != converters.end()) { it->second->read(esm); @@ -386,7 +386,7 @@ namespace ESSImport // Writing order should be Dynamic Store -> Cells -> Player, // so that references to dynamic records can be recognized when loading - for (std::map >::const_iterator it = converters.begin(); + for (std::map >::const_iterator it = converters.begin(); it != converters.end(); ++it) { if (it->second->getStage() != 0) @@ -399,7 +399,7 @@ namespace ESSImport context.mPlayerBase.save(writer); writer.endRecord(ESM::REC_NPC_); - for (std::map >::const_iterator it = converters.begin(); + for (std::map >::const_iterator it = converters.begin(); it != converters.end(); ++it) { if (it->second->getStage() != 1) diff --git a/apps/essimporter/main.cpp b/apps/essimporter/main.cpp index a4ad114ec..d593669c3 100644 --- a/apps/essimporter/main.cpp +++ b/apps/essimporter/main.cpp @@ -2,8 +2,6 @@ #include #include -#include -#include #include diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 622db4da4..d3dbfa559 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -1,5 +1,6 @@ #include "graphicspage.hpp" +#include #include #include #include @@ -12,14 +13,8 @@ #include -#include - #include -#include - -#include - QString getAspect(int x, int y) { int gcd = boost::math::gcd (x, y); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 94e186db8..31da90d2f 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -172,7 +172,10 @@ Launcher::FirstRunDialogResult Launcher::MainDialog::showFirstRunDialog() } } - return setup() ? FirstRunDialogResultContinue : FirstRunDialogResultFailure; + if (!setup() || !setupGameData()) { + return FirstRunDialogResultFailure; + } + return FirstRunDialogResultContinue; } void Launcher::MainDialog::setVersionLabel() @@ -344,6 +347,11 @@ bool Launcher::MainDialog::setupGameSettings() file.close(); } + return true; +} + +bool Launcher::MainDialog::setupGameData() +{ QStringList dataDirs; // Check if the paths actually contain data files diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 96b5c0b97..8d0d61b8f 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -72,6 +72,7 @@ namespace Launcher bool setupLauncherSettings(); bool setupGameSettings(); bool setupGraphicsSettings(); + bool setupGameData(); void setVersionLabel(); diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index fb3144814..24646b844 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -1,17 +1,12 @@ #include "importer.hpp" -#include #include -#include -#include -#include -#include #include #include -#include #include #include +#include namespace bfs = boost::filesystem; diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index a3f115fcf..8a2aeb603 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -1,11 +1,9 @@ #include "importer.hpp" -#include #include #include #include -#include #include namespace bpo = boost::program_options; diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 8a3d3c1c8..0a146dc06 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -110,7 +110,7 @@ opencs_units_noqt (view/tools ) opencs_units (view/prefs - dialogue pagebase page keybindingpage + dialogue pagebase page keybindingpage contextmenulist ) opencs_units (model/prefs diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 54e323956..86c87962d 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -5,9 +5,6 @@ #include #include -#include -#include - #include #include @@ -33,11 +30,7 @@ CS::Editor::Editor () NifOsg::Loader::setShowMarkers(true); - mVFS.reset(new VFS::Manager(mFsStrict)); - - VFS::registerArchives(mVFS.get(), Files::Collections(config.first, !mFsStrict), config.second, true); - - mDocumentManager.setVFS(mVFS.get()); + mDocumentManager.setFileData(mFsStrict, config.first, config.second); mNewGame.setLocalData (mLocal); mFileDialog.setLocalData (mLocal); diff --git a/apps/opencs/editor.hpp b/apps/opencs/editor.hpp index b088e9a44..b60f5c6a8 100644 --- a/apps/opencs/editor.hpp +++ b/apps/opencs/editor.hpp @@ -1,8 +1,6 @@ #ifndef CS_EDITOR_H #define CS_EDITOR_H -#include - #include #include @@ -30,11 +28,6 @@ #include "view/tools/merge.hpp" -namespace VFS -{ - class Manager; -} - namespace CSMDoc { class Document; @@ -46,9 +39,6 @@ namespace CS { Q_OBJECT - // FIXME: should be moved to document, so we can have different resources for each opened project - std::auto_ptr mVFS; - Files::ConfigurationManager mCfgMgr; CSMPrefs::State mSettingsState; CSMDoc::DocumentManager mDocumentManager; diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 87fbccb3f..7257b2fe3 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "../world/defaultgmsts.hpp" @@ -268,13 +269,14 @@ void CSMDoc::Document::createBase() } } -CSMDoc::Document::Document (const VFS::Manager* vfs, const Files::ConfigurationManager& configuration, - const std::vector< boost::filesystem::path >& files, bool new_, +CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, + const std::vector< boost::filesystem::path >& files,bool new_, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, const Fallback::Map* fallback, - ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager, - const std::vector& blacklistedScripts) -: mVFS(vfs), mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, resourcesManager, fallback, resDir), + ToUTF8::FromType encoding, + const std::vector& blacklistedScripts, + bool fsStrict, const Files::PathContainer& dataPaths, const std::vector& archives) +: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, fsStrict, dataPaths, archives, fallback, resDir), mTools (*this, encoding), mProjectPath ((configuration.getUserDataPath() / "projects") / (savePath.filename().string() + ".project")), @@ -336,11 +338,6 @@ CSMDoc::Document::~Document() { } -const VFS::Manager *CSMDoc::Document::getVFS() const -{ - return mVFS; -} - QUndoStack& CSMDoc::Document::getUndoStack() { return mUndoStack; @@ -415,9 +412,9 @@ void CSMDoc::Document::runSearch (const CSMWorld::UniversalId& searchId, const C emit stateChanged (getState(), this); } -void CSMDoc::Document::runMerge (std::auto_ptr target) +void CSMDoc::Document::runMerge (std::unique_ptr target) { - mTools.runMerge (target); + mTools.runMerge (std::move(target)); emit stateChanged (getState(), this); } diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 41640f66d..d31fd5aca 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -3,13 +3,13 @@ #include -#include #include #include #include #include +#include #include #include "../world/data.hpp" @@ -60,7 +60,6 @@ namespace CSMDoc private: - const VFS::Manager* mVFS; boost::filesystem::path mSavePath; std::vector mContentFiles; bool mNew; @@ -103,17 +102,15 @@ namespace CSMDoc public: - Document (const VFS::Manager* vfs, const Files::ConfigurationManager& configuration, + Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, bool new_, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, - const Fallback::Map* fallback, - ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager, - const std::vector& blacklistedScripts); + const Fallback::Map* fallback, ToUTF8::FromType encoding, + const std::vector& blacklistedScripts, + bool fsStrict, const Files::PathContainer& dataPaths, const std::vector& archives); ~Document(); - const VFS::Manager* getVFS() const; - QUndoStack& getUndoStack(); int getState() const; @@ -137,7 +134,7 @@ namespace CSMDoc void runSearch (const CSMWorld::UniversalId& searchId, const CSMTools::Search& search); - void runMerge (std::auto_ptr target); + void runMerge (std::unique_ptr target); void abortOperation (int type); diff --git a/apps/opencs/model/doc/documentmanager.cpp b/apps/opencs/model/doc/documentmanager.cpp index 87fb960c1..531cfd267 100644 --- a/apps/opencs/model/doc/documentmanager.cpp +++ b/apps/opencs/model/doc/documentmanager.cpp @@ -1,8 +1,5 @@ #include "documentmanager.hpp" -#include -#include - #include #ifndef Q_MOC_RUN @@ -12,7 +9,7 @@ #include "document.hpp" CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration) -: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mVFS(NULL) +: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252) { boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects"; @@ -65,7 +62,7 @@ CSMDoc::Document *CSMDoc::DocumentManager::makeDocument ( const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, bool new_) { - return new Document (mVFS, mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mResourcesManager, mBlacklistedScripts); + return new Document (mConfiguration, files, new_, savePath, mResDir, &mFallbackMap, mEncoding, mBlacklistedScripts, mFsStrict, mDataPaths, mArchives); } void CSMDoc::DocumentManager::insertDocument (CSMDoc::Document *document) @@ -130,8 +127,9 @@ void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std:: removeDocument (document); } -void CSMDoc::DocumentManager::setVFS(const VFS::Manager *vfs) +void CSMDoc::DocumentManager::setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector& archives) { - mResourcesManager.setVFS(vfs); - mVFS = vfs; + mFsStrict = strict; + mDataPaths = dataPaths; + mArchives = archives; } diff --git a/apps/opencs/model/doc/documentmanager.hpp b/apps/opencs/model/doc/documentmanager.hpp index ed8e327d7..ae6d9481a 100644 --- a/apps/opencs/model/doc/documentmanager.hpp +++ b/apps/opencs/model/doc/documentmanager.hpp @@ -11,8 +11,7 @@ #include #include - -#include "../world/resourcesmanager.hpp" +#include #include "loader.hpp" @@ -39,9 +38,14 @@ namespace CSMDoc QThread mLoaderThread; Loader mLoader; ToUTF8::FromType mEncoding; - CSMWorld::ResourcesManager mResourcesManager; std::vector mBlacklistedScripts; - const VFS::Manager* mVFS; + + boost::filesystem::path mResDir; + Fallback::Map mFallbackMap; + + bool mFsStrict; + Files::PathContainer mDataPaths; + std::vector mArchives; DocumentManager (const DocumentManager&); DocumentManager& operator= (const DocumentManager&); @@ -74,15 +78,11 @@ namespace CSMDoc void setBlacklistedScripts (const std::vector& scriptIds); - void setVFS(const VFS::Manager* vfs); + /// Sets the file data that gets passed to newly created documents. + void setFileData(bool strict, const Files::PathContainer& dataPaths, const std::vector& archives); bool isEmpty(); - private: - - boost::filesystem::path mResDir; - Fallback::Map mFallbackMap; - private slots: void documentLoaded (Document *document); diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 82a965ae4..f9c028e29 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -1,20 +1,15 @@ #include "savingstages.hpp" -#include - #include #include #include -#include - #include "../world/infocollection.hpp" #include "../world/cellcoordinates.hpp" #include "document.hpp" -#include "savingstate.hpp" CSMDoc::OpenSaveStage::OpenSaveStage (Document& document, SavingState& state, bool projectFile) : mDocument (document), mState (state), mProjectFile (projectFile) diff --git a/apps/opencs/model/doc/savingstate.cpp b/apps/opencs/model/doc/savingstate.cpp index 10539c1b5..7214735f0 100644 --- a/apps/opencs/model/doc/savingstate.cpp +++ b/apps/opencs/model/doc/savingstate.cpp @@ -1,5 +1,7 @@ #include "savingstate.hpp" +#include + #include "operation.hpp" #include "document.hpp" diff --git a/apps/opencs/model/filter/andnode.cpp b/apps/opencs/model/filter/andnode.cpp index 908662799..757865717 100644 --- a/apps/opencs/model/filter/andnode.cpp +++ b/apps/opencs/model/filter/andnode.cpp @@ -2,7 +2,7 @@ #include -CSMFilter::AndNode::AndNode (const std::vector >& nodes) +CSMFilter::AndNode::AndNode (const std::vector >& nodes) : NAryNode (nodes, "and") {} diff --git a/apps/opencs/model/filter/andnode.hpp b/apps/opencs/model/filter/andnode.hpp index 3838b451d..56d1d7948 100644 --- a/apps/opencs/model/filter/andnode.hpp +++ b/apps/opencs/model/filter/andnode.hpp @@ -9,7 +9,7 @@ namespace CSMFilter { public: - AndNode (const std::vector >& nodes); + AndNode (const std::vector >& nodes); virtual bool test (const CSMWorld::IdTableBase& table, int row, const std::map& columns) const; diff --git a/apps/opencs/model/filter/narynode.cpp b/apps/opencs/model/filter/narynode.cpp index f2e0e5cb2..2fa9ac6cc 100644 --- a/apps/opencs/model/filter/narynode.cpp +++ b/apps/opencs/model/filter/narynode.cpp @@ -2,7 +2,7 @@ #include -CSMFilter::NAryNode::NAryNode (const std::vector >& nodes, +CSMFilter::NAryNode::NAryNode (const std::vector >& nodes, const std::string& name) : mNodes (nodes), mName (name) {} @@ -21,7 +21,7 @@ std::vector CSMFilter::NAryNode::getReferencedColumns() const { std::vector columns; - for (std::vector >::const_iterator iter (mNodes.begin()); + for (std::vector >::const_iterator iter (mNodes.begin()); iter!=mNodes.end(); ++iter) { std::vector columns2 = (*iter)->getReferencedColumns(); diff --git a/apps/opencs/model/filter/narynode.hpp b/apps/opencs/model/filter/narynode.hpp index aa501d009..1cd93e62e 100644 --- a/apps/opencs/model/filter/narynode.hpp +++ b/apps/opencs/model/filter/narynode.hpp @@ -4,20 +4,18 @@ #include #include -#include - #include "node.hpp" namespace CSMFilter { class NAryNode : public Node { - std::vector > mNodes; + std::vector > mNodes; std::string mName; public: - NAryNode (const std::vector >& nodes, const std::string& name); + NAryNode (const std::vector >& nodes, const std::string& name); int getSize() const; diff --git a/apps/opencs/model/filter/node.hpp b/apps/opencs/model/filter/node.hpp index 58588bdc5..7295b9018 100644 --- a/apps/opencs/model/filter/node.hpp +++ b/apps/opencs/model/filter/node.hpp @@ -3,10 +3,9 @@ #include #include +#include #include -#include - #include namespace CSMWorld @@ -48,6 +47,6 @@ namespace CSMFilter }; } -Q_DECLARE_METATYPE (boost::shared_ptr) +Q_DECLARE_METATYPE (std::shared_ptr) #endif diff --git a/apps/opencs/model/filter/notnode.cpp b/apps/opencs/model/filter/notnode.cpp index ba5302bbe..81588c754 100644 --- a/apps/opencs/model/filter/notnode.cpp +++ b/apps/opencs/model/filter/notnode.cpp @@ -1,6 +1,6 @@ #include "notnode.hpp" -CSMFilter::NotNode::NotNode (boost::shared_ptr child) : UnaryNode (child, "not") {} +CSMFilter::NotNode::NotNode (std::shared_ptr child) : UnaryNode (child, "not") {} bool CSMFilter::NotNode::test (const CSMWorld::IdTableBase& table, int row, const std::map& columns) const diff --git a/apps/opencs/model/filter/notnode.hpp b/apps/opencs/model/filter/notnode.hpp index 0281d99da..e3c57cede 100644 --- a/apps/opencs/model/filter/notnode.hpp +++ b/apps/opencs/model/filter/notnode.hpp @@ -9,7 +9,7 @@ namespace CSMFilter { public: - NotNode (boost::shared_ptr child); + NotNode (std::shared_ptr child); virtual bool test (const CSMWorld::IdTableBase& table, int row, const std::map& columns) const; diff --git a/apps/opencs/model/filter/ornode.cpp b/apps/opencs/model/filter/ornode.cpp index 41ec7b5cf..9e6d8b2c4 100644 --- a/apps/opencs/model/filter/ornode.cpp +++ b/apps/opencs/model/filter/ornode.cpp @@ -2,7 +2,7 @@ #include -CSMFilter::OrNode::OrNode (const std::vector >& nodes) +CSMFilter::OrNode::OrNode (const std::vector >& nodes) : NAryNode (nodes, "or") {} diff --git a/apps/opencs/model/filter/ornode.hpp b/apps/opencs/model/filter/ornode.hpp index 07ab51a6a..b89da4e75 100644 --- a/apps/opencs/model/filter/ornode.hpp +++ b/apps/opencs/model/filter/ornode.hpp @@ -9,7 +9,7 @@ namespace CSMFilter { public: - OrNode (const std::vector >& nodes); + OrNode (const std::vector >& nodes); virtual bool test (const CSMWorld::IdTableBase& table, int row, const std::map& columns) const; diff --git a/apps/opencs/model/filter/parser.cpp b/apps/opencs/model/filter/parser.cpp index c0c089169..d2bedc666 100644 --- a/apps/opencs/model/filter/parser.cpp +++ b/apps/opencs/model/filter/parser.cpp @@ -235,7 +235,7 @@ CSMFilter::Token CSMFilter::Parser::getNextToken() return Token (Token::Type_None); } -boost::shared_ptr CSMFilter::Parser::parseImp (bool allowEmpty, bool ignoreOneShot) +std::shared_ptr CSMFilter::Parser::parseImp (bool allowEmpty, bool ignoreOneShot) { if (Token token = getNextToken()) { @@ -247,11 +247,11 @@ boost::shared_ptr CSMFilter::Parser::parseImp (bool allowEmpty, { case Token::Type_Keyword_True: - return boost::shared_ptr (new BooleanNode (true)); + return std::shared_ptr (new BooleanNode (true)); case Token::Type_Keyword_False: - return boost::shared_ptr (new BooleanNode (false)); + return std::shared_ptr (new BooleanNode (false)); case Token::Type_Keyword_And: case Token::Type_Keyword_Or: @@ -260,12 +260,12 @@ boost::shared_ptr CSMFilter::Parser::parseImp (bool allowEmpty, case Token::Type_Keyword_Not: { - boost::shared_ptr node = parseImp(); + std::shared_ptr node = parseImp(); if (mError) - return boost::shared_ptr(); + return std::shared_ptr(); - return boost::shared_ptr (new NotNode (node)); + return std::shared_ptr (new NotNode (node)); } case Token::Type_Keyword_Text: @@ -281,7 +281,7 @@ boost::shared_ptr CSMFilter::Parser::parseImp (bool allowEmpty, if (!allowEmpty) error(); - return boost::shared_ptr(); + return std::shared_ptr(); default: @@ -289,27 +289,27 @@ boost::shared_ptr CSMFilter::Parser::parseImp (bool allowEmpty, } } - return boost::shared_ptr(); + return std::shared_ptr(); } -boost::shared_ptr CSMFilter::Parser::parseNAry (const Token& keyword) +std::shared_ptr CSMFilter::Parser::parseNAry (const Token& keyword) { - std::vector > nodes; + std::vector > nodes; Token token = getNextToken(); if (token.mType!=Token::Type_Open) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } for (;;) { - boost::shared_ptr node = parseImp(); + std::shared_ptr node = parseImp(); if (mError) - return boost::shared_ptr(); + return std::shared_ptr(); nodes.push_back (node); @@ -318,7 +318,7 @@ boost::shared_ptr CSMFilter::Parser::parseNAry (const Token& ke if (!token || (token.mType!=Token::Type_Close && token.mType!=Token::Type_Comma)) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } if (token.mType==Token::Type_Close) @@ -328,31 +328,31 @@ boost::shared_ptr CSMFilter::Parser::parseNAry (const Token& ke if (nodes.empty()) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } switch (keyword.mType) { - case Token::Type_Keyword_And: return boost::shared_ptr (new AndNode (nodes)); - case Token::Type_Keyword_Or: return boost::shared_ptr (new OrNode (nodes)); - default: error(); return boost::shared_ptr(); + case Token::Type_Keyword_And: return std::shared_ptr (new AndNode (nodes)); + case Token::Type_Keyword_Or: return std::shared_ptr (new OrNode (nodes)); + default: error(); return std::shared_ptr(); } } -boost::shared_ptr CSMFilter::Parser::parseText() +std::shared_ptr CSMFilter::Parser::parseText() { Token token = getNextToken(); if (token.mType!=Token::Type_Open) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } token = getNextToken(); if (!token) - return boost::shared_ptr(); + return std::shared_ptr(); // parse column ID int columnId = -1; @@ -370,7 +370,7 @@ boost::shared_ptr CSMFilter::Parser::parseText() if (columnId<0) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } token = getNextToken(); @@ -378,7 +378,7 @@ boost::shared_ptr CSMFilter::Parser::parseText() if (token.mType!=Token::Type_Comma) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } // parse text pattern @@ -387,7 +387,7 @@ boost::shared_ptr CSMFilter::Parser::parseText() if (!token.isString()) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } std::string text = token.mString; @@ -397,26 +397,26 @@ boost::shared_ptr CSMFilter::Parser::parseText() if (token.mType!=Token::Type_Close) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } - return boost::shared_ptr (new TextNode (columnId, text)); + return std::shared_ptr (new TextNode (columnId, text)); } -boost::shared_ptr CSMFilter::Parser::parseValue() +std::shared_ptr CSMFilter::Parser::parseValue() { Token token = getNextToken(); if (token.mType!=Token::Type_Open) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } token = getNextToken(); if (!token) - return boost::shared_ptr(); + return std::shared_ptr(); // parse column ID int columnId = -1; @@ -434,7 +434,7 @@ boost::shared_ptr CSMFilter::Parser::parseValue() if (columnId<0) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } token = getNextToken(); @@ -442,7 +442,7 @@ boost::shared_ptr CSMFilter::Parser::parseValue() if (token.mType!=Token::Type_Comma) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } // parse value @@ -467,7 +467,7 @@ boost::shared_ptr CSMFilter::Parser::parseValue() else if (token.mType!=Token::Type_CloseSquare && token.mType!=Token::Type_Open) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } token = getNextToken(); @@ -481,7 +481,7 @@ boost::shared_ptr CSMFilter::Parser::parseValue() if (token.mType!=Token::Type_Comma) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } } else if (token.mType==Token::Type_Comma) @@ -491,7 +491,7 @@ boost::shared_ptr CSMFilter::Parser::parseValue() else { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } token = getNextToken(); @@ -513,7 +513,7 @@ boost::shared_ptr CSMFilter::Parser::parseValue() else if (token.mType!=Token::Type_OpenSquare && token.mType!=Token::Type_Close) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } } @@ -522,10 +522,10 @@ boost::shared_ptr CSMFilter::Parser::parseValue() if (token.mType!=Token::Type_Close) { error(); - return boost::shared_ptr(); + return std::shared_ptr(); } - return boost::shared_ptr (new ValueNode (columnId, lowerType, upperType, lower, upper)); + return std::shared_ptr (new ValueNode (columnId, lowerType, upperType, lower, upper)); } void CSMFilter::Parser::error() @@ -556,7 +556,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined) } else if (!allowPredefined || token==Token (Token::Type_OneShot)) { - boost::shared_ptr node = parseImp (true, token!=Token (Token::Type_OneShot)); + std::shared_ptr node = parseImp (true, token!=Token (Token::Type_OneShot)); if (mError) return false; @@ -612,7 +612,7 @@ bool CSMFilter::Parser::parse (const std::string& filter, bool allowPredefined) } } -boost::shared_ptr CSMFilter::Parser::getFilter() const +std::shared_ptr CSMFilter::Parser::getFilter() const { if (mError) throw std::logic_error ("No filter available"); diff --git a/apps/opencs/model/filter/parser.hpp b/apps/opencs/model/filter/parser.hpp index 5700102cf..344c552ef 100644 --- a/apps/opencs/model/filter/parser.hpp +++ b/apps/opencs/model/filter/parser.hpp @@ -1,8 +1,6 @@ #ifndef CSM_FILTER_PARSER_H #define CSM_FILTER_PARSER_H -#include - #include "node.hpp" namespace CSMWorld @@ -16,7 +14,7 @@ namespace CSMFilter class Parser { - boost::shared_ptr mFilter; + std::shared_ptr mFilter; std::string mInput; int mIndex; bool mError; @@ -31,14 +29,14 @@ namespace CSMFilter Token checkKeywords (const Token& token); ///< Turn string token into keyword token, if possible. - boost::shared_ptr parseImp (bool allowEmpty = false, bool ignoreOneShot = false); + std::shared_ptr parseImp (bool allowEmpty = false, bool ignoreOneShot = false); ///< Will return a null-pointer, if there is nothing more to parse. - boost::shared_ptr parseNAry (const Token& keyword); + std::shared_ptr parseNAry (const Token& keyword); - boost::shared_ptr parseText(); + std::shared_ptr parseText(); - boost::shared_ptr parseValue(); + std::shared_ptr parseValue(); void error(); @@ -51,7 +49,7 @@ namespace CSMFilter /// /// \return Success? - boost::shared_ptr getFilter() const; + std::shared_ptr getFilter() const; ///< Throws an exception if the last call to parse did not return true. }; } diff --git a/apps/opencs/model/filter/unarynode.cpp b/apps/opencs/model/filter/unarynode.cpp index cbdadf6fc..7211f78b0 100644 --- a/apps/opencs/model/filter/unarynode.cpp +++ b/apps/opencs/model/filter/unarynode.cpp @@ -1,6 +1,6 @@ #include "unarynode.hpp" -CSMFilter::UnaryNode::UnaryNode (boost::shared_ptr child, const std::string& name) +CSMFilter::UnaryNode::UnaryNode (std::shared_ptr child, const std::string& name) : mChild (child), mName (name) {} diff --git a/apps/opencs/model/filter/unarynode.hpp b/apps/opencs/model/filter/unarynode.hpp index 6bbc96092..cbee4e0ba 100644 --- a/apps/opencs/model/filter/unarynode.hpp +++ b/apps/opencs/model/filter/unarynode.hpp @@ -1,20 +1,18 @@ #ifndef CSM_FILTER_UNARYNODE_H #define CSM_FILTER_UNARYNODE_H -#include - #include "node.hpp" namespace CSMFilter { class UnaryNode : public Node { - boost::shared_ptr mChild; + std::shared_ptr mChild; std::string mName; public: - UnaryNode (boost::shared_ptr child, const std::string& name); + UnaryNode (std::shared_ptr child, const std::string& name); const Node& getChild() const; diff --git a/apps/opencs/model/prefs/boolsetting.cpp b/apps/opencs/model/prefs/boolsetting.cpp index 6c0babaf7..6431dc6af 100644 --- a/apps/opencs/model/prefs/boolsetting.cpp +++ b/apps/opencs/model/prefs/boolsetting.cpp @@ -11,7 +11,7 @@ CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, bool default_) -: Setting (parent, values, mutex, key, label), mDefault (default_) +: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0) {} CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip) @@ -22,18 +22,28 @@ CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& too std::pair CSMPrefs::BoolSetting::makeWidgets (QWidget *parent) { - QCheckBox *widget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent); - widget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked); + mWidget = new QCheckBox (QString::fromUtf8 (getLabel().c_str()), parent); + mWidget->setCheckState (mDefault ? Qt::Checked : Qt::Unchecked); if (!mTooltip.empty()) { QString tooltip = QString::fromUtf8 (mTooltip.c_str()); - widget->setToolTip (tooltip); + mWidget->setToolTip (tooltip); } - connect (widget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int))); + connect (mWidget, SIGNAL (stateChanged (int)), this, SLOT (valueChanged (int))); - return std::make_pair (static_cast (0), widget); + return std::make_pair (static_cast (0), mWidget); +} + +void CSMPrefs::BoolSetting::updateWidget() +{ + if (mWidget) + { + mWidget->setCheckState(getValues().getBool(getKey(), getParent()->getKey()) + ? Qt::Checked + : Qt::Unchecked); + } } void CSMPrefs::BoolSetting::valueChanged (int value) diff --git a/apps/opencs/model/prefs/boolsetting.hpp b/apps/opencs/model/prefs/boolsetting.hpp index f8a321859..37c018d14 100644 --- a/apps/opencs/model/prefs/boolsetting.hpp +++ b/apps/opencs/model/prefs/boolsetting.hpp @@ -3,6 +3,8 @@ #include "setting.hpp" +class QCheckBox; + namespace CSMPrefs { class BoolSetting : public Setting @@ -11,6 +13,7 @@ namespace CSMPrefs std::string mTooltip; bool mDefault; + QCheckBox* mWidget; public: @@ -22,6 +25,8 @@ namespace CSMPrefs /// Return label, input widget. virtual std::pair makeWidgets (QWidget *parent); + virtual void updateWidget(); + private slots: void valueChanged (int value); diff --git a/apps/opencs/model/prefs/coloursetting.cpp b/apps/opencs/model/prefs/coloursetting.cpp index d51bfad56..1a41621da 100644 --- a/apps/opencs/model/prefs/coloursetting.cpp +++ b/apps/opencs/model/prefs/coloursetting.cpp @@ -3,6 +3,7 @@ #include #include +#include #include @@ -13,7 +14,7 @@ CSMPrefs::ColourSetting::ColourSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, QColor default_) -: Setting (parent, values, mutex, key, label), mDefault (default_) +: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0) {} CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip (const std::string& tooltip) @@ -26,18 +27,27 @@ std::pair CSMPrefs::ColourSetting::makeWidgets (QWidget *p { QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent); - CSVWidget::ColorEditor *widget = new CSVWidget::ColorEditor (mDefault, parent); + mWidget = new CSVWidget::ColorEditor (mDefault, parent); if (!mTooltip.empty()) { QString tooltip = QString::fromUtf8 (mTooltip.c_str()); label->setToolTip (tooltip); - widget->setToolTip (tooltip); + mWidget->setToolTip (tooltip); } - connect (widget, SIGNAL (pickingFinished()), this, SLOT (valueChanged())); + connect (mWidget, SIGNAL (pickingFinished()), this, SLOT (valueChanged())); - return std::make_pair (label, widget); + return std::make_pair (label, mWidget); +} + +void CSMPrefs::ColourSetting::updateWidget() +{ + if (mWidget) + { + mWidget->setColor(QString::fromStdString + (getValues().getString(getKey(), getParent()->getKey()))); + } } void CSMPrefs::ColourSetting::valueChanged() diff --git a/apps/opencs/model/prefs/coloursetting.hpp b/apps/opencs/model/prefs/coloursetting.hpp index be58426f2..e892b21d6 100644 --- a/apps/opencs/model/prefs/coloursetting.hpp +++ b/apps/opencs/model/prefs/coloursetting.hpp @@ -5,6 +5,11 @@ #include +namespace CSVWidget +{ + class ColorEditor; +} + namespace CSMPrefs { class ColourSetting : public Setting @@ -13,6 +18,7 @@ namespace CSMPrefs std::string mTooltip; QColor mDefault; + CSVWidget::ColorEditor* mWidget; public: @@ -25,6 +31,8 @@ namespace CSMPrefs /// Return label, input widget. virtual std::pair makeWidgets (QWidget *parent); + virtual void updateWidget(); + private slots: void valueChanged(); diff --git a/apps/opencs/model/prefs/doublesetting.cpp b/apps/opencs/model/prefs/doublesetting.cpp index 531196174..8ae6f4818 100644 --- a/apps/opencs/model/prefs/doublesetting.cpp +++ b/apps/opencs/model/prefs/doublesetting.cpp @@ -16,7 +16,7 @@ CSMPrefs::DoubleSetting::DoubleSetting (Category *parent, Settings::Manager *val QMutex *mutex, const std::string& key, const std::string& label, double default_) : Setting (parent, values, mutex, key, label), mPrecision(2), mMin (0), mMax (std::numeric_limits::max()), - mDefault (default_) + mDefault (default_), mWidget(0) {} CSMPrefs::DoubleSetting& CSMPrefs::DoubleSetting::setPrecision(int precision) @@ -54,21 +54,29 @@ std::pair CSMPrefs::DoubleSetting::makeWidgets (QWidget *p { QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent); - QDoubleSpinBox *widget = new QDoubleSpinBox (parent); - widget->setDecimals(mPrecision); - widget->setRange (mMin, mMax); - widget->setValue (mDefault); + mWidget = new QDoubleSpinBox (parent); + mWidget->setDecimals(mPrecision); + mWidget->setRange (mMin, mMax); + mWidget->setValue (mDefault); if (!mTooltip.empty()) { QString tooltip = QString::fromUtf8 (mTooltip.c_str()); label->setToolTip (tooltip); - widget->setToolTip (tooltip); + mWidget->setToolTip (tooltip); } - connect (widget, SIGNAL (valueChanged (double)), this, SLOT (valueChanged (double))); + connect (mWidget, SIGNAL (valueChanged (double)), this, SLOT (valueChanged (double))); - return std::make_pair (label, widget); + return std::make_pair (label, mWidget); +} + +void CSMPrefs::DoubleSetting::updateWidget() +{ + if (mWidget) + { + mWidget->setValue(getValues().getFloat(getKey(), getParent()->getKey())); + } } void CSMPrefs::DoubleSetting::valueChanged (double value) diff --git a/apps/opencs/model/prefs/doublesetting.hpp b/apps/opencs/model/prefs/doublesetting.hpp index 8fd345f4d..4d297409b 100644 --- a/apps/opencs/model/prefs/doublesetting.hpp +++ b/apps/opencs/model/prefs/doublesetting.hpp @@ -3,6 +3,8 @@ #include "setting.hpp" +class QDoubleSpinBox; + namespace CSMPrefs { class DoubleSetting : public Setting @@ -14,6 +16,7 @@ namespace CSMPrefs double mMax; std::string mTooltip; double mDefault; + QDoubleSpinBox* mWidget; public: @@ -35,6 +38,8 @@ namespace CSMPrefs /// Return label, input widget. virtual std::pair makeWidgets (QWidget *parent); + virtual void updateWidget(); + private slots: void valueChanged (double value); diff --git a/apps/opencs/model/prefs/enumsetting.cpp b/apps/opencs/model/prefs/enumsetting.cpp index e69f717ea..226b17173 100644 --- a/apps/opencs/model/prefs/enumsetting.cpp +++ b/apps/opencs/model/prefs/enumsetting.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -41,7 +42,7 @@ CSMPrefs::EnumValues& CSMPrefs::EnumValues::add (const std::string& value, const CSMPrefs::EnumSetting::EnumSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, const EnumValue& default_) -: Setting (parent, values, mutex, key, label), mDefault (default_) +: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(0) {} CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::setTooltip (const std::string& tooltip) @@ -72,7 +73,7 @@ std::pair CSMPrefs::EnumSetting::makeWidgets (QWidget *par { QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent); - QComboBox *widget = new QComboBox (parent); + mWidget = new QComboBox (parent); int index = 0; @@ -81,14 +82,14 @@ std::pair CSMPrefs::EnumSetting::makeWidgets (QWidget *par if (mDefault.mValue==mValues.mValues[i].mValue) index = i; - widget->addItem (QString::fromUtf8 (mValues.mValues[i].mValue.c_str())); + mWidget->addItem (QString::fromUtf8 (mValues.mValues[i].mValue.c_str())); if (!mValues.mValues[i].mTooltip.empty()) - widget->setItemData (i, QString::fromUtf8 (mValues.mValues[i].mTooltip.c_str()), + mWidget->setItemData (i, QString::fromUtf8 (mValues.mValues[i].mTooltip.c_str()), Qt::ToolTipRole); } - widget->setCurrentIndex (index); + mWidget->setCurrentIndex (index); if (!mTooltip.empty()) { @@ -96,9 +97,20 @@ std::pair CSMPrefs::EnumSetting::makeWidgets (QWidget *par label->setToolTip (tooltip); } - connect (widget, SIGNAL (currentIndexChanged (int)), this, SLOT (valueChanged (int))); + connect (mWidget, SIGNAL (currentIndexChanged (int)), this, SLOT (valueChanged (int))); - return std::make_pair (label, widget); + return std::make_pair (label, mWidget); +} + +void CSMPrefs::EnumSetting::updateWidget() +{ + if (mWidget) + { + int index = mWidget->findText(QString::fromStdString + (getValues().getString(getKey(), getParent()->getKey()))); + + mWidget->setCurrentIndex(index); + } } void CSMPrefs::EnumSetting::valueChanged (int value) diff --git a/apps/opencs/model/prefs/enumsetting.hpp b/apps/opencs/model/prefs/enumsetting.hpp index 728de3acd..b01635cdf 100644 --- a/apps/opencs/model/prefs/enumsetting.hpp +++ b/apps/opencs/model/prefs/enumsetting.hpp @@ -5,6 +5,8 @@ #include "setting.hpp" +class QComboBox; + namespace CSMPrefs { struct EnumValue @@ -35,6 +37,7 @@ namespace CSMPrefs std::string mTooltip; EnumValue mDefault; EnumValues mValues; + QComboBox* mWidget; public: @@ -53,6 +56,8 @@ namespace CSMPrefs /// Return label, input widget. virtual std::pair makeWidgets (QWidget *parent); + virtual void updateWidget(); + private slots: void valueChanged (int value); diff --git a/apps/opencs/model/prefs/intsetting.cpp b/apps/opencs/model/prefs/intsetting.cpp index 269a63af4..25dbf78c2 100644 --- a/apps/opencs/model/prefs/intsetting.cpp +++ b/apps/opencs/model/prefs/intsetting.cpp @@ -15,7 +15,7 @@ CSMPrefs::IntSetting::IntSetting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label, int default_) : Setting (parent, values, mutex, key, label), mMin (0), mMax (std::numeric_limits::max()), - mDefault (default_) + mDefault (default_), mWidget(0) {} CSMPrefs::IntSetting& CSMPrefs::IntSetting::setRange (int min, int max) @@ -47,20 +47,28 @@ std::pair CSMPrefs::IntSetting::makeWidgets (QWidget *pare { QLabel *label = new QLabel (QString::fromUtf8 (getLabel().c_str()), parent); - QSpinBox *widget = new QSpinBox (parent); - widget->setRange (mMin, mMax); - widget->setValue (mDefault); + mWidget = new QSpinBox (parent); + mWidget->setRange (mMin, mMax); + mWidget->setValue (mDefault); if (!mTooltip.empty()) { QString tooltip = QString::fromUtf8 (mTooltip.c_str()); label->setToolTip (tooltip); - widget->setToolTip (tooltip); + mWidget->setToolTip (tooltip); } - connect (widget, SIGNAL (valueChanged (int)), this, SLOT (valueChanged (int))); + connect (mWidget, SIGNAL (valueChanged (int)), this, SLOT (valueChanged (int))); - return std::make_pair (label, widget); + return std::make_pair (label, mWidget); +} + +void CSMPrefs::IntSetting::updateWidget() +{ + if (mWidget) + { + mWidget->setValue(getValues().getInt(getKey(), getParent()->getKey())); + } } void CSMPrefs::IntSetting::valueChanged (int value) diff --git a/apps/opencs/model/prefs/intsetting.hpp b/apps/opencs/model/prefs/intsetting.hpp index 0ee6cf9e3..ee0989d83 100644 --- a/apps/opencs/model/prefs/intsetting.hpp +++ b/apps/opencs/model/prefs/intsetting.hpp @@ -3,6 +3,8 @@ #include "setting.hpp" +class QSpinBox; + namespace CSMPrefs { class IntSetting : public Setting @@ -13,6 +15,7 @@ namespace CSMPrefs int mMax; std::string mTooltip; int mDefault; + QSpinBox* mWidget; public: @@ -31,6 +34,8 @@ namespace CSMPrefs /// Return label, input widget. virtual std::pair makeWidgets (QWidget *parent); + virtual void updateWidget(); + private slots: void valueChanged (int value); diff --git a/apps/opencs/model/prefs/modifiersetting.cpp b/apps/opencs/model/prefs/modifiersetting.cpp index 4f4fac248..da6b2ccdd 100644 --- a/apps/opencs/model/prefs/modifiersetting.cpp +++ b/apps/opencs/model/prefs/modifiersetting.cpp @@ -32,6 +32,10 @@ namespace CSMPrefs widget->setCheckable(true); widget->installEventFilter(this); + + // right clicking on button sets shortcut to RMB, so context menu should not appear + widget->setContextMenuPolicy(Qt::PreventContextMenu); + mButton = widget; connect(widget, SIGNAL(toggled(bool)), this, SLOT(buttonToggled(bool))); @@ -39,6 +43,19 @@ namespace CSMPrefs return std::make_pair(label, widget); } + void ModifierSetting::updateWidget() + { + if (mButton) + { + std::string shortcut = getValues().getString(getKey(), getParent()->getKey()); + + int modifier; + State::get().getShortcutManager().convertFromString(shortcut, modifier); + State::get().getShortcutManager().setModifier(getKey(), modifier); + resetState(); + } + } + bool ModifierSetting::eventFilter(QObject* target, QEvent* event) { if (event->type() == QEvent::KeyPress) diff --git a/apps/opencs/model/prefs/modifiersetting.hpp b/apps/opencs/model/prefs/modifiersetting.hpp index 95983f66d..2c6a45b5a 100644 --- a/apps/opencs/model/prefs/modifiersetting.hpp +++ b/apps/opencs/model/prefs/modifiersetting.hpp @@ -21,6 +21,8 @@ namespace CSMPrefs virtual std::pair makeWidgets(QWidget* parent); + virtual void updateWidget(); + protected: bool eventFilter(QObject* target, QEvent* event); diff --git a/apps/opencs/model/prefs/setting.cpp b/apps/opencs/model/prefs/setting.cpp index 75b58322d..165062232 100644 --- a/apps/opencs/model/prefs/setting.cpp +++ b/apps/opencs/model/prefs/setting.cpp @@ -30,6 +30,10 @@ std::pair CSMPrefs::Setting::makeWidgets (QWidget *parent) return std::pair (0, 0); } +void CSMPrefs::Setting::updateWidget() +{ +} + const CSMPrefs::Category *CSMPrefs::Setting::getParent() const { return mParent; diff --git a/apps/opencs/model/prefs/setting.hpp b/apps/opencs/model/prefs/setting.hpp index 00bcc638b..7cb2d7acf 100644 --- a/apps/opencs/model/prefs/setting.hpp +++ b/apps/opencs/model/prefs/setting.hpp @@ -47,6 +47,11 @@ namespace CSMPrefs /// widget. virtual std::pair makeWidgets (QWidget *parent); + /// Updates the widget returned by makeWidgets() to the current setting. + /// + /// \note If make_widgets() has not been called yet then nothing happens. + virtual void updateWidget(); + const Category *getParent() const; const std::string& getKey() const; diff --git a/apps/opencs/model/prefs/shortcutsetting.cpp b/apps/opencs/model/prefs/shortcutsetting.cpp index c56119deb..de495b9fc 100644 --- a/apps/opencs/model/prefs/shortcutsetting.cpp +++ b/apps/opencs/model/prefs/shortcutsetting.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "state.hpp" #include "shortcutmanager.hpp" @@ -39,6 +40,10 @@ namespace CSMPrefs widget->setCheckable(true); widget->installEventFilter(this); + + // right clicking on button sets shortcut to RMB, so context menu should not appear + widget->setContextMenuPolicy(Qt::PreventContextMenu); + mButton = widget; connect(widget, SIGNAL(toggled(bool)), this, SLOT(buttonToggled(bool))); @@ -46,6 +51,19 @@ namespace CSMPrefs return std::make_pair(label, widget); } + void ShortcutSetting::updateWidget() + { + if (mButton) + { + std::string shortcut = getValues().getString(getKey(), getParent()->getKey()); + + QKeySequence sequence; + State::get().getShortcutManager().convertFromString(shortcut, sequence); + State::get().getShortcutManager().setSequence(getKey(), sequence); + resetState(); + } + } + bool ShortcutSetting::eventFilter(QObject* target, QEvent* event) { if (event->type() == QEvent::KeyPress) diff --git a/apps/opencs/model/prefs/shortcutsetting.hpp b/apps/opencs/model/prefs/shortcutsetting.hpp index bb38b580a..c388305a6 100644 --- a/apps/opencs/model/prefs/shortcutsetting.hpp +++ b/apps/opencs/model/prefs/shortcutsetting.hpp @@ -21,6 +21,8 @@ namespace CSMPrefs virtual std::pair makeWidgets(QWidget* parent); + virtual void updateWidget(); + protected: bool eventFilter(QObject* target, QEvent* event); diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index b8d6102ac..5c0b2e282 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -152,6 +152,8 @@ void CSMPrefs::State::declare() setRange (0, 10000); declareInt ("error-height", "Initial height of the error panel", 100). setRange (100, 10000); + declareBool ("highlight-occurrences", "Highlight other occurrences of selected names", true); + declareColour ("colour-highlight", "Colour of highlighted occurrences", QColor("lightcyan")); declareSeparator(); declareColour ("colour-int", "Highlight Colour: Integer Literals", QColor ("darkmagenta")); declareColour ("colour-float", "Highlight Colour: Float Literals", QColor ("magenta")); @@ -257,6 +259,7 @@ void CSMPrefs::State::declare() declareShortcut ("document-character-topicinfos", "Open Topic Info List", QKeySequence()); declareShortcut ("document-character-journalinfos", "Open Journal Info List", QKeySequence()); declareShortcut ("document-character-bodyparts", "Open Body Part List", QKeySequence()); + declareShortcut ("document-assets-reload", "Reload Assets", QKeySequence(Qt::Key_F5)); declareShortcut ("document-assets-sounds", "Open Sound Asset List", QKeySequence()); declareShortcut ("document-assets-soundgens", "Open Sound Generator List", QKeySequence()); declareShortcut ("document-assets-meshes", "Open Mesh Asset List", QKeySequence()); @@ -326,6 +329,10 @@ void CSMPrefs::State::declare() declareShortcut ("orbit-roll-right", "Roll Right", QKeySequence(Qt::Key_E)); declareShortcut ("orbit-speed-mode", "Toggle Speed Mode", QKeySequence(Qt::Key_F)); declareShortcut ("orbit-center-selection", "Center On Selected", QKeySequence(Qt::Key_C)); + + declareSubcategory ("Script Editor"); + declareShortcut ("script-editor-comment", "Comment Selection", QKeySequence()); + declareShortcut ("script-editor-uncomment", "Uncomment Selection", QKeySequence()); } void CSMPrefs::State::declareCategory (const std::string& key) @@ -581,6 +588,41 @@ CSMPrefs::State& CSMPrefs::State::get() return *sThis; } +void CSMPrefs::State::resetCategory(const std::string& category) +{ + for (Settings::CategorySettingValueMap::iterator i = mSettings.mUserSettings.begin(); + i != mSettings.mUserSettings.end(); ++i) + { + // if the category matches + if (i->first.first == category) + { + // mark the setting as changed + mSettings.mChangedSettings.insert(std::make_pair(i->first.first, i->first.second)); + // reset the value to the default + i->second = mSettings.mDefaultSettings[i->first]; + } + } + + Collection::iterator container = mCategories.find(category); + if (container != mCategories.end()) + { + Category settings = container->second; + for (Category::Iterator i = settings.begin(); i != settings.end(); ++i) + { + (*i)->updateWidget(); + update(**i); + } + } +} + +void CSMPrefs::State::resetAll() +{ + for (Collection::iterator iter = mCategories.begin(); iter != mCategories.end(); ++iter) + { + resetCategory(iter->first); + } +} + CSMPrefs::State& CSMPrefs::get() { diff --git a/apps/opencs/model/prefs/state.hpp b/apps/opencs/model/prefs/state.hpp index 1e46c68ee..a32583dc5 100644 --- a/apps/opencs/model/prefs/state.hpp +++ b/apps/opencs/model/prefs/state.hpp @@ -106,6 +106,10 @@ namespace CSMPrefs static State& get(); + void resetCategory(const std::string& category); + + void resetAll(); + signals: void settingChanged (const CSMPrefs::Setting *setting); diff --git a/apps/opencs/model/tools/mergeoperation.cpp b/apps/opencs/model/tools/mergeoperation.cpp index 907d742ed..9b595046a 100644 --- a/apps/opencs/model/tools/mergeoperation.cpp +++ b/apps/opencs/model/tools/mergeoperation.cpp @@ -45,9 +45,9 @@ CSMTools::MergeOperation::MergeOperation (CSMDoc::Document& document, ToUTF8::Fr appendStage (new FinishMergedDocumentStage (mState, encoding)); } -void CSMTools::MergeOperation::setTarget (std::auto_ptr document) +void CSMTools::MergeOperation::setTarget (std::unique_ptr document) { - mState.mTarget = document; + mState.mTarget = std::move(document); } void CSMTools::MergeOperation::operationDone() diff --git a/apps/opencs/model/tools/mergeoperation.hpp b/apps/opencs/model/tools/mergeoperation.hpp index bdaeb2ccd..733fc8eba 100644 --- a/apps/opencs/model/tools/mergeoperation.hpp +++ b/apps/opencs/model/tools/mergeoperation.hpp @@ -27,7 +27,7 @@ namespace CSMTools MergeOperation (CSMDoc::Document& document, ToUTF8::FromType encoding); /// \attention Do not call this function while a merge is running. - void setTarget (std::auto_ptr document); + void setTarget (std::unique_ptr document); protected slots: diff --git a/apps/opencs/model/tools/mergestate.hpp b/apps/opencs/model/tools/mergestate.hpp index 29e1bbda7..96e6752e2 100644 --- a/apps/opencs/model/tools/mergestate.hpp +++ b/apps/opencs/model/tools/mergestate.hpp @@ -12,7 +12,7 @@ namespace CSMTools { struct MergeState { - std::auto_ptr mTarget; + std::unique_ptr mTarget; CSMDoc::Document& mSource; bool mCompleted; std::map, int> mTextureIndices; // (texture, content file) -> new texture diff --git a/apps/opencs/model/tools/referencecheck.cpp b/apps/opencs/model/tools/referencecheck.cpp index be9663e7a..7f247741c 100644 --- a/apps/opencs/model/tools/referencecheck.cpp +++ b/apps/opencs/model/tools/referencecheck.cpp @@ -1,7 +1,5 @@ #include "referencecheck.hpp" -#include - CSMTools::ReferenceCheckStage::ReferenceCheckStage( const CSMWorld::RefCollection& references, const CSMWorld::RefIdCollection& referencables, @@ -40,9 +38,9 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message if ((isLight && cellRef.mChargeFloat < -1) || (!isLight && cellRef.mChargeInt < -1)) { std::string str = " has invalid charge "; if (localIndex.second == CSMWorld::UniversalId::Type_Light) - str += boost::lexical_cast(cellRef.mChargeFloat); + str += std::to_string(cellRef.mChargeFloat); else - str += boost::lexical_cast(cellRef.mChargeInt); + str += std::to_string(cellRef.mChargeInt); messages.push_back(std::make_pair(id, id.getId() + str)); } } @@ -66,9 +64,9 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message // Check item's faction rank if (hasFaction && cellRef.mFactionRank < -1) - messages.push_back(std::make_pair(id, " has faction set but has invalid faction rank " + boost::lexical_cast(cellRef.mFactionRank))); + messages.push_back(std::make_pair(id, " has faction set but has invalid faction rank " + std::to_string(cellRef.mFactionRank))); else if (!hasFaction && cellRef.mFactionRank != -2) - messages.push_back(std::make_pair(id, " has invalid faction rank " + boost::lexical_cast(cellRef.mFactionRank))); + messages.push_back(std::make_pair(id, " has invalid faction rank " + std::to_string(cellRef.mFactionRank))); // If door have destination cell, check if that reference is valid if (!cellRef.mDestCell.empty()) @@ -79,7 +77,7 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message if (cellRef.mScale < 0) { std::string str = " has negative scale "; - str += boost::lexical_cast(cellRef.mScale); + str += std::to_string(cellRef.mScale); messages.push_back(std::make_pair(id, id.getId() + str)); } @@ -87,7 +85,7 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages &message if (cellRef.mEnchantmentCharge < 0 && cellRef.mEnchantmentCharge != -1) { std::string str = " has negative enchantment points "; - str += boost::lexical_cast(cellRef.mEnchantmentCharge); + str += std::to_string(cellRef.mEnchantmentCharge); messages.push_back(std::make_pair(id, id.getId() + str)); } diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index f538a716e..3b2c80263 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -216,7 +216,7 @@ void CSMTools::Tools::runSearch (const CSMWorld::UniversalId& searchId, const Se mSearch.start(); } -void CSMTools::Tools::runMerge (std::auto_ptr target) +void CSMTools::Tools::runMerge (std::unique_ptr target) { // not setting an active report, because merge does not produce messages @@ -230,7 +230,7 @@ void CSMTools::Tools::runMerge (std::auto_ptr target) target->flagAsDirty(); - mMergeOperation->setTarget (target); + mMergeOperation->setTarget (std::move(target)); mMerge.start(); } diff --git a/apps/opencs/model/tools/tools.hpp b/apps/opencs/model/tools/tools.hpp index e16a3854c..f544c8312 100644 --- a/apps/opencs/model/tools/tools.hpp +++ b/apps/opencs/model/tools/tools.hpp @@ -77,7 +77,7 @@ namespace CSMTools void runSearch (const CSMWorld::UniversalId& searchId, const Search& search); - void runMerge (std::auto_ptr target); + void runMerge (std::unique_ptr target); void abortOperation (int type); ///< \attention The operation is not aborted immediately. diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 33a71e97a..154bdab82 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -5,8 +5,6 @@ #include #include -#include - #include #include diff --git a/apps/opencs/model/world/commanddispatcher.cpp b/apps/opencs/model/world/commanddispatcher.cpp index ffbaa3dec..5d6a35cc5 100644 --- a/apps/opencs/model/world/commanddispatcher.cpp +++ b/apps/opencs/model/world/commanddispatcher.cpp @@ -138,7 +138,7 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons if (mLocked) return; - std::auto_ptr modifyCell; + std::unique_ptr modifyCell; int columnId = model->data (index, ColumnBase::Role_ColumnId).toInt(); @@ -167,7 +167,7 @@ void CSMWorld::CommandDispatcher::executeModify (QAbstractItemModel *model, cons } } - std::auto_ptr modifyData ( + std::unique_ptr modifyData ( new CSMWorld::ModifyCommand (*model, index, new_)); if (modifyCell.get()) diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 5a59f19f7..007190e4a 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -11,6 +11,8 @@ #include #include +#include +#include #include "idtable.hpp" #include "idtree.hpp" @@ -61,11 +63,18 @@ int CSMWorld::Data::count (RecordBase::State state, const CollectionBase& collec return number; } -CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir) +CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, + const std::vector& archives, const Fallback::Map* fallback, const boost::filesystem::path& resDir) : mEncoder (encoding), mPathgrids (mCells), mRefs (mCells), - mResourcesManager (resourcesManager), mFallbackMap(fallback), - mReader (0), mDialogue (0), mReaderIndex(1), mResourceSystem(new Resource::ResourceSystem(resourcesManager.getVFS())) + mFallbackMap(fallback), mReader (0), mDialogue (0), mReaderIndex(1), + mFsStrict(fsStrict), mDataPaths(dataPaths), mArchives(archives) { + mVFS.reset(new VFS::Manager(mFsStrict)); + VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true); + + mResourcesManager.setVFS(mVFS.get()); + mResourceSystem.reset(new Resource::ResourceSystem(mVFS.get())); + mResourceSystem->getSceneManager()->setShaderPath((resDir / "shaders").string()); int index = 0; @@ -327,7 +336,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mCells.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_WaterLevel, ColumnBase::Display_Float)); mCells.getNestableColumn(index)->addColumn( - new NestedChildColumn (Columns::ColumnId_MapColor, ColumnBase::Display_Integer)); + new NestedChildColumn (Columns::ColumnId_MapColor, ColumnBase::Display_Colour)); mEnchantments.addColumn (new StringIdColumn); mEnchantments.addColumn (new RecordStateColumn); @@ -554,12 +563,12 @@ CSMWorld::Data::~Data() delete mReader; } -boost::shared_ptr CSMWorld::Data::getResourceSystem() +std::shared_ptr CSMWorld::Data::getResourceSystem() { return mResourceSystem; } -boost::shared_ptr CSMWorld::Data::getResourceSystem() const +std::shared_ptr CSMWorld::Data::getResourceSystem() const { return mResourceSystem; } @@ -891,7 +900,7 @@ void CSMWorld::Data::merge() int CSMWorld::Data::startLoading (const boost::filesystem::path& path, bool base, bool project) { // Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading - boost::shared_ptr ptr(mReader); + std::shared_ptr ptr(mReader); mReaders.push_back(ptr); mReader = 0; @@ -945,7 +954,7 @@ bool CSMWorld::Data::continueLoading (CSMDoc::Messages& messages) // Don't delete the Reader yet. Some record types store a reference to the Reader to handle on-demand loading. // We don't store non-base reader, because everything going into modified will be // fully loaded during the initial loading process. - boost::shared_ptr ptr(mReader); + std::shared_ptr ptr(mReader); mReaders.push_back(ptr); } else @@ -1215,6 +1224,43 @@ std::vector CSMWorld::Data::getIds (bool listDeleted) const return ids; } +void CSMWorld::Data::assetsChanged() +{ + mVFS.get()->reset(); + VFS::registerArchives(mVFS.get(), Files::Collections(mDataPaths, !mFsStrict), mArchives, true); + + const UniversalId assetTableIds[] = { + UniversalId::Type_Meshes, + UniversalId::Type_Icons, + UniversalId::Type_Musics, + UniversalId::Type_SoundsRes, + UniversalId::Type_Textures, + UniversalId::Type_Videos + }; + + size_t numAssetTables = sizeof(assetTableIds) / sizeof(UniversalId); + + for (size_t i = 0; i < numAssetTables; ++i) + { + ResourceTable* table = static_cast(getTableModel(assetTableIds[i])); + table->beginReset(); + } + + // Trigger recreation + mResourcesManager.recreateResources(); + + for (size_t i = 0; i < numAssetTables; ++i) + { + ResourceTable* table = static_cast(getTableModel(assetTableIds[i])); + table->endReset(); + } + + // Get rid of potentially old cached assets + mResourceSystem->clearCache(); + + emit assetTablesChanged(); +} + void CSMWorld::Data::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) { if (topLeft.column()<=0) @@ -1228,7 +1274,7 @@ void CSMWorld::Data::rowsChanged (const QModelIndex& parent, int start, int end) const VFS::Manager* CSMWorld::Data::getVFS() const { - return mResourcesManager.getVFS(); + return mVFS.get(); } const Fallback::Map* CSMWorld::Data::getFallbackMap() const diff --git a/apps/opencs/model/world/data.hpp b/apps/opencs/model/world/data.hpp index dc00a33d2..8a3667ea1 100644 --- a/apps/opencs/model/world/data.hpp +++ b/apps/opencs/model/world/data.hpp @@ -31,6 +31,7 @@ #include +#include #include #include "../doc/stage.hpp" @@ -46,6 +47,7 @@ #include "infocollection.hpp" #include "nestedinfocollection.hpp" #include "pathgrid.hpp" +#include "resourcesmanager.hpp" #include "metadata.hpp" #ifndef Q_MOC_RUN #include "subcellcollection.hpp" @@ -108,7 +110,6 @@ namespace CSMWorld RefCollection mRefs; IdCollection mFilters; Collection mMetaData; - const ResourcesManager& mResourcesManager; const Fallback::Map* mFallbackMap; std::vector mModels; std::map mModelIndex; @@ -119,9 +120,14 @@ namespace CSMWorld std::map > mRefLoadCache; int mReaderIndex; - boost::shared_ptr mResourceSystem; + bool mFsStrict; + Files::PathContainer mDataPaths; + std::vector mArchives; + std::unique_ptr mVFS; + ResourcesManager mResourcesManager; + std::shared_ptr mResourceSystem; - std::vector > mReaders; + std::vector > mReaders; std::map mContentFileNames; @@ -140,7 +146,9 @@ namespace CSMWorld public: - Data (ToUTF8::FromType encoding, const ResourcesManager& resourcesManager, const Fallback::Map* fallback, const boost::filesystem::path& resDir); + Data (ToUTF8::FromType encoding, bool fsStrict, const Files::PathContainer& dataPaths, + const std::vector& archives, const Fallback::Map* fallback, + const boost::filesystem::path& resDir); virtual ~Data(); @@ -148,9 +156,9 @@ namespace CSMWorld const Fallback::Map* getFallbackMap() const; - boost::shared_ptr getResourceSystem(); + std::shared_ptr getResourceSystem(); - boost::shared_ptr getResourceSystem() const; + std::shared_ptr getResourceSystem() const; const IdCollection& getGlobals() const; @@ -304,8 +312,12 @@ namespace CSMWorld void idListChanged(); + void assetTablesChanged(); + private slots: + void assetsChanged(); + void dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); void rowsChanged (const QModelIndex& parent, int start, int end); diff --git a/apps/opencs/model/world/idcompletionmanager.cpp b/apps/opencs/model/world/idcompletionmanager.cpp index 7f3221342..9fa6e3add 100644 --- a/apps/opencs/model/world/idcompletionmanager.cpp +++ b/apps/opencs/model/world/idcompletionmanager.cpp @@ -1,7 +1,5 @@ #include "idcompletionmanager.hpp" -#include - #include #include "../../view/widget/completerpopup.hpp" @@ -77,7 +75,7 @@ bool CSMWorld::IdCompletionManager::hasCompleterFor(CSMWorld::ColumnBase::Displa return mCompleters.find(display) != mCompleters.end(); } -boost::shared_ptr CSMWorld::IdCompletionManager::getCompleter(CSMWorld::ColumnBase::Display display) +std::shared_ptr CSMWorld::IdCompletionManager::getCompleter(CSMWorld::ColumnBase::Display display) { if (!hasCompleterFor(display)) { @@ -99,7 +97,7 @@ void CSMWorld::IdCompletionManager::generateCompleters(CSMWorld::Data &data) int idColumn = table->searchColumnIndex(CSMWorld::Columns::ColumnId_Id); if (idColumn != -1) { - boost::shared_ptr completer = boost::make_shared(table); + std::shared_ptr completer = std::make_shared(table); completer->setCompletionColumn(idColumn); // The completion role must be Qt::DisplayRole to get the ID values from the model completer->setCompletionRole(Qt::DisplayRole); diff --git a/apps/opencs/model/world/idcompletionmanager.hpp b/apps/opencs/model/world/idcompletionmanager.hpp index 7944e6777..e48360432 100644 --- a/apps/opencs/model/world/idcompletionmanager.hpp +++ b/apps/opencs/model/world/idcompletionmanager.hpp @@ -3,8 +3,7 @@ #include #include - -#include +#include #include "columnbase.hpp" #include "universalid.hpp" @@ -20,7 +19,7 @@ namespace CSMWorld { static const std::map sCompleterModelTypes; - std::map > mCompleters; + std::map > mCompleters; // Don't allow copying IdCompletionManager(const IdCompletionManager &); @@ -34,7 +33,7 @@ namespace CSMWorld IdCompletionManager(Data &data); bool hasCompleterFor(ColumnBase::Display display) const; - boost::shared_ptr getCompleter(ColumnBase::Display display); + std::shared_ptr getCompleter(ColumnBase::Display display); }; } diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index fbf7b6cf3..6d50e9edb 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -82,7 +82,7 @@ void CSMWorld::IdTableProxyModel::setSourceModel(QAbstractItemModel *model) SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); } -void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr& filter) +void CSMWorld::IdTableProxyModel::setFilter (const std::shared_ptr& filter) { beginResetModel(); mFilter = filter; diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index cf31b5c11..dd7ab41eb 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -3,8 +3,6 @@ #include -#include - #include #include @@ -19,7 +17,7 @@ namespace CSMWorld { Q_OBJECT - boost::shared_ptr mFilter; + std::shared_ptr mFilter; std::map mColumnMap; // column ID, column index in this model (or -1) // Cache of enum values for enum columns (e.g. Modified, Record Type). @@ -43,7 +41,7 @@ namespace CSMWorld virtual void setSourceModel(QAbstractItemModel *model); - void setFilter (const boost::shared_ptr& filter); + void setFilter (const std::shared_ptr& filter); void refreshFilter(); diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index c0ce575b7..31dae256e 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -808,7 +808,7 @@ void CSMWorld::RefIdCollection::cloneRecord(const std::string& origin, const std::string& destination, const CSMWorld::UniversalId::Type type) { - std::auto_ptr newRecord(mData.getRecord(mData.searchId(origin)).modifiedCopy()); + std::unique_ptr newRecord(mData.getRecord(mData.searchId(origin)).modifiedCopy()); mAdapters.find(type)->second->setId(*newRecord, destination); mData.insertRecord(*newRecord, type, destination); } diff --git a/apps/opencs/model/world/refiddata.cpp b/apps/opencs/model/world/refiddata.cpp index 2d8c9ac10..e2ffbcca6 100644 --- a/apps/opencs/model/world/refiddata.cpp +++ b/apps/opencs/model/world/refiddata.cpp @@ -389,7 +389,7 @@ void CSMWorld::RefIdData::copyTo (int index, RefIdData& target) const std::string id = source->getId (localIndex.first); - std::auto_ptr newRecord (source->getRecord (localIndex.first).modifiedCopy()); + std::unique_ptr newRecord (source->getRecord (localIndex.first).modifiedCopy()); target.insertRecord (*newRecord, localIndex.second, id); } diff --git a/apps/opencs/model/world/resources.cpp b/apps/opencs/model/world/resources.cpp index 5fe9194d7..5bf0267bb 100644 --- a/apps/opencs/model/world/resources.cpp +++ b/apps/opencs/model/world/resources.cpp @@ -12,6 +12,14 @@ CSMWorld::Resources::Resources (const VFS::Manager* vfs, const std::string& base const char * const *extensions) : mBaseDirectory (baseDirectory), mType (type) { + recreate(vfs, extensions); +} + +void CSMWorld::Resources::recreate(const VFS::Manager* vfs, const char * const *extensions) +{ + mFiles.clear(); + mIndex.clear(); + int baseSize = mBaseDirectory.size(); const std::map& index = vfs->getIndex(); diff --git a/apps/opencs/model/world/resources.hpp b/apps/opencs/model/world/resources.hpp index d6998da9f..5e9872ea8 100644 --- a/apps/opencs/model/world/resources.hpp +++ b/apps/opencs/model/world/resources.hpp @@ -27,6 +27,8 @@ namespace CSMWorld Resources (const VFS::Manager* vfs, const std::string& baseDirectory, UniversalId::Type type, const char * const *extensions = 0); + void recreate(const VFS::Manager* vfs, const char * const *extensions = 0); + int getSize() const; std::string getId (int index) const; diff --git a/apps/opencs/model/world/resourcesmanager.cpp b/apps/opencs/model/world/resourcesmanager.cpp index 016799be3..62dfe53a9 100644 --- a/apps/opencs/model/world/resourcesmanager.cpp +++ b/apps/opencs/model/world/resourcesmanager.cpp @@ -14,21 +14,24 @@ void CSMWorld::ResourcesManager::addResources (const Resources& resources) resources)); } +const char * const * CSMWorld::ResourcesManager::getMeshExtensions() +{ + // maybe we could go over the osgDB::Registry to list all supported node formats + static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 }; + return sMeshTypes; +} + void CSMWorld::ResourcesManager::setVFS(const VFS::Manager *vfs) { mVFS = vfs; mResources.clear(); - // maybe we could go over the osgDB::Registry to list all supported node formats - - static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 }; - - addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, sMeshTypes)); + addResources (Resources (vfs, "meshes", UniversalId::Type_Mesh, getMeshExtensions())); addResources (Resources (vfs, "icons", UniversalId::Type_Icon)); addResources (Resources (vfs, "music", UniversalId::Type_Music)); addResources (Resources (vfs, "sound", UniversalId::Type_SoundRes)); addResources (Resources (vfs, "textures", UniversalId::Type_Texture)); - addResources (Resources (vfs, "videos", UniversalId::Type_Video)); + addResources (Resources (vfs, "video", UniversalId::Type_Video)); } const VFS::Manager* CSMWorld::ResourcesManager::getVFS() const @@ -36,6 +39,18 @@ const VFS::Manager* CSMWorld::ResourcesManager::getVFS() const return mVFS; } +void CSMWorld::ResourcesManager::recreateResources() +{ + std::map::iterator it = mResources.begin(); + for ( ; it != mResources.end(); ++it) + { + if (it->first == UniversalId::Type_Mesh) + it->second.recreate(mVFS, getMeshExtensions()); + else + it->second.recreate(mVFS); + } +} + const CSMWorld::Resources& CSMWorld::ResourcesManager::get (UniversalId::Type type) const { std::map::const_iterator iter = mResources.find (type); diff --git a/apps/opencs/model/world/resourcesmanager.hpp b/apps/opencs/model/world/resourcesmanager.hpp index 1ce06f2d3..0e8385300 100644 --- a/apps/opencs/model/world/resourcesmanager.hpp +++ b/apps/opencs/model/world/resourcesmanager.hpp @@ -22,6 +22,8 @@ namespace CSMWorld void addResources (const Resources& resources); + const char * const * getMeshExtensions(); + public: ResourcesManager(); @@ -30,6 +32,8 @@ namespace CSMWorld void setVFS(const VFS::Manager* vfs); + void recreateResources(); + const Resources& get (UniversalId::Type type) const; }; } diff --git a/apps/opencs/model/world/resourcetable.cpp b/apps/opencs/model/world/resourcetable.cpp index 5227ec3e6..f55f87873 100644 --- a/apps/opencs/model/world/resourcetable.cpp +++ b/apps/opencs/model/world/resourcetable.cpp @@ -154,3 +154,13 @@ int CSMWorld::ResourceTable::getColumnId (int column) const return -1; } + +void CSMWorld::ResourceTable::beginReset() +{ + beginResetModel(); +} + +void CSMWorld::ResourceTable::endReset() +{ + endResetModel(); +} diff --git a/apps/opencs/model/world/resourcetable.hpp b/apps/opencs/model/world/resourcetable.hpp index 88dcc24b0..7d538df53 100644 --- a/apps/opencs/model/world/resourcetable.hpp +++ b/apps/opencs/model/world/resourcetable.hpp @@ -52,7 +52,12 @@ namespace CSMWorld /// Is \a id flagged as deleted? virtual bool isDeleted (const std::string& id) const; - virtual int getColumnId (int column) const; + virtual int getColumnId (int column) const; + + /// Signal Qt that the data is about to change. + void beginReset(); + /// Signal Qt that the data has been changed. + void endReset(); }; } diff --git a/apps/opencs/view/doc/adjusterwidget.cpp b/apps/opencs/view/doc/adjusterwidget.cpp index 620d853ac..06da68ed8 100644 --- a/apps/opencs/view/doc/adjusterwidget.cpp +++ b/apps/opencs/view/doc/adjusterwidget.cpp @@ -1,8 +1,5 @@ #include "adjusterwidget.hpp" -#include -#include - #include #include diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index ff49a90fd..dfbeea031 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -284,6 +284,13 @@ void CSVDoc::View::setupAssetsMenu() { QMenu *assets = menuBar()->addMenu (tr ("Assets")); + QAction *reload = new QAction (tr ("Reload"), this); + connect (reload, SIGNAL (triggered()), &mDocument->getData(), SLOT (assetsChanged())); + setupShortcut("document-assets-reload", reload); + assets->addAction (reload); + + assets->addSeparator(); + QAction *sounds = new QAction (tr ("Sounds"), this); connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView())); setupShortcut("document-assets-sounds", sounds); diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index f672877d9..51a36969a 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -1,8 +1,6 @@ #ifndef CSV_FILTER_EDITWIDGET_H #define CSV_FILTER_EDITWIDGET_H -#include - #include #include #include @@ -38,7 +36,7 @@ namespace CSVFilter signals: - void filterChanged (boost::shared_ptr filter); + void filterChanged (std::shared_ptr filter); private: std::string generateFilter(std::pair >& seekedString) const; diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index 4c252e7d9..461b131db 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -21,8 +21,8 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) setLayout (layout); connect (mRecordFilterBox, - SIGNAL (filterChanged (boost::shared_ptr)), - this, SIGNAL (recordFilterChanged (boost::shared_ptr))); + SIGNAL (filterChanged (std::shared_ptr)), + this, SIGNAL (recordFilterChanged (std::shared_ptr))); setAcceptDrops(true); } diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index c765164e7..e794a9880 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -41,7 +41,7 @@ namespace CSVFilter void dragMoveEvent(QDragMoveEvent *event); signals: - void recordFilterChanged (boost::shared_ptr filter); + void recordFilterChanged (std::shared_ptr filter); void recordDropped (std::vector& types, Qt::DropAction action); }; diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index 2bf589215..d24465897 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -23,8 +23,8 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare setLayout (layout); connect ( - mEdit, SIGNAL (filterChanged (boost::shared_ptr)), - this, SIGNAL (filterChanged (boost::shared_ptr))); + mEdit, SIGNAL (filterChanged (std::shared_ptr)), + this, SIGNAL (filterChanged (std::shared_ptr))); } void CSVFilter::RecordFilterBox::setFilter (const std::string& filter) diff --git a/apps/opencs/view/filter/recordfilterbox.hpp b/apps/opencs/view/filter/recordfilterbox.hpp index 29d12529a..77a07c92b 100644 --- a/apps/opencs/view/filter/recordfilterbox.hpp +++ b/apps/opencs/view/filter/recordfilterbox.hpp @@ -1,8 +1,6 @@ #ifndef CSV_FILTER_RECORDFILTERBOX_H #define CSV_FILTER_RECORDFILTERBOX_H -#include - #include #include @@ -38,7 +36,7 @@ namespace CSVFilter signals: - void filterChanged (boost::shared_ptr filter); + void filterChanged (std::shared_ptr filter); }; } diff --git a/apps/opencs/view/prefs/contextmenulist.cpp b/apps/opencs/view/prefs/contextmenulist.cpp new file mode 100644 index 000000000..8115c3ecc --- /dev/null +++ b/apps/opencs/view/prefs/contextmenulist.cpp @@ -0,0 +1,44 @@ +#include "contextmenulist.hpp" + +#include +#include +#include + +#include "../../model/prefs/state.hpp" + +CSVPrefs::ContextMenuList::ContextMenuList(QWidget* parent) + :QListWidget(parent) +{ +} + +void CSVPrefs::ContextMenuList::contextMenuEvent(QContextMenuEvent* e) +{ + QMenu* menu = new QMenu(); + + menu->addAction("Reset category to default", this, SLOT(resetCategory())); + menu->addAction("Reset all to default", this, SLOT(resetAll())); + + menu->exec(e->globalPos()); + delete menu; +} + +void CSVPrefs::ContextMenuList::mousePressEvent(QMouseEvent* e) +{ + // enable all buttons except right click + // This means that when right-clicking to enable the + // context menu, the page doesn't switch at the same time. + if (!(e->buttons() & Qt::RightButton)) + { + QListWidget::mousePressEvent(e); + } +} + +void CSVPrefs::ContextMenuList::resetCategory() +{ + CSMPrefs::State::get().resetCategory(currentItem()->text().toStdString()); +} + +void CSVPrefs::ContextMenuList::resetAll() +{ + CSMPrefs::State::get().resetAll(); +} diff --git a/apps/opencs/view/prefs/contextmenulist.hpp b/apps/opencs/view/prefs/contextmenulist.hpp new file mode 100644 index 000000000..6aa187ca4 --- /dev/null +++ b/apps/opencs/view/prefs/contextmenulist.hpp @@ -0,0 +1,33 @@ +#ifndef CSV_PREFS_CONTEXTMENULIST_H +#define CSV_PREFS_CONTEXTMENULIST_H + +#include + +class QContextMenuEvent; +class QMouseEvent; + +namespace CSVPrefs +{ + class ContextMenuList : public QListWidget + { + Q_OBJECT + + public: + + ContextMenuList(QWidget* parent = 0); + + protected: + + void contextMenuEvent(QContextMenuEvent* e); + + void mousePressEvent(QMouseEvent* e); + + private slots: + + void resetCategory(); + + void resetAll(); + }; +} + +#endif diff --git a/apps/opencs/view/prefs/dialogue.cpp b/apps/opencs/view/prefs/dialogue.cpp index 6848bcaba..7f901c470 100644 --- a/apps/opencs/view/prefs/dialogue.cpp +++ b/apps/opencs/view/prefs/dialogue.cpp @@ -12,16 +12,17 @@ #include "page.hpp" #include "keybindingpage.hpp" +#include "contextmenulist.hpp" void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main) { - mList = new QListWidget (main); - mList->setMinimumWidth (50); - mList->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); + CSVPrefs::ContextMenuList* list = new CSVPrefs::ContextMenuList (main); + list->setMinimumWidth (50); + list->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); - mList->setSelectionBehavior (QAbstractItemView::SelectItems); + list->setSelectionBehavior (QAbstractItemView::SelectItems); - main->addWidget (mList); + main->addWidget (list); QFontMetrics metrics (QApplication::font()); @@ -33,12 +34,12 @@ void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main) QString label = QString::fromUtf8 (iter->second.getKey().c_str()); maxWidth = std::max (maxWidth, metrics.width (label)); - mList->addItem (label); + list->addItem (label); } - mList->setMaximumWidth (maxWidth + 10); + list->setMaximumWidth (maxWidth + 10); - connect (mList, SIGNAL (currentItemChanged (QListWidgetItem *, QListWidgetItem *)), + connect (list, SIGNAL (currentItemChanged (QListWidgetItem *, QListWidgetItem *)), this, SLOT (selectionChanged (QListWidgetItem *, QListWidgetItem *))); } diff --git a/apps/opencs/view/prefs/dialogue.hpp b/apps/opencs/view/prefs/dialogue.hpp index fc66892c8..ce017209a 100644 --- a/apps/opencs/view/prefs/dialogue.hpp +++ b/apps/opencs/view/prefs/dialogue.hpp @@ -16,7 +16,6 @@ namespace CSVPrefs { Q_OBJECT - QListWidget *mList; QStackedWidget *mContent; private: diff --git a/apps/opencs/view/prefs/pagebase.cpp b/apps/opencs/view/prefs/pagebase.cpp index 16684a69d..15535b785 100644 --- a/apps/opencs/view/prefs/pagebase.cpp +++ b/apps/opencs/view/prefs/pagebase.cpp @@ -1,7 +1,11 @@ #include "pagebase.hpp" +#include +#include + #include "../../model/prefs/category.hpp" +#include "../../model/prefs/state.hpp" CSVPrefs::PageBase::PageBase (CSMPrefs::Category& category, QWidget *parent) : QScrollArea (parent), mCategory (category) @@ -11,3 +15,24 @@ CSMPrefs::Category& CSVPrefs::PageBase::getCategory() { return mCategory; } + +void CSVPrefs::PageBase::contextMenuEvent(QContextMenuEvent* e) +{ + QMenu* menu = new QMenu(); + + menu->addAction("Reset category to default", this, SLOT(resetCategory())); + menu->addAction("Reset all to default", this, SLOT(resetAll())); + + menu->exec(e->globalPos()); + delete menu; +} + +void CSVPrefs::PageBase::resetCategory() +{ + CSMPrefs::State::get().resetCategory(getCategory().getKey()); +} + +void CSVPrefs::PageBase::resetAll() +{ + CSMPrefs::State::get().resetAll(); +} diff --git a/apps/opencs/view/prefs/pagebase.hpp b/apps/opencs/view/prefs/pagebase.hpp index affe49f4a..91a4dee5b 100644 --- a/apps/opencs/view/prefs/pagebase.hpp +++ b/apps/opencs/view/prefs/pagebase.hpp @@ -3,6 +3,8 @@ #include +class QContextMenuEvent; + namespace CSMPrefs { class Category; @@ -21,6 +23,16 @@ namespace CSVPrefs PageBase (CSMPrefs::Category& category, QWidget *parent); CSMPrefs::Category& getCategory(); + + protected: + + void contextMenuEvent(QContextMenuEvent*); + + private slots: + + void resetCategory(); + + void resetAll(); }; } diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 7cf542835..153de773c 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -62,7 +62,7 @@ bool CSVRender::Cell::addObjects (int start, int end) { std::string id = Misc::StringUtils::lowerCase (collection.getRecord (i).get().mId); - std::auto_ptr object (new Object (mData, mCellNode, id, false)); + std::unique_ptr object (new Object (mData, mCellNode, id, false)); if (mSubModeElementMask & Mask_Reference) object->setSubMode (mSubMode); @@ -283,6 +283,24 @@ void CSVRender::Cell::pathgridRemoved() mPathgrid->removeGeometry(); } +void CSVRender::Cell::reloadAssets() +{ + for (std::map::const_iterator iter (mObjects.begin()); + iter != mObjects.end(); ++iter) + { + iter->second->reloadAssets(); + } + + if (mTerrain) + { + mTerrain->unloadCell(mCoordinates.getX(), mCoordinates.getY()); + mTerrain->loadCell(mCoordinates.getX(), mCoordinates.getY()); + } + + if (mCellWater) + mCellWater->reloadAssets(); +} + void CSVRender::Cell::setSelection (int elementMask, Selection mode) { if (elementMask & Mask_Reference) diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index e8e0d2c63..f53f61973 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -47,13 +47,13 @@ namespace CSVRender std::string mId; osg::ref_ptr mCellNode; std::map mObjects; - std::auto_ptr mTerrain; + std::unique_ptr mTerrain; CSMWorld::CellCoordinates mCoordinates; - std::auto_ptr mCellArrows[4]; - std::auto_ptr mCellMarker; - std::auto_ptr mCellBorder; - std::auto_ptr mCellWater; - std::auto_ptr mPathgrid; + std::unique_ptr mCellArrows[4]; + std::unique_ptr mCellMarker; + std::unique_ptr mCellBorder; + std::unique_ptr mCellWater; + std::unique_ptr mPathgrid; bool mDeleted; int mSubMode; unsigned int mSubModeElementMask; @@ -118,6 +118,8 @@ namespace CSVRender void pathgridRemoved(); + void reloadAssets(); + void setSelection (int elementMask, Selection mode); // Select everything that references the same ID as at least one of the elements diff --git a/apps/opencs/view/render/cellmarker.cpp b/apps/opencs/view/render/cellmarker.cpp index 980ed305a..d0521a7b7 100644 --- a/apps/opencs/view/render/cellmarker.cpp +++ b/apps/opencs/view/render/cellmarker.cpp @@ -1,15 +1,10 @@ #include "cellmarker.hpp" -#include - #include #include #include -#include #include -#include "mask.hpp" - CSVRender::CellMarkerTag::CellMarkerTag(CellMarker *marker) : TagBase(Mask_CellMarker), mMarker(marker) {} @@ -42,8 +37,8 @@ void CSVRender::CellMarker::buildMarker() // Add text containing cell's coordinates. std::string coordinatesText = - boost::lexical_cast(mCoordinates.getX()) + "," + - boost::lexical_cast(mCoordinates.getY()); + std::to_string(mCoordinates.getX()) + "," + + std::to_string(mCoordinates.getY()); markerText->setText(coordinatesText); // Add text to marker node. diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index 15ea15cc4..d7e8669ef 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -92,6 +92,11 @@ namespace CSVRender } } + void CellWater::reloadAssets() + { + recreate(); + } + void CellWater::cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight) { const CSMWorld::Collection& cells = mData.getCells(); diff --git a/apps/opencs/view/render/cellwater.hpp b/apps/opencs/view/render/cellwater.hpp index d2ed9b458..47e586707 100644 --- a/apps/opencs/view/render/cellwater.hpp +++ b/apps/opencs/view/render/cellwater.hpp @@ -42,6 +42,8 @@ namespace CSVRender void updateCellData(const CSMWorld::Record& cellRecord); + void reloadAssets(); + private slots: void cellDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 3373daa4a..fae609af5 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -559,7 +559,7 @@ void CSVRender::InstanceMode::dropEvent (QDropEvent* event) if (mode=="Create cell and insert") { - std::auto_ptr createCommand ( + std::unique_ptr createCommand ( new CSMWorld::CreateCommand (cellTable, cellId)); int parentIndex = cellTable.findColumnIndex (CSMWorld::Columns::ColumnId_Cell); @@ -610,7 +610,7 @@ void CSVRender::InstanceMode::dropEvent (QDropEvent* event) if (mime->isReferencable (iter->getType())) { // create reference - std::auto_ptr createCommand ( + std::unique_ptr createCommand ( new CSMWorld::CreateCommand ( referencesTable, document.getData().getReferences().getNewId())); diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index eb90e9db3..522057097 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -532,6 +532,12 @@ bool CSVRender::Object::referenceDataChanged (const QModelIndex& topLeft, return false; } +void CSVRender::Object::reloadAssets() +{ + update(); + updateMarker(); +} + std::string CSVRender::Object::getReferenceId() const { return mReferenceId; diff --git a/apps/opencs/view/render/object.hpp b/apps/opencs/view/render/object.hpp index d3cba6c55..e14697e62 100644 --- a/apps/opencs/view/render/object.hpp +++ b/apps/opencs/view/render/object.hpp @@ -3,8 +3,6 @@ #include -#include - #include #include @@ -153,6 +151,9 @@ namespace CSVRender /// this object? bool referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); + /// Reloads the underlying asset + void reloadAssets(); + /// Returns an empty string if this is a refereceable-type object. std::string getReferenceId() const; diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index e855f7e41..b1077139c 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -54,7 +54,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells() { modified = true; - std::auto_ptr cell (new Cell (mDocument.getData(), mRootNode, + std::unique_ptr cell (new Cell (mDocument.getData(), mRootNode, iter->first.getId (mWorldspace), deleted)); delete iter->second; @@ -378,7 +378,7 @@ void CSVRender::PagedWorldspaceWidget::addCellToScene ( bool deleted = index==-1 || cells.getRecord (index).mState==CSMWorld::RecordBase::State_Deleted; - std::auto_ptr cell ( + std::unique_ptr cell ( new Cell (mDocument.getData(), mRootNode, coordinates.getId (mWorldspace), deleted)); EditMode *editMode = getEditMode(); @@ -472,6 +472,9 @@ CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc connect (cells, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (cellAdded (const QModelIndex&, int, int))); + connect (&document.getData(), SIGNAL (assetTablesChanged ()), + this, SLOT (assetTablesChanged ())); + // Shortcuts CSMPrefs::Shortcut* loadCameraCellShortcut = new CSMPrefs::Shortcut("scene-load-cam-cell", this); connect(loadCameraCellShortcut, SIGNAL(activated()), this, SLOT(loadCameraCell())); @@ -520,7 +523,7 @@ void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint) // Loop through all the coordinates to add them to selection while (stream >> ignore1 >> ignore2 >> x >> y) selection.add (CSMWorld::CellCoordinates (x, y)); - + // Mark that camera needs setup mCamPositionSet=false; } @@ -763,6 +766,15 @@ void CSVRender::PagedWorldspaceWidget::cellAdded (const QModelIndex& index, int flagAsModified(); } +void CSVRender::PagedWorldspaceWidget::assetTablesChanged() +{ + std::map::iterator iter = mCells.begin(); + for ( ; iter != mCells.end(); ++iter) + { + iter->second->reloadAssets(); + } +} + void CSVRender::PagedWorldspaceWidget::loadCameraCell() { addCellToSceneFromCamera(0, 0); diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 0663d3424..8c41df51e 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -84,7 +84,7 @@ namespace CSVRender /// hint system. virtual ~PagedWorldspaceWidget(); - + /// Decodes the the hint string to set of cell that are rendered. void useViewHint (const std::string& hint); @@ -155,6 +155,8 @@ namespace CSVRender virtual void cellAdded (const QModelIndex& index, int start, int end); + void assetTablesChanged (); + void loadCameraCell(); void loadEastCell(); diff --git a/apps/opencs/view/render/previewwidget.cpp b/apps/opencs/view/render/previewwidget.cpp index 2f3510317..972fb556d 100644 --- a/apps/opencs/view/render/previewwidget.cpp +++ b/apps/opencs/view/render/previewwidget.cpp @@ -17,6 +17,9 @@ CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data, connect (referenceables, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), this, SLOT (referenceableAboutToBeRemoved (const QModelIndex&, int, int))); + connect (&mData, SIGNAL (assetTablesChanged ()), + this, SLOT (assetTablesChanged ())); + if (!referenceable) { QAbstractItemModel *references = @@ -119,3 +122,8 @@ void CSVRender::PreviewWidget::referenceAboutToBeRemoved (const QModelIndex& par if (index.row()>=start && index.row()<=end) emit closeRequest(); } + +void CSVRender::PreviewWidget::assetTablesChanged () +{ + mObject.reloadAssets(); +} diff --git a/apps/opencs/view/render/previewwidget.hpp b/apps/opencs/view/render/previewwidget.hpp index 73f7dc810..630ccf293 100644 --- a/apps/opencs/view/render/previewwidget.hpp +++ b/apps/opencs/view/render/previewwidget.hpp @@ -47,6 +47,8 @@ namespace CSVRender void referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight); void referenceAboutToBeRemoved (const QModelIndex& parent, int start, int end); + + void assetTablesChanged (); }; } diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index a072cd0aa..3a801ffc3 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -172,7 +172,7 @@ void CompositeViewer::update() // --------------------------------------------------- -SceneWidget::SceneWidget(boost::shared_ptr resourceSystem, QWidget *parent, Qt::WindowFlags f, +SceneWidget::SceneWidget(std::shared_ptr resourceSystem, QWidget *parent, Qt::WindowFlags f, bool retrieveInput) : RenderWidget(parent, f) , mResourceSystem(resourceSystem) @@ -393,6 +393,7 @@ void SceneWidget::selectNavigationMode (const std::string& mode) mCurrentCamControl->setCamera(NULL); mCurrentCamControl = mOrbitCamControl; mOrbitCamControl->setCamera(getCamera()); + mOrbitCamControl->reset(); } } diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index c5d9cdfce..cc3191c81 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -10,8 +10,6 @@ #include #include -#include - #include "lightingday.hpp" #include "lightingnight.hpp" #include "lightingbright.hpp" @@ -78,7 +76,7 @@ namespace CSVRender { Q_OBJECT public: - SceneWidget(boost::shared_ptr resourceSystem, QWidget* parent = 0, + SceneWidget(std::shared_ptr resourceSystem, QWidget* parent = 0, Qt::WindowFlags f = 0, bool retrieveInput = true); virtual ~SceneWidget(); @@ -98,7 +96,7 @@ namespace CSVRender virtual void mouseMoveEvent (QMouseEvent *event); virtual void wheelEvent (QWheelEvent *event); - boost::shared_ptr mResourceSystem; + std::shared_ptr mResourceSystem; Lighting* mLighting; diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index b82aa45b2..3201f7303 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -47,6 +47,9 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)), this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int))); + connect (&document.getData(), SIGNAL (assetTablesChanged ()), + this, SLOT (assetTablesChanged ())); + update(); mCell.reset (new Cell (document.getData(), mRootNode, mCellId)); @@ -82,6 +85,12 @@ void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelI emit closeRequest(); } +void CSVRender::UnpagedWorldspaceWidget::assetTablesChanged() +{ + if (mCell) + mCell->reloadAssets(); +} + bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector& universalIdData, DropType type) { if (WorldspaceWidget::handleDrop (universalIdData, type)) diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index 57e8d1a19..527463990 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -29,7 +29,7 @@ namespace CSVRender std::string mCellId; CSMWorld::IdTable *mCellsModel; CSMWorld::IdTable *mReferenceablesModel; - std::auto_ptr mCell; + std::unique_ptr mCell; void update(); @@ -108,6 +108,8 @@ namespace CSVRender void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end); + void assetTablesChanged (); + signals: void cellChanged(const CSMWorld::UniversalId& id); diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index b30d7de8a..08b97e1be 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -1,8 +1,6 @@ #ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H #define OPENCS_VIEW_WORLDSPACEWIDGET_H -#include - #include #include diff --git a/apps/opencs/view/tools/merge.cpp b/apps/opencs/view/tools/merge.cpp index 566a5ee06..c49044ccd 100644 --- a/apps/opencs/view/tools/merge.cpp +++ b/apps/opencs/view/tools/merge.cpp @@ -127,10 +127,10 @@ void CSVTools::Merge::accept() { std::vector< boost::filesystem::path > files (1, mAdjuster->getPath()); - std::auto_ptr target ( + std::unique_ptr target ( mDocumentManager.makeDocument (files, files[0], true)); - mDocument->runMerge (target); + mDocument->runMerge (std::move(target)); hide(); } diff --git a/apps/opencs/view/widget/coloreditor.cpp b/apps/opencs/view/widget/coloreditor.cpp index 7ef1ec7b1..5f82f8e26 100644 --- a/apps/opencs/view/widget/coloreditor.cpp +++ b/apps/opencs/view/widget/coloreditor.cpp @@ -10,9 +10,20 @@ #include "colorpickerpopup.hpp" -CSVWidget::ColorEditor::ColorEditor(const QColor &color, QWidget *parent, bool popupOnStart) +CSVWidget::ColorEditor::ColorEditor(const QColor &color, QWidget *parent, const bool popupOnStart) + : ColorEditor(parent, popupOnStart) +{ + setColor(color); +} + +CSVWidget::ColorEditor::ColorEditor(const int colorInt, QWidget *parent, const bool popupOnStart) + : ColorEditor(parent, popupOnStart) +{ + setColor(colorInt); +} + +CSVWidget::ColorEditor::ColorEditor(QWidget *parent, const bool popupOnStart) : QPushButton(parent), - mColor(color), mColorPicker(new ColorPickerPopup(this)), mPopupOnStart(popupOnStart) { @@ -53,12 +64,25 @@ QColor CSVWidget::ColorEditor::color() const return mColor; } +int CSVWidget::ColorEditor::colorInt() const +{ + return (mColor.blue() << 16) | (mColor.green() << 8) | (mColor.red()); +} + void CSVWidget::ColorEditor::setColor(const QColor &color) { mColor = color; update(); } +void CSVWidget::ColorEditor::setColor(const int colorInt) +{ + // Color RGB values are stored in given integer. + // First byte is red, second byte is green, third byte is blue. + QColor color = QColor(colorInt & 0xff, (colorInt >> 8) & 0xff, (colorInt >> 16) & 0xff); + setColor(color); +} + void CSVWidget::ColorEditor::showPicker() { if (isChecked()) diff --git a/apps/opencs/view/widget/coloreditor.hpp b/apps/opencs/view/widget/coloreditor.hpp index 61232cb13..668f22cc9 100644 --- a/apps/opencs/view/widget/coloreditor.hpp +++ b/apps/opencs/view/widget/coloreditor.hpp @@ -22,15 +22,27 @@ namespace CSVWidget QPoint calculatePopupPosition(); public: - ColorEditor(const QColor &color, QWidget *parent = 0, bool popupOnStart = false); + ColorEditor(const QColor &color, QWidget *parent = 0, const bool popupOnStart = false); + ColorEditor(const int colorInt, QWidget *parent = 0, const bool popupOnStart = false); QColor color() const; + + /// \return Color RGB value encoded in an int. + int colorInt() const; + void setColor(const QColor &color); + /// \brief Set color using given int value. + /// \param colorInt RGB color value encoded as an integer. + void setColor(const int colorInt); + protected: virtual void paintEvent(QPaintEvent *event); virtual void showEvent(QShowEvent *event); + private: + ColorEditor(QWidget *parent = 0, const bool popupOnStart = false); + private slots: void showPicker(); void pickerHid(); diff --git a/apps/opencs/view/world/creator.hpp b/apps/opencs/view/world/creator.hpp index b76348199..320bbf6ae 100644 --- a/apps/opencs/view/world/creator.hpp +++ b/apps/opencs/view/world/creator.hpp @@ -91,7 +91,7 @@ namespace CSVWorld Creator *CreatorFactory::makeCreator (CSMDoc::Document& document, const CSMWorld::UniversalId& id) const { - std::auto_ptr creator (new CreatorT (document.getData(), document.getUndoStack(), id)); + std::unique_ptr creator (new CreatorT (document.getData(), document.getUndoStack(), id)); creator->setScope (scope); diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 87d5b3d7f..7b198056c 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -120,7 +120,7 @@ mIndex(index) CSVWorld::DialogueDelegateDispatcherProxy::DialogueDelegateDispatcherProxy(QWidget* editor, CSMWorld::ColumnBase::Display display) : mEditor(editor), mDisplay(display), -mIndexWrapper(NULL) +mIndexWrapper(nullptr) { } diff --git a/apps/opencs/view/world/dialoguesubview.hpp b/apps/opencs/view/world/dialoguesubview.hpp index bd7116ba2..cbcb9b210 100644 --- a/apps/opencs/view/world/dialoguesubview.hpp +++ b/apps/opencs/view/world/dialoguesubview.hpp @@ -84,7 +84,7 @@ namespace CSVWorld CSMWorld::ColumnBase::Display mDisplay; - std::auto_ptr mIndexWrapper; + std::unique_ptr mIndexWrapper; public: DialogueDelegateDispatcherProxy(QWidget* editor, diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index dd2bd82df..bf4c4967f 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -63,7 +63,7 @@ std::string CSVWorld::GenericCreator::getIdValidatorResult() const void CSVWorld::GenericCreator::configureCreateCommand (CSMWorld::CreateCommand& command) const {} -void CSVWorld::GenericCreator::pushCommand (std::auto_ptr command, +void CSVWorld::GenericCreator::pushCommand (std::unique_ptr command, const std::string& id) { mUndoStack.push (command.release()); @@ -224,7 +224,7 @@ void CSVWorld::GenericCreator::create() { std::string id = getId(); - std::auto_ptr command; + std::unique_ptr command; if (mCloneMode) { @@ -239,7 +239,7 @@ void CSVWorld::GenericCreator::create() } configureCreateCommand (*command); - pushCommand (command, id); + pushCommand (std::move(command), id); emit done(); emit requestFocus(id); diff --git a/apps/opencs/view/world/genericcreator.hpp b/apps/opencs/view/world/genericcreator.hpp index f3fc82ec1..60d487bc1 100644 --- a/apps/opencs/view/world/genericcreator.hpp +++ b/apps/opencs/view/world/genericcreator.hpp @@ -71,7 +71,7 @@ namespace CSVWorld /// Allow subclasses to wrap the create command together with additional commands /// into a macro. - virtual void pushCommand (std::auto_ptr command, + virtual void pushCommand (std::unique_ptr command, const std::string& id); CSMWorld::Data& getData() const; diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 6f27d5656..1105404b3 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -7,12 +7,14 @@ #include #include #include +#include #include "../../model/doc/document.hpp" #include "../../model/world/universalid.hpp" #include "../../model/world/tablemimedata.hpp" #include "../../model/prefs/state.hpp" +#include "../../model/prefs/shortcut.hpp" CSVWorld::ScriptEdit::ChangeLock::ChangeLock (ScriptEdit& edit) : mEdit (edit) { @@ -49,6 +51,7 @@ CSVWorld::ScriptEdit::ScriptEdit( mDefaultFont(font()), mMonoFont(QFont("Monospace")), mTabCharCount(4), + mMarkOccurrences(true), mDocument(document), mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) { @@ -85,6 +88,18 @@ CSVWorld::ScriptEdit::ScriptEdit( <associateAction(mCommentAction); + + mUncommentAction = new QAction (tr ("Uncomment Selection"), this); + connect(mUncommentAction, SIGNAL (triggered()), this, SLOT (uncommentSelection())); + CSMPrefs::Shortcut *uncommentShortcut = new CSMPrefs::Shortcut("script-editor-uncomment", this); + uncommentShortcut->associateAction(mUncommentAction); mHighlighter = new ScriptHighlighter (document.getData(), mode, ScriptEdit::document()); @@ -230,6 +245,13 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting) mTabCharCount = setting->toInt(); setTabWidth(); } + else if (*setting == "Scripts/highlight-occurrences") + { + mMarkOccurrences = setting->isTrue(); + mHighlighter->setMarkedWord(""); + updateHighlighting(); + mHighlighter->setMarkOccurrences(mMarkOccurrences); + } } void CSVWorld::ScriptEdit::idListChanged() @@ -284,6 +306,84 @@ void CSVWorld::ScriptEdit::updateLineNumberArea(const QRect &rect, int dy) updateLineNumberAreaWidth(0); } +void CSVWorld::ScriptEdit::markOccurrences() +{ + if (mMarkOccurrences) + { + QTextCursor cursor = textCursor(); + + // prevent infinite recursion with cursor.select(), + // which ends up calling this function again + // could be fixed with blockSignals, but mDocument is const + disconnect(this, SIGNAL(cursorPositionChanged()), this, 0); + cursor.select(QTextCursor::WordUnderCursor); + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(markOccurrences())); + + QString word = cursor.selectedText(); + mHighlighter->setMarkedWord(word.toStdString()); + mHighlighter->rehighlight(); + } +} + +void CSVWorld::ScriptEdit::commentSelection() +{ + QTextCursor begin = textCursor(); + QTextCursor end = begin; + begin.setPosition(begin.selectionStart()); + begin.movePosition(QTextCursor::StartOfLine); + + end.setPosition(end.selectionEnd()); + end.movePosition(QTextCursor::EndOfLine); + + begin.beginEditBlock(); + + for (; begin < end; begin.movePosition(QTextCursor::EndOfLine), begin.movePosition(QTextCursor::Right)) + { + begin.insertText(";"); + } + + begin.endEditBlock(); +} + +void CSVWorld::ScriptEdit::uncommentSelection() +{ + QTextCursor begin = textCursor(); + QTextCursor end = begin; + begin.setPosition(begin.selectionStart()); + begin.movePosition(QTextCursor::StartOfLine); + + end.setPosition(end.selectionEnd()); + end.movePosition(QTextCursor::EndOfLine); + + begin.beginEditBlock(); + + for (; begin < end; begin.movePosition(QTextCursor::EndOfLine), begin.movePosition(QTextCursor::Right)) { + begin.select(QTextCursor::LineUnderCursor); + QString line = begin.selectedText(); + + if (line.size() == 0) + continue; + + // get first nonspace character in line + int index; + for (index = 0; index != line.size(); ++index) + { + if (!line[index].isSpace()) + break; + } + + if (index != line.size() && line[index] == ';') + { + // remove the semicolon + line.remove(index, 1); + // put the line back + begin.insertText(line); + } + } + + begin.endEditBlock(); +} + void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e) { QPlainTextEdit::resizeEvent(e); @@ -292,6 +392,26 @@ void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e) mLineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); } +void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event) +{ + QMenu *menu = createStandardContextMenu(); + + // remove redo/undo since they are disabled + QList menuActions = menu->actions(); + for (QList::iterator i = menuActions.begin(); i < menuActions.end(); ++i) + { + if ((*i)->text().contains("Undo") || (*i)->text().contains("Redo")) + { + (*i)->setVisible(false); + } + } + menu->addAction(mCommentAction); + menu->addAction(mUncommentAction); + + menu->exec(event->globalPos()); + delete menu; +} + void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event) { QPainter painter(mLineNumberArea); diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 4977ed8e0..b0a4b0577 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "../../model/world/universalid.hpp" @@ -54,6 +55,9 @@ namespace CSVWorld QFont mDefaultFont; QFont mMonoFont; int mTabCharCount; + bool mMarkOccurrences; + QAction *mCommentAction; + QAction *mUncommentAction; protected: @@ -77,6 +81,8 @@ namespace CSVWorld virtual void resizeEvent(QResizeEvent *e); + virtual void contextMenuEvent(QContextMenuEvent *event); + private: QVector mAllowedTypes; @@ -111,6 +117,13 @@ namespace CSVWorld void updateLineNumberAreaWidth(int newBlockCount); void updateLineNumberArea(const QRect &, int); + + void markOccurrences(); + + void commentSelection(); + + void uncommentSelection(); + }; class LineNumberArea : public QWidget diff --git a/apps/opencs/view/world/scripterrortable.cpp b/apps/opencs/view/world/scripterrortable.cpp index c22bcf199..ca7cbd159 100644 --- a/apps/opencs/view/world/scripterrortable.cpp +++ b/apps/opencs/view/world/scripterrortable.cpp @@ -52,6 +52,13 @@ void CSVWorld::ScriptErrorTable::addMessage (const std::string& message, columnItem->setFlags (columnItem->flags() ^ Qt::ItemIsEditable); setItem (row, 3, columnItem); } + else + { + QTableWidgetItem *lineItem = new QTableWidgetItem; + lineItem->setData (Qt::DisplayRole, "-"); + lineItem->setFlags (lineItem->flags() ^ Qt::ItemIsEditable); + setItem (row, 1, lineItem); + } QTableWidgetItem *messageItem = new QTableWidgetItem (QString::fromUtf8 (message.c_str())); messageItem->setFlags (messageItem->flags() ^ Qt::ItemIsEditable); @@ -141,7 +148,7 @@ void CSVWorld::ScriptErrorTable::settingChanged (const CSMPrefs::Setting *settin void CSVWorld::ScriptErrorTable::cellClicked (int row, int column) { - if (item (row, 1)) + if (item (row, 3)) { int scriptLine = item (row, 1)->data (Qt::DisplayRole).toInt(); int scriptColumn = item (row, 3)->data (Qt::DisplayRole).toInt(); diff --git a/apps/opencs/view/world/scripthighlighter.cpp b/apps/opencs/view/world/scripthighlighter.cpp index 846a61b47..6aba66053 100644 --- a/apps/opencs/view/world/scripthighlighter.cpp +++ b/apps/opencs/view/world/scripthighlighter.cpp @@ -72,7 +72,11 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type // compensate for bug in Compiler::Scanner (position of token is the character after the token) index -= length; - setFormat (index, length, mScheme[type]); + QTextCharFormat scheme = mScheme[type]; + if (mMarkOccurrences && type == Type_Name && loc.mLiteral == mMarkedWord) + scheme.merge(mScheme[Type_Highlight]); + + setFormat (index, length, scheme); } CSVWorld::ScriptHighlighter::ScriptHighlighter (const CSMWorld::Data& data, Mode mode, @@ -105,6 +109,16 @@ void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text) catch (...) {} // ignore syntax errors } +void CSVWorld::ScriptHighlighter::setMarkOccurrences(bool flag) +{ + mMarkOccurrences = flag; +} + +void CSVWorld::ScriptHighlighter::setMarkedWord(const std::string& name) +{ + mMarkedWord = name; +} + void CSVWorld::ScriptHighlighter::invalidateIds() { mContext.invalidateIds(); @@ -117,7 +131,7 @@ bool CSVWorld::ScriptHighlighter::settingChanged (const CSMPrefs::Setting *setti static const char *const colours[Type_Id+2] = { "colour-int", "colour-float", "colour-name", "colour-keyword", - "colour-special", "colour-comment", "colour-id", + "colour-special", "colour-comment", "colour-highlight", "colour-id", 0 }; @@ -125,7 +139,10 @@ bool CSVWorld::ScriptHighlighter::settingChanged (const CSMPrefs::Setting *setti if (setting->getKey()==colours[i]) { QTextCharFormat format; - format.setForeground (setting->toColor()); + if (i == Type_Highlight) + format.setBackground (setting->toColor()); + else + format.setForeground (setting->toColor()); mScheme[static_cast (i)] = format; return true; } diff --git a/apps/opencs/view/world/scripthighlighter.hpp b/apps/opencs/view/world/scripthighlighter.hpp index 33824da0d..a7d0fc2a1 100644 --- a/apps/opencs/view/world/scripthighlighter.hpp +++ b/apps/opencs/view/world/scripthighlighter.hpp @@ -2,6 +2,7 @@ #define CSV_WORLD_SCRIPTHIGHLIGHTER_H #include +#include #include @@ -30,7 +31,8 @@ namespace CSVWorld Type_Keyword = 3, Type_Special = 4, Type_Comment = 5, - Type_Id = 6 + Type_Highlight = 6, + Type_Id = 7 }; enum Mode @@ -47,6 +49,8 @@ namespace CSVWorld CSMWorld::ScriptContext mContext; std::map mScheme; Mode mMode; + bool mMarkOccurrences; + std::string mMarkedWord; private: @@ -91,6 +95,10 @@ namespace CSVWorld virtual void highlightBlock (const QString& text); + void setMarkOccurrences(bool); + + void setMarkedWord(const std::string& name); + void invalidateIds(); bool settingChanged (const CSMPrefs::Setting *setting); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 07db5b477..30dba4241 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -692,7 +692,7 @@ void CSVWorld::Table::requestFocus (const std::string& id) scrollTo (index, QAbstractItemView::PositionAtTop); } -void CSVWorld::Table::recordFilterChanged (boost::shared_ptr filter) +void CSVWorld::Table::recordFilterChanged (std::shared_ptr filter) { mProxyModel->setFilter (filter); tableSizeUpdate(); diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 768ff185d..26f6e7899 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -151,7 +151,7 @@ namespace CSVWorld void requestFocus (const std::string& id); - void recordFilterChanged (boost::shared_ptr filter); + void recordFilterChanged (std::shared_ptr filter); void rowAdded(const std::string &id); }; diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index fcf66ed81..6664a3771 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -78,8 +78,8 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D mTable, SLOT (requestFocus (const std::string&))); connect (mFilterBox, - SIGNAL (recordFilterChanged (boost::shared_ptr)), - mTable, SLOT (recordFilterChanged (boost::shared_ptr))); + SIGNAL (recordFilterChanged (std::shared_ptr)), + mTable, SLOT (recordFilterChanged (std::shared_ptr))); connect(mFilterBox, SIGNAL(recordDropped(std::vector&, Qt::DropAction)), this, SLOT(createFilterRequest(std::vector&, Qt::DropAction))); diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index e44606652..efba1ea82 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -127,22 +127,23 @@ void CSVWorld::CommandDelegate::setModelDataImp (QWidget *editor, QAbstractItemM if (!mCommandDispatcher) return; - QVariant new_; - // Color columns use a custom editor, so we need explicitly extract a data from it + QVariant variant; + + // Color columns use a custom editor, so we need to fetch selected color from it. CSVWidget::ColorEditor *colorEditor = qobject_cast(editor); if (colorEditor != NULL) { - new_ = colorEditor->color(); + variant = colorEditor->colorInt(); } else { NastyTableModelHack hack (*model); QStyledItemDelegate::setModelData (editor, &hack, index); - new_ = hack.getData(); + variant = hack.getData(); } - if ((model->data (index)!=new_) && (model->flags(index) & Qt::ItemIsEditable)) - mCommandDispatcher->executeModify (model, index, new_); + if ((model->data (index)!=variant) && (model->flags(index) & Qt::ItemIsEditable)) + mCommandDispatcher->executeModify (model, index, variant); } CSVWorld::CommandDelegate::CommandDelegate (CSMWorld::CommandDispatcher *commandDispatcher, @@ -179,7 +180,7 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO // (the third parameter of ColorEditor's constructor) else if (display == CSMWorld::ColumnBase::Display_Colour) { - return new CSVWidget::ColorEditor(index.data().value(), parent, true); + return new CSVWidget::ColorEditor(index.data().toInt(), parent, true); } return createEditor (parent, option, index, display); } @@ -202,9 +203,9 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO switch (display) { case CSMWorld::ColumnBase::Display_Colour: - - return new CSVWidget::ColorEditor(index.data().value(), parent); - + { + return new CSVWidget::ColorEditor(variant.toInt(), parent); + } case CSMWorld::ColumnBase::Display_Integer: { DialogueSpinBox *sb = new DialogueSpinBox(parent); @@ -291,13 +292,13 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay) const { - QVariant v = index.data(Qt::EditRole); + QVariant variant = index.data(Qt::EditRole); if (tryDisplay) { - if (!v.isValid()) + if (!variant.isValid()) { - v = index.data(Qt::DisplayRole); - if (!v.isValid()) + variant = index.data(Qt::DisplayRole); + if (!variant.isValid()) { return; } @@ -305,7 +306,7 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde QPlainTextEdit* plainTextEdit = qobject_cast(editor); if(plainTextEdit) //for some reason it is easier to brake the loop here { - if(plainTextEdit->toPlainText() == v.toString()) + if (plainTextEdit->toPlainText() == variant.toString()) { return; } @@ -316,23 +317,25 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde CSVWidget::ColorEditor *colorEditor = qobject_cast(editor); if (colorEditor != NULL) { - colorEditor->setColor(index.data().value()); + colorEditor->setColor(variant.toInt()); return; } QByteArray n = editor->metaObject()->userProperty().name(); - if (n == "dateTime") { + if (n == "dateTime") + { if (editor->inherits("QTimeEdit")) n = "time"; else if (editor->inherits("QDateEdit")) n = "date"; } - if (!n.isEmpty()) { - if (!v.isValid()) - v = QVariant(editor->property(n).userType(), (const void *)0); - editor->setProperty(n, v); + if (!n.isEmpty()) + { + if (!variant.isValid()) + variant = QVariant(editor->property(n).userType(), (const void *)0); + editor->setProperty(n, variant); } } diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 6e4a7baab..5fd52abae 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -81,10 +81,10 @@ add_openmw_dir (mwclass add_openmw_dir (mwmechanics mechanicsmanagerimp stat creaturestats magiceffects movement actorutil - drawstate spells activespells npcstats aipackage aisequence aipursue alchemy aiwander aitravel aifollow aiavoiddoor + drawstate spells activespells npcstats aipackage aisequence aipursue alchemy aiwander aitravel aifollow aiavoiddoor aibreathe aiescort aiactivate aicombat repair enchanting pathfinding pathgrid security spellsuccess spellcasting disease pickpocket levelledlist combat steering obstacle autocalcspell difficultyscaling aicombataction actor summoning - character actors objects aistate coordinateconverter trading aiface + character actors objects aistate coordinateconverter trading aiface weaponpriority spellpriority ) add_openmw_dir (mwstate diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2a0bcb108..c921e17d0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -1,6 +1,5 @@ #include "engine.hpp" -#include #include #include @@ -28,7 +27,6 @@ #include #include -#include #include @@ -280,8 +278,7 @@ void OMW::Engine::setResourceDir (const boost::filesystem::path& parResDir) mResDir = parResDir; } -// Set start cell name (only interiors for now) - +// Set start cell name void OMW::Engine::setCell (const std::string& cellName) { mCellName = cellName; @@ -526,7 +523,6 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) window->setStore(mEnvironment.getWorld()->getStore()); window->initUI(); - window->renderWorldMap(); //Load translation data mTranslationDataStorage.setEncoder(mEncoder); @@ -712,6 +708,9 @@ void OMW::Engine::go() { mViewer->eventTraversal(); mViewer->updateTraversal(); + + mEnvironment.getWorld()->updateWindowManager(); + mViewer->renderingTraversals(); } diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index d06ca594d..bf144bfed 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -71,8 +71,8 @@ namespace OMW class Engine { SDL_Window* mWindow; - std::auto_ptr mVFS; - std::auto_ptr mResourceSystem; + std::unique_ptr mVFS; + std::unique_ptr mResourceSystem; osg::ref_ptr mWorkQueue; MWBase::Environment mEnvironment; ToUTF8::FromType mEncoding; @@ -148,7 +148,7 @@ namespace OMW /// Set resource dir void setResourceDir(const boost::filesystem::path& parResDir); - /// Set start cell name (only interiors for now) + /// Set start cell name void setCell(const std::string& cellName); /** diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index d0abdad52..9e44f237e 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,11 +6,8 @@ #include #include -#include #include "engine.hpp" -#include -#include #include #if defined(_WIN32) @@ -24,6 +20,9 @@ #include #endif +#if (defined(__APPLE__) || defined(__linux) || defined(__unix) || defined(__posix)) +#include +#endif #if (defined(__APPLE__) || (defined(__linux) && !defined(ANDROID)) || (defined(__unix) && !defined(ANDROID)) || defined(__posix)) #define USE_CRASH_CATCHER 1 @@ -37,7 +36,6 @@ extern int cc_install_handlers(int argc, char **argv, int num_signals, int *sigs extern int is_debugger_attached(void); #endif -#include /** * Workaround for problems with whitespaces in paths in older versions of Boost library */ @@ -310,7 +308,7 @@ int main(int argc, char**argv) boost::filesystem::ofstream logfile; - std::auto_ptr engine; + std::unique_ptr engine; int ret = 0; try diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index 1fe63e633..18f249e56 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -50,7 +50,7 @@ namespace MWBase virtual void goodbye() = 0; - virtual void say(const MWWorld::Ptr &actor, const std::string &topic) const = 0; + virtual void say(const MWWorld::Ptr &actor, const std::string &topic) = 0; //calbacks for the GUI virtual void keywordSelected (const std::string& keyword) = 0; diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index bd0d2ea4a..f5013a8f3 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -7,6 +7,8 @@ #include #include +#include "../mwworld/ptr.hpp" + namespace osg { class Vec3f; @@ -230,8 +232,8 @@ namespace MWBase /// Has the player stolen this item from the given owner? virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0; - - virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim) = 0; + + virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim) = 0; /// Turn actor into werewolf or normal form. virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0; @@ -241,6 +243,11 @@ namespace MWBase virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0; virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0; + + virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count) = 0; + + virtual bool isRunning(const MWWorld::Ptr& ptr) = 0; + virtual bool isSneaking(const MWWorld::Ptr& ptr) = 0; }; } diff --git a/apps/openmw/mwbase/soundmanager.hpp b/apps/openmw/mwbase/soundmanager.hpp index 22582c2b1..9aa4bafdf 100644 --- a/apps/openmw/mwbase/soundmanager.hpp +++ b/apps/openmw/mwbase/soundmanager.hpp @@ -1,9 +1,9 @@ #ifndef GAME_MWBASE_SOUNDMANAGER_H #define GAME_MWBASE_SOUNDMANAGER_H +#include #include #include -#include #include "../mwworld/ptr.hpp" @@ -17,13 +17,13 @@ namespace MWSound class Sound; class Stream; struct Sound_Decoder; - typedef boost::shared_ptr DecoderPtr; + typedef std::shared_ptr DecoderPtr; } namespace MWBase { - typedef boost::shared_ptr SoundPtr; - typedef boost::shared_ptr SoundStreamPtr; + typedef std::shared_ptr SoundPtr; + typedef std::shared_ptr SoundStreamPtr; /// \brief Interface for sound manager (implemented in MWSound) class SoundManager diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index f103ce191..416a7ad87 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -72,6 +72,8 @@ namespace MWGui ShowInDialogueMode_Only, ShowInDialogueMode_Never }; + + struct TextColours; } namespace SFO @@ -351,6 +353,8 @@ namespace MWBase /// Cycle to next or previous weapon virtual void cycleWeapon(bool next) = 0; + virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0; + // In WindowManager for now since there isn't a VFS singleton virtual std::string correctIconPath(const std::string& path) = 0; virtual std::string correctBookartPath(const std::string& path, int width, int height) = 0; @@ -359,6 +363,8 @@ namespace MWBase virtual void removeCell(MWWorld::CellStore* cell) = 0; virtual void writeFog(MWWorld::CellStore* cell) = 0; + + virtual const MWGui::TextColours& getTextColours() = 0; }; } diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 86d26d3a7..5e76d82eb 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -358,6 +358,8 @@ namespace MWBase virtual void update (float duration, bool paused) = 0; + virtual void updateWindowManager () = 0; + virtual MWWorld::Ptr placeObject (const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount) = 0; ///< copy and place an object into the gameworld at the specified cursor position /// @param object @@ -383,6 +385,7 @@ namespace MWBase ///Is the head of the creature underwater? virtual bool isSubmerged(const MWWorld::ConstPtr &object) const = 0; virtual bool isUnderwater(const MWWorld::CellStore* cell, const osg::Vec3f &pos) const = 0; + virtual bool isUnderwater(const MWWorld::ConstPtr &object, const float heightRatio) const = 0; virtual bool isWaterWalkingCastableOnTarget(const MWWorld::ConstPtr &target) const = 0; virtual bool isOnGround(const MWWorld::Ptr &ptr) const = 0; diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index 3e0ec366f..8df262f24 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -51,6 +51,11 @@ namespace MWClass return ""; } + bool Activator::isActivator() const + { + return true; + } + bool Activator::useAnim() const { return true; @@ -73,7 +78,7 @@ namespace MWClass void Activator::registerSelf() { - boost::shared_ptr instance (new Activator); + std::shared_ptr instance (new Activator); registerClass (typeid (ESM::Activator).name(), instance); } @@ -107,19 +112,19 @@ namespace MWClass return info; } - boost::shared_ptr Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const + std::shared_ptr Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const { if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Sound *sound = store.get().searchRandom("WolfActivator"); - boost::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - return boost::shared_ptr(new MWWorld::NullAction); + return std::shared_ptr(new MWWorld::NullAction); } diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index 4fe4dda7e..3f333f4cb 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -33,7 +33,7 @@ namespace MWClass virtual std::string getScript (const MWWorld::ConstPtr& ptr) const; ///< Return name of the script attached to ptr - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation static void registerSelf(); @@ -42,6 +42,8 @@ namespace MWClass virtual bool useAnim() const; ///< Whether or not to use animated variant of model (default false) + + virtual bool isActivator() const; }; } diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 3642a22ed..a271dc5e9 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -51,7 +51,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Apparatus::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -73,7 +73,7 @@ namespace MWClass void Apparatus::registerSelf() { - boost::shared_ptr instance (new Apparatus); + std::shared_ptr instance (new Apparatus); registerClass (typeid (ESM::Apparatus).name(), instance); } @@ -125,9 +125,9 @@ namespace MWClass } - boost::shared_ptr Apparatus::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Apparatus::use (const MWWorld::Ptr& ptr) const { - return boost::shared_ptr(new MWWorld::ActionAlchemy()); + return std::shared_ptr(new MWWorld::ActionAlchemy()); } MWWorld::Ptr Apparatus::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/apparatus.hpp b/apps/openmw/mwclass/apparatus.hpp index d669b9c2d..539c1068b 100644 --- a/apps/openmw/mwclass/apparatus.hpp +++ b/apps/openmw/mwclass/apparatus.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -50,7 +50,7 @@ namespace MWClass virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index f652cbd04..460cd517a 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -57,7 +57,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Armor::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -165,7 +165,7 @@ namespace MWClass void Armor::registerSelf() { - boost::shared_ptr instance (new Armor); + std::shared_ptr instance (new Armor); registerClass (typeid (ESM::Armor).name(), instance); } @@ -354,9 +354,9 @@ namespace MWClass return std::make_pair(1,""); } - boost::shared_ptr Armor::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Armor::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/armor.hpp b/apps/openmw/mwclass/armor.hpp index 025bc8af1..628ac1b88 100644 --- a/apps/openmw/mwclass/armor.hpp +++ b/apps/openmw/mwclass/armor.hpp @@ -22,7 +22,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -73,7 +73,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. \n /// Second item in the pair specifies the error message - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/bodypart.cpp b/apps/openmw/mwclass/bodypart.cpp index be2b927cc..41a9d998e 100644 --- a/apps/openmw/mwclass/bodypart.cpp +++ b/apps/openmw/mwclass/bodypart.cpp @@ -33,7 +33,7 @@ namespace MWClass void BodyPart::registerSelf() { - boost::shared_ptr instance (new BodyPart); + std::shared_ptr instance (new BodyPart); registerClass (typeid (ESM::BodyPart).name(), instance); } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index f2c97d770..3d6455dc6 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -54,7 +54,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Book::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Book::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -62,13 +62,13 @@ namespace MWClass const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Sound *sound = store.get().searchRandom("WolfItem"); - boost::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - return boost::shared_ptr(new MWWorld::ActionRead(ptr)); + return std::shared_ptr(new MWWorld::ActionRead(ptr)); } std::string Book::getScript (const MWWorld::ConstPtr& ptr) const @@ -87,7 +87,7 @@ namespace MWClass void Book::registerSelf() { - boost::shared_ptr instance (new Book); + std::shared_ptr instance (new Book); registerClass (typeid (ESM::Book).name(), instance); } @@ -162,9 +162,9 @@ namespace MWClass return record->mId; } - boost::shared_ptr Book::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Book::use (const MWWorld::Ptr& ptr) const { - return boost::shared_ptr(new MWWorld::ActionRead(ptr)); + return std::shared_ptr(new MWWorld::ActionRead(ptr)); } MWWorld::Ptr Book::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const diff --git a/apps/openmw/mwclass/book.hpp b/apps/openmw/mwclass/book.hpp index 73bfecacd..82ca08a4d 100644 --- a/apps/openmw/mwclass/book.hpp +++ b/apps/openmw/mwclass/book.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -53,7 +53,7 @@ namespace MWClass virtual std::string applyEnchantment(const MWWorld::ConstPtr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const; ///< Creates a new record using \a ptr as template, with the given name and the given enchantment applied to it. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 1d99ee8e2..b37d1e90b 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -53,7 +53,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Clothing::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -124,7 +124,7 @@ namespace MWClass void Clothing::registerSelf() { - boost::shared_ptr instance (new Clothing); + std::shared_ptr instance (new Clothing); registerClass (typeid (ESM::Clothing).name(), instance); } @@ -243,9 +243,9 @@ namespace MWClass return std::make_pair (1, ""); } - boost::shared_ptr Clothing::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Clothing::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/clothing.hpp b/apps/openmw/mwclass/clothing.hpp index e1c0f63f7..202b6596e 100644 --- a/apps/openmw/mwclass/clothing.hpp +++ b/apps/openmw/mwclass/clothing.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -65,7 +65,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. /// Second item in the pair specifies the error message - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index fe2899aff..dc4eb844a 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -52,7 +52,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - std::auto_ptr data (new ContainerCustomData); + std::unique_ptr data (new ContainerCustomData); MWWorld::LiveCellRef *ref = ptr.get(); @@ -118,18 +118,18 @@ namespace MWClass return true; } - boost::shared_ptr Container::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Container::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return boost::shared_ptr (new MWWorld::NullAction ()); + return std::shared_ptr (new MWWorld::NullAction ()); if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Sound *sound = store.get().searchRandom("WolfContainer"); - boost::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; @@ -181,20 +181,20 @@ namespace MWClass { if(!isTrapped) { - boost::shared_ptr action (new MWWorld::ActionOpen(ptr)); + std::shared_ptr action (new MWWorld::ActionOpen(ptr)); return action; } else { // Activate trap - boost::shared_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); + std::shared_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); action->setSound(trapActivationSound); return action; } } else { - boost::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); action->setSound(lockedSound); return action; } @@ -224,7 +224,7 @@ namespace MWClass void Container::registerSelf() { - boost::shared_ptr instance (new Container); + std::shared_ptr instance (new Container); registerClass (typeid (ESM::Container).name(), instance); } @@ -308,7 +308,7 @@ namespace MWClass if (!ptr.getRefData().getCustomData()) { // Create a CustomData, but don't fill it from ESM records (not needed) - std::auto_ptr data (new ContainerCustomData); + std::unique_ptr data (new ContainerCustomData); ptr.getRefData().setCustomData (data.release()); } diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 04223f264..e38d98b5c 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -23,7 +23,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7c2e05c77..65f8c80d8 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -4,6 +4,7 @@ #include #include +#include #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/magiceffects.hpp" @@ -108,7 +109,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - std::auto_ptr data (new CreatureCustomData); + std::unique_ptr data (new CreatureCustomData); MWWorld::LiveCellRef *ref = ptr.get(); @@ -434,7 +435,7 @@ namespace MWClass } } - boost::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Creature::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -442,17 +443,34 @@ namespace MWClass const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Sound *sound = store.get().searchRandom("WolfCreature"); - boost::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - if(getCreatureStats(ptr).isDead()) - return boost::shared_ptr(new MWWorld::ActionOpen(ptr, true)); - if(ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat()) - return boost::shared_ptr(new MWWorld::FailedAction("")); - return boost::shared_ptr(new MWWorld::ActionTalk(ptr)); + const MWMechanics::CreatureStats& stats = getCreatureStats(ptr); + + if(stats.isDead()) + { + bool canLoot = Settings::Manager::getBool ("can loot during death animation", "Game"); + + // by default user can loot friendly actors during death animation + if (canLoot && !stats.getAiSequence().isInCombat()) + return std::shared_ptr(new MWWorld::ActionOpen(ptr, true)); + + // otherwise wait until death animation + if(stats.isDeathAnimationFinished()) + return std::shared_ptr(new MWWorld::ActionOpen(ptr, true)); + + // death animation is not finished, do nothing + return std::shared_ptr (new MWWorld::FailedAction("")); + } + + if(stats.getAiSequence().isInCombat()) + return std::shared_ptr(new MWWorld::FailedAction("")); + + return std::shared_ptr(new MWWorld::ActionTalk(ptr)); } MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) const @@ -489,7 +507,7 @@ namespace MWClass void Creature::registerSelf() { - boost::shared_ptr instance (new Creature); + std::shared_ptr instance (new Creature); registerClass (typeid (ESM::Creature).name(), instance); } @@ -558,7 +576,11 @@ namespace MWClass return true; const CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData(); - return !customData.mCreatureStats.getAiSequence().isInCombat() || customData.mCreatureStats.isDead(); + + if (customData.mCreatureStats.isDead() && customData.mCreatureStats.isDeathAnimationFinished()) + return true; + + return !customData.mCreatureStats.getAiSequence().isInCombat(); } MWGui::ToolTipInfo Creature::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const @@ -742,7 +764,7 @@ namespace MWClass if (!ptr.getRefData().getCustomData()) { // Create a CustomData, but don't fill it from ESM records (not needed) - std::auto_ptr data (new CreatureCustomData); + std::unique_ptr data (new CreatureCustomData); if (hasInventoryStore(ptr)) data->mContainerStore = new MWWorld::InventoryStore(); diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 076bc8572..e3689204a 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -60,7 +60,7 @@ namespace MWClass virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, const osg::Vec3f &hitPosition, bool successful) const; - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation diff --git a/apps/openmw/mwclass/creaturelevlist.cpp b/apps/openmw/mwclass/creaturelevlist.cpp index 5941a09f5..4a4d9793e 100644 --- a/apps/openmw/mwclass/creaturelevlist.cpp +++ b/apps/openmw/mwclass/creaturelevlist.cpp @@ -70,7 +70,7 @@ namespace MWClass void CreatureLevList::registerSelf() { - boost::shared_ptr instance (new CreatureLevList); + std::shared_ptr instance (new CreatureLevList); registerClass (typeid (ESM::CreatureLevList).name(), instance); } @@ -132,7 +132,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - std::auto_ptr data (new CreatureLevListCustomData); + std::unique_ptr data (new CreatureLevListCustomData); data->mSpawnActorId = -1; data->mSpawn = true; diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index bc3455c65..07e6cc9db 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -76,6 +76,11 @@ namespace MWClass } } + bool Door::isDoor() const + { + return true; + } + bool Door::useAnim() const { return true; @@ -99,7 +104,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Door::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Door::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { MWWorld::LiveCellRef *ref = ptr.get(); @@ -132,15 +137,19 @@ namespace MWClass // make key id lowercase std::string keyId = ptr.getCellRef().getKey(); - Misc::StringUtils::lowerCaseInPlace(keyId); - for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it) + if (!keyId.empty()) { - std::string refId = it->getCellRef().getRefId(); - Misc::StringUtils::lowerCaseInPlace(refId); - if (refId == keyId) + Misc::StringUtils::lowerCaseInPlace(keyId); + for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it) { - hasKey = true; - keyName = it->getClass().getName(*it); + std::string refId = it->getCellRef().getRefId(); + Misc::StringUtils::lowerCaseInPlace(refId); + if (refId == keyId) + { + hasKey = true; + keyName = it->getClass().getName(*it); + break; + } } } @@ -166,7 +175,7 @@ namespace MWClass if(isTrapped) { // Trap activation - boost::shared_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); + std::shared_ptr action(new MWWorld::ActionTrap(ptr.getCellRef().getTrap(), ptr)); action->setSound(trapActivationSound); return action; } @@ -176,12 +185,12 @@ namespace MWClass if (actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getDistanceToFacedObject() > MWBase::Environment::get().getWorld()->getMaxActivationDistance()) { // player activated teleport door with telekinesis - boost::shared_ptr action(new MWWorld::FailedAction); + std::shared_ptr action(new MWWorld::FailedAction); return action; } else { - boost::shared_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); + std::shared_ptr action(new MWWorld::ActionTeleport (ptr.getCellRef().getDestCell(), ptr.getCellRef().getDoorDest(), true)); action->setSound(openSound); return action; } @@ -189,7 +198,7 @@ namespace MWClass else { // animated door - boost::shared_ptr action(new MWWorld::ActionDoor(ptr)); + std::shared_ptr action(new MWWorld::ActionDoor(ptr)); int doorstate = getDoorState(ptr); bool opening = true; float doorRot = ptr.getRefData().getPosition().rot[2] - ptr.getCellRef().getPosition().rot[2]; @@ -223,7 +232,7 @@ namespace MWClass else { // locked, and we can't open. - boost::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); + std::shared_ptr action(new MWWorld::FailedAction(std::string(), ptr)); action->setSound(lockedSound); return action; } @@ -264,7 +273,7 @@ namespace MWClass void Door::registerSelf() { - boost::shared_ptr instance (new Door); + std::shared_ptr instance (new Door); registerClass (typeid (ESM::Door).name(), instance); } @@ -350,7 +359,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - std::auto_ptr data(new DoorCustomData); + std::unique_ptr data(new DoorCustomData); data->mDoorState = 0; ptr.getRefData().setCustomData(data.release()); diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index 3760f59c4..57e475382 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -20,13 +20,15 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool isDoor() const; + virtual bool useAnim() const; virtual std::string getName (const MWWorld::ConstPtr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index a9a995f2f..09d149331 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -54,7 +54,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Ingredient::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -75,9 +75,9 @@ namespace MWClass } - boost::shared_ptr Ingredient::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Ingredient::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action (new MWWorld::ActionEat (ptr)); + std::shared_ptr action (new MWWorld::ActionEat (ptr)); action->setSound ("Swallow"); @@ -86,7 +86,7 @@ namespace MWClass void Ingredient::registerSelf() { - boost::shared_ptr instance (new Ingredient); + std::shared_ptr instance (new Ingredient); registerClass (typeid (ESM::Ingredient).name(), instance); } diff --git a/apps/openmw/mwclass/ingredient.hpp b/apps/openmw/mwclass/ingredient.hpp index 9a8bdacfb..1136eb50f 100644 --- a/apps/openmw/mwclass/ingredient.hpp +++ b/apps/openmw/mwclass/ingredient.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -36,7 +36,7 @@ namespace MWClass virtual int getValue (const MWWorld::ConstPtr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/itemlevlist.cpp b/apps/openmw/mwclass/itemlevlist.cpp index 290ac4c26..d2c246a85 100644 --- a/apps/openmw/mwclass/itemlevlist.cpp +++ b/apps/openmw/mwclass/itemlevlist.cpp @@ -12,7 +12,7 @@ namespace MWClass void ItemLevList::registerSelf() { - boost::shared_ptr instance (new ItemLevList); + std::shared_ptr instance (new ItemLevList); registerClass (typeid (ESM::ItemLevList).name(), instance); } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index ed69ee3ac..172c16c83 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -79,15 +79,15 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Light::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Light::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return boost::shared_ptr(new MWWorld::NullAction()); + return std::shared_ptr(new MWWorld::NullAction()); MWWorld::LiveCellRef *ref = ptr.get(); if(!(ref->mBase->mData.mFlags&ESM::Light::Carry)) - return boost::shared_ptr(new MWWorld::FailedAction()); + return std::shared_ptr(new MWWorld::FailedAction()); return defaultItemActivate(ptr, actor); } @@ -120,7 +120,7 @@ namespace MWClass void Light::registerSelf() { - boost::shared_ptr instance (new Light); + std::shared_ptr instance (new Light); registerClass (typeid (ESM::Light).name(), instance); } @@ -186,9 +186,9 @@ namespace MWClass return Class::showsInInventory(ptr); } - boost::shared_ptr Light::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Light::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 284a7d817..59085d97e 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -30,7 +30,7 @@ namespace MWClass virtual bool showsInInventory (const MWWorld::ConstPtr& ptr) const; - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -55,7 +55,7 @@ namespace MWClass virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index a335415ac..b8f6f5ecb 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -52,7 +52,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Lockpick::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -83,7 +83,7 @@ namespace MWClass void Lockpick::registerSelf() { - boost::shared_ptr instance (new Lockpick); + std::shared_ptr instance (new Lockpick); registerClass (typeid (ESM::Lockpick).name(), instance); } @@ -139,9 +139,9 @@ namespace MWClass return info; } - boost::shared_ptr Lockpick::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Lockpick::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/lockpick.hpp b/apps/openmw/mwclass/lockpick.hpp index f04674f5c..efa675c95 100644 --- a/apps/openmw/mwclass/lockpick.hpp +++ b/apps/openmw/mwclass/lockpick.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -51,7 +51,7 @@ namespace MWClass virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 3e1d750ad..a68176226 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -1,14 +1,11 @@ #include "misc.hpp" -#include - #include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwworld/ptr.hpp" #include "../mwworld/actiontake.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/esmstore.hpp" @@ -22,8 +19,6 @@ #include "../mwrender/objects.hpp" #include "../mwrender/renderinginterface.hpp" -#include - namespace MWClass { bool Miscellaneous::isGold (const MWWorld::ConstPtr& ptr) const @@ -65,7 +60,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Miscellaneous::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -97,7 +92,7 @@ namespace MWClass void Miscellaneous::registerSelf() { - boost::shared_ptr instance (new Miscellaneous); + std::shared_ptr instance (new Miscellaneous); registerClass (typeid (ESM::Miscellaneous).name(), instance); } @@ -146,7 +141,7 @@ namespace MWClass if (!gold) countString = MWGui::ToolTips::getCountString(count); else // gold displays its count also if it's 1. - countString = " (" + boost::lexical_cast(count) + ")"; + countString = " (" + std::to_string(count) + ")"; info.caption = ref->mBase->mName + countString; info.icon = ref->mBase->mIcon; @@ -213,12 +208,12 @@ namespace MWClass return newPtr; } - boost::shared_ptr Miscellaneous::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Miscellaneous::use (const MWWorld::Ptr& ptr) const { if (ptr.getCellRef().getSoul().empty()) - return boost::shared_ptr(new MWWorld::NullAction()); + return std::shared_ptr(new MWWorld::NullAction()); else - return boost::shared_ptr(new MWWorld::ActionSoulgem(ptr)); + return std::shared_ptr(new MWWorld::ActionSoulgem(ptr)); } bool Miscellaneous::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/misc.hpp b/apps/openmw/mwclass/misc.hpp index 2a534f058..37e77860b 100644 --- a/apps/openmw/mwclass/misc.hpp +++ b/apps/openmw/mwclass/misc.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -49,7 +49,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 855850dfd..ca6c85aba 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -303,7 +304,7 @@ namespace MWClass { if (!ptr.getRefData().getCustomData()) { - std::auto_ptr data(new NpcCustomData); + std::unique_ptr data(new NpcCustomData); MWWorld::LiveCellRef *ref = ptr.get(); @@ -844,12 +845,12 @@ namespace MWClass } } - boost::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Npc::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { // player got activated by another NPC if(ptr == MWMechanics::getPlayer()) - return boost::shared_ptr(new MWWorld::ActionTalk(actor)); + return std::shared_ptr(new MWWorld::ActionTalk(actor)); // Werewolfs can't activate NPCs if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) @@ -857,23 +858,42 @@ namespace MWClass const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Sound *sound = store.get().searchRandom("WolfNPC"); - boost::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - if(getCreatureStats(ptr).isDead()) - return boost::shared_ptr(new MWWorld::ActionOpen(ptr, true)); - if(ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat()) - return boost::shared_ptr(new MWWorld::FailedAction("#{sActorInCombat}")); + const MWMechanics::CreatureStats& stats = getCreatureStats(ptr); + + if(stats.isDead()) + { + bool canLoot = Settings::Manager::getBool ("can loot during death animation", "Game"); + + // by default user can loot friendly actors during death animation + if (canLoot && !stats.getAiSequence().isInCombat()) + return std::shared_ptr(new MWWorld::ActionOpen(ptr, true)); + + // otherwise wait until death animation + if(stats.isDeathAnimationFinished()) + return std::shared_ptr(new MWWorld::ActionOpen(ptr, true)); + + // death animation is not finished, do nothing + return std::shared_ptr (new MWWorld::FailedAction("")); + } + + if(stats.getAiSequence().isInCombat()) + return std::shared_ptr(new MWWorld::FailedAction("")); + if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak) - || ptr.getClass().getCreatureStats(ptr).getKnockedDown()) - return boost::shared_ptr(new MWWorld::ActionOpen(ptr)); // stealing + || ptr.getClass().getCreatureStats(ptr).getKnockedDown()) + return std::shared_ptr(new MWWorld::ActionOpen(ptr)); // stealing + // Can't talk to werewolfs if(ptr.getClass().isNpc() && ptr.getClass().getNpcStats(ptr).isWerewolf()) - return boost::shared_ptr (new MWWorld::FailedAction("")); - return boost::shared_ptr(new MWWorld::ActionTalk(ptr)); + return std::shared_ptr (new MWWorld::FailedAction("")); + + return std::shared_ptr(new MWWorld::ActionTalk(ptr)); } MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) @@ -1009,7 +1029,7 @@ namespace MWClass void Npc::registerSelf() { - boost::shared_ptr instance (new Npc); + std::shared_ptr instance (new Npc); registerClass (typeid (ESM::NPC).name(), instance); } @@ -1019,7 +1039,11 @@ namespace MWClass return true; const NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData(); - return !customData.mNpcStats.getAiSequence().isInCombat() || customData.mNpcStats.isDead(); + + if (customData.mNpcStats.isDead() && customData.mNpcStats.isDeathAnimationFinished()) + return true; + + return !customData.mNpcStats.getAiSequence().isInCombat(); } MWGui::ToolTipInfo Npc::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const @@ -1259,7 +1283,7 @@ namespace MWClass if (!ptr.getRefData().getCustomData()) { // Create a CustomData, but don't fill it from ESM records (not needed) - std::auto_ptr data (new NpcCustomData); + std::unique_ptr data (new NpcCustomData); ptr.getRefData().setCustomData (data.release()); } } diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index 3120c498c..e91dc7113 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -78,7 +78,7 @@ namespace MWClass virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector& models) const; ///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel(). - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 225175979..ffdccf438 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -55,7 +55,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Potion::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -78,7 +78,7 @@ namespace MWClass void Potion::registerSelf() { - boost::shared_ptr instance (new Potion); + std::shared_ptr instance (new Potion); registerClass (typeid (ESM::Potion).name(), instance); } @@ -139,12 +139,12 @@ namespace MWClass return info; } - boost::shared_ptr Potion::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Potion::use (const MWWorld::Ptr& ptr) const { MWWorld::LiveCellRef *ref = ptr.get(); - boost::shared_ptr action ( + std::shared_ptr action ( new MWWorld::ActionApply (ptr, ref->mBase->mId)); action->setSound ("Drink"); diff --git a/apps/openmw/mwclass/potion.hpp b/apps/openmw/mwclass/potion.hpp index 9cdd58058..ad9a329c0 100644 --- a/apps/openmw/mwclass/potion.hpp +++ b/apps/openmw/mwclass/potion.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -36,7 +36,7 @@ namespace MWClass virtual int getValue (const MWWorld::ConstPtr& ptr) const; ///< Return trade value of the object. Throws an exception, if the object can't be traded. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) const; + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu static void registerSelf(); diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 185aa66cb..ecaa056f9 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -51,7 +51,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Probe::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -83,7 +83,7 @@ namespace MWClass void Probe::registerSelf() { - boost::shared_ptr instance (new Probe); + std::shared_ptr instance (new Probe); registerClass (typeid (ESM::Probe).name(), instance); } @@ -139,9 +139,9 @@ namespace MWClass return info; } - boost::shared_ptr Probe::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Probe::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/probe.hpp b/apps/openmw/mwclass/probe.hpp index 4fc991a5f..f67d8af86 100644 --- a/apps/openmw/mwclass/probe.hpp +++ b/apps/openmw/mwclass/probe.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -51,7 +51,7 @@ namespace MWClass virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const; ///< Return name of inventory icon. - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index cbdfade2b..566d16106 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -51,7 +51,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Repair::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -74,7 +74,7 @@ namespace MWClass void Repair::registerSelf() { - boost::shared_ptr instance (new Repair); + std::shared_ptr instance (new Repair); registerClass (typeid (ESM::Repair).name(), instance); } @@ -149,9 +149,9 @@ namespace MWClass return MWWorld::Ptr(cell.insert(ref), &cell); } - boost::shared_ptr Repair::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Repair::use (const MWWorld::Ptr& ptr) const { - return boost::shared_ptr(new MWWorld::ActionRepair(ptr)); + return std::shared_ptr(new MWWorld::ActionRepair(ptr)); } bool Repair::canSell (const MWWorld::ConstPtr& item, int npcServices) const diff --git a/apps/openmw/mwclass/repair.hpp b/apps/openmw/mwclass/repair.hpp index f0d1292f4..34ba4035b 100644 --- a/apps/openmw/mwclass/repair.hpp +++ b/apps/openmw/mwclass/repair.hpp @@ -20,7 +20,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -49,7 +49,7 @@ namespace MWClass virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action). diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 65e69ea90..40a6b998c 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -43,7 +43,7 @@ namespace MWClass void Static::registerSelf() { - boost::shared_ptr instance (new Static); + std::shared_ptr instance (new Static); registerClass (typeid (ESM::Static).name(), instance); } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 470c7040d..efb6248af 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -1,6 +1,7 @@ #include "weapon.hpp" #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -53,7 +54,7 @@ namespace MWClass return ref->mBase->mName; } - boost::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, + std::shared_ptr Weapon::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { return defaultItemActivate(ptr, actor); @@ -142,7 +143,7 @@ namespace MWClass void Weapon::registerSelf() { - boost::shared_ptr instance (new Weapon); + std::shared_ptr instance (new Weapon); registerClass (typeid (ESM::Weapon).name(), instance); } @@ -261,8 +262,8 @@ namespace MWClass std::string text; - // weapon type & damage. arrows / bolts don't have his info. - if (ref->mBase->mData.mType < 12) + // weapon type & damage + if ((ref->mBase->mData.mType < 12 || Settings::Manager::getBool("show projectile damage", "Game")) && ref->mBase->mData.mType < 14) { text += "\n#{sType} "; @@ -279,6 +280,8 @@ namespace MWClass mapping[ESM::Weapon::MarksmanBow] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", ""); + mapping[ESM::Weapon::Arrow] = std::make_pair("sSkillMarksman", ""); + mapping[ESM::Weapon::Bolt] = std::make_pair("sSkillMarksman", ""); std::string type = mapping[ref->mBase->mData.mType].first; std::string oneOrTwoHanded = mapping[ref->mBase->mData.mType].second; @@ -318,6 +321,14 @@ namespace MWClass + MWGui::ToolTips::toString(ref->mBase->mData.mHealth); } + // add reach and attack speed for melee weapon + if (ref->mBase->mData.mType < 9 && Settings::Manager::getBool("show melee info", "Game")) + { + text += MWGui::ToolTips::getPercentString(ref->mBase->mData.mReach, "#{sRange}"); + + text += MWGui::ToolTips::getPercentString(ref->mBase->mData.mSpeed, "#{sAttributeSpeed}"); + } + text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}"); text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); @@ -381,9 +392,9 @@ namespace MWClass return std::make_pair(1, ""); } - boost::shared_ptr Weapon::use (const MWWorld::Ptr& ptr) const + std::shared_ptr Weapon::use (const MWWorld::Ptr& ptr) const { - boost::shared_ptr action(new MWWorld::ActionEquip(ptr)); + std::shared_ptr action(new MWWorld::ActionEquip(ptr)); action->setSound(getUpSoundId(ptr)); diff --git a/apps/openmw/mwclass/weapon.hpp b/apps/openmw/mwclass/weapon.hpp index 5fc3983f2..c14847363 100644 --- a/apps/openmw/mwclass/weapon.hpp +++ b/apps/openmw/mwclass/weapon.hpp @@ -21,7 +21,7 @@ namespace MWClass ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. - virtual boost::shared_ptr activate (const MWWorld::Ptr& ptr, + virtual std::shared_ptr activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const; ///< Generate action for activation @@ -72,7 +72,7 @@ namespace MWClass ///< Return 0 if player cannot equip item. 1 if can equip. 2 if it's twohanded weapon. 3 if twohanded weapon conflicts with that. /// Second item in the pair specifies the error message - virtual boost::shared_ptr use (const MWWorld::Ptr& ptr) + virtual std::shared_ptr use (const MWWorld::Ptr& ptr) const; ///< Generate action for using via inventory menu diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 254bc7d47..fa5bfbe2f 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -170,8 +170,8 @@ namespace MWDialogue parseText (info->mResponse); MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); - win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext)); - executeScript (info->mResultScript); + win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), "", false); + executeScript (info->mResultScript, mActor); mLastTopic = Misc::StringUtils::lowerCase(it->mId); // update topics again to accommodate changes resulting from executeScript @@ -190,7 +190,7 @@ namespace MWDialogue MWBase::Environment::get().getWindowManager()->showCompanionWindow(mActor); } - bool DialogueManager::compile (const std::string& cmd,std::vector& code) + bool DialogueManager::compile (const std::string& cmd, std::vector& code, const MWWorld::Ptr& actor) { bool success = true; @@ -206,7 +206,7 @@ namespace MWDialogue Compiler::Locals locals; - std::string actorScript = mActor.getClass().getScript (mActor); + std::string actorScript = actor.getClass().getScript (actor); if (!actorScript.empty()) { @@ -246,14 +246,14 @@ namespace MWDialogue return success; } - void DialogueManager::executeScript (const std::string& script) + void DialogueManager::executeScript (const std::string& script, const MWWorld::Ptr& actor) { std::vector code; - if(compile(script,code)) + if(compile(script, code, actor)) { try { - MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor); + MWScript::InterpreterContext interpreterContext(&actor.getRefData().getLocals(), actor); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); interpreter.run (&code[0], code.size(), interpreterContext); @@ -317,7 +317,7 @@ namespace MWDialogue } } - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); mLastTopic = topic; } @@ -500,7 +500,7 @@ namespace MWDialogue } } - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); } else { @@ -618,13 +618,13 @@ namespace MWDialogue win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext), gmsts.find ("sServiceRefusal")->getString()); - executeScript (info->mResultScript); + executeScript (info->mResultScript, mActor); return true; } return false; } - void DialogueManager::say(const MWWorld::Ptr &actor, const std::string &topic) const + void DialogueManager::say(const MWWorld::Ptr &actor, const std::string &topic) { MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); if(!sndMgr->sayDone(actor)) @@ -633,6 +633,12 @@ namespace MWDialogue return; } + if (actor.getClass().isNpc() && MWBase::Environment::get().getWorld()->isSwimming(actor)) + { + // NPCs don't talk while submerged + return; + } + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Dialogue *dial = store.get().find(topic); @@ -646,6 +652,8 @@ namespace MWDialogue winMgr->messageBox(info->mResponse); if (!info->mSound.empty()) sndMgr->say(actor, info->mSound); + if (!info->mResultScript.empty()) + executeScript(info->mResultScript, actor); } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index bbe42975c..40a24a1f8 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -51,8 +51,8 @@ namespace MWDialogue void updateTopics(); void updateGlobals(); - bool compile (const std::string& cmd,std::vector& code); - void executeScript (const std::string& script); + bool compile (const std::string& cmd, std::vector& code, const MWWorld::Ptr& actor); + void executeScript (const std::string& script, const MWWorld::Ptr& actor); void executeTopic (const std::string& topic); @@ -74,7 +74,7 @@ namespace MWDialogue virtual bool checkServiceRefused (); - virtual void say(const MWWorld::Ptr &actor, const std::string &topic) const; + virtual void say(const MWWorld::Ptr &actor, const std::string &topic); //calbacks for the GUI virtual void keywordSelected (const std::string& keyword); diff --git a/apps/openmw/mwdialogue/journalimp.cpp b/apps/openmw/mwdialogue/journalimp.cpp index f11ec651d..27a3b31b5 100644 --- a/apps/openmw/mwdialogue/journalimp.cpp +++ b/apps/openmw/mwdialogue/journalimp.cpp @@ -85,13 +85,15 @@ namespace MWDialogue StampedJournalEntry entry = StampedJournalEntry::makeFromQuest (id, index, actor); - mJournal.push_back (entry); - Quest& quest = getQuest (id); - quest.addEntry (entry); // we are doing slicing on purpose here - MWBase::Environment::get().getWindowManager()->messageBox ("#{sJournalEntry}"); + // there is no need to show empty entries in journal + if (!entry.getText().empty()) + { + mJournal.push_back (entry); + MWBase::Environment::get().getWindowManager()->messageBox ("#{sJournalEntry}"); + } } void Journal::setJournalIndex (const std::string& id, int index) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 1d758cccf..7379f3613 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -4,7 +4,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwmechanics/magiceffects.hpp" @@ -66,26 +65,27 @@ namespace MWGui void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender) { MWMechanics::Alchemy::Result result = mAlchemy->create (mNameEdit->getCaption ()); + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); switch (result) { case MWMechanics::Alchemy::Result_NoName: - MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage37}"); + winMgr->messageBox("#{sNotifyMessage37}"); break; case MWMechanics::Alchemy::Result_NoMortarAndPestle: - MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage45}"); + winMgr->messageBox("#{sNotifyMessage45}"); break; case MWMechanics::Alchemy::Result_LessThanTwoIngredients: - MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage6a}"); + winMgr->messageBox("#{sNotifyMessage6a}"); break; case MWMechanics::Alchemy::Result_Success: - MWBase::Environment::get().getWindowManager()->messageBox("#{sPotionSuccess}"); - MWBase::Environment::get().getSoundManager()->playSound("potion success", 1.f, 1.f); + winMgr->messageBox("#{sPotionSuccess}"); + winMgr->playSound("potion success"); break; case MWMechanics::Alchemy::Result_NoEffects: case MWMechanics::Alchemy::Result_RandomFailure: - MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage8}"); - MWBase::Environment::get().getSoundManager()->playSound("potion fail", 1.f, 1.f); + winMgr->messageBox("#{sNotifyMessage8}"); + winMgr->playSound("potion fail"); break; } @@ -151,7 +151,7 @@ namespace MWGui update(); std::string sound = item.getClass().getUpSoundId(item); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound(sound); } } diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index 69fff8c67..e1f48d4a3 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -3,6 +3,8 @@ #include +#include "../mwmechanics/alchemy.hpp" + #include "widgets.hpp" #include "windowbase.hpp" @@ -48,7 +50,7 @@ namespace MWGui void update(); - std::auto_ptr mAlchemy; + std::unique_ptr mAlchemy; std::vector mApparatus; std::vector mIngredients; diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index c5c4e8d03..137594076 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -6,11 +6,6 @@ #include "MyGUI_TextureUtility.h" #include "MyGUI_FactoryManager.h" -#include -#include -#include -#include - #include namespace MWGui @@ -40,22 +35,22 @@ struct TypesetBookImpl : TypesetBook MyGUI::Colour mNormalColour; InteractiveId mInteractiveId; - bool match (MyGUI::IFont* tstFont, MyGUI::Colour tstHotColour, MyGUI::Colour tstActiveColour, - MyGUI::Colour tstNormalColour, intptr_t tstInteractiveId) + bool match (MyGUI::IFont* tstFont, const MyGUI::Colour& tstHotColour, const MyGUI::Colour& tstActiveColour, + const MyGUI::Colour& tstNormalColour, intptr_t tstInteractiveId) { return (mFont == tstFont) && partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); } - bool match (char const * tstFont, MyGUI::Colour tstHotColour, MyGUI::Colour tstActiveColour, - MyGUI::Colour tstNormalColour, intptr_t tstInteractiveId) + bool match (char const * tstFont, const MyGUI::Colour& tstHotColour, const MyGUI::Colour& tstActiveColour, + const MyGUI::Colour& tstNormalColour, intptr_t tstInteractiveId) { return (mFont->getResourceName () == tstFont) && partal_match (tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); } - bool partal_match (MyGUI::Colour tstHotColour, MyGUI::Colour tstActiveColour, - MyGUI::Colour tstNormalColour, intptr_t tstInteractiveId) + bool partal_match (const MyGUI::Colour& tstHotColour, const MyGUI::Colour& tstActiveColour, + const MyGUI::Colour& tstNormalColour, intptr_t tstInteractiveId) { return (mHotColour == tstHotColour ) && @@ -235,7 +230,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter }; typedef TypesetBookImpl Book; - typedef boost::shared_ptr BookPtr; + typedef std::shared_ptr BookPtr; typedef std::vector::const_iterator PartialTextConstIterator; int mPageWidth; @@ -259,14 +254,14 @@ struct TypesetBookImpl::Typesetter : BookTypesetter mCurrentContent (NULL), mCurrentAlignment (AlignLeft) { - mBook = boost::make_shared (); + mBook = std::make_shared (); } virtual ~Typesetter () { } - Style * createStyle (char const * fontName, Colour fontColour) + Style * createStyle (char const * fontName, const Colour& fontColour) { if (strcmp(fontName, "") == 0) return createStyle(MyGUI::FontManager::getInstance().getDefaultFont().c_str(), fontColour); @@ -289,7 +284,8 @@ struct TypesetBookImpl::Typesetter : BookTypesetter return &style; } - Style* createHotStyle (Style* baseStyle, Colour normalColour, Colour hoverColour, Colour activeColour, InteractiveId id, bool unique) + Style* createHotStyle (Style* baseStyle, const Colour& normalColour, const Colour& hoverColour, + const Colour& activeColour, InteractiveId id, bool unique) { StyleImpl* BaseStyle = static_cast (baseStyle); @@ -439,9 +435,15 @@ struct TypesetBookImpl::Typesetter : BookTypesetter } else { + // The section won't completely fit on the current page. Finish the current page and start a new one. + mBook->mPages.push_back (Page (curPageStart, curPageStop)); + + curPageStart = i->mRect.top; + curPageStop = i->mRect.bottom; + //split section int sectionHeightLeft = sectionHeight; - while (sectionHeightLeft > mPageHeight) + while (sectionHeightLeft >= mPageHeight) { // Adjust to the top of the first line that does not fit on the current page anymore int splitPos = curPageStop; @@ -628,7 +630,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter BookTypesetter::Ptr BookTypesetter::create (int pageWidth, int pageHeight) { - return boost::make_shared (pageWidth, pageHeight); + return std::make_shared (pageWidth, pageHeight); } namespace @@ -897,10 +899,10 @@ public: Style* mFocusItem; bool mItemActive; MyGUI::MouseButton mLastDown; - boost::function mLinkClicked; + std::function mLinkClicked; - boost::shared_ptr mBook; + std::shared_ptr mBook; MyGUI::ILayerNode* mNode; ActiveTextFormats mActiveTextFormats; @@ -1034,7 +1036,7 @@ public: void showPage (TypesetBook::Ptr book, size_t newPage) { - boost::shared_ptr newBook = boost::dynamic_pointer_cast (book); + std::shared_ptr newBook = std::dynamic_pointer_cast (book); if (mBook != newBook) { @@ -1050,7 +1052,7 @@ public: mActiveTextFormats.clear (); - if (newBook != NULL) + if (newBook != nullptr) { createActiveFormats (newBook); @@ -1123,7 +1125,7 @@ public: } }; - void createActiveFormats (boost::shared_ptr newBook) + void createActiveFormats (std::shared_ptr newBook) { newBook->visitRuns (0, 0x7FFFFFFF, CreateActiveFormat (this)); @@ -1265,14 +1267,14 @@ public: mPageDisplay->showPage (book, page); } - void adviseLinkClicked (boost::function linkClicked) + void adviseLinkClicked (std::function linkClicked) { mPageDisplay->mLinkClicked = linkClicked; } void unadviseLinkClicked () { - mPageDisplay->mLinkClicked = boost::function (); + mPageDisplay->mLinkClicked = std::function (); } protected: diff --git a/apps/openmw/mwgui/bookpage.hpp b/apps/openmw/mwgui/bookpage.hpp index c7340ec7c..66d1834c7 100644 --- a/apps/openmw/mwgui/bookpage.hpp +++ b/apps/openmw/mwgui/bookpage.hpp @@ -6,8 +6,6 @@ #include #include -#include -#include namespace MWGui { @@ -15,7 +13,7 @@ namespace MWGui /// the book page widget. struct TypesetBook { - typedef boost::shared_ptr Ptr; + typedef std::shared_ptr Ptr; typedef intptr_t InteractiveId; /// Returns the number of pages in the document. @@ -33,12 +31,15 @@ namespace MWGui /// A factory class for creating a typeset book instance. struct BookTypesetter { - typedef boost::shared_ptr Ptr; + typedef std::shared_ptr Ptr; typedef TypesetBook::InteractiveId InteractiveId; typedef MyGUI::Colour Colour; typedef uint8_t const * Utf8Point; typedef std::pair Utf8Span; + + + enum Alignment { AlignLeft = -1, AlignCenter = 0, @@ -55,12 +56,13 @@ namespace MWGui static Ptr create (int pageWidth, int pageHeight); /// Create a simple text style consisting of a font and a text color. - virtual Style* createStyle (char const * Font, Colour Colour) = 0; + virtual Style* createStyle (char const * Font, const Colour& Colour) = 0; /// Create a hyper-link style with a user-defined identifier based on an /// existing style. The unique flag forces a new instance of this style /// to be created even if an existing instance is present. - virtual Style* createHotStyle (Style * BaseStyle, Colour NormalColour, Colour HoverColour, Colour ActiveColour, InteractiveId Id, bool Unique = true) = 0; + virtual Style* createHotStyle (Style * BaseStyle, const Colour& NormalColour, const Colour& HoverColour, + const Colour& ActiveColour, InteractiveId Id, bool Unique = true) = 0; /// Insert a line break into the document. Newline characters in the input /// text have the same affect. The margin parameter adds additional space @@ -102,7 +104,7 @@ namespace MWGui public: typedef TypesetBook::InteractiveId InteractiveId; - typedef boost::function ClickCallback; + typedef std::function ClickCallback; /// Make the widget display the specified page from the specified book. virtual void showPage (TypesetBook::Ptr Book, size_t Page) = 0; diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index f3cefb787..b3296e7a7 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -6,7 +6,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwmechanics/actorutil.hpp" @@ -82,7 +81,7 @@ namespace MWGui clearPages(); mCurrentPage = 0; - MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("book open"); MWWorld::LiveCellRef *ref = mBook.get(); @@ -98,7 +97,7 @@ namespace MWGui void BookWindow::exit() { // no 3d sounds because the object could be in a container. - MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("book close"); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Book); } @@ -122,7 +121,7 @@ namespace MWGui void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender) { - MWBase::Environment::get().getSoundManager()->playSound("Item Book Up", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("Item Book Up"); MWWorld::ActionTake take(mBook); take.execute (MWMechanics::getPlayer()); @@ -195,7 +194,7 @@ namespace MWGui { if ((mCurrentPage+1)*2 < mPages.size()) { - MWBase::Environment::get().getSoundManager()->playSound ("book page2", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("book page2"); ++mCurrentPage; @@ -206,7 +205,7 @@ namespace MWGui { if (mCurrentPage > 0) { - MWBase::Environment::get().getSoundManager()->playSound ("book page", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("book page"); --mCurrentPage; diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 9464daaf6..2deb62215 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -13,6 +13,7 @@ #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" +#include "../mwworld/player.hpp" #include "textinput.hpp" #include "race.hpp" @@ -230,14 +231,23 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->removeDialog(mReviewDialog); mReviewDialog = 0; mReviewDialog = new ReviewDialog(); - mReviewDialog->setPlayerName(mPlayerName); - mReviewDialog->setRace(mPlayerRaceId); - mReviewDialog->setClass(mPlayerClass); - mReviewDialog->setBirthSign(mPlayerBirthSignId); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + + const ESM::NPC *playerNpc = world->getPlayerPtr().get()->mBase; + + const MWWorld::Player player = world->getPlayer(); + + const ESM::Class *playerClass = world->getStore().get().find(playerNpc->mClass); + + mReviewDialog->setPlayerName(playerNpc->mName); + mReviewDialog->setRace(playerNpc->mRace); + mReviewDialog->setClass(*playerClass); + mReviewDialog->setBirthSign(player.getBirthSign()); { - MWWorld::Ptr player = MWMechanics::getPlayer(); - const MWMechanics::CreatureStats& stats = player.getClass().getCreatureStats(player); + MWWorld::Ptr playerPtr = MWMechanics::getPlayer(); + const MWMechanics::CreatureStats& stats = playerPtr.getClass().getCreatureStats(playerPtr); mReviewDialog->setHealth ( stats.getHealth() ); mReviewDialog->setMagicka( stats.getMagicka() ); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 00df18e1d..c9be21322 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -5,7 +5,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/dialoguemanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -224,7 +223,7 @@ namespace MWGui // play the sound of the first object MWWorld::Ptr item = mModel->getItem(i).mBase; std::string sound = item.getClass().getUpSoundId(item); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound(sound); } const ItemStack& item = mModel->getItem(i); diff --git a/apps/openmw/mwgui/containeritemmodel.cpp b/apps/openmw/mwgui/containeritemmodel.cpp index 1e4749695..d62cd16b0 100644 --- a/apps/openmw/mwgui/containeritemmodel.cpp +++ b/apps/openmw/mwgui/containeritemmodel.cpp @@ -1,5 +1,7 @@ #include "containeritemmodel.hpp" +#include + #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 771e1bf95..f478dad7e 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -1,7 +1,5 @@ #include "dialogue.hpp" -#include - #include #include #include @@ -13,7 +11,6 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/dialoguemanager.hpp" #include "../mwworld/class.hpp" @@ -25,19 +22,10 @@ #include "widgets.hpp" #include "bookpage.hpp" +#include "textcolours.hpp" #include "journalbooks.hpp" // to_utf8_span -namespace -{ - - MyGUI::Colour getDialogueTextColour (const std::string& type) - { - return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}")); - } - -} - namespace MWGui { @@ -107,19 +95,23 @@ namespace MWGui // -------------------------------------------------------------------------------------------------- - Response::Response(const std::string &text, const std::string &title) - : mTitle(title) + Response::Response(const std::string &text, const std::string &title, bool needMargin) + : mTitle(title), mNeedMargin(needMargin) { mText = text; } void Response::write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map& topicLinks) const { - BookTypesetter::Style* title = typesetter->createStyle("", getDialogueTextColour("header")); - typesetter->sectionBreak(9); + typesetter->sectionBreak(mNeedMargin ? 9 : 0); + if (mTitle != "") + { + const MyGUI::Colour& headerColour = MWBase::Environment::get().getWindowManager()->getTextColours().header; + BookTypesetter::Style* title = typesetter->createStyle("", headerColour); typesetter->write(title, to_utf8_span(mTitle.c_str())); - typesetter->sectionBreak(9); + typesetter->sectionBreak(); + } typedef std::pair Range; std::map hyperLinks; @@ -159,15 +151,16 @@ namespace MWGui if (hyperLinks.size() && MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation()) { - BookTypesetter::Style* style = typesetter->createStyle("", getDialogueTextColour("normal")); + const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); + + BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal); size_t formatted = 0; // points to the first character that is not laid out yet for (std::map::iterator it = hyperLinks.begin(); it != hyperLinks.end(); ++it) { intptr_t topicId = it->second; - const MyGUI::Colour linkHot(getDialogueTextColour("link_over")); - const MyGUI::Colour linkNormal(getDialogueTextColour("link")); - const MyGUI::Colour linkActive(getDialogueTextColour("link_pressed")); - BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, linkNormal, linkHot, linkActive, topicId); + BookTypesetter::Style* hotStyle = typesetter->createHotStyle (style, textColours.link, + textColours.linkOver, textColours.linkPressed, + topicId); if (formatted < it->first.first) typesetter->write(style, formatted, it->first.first); typesetter->write(hotStyle, it->first.first, it->first.second); @@ -199,14 +192,13 @@ namespace MWGui void Response::addTopicLink(BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const { - BookTypesetter::Style* style = typesetter->createStyle("", getDialogueTextColour("normal")); + const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); + + BookTypesetter::Style* style = typesetter->createStyle("", textColours.normal); - const MyGUI::Colour linkHot(getDialogueTextColour("link_over")); - const MyGUI::Colour linkNormal(getDialogueTextColour("link")); - const MyGUI::Colour linkActive(getDialogueTextColour("link_pressed")); if (topicId) - style = typesetter->createHotStyle (style, linkNormal, linkHot, linkActive, topicId); + style = typesetter->createHotStyle (style, textColours.link, textColours.linkOver, textColours.linkPressed, topicId); typesetter->write (style, begin, end); } @@ -217,7 +209,8 @@ namespace MWGui void Message::write(BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map& topicLinks) const { - BookTypesetter::Style* title = typesetter->createStyle("", getDialogueTextColour("notify")); + const MyGUI::Colour& textColour = MWBase::Environment::get().getWindowManager()->getTextColours().notify; + BookTypesetter::Style* title = typesetter->createStyle("", textColour); typesetter->sectionBreak(9); typesetter->write(title, to_utf8_span(mText.c_str())); } @@ -227,21 +220,21 @@ namespace MWGui void Choice::activated() { - MWBase::Environment::get().getSoundManager()->playSound("Menu Click", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("Menu Click"); MWBase::Environment::get().getDialogueManager()->questionAnswered(mChoiceId); } void Topic::activated() { - MWBase::Environment::get().getSoundManager()->playSound("Menu Click", 1.f, 1.f); + MWBase::Environment::get().getWindowManager()->playSound("Menu Click"); MWBase::Environment::get().getDialogueManager()->keywordSelected(Misc::StringUtils::lowerCase(mTopicId)); } void Goodbye::activated() { - MWBase::Environment::get().getSoundManager()->playSound("Menu Click", 1.f, 1.f); + MWBase::Environment::get().getWindowManager()->playSound("Menu Click"); MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); } @@ -277,7 +270,7 @@ namespace MWGui mScrollBar->eventScrollChangePosition += MyGUI::newDelegate(this, &DialogueWindow::onScrollbarMoved); mHistory->eventMouseWheel += MyGUI::newDelegate(this, &DialogueWindow::onMouseWheel); - BookPage::ClickCallback callback = boost::bind (&DialogueWindow::notifyLinkClicked, this, _1); + BookPage::ClickCallback callback = std::bind (&DialogueWindow::notifyLinkClicked, this, std::placeholders::_1); mHistory->adviseLinkClicked(callback); mMainWidget->castType()->eventWindowChangeCoord += MyGUI::newDelegate(this, &DialogueWindow::onWindowResize); @@ -300,8 +293,12 @@ namespace MWGui void DialogueWindow::onWindowResize(MyGUI::Window* _sender) { + // if the window has only been moved, not resized, we don't need to update + if (mCurrentWindowSize == _sender->getSize()) return; + mTopicsList->adjustSize(); updateHistory(); + mCurrentWindowSize = _sender->getSize(); } void DialogueWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) @@ -486,16 +483,15 @@ namespace MWGui typesetter->sectionBreak(9); // choices - const MyGUI::Colour linkHot(getDialogueTextColour("answer_over")); - const MyGUI::Colour linkNormal(getDialogueTextColour("answer")); - const MyGUI::Colour linkActive(getDialogueTextColour("answer_pressed")); + const TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); for (std::vector >::iterator it = mChoices.begin(); it != mChoices.end(); ++it) { Choice* link = new Choice(it->second); mLinks.push_back(link); typesetter->lineBreak(); - BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, linkNormal, linkHot, linkActive, + BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver, + textColours.answerPressed, TypesetBook::InteractiveId(link)); typesetter->write(questionStyle, to_utf8_span(it->first.c_str())); } @@ -505,7 +501,8 @@ namespace MWGui Goodbye* link = new Goodbye(); mLinks.push_back(link); std::string goodbye = MWBase::Environment::get().getWorld()->getStore().get().find("sGoodbye")->getString(); - BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, linkNormal, linkHot, linkActive, + BookTypesetter::Style* questionStyle = typesetter->createHotStyle(body, textColours.answer, textColours.answerOver, + textColours.answerPressed, TypesetBook::InteractiveId(link)); typesetter->lineBreak(); typesetter->write(questionStyle, to_utf8_span(goodbye.c_str())); @@ -550,7 +547,7 @@ namespace MWGui mHistory->setPosition(0, static_cast(pos) * -1); } - void DialogueWindow::addResponse(const std::string &text, const std::string &title) + void DialogueWindow::addResponse(const std::string &text, const std::string &title, bool needMargin) { // This is called from the dialogue manager, so text is // case-smashed - thus we have to retrieve the correct case @@ -569,7 +566,7 @@ namespace MWGui } } - mHistoryContents.push_back(new Response(text, realTitle)); + mHistoryContents.push_back(new Response(text, realTitle, needMargin)); updateHistory(); } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index d34574e89..5b5ae5b68 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -82,10 +82,11 @@ namespace MWGui struct Response : DialogueText { - Response(const std::string& text, const std::string& title = ""); + Response(const std::string& text, const std::string& title = "", bool needMargin = true); virtual void write (BookTypesetter::Ptr typesetter, KeywordSearchT* keywordSearch, std::map& topicLinks) const; void addTopicLink (BookTypesetter::Ptr typesetter, intptr_t topicId, size_t begin, size_t end) const; std::string mTitle; + bool mNeedMargin; }; struct Message : DialogueText @@ -109,7 +110,7 @@ namespace MWGui void startDialogue(MWWorld::Ptr actor, std::string npcName, bool resetHistory); void setKeywords(std::list keyWord); - void addResponse (const std::string& text, const std::string& title=""); + void addResponse (const std::string& text, const std::string& title="", bool needMargin = true); void addMessageBox(const std::string& text); @@ -170,6 +171,8 @@ namespace MWGui MyGUI::TextBox* mDispositionText; PersuasionDialog mPersuasionDialog; + + MyGUI::IntSize mCurrentWindowSize; }; } #endif diff --git a/apps/openmw/mwgui/draganddrop.cpp b/apps/openmw/mwgui/draganddrop.cpp index 6053a7fb0..fa17d974d 100644 --- a/apps/openmw/mwgui/draganddrop.cpp +++ b/apps/openmw/mwgui/draganddrop.cpp @@ -5,7 +5,6 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/environment.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwworld/class.hpp" @@ -64,7 +63,7 @@ void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemMode } std::string sound = mItem.mBase.getClass().getUpSoundId(mItem.mBase); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound (sound); if (mSourceSortModel) { @@ -94,7 +93,7 @@ void DragAndDrop::startDrag (int index, SortFilterItemModel* sortModel, ItemMode void DragAndDrop::drop(ItemModel *targetModel, ItemView *targetView) { std::string sound = mItem.mBase.getClass().getDownSoundId(mItem.mBase); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound(sound); // We can't drop a conjured item to the ground; the target container should always be the source container if (mItem.mFlags & ItemStack::Flag_Bound && targetModel != mSourceModel) diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index e22891c9d..c7d2ef7de 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -2,16 +2,12 @@ #include -#include - #include #include #include +#include -#include "../mwbase/environment.hpp" -#include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/dialoguemanager.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/class.hpp" @@ -43,6 +39,8 @@ namespace MWGui getWidget(mEnchantmentPoints, "Enchantment"); getWidget(mCastCost, "CastCost"); getWidget(mCharge, "Charge"); + getWidget(mSuccessChance, "SuccessChance"); + getWidget(mChanceLayout, "ChanceLayout"); getWidget(mTypeButton, "TypeButton"); getWidget(mBuyButton, "BuyButton"); getWidget(mPrice, "PriceLabel"); @@ -115,6 +113,9 @@ namespace MWGui mCharge->setCaption(MyGUI::utility::toString(mEnchanting.getGemCharge())); + int successChance = int(mEnchanting.getEnchantChance()); + mSuccessChance->setCaption(MyGUI::utility::toString(std::max(0, successChance))); + std::stringstream castCost; castCost << mEnchanting.getEffectiveCastCost(); mCastCost->setCaption(castCost.str()); @@ -144,11 +145,15 @@ namespace MWGui void EnchantingDialog::startEnchanting (MWWorld::Ptr actor) { + mName->setCaption(""); + mEnchanting.setSelfEnchanting(false); mEnchanting.setEnchanter(actor); mBuyButton->setCaptionWithReplacing("#{sBuy}"); + mChanceLayout->setVisible(false); + mPtr = actor; setSoulGem(MWWorld::Ptr()); @@ -162,6 +167,8 @@ namespace MWGui void EnchantingDialog::startSelfEnchanting(MWWorld::Ptr soulgem) { + mName->setCaption(""); + MWWorld::Ptr player = MWMechanics::getPlayer(); mEnchanting.setSelfEnchanting(true); @@ -169,6 +176,10 @@ namespace MWGui mBuyButton->setCaptionWithReplacing("#{sCreate}"); + bool enabled = Settings::Manager::getBool("show enchant chance","Game"); + + mChanceLayout->setVisible(enabled); + mPtr = player; startEditing(); @@ -225,7 +236,7 @@ namespace MWGui mItemSelectionDialog->setVisible(false); setItem(item); - MWBase::Environment::get().getSoundManager()->playSound(item.getClass().getDownSoundId(item), 1, 1); + MWBase::Environment::get().getWindowManager()->playSound(item.getClass().getDownSoundId(item)); mEnchanting.nextCastStyle(); updateLabels(); } @@ -247,7 +258,7 @@ namespace MWGui } setSoulGem(item); - MWBase::Environment::get().getSoundManager()->playSound(item.getClass().getDownSoundId(item), 1, 1); + MWBase::Environment::get().getWindowManager()->playSound(item.getClass().getDownSoundId(item)); updateLabels(); } @@ -273,7 +284,9 @@ namespace MWGui else { setSoulGem(MWWorld::Ptr()); + mEnchanting.nextCastStyle(); updateLabels(); + updateEffectsView(); } } @@ -347,8 +360,9 @@ namespace MWGui if (msg.find("%s") != std::string::npos) msg.replace(msg.find("%s"), 2, item.getClass().getName(item)); MWBase::Environment::get().getWindowManager()->messageBox(msg); - MWBase::Environment::get().getMechanicsManager()->commitCrime(player, mPtr, MWBase::MechanicsManager::OT_Theft, - item.getClass().getValue(item), true); + + MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, item, mPtr, 1); + MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Enchanting); MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); return; @@ -360,12 +374,12 @@ namespace MWGui if(result==1) { - MWBase::Environment::get().getSoundManager()->playSound("enchant success", 1.f, 1.f); + MWBase::Environment::get().getWindowManager()->playSound("enchant success"); MWBase::Environment::get().getWindowManager()->messageBox ("#{sEnchantmentMenu12}"); } else { - MWBase::Environment::get().getSoundManager()->playSound("enchant fail", 1.f, 1.f); + MWBase::Environment::get().getWindowManager()->playSound("enchant fail"); MWBase::Environment::get().getWindowManager()->messageBox ("#{sNotifyMessage34}"); } diff --git a/apps/openmw/mwgui/enchantingdialog.hpp b/apps/openmw/mwgui/enchantingdialog.hpp index 5b67d199b..cb7c6c0d0 100644 --- a/apps/openmw/mwgui/enchantingdialog.hpp +++ b/apps/openmw/mwgui/enchantingdialog.hpp @@ -49,6 +49,8 @@ namespace MWGui ItemSelectionDialog* mItemSelectionDialog; + MyGUI::Widget* mChanceLayout; + MyGUI::Button* mCancelButton; ItemWidget* mItemBox; ItemWidget* mSoulBox; @@ -60,6 +62,7 @@ namespace MWGui MyGUI::TextBox* mEnchantmentPoints; MyGUI::TextBox* mCastCost; MyGUI::TextBox* mCharge; + MyGUI::TextBox* mSuccessChance; MyGUI::TextBox* mPrice; MyGUI::TextBox* mPriceText; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 7ce2dfa8b..84e5794e3 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -183,7 +183,7 @@ namespace MWGui int modified = static_cast(value.getModified()); MyGUI::Widget* w; - std::string valStr = MyGUI::utility::toString(current) + "/" + MyGUI::utility::toString(modified); + std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); if (id == "HBar") { mHealth->setProgressRange(modified); diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 21b90991c..8b0f895d1 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -18,7 +18,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/scriptmanager.hpp" @@ -136,6 +135,18 @@ namespace MWGui dirtyPreview(); updatePreviewSize(); + + updateEncumbranceBar(); + mItemView->update(); + notifyContentChanged(); + } + + void InventoryWindow::clear() + { + mPtr = MWWorld::Ptr(); + mTradeModel = NULL; + mSortModel = NULL; + mItemView->setModel(NULL); } void InventoryWindow::setGuiMode(GuiMode mode) @@ -227,7 +238,7 @@ namespace MWGui // Can't give conjured items to a merchant if (item.mFlags & ItemStack::Flag_Bound) { - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound(sound); MWBase::Environment::get().getWindowManager()->messageBox("#{sBarterDialog9}"); return; } @@ -236,7 +247,7 @@ namespace MWGui int services = MWBase::Environment::get().getWindowManager()->getTradeWindow()->getMerchantServices(); if (!object.getClass().canSell(object, services)) { - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound(sound); MWBase::Environment::get().getWindowManager()-> messageBox("#{sBarterDialog4}"); return; @@ -309,8 +320,8 @@ namespace MWGui { ensureSelectedItemUnequipped(count); const ItemStack& item = mTradeModel->getItem(mSelectedItem); - std::string sound = item.mBase.getClass().getDownSoundId(item.mBase); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + std::string sound = item.mBase.getClass().getUpSoundId(item.mBase); + MWBase::Environment::get().getWindowManager()->playSound(sound); if (item.mType == ItemStack::Type_Barter) { @@ -340,13 +351,12 @@ namespace MWGui void InventoryWindow::open() { - mPtr = MWMechanics::getPlayer(); - - updateEncumbranceBar(); - - mItemView->update(); - - notifyContentChanged(); + if (!mPtr.isEmpty()) + { + updateEncumbranceBar(); + mItemView->update(); + notifyContentChanged(); + } adjustPanes(); } @@ -433,6 +443,8 @@ namespace MWGui void InventoryWindow::onPinToggled() { + Settings::Manager::setBool("inventory pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setWeaponVisibility(!mPinned); } @@ -480,7 +492,7 @@ namespace MWGui { if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0) { - boost::shared_ptr action = ptr.getClass().use(ptr); + std::shared_ptr action = ptr.getClass().use(ptr); action->execute (player); } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 651bda590..761464540 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -5,6 +5,7 @@ #include "mode.hpp" #include "../mwworld/ptr.hpp" +#include "../mwrender/characterpreview.hpp" namespace osg { @@ -16,11 +17,6 @@ namespace Resource class ResourceSystem; } -namespace MWRender -{ - class InventoryPreview; -} - namespace MWGui { namespace Widgets @@ -60,6 +56,8 @@ namespace MWGui void updatePlayer(); + void clear(); + void useItem(const MWWorld::Ptr& ptr); void setGuiMode(GuiMode mode); @@ -99,8 +97,8 @@ namespace MWGui int mLastXSize; int mLastYSize; - std::auto_ptr mPreviewTexture; - std::auto_ptr mPreview; + std::unique_ptr mPreviewTexture; + std::unique_ptr mPreview; bool mTrading; diff --git a/apps/openmw/mwgui/itemchargeview.hpp b/apps/openmw/mwgui/itemchargeview.hpp index 0988f655b..956272aec 100644 --- a/apps/openmw/mwgui/itemchargeview.hpp +++ b/apps/openmw/mwgui/itemchargeview.hpp @@ -69,7 +69,7 @@ namespace MWGui typedef std::vector Lines; Lines mLines; - std::auto_ptr mModel; + std::unique_ptr mModel; MyGUI::ScrollView* mScrollView; DisplayMode mDisplayMode; }; diff --git a/apps/openmw/mwgui/jailscreen.cpp b/apps/openmw/mwgui/jailscreen.cpp index 211e0c5f9..8ac133d76 100644 --- a/apps/openmw/mwgui/jailscreen.cpp +++ b/apps/openmw/mwgui/jailscreen.cpp @@ -93,7 +93,7 @@ namespace MWGui if (skill == ESM::Skill::Security || skill == ESM::Skill::Sneak) value.setBase(std::min(100, value.getBase()+1)); else - value.setBase(value.getBase()-1); + value.setBase(std::max(0, value.getBase()-1)); } const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); diff --git a/apps/openmw/mwgui/journalbooks.cpp b/apps/openmw/mwgui/journalbooks.cpp index f84fb517b..a1d74fab6 100644 --- a/apps/openmw/mwgui/journalbooks.cpp +++ b/apps/openmw/mwgui/journalbooks.cpp @@ -2,13 +2,14 @@ #include +#include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" + +#include "textcolours.hpp" + + namespace { - MyGUI::Colour getTextColour (const std::string& type) - { - return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}")); - } - struct AddContent { MWGui::BookTypesetter::Ptr mTypesetter; @@ -31,12 +32,10 @@ namespace { MWGui::BookTypesetter::Style* style = mBodyStyle; - static const MyGUI::Colour linkHot (getTextColour("journal_link_over")); - static const MyGUI::Colour linkNormal (getTextColour("journal_link")); - static const MyGUI::Colour linkActive (getTextColour("journal_link_pressed")); - + const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); if (topicId) - style = mTypesetter->createHotStyle (mBodyStyle, linkNormal, linkHot, linkActive, topicId); + style = mTypesetter->createHotStyle (mBodyStyle, textColours.journalLink, textColours.journalLinkOver, + textColours.journalLinkPressed, topicId); mTypesetter->write (style, begin, end); } @@ -83,7 +82,7 @@ namespace AddEntry::operator () (entry); - mTypesetter->sectionBreak (10); + mTypesetter->sectionBreak (30); } }; @@ -108,7 +107,7 @@ namespace mTypesetter->selectContent (mContentId); mTypesetter->write (mBodyStyle, 2, 3);// end quote - mTypesetter->sectionBreak (10); + mTypesetter->sectionBreak (30); } }; @@ -122,7 +121,7 @@ namespace void operator () (MWGui::JournalViewModel::Utf8Span topicName) { mTypesetter->write (mBodyStyle, topicName); - mTypesetter->sectionBreak (10); + mTypesetter->sectionBreak (); } }; @@ -136,7 +135,7 @@ namespace void operator () (MWGui::JournalViewModel::Utf8Span topicName) { mTypesetter->write (mBodyStyle, topicName); - mTypesetter->sectionBreak (10); + mTypesetter->sectionBreak (); } }; } @@ -233,11 +232,10 @@ book JournalBooks::createTopicIndexBook () sprintf (buffer, "( %c )", ch); - MyGUI::Colour linkHot (getTextColour("journal_topic_over")); - MyGUI::Colour linkActive (getTextColour("journal_topic_pressed")); - MyGUI::Colour linkNormal (getTextColour("journal_topic")); - - BookTypesetter::Style* style = typesetter->createHotStyle (body, linkNormal, linkHot, linkActive, ch); + const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours(); + BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic, + textColours.journalTopicOver, + textColours.journalTopicPressed, ch); if (i == 13) typesetter->sectionBreak (); @@ -252,7 +250,7 @@ book JournalBooks::createTopicIndexBook () BookTypesetter::Ptr JournalBooks::createTypesetter () { //TODO: determine page size from layout... - return BookTypesetter::create (240, 300); + return BookTypesetter::create (240, 320); } } diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index 70f1305e0..b5d08eec6 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -2,12 +2,9 @@ #include #include -#include #include -#include - #include #include "../mwbase/world.hpp" @@ -15,7 +12,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwdialogue/journalentry.hpp" #include "../mwdialogue/keywordsearch.hpp" namespace MWGui { @@ -151,7 +147,7 @@ struct JournalViewModelImpl : JournalViewModel return toUtf8Span (utf8text); } - void visitSpans (boost::function < void (TopicId, size_t, size_t)> visitor) const + void visitSpans (std::function < void (TopicId, size_t, size_t)> visitor) const { ensureLoaded (); mModel->ensureKeyWordSearchLoaded (); @@ -195,7 +191,7 @@ struct JournalViewModelImpl : JournalViewModel }; - void visitQuestNames (bool active_only, boost::function visitor) const + void visitQuestNames (bool active_only, std::function visitor) const { MWBase::Journal * journal = MWBase::Environment::get ().getJournal (); @@ -270,7 +266,7 @@ struct JournalViewModelImpl : JournalViewModel } }; - void visitJournalEntries (const std::string& questName, boost::function visitor) const + void visitJournalEntries (const std::string& questName, std::function visitor) const { MWBase::Journal * journal = MWBase::Environment::get().getJournal(); @@ -303,13 +299,13 @@ struct JournalViewModelImpl : JournalViewModel } } - void visitTopicName (TopicId topicId, boost::function visitor) const + void visitTopicName (TopicId topicId, std::function visitor) const { MWDialogue::Topic const & topic = * reinterpret_cast (topicId); visitor (toUtf8Span (topic.getName())); } - void visitTopicNamesStartingWith (char character, boost::function < void (const std::string&) > visitor) const + void visitTopicNamesStartingWith (char character, std::function < void (const std::string&) > visitor) const { MWBase::Journal * journal = MWBase::Environment::get().getJournal(); @@ -343,7 +339,7 @@ struct JournalViewModelImpl : JournalViewModel }; - void visitTopicEntries (TopicId topicId, boost::function visitor) const + void visitTopicEntries (TopicId topicId, std::function visitor) const { typedef MWDialogue::Topic::TEntryIter iterator_t; @@ -356,7 +352,7 @@ struct JournalViewModelImpl : JournalViewModel JournalViewModel::Ptr JournalViewModel::create () { - return boost::make_shared (); + return std::make_shared (); } } diff --git a/apps/openmw/mwgui/journalviewmodel.hpp b/apps/openmw/mwgui/journalviewmodel.hpp index b3c6b0183..3edde3d31 100644 --- a/apps/openmw/mwgui/journalviewmodel.hpp +++ b/apps/openmw/mwgui/journalviewmodel.hpp @@ -5,8 +5,6 @@ #include #include #include -#include -#include namespace MWGui { @@ -18,7 +16,7 @@ namespace MWGui /// game data store. struct JournalViewModel { - typedef boost::shared_ptr Ptr; + typedef std::shared_ptr Ptr; typedef intptr_t QuestId; typedef intptr_t TopicId; @@ -38,7 +36,7 @@ namespace MWGui /// Visits each subset of text in the body, delivering the beginning /// and end of the span relative to the body, and a valid topic ID if /// the span represents a keyword, or zero if not. - virtual void visitSpans (boost::function visitor) const = 0; + virtual void visitSpans (std::function visitor) const = 0; }; /// An interface to topic data. @@ -68,20 +66,20 @@ namespace MWGui virtual bool isEmpty () const = 0; /// walks the active and optionally completed, quests providing the name and completed status - virtual void visitQuestNames (bool active_only, boost::function visitor) const = 0; + virtual void visitQuestNames (bool active_only, std::function visitor) const = 0; /// walks over the journal entries related to all quests with the given name /// If \a questName is empty, simply visits all journal entries - virtual void visitJournalEntries (const std::string& questName, boost::function visitor) const = 0; + virtual void visitJournalEntries (const std::string& questName, std::function visitor) const = 0; /// provides the name of the topic specified by its id - virtual void visitTopicName (TopicId topicId, boost::function visitor) const = 0; + virtual void visitTopicName (TopicId topicId, std::function visitor) const = 0; /// walks over the topics whose names start with the specified character providing the topics name - virtual void visitTopicNamesStartingWith (char character, boost::function < void (const std::string&) > visitor) const = 0; + virtual void visitTopicNamesStartingWith (char character, std::function < void (const std::string&) > visitor) const = 0; /// walks over the topic entries for the topic specified by its identifier - virtual void visitTopicEntries (TopicId topicId, boost::function visitor) const = 0; + virtual void visitTopicEntries (TopicId topicId, std::function visitor) const = 0; // create an instance of the default journal view model implementation static Ptr create (); diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 9af87c7ae..e96cc8b70 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -9,15 +9,11 @@ #include #include -#include -#include - #include #include #include #include "../mwbase/environment.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/journal.hpp" @@ -62,6 +58,7 @@ namespace Book mTopicIndexBook; bool mQuestMode; bool mOptionsMode; + bool mTopicsMode; bool mAllQuests; template @@ -124,7 +121,7 @@ namespace { MWGui::BookPage::ClickCallback callback; - callback = boost::bind (&JournalWindowImpl::notifyTopicClicked, this, _1); + callback = std::bind (&JournalWindowImpl::notifyTopicClicked, this, std::placeholders::_1); getPage (LeftBookPage)->adviseLinkClicked (callback); getPage (RightBookPage)->adviseLinkClicked (callback); @@ -136,7 +133,7 @@ namespace { MWGui::BookPage::ClickCallback callback; - callback = boost::bind (&JournalWindowImpl::notifyIndexLinkClicked, this, _1); + callback = std::bind(&JournalWindowImpl::notifyIndexLinkClicked, this, std::placeholders::_1); getPage (LeftTopicIndex)->adviseLinkClicked (callback); getPage (RightTopicIndex)->adviseLinkClicked (callback); @@ -190,16 +187,17 @@ namespace } adjustButton(TopicsBTN); - int width = getWidget(TopicsBTN)->getSize().width + getWidget(QuestsBTN)->getSize().width; int topicsWidth = getWidget(TopicsBTN)->getSize().width; - int pageWidth = getWidget(RightBookPage)->getSize().width; + int cancelLeft = getWidget(CancelBTN)->getPosition().left; + int cancelRight = getWidget(CancelBTN)->getPosition().left + getWidget(CancelBTN)->getSize().width; - getWidget(TopicsBTN)->setPosition((pageWidth - width)/2, getWidget(TopicsBTN)->getPosition().top); - getWidget(QuestsBTN)->setPosition((pageWidth - width)/2 + topicsWidth, getWidget(QuestsBTN)->getPosition().top); + getWidget(TopicsBTN)->setPosition(cancelLeft - topicsWidth, getWidget(TopicsBTN)->getPosition().top); + getWidget(QuestsBTN)->setPosition(cancelRight, getWidget(QuestsBTN)->getPosition().top); mQuestMode = false; mAllQuests = false; mOptionsMode = false; + mTopicsMode = false; } void adjustButton (char const * name) @@ -263,6 +261,7 @@ namespace void setBookMode () { mOptionsMode = false; + mTopicsMode = false; setVisible (OptionsBTN, true); setVisible (OptionsOverlay, false); @@ -273,6 +272,7 @@ namespace void setOptionsMode () { mOptionsMode = true; + mTopicsMode = false; setVisible (OptionsBTN, false); setVisible (OptionsOverlay, true); @@ -296,6 +296,8 @@ namespace // If in quest mode, ensure the quest list is updated if (mQuestMode) notifyQuests(getWidget(QuestsList)); + else + notifyTopics(getWidget(TopicsList)); } void pushBook (Book book, unsigned int page) @@ -374,6 +376,9 @@ namespace setVisible (JournalBTN, true); mOptionsMode = false; + mTopicsMode = false; + + MWBase::Environment::get().getWindowManager()->playSound("book page"); } void notifyTopicSelected (const std::string& topic, int id) @@ -403,6 +408,8 @@ namespace setVisible (JournalBTN, true); mOptionsMode = false; + + MWBase::Environment::get().getWindowManager()->playSound("book page"); } void notifyOptions(MyGUI::Widget* _sender) @@ -420,6 +427,8 @@ namespace { assert (mStates.size () > 1); popBook (); + + MWBase::Environment::get().getWindowManager()->playSound("book page"); } void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId character) @@ -428,6 +437,8 @@ namespace setVisible (RightTopicIndex, false); setVisible (TopicsList, true); + mTopicsMode = true; + Gui::MWList* list = getWidget(TopicsList); list->clear(); @@ -436,17 +447,22 @@ namespace mModel->visitTopicNamesStartingWith((char) character, add); list->adjustSize(); + + MWBase::Environment::get().getWindowManager()->playSound("book page"); } void notifyTopics(MyGUI::Widget* _sender) { mQuestMode = false; + mTopicsMode = false; setVisible (LeftTopicIndex, true); setVisible (RightTopicIndex, true); setVisible (TopicsList, false); setVisible (QuestsList, false); setVisible (ShowAllBTN, false); setVisible (ShowActiveBTN, false); + + MWBase::Environment::get().getWindowManager()->playSound("book page"); } struct AddNamesToList @@ -498,6 +514,8 @@ namespace SetNamesInactive setInactive(list); mModel->visitQuestNames(!mAllQuests, setInactive); } + + MWBase::Environment::get().getWindowManager()->playSound("book page"); } void notifyShowAll(MyGUI::Widget* _sender) @@ -514,13 +532,23 @@ namespace void notifyCancel(MyGUI::Widget* _sender) { - setBookMode (); + if (mTopicsMode) + { + notifyTopics(_sender); + } + else + { + setBookMode(); + MWBase::Environment::get().getWindowManager()->playSound("book page"); + } + } void notifyClose(MyGUI::Widget* _sender) { - MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); - MWBase::Environment::get().getWindowManager ()->popGuiMode (); + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); + winMgr->playSound("book close"); + winMgr->popGuiMode(); } void notifyMouseWheel(MyGUI::Widget* sender, int rel) @@ -542,6 +570,8 @@ namespace if (page+2 < book->pageCount()) { + MWBase::Environment::get().getWindowManager()->playSound("book page"); + page += 2; updateShowingPages (); } @@ -558,6 +588,8 @@ namespace if(page >= 2) { + MWBase::Environment::get().getWindowManager()->playSound("book page"); + page -= 2; updateShowingPages (); } diff --git a/apps/openmw/mwgui/journalwindow.hpp b/apps/openmw/mwgui/journalwindow.hpp index 740284e20..cc645ca44 100644 --- a/apps/openmw/mwgui/journalwindow.hpp +++ b/apps/openmw/mwgui/journalwindow.hpp @@ -1,7 +1,7 @@ #ifndef MWGUI_JOURNAL_H #define MWGUI_JOURNAL_H -#include +#include namespace MWBase { class WindowManager; } @@ -12,7 +12,7 @@ namespace MWGui struct JournalWindow { /// construct a new instance of the one JournalWindow implementation - static JournalWindow * create (boost::shared_ptr Model, bool questList); + static JournalWindow * create (std::shared_ptr Model, bool questList); /// destroy this instance of the JournalWindow implementation virtual ~JournalWindow () {}; diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 1434455b2..362ad3b1c 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -89,7 +89,7 @@ namespace MWGui void LevelupDialog::resetCoins() { - const int coinSpacing = 10; + const int coinSpacing = 33; int curX = mCoinBox->getWidth()/2 - (coinSpacing*(mCoinCount - 1) + 16*mCoinCount)/2; for (unsigned int i=0; i mTexture; - std::auto_ptr mGuiTexture; + std::unique_ptr mGuiTexture; void changeWallpaper(); diff --git a/apps/openmw/mwgui/mainmenu.cpp b/apps/openmw/mwgui/mainmenu.cpp index 258f0dfb0..5a435b9cf 100644 --- a/apps/openmw/mwgui/mainmenu.cpp +++ b/apps/openmw/mwgui/mainmenu.cpp @@ -10,7 +10,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/statemanager.hpp" @@ -76,23 +75,25 @@ namespace MWGui void MainMenu::onButtonClicked(MyGUI::Widget *sender) { + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); + std::string name = *sender->getUserData(); - MWBase::Environment::get().getSoundManager()->playSound("Menu Click", 1.f, 1.f); + winMgr->playSound("Menu Click"); if (name == "return") { - MWBase::Environment::get().getWindowManager ()->removeGuiMode (GM_MainMenu); + winMgr->removeGuiMode (GM_MainMenu); } else if (name == "options") - MWBase::Environment::get().getWindowManager ()->pushGuiMode (GM_Settings); + winMgr->pushGuiMode (GM_Settings); else if (name == "credits") - MWBase::Environment::get().getWindowManager()->playVideo("mw_credits.bik", true); + winMgr->playVideo("mw_credits.bik", true); else if (name == "exitgame") { if (MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame) onExitConfirmed(); else { - ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog(); + ConfirmationDialog* dialog = winMgr->getConfirmationDialog(); dialog->askForConfirmation("#{sMessage2}"); dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &MainMenu::onExitConfirmed); @@ -105,7 +106,7 @@ namespace MWGui onNewGameConfirmed(); else { - ConfirmationDialog* dialog = MWBase::Environment::get().getWindowManager()->getConfirmationDialog(); + ConfirmationDialog* dialog = winMgr->getConfirmationDialog(); dialog->askForConfirmation("#{sNotifyMessage54}"); dialog->eventOkClicked.clear(); dialog->eventOkClicked += MyGUI::newDelegate(this, &MainMenu::onNewGameConfirmed); diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 5c7e73862..7d81b6ab3 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -252,7 +252,7 @@ namespace MWGui osg::ref_ptr tex = mLocalMapRender->getFogOfWarTexture(x, y); if (tex) { - boost::shared_ptr myguitex (new osgMyGUI::OSGTexture(tex)); + std::shared_ptr myguitex (new osgMyGUI::OSGTexture(tex)); fog->setRenderItemTexture(myguitex.get()); fog->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f)); fogTextures.push_back(myguitex); @@ -382,7 +382,7 @@ namespace MWGui osg::ref_ptr texture = mLocalMapRender->getMapTexture(mapX, mapY); if (texture) { - boost::shared_ptr guiTex (new osgMyGUI::OSGTexture(texture)); + std::shared_ptr guiTex (new osgMyGUI::OSGTexture(texture)); textures.push_back(guiTex); box->setRenderItemTexture(guiTex.get()); box->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f)); @@ -629,7 +629,7 @@ namespace MWGui , mGlobalMap(0) , mGlobalMapImage(NULL) , mGlobalMapOverlay(NULL) - , mGlobal(false) + , mGlobal(Settings::Manager::getBool("global", "Map")) , mEventBoxGlobal(NULL) , mEventBoxLocal(NULL) , mGlobalMapRender(new MWRender::GlobalMap(localMapRender->getRoot(), workQueue)) @@ -667,7 +667,7 @@ namespace MWGui getWidget(mButton, "WorldButton"); mButton->eventMouseButtonClick += MyGUI::newDelegate(this, &MapWindow::onWorldButtonClicked); - mButton->setCaptionWithReplacing("#{sWorld}"); + mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}"); getWidget(mEventBoxGlobal, "EventBoxGlobal"); mEventBoxGlobal->eventMouseDrag += MyGUI::newDelegate(this, &MapWindow::onMouseDrag); @@ -680,6 +680,9 @@ namespace MWGui mEventBoxLocal->eventMouseButtonDoubleClick += MyGUI::newDelegate(this, &MapWindow::onMapDoubleClicked); LocalMapBase::init(mLocalMap, mPlayerArrowLocal, Settings::Manager::getInt("local map widget size", "Map"), Settings::Manager::getInt("local map cell distance", "Map")); + + mGlobalMap->setVisible(mGlobal); + mLocalMap->setVisible(!mGlobal); } void MapWindow::onNoteEditOk() @@ -777,7 +780,7 @@ namespace MWGui void MapWindow::setVisible(bool visible) { WindowBase::setVisible(visible); - mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->isGuiMode()); + mButton->setVisible(visible && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_None); } void MapWindow::renderGlobalMap() @@ -918,6 +921,8 @@ namespace MWGui mGlobalMap->setVisible(mGlobal); mLocalMap->setVisible(!mGlobal); + Settings::Manager::setBool("global", "Map", mGlobal); + mButton->setCaptionWithReplacing( mGlobal ? "#{sLocal}" : "#{sWorld}"); @@ -927,6 +932,8 @@ namespace MWGui void MapWindow::onPinToggled() { + Settings::Manager::setBool("map pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setMinimapVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/mapwindow.hpp b/apps/openmw/mwgui/mapwindow.hpp index 4e648c4b7..312447a24 100644 --- a/apps/openmw/mwgui/mapwindow.hpp +++ b/apps/openmw/mwgui/mapwindow.hpp @@ -3,8 +3,6 @@ #include -#include - #include "windowpinnablebase.hpp" #include @@ -130,7 +128,7 @@ namespace MWGui std::vector mMapWidgets; std::vector mFogWidgets; - typedef std::vector > TextureVector; + typedef std::vector > TextureVector; TextureVector mMapTextures; TextureVector mFogTextures; @@ -247,8 +245,8 @@ namespace MWGui void setGlobalMapMarkerTooltip(MyGUI::Widget* widget, int x, int y); MyGUI::ScrollView* mGlobalMap; - std::auto_ptr mGlobalMapTexture; - std::auto_ptr mGlobalMapOverlayTexture; + std::unique_ptr mGlobalMapTexture; + std::unique_ptr mGlobalMapOverlayTexture; MyGUI::ImageBox* mGlobalMapImage; MyGUI::ImageBox* mGlobalMapOverlay; MyGUI::ImageBox* mPlayerArrowLocal; diff --git a/apps/openmw/mwgui/merchantrepair.cpp b/apps/openmw/mwgui/merchantrepair.cpp index c4639d602..9e27c0154 100644 --- a/apps/openmw/mwgui/merchantrepair.cpp +++ b/apps/openmw/mwgui/merchantrepair.cpp @@ -10,7 +10,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/actorutil.hpp" @@ -21,6 +20,7 @@ namespace MWGui { +const int MerchantRepair::sLineHeight = 18; MerchantRepair::MerchantRepair() : WindowBase("openmw_merchantrepair.layout") @@ -79,16 +79,16 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor) 0, currentY, 0, - 18, + sLineHeight, MyGUI::Align::Default ); - currentY += 18; + currentY += sLineHeight; button->setUserString("Price", MyGUI::utility::toString(price)); button->setUserData(MWWorld::Ptr(*iter)); button->setCaptionWithReplacing(name); - button->setSize(button->getTextSize().width,18); + button->setSize(mList->getWidth(),sLineHeight); button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel); button->setUserString("ToolTipType", "ItemPtr"); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick); @@ -137,8 +137,7 @@ void MerchantRepair::onRepairButtonClick(MyGUI::Widget *sender) player.getClass().getContainerStore(player).restack(item); - MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1); - + MWBase::Environment::get().getWindowManager()->playSound("Repair"); player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player); diff --git a/apps/openmw/mwgui/merchantrepair.hpp b/apps/openmw/mwgui/merchantrepair.hpp index 231d11089..8dcdfee12 100644 --- a/apps/openmw/mwgui/merchantrepair.hpp +++ b/apps/openmw/mwgui/merchantrepair.hpp @@ -30,6 +30,7 @@ protected: void onRepairButtonClick(MyGUI::Widget* sender); void onOkButtonClick(MyGUI::Widget* sender); + static const int sLineHeight; }; } diff --git a/apps/openmw/mwgui/messagebox.cpp b/apps/openmw/mwgui/messagebox.cpp index f8ddeba3e..ab43df0f1 100644 --- a/apps/openmw/mwgui/messagebox.cpp +++ b/apps/openmw/mwgui/messagebox.cpp @@ -196,7 +196,7 @@ namespace MWGui InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message, const std::vector& buttons) - : WindowModal("openmw_interactive_messagebox.layout") + : WindowModal(MWBase::Environment::get().getWindowManager()->isGuiMode() ? "openmw_interactive_messagebox_notransp.layout" : "openmw_interactive_messagebox.layout") , mMessageBoxManager(parMessageBoxManager) , mButtonPressed(-1) { diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index 63cc14d98..619540cff 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -370,7 +370,8 @@ namespace MWGui mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(mParent, &QuickKeysMenu::onCancelButtonClicked); - int maxWidth = mItemButton->getTextSize ().width + 24; + int maxWidth = mLabel->getTextSize ().width + 24; + maxWidth = std::max(maxWidth, mItemButton->getTextSize ().width + 24); maxWidth = std::max(maxWidth, mMagicButton->getTextSize ().width + 24); maxWidth = std::max(maxWidth, mUnassignButton->getTextSize ().width + 24); maxWidth = std::max(maxWidth, mCancelButton->getTextSize ().width + 24); diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 184ce0775..047f65263 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -2,13 +2,10 @@ #include #include -#include #include #include -#include - #include #include "../mwworld/esmstore.hpp" @@ -146,6 +143,7 @@ namespace MWGui const ESM::NPC& proto = mPreview->getPrototype(); setRaceId(proto.mRace); + setGender(proto.isMale() ? GM_Male : GM_Female); recountParts(); for (unsigned int i=0; i namespace MWGui @@ -115,8 +116,8 @@ namespace MWGui float mCurrentAngle; - std::auto_ptr mPreview; - std::auto_ptr mPreviewTexture; + std::unique_ptr mPreview; + std::unique_ptr mPreviewTexture; bool mPreviewDirty; }; diff --git a/apps/openmw/mwgui/recharge.cpp b/apps/openmw/mwgui/recharge.cpp index afca12ad9..390a1f83c 100644 --- a/apps/openmw/mwgui/recharge.cpp +++ b/apps/openmw/mwgui/recharge.cpp @@ -12,7 +12,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" @@ -33,6 +32,7 @@ namespace MWGui Recharge::Recharge() : WindowBase("openmw_recharge_dialog.layout") + , mItemSelectionDialog(NULL) { getWidget(mBox, "Box"); getWidget(mGemBox, "GemBox"); @@ -45,6 +45,8 @@ Recharge::Recharge() mBox->setDisplayMode(ItemChargeView::DisplayMode_EnchantmentCharge); + mGemIcon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onSelectItem); + setVisible(false); } @@ -87,6 +89,12 @@ void Recharge::updateView() mGemBox->setVisible(toolBoxVisible); mGemBox->setUserString("Hidden", toolBoxVisible ? "false" : "true"); + if (!toolBoxVisible) + { + mGemIcon->setItem(MWWorld::Ptr()); + mGemIcon->clearUserStrings(); + } + mBox->update(); Gui::Box* box = dynamic_cast(mMainWidget); @@ -102,6 +110,34 @@ void Recharge::onCancel(MyGUI::Widget *sender) exit(); } +void Recharge::onSelectItem(MyGUI::Widget *sender) +{ + delete mItemSelectionDialog; + mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}"); + mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Recharge::onItemSelected); + mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Recharge::onItemCancel); + mItemSelectionDialog->setVisible(true); + mItemSelectionDialog->openContainer(MWMechanics::getPlayer()); + mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyChargedSoulstones); +} + +void Recharge::onItemSelected(MWWorld::Ptr item) +{ + mItemSelectionDialog->setVisible(false); + + mGemIcon->setItem(item); + mGemIcon->setUserString ("ToolTipType", "ItemPtr"); + mGemIcon->setUserData(item); + + MWBase::Environment::get().getWindowManager()->playSound(item.getClass().getDownSoundId(item)); + updateView(); +} + +void Recharge::onItemCancel() +{ + mItemSelectionDialog->setVisible(false); +} + void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item) { MWWorld::Ptr gem = *mGemIcon->getUserData(); @@ -138,7 +174,7 @@ void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item) item.getCellRef().setEnchantmentCharge( std::min(item.getCellRef().getEnchantmentCharge() + restored, static_cast(enchantment->mData.mCharge))); - MWBase::Environment::get().getSoundManager()->playSound("Enchant Success",1,1); + MWBase::Environment::get().getWindowManager()->playSound("Enchant Success"); player.getClass().getContainerStore(player).restack(item); @@ -146,7 +182,7 @@ void Recharge::onItemClicked(MyGUI::Widget *sender, const MWWorld::Ptr& item) } else { - MWBase::Environment::get().getSoundManager()->playSound("Enchant Fail",1,1); + MWBase::Environment::get().getWindowManager()->playSound("Enchant Fail"); } gem.getContainerStore()->remove(gem, 1, player); diff --git a/apps/openmw/mwgui/recharge.hpp b/apps/openmw/mwgui/recharge.hpp index bbcf994dd..cc3db14df 100644 --- a/apps/openmw/mwgui/recharge.hpp +++ b/apps/openmw/mwgui/recharge.hpp @@ -3,6 +3,8 @@ #include "windowbase.hpp" +#include "itemselection.hpp" + namespace MWWorld { class Ptr; @@ -11,6 +13,7 @@ namespace MWWorld namespace MWGui { +class ItemSelectionDialog; class ItemWidget; class ItemChargeView; @@ -32,12 +35,19 @@ protected: ItemWidget* mGemIcon; + ItemSelectionDialog* mItemSelectionDialog; + MyGUI::TextBox* mChargeLabel; MyGUI::Button* mCancelButton; void updateView(); + void onSelectItem(MyGUI::Widget* sender); + + void onItemSelected(MWWorld::Ptr item); + void onItemCancel(); + void onItemClicked (MyGUI::Widget* sender, const MWWorld::Ptr& item); void onCancel (MyGUI::Widget* sender); void onMouseWheel(MyGUI::Widget* _sender, int _rel); diff --git a/apps/openmw/mwgui/referenceinterface.cpp b/apps/openmw/mwgui/referenceinterface.cpp index 76bb4f53f..9aaa98f19 100644 --- a/apps/openmw/mwgui/referenceinterface.cpp +++ b/apps/openmw/mwgui/referenceinterface.cpp @@ -20,9 +20,8 @@ namespace MWGui { MWWorld::CellStore* playerCell = MWMechanics::getPlayer().getCell(); - // check if player has changed cell, or count of the reference has become 0 - if ((playerCell != mCurrentPlayerCell && mCurrentPlayerCell != NULL) - || (!mPtr.isEmpty() && mPtr.getRefData().getCount() == 0)) + // check if count of the reference has become 0 + if (!mPtr.isEmpty() && mPtr.getRefData().getCount() == 0) { if (!mPtr.isEmpty()) { diff --git a/apps/openmw/mwgui/repair.cpp b/apps/openmw/mwgui/repair.cpp index 3acea985b..4d6441450 100644 --- a/apps/openmw/mwgui/repair.cpp +++ b/apps/openmw/mwgui/repair.cpp @@ -11,7 +11,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwmechanics/actorutil.hpp" @@ -30,6 +29,7 @@ namespace MWGui Repair::Repair() : WindowBase("openmw_repair.layout") + , mItemSelectionDialog(NULL) { getWidget(mRepairBox, "RepairBox"); getWidget(mToolBox, "ToolBox"); @@ -39,9 +39,11 @@ Repair::Repair() getWidget(mCancelButton, "CancelButton"); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onCancel); - mRepairBox->eventItemClicked += MyGUI::newDelegate(this, &Repair::onRepairItem); + mRepairBox->eventItemClicked += MyGUI::newDelegate(this, &Repair::onRepairItem); mRepairBox->setDisplayMode(ItemChargeView::DisplayMode_Health); + + mToolIcon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onSelectItem); } void Repair::open() @@ -63,7 +65,7 @@ void Repair::exit() void Repair::startRepairItem(const MWWorld::Ptr &item) { - MWBase::Environment::get().getSoundManager()->playSound("Item Repair Up",1,1); + MWBase::Environment::get().getWindowManager()->playSound("Item Repair Up"); mRepair.setTool(item); @@ -83,6 +85,8 @@ void Repair::updateRepairView() float quality = ref->mBase->mData.mQuality; + mToolIcon->setUserData(mRepair.getTool()); + std::stringstream qualityStr; qualityStr << std::setprecision(3) << quality; @@ -93,6 +97,12 @@ void Repair::updateRepairView() mToolBox->setVisible(toolBoxVisible); mToolBox->setUserString("Hidden", toolBoxVisible ? "false" : "true"); + if (!toolBoxVisible) + { + mToolIcon->setItem(MWWorld::Ptr()); + mToolIcon->clearUserStrings(); + } + mRepairBox->update(); Gui::Box* box = dynamic_cast(mMainWidget); @@ -103,6 +113,36 @@ void Repair::updateRepairView() center(); } +void Repair::onSelectItem(MyGUI::Widget *sender) +{ + delete mItemSelectionDialog; + mItemSelectionDialog = new ItemSelectionDialog("#{sRepair}"); + mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &Repair::onItemSelected); + mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &Repair::onItemCancel); + mItemSelectionDialog->setVisible(true); + mItemSelectionDialog->openContainer(MWMechanics::getPlayer()); + mItemSelectionDialog->setFilter(SortFilterItemModel::Filter_OnlyRepairTools); +} + +void Repair::onItemSelected(MWWorld::Ptr item) +{ + mItemSelectionDialog->setVisible(false); + + mToolIcon->setItem(item); + mToolIcon->setUserString ("ToolTipType", "ItemPtr"); + mToolIcon->setUserData(item); + + mRepair.setTool(item); + + MWBase::Environment::get().getWindowManager()->playSound(item.getClass().getDownSoundId(item)); + updateRepairView(); +} + +void Repair::onItemCancel() +{ + mItemSelectionDialog->setVisible(false); +} + void Repair::onCancel(MyGUI::Widget* /*sender*/) { exit(); diff --git a/apps/openmw/mwgui/repair.hpp b/apps/openmw/mwgui/repair.hpp index 8746f7dc4..c50ba861a 100644 --- a/apps/openmw/mwgui/repair.hpp +++ b/apps/openmw/mwgui/repair.hpp @@ -3,11 +3,14 @@ #include "windowbase.hpp" +#include "itemselection.hpp" + #include "../mwmechanics/repair.hpp" namespace MWGui { +class ItemSelectionDialog; class ItemWidget; class ItemChargeView; @@ -29,6 +32,8 @@ protected: ItemWidget* mToolIcon; + ItemSelectionDialog* mItemSelectionDialog; + MyGUI::TextBox* mUsesLabel; MyGUI::TextBox* mQualityLabel; @@ -38,6 +43,11 @@ protected: void updateRepairView(); + void onSelectItem(MyGUI::Widget* sender); + + void onItemSelected(MWWorld::Ptr item); + void onItemCancel(); + void onRepairItem(MyGUI::Widget* sender, const MWWorld::Ptr& ptr); void onCancel(MyGUI::Widget* sender); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index d2971a093..1a680b801 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -160,22 +160,31 @@ namespace MWGui void ReviewDialog::setHealth(const MWMechanics::DynamicStat& value) { - mHealth->setValue(static_cast(value.getCurrent()), static_cast(value.getModified())); - std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified()); + int current = std::max(0, static_cast(value.getCurrent())); + int modified = static_cast(value.getModified()); + + mHealth->setValue(current, modified); + std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); mHealth->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr); } void ReviewDialog::setMagicka(const MWMechanics::DynamicStat& value) { - mMagicka->setValue(static_cast(value.getCurrent()), static_cast(value.getModified())); - std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified()); + int current = std::max(0, static_cast(value.getCurrent())); + int modified = static_cast(value.getModified()); + + mMagicka->setValue(current, modified); + std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); mMagicka->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr); } void ReviewDialog::setFatigue(const MWMechanics::DynamicStat& value) { - mFatigue->setValue(static_cast(value.getCurrent()), static_cast(value.getModified())); - std::string valStr = MyGUI::utility::toString(value.getCurrent()) + "/" + MyGUI::utility::toString(value.getModified()); + int current = std::max(0, static_cast(value.getCurrent())); + int modified = static_cast(value.getModified()); + + mFatigue->setValue(current, modified); + std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); mFatigue->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr); } diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index cbc95e808..84d4ca959 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -168,9 +169,9 @@ namespace MWGui className = "?"; // From an older savegame format that did not support custom classes properly. } - title << " (Level " << it->getSignature().mPlayerLevel << " " << className << ")"; + title << " (#{sLevel} " << it->getSignature().mPlayerLevel << " " << MyGUI::TextIterator::toTagsString(className) << ")"; - mCharacterSelection->addItem (title.str()); + mCharacterSelection->addItem (MyGUI::LanguageManager::getInstance().replaceTags(title.str())); if (mCurrentCharacter == &*it || (!mCurrentCharacter && !mSaving && directory==Misc::StringUtils::lowerCase ( diff --git a/apps/openmw/mwgui/savegamedialog.hpp b/apps/openmw/mwgui/savegamedialog.hpp index 6a9e59cc6..be0e47cab 100644 --- a/apps/openmw/mwgui/savegamedialog.hpp +++ b/apps/openmw/mwgui/savegamedialog.hpp @@ -48,7 +48,7 @@ namespace MWGui void fillSaveList(); - std::auto_ptr mScreenshotTexture; + std::unique_ptr mScreenshotTexture; MyGUI::ImageBox* mScreenshot; bool mSaving; diff --git a/apps/openmw/mwgui/screenfader.hpp b/apps/openmw/mwgui/screenfader.hpp index f87fd8443..b510e133a 100644 --- a/apps/openmw/mwgui/screenfader.hpp +++ b/apps/openmw/mwgui/screenfader.hpp @@ -3,8 +3,6 @@ #include -#include - #include "windowbase.hpp" namespace MWGui @@ -14,7 +12,7 @@ namespace MWGui class FadeOp { public: - typedef boost::shared_ptr Ptr; + typedef std::shared_ptr Ptr; FadeOp(ScreenFader * fader, float time, float targetAlpha); diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index ccc07174d..a5d4c3324 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -7,7 +7,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwmechanics/actorutil.hpp" @@ -53,7 +52,7 @@ namespace MWGui void ScrollWindow::openScroll (MWWorld::Ptr scroll, bool showTakeButton) { // no 3d sounds because the object could be in a container. - MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("scroll"); mScroll = scroll; @@ -78,7 +77,7 @@ namespace MWGui void ScrollWindow::exit() { - MWBase::Environment::get().getSoundManager()->playSound ("scroll", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("scroll"); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Scroll); } @@ -102,7 +101,7 @@ namespace MWGui void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender) { - MWBase::Environment::get().getSoundManager()->playSound("Item Book Up", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("Item Book Up"); MWWorld::ActionTake take(mScroll); take.execute (MWMechanics::getPlayer()); diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index c167164d9..f46199c80 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -3,17 +3,15 @@ #include #include #include -#include #include #include #include #include -#include +#include #include -#include #include #include diff --git a/apps/openmw/mwgui/sortfilteritemmodel.cpp b/apps/openmw/mwgui/sortfilteritemmodel.cpp index 09438b950..68d95fb88 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.cpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.cpp @@ -129,6 +129,8 @@ namespace MWGui if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name() || base.getCellRef().getSoul() == "")) return false; + if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name())) + return false; if ((mFilter & Filter_OnlyEnchantable) && (item.mFlags & ItemStack::Flag_Enchanted || (base.getTypeName() != typeid(ESM::Armor).name() && base.getTypeName() != typeid(ESM::Clothing).name() @@ -141,7 +143,7 @@ namespace MWGui if ((mFilter & Filter_OnlyUsableItems) && base.getClass().getScript(base).empty()) { - boost::shared_ptr actionOnUse = base.getClass().use(base); + std::shared_ptr actionOnUse = base.getClass().use(base); if (!actionOnUse || actionOnUse->isNullAction()) return false; } diff --git a/apps/openmw/mwgui/sortfilteritemmodel.hpp b/apps/openmw/mwgui/sortfilteritemmodel.hpp index 3d5396e2a..4731cbb8a 100644 --- a/apps/openmw/mwgui/sortfilteritemmodel.hpp +++ b/apps/openmw/mwgui/sortfilteritemmodel.hpp @@ -41,6 +41,7 @@ namespace MWGui static const int Filter_OnlyUsableItems = (1<<4); // Only items with a Use action static const int Filter_OnlyRepairable = (1<<5); static const int Filter_OnlyRechargable = (1<<6); + static const int Filter_OnlyRepairTools = (1<<7); private: diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index 843731cff..6a7376aa0 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -6,7 +6,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -23,11 +22,8 @@ namespace MWGui SpellBuyingWindow::SpellBuyingWindow() : WindowBase("openmw_spell_buying_window.layout") - , mLastPos(0) , mCurrentY(0) { - setCoord(0, 0, 450, 300); - getWidget(mCancelButton, "CancelButton"); getWidget(mPlayerGold, "PlayerGold"); getWidget(mSpellsView, "SpellsView"); @@ -40,13 +36,20 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_SpellBuying); } - void SpellBuyingWindow::addSpell(const std::string& spellId) + bool SpellBuyingWindow::sortSpells (const ESM::Spell* left, const ESM::Spell* right) + { + std::string leftName = Misc::StringUtils::lowerCase(left->mName); + std::string rightName = Misc::StringUtils::lowerCase(right->mName); + + return leftName.compare(rightName) < 0; + } + + void SpellBuyingWindow::addSpell(const ESM::Spell& spell) { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(spellId); - int price = static_cast(spell->mData.mCost*store.get().find("fSpellValueMult")->getFloat()); + int price = static_cast(spell.mData.mCost*store.get().find("fSpellValueMult")->getFloat()); price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); MWWorld::Ptr player = MWMechanics::getPlayer(); @@ -67,13 +70,13 @@ namespace MWGui mCurrentY += sLineHeight; toAdd->setUserData(price); - toAdd->setCaptionWithReplacing(spell->mName+" - "+MyGUI::utility::toString(price)+"#{sgp}"); - toAdd->setSize(toAdd->getTextSize().width,sLineHeight); + toAdd->setCaptionWithReplacing(spell.mName+" - "+MyGUI::utility::toString(price)+"#{sgp}"); + toAdd->setSize(mSpellsView->getWidth(),sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->setUserString("ToolTipType", "Spell"); - toAdd->setUserString("Spell", spellId); + toAdd->setUserString("Spell", spell.mId); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellBuyingWindow::onSpellButtonClick); - mSpellsWidgetMap.insert(std::make_pair (toAdd, spellId)); + mSpellsWidgetMap.insert(std::make_pair (toAdd, spell.mId)); } void SpellBuyingWindow::clearSpells() @@ -85,7 +88,7 @@ namespace MWGui mSpellsWidgetMap.clear(); } - void SpellBuyingWindow::startSpellBuying(const MWWorld::Ptr& actor) + void SpellBuyingWindow::startSpellBuying(const MWWorld::Ptr& actor, int startOffset) { center(); mPtr = actor; @@ -93,6 +96,8 @@ namespace MWGui MWMechanics::Spells& merchantSpells = actor.getClass().getCreatureStats (actor).getSpells(); + std::vector spellsToSort; + for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) { const ESM::Spell* spell = iter->first; @@ -112,15 +117,25 @@ namespace MWGui if (playerHasSpell(iter->first->mId)) continue; - addSpell (iter->first->mId); + spellsToSort.push_back(iter->first); } + std::stable_sort(spellsToSort.begin(), spellsToSort.end(), sortSpells); + + for (std::vector::iterator it = spellsToSort.begin() ; it != spellsToSort.end(); ++it) + { + addSpell(**it); + } + + spellsToSort.clear(); + updateLabels(); // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mSpellsView->setVisibleVScroll(false); mSpellsView->setCanvasSize (MyGUI::IntSize(mSpellsView->getWidth(), std::max(mSpellsView->getHeight(), mCurrentY))); mSpellsView->setVisibleVScroll(true); + mSpellsView->setViewOffset(MyGUI::IntPoint(0, startOffset)); } bool SpellBuyingWindow::playerHasSpell(const std::string &id) @@ -146,9 +161,9 @@ namespace MWGui MWMechanics::CreatureStats& npcStats = mPtr.getClass().getCreatureStats(mPtr); npcStats.setGoldPool(npcStats.getGoldPool() + price); - startSpellBuying(mPtr); + startSpellBuying(mPtr, mSpellsView->getViewOffset().top); - MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound("Item Gold Up"); } void SpellBuyingWindow::onCancelButtonClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/spellbuyingwindow.hpp b/apps/openmw/mwgui/spellbuyingwindow.hpp index 2a6dcfdcc..37210819f 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.hpp +++ b/apps/openmw/mwgui/spellbuyingwindow.hpp @@ -4,6 +4,8 @@ #include "windowbase.hpp" #include "referenceinterface.hpp" +#include "../mwworld/esmstore.hpp" + namespace MyGUI { class Gui; @@ -23,7 +25,7 @@ namespace MWGui public: SpellBuyingWindow(); - void startSpellBuying(const MWWorld::Ptr& actor); + void startSpellBuying(const MWWorld::Ptr& actor, int startOffset); virtual void exit(); @@ -38,7 +40,7 @@ namespace MWGui void onCancelButtonClicked(MyGUI::Widget* _sender); void onSpellButtonClick(MyGUI::Widget* _sender); void onMouseWheel(MyGUI::Widget* _sender, int _rel); - void addSpell(const std::string& spellID); + void addSpell(const ESM::Spell& spell); void clearSpells(); int mLastPos,mCurrentY; @@ -49,6 +51,9 @@ namespace MWGui virtual void onReferenceUnavailable(); bool playerHasSpell (const std::string& id); + + private: + static bool sortSpells (const ESM::Spell* left, const ESM::Spell* right); }; } diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 64d4d86c6..354253fa4 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -7,7 +7,6 @@ #include #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -171,11 +170,20 @@ namespace MWGui mAreaSlider->setScrollPosition (effect.mArea); mDurationSlider->setScrollPosition (effect.mDuration-1); + if (mEffect.mRange == ESM::RT_Self) + mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}"); + else if (mEffect.mRange == ESM::RT_Target) + mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}"); + else if (mEffect.mRange == ESM::RT_Touch) + mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}"); + onMagnitudeMinChanged (mMagnitudeMinSlider, effect.mMagnMin-1); onMagnitudeMaxChanged (mMagnitudeMinSlider, effect.mMagnMax-1); onAreaChanged (mAreaSlider, effect.mArea); onDurationChanged (mDurationSlider, effect.mDuration-1); eventEffectModified(mEffect); + + updateBoxes(); } void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect) @@ -396,7 +404,7 @@ namespace MWGui MWMechanics::CreatureStats& npcStats = mPtr.getClass().getCreatureStats(mPtr); npcStats.setGoldPool(npcStats.getGoldPool() + price); - MWBase::Environment::get().getSoundManager()->playSound ("Mysticism Hit", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound ("Mysticism Hit"); const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell); @@ -440,22 +448,11 @@ namespace MWGui for (std::vector::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { - float x = 0.5f * (it->mMagnMin + it->mMagnMax); - - const ESM::MagicEffect* effect = - store.get().find(it->mEffectID); + const ESM::ENAMstruct& effect = *it; - x *= 0.1f * effect->mData.mBaseCost; - x *= 1 + it->mDuration; - x += 0.05f * std::max(1, it->mArea) * effect->mData.mBaseCost; + y += std::max(1.f, MWMechanics::calcEffectCost(effect)); - float fEffectCostMult = - store.get().find("fEffectCostMult")->getFloat(); - - y += x * fEffectCostMult; - y = std::max(1.f,y); - - if (it->mRange == ESM::RT_Target) + if (effect.mRange == ESM::RT_Target) y *= 1.5; } @@ -475,8 +472,10 @@ namespace MWGui mPriceLabel->setCaption(MyGUI::utility::toString(int(price))); - float chance = MWMechanics::getSpellSuccessChance(&mSpell, MWMechanics::getPlayer()); - mSuccessChance->setCaption(MyGUI::utility::toString(int(chance))); + float chance = MWMechanics::calcSpellBaseSuccessChance(&mSpell, MWMechanics::getPlayer(), NULL); + + int intChance = std::min(100, int(chance)); + mSuccessChance->setCaption(MyGUI::utility::toString(intChance)); } // ------------------------------------------------------------------------------------------------ diff --git a/apps/openmw/mwgui/spellmodel.cpp b/apps/openmw/mwgui/spellmodel.cpp index d4ab552ff..6953d682b 100644 --- a/apps/openmw/mwgui/spellmodel.cpp +++ b/apps/openmw/mwgui/spellmodel.cpp @@ -2,8 +2,6 @@ #include -#include - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -61,8 +59,8 @@ namespace MWGui if (spell->mData.mType == ESM::Spell::ST_Spell) { newSpell.mType = Spell::Type_Spell; - std::string cost = boost::lexical_cast(spell->mData.mCost); - std::string chance = boost::lexical_cast(int(MWMechanics::getSpellSuccessChance(spell, mActor))); + std::string cost = std::to_string(spell->mData.mCost); + std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor))); newSpell.mCostColumn = cost + "/" + chance; } else @@ -112,11 +110,11 @@ namespace MWGui int castCost = MWMechanics::getEffectiveEnchantmentCastCost(static_cast(enchant->mData.mCost), mActor); - std::string cost = boost::lexical_cast(castCost); + std::string cost = std::to_string(castCost); int currentCharge = int(item.getCellRef().getEnchantmentCharge()); if (currentCharge == -1) currentCharge = enchant->mData.mCharge; - std::string charge = boost::lexical_cast(currentCharge); + std::string charge = std::to_string(currentCharge); newSpell.mCostColumn = cost + "/" + charge; newSpell.mActive = invStore.isEquipped(item); diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index 9932cddfa..ebda8873c 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -96,9 +96,9 @@ namespace MWGui if (spell.mType == Spell::Type_Power) addGroup("#{sPowers}", ""); else if (spell.mType == Spell::Type_Spell) - addGroup("#{sSpells}", "#{sCostChance}"); + addGroup("#{sSpells}", mShowCostColumn ? "#{sCostChance}" : ""); else - addGroup("#{sMagicItem}", "#{sCostCharge}"); + addGroup("#{sMagicItem}", mShowCostColumn ? "#{sCostCharge}" : ""); curType = spell.mType; } diff --git a/apps/openmw/mwgui/spellview.hpp b/apps/openmw/mwgui/spellview.hpp index a4f8ddf39..0eb69f6ba 100644 --- a/apps/openmw/mwgui/spellview.hpp +++ b/apps/openmw/mwgui/spellview.hpp @@ -1,7 +1,7 @@ #ifndef OPENMW_GUI_SPELLVIEW_H #define OPENMW_GUI_SPELLVIEW_H -#include +#include #include @@ -56,7 +56,7 @@ namespace MWGui private: MyGUI::ScrollView* mScrollView; - std::auto_ptr mModel; + std::unique_ptr mModel; /// tracks a row in the spell view struct LineInfo diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index 7c12a8fc2..0c3485e6a 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -4,6 +4,8 @@ #include +#include + #include "../mwbase/windowmanager.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -48,6 +50,8 @@ namespace MWGui void SpellWindow::onPinToggled() { + Settings::Manager::setBool("spells pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setSpellVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index d68c1bcc5..22140b8b2 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -152,7 +154,7 @@ namespace MWGui // health, magicka, fatigue tooltip MyGUI::Widget* w; - std::string valStr = MyGUI::utility::toString(current) + "/" + MyGUI::utility::toString(modified); + std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified); if (id == "HBar") { getWidget(w, "Health"); @@ -616,13 +618,13 @@ namespace MWGui if (rankData.mSkill1 > 0) text += "\n#{sNeedOneSkill} " + MyGUI::utility::toString(rankData.mSkill1); if (rankData.mSkill2 > 0) - text += "\n#{sNeedTwoSkills} " + MyGUI::utility::toString(rankData.mSkill2); + text += " #{sand} #{sNeedTwoSkills} " + MyGUI::utility::toString(rankData.mSkill2); } } w->setUserString("ToolTipType", "Layout"); - w->setUserString("ToolTipLayout", "TextToolTip"); - w->setUserString("Caption_Text", text); + w->setUserString("ToolTipLayout", "FactionToolTip"); + w->setUserString("Caption_FactionText", text); } } @@ -672,6 +674,8 @@ namespace MWGui void StatsWindow::onPinToggled() { + Settings::Manager::setBool("stats pin", "Windows", mPinned); + MWBase::Environment::get().getWindowManager()->setHMSVisibility(!mPinned); } diff --git a/apps/openmw/mwgui/textcolours.hpp b/apps/openmw/mwgui/textcolours.hpp new file mode 100644 index 000000000..3fa55654b --- /dev/null +++ b/apps/openmw/mwgui/textcolours.hpp @@ -0,0 +1,35 @@ +#ifndef MWGUI_TEXTCOLORS_H +#define MWGUI_TEXTCOLORS_H + +#include + +namespace MWGui +{ + + struct TextColours + { + MyGUI::Colour header; + MyGUI::Colour normal; + MyGUI::Colour notify; + + + MyGUI::Colour link; + MyGUI::Colour linkOver; + MyGUI::Colour linkPressed; + + MyGUI::Colour answer; + MyGUI::Colour answerOver; + MyGUI::Colour answerPressed; + + MyGUI::Colour journalLink; + MyGUI::Colour journalLinkOver; + MyGUI::Colour journalLinkPressed; + + MyGUI::Colour journalTopic; + MyGUI::Colour journalTopicOver; + MyGUI::Colour journalTopicPressed; + }; + +} + +#endif diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 44ee6cac1..9b89c3957 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -40,6 +40,7 @@ namespace MWGui , mEnabled(true) , mFullHelp(false) , mShowOwned(0) + , mFrameDuration(0.f) { getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); @@ -67,6 +68,11 @@ namespace MWGui } void ToolTips::onFrame(float frameDuration) + { + mFrameDuration = frameDuration; + } + + void ToolTips::update(float frameDuration) { while (mDynamicToolTipBox->getChildCount()) @@ -320,6 +326,8 @@ namespace MWGui void ToolTips::setFocusObject(const MWWorld::ConstPtr& focus) { mFocusObject = focus; + + update(mFrameDuration); } MyGUI::IntSize ToolTips::getToolTipViaPtr (int count, bool image) @@ -351,12 +359,11 @@ namespace MWGui { if(!mFocusObject.isEmpty()) { - const MWWorld::CellRef& cellref = mFocusObject.getCellRef(); MWWorld::Ptr ptr = MWMechanics::getPlayer(); MWWorld::Ptr victim; MWBase::MechanicsManager* mm = MWBase::Environment::get().getMechanicsManager(); - bool allowed = mm->isAllowedToUse(ptr, cellref, victim); + bool allowed = mm->isAllowedToUse(ptr, mFocusObject, victim); return !allowed; } @@ -370,17 +377,10 @@ namespace MWGui { mDynamicToolTipBox->setVisible(true); - if(mShowOwned == 1 || mShowOwned == 3) - { - if(isFocusObject && checkOwned()) - { - mDynamicToolTipBox->changeWidgetSkin("HUD_Box_NoTransp_Owned"); - } - else - { - mDynamicToolTipBox->changeWidgetSkin("HUD_Box_NoTransp"); - } - } + if((mShowOwned == 1 || mShowOwned == 3) && isFocusObject && checkOwned()) + mDynamicToolTipBox->changeWidgetSkin(MWBase::Environment::get().getWindowManager()->isGuiMode() ? "HUD_Box_NoTransp_Owned" : "HUD_Box_Owned"); + else + mDynamicToolTipBox->changeWidgetSkin(MWBase::Environment::get().getWindowManager()->isGuiMode() ? "HUD_Box_NoTransp" : "HUD_Box"); std::string caption = info.caption; std::string image = info.icon; @@ -594,6 +594,14 @@ namespace MWGui return "\n" + prefix + ": " + toString(weight); } + std::string ToolTips::getPercentString(const float value, const std::string& prefix) + { + if (value == 0) + return ""; + else + return "\n" + prefix + ": " + toString(value*100) +"%"; + } + std::string ToolTips::getValueString(const int value, const std::string& prefix) { if (value == 0) @@ -701,20 +709,28 @@ namespace MWGui void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId) { - widget->setUserString("Caption_CenteredCaption", name); + widget->setUserString("Caption_Caption", name); std::string specText; // get all skills of this specialisation const MWWorld::Store &skills = MWBase::Environment::get().getWorld()->getStore().get(); + bool isFirst = true; MWWorld::Store::iterator it = skills.begin(); for (; it != skills.end(); ++it) { if (it->second.mData.mSpecialization == specId) - specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->first] + "}"; + { + if (isFirst) + isFirst = false; + else + specText += "\n"; + + specText += std::string("#{") + ESM::Skill::sSkillNameIds[it->first] + "}"; + } } - widget->setUserString("Caption_CenteredCaptionText", specText); - widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); + widget->setUserString("Caption_ColumnText", specText); + widget->setUserString("ToolTipLayout", "SpecializationToolTip"); widget->setUserString("ToolTipType", "Layout"); } @@ -769,7 +785,7 @@ namespace MWGui { if (it == categories[category].spells.begin()) { - text += std::string("\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}"; + text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}"; } const std::string &spellId = *it; @@ -787,7 +803,7 @@ namespace MWGui widget->setUserString("Caption_CenteredCaption", playerRace->mName); widget->setUserString("Caption_CenteredCaptionText", playerRace->mDescription); widget->setUserString("ToolTipType", "Layout"); - widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); + widget->setUserString("ToolTipLayout", "RaceToolTip"); } void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass) diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index de5b89b7f..bb2affc63 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -50,6 +50,7 @@ namespace MWGui ToolTips(); void onFrame(float frameDuration); + void update(float frameDuration); void setEnabled(bool enabled); @@ -63,6 +64,7 @@ namespace MWGui ///< set the screen-space position of the tooltip for focused object static std::string getWeightString(const float weight, const std::string& prefix); + static std::string getPercentString(const float value, const std::string& prefix); static std::string getValueString(const int value, const std::string& prefix); ///< @return "prefix: value" or "" if value is 0 @@ -125,6 +127,8 @@ namespace MWGui bool mFullHelp; int mShowOwned; + + float mFrameDuration; }; } #endif diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index e191c16bb..ca0bb48e8 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -1,5 +1,7 @@ #include "tradewindow.hpp" +#include + #include #include #include @@ -8,7 +10,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/dialoguemanager.hpp" @@ -121,8 +122,6 @@ namespace MWGui mCurrentBalance = 0; mCurrentMerchantOffer = 0; - restock(); - std::vector itemSources; MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources); @@ -208,8 +207,8 @@ namespace MWGui void TradeWindow::sellItem(MyGUI::Widget* sender, int count) { const ItemStack& item = mTradeModel->getItem(mItemToSell); - std::string sound = item.mBase.getClass().getDownSoundId(item.mBase); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + std::string sound = item.mBase.getClass().getUpSoundId(item.mBase); + MWBase::Environment::get().getWindowManager()->playSound(sound); TradeItemModel* playerTradeModel = MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getTradeModel(); @@ -312,9 +311,9 @@ namespace MWGui if (msg.find("%s") != std::string::npos) msg.replace(msg.find("%s"), 2, it->mBase.getClass().getName(it->mBase)); MWBase::Environment::get().getWindowManager()->messageBox(msg); - MWBase::Environment::get().getMechanicsManager()->commitCrime(player, mPtr, MWBase::MechanicsManager::OT_Theft, - it->mBase.getClass().getValue(it->mBase) - * it->mCount, true); + + MWBase::Environment::get().getMechanicsManager()->confiscateStolenItemToOwner(player, it->mBase, mPtr, it->mCount); + onCancelButtonClicked(mCancelButton); MWBase::Environment::get().getDialogueManager()->goodbyeSelected(); return; @@ -354,10 +353,10 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse( MWBase::Environment::get().getWorld()->getStore().get().find("sBarterDialog5")->getString()); - std::string sound = "Item Gold Up"; - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); - + MWBase::Environment::get().getWindowManager()->playSound("Item Gold Up"); MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter); + + restock(); } void TradeWindow::onCancelButtonClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 3063b3268..3a7afe497 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -8,7 +8,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/dialoguemanager.hpp" #include "../mwmechanics/creaturestats.hpp" @@ -28,8 +27,6 @@ namespace MWGui WindowBase("openmw_travel_window.layout") , mCurrentY(0) { - setCoord(0, 0, 450, 300); - getWidget(mCancelButton, "CancelButton"); getWidget(mPlayerGold, "PlayerGold"); getWidget(mSelect, "Select"); @@ -96,7 +93,7 @@ namespace MWGui toAdd->setUserString("price",oss.str()); toAdd->setCaptionWithReplacing("#{sCell=" + name + "} - " + MyGUI::utility::toString(price)+"#{sgp}"); - toAdd->setSize(toAdd->getTextSize().width,sLineHeight); + toAdd->setSize(mDestinationsView->getWidth(),sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); toAdd->setUserString("Destination", name); toAdd->setUserData(pos); @@ -160,7 +157,7 @@ namespace MWGui if (!mPtr.getCell()->isExterior()) // Interior cell -> mages guild transport - MWBase::Environment::get().getSoundManager()->playSound("mysticism cast", 1, 1); + MWBase::Environment::get().getWindowManager()->playSound("mysticism cast"); player.getClass().getContainerStore(player).remove(MWWorld::ContainerStore::sGoldId, price, player); diff --git a/apps/openmw/mwgui/videowidget.hpp b/apps/openmw/mwgui/videowidget.hpp index 6b265628e..ac240e69d 100644 --- a/apps/openmw/mwgui/videowidget.hpp +++ b/apps/openmw/mwgui/videowidget.hpp @@ -51,8 +51,8 @@ namespace MWGui private: const VFS::Manager* mVFS; - std::auto_ptr mTexture; - std::auto_ptr mPlayer; + std::unique_ptr mTexture; + std::unique_ptr mPlayer; }; } diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 8685475a4..ba58a9c69 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -134,7 +134,7 @@ namespace MWGui void WaitDialog::startWaiting(int hoursToWait) { - if(Settings::Manager::getBool("autosave","Saves") && mSleeping) //autosaves when enabled and sleeping + if(Settings::Manager::getBool("autosave","Saves")) //autosaves when enabled MWBase::Environment::get().getStateManager()->quickSave("Autosave"); MWBase::World* world = MWBase::Environment::get().getWorld(); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 16d1a9c6d..e4f6eafde 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -113,6 +113,16 @@ #include "jailscreen.hpp" #include "itemchargeview.hpp" +namespace +{ + + MyGUI::Colour getTextColour(const std::string& type) + { + return MyGUI::Colour::parse(MyGUI::LanguageManager::getInstance().replaceTags("#{fontcolour=" + type + "}")); + } + +} + namespace MWGui { @@ -283,12 +293,34 @@ namespace MWGui int w = MyGUI::RenderManager::getInstance().getViewSize().width; int h = MyGUI::RenderManager::getInstance().getViewSize().height; + mTextColours.header = getTextColour("header"); + mTextColours.normal = getTextColour("normal"); + mTextColours.notify = getTextColour("notify"); + + mTextColours.link = getTextColour("link"); + mTextColours.linkOver = getTextColour("link_over"); + mTextColours.linkPressed = getTextColour("link_pressed"); + + mTextColours.answer = getTextColour("answer"); + mTextColours.answerOver = getTextColour("answer_over"); + mTextColours.answerPressed = getTextColour("answer_pressed"); + + mTextColours.journalLink = getTextColour("journal_link"); + mTextColours.journalLinkOver = getTextColour("journal_link_over"); + mTextColours.journalLinkPressed = getTextColour("journal_link_pressed"); + + mTextColours.journalTopic = getTextColour("journal_topic"); + mTextColours.journalTopicOver = getTextColour("journal_topic_over"); + mTextColours.journalTopicPressed = getTextColour("journal_topic_pressed"); + + mDragAndDrop = new DragAndDrop(); mRecharge = new Recharge(); mMenu = new MainMenu(w, h, mResourceSystem->getVFS(), mVersionDescription); mLocalMapRender = new MWRender::LocalMap(mViewer->getSceneData()->asGroup()); mMap = new MapWindow(mCustomMarkers, mDragAndDrop, mLocalMapRender, mWorkQueue); + mMap->renderGlobalMap(); trackWindow(mMap, "map"); mStatsWindow = new StatsWindow(mDragAndDrop); trackWindow(mStatsWindow, "stats"); @@ -368,17 +400,14 @@ namespace MWGui mPlayerSkillValues.insert(std::make_pair(ESM::Skill::sSkillIds[i], MWMechanics::SkillValue())); } + updatePinnedWindows(); + // Set up visibility updateVisible(); MWBase::Environment::get().getInputManager()->changeInputMode(false); } - void WindowManager::renderWorldMap() - { - mMap->renderGlobalMap(); - } - void WindowManager::setNewGame(bool newgame) { // This method will always be called after loading a savegame or starting a new game @@ -550,14 +579,14 @@ namespace MWGui setSpellVisibility((mAllowed & GW_Magic) && (!mSpellWindow->pinned() || (mForceHidden & GW_Magic))); setHMSVisibility((mAllowed & GW_Stats) && (!mStatsWindow->pinned() || (mForceHidden & GW_Stats))); - // If in game mode, show only the pinned windows - if (gameMode) + // If in game mode (or interactive messagebox), show only the pinned windows + if (mGuiModes.empty()) { mInventoryWindow->setGuiMode(GM_None); - mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map)); - mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats)); - mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory)); - mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic)); + mMap->setVisible(mMap->pinned() && !(mForceHidden & GW_Map) && (mAllowed & GW_Map)); + mStatsWindow->setVisible(mStatsWindow->pinned() && !(mForceHidden & GW_Stats) && (mAllowed & GW_Stats)); + mInventoryWindow->setVisible(mInventoryWindow->pinned() && !(mForceHidden & GW_Inventory) && (mAllowed & GW_Inventory)); + mSpellWindow->setVisible(mSpellWindow->pinned() && !(mForceHidden & GW_Magic) && (mAllowed & GW_Magic)); return; } @@ -858,7 +887,7 @@ namespace MWGui mRepair->exit(); break; case GM_Journal: - MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); + playSound("book close"); removeGuiMode(GM_Journal); //Simple way to remove it break; default: @@ -1696,6 +1725,10 @@ namespace MWGui mCompanionWindow->resetReference(); mConsole->resetReference(); + mToolTips->setFocusObject(MWWorld::ConstPtr()); + + mInventoryWindow->clear(); + mSelectedSpell.clear(); mCustomMarkers.clear(); @@ -1855,6 +1888,17 @@ namespace MWGui mVideoWidget->stop(); } + void WindowManager::updatePinnedWindows() + { + mInventoryWindow->setPinned(Settings::Manager::getBool("inventory pin", "Windows")); + + mMap->setPinned(Settings::Manager::getBool("map pin", "Windows")); + + mSpellWindow->setPinned(Settings::Manager::getBool("spells pin", "Windows")); + + mStatsWindow->setPinned(Settings::Manager::getBool("stats pin", "Windows")); + } + void WindowManager::pinWindow(GuiWindow window) { switch (window) @@ -1939,12 +1983,8 @@ namespace MWGui char* text=0; text = SDL_GetClipboardText(); if (text) - { - // MyGUI's clipboard might still have color information, to retain that information, only set the new text - // if it actually changed (clipboard inserted by an external application) - if (MyGUI::TextIterator::getOnlyText(_data) != text) - _data = text; - } + _data = MyGUI::TextIterator::toTagsString(text); + SDL_free(text); } @@ -1965,6 +2005,11 @@ namespace MWGui mInventoryWindow->cycle(next); } + void WindowManager::playSound(const std::string& soundId, float volume, float pitch) + { + MWBase::Environment::get().getSoundManager()->playSound(soundId, volume, pitch, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoEnv); + } + void WindowManager::setConsoleSelectedObject(const MWWorld::Ptr &object) { mConsole->setSelectedObject(object); @@ -1985,7 +2030,7 @@ namespace MWGui void WindowManager::startSpellBuying(const MWWorld::Ptr &actor) { pushGuiMode(GM_SpellBuying); - mSpellBuyingWindow->startSpellBuying(actor); + mSpellBuyingWindow->startSpellBuying(actor, 0); } void WindowManager::startTrade(const MWWorld::Ptr &actor) @@ -2120,4 +2165,9 @@ namespace MWGui mLocalMapRender->saveFogOfWar(cell); } + const MWGui::TextColours& WindowManager::getTextColours() + { + return mTextColours; + } + } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index a8f6263c2..f74ba21a3 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -19,6 +19,7 @@ #include #include "mapwindow.hpp" +#include "textcolours.hpp" #include #include @@ -137,7 +138,6 @@ namespace MWGui void setStore (const MWWorld::ESMStore& store); void initUI(); - void renderWorldMap(); virtual Loading::Listener* getLoadingScreen(); @@ -381,6 +381,8 @@ namespace MWGui /// Cycle to next or previous weapon virtual void cycleWeapon(bool next); + virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f); + // In WindowManager for now since there isn't a VFS singleton virtual std::string correctIconPath(const std::string& path); virtual std::string correctBookartPath(const std::string& path, int width, int height); @@ -390,6 +392,8 @@ namespace MWGui void removeCell(MWWorld::CellStore* cell); void writeFog(MWWorld::CellStore* cell); + virtual const MWGui::TextColours& getTextColours(); + private: const MWWorld::ESMStore* mStore; Resource::ResourceSystem* mResourceSystem; @@ -398,7 +402,7 @@ namespace MWGui osgMyGUI::Platform* mGuiPlatform; osgViewer::Viewer* mViewer; - std::auto_ptr mFontLoader; + std::unique_ptr mFontLoader; bool mConsoleOnlyScripts; @@ -513,6 +517,8 @@ namespace MWGui std::string mVersionDescription; + MWGui::TextColours mTextColours; + /** * Called when MyGUI tries to retrieve a tag's value. Tags must be denoted in #{tag} notation and will be replaced upon setting a user visible text/property. * Supported syntax: @@ -540,6 +546,8 @@ namespace MWGui void createTextures(); void createCursors(); void setMenuTransparency(float value); + + void updatePinnedWindows(); }; } diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 234a17cc3..a823ae0fd 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1,9 +1,5 @@ #include "inputmanagerimp.hpp" -#include - -#include - #include #include @@ -22,7 +18,6 @@ #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwbase/statemanager.hpp" #include "../mwbase/environment.hpp" @@ -417,18 +412,21 @@ namespace MWInput { float xAxis = mInputBinder->getChannel(A_LookLeftRight)->getValue()*2.0f-1.0f; float yAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f; - resetIdleTime(); + if (xAxis != 0 || yAxis != 0) + { + resetIdleTime(); - float rot[3]; - rot[0] = yAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier; - rot[1] = 0.0f; - rot[2] = xAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f); + float rot[3]; + rot[0] = yAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier; + rot[1] = 0.0f; + rot[2] = xAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f); - // Only actually turn player when we're not in vanity mode - if(!MWBase::Environment::get().getWorld()->vanityRotateCamera(rot)) - { - mPlayer->yaw(rot[2]); - mPlayer->pitch(rot[0]); + // Only actually turn player when we're not in vanity mode + if(!MWBase::Environment::get().getWorld()->vanityRotateCamera(rot)) + { + mPlayer->yaw(rot[2]); + mPlayer->pitch(rot[0]); + } } } @@ -714,9 +712,9 @@ namespace MWInput if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0) { MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType(false); - if (b && b->getEnabled()) + if (b && b->getEnabled() && id == SDL_BUTTON_LEFT) { - MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f); + MWBase::Environment::get().getWindowManager()->playSound("Menu Click"); } } } @@ -811,7 +809,7 @@ namespace MWInput MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType(false); if (b && b->getEnabled()) { - MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f); + MWBase::Environment::get().getWindowManager()->playSound("Menu Click"); } } } @@ -1024,14 +1022,15 @@ namespace MWInput return; if(MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_Journal + && MWBase::Environment::get().getWindowManager()->getMode() != MWGui::GM_MainMenu && MWBase::Environment::get().getWindowManager ()->getJournalAllowed()) { - MWBase::Environment::get().getSoundManager()->playSound ("book open", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound ("book open"); MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Journal); } else if(MWBase::Environment::get().getWindowManager()->containsMode(MWGui::GM_Journal)) { - MWBase::Environment::get().getSoundManager()->playSound ("book close", 1.0, 1.0); + MWBase::Environment::get().getWindowManager()->playSound ("book close"); MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Journal); } } @@ -1175,7 +1174,7 @@ namespace MWInput bool controlExists = mInputBinder->getChannel(i)->getControlsCount () != 0; if (!controlExists) { - control = new ICS::Control(boost::lexical_cast(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX); + control = new ICS::Control(std::to_string(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX); mInputBinder->addControl(control); control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT); } @@ -1244,10 +1243,10 @@ namespace MWInput if (!controlExists) { float initial; - if (defaultButtonBindings.find(i) != defaultButtonBindings.end()) + if (defaultAxisBindings.find(i) == defaultAxisBindings.end()) initial = 0.0f; else initial = 0.5f; - control = new ICS::Control(boost::lexical_cast(i), false, true, initial, ICS::ICS_MAX, ICS::ICS_MAX); + control = new ICS::Control(std::to_string(i), false, true, initial, ICS::ICS_MAX, ICS::ICS_MAX); mInputBinder->addControl(control); control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT); } @@ -1260,12 +1259,13 @@ namespace MWInput { clearAllControllerBindings(control); - if (defaultButtonBindings.find(i) != defaultButtonBindings.end()) + if (defaultButtonBindings.find(i) != defaultButtonBindings.end() + && !mInputBinder->isJoystickButtonBound(mFakeDeviceID, defaultButtonBindings[i])) { control->setInitialValue(0.0f); mInputBinder->addJoystickButtonBinding(control, mFakeDeviceID, defaultButtonBindings[i], ICS::Control::INCREASE); } - else if (defaultAxisBindings.find(i) != defaultAxisBindings.end()) + else if (defaultAxisBindings.find(i) != defaultAxisBindings.end() && !mInputBinder->isJoystickAxisBound(mFakeDeviceID, defaultAxisBindings[i])) { control->setValue(0.5f); control->setInitialValue(0.5f); @@ -1336,7 +1336,7 @@ namespace MWInput if (key != SDL_SCANCODE_UNKNOWN) return MyGUI::TextIterator::toTagsString(mInputBinder->scancodeToString (key)); else if (mouse != ICS_MAX_DEVICE_BUTTONS) - return "#{sMouse} " + boost::lexical_cast(mouse); + return "#{sMouse} " + std::to_string(mouse); else return "#{sNone}"; } @@ -1391,7 +1391,7 @@ namespace MWInput case SDL_CONTROLLER_BUTTON_Y: return "Y Button"; default: - return "Button " + boost::lexical_cast(button); + return "Button " + std::to_string(button); } } std::string InputManager::sdlControllerAxisToString(int axis) @@ -1411,7 +1411,7 @@ namespace MWInput case SDL_CONTROLLER_AXIS_TRIGGERRIGHT: return "Right Trigger"; default: - return "Axis " + boost::lexical_cast(axis); + return "Axis " + std::to_string(axis); } } diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 52c05fdfa..90d29f686 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -222,10 +222,23 @@ namespace MWMechanics } } - void ActiveSpells::purgeAll(float chance) + void ActiveSpells::purgeAll(float chance, bool spellOnly) { for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); ) { + const std::string spellId = it->first; + + // if spellOnly is true, dispell only spells. Leave potions, enchanted items etc. + if (spellOnly) + { + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(spellId); + if (!spell || spell->mData.mType != ESM::Spell::ST_Spell) + { + ++it; + continue; + } + } + if (Misc::Rng::roll0to99() < chance) mSpells.erase(it++); else diff --git a/apps/openmw/mwmechanics/activespells.hpp b/apps/openmw/mwmechanics/activespells.hpp index 0f1f803b7..a19c8a51d 100644 --- a/apps/openmw/mwmechanics/activespells.hpp +++ b/apps/openmw/mwmechanics/activespells.hpp @@ -89,7 +89,7 @@ namespace MWMechanics void purgeEffect (short effectId, const std::string& sourceId); /// Remove all active effects, if roll succeeds (for each effect) - void purgeAll (float chance); + void purgeAll(float chance, bool spellOnly = false); /// Remove all effects with CASTER_LINKED flag that were cast by \a casterActorId void purge (int casterActorId); diff --git a/apps/openmw/mwmechanics/actor.hpp b/apps/openmw/mwmechanics/actor.hpp index 846af1467..b8e114ead 100644 --- a/apps/openmw/mwmechanics/actor.hpp +++ b/apps/openmw/mwmechanics/actor.hpp @@ -32,7 +32,7 @@ namespace MWMechanics AiState& getAiState(); private: - std::auto_ptr mCharacterController; + std::unique_ptr mCharacterController; AiState mAiState; }; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 88fee8ef1..630e18e80 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -25,6 +25,8 @@ #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/statemanager.hpp" +#include "../mwmechanics/aibreathe.hpp" + #include "spellcasting.hpp" #include "npcstats.hpp" #include "creaturestats.hpp" @@ -78,7 +80,7 @@ class CheckActorCommanded : public MWMechanics::EffectSourceVisitor MWWorld::Ptr mActor; public: bool mCommanded; - CheckActorCommanded(MWWorld::Ptr actor) + CheckActorCommanded(const MWWorld::Ptr& actor) : mActor(actor) , mCommanded(false){} @@ -114,9 +116,7 @@ void adjustCommandedActor (const MWWorld::Ptr& actor) } if (!check.mCommanded && hasCommandPackage) - { stats.getAiSequence().erase(it); - } } void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float& magicka) @@ -151,7 +151,7 @@ namespace MWMechanics MWWorld::Ptr mActor; bool mTrapped; public: - SoulTrap(MWWorld::Ptr trappedCreature) + SoulTrap(const MWWorld::Ptr& trappedCreature) : mCreature(trappedCreature) , mTrapped(false) { @@ -596,6 +596,21 @@ namespace MWMechanics } } + // purge levitate effect if levitation is disabled + // check only modifier, because base value can be setted from SetFlying console command. + if (MWBase::Environment::get().getWorld()->isLevitationEnabled() == false && effects.get(ESM::MagicEffect::Levitate).getModifier() > 0) + { + creatureStats.getSpells().purgeEffect(ESM::MagicEffect::Levitate); + creatureStats.getActiveSpells().purgeEffect(ESM::MagicEffect::Levitate); + if (ptr.getClass().hasInventoryStore(ptr)) + ptr.getClass().getInventoryStore(ptr).purgeEffect(ESM::MagicEffect::Levitate); + + if (ptr == getPlayer()) + { + MWBase::Environment::get().getWindowManager()->messageBox ("#{sLevitateDisabled}"); + } + } + // attributes for(int i = 0;i < ESM::Attribute::Length;++i) { @@ -707,16 +722,8 @@ namespace MWMechanics // any value of calm > 0 will stop the actor from fighting if ((effects.get(ESM::MagicEffect::CalmHumanoid).getMagnitude() > 0 && ptr.getClass().isNpc()) - || (effects.get(ESM::MagicEffect::CalmCreature).getMagnitude() > 0 && !ptr.getClass().isNpc())) - { - for (std::list::const_iterator it = creatureStats.getAiSequence().begin(); it != creatureStats.getAiSequence().end(); ) - { - if ((*it)->getTypeId() == AiPackage::TypeIdCombat) - it = creatureStats.getAiSequence().erase(it); - else - ++it; - } - } + || (effects.get(ESM::MagicEffect::CalmCreature).getMagnitude() > 0 && !ptr.getClass().isNpc())) + creatureStats.getAiSequence().stopCombat(); // Update bound effects // Note: in vanilla MW multiple bound items of the same type can be created by different spells. @@ -776,7 +783,7 @@ namespace MWMechanics creatureStats.getActiveSpells().visitEffectSources(updateSummonedCreatures); if (ptr.getClass().hasInventoryStore(ptr)) ptr.getClass().getInventoryStore(ptr).visitEffectSources(updateSummonedCreatures); - updateSummonedCreatures.process(); + updateSummonedCreatures.process(mTimerDisposeSummonsCorpses == 0.f); } } @@ -795,6 +802,26 @@ namespace MWMechanics } } + bool Actors::isRunning(const MWWorld::Ptr& ptr) + { + PtrActorMap::iterator it = mActors.find(ptr); + if (it == mActors.end()) + return false; + CharacterController* ctrl = it->second->getCharacterController(); + + return ctrl->isRunning(); + } + + bool Actors::isSneaking(const MWWorld::Ptr& ptr) + { + PtrActorMap::iterator it = mActors.find(ptr); + if (it == mActors.end()) + return false; + CharacterController* ctrl = it->second->getCharacterController(); + + return ctrl->isSneaking(); + } + void Actors::updateDrowning(const MWWorld::Ptr& ptr, float duration) { PtrActorMap::iterator it = mActors.find(ptr); @@ -803,6 +830,21 @@ namespace MWMechanics CharacterController* ctrl = it->second->getCharacterController(); NpcStats &stats = ptr.getClass().getNpcStats(ptr); + + // When npc stats are just initialized, mTimeToStartDrowning == -1 and we should get value from GMST + static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get().find("fHoldBreathTime")->getFloat(); + if (stats.getTimeToStartDrowning() == -1.f) + stats.setTimeToStartDrowning(fHoldBreathTime); + + if (ptr.getClass().isNpc() && stats.getTimeToStartDrowning() < fHoldBreathTime / 2) + { + if(ptr != MWMechanics::getPlayer() ) { + MWMechanics::AiSequence& seq = ptr.getClass().getCreatureStats(ptr).getAiSequence(); + if(seq.getTypeId() != MWMechanics::AiPackage::TypeIdBreathe) //Only add it once + seq.stack(MWMechanics::AiBreathe(), ptr); + } + } + MWBase::World *world = MWBase::Environment::get().getWorld(); bool knockedOutUnderwater = (ctrl->isKnockedOut() && world->isUnderwater(ptr.getCell(), osg::Vec3f(ptr.getRefData().getPosition().asVec3()))); if((world->isSubmerged(ptr) || knockedOutUnderwater) @@ -839,10 +881,7 @@ namespace MWMechanics } } else - { - static const float fHoldBreathTime = world->getStore().get().find("fHoldBreathTime")->getFloat(); stats.setTimeToStartDrowning(fHoldBreathTime); - } } void Actors::updateEquippedLight (const MWWorld::Ptr& ptr, float duration) @@ -1001,7 +1040,9 @@ namespace MWMechanics } } - Actors::Actors() {} + Actors::Actors() { + mTimerDisposeSummonsCorpses = 0.2f; // We should add a delay between summoned creature death and its corpse despawning + } Actors::~Actors() { @@ -1070,6 +1111,7 @@ namespace MWMechanics // target lists get updated once every 1.0 sec if (timerUpdateAITargets >= 1.0f) timerUpdateAITargets = 0; if (timerUpdateHeadTrack >= 0.3f) timerUpdateHeadTrack = 0; + if (mTimerDisposeSummonsCorpses >= 0.2f) mTimerDisposeSummonsCorpses = 0; if (timerUpdateEquippedLight >= updateEquippedLightInterval) timerUpdateEquippedLight = 0; MWWorld::Ptr player = getPlayer(); @@ -1174,6 +1216,7 @@ namespace MWMechanics timerUpdateAITargets += duration; timerUpdateHeadTrack += duration; timerUpdateEquippedLight += duration; + mTimerDisposeSummonsCorpses += duration; // Looping magic VFX update // Note: we need to do this before any of the animations are updated. @@ -1439,6 +1482,11 @@ namespace MWMechanics calculateCreatureStatModifiers (iter->first, duration); if (iter->first.getClass().isNpc()) calculateNpcStatModifiers(iter->first, duration); + + MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(iter->first); + if (animation) + animation->updateEffects(duration); + } fastForwardAi(); diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 362c2f126..59e422928 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -107,6 +107,9 @@ namespace MWMechanics int countDeaths (const std::string& id) const; ///< Return the number of deaths for actors with the given ID. + bool isRunning(const MWWorld::Ptr& ptr); + bool isSneaking(const MWWorld::Ptr& ptr); + void forceStateUpdate(const MWWorld::Ptr &ptr); bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false); @@ -150,6 +153,7 @@ namespace MWMechanics private: PtrActorMap mActors; + float mTimerDisposeSummonsCorpses; }; } diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index b1426a4c1..d38a1299f 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -55,7 +55,7 @@ namespace MWMechanics void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::auto_ptr activate(new ESM::AiSequence::AiActivate()); + std::unique_ptr activate(new ESM::AiSequence::AiActivate()); activate->mTargetId = mObjectId; ESM::AiSequence::AiPackageContainer package; diff --git a/apps/openmw/mwmechanics/aibreathe.cpp b/apps/openmw/mwmechanics/aibreathe.cpp new file mode 100644 index 000000000..4e0076824 --- /dev/null +++ b/apps/openmw/mwmechanics/aibreathe.cpp @@ -0,0 +1,54 @@ +#include "aibreathe.hpp" + +#include "../mwbase/world.hpp" +#include "../mwbase/environment.hpp" + +#include "../mwworld/class.hpp" +#include "../mwworld/esmstore.hpp" + +#include "npcstats.hpp" + +#include "movement.hpp" +#include "steering.hpp" + +MWMechanics::AiBreathe::AiBreathe() +: AiPackage() +{ + +} + +bool MWMechanics::AiBreathe::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) +{ + static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get().find("fHoldBreathTime")->getFloat(); + + const MWWorld::Class& actorClass = actor.getClass(); + if (actorClass.isNpc()) + { + if (actorClass.getNpcStats(actor).getTimeToStartDrowning() < fHoldBreathTime / 2) + { + actor.getClass().getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true); + + actor.getClass().getMovementSettings(actor).mPosition[1] = 1; + smoothTurn(actor, -180, 0); + + return false; + } + } + + return true; +} + +MWMechanics::AiBreathe *MWMechanics::AiBreathe::clone() const +{ + return new AiBreathe(*this); +} + +int MWMechanics::AiBreathe::getTypeId() const +{ + return TypeIdBreathe; +} + +unsigned int MWMechanics::AiBreathe::getPriority() const +{ + return 2; +} diff --git a/apps/openmw/mwmechanics/aibreathe.hpp b/apps/openmw/mwmechanics/aibreathe.hpp new file mode 100644 index 000000000..263ab8c2b --- /dev/null +++ b/apps/openmw/mwmechanics/aibreathe.hpp @@ -0,0 +1,28 @@ +#ifndef GAME_MWMECHANICS_AIBREATHE_H +#define GAME_MWMECHANICS_AIBREATHE_H + +#include "aipackage.hpp" + +namespace MWMechanics +{ + /// \brief AiPackage to have an actor resurface to breathe + // The AI will go up if lesser than half breath left + class AiBreathe : public AiPackage + { + public: + AiBreathe(); + + virtual AiBreathe *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration); + + virtual int getTypeId() const; + + virtual unsigned int getPriority() const; + + virtual bool canCancel() const { return false; } + virtual bool shouldCancelPreviousAi() const { return false; } + }; +} +#endif + diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 17005f235..68d282d0c 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -47,7 +47,7 @@ namespace MWMechanics bool mCombatMove; osg::Vec3f mLastTargetPos; const MWWorld::CellStore* mCell; - boost::shared_ptr mCurrentAction; + std::shared_ptr mCurrentAction; float mActionCooldown; float mStrength; bool mForceNoShortcut; @@ -249,7 +249,7 @@ namespace MWMechanics actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true); float& actionCooldown = storage.mActionCooldown; - boost::shared_ptr& currentAction = storage.mCurrentAction; + std::shared_ptr& currentAction = storage.mCurrentAction; if (!forceFlee) { @@ -479,7 +479,7 @@ namespace MWMechanics void AiCombat::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::auto_ptr combat(new ESM::AiSequence::AiCombat()); + std::unique_ptr combat(new ESM::AiSequence::AiCombat()); combat->mTargetActorId = mTargetActorId; ESM::AiSequence::AiPackageContainer package; @@ -500,8 +500,7 @@ namespace MWMechanics { // get the range of the target's weapon float rangeAttackOfTarget = 0.f; - bool isRangedCombat = false; - MWWorld::Ptr targetWeapon = MWWorld::Ptr(); + MWWorld::Ptr targetWeapon = MWWorld::Ptr(); const MWWorld::Class& targetClass = target.getClass(); if (targetClass.hasInventoryStore(target)) @@ -513,10 +512,13 @@ namespace MWMechanics targetWeapon = *weaponSlot; } - boost::shared_ptr targetWeaponAction (new ActionWeapon(targetWeapon)); + std::shared_ptr targetWeaponAction (new ActionWeapon(targetWeapon)); if (targetWeaponAction.get()) + { + bool isRangedCombat = false; rangeAttackOfTarget = targetWeaponAction->getCombatRange(isRangedCombat); + } // apply sideway movement (kind of dodging) with some probability // if actor is within range of target's weapon @@ -533,6 +535,10 @@ namespace MWMechanics // opponent's weapon range, or not backing up if opponent is also using a ranged weapon if (isDistantCombat && distToTarget < rangeAttack / 4) { + // actor should not back up into water + if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.5f)) + return; + mMovement.mPosition[1] = -1; } } diff --git a/apps/openmw/mwmechanics/aicombat.hpp b/apps/openmw/mwmechanics/aicombat.hpp index fbe864ca0..e7d74248b 100644 --- a/apps/openmw/mwmechanics/aicombat.hpp +++ b/apps/openmw/mwmechanics/aicombat.hpp @@ -3,8 +3,6 @@ #include "aipackage.hpp" -#include - #include "../mwworld/cellstore.hpp" // for Doors #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwmechanics/aicombataction.cpp b/apps/openmw/mwmechanics/aicombataction.cpp index cc1434d52..d44498966 100644 --- a/apps/openmw/mwmechanics/aicombataction.cpp +++ b/apps/openmw/mwmechanics/aicombataction.cpp @@ -16,405 +16,25 @@ #include "npcstats.hpp" #include "spellcasting.hpp" #include "combat.hpp" - -namespace -{ - -// RangeTypes using bitflags to allow multiple range types, as can be the case with spells having multiple effects. -enum RangeTypes -{ - Self = 0x1, - Touch = 0x10, - Target = 0x100 -}; - -int getRangeTypes (const ESM::EffectList& effects) -{ - int types = 0; - for (std::vector::const_iterator it = effects.mList.begin(); it != effects.mList.end(); ++it) - { - if (it->mRange == ESM::RT_Self) - types |= Self; - else if (it->mRange == ESM::RT_Touch) - types |= Touch; - else if (it->mRange == ESM::RT_Target) - types |= Target; - } - return types; -} - -float suggestCombatRange(int rangeTypes) -{ - if (rangeTypes & Touch) - { - static const float fCombatDistance = MWBase::Environment::get().getWorld()->getStore().get().find("fCombatDistance")->getFloat(); - return fCombatDistance; - } - else if (rangeTypes & Target) - { - return 1000.f; - } - else - { - // For Self spells, distance doesn't matter, so back away slightly to avoid enemy hits - return 600.f; - } -} - -int numEffectsToCure (const MWWorld::Ptr& actor, int effectFilter=-1) -{ - int toCure=0; - const MWMechanics::ActiveSpells& activeSpells = actor.getClass().getCreatureStats(actor).getActiveSpells(); - for (MWMechanics::ActiveSpells::TIterator it = activeSpells.begin(); it != activeSpells.end(); ++it) - { - const MWMechanics::ActiveSpells::ActiveSpellParams& params = it->second; - for (std::vector::const_iterator effectIt = params.mEffects.begin(); - effectIt != params.mEffects.end(); ++effectIt) - { - int effectId = effectIt->mEffectId; - if (effectFilter != -1 && effectId != effectFilter) - continue; - const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); - if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful - && effectIt->mDuration > 3 // Don't attempt to cure if effect runs out shortly anyway - ) - ++toCure; - } - } - return toCure; -} - -} +#include "weaponpriority.hpp" +#include "spellpriority.hpp" namespace MWMechanics { - - float ratePotion (const MWWorld::Ptr &item, const MWWorld::Ptr& actor) - { - if (item.getTypeName() != typeid(ESM::Potion).name()) - return 0.f; - - const ESM::Potion* potion = item.get()->mBase; - return rateEffects(potion->mEffects, actor, MWWorld::Ptr()); - } - - float rateWeapon (const MWWorld::Ptr &item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, int type, - float arrowRating, float boltRating) - { - if (item.getTypeName() != typeid(ESM::Weapon).name()) - return 0.f; - - const ESM::Weapon* weapon = item.get()->mBase; - - if (type != -1 && weapon->mData.mType != type) - return 0.f; - - float rating=0.f; - float bonus=0.f; - - if (weapon->mData.mType >= ESM::Weapon::MarksmanBow && weapon->mData.mType <= ESM::Weapon::MarksmanThrown) - bonus+=1.5f; - - if (weapon->mData.mType >= ESM::Weapon::MarksmanBow) - { - rating = (weapon->mData.mChop[0] + weapon->mData.mChop[1]) / 2.f; - } - else - { - for (int i=0; i<2; ++i) - { - rating += weapon->mData.mSlash[i]; - rating += weapon->mData.mThrust[i]; - rating += weapon->mData.mChop[i]; - } - rating /= 6.f; - } - - if (item.getClass().hasItemHealth(item)) - { - if (item.getClass().getItemHealth(item) == 0) - return 0.f; - rating *= item.getClass().getItemHealth(item) / float(item.getClass().getItemMaxHealth(item)); - } - - if (weapon->mData.mType == ESM::Weapon::MarksmanBow) - { - if (arrowRating <= 0.f) - rating = 0.f; - else - rating += arrowRating; - } - else if (weapon->mData.mType == ESM::Weapon::MarksmanCrossbow) - { - if (boltRating <= 0.f) - rating = 0.f; - else - rating += boltRating; - } - - if (!weapon->mEnchant.empty()) - { - const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get().find(weapon->mEnchant); - if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes - && (item.getCellRef().getEnchantmentCharge() == -1 - || item.getCellRef().getEnchantmentCharge() >= enchantment->mData.mCost)) - rating += rateEffects(enchantment->mEffects, actor, enemy); - } - - int skill = item.getClass().getEquipmentSkill(item); - if (skill != -1) - rating *= actor.getClass().getSkill(actor, skill) / 100.f; - - return rating + bonus; - } - - float rateSpell(const ESM::Spell *spell, const MWWorld::Ptr &actor, const MWWorld::Ptr& enemy) + float suggestCombatRange(int rangeTypes) { - const CreatureStats& stats = actor.getClass().getCreatureStats(actor); - - float successChance = MWMechanics::getSpellSuccessChance(spell, actor); - if (successChance == 0.f) - return 0.f; - - if (spell->mData.mType != ESM::Spell::ST_Spell) - return 0.f; - - // Don't make use of racial bonus spells, like MW. Can be made optional later - if (actor.getClass().isNpc()) - { - std::string raceid = actor.get()->mBase->mRace; - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); - if (race->mPowers.exists(spell->mId)) - return 0.f; - } - - if (spell->mData.mCost > stats.getMagicka().getCurrent()) - return 0.f; - - // Spells don't stack, so early out if the spell is still active on the target - int types = getRangeTypes(spell->mEffects); - if ((types & Self) && stats.getActiveSpells().isSpellActive(spell->mId)) - return 0.f; - if ( ((types & Touch) || (types & Target)) && enemy.getClass().getCreatureStats(enemy).getActiveSpells().isSpellActive(spell->mId)) - return 0.f; - - return rateEffects(spell->mEffects, actor, enemy) * (successChance / 100.f); - } - - float rateMagicItem(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor, const MWWorld::Ptr& enemy) - { - if (ptr.getClass().getEnchantment(ptr).empty()) - return 0.f; - - const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get().find(ptr.getClass().getEnchantment(ptr)); - - if (enchantment->mData.mType == ESM::Enchantment::CastOnce) - { - return rateEffects(enchantment->mEffects, actor, enemy); - } - else - { - //if (!ptr.getClass().canBeEquipped(ptr, actor)) - return 0.f; - } - } + static const float fCombatDistance = MWBase::Environment::get().getWorld()->getStore().get().find("fCombatDistance")->getFloat(); + static float fHandToHandReach = MWBase::Environment::get().getWorld()->getStore().get().find("fHandToHandReach")->getFloat(); - float rateEffect(const ESM::ENAMstruct &effect, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) - { - // NOTE: enemy may be empty + // This distance is a possible distance of melee attack + static float distance = fCombatDistance * std::max(2.f, fHandToHandReach); - float rating = 1; - switch (effect.mEffectID) + if (rangeTypes & RangeTypes::Touch) { - case ESM::MagicEffect::Soultrap: - case ESM::MagicEffect::AlmsiviIntervention: - case ESM::MagicEffect::DivineIntervention: - case ESM::MagicEffect::CalmHumanoid: - case ESM::MagicEffect::CalmCreature: - case ESM::MagicEffect::FrenzyHumanoid: - case ESM::MagicEffect::FrenzyCreature: - case ESM::MagicEffect::DemoralizeHumanoid: - case ESM::MagicEffect::DemoralizeCreature: - case ESM::MagicEffect::RallyHumanoid: - case ESM::MagicEffect::RallyCreature: - case ESM::MagicEffect::Charm: - case ESM::MagicEffect::DetectAnimal: - case ESM::MagicEffect::DetectEnchantment: - case ESM::MagicEffect::DetectKey: - case ESM::MagicEffect::Telekinesis: - case ESM::MagicEffect::Mark: - case ESM::MagicEffect::Recall: - case ESM::MagicEffect::Jump: - case ESM::MagicEffect::WaterBreathing: - case ESM::MagicEffect::SwiftSwim: - case ESM::MagicEffect::WaterWalking: - case ESM::MagicEffect::SlowFall: - case ESM::MagicEffect::Light: - case ESM::MagicEffect::Lock: - case ESM::MagicEffect::Open: - case ESM::MagicEffect::TurnUndead: - case ESM::MagicEffect::WeaknessToCommonDisease: - case ESM::MagicEffect::WeaknessToBlightDisease: - case ESM::MagicEffect::WeaknessToCorprusDisease: - case ESM::MagicEffect::CureCommonDisease: - case ESM::MagicEffect::CureBlightDisease: - case ESM::MagicEffect::CureCorprusDisease: - case ESM::MagicEffect::ResistBlightDisease: - case ESM::MagicEffect::ResistCommonDisease: - case ESM::MagicEffect::ResistCorprusDisease: - case ESM::MagicEffect::Invisibility: - case ESM::MagicEffect::Chameleon: - return 0.f; - - case ESM::MagicEffect::RestoreAttribute: - return 0.f; // TODO: implement based on attribute damage - case ESM::MagicEffect::RestoreSkill: - return 0.f; // TODO: implement based on skill damage - - case ESM::MagicEffect::ResistFire: - case ESM::MagicEffect::ResistFrost: - case ESM::MagicEffect::ResistMagicka: - case ESM::MagicEffect::ResistNormalWeapons: - case ESM::MagicEffect::ResistParalysis: - case ESM::MagicEffect::ResistPoison: - case ESM::MagicEffect::ResistShock: - return 0.f; // probably useless since we don't know in advance what the enemy will cast - - // don't cast these for now as they would make the NPC cast the same effect over and over again, especially when they have potions - case ESM::MagicEffect::FortifyAttribute: - case ESM::MagicEffect::FortifyHealth: - case ESM::MagicEffect::FortifyMagicka: - case ESM::MagicEffect::FortifyFatigue: - case ESM::MagicEffect::FortifySkill: - case ESM::MagicEffect::FortifyMaximumMagicka: - return 0.f; - - case ESM::MagicEffect::Feather: - if (actor.getClass().getEncumbrance(actor) - actor.getClass().getCapacity(actor) >= 0) - return 100.f; - else - return 0.f; - case ESM::MagicEffect::Levitate: - return 0.f; // AI isn't designed to take advantage of this, and could be perceived as unfair anyway - case ESM::MagicEffect::BoundBoots: - case ESM::MagicEffect::BoundHelm: - if (actor.getClass().isNpc()) - { - // Beast races can't wear helmets or boots - std::string raceid = actor.get()->mBase->mRace; - const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); - if (race->mData.mFlags & ESM::Race::Beast) - return 0.f; - } - // Intended fall-through - // Creatures can not wear armor - case ESM::MagicEffect::BoundCuirass: - case ESM::MagicEffect::BoundGloves: - if (!actor.getClass().isNpc()) - return 0.f; - break; - - case ESM::MagicEffect::RestoreHealth: - case ESM::MagicEffect::RestoreMagicka: - case ESM::MagicEffect::RestoreFatigue: - if (effect.mRange == ESM::RT_Self) - { - int priority = 1; - if (effect.mEffectID == ESM::MagicEffect::RestoreHealth) - priority = 10; - const DynamicStat& current = actor.getClass().getCreatureStats(actor). - getDynamic(effect.mEffectID - ESM::MagicEffect::RestoreHealth); - float toHeal = (effect.mMagnMin + effect.mMagnMax)/2.f * effect.mDuration; - // Effect doesn't heal more than we need, *or* we are below 1/2 health - if (current.getModified() - current.getCurrent() > toHeal - || current.getCurrent() < current.getModified()*0.5) - { - return 10000.f * priority - - (toHeal - (current.getModified()-current.getCurrent())); // prefer the most fitting potion - } - else - return -10000.f * priority; // Save for later - } - break; - - // Prefer Cure effects over Dispel, because Dispel also removes positive effects - case ESM::MagicEffect::Dispel: - return 1000.f * numEffectsToCure(actor); - case ESM::MagicEffect::CureParalyzation: - return 1001.f * numEffectsToCure(actor, ESM::MagicEffect::Paralyze); - case ESM::MagicEffect::CurePoison: - return 1001.f * numEffectsToCure(actor, ESM::MagicEffect::Poison); - - case ESM::MagicEffect::DisintegrateArmor: // TODO: check if actor is wearing armor - case ESM::MagicEffect::DisintegrateWeapon: // TODO: check if actor is wearing weapon - break; - - case ESM::MagicEffect::DamageAttribute: - case ESM::MagicEffect::DrainAttribute: - if (!enemy.isEmpty() && enemy.getClass().getCreatureStats(enemy).getAttribute(effect.mAttribute).getModified() <= 0) - return 0.f; - { - if (effect.mAttribute >= 0 && effect.mAttribute < ESM::Attribute::Length) - { - const float attributePriorities[ESM::Attribute::Length] = { - 1.0f, // Strength - 0.5f, // Intelligence - 0.6f, // Willpower - 0.7f, // Agility - 0.5f, // Speed - 0.8f, // Endurance - 0.7f, // Personality - 0.3f // Luck - }; - rating *= attributePriorities[effect.mAttribute]; - } - } - break; - - case ESM::MagicEffect::DamageSkill: - case ESM::MagicEffect::DrainSkill: - if (enemy.isEmpty() || !enemy.getClass().isNpc()) - return 0.f; - if (enemy.getClass().getNpcStats(enemy).getSkill(effect.mSkill).getModified() <= 0) - return 0.f; - break; - - default: - break; + return fCombatDistance; } - // TODO: for non-cumulative effects (e.g. paralyze), check if the enemy is already suffering from them - - // TODO: could take into account enemy's resistance/weakness against the effect - - const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); - - rating *= magicEffect->mData.mBaseCost; - - if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) - rating *= (effect.mMagnMin + effect.mMagnMax)/2.f; - if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) - rating *= effect.mDuration; - - if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful) - rating *= -1.f; - - // Currently treating all "on target" or "on touch" effects to target the enemy actor. - // Combat AI is egoistic, so doesn't consider applying positive effects to friendly actors. - if (effect.mRange != ESM::RT_Self) - rating *= -1.f; - return rating; - } - - float rateEffects(const ESM::EffectList &list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) - { - // NOTE: enemy may be empty - float rating = 0.f; - for (std::vector::const_iterator it = list.mList.begin(); it != list.mList.end(); ++it) - { - rating += rateEffect(*it, actor, enemy); - } - return rating; + return distance * 4; } void ActionSpell::prepare(const MWWorld::Ptr &actor) @@ -436,7 +56,7 @@ namespace MWMechanics const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().find(mSpellId); int types = getRangeTypes(spell->mEffects); - isRanged = (types & Target); + isRanged = (types & RangeTypes::Target) | (types & RangeTypes::Self); return suggestCombatRange(types); } @@ -451,12 +71,15 @@ namespace MWMechanics { const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get().find(mItem->getClass().getEnchantment(*mItem)); int types = getRangeTypes(enchantment->mEffects); + + isRanged = (types & RangeTypes::Target) | (types & RangeTypes::Self); return suggestCombatRange(types); } float ActionPotion::getCombatRange(bool& isRanged) const { - // distance doesn't matter, so back away slightly to avoid enemy hits + // Distance doesn't matter since this action has no animation + // If we want to back away slightly to avoid enemy hits, we should set isRanged to "true" return 600.f; } @@ -518,14 +141,14 @@ namespace MWMechanics return mWeapon.get()->mBase; } - boost::shared_ptr prepareNextAction(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) + std::shared_ptr prepareNextAction(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) { Spells& spells = actor.getClass().getCreatureStats(actor).getSpells(); float bestActionRating = 0.f; float antiFleeRating = 0.f; // Default to hand-to-hand combat - boost::shared_ptr bestAction (new ActionWeapon(MWWorld::Ptr())); + std::shared_ptr bestAction (new ActionWeapon(MWWorld::Ptr())); if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { bestAction->prepare(actor); @@ -629,6 +252,79 @@ namespace MWMechanics return bestAction; } + float getBestActionRating(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) + { + Spells& spells = actor.getClass().getCreatureStats(actor).getSpells(); + + float bestActionRating = 0.f; + // Default to hand-to-hand combat + if (actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) + { + return bestActionRating; + } + + if (actor.getClass().hasInventoryStore(actor)) + { + MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor); + + for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) + { + float rating = rateMagicItem(*it, actor, enemy); + if (rating > bestActionRating) + { + bestActionRating = rating; + } + } + + float bestArrowRating = 0; + for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) + { + float rating = rateWeapon(*it, actor, enemy, ESM::Weapon::Arrow); + if (rating > bestArrowRating) + { + bestArrowRating = rating; + } + } + + float bestBoltRating = 0; + for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) + { + float rating = rateWeapon(*it, actor, enemy, ESM::Weapon::Bolt); + if (rating > bestBoltRating) + { + bestBoltRating = rating; + } + } + + for (MWWorld::ContainerStoreIterator it = store.begin(); it != store.end(); ++it) + { + std::vector equipmentSlots = it->getClass().getEquipmentSlots(*it).first; + if (std::find(equipmentSlots.begin(), equipmentSlots.end(), (int)MWWorld::InventoryStore::Slot_CarriedRight) + == equipmentSlots.end()) + continue; + + float rating = rateWeapon(*it, actor, enemy, -1, bestArrowRating, bestBoltRating); + if (rating > bestActionRating) + { + bestActionRating = rating; + } + } + } + + for (Spells::TIterator it = spells.begin(); it != spells.end(); ++it) + { + const ESM::Spell* spell = it->first; + + float rating = rateSpell(spell, actor, enemy); + if (rating > bestActionRating) + { + bestActionRating = rating; + } + } + + return bestActionRating; + } + float getDistanceMinusHalfExtents(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool minusZDist) { @@ -685,7 +381,7 @@ namespace MWMechanics for (std::vector::const_iterator effectIt = spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt) { - if (effectIt->mArea == ESM::RT_Target) + if (effectIt->mRange == ESM::RT_Target) { const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get().find(effectIt->mEffectID); dist = effect->mData.mSpeed; @@ -702,7 +398,7 @@ namespace MWMechanics for (std::vector::const_iterator effectIt = ench->mEffects.mList.begin(); effectIt != ench->mEffects.mList.end(); ++effectIt) { - if (effectIt->mArea == ESM::RT_Target) + if (effectIt->mRange == ESM::RT_Target) { const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().get().find(effectIt->mEffectID); dist = effect->mData.mSpeed; @@ -813,67 +509,6 @@ namespace MWMechanics return true; } - float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) - { - const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); - - static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->getFloat(); - static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->getFloat(); - - float mult = fAIMagicSpellMult; - - for (std::vector::const_iterator effectIt = - spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt) - { - if (effectIt->mArea == ESM::RT_Target) - { - if (!MWBase::Environment::get().getWorld()->isSwimming(enemy)) - mult = fAIRangeMagicSpellMult; - else - mult = 0.0f; - break; - } - } - - return MWMechanics::getSpellSuccessChance(spell, actor) * mult; - } - - float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) - { - const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); - - static const float fAIMeleeWeaponMult = gmst.find("fAIMeleeWeaponMult")->getFloat(); - static const float fAIMeleeArmorMult = gmst.find("fAIMeleeArmorMult")->getFloat(); - static const float fAIRangeMeleeWeaponMult = gmst.find("fAIRangeMeleeWeaponMult")->getFloat(); - - if (weapon.isEmpty()) - return 0.f; - - float skillMult = actor.getClass().getSkill(actor, weapon.getClass().getEquipmentSkill(weapon)) * 0.01f; - float chopMult = fAIMeleeWeaponMult; - float bonusDamage = 0.f; - - const ESM::Weapon* esmWeap = weapon.get()->mBase; - - if (esmWeap->mData.mType >= ESM::Weapon::MarksmanBow) - { - if (!ammo.isEmpty() && !MWBase::Environment::get().getWorld()->isSwimming(enemy)) - { - bonusDamage = ammo.get()->mBase->mData.mChop[1]; - chopMult = fAIRangeMeleeWeaponMult; - } - else - chopMult = 0.f; - } - - float chopRating = (esmWeap->mData.mChop[1] + bonusDamage) * skillMult * chopMult; - float slashRating = esmWeap->mData.mSlash[1] * skillMult * fAIMeleeWeaponMult; - float thrustRating = esmWeap->mData.mThrust[1] * skillMult * fAIMeleeWeaponMult; - - return actor.getClass().getArmorRating(actor) * fAIMeleeArmorMult - + std::max(std::max(chopRating, slashRating), thrustRating); - } - float vanillaRateFlee(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) { const CreatureStats& stats = actor.getClass().getCreatureStats(actor); @@ -919,5 +554,4 @@ namespace MWMechanics return false; } - } diff --git a/apps/openmw/mwmechanics/aicombataction.hpp b/apps/openmw/mwmechanics/aicombataction.hpp index 0f1f7dd5b..466ae2dc4 100644 --- a/apps/openmw/mwmechanics/aicombataction.hpp +++ b/apps/openmw/mwmechanics/aicombataction.hpp @@ -1,7 +1,7 @@ #ifndef OPENMW_AICOMBAT_ACTION_H #define OPENMW_AICOMBAT_ACTION_H -#include +#include #include @@ -10,7 +10,6 @@ namespace MWMechanics { - class Action { public: @@ -55,7 +54,7 @@ namespace MWMechanics virtual float getCombatRange (bool& isRanged) const; /// Since this action has no animation, apply a small cool down for using it - virtual float getActionCooldown() { return 1.f; } + virtual float getActionCooldown() { return 0.75f; } }; class ActionPotion : public Action @@ -69,7 +68,7 @@ namespace MWMechanics virtual bool isAttackingOrSpell() const { return false; } /// Since this action has no animation, apply a small cool down for using it - virtual float getActionCooldown() { return 1.f; } + virtual float getActionCooldown() { return 0.75f; } }; class ActionWeapon : public Action @@ -88,26 +87,13 @@ namespace MWMechanics virtual const ESM::Weapon* getWeapon() const; }; - float rateSpell (const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); - float rateMagicItem (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); - float ratePotion (const MWWorld::Ptr& item, const MWWorld::Ptr &actor); - /// @param type Skip all weapons that are not of this type (i.e. return rating 0) - float rateWeapon (const MWWorld::Ptr& item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, - int type=-1, float arrowRating=0.f, float boltRating=0.f); - - /// @note target may be empty - float rateEffect (const ESM::ENAMstruct& effect, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); - /// @note target may be empty - float rateEffects (const ESM::EffectList& list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); - - boost::shared_ptr prepareNextAction (const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + std::shared_ptr prepareNextAction (const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + float getBestActionRating(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy); float getDistanceMinusHalfExtents(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, bool minusZDist=false); float getMaxAttackDistance(const MWWorld::Ptr& actor); bool canFight(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); - float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); - float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); float vanillaRateFlee(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); bool makeFleeDecision(const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, float antiFleeRating); } diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 4c9b5fd4f..103ef32e1 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -126,7 +126,7 @@ namespace MWMechanics void AiEscort::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::auto_ptr escort(new ESM::AiSequence::AiEscort()); + std::unique_ptr escort(new ESM::AiSequence::AiEscort()); escort->mData.mX = mX; escort->mData.mY = mY; escort->mData.mZ = mZ; diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index fd3014298..fd5f9c7fe 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -22,8 +22,15 @@ struct AiFollowStorage : AiTemporaryBase { float mTimer; bool mMoving; - - AiFollowStorage() : mTimer(0.f), mMoving(false) {} + float mTargetAngleRadians; + bool mTurnActorToTarget; + + AiFollowStorage() : + mTimer(0.f), + mMoving(false), + mTargetAngleRadians(0.f), + mTurnActorToTarget(false) + {} }; int AiFollow::mFollowIndexCounter = 0; @@ -73,6 +80,15 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte AiFollowStorage& storage = state.get(); + bool& rotate = storage.mTurnActorToTarget; + if (rotate) + { + if (zTurn(actor, storage.mTargetAngleRadians)) + rotate = false; + + return false; + } + // AiFollow requires the target to be in range and within sight for the initial activation if (!mActive) { @@ -144,13 +160,33 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte //Set the target destination from the actor ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos; - if (!storage.mMoving) - { - const short threshold = 10; // to avoid constant switching between moving/stopping + short baseFollowDistance = followDistance; + short threshold = 30; // to avoid constant switching between moving/stopping + if (storage.mMoving) + followDistance -= threshold; + else followDistance += threshold; + + osg::Vec3f targetPos(target.getRefData().getPosition().asVec3()); + osg::Vec3f actorPos(actor.getRefData().getPosition().asVec3()); + + osg::Vec3f dir = targetPos - actorPos; + float targetDistSqr = dir.length2(); + + if (targetDistSqr <= followDistance * followDistance) + { + float faceAngleRadians = std::atan2(dir.x(), dir.y()); + + if (!zTurn(actor, faceAngleRadians, osg::DegreesToRadians(45.f))) + { + storage.mTargetAngleRadians = faceAngleRadians; + storage.mTurnActorToTarget = true; + } + + return false; } - storage.mMoving = !pathTo(actor, dest, duration, followDistance); // Go to the destination + storage.mMoving = !pathTo(actor, dest, duration, baseFollowDistance); // Go to the destination if (storage.mMoving) { @@ -188,7 +224,7 @@ bool AiFollow::isCommanded() const void AiFollow::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::auto_ptr follow(new ESM::AiSequence::AiFollow()); + std::unique_ptr follow(new ESM::AiSequence::AiFollow()); follow->mData.mX = mX; follow->mData.mY = mY; follow->mData.mZ = mZ; diff --git a/apps/openmw/mwmechanics/aipackage.cpp b/apps/openmw/mwmechanics/aipackage.cpp index abdc57042..f837ad2ee 100644 --- a/apps/openmw/mwmechanics/aipackage.cpp +++ b/apps/openmw/mwmechanics/aipackage.cpp @@ -12,6 +12,7 @@ #include "../mwworld/action.hpp" #include "../mwworld/class.hpp" #include "../mwworld/cellstore.hpp" +#include "../mwworld/inventorystore.hpp" #include "creaturestats.hpp" #include "movement.hpp" @@ -175,14 +176,42 @@ void MWMechanics::AiPackage::evadeObstacles(const MWWorld::Ptr& actor, float dur if (!mObstacleCheck.check(actor, duration)) return; // first check if obstacle is a door - MWWorld::Ptr door = getNearbyDoor(actor); // NOTE: checks interior cells only + static float distance = MWBase::Environment::get().getWorld()->getMaxActivationDistance(); + + MWWorld::Ptr door = getNearbyDoor(actor, distance); if (door != MWWorld::Ptr()) { // note: AiWander currently does not open doors - if (getTypeId() != TypeIdWander && !door.getCellRef().getTeleport() && door.getCellRef().getTrap().empty() - && door.getCellRef().getLockLevel() <= 0 && door.getClass().getDoorState(door) == 0) + if (getTypeId() != TypeIdWander && !door.getCellRef().getTeleport() && door.getClass().getDoorState(door) == 0) { - MWBase::Environment::get().getWorld()->activateDoor(door, 1); + if ((door.getCellRef().getTrap().empty() && door.getCellRef().getLockLevel() <= 0 )) + { + MWBase::Environment::get().getWorld()->activate(door, actor); + return; + } + + std::string keyId = door.getCellRef().getKey(); + if (keyId.empty()) + return; + + bool hasKey = false; + const MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor); + + // make key id lowercase + Misc::StringUtils::lowerCaseInPlace(keyId); + for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it) + { + std::string refId = it->getCellRef().getRefId(); + Misc::StringUtils::lowerCaseInPlace(refId); + if (refId == keyId) + { + hasKey = true; + break; + } + } + + if (hasKey) + MWBase::Environment::get().getWorld()->activate(door, actor); } } else // any other obstacle (NPC, crate, etc.) diff --git a/apps/openmw/mwmechanics/aipackage.hpp b/apps/openmw/mwmechanics/aipackage.hpp index 5e23e085e..acbd87908 100644 --- a/apps/openmw/mwmechanics/aipackage.hpp +++ b/apps/openmw/mwmechanics/aipackage.hpp @@ -41,12 +41,13 @@ namespace MWMechanics TypeIdFollow = 3, TypeIdActivate = 4, - // These 4 are not really handled as Ai Packages in the MW engine + // These 5 are not really handled as Ai Packages in the MW engine // For compatibility do *not* return these in the getCurrentAiPackage script function.. TypeIdCombat = 5, TypeIdPursue = 6, TypeIdAvoidDoor = 7, - TypeIdFace = 8 + TypeIdFace = 8, + TypeIdBreathe = 9 }; ///Default constructor diff --git a/apps/openmw/mwmechanics/aipursue.cpp b/apps/openmw/mwmechanics/aipursue.cpp index 2b218de03..f9884eb6d 100644 --- a/apps/openmw/mwmechanics/aipursue.cpp +++ b/apps/openmw/mwmechanics/aipursue.cpp @@ -73,7 +73,7 @@ MWWorld::Ptr AiPursue::getTarget() const void AiPursue::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::auto_ptr pursue(new ESM::AiSequence::AiPursue()); + std::unique_ptr pursue(new ESM::AiSequence::AiPursue()); pursue->mTargetActorId = mTargetActorId; ESM::AiSequence::AiPackageContainer package; diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 84c8eca49..2a2d598f5 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -16,6 +16,7 @@ #include "aifollow.hpp" #include "aiactivate.hpp" #include "aicombat.hpp" +#include "aicombataction.hpp" #include "aipursue.hpp" #include "actorutil.hpp" @@ -96,16 +97,16 @@ std::list::const_iterator AiSequence::end() const return mPackages.end(); } -std::list::const_iterator AiSequence::erase(std::list::const_iterator package) +void AiSequence::erase(std::list::const_iterator package) { // Not sure if manually terminated packages should trigger mDone, probably not? for(std::list::iterator it = mPackages.begin(); it != mPackages.end(); ++it) { if (package == it) { - AiPackage* packagePtr = *it; - delete packagePtr; - return mPackages.erase(it); + delete *it; + mPackages.erase(it); + return; } } throw std::runtime_error("can't find package to erase"); @@ -121,6 +122,16 @@ bool AiSequence::isInCombat() const return false; } +bool AiSequence::hasPackage(int typeId) const +{ + for (std::list::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it) + { + if ((*it)->getTypeId() == typeId) + return true; + } + return false; +} + bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const { for(std::list::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it) @@ -172,7 +183,8 @@ bool isActualAiPackage(int packageTypeId) return (packageTypeId != AiPackage::TypeIdCombat && packageTypeId != AiPackage::TypeIdPursue && packageTypeId != AiPackage::TypeIdAvoidDoor - && packageTypeId != AiPackage::TypeIdFace); + && packageTypeId != AiPackage::TypeIdFace + && packageTypeId != AiPackage::TypeIdBreathe); } void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) @@ -198,6 +210,8 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac float nearestDist = std::numeric_limits::max(); osg::Vec3f vActorPos = actor.getRefData().getPosition().asVec3(); + float bestRating = 0.f; + for(std::list::iterator it = mPackages.begin(); it != mPackages.end();) { if ((*it)->getTypeId() != AiPackage::TypeIdCombat) break; @@ -212,6 +226,8 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac } else { + float rating = MWMechanics::getBestActionRating(actor, target); + const ESM::Position &targetPos = target.getRefData().getPosition(); float distTo = (targetPos.asVec3() - vActorPos).length(); @@ -220,10 +236,12 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac if (it == mPackages.begin()) distTo = std::max(0.f, distTo - 50.f); - if (distTo < nearestDist) + // if a target has higher priority than current target or has same priority but closer + if (rating > bestRating || ((distTo < nearestDist) && rating == bestRating)) { nearestDist = distTo; itActualCombat = it; + bestRating = rating; } ++it; } @@ -285,21 +303,6 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor) if (actor == getPlayer()) throw std::runtime_error("Can't add AI packages to player"); - if (package.getTypeId() == AiPackage::TypeIdCombat || package.getTypeId() == AiPackage::TypeIdPursue) - { - // Notify AiWander of our current position so we can return to it after combat finished - for (std::list::const_iterator iter (mPackages.begin()); iter!=mPackages.end(); ++iter) - { - if((*iter)->getTypeId() == AiPackage::TypeIdCombat && package.getTypeId() == AiPackage::TypeIdCombat - && (*iter)->getTarget() == (&package)->getTarget()) - { - return; // already in combat with this actor - } - else if ((*iter)->getTypeId() == AiPackage::TypeIdWander) - static_cast(*iter)->setReturnPosition(actor.getRefData().getPosition().asVec3()); - } - } - // Stop combat when a non-combat AI package is added if (isActualAiPackage(package.getTypeId())) stopCombat(); @@ -412,7 +415,7 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence) for (std::vector::const_iterator it = sequence.mPackages.begin(); it != sequence.mPackages.end(); ++it) { - std::auto_ptr package (NULL); + std::unique_ptr package (nullptr); switch (it->mType) { case ESM::AiSequence::Ai_Wander: diff --git a/apps/openmw/mwmechanics/aisequence.hpp b/apps/openmw/mwmechanics/aisequence.hpp index 4f8b542a4..41d204ee2 100644 --- a/apps/openmw/mwmechanics/aisequence.hpp +++ b/apps/openmw/mwmechanics/aisequence.hpp @@ -64,7 +64,7 @@ namespace MWMechanics std::list::const_iterator begin() const; std::list::const_iterator end() const; - std::list::const_iterator erase (std::list::const_iterator package); + void erase (std::list::const_iterator package); /// Returns currently executing AiPackage type /** \see enum AiPackage::TypeId **/ @@ -85,6 +85,9 @@ namespace MWMechanics /// Is there any combat package? bool isInCombat () const; + /// Does this AI sequence have the given package type? + bool hasPackage(int typeId) const; + /// Are we in combat with this particular actor? bool isInCombat (const MWWorld::Ptr& actor) const; diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index 7cef7aff1..36b96101f 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -79,7 +79,7 @@ namespace MWMechanics void AiTravel::writeState(ESM::AiSequence::AiSequence &sequence) const { - std::auto_ptr travel(new ESM::AiSequence::AiTravel()); + std::unique_ptr travel(new ESM::AiSequence::AiTravel()); travel->mData.mX = mX; travel->mData.mY = mY; travel->mData.mZ = mZ; diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 5396b5b39..b44b187ad 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -113,7 +113,7 @@ namespace MWMechanics AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector& idle, bool repeat): mDistance(distance), mDuration(duration), mRemainingDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle), - mRepeat(repeat), mStoredInitialActorPosition(false) + mRepeat(repeat), mStoredInitialActorPosition(false), mInitialActorPosition(osg::Vec3f(0, 0, 0)), mHasDestination(false), mDestination(osg::Vec3f(0, 0, 0)) { mIdle.resize(8, 0); init(); @@ -123,9 +123,6 @@ namespace MWMechanics { // NOTE: mDistance and mDuration must be set already - mHasReturnPosition = false; - mReturnPosition = osg::Vec3f(0,0,0); - if(mDistance < 0) mDistance = 0; if(mDuration < 0) @@ -211,6 +208,19 @@ namespace MWMechanics cStats.setMovementFlag(CreatureStats::Flag_Run, false); ESM::Position pos = actor.getRefData().getPosition(); + + // If there is already a destination due to the package having been interrupted by a combat or pursue package, + // rebuild a path to it + if (!mPathFinder.isPathConstructed() && mHasDestination) + { + ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(mDestination)); + ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos)); + + mPathFinder.buildSyncedPath(start, dest, actor.getCell()); + + if (mPathFinder.isPathConstructed()) + storage.setState(Wander_Walking); + } doPerFrameActionsForState(actor, duration, storage, pos); @@ -253,9 +263,8 @@ namespace MWMechanics getAllowedNodes(actor, currentCell->getCell(), storage); } - // Actor becomes stationary - see above URL's for previous research - // If a creature or an NPC with a wander distance and no pathgrid is available, - // randomly idle or wander around near spawn point + // If the package has a wander distance but no pathgrid is available, + // randomly idle or wander near spawn point if(storage.mAllowedNodes.empty() && mDistance > 0 && !storage.mIsWanderingManually) { // Typically want to idle for a short time before the next wander if (Misc::Rng::rollDice(100) >= 96) { @@ -277,10 +286,8 @@ namespace MWMechanics mDistance = 0; // For stationary NPCs, move back to the starting location if another AiPackage moved us elsewhere - if (cellChange) - mHasReturnPosition = false; - if (mDistance == 0 && mHasReturnPosition - && (pos.asVec3() - mReturnPosition).length2() > (DESTINATION_TOLERANCE * DESTINATION_TOLERANCE)) + if (mDistance == 0 && !cellChange + && (pos.asVec3() - mInitialActorPosition).length2() > (DESTINATION_TOLERANCE * DESTINATION_TOLERANCE)) { returnToStartLocation(actor, storage, pos); } @@ -334,7 +341,8 @@ namespace MWMechanics { if (!mPathFinder.isPathConstructed()) { - ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(mReturnPosition)); + mDestination = mInitialActorPosition; + ESM::Pathgrid::Point dest(PathFinder::MakePathgridPoint(mDestination)); // actor position is already in world coordinates ESM::Pathgrid::Point start(PathFinder::MakePathgridPoint(pos)); @@ -345,6 +353,7 @@ namespace MWMechanics if (mPathFinder.isPathConstructed()) { storage.setState(Wander_Walking); + mHasDestination = true; } } } @@ -357,7 +366,6 @@ namespace MWMechanics const osg::Vec3f currentPositionVec3f = osg::Vec3f(currentPosition.mX, currentPosition.mY, currentPosition.mZ); std::size_t attempts = 10; // If a unit can't wander out of water, don't want to hang here - osg::Vec3f destination; ESM::Pathgrid::Point destinationPosition; bool isWaterCreature = actor.getClass().isPureWaterCreature(actor); do { @@ -369,17 +377,18 @@ namespace MWMechanics const float destinationY = mInitialActorPosition.y() + wanderRadius * std::sin(randomDirection); const float destinationZ = mInitialActorPosition.z(); destinationPosition = ESM::Pathgrid::Point(destinationX, destinationY, destinationZ); - destination = osg::Vec3f(destinationX, destinationY, destinationZ); + mDestination = osg::Vec3f(destinationX, destinationY, destinationZ); // Check if land creature will walk onto water or if water creature will swim onto land - if ((!isWaterCreature && !destinationIsAtWater(actor, destination)) || - (isWaterCreature && !destinationThroughGround(currentPositionVec3f, destination))) { + if ((!isWaterCreature && !destinationIsAtWater(actor, mDestination)) || + (isWaterCreature && !destinationThroughGround(currentPositionVec3f, mDestination))) { mPathFinder.buildSyncedPath(currentPosition, destinationPosition, actor.getCell()); mPathFinder.addPointToPath(destinationPosition); if (mPathFinder.isPathConstructed()) { storage.setState(Wander_Walking, true); + mHasDestination = true; } return; } @@ -440,11 +449,14 @@ namespace MWMechanics { // Check if an idle actor is too close to a door - if so start walking storage.mDoorCheckDuration += duration; + + static float distance = MWBase::Environment::get().getWorld()->getMaxActivationDistance(); + if (storage.mDoorCheckDuration >= DOOR_CHECK_INTERVAL) { storage.mDoorCheckDuration = 0; // restart timer if (mDistance && // actor is not intended to be stationary - proximityToDoor(actor, MIN_DIST_TO_DOOR_SQUARED*1.6f*1.6f)) // NOTE: checks interior cells only + proximityToDoor(actor, distance*1.6f)) { storage.setState(Wander_MoveNow); storage.mTrimCurrentNode = false; // just in case @@ -466,7 +478,10 @@ namespace MWMechanics GreetingState& greetingState = storage.mSaidGreeting; if (!checkIdle(actor, storage.mIdleAnimation) && (greetingState == Greet_Done || greetingState == Greet_None)) { - storage.setState(Wander_ChooseAction); + if (mPathFinder.isPathConstructed()) + storage.setState(Wander_Walking); + else + storage.setState(Wander_ChooseAction); } } @@ -474,11 +489,10 @@ namespace MWMechanics float duration, AiWanderStorage& storage, ESM::Position& pos) { // Is there no destination or are we there yet? - if ((!mPathFinder.isPathConstructed()) || pathTo(actor, mPathFinder.getPath().back(), duration, DESTINATION_TOLERANCE)) + if ((!mPathFinder.isPathConstructed()) || pathTo(actor, ESM::Pathgrid::Point(mPathFinder.getPath().back()), duration, DESTINATION_TOLERANCE)) { stopWalking(actor, storage); storage.setState(Wander_ChooseAction); - mHasReturnPosition = false; } else { @@ -490,8 +504,8 @@ namespace MWMechanics void AiWander::onChooseActionStatePerFrameActions(const MWWorld::Ptr& actor, AiWanderStorage& storage) { - short unsigned& idleAnimation = storage.mIdleAnimation; - idleAnimation = getRandomIdle(); + unsigned short idleAnimation = getRandomIdle(); + storage.mIdleAnimation = idleAnimation; if (!idleAnimation && mDistance) { @@ -516,16 +530,18 @@ namespace MWMechanics void AiWander::evadeObstacles(const MWWorld::Ptr& actor, AiWanderStorage& storage, float duration, ESM::Position& pos) { + static float distance = MWBase::Environment::get().getWorld()->getMaxActivationDistance(); + if (mObstacleCheck.isEvading()) { // first check if we're walking into a door - if (proximityToDoor(actor)) // NOTE: checks interior cells only + if (proximityToDoor(actor, distance)) { // remove allowed points then select another random destination storage.mTrimCurrentNode = true; trimAllowedNodes(storage.mAllowedNodes, mPathFinder); mObstacleCheck.clear(); - mPathFinder.clearPath(); + stopWalking(actor, storage); storage.setState(Wander_MoveNow); } @@ -535,9 +551,7 @@ namespace MWMechanics // if stuck for sufficiently long, act like current location was the destination if (storage.mStuckCount >= COUNT_BEFORE_RESET) // something has gone wrong, reset { - //std::cout << "Reset \""<< cls.getName(actor) << "\"" << std::endl; mObstacleCheck.clear(); - stopWalking(actor, storage); storage.setState(Wander_ChooseAction); storage.mStuckCount = 0; @@ -612,7 +626,7 @@ namespace MWMechanics if (storage.mState == Wander_Walking) { - stopWalking(actor, storage); + stopWalking(actor, storage, false); mObstacleCheck.clear(); storage.setState(Wander_IdleNow); } @@ -657,6 +671,8 @@ namespace MWMechanics if (mPathFinder.isPathConstructed()) { + mDestination = osg::Vec3f(dest.mX, dest.mY, dest.mZ); + mHasDestination = true; // Remove this node as an option and add back the previously used node (stops NPC from picking the same node): ESM::Pathgrid::Point temp = storage.mAllowedNodes[randNode]; storage.mAllowedNodes.erase(storage.mAllowedNodes.begin() + randNode); @@ -710,9 +726,13 @@ namespace MWMechanics return TypeIdWander; } - void AiWander::stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage) + void AiWander::stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage, bool clearPath) { - mPathFinder.clearPath(); + if (clearPath) + { + mPathFinder.clearPath(); + mHasDestination = false; + } actor.getClass().getMovementSettings(actor).mPosition[1] = 0; } @@ -743,15 +763,6 @@ namespace MWMechanics } } - void AiWander::setReturnPosition(const osg::Vec3f& position) - { - if (!mHasReturnPosition) - { - mHasReturnPosition = true; - mReturnPosition = position; - } - } - short unsigned AiWander::getRandomIdle() { unsigned short idleRoll = 0; @@ -893,7 +904,7 @@ namespace MWMechanics storage.mAllowedNodes.push_back(PathFinder::MakePathgridPoint(vectorStart + delta)); } - void AiWander::SetCurrentNodeToClosestAllowedNode(osg::Vec3f npcPos, AiWanderStorage& storage) + void AiWander::SetCurrentNodeToClosestAllowedNode(const osg::Vec3f& npcPos, AiWanderStorage& storage) { float distanceToClosestNode = std::numeric_limits::max(); unsigned int index = 0; @@ -919,7 +930,7 @@ namespace MWMechanics else remainingDuration = mDuration; - std::auto_ptr wander(new ESM::AiSequence::AiWander()); + std::unique_ptr wander(new ESM::AiSequence::AiWander()); wander->mData.mDistance = mDistance; wander->mData.mDuration = mDuration; wander->mData.mTimeOfDay = mTimeOfDay; @@ -945,6 +956,8 @@ namespace MWMechanics , mTimeOfDay(wander->mData.mTimeOfDay) , mRepeat(wander->mData.mShouldRepeat != 0) , mStoredInitialActorPosition(wander->mStoredInitialActorPosition) + , mHasDestination(false) + , mDestination(osg::Vec3f(0, 0, 0)) { if (mStoredInitialActorPosition) mInitialActorPosition = wander->mInitialActorPosition; @@ -953,7 +966,6 @@ namespace MWMechanics if (mRemainingDuration <= 0 || mRemainingDuration >= 24) mRemainingDuration = mDuration; - init(); } } diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index f9b03ca5e..01d889e2f 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -44,10 +44,6 @@ namespace MWMechanics virtual int getTypeId() const; - /// Set the position to return to for a stationary (non-wandering) actor - /** In case another AI package moved the actor elsewhere **/ - void setReturnPosition (const osg::Vec3f& position); - virtual void writeState(ESM::AiSequence::AiSequence &sequence) const; virtual void fastForward(const MWWorld::Ptr& actor, AiState& state); @@ -70,7 +66,7 @@ namespace MWMechanics private: // NOTE: mDistance and mDuration must be set already void init(); - void stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage); + void stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage, bool clearPath = true); /// Have the given actor play an idle animation /// @return Success or error @@ -87,7 +83,7 @@ namespace MWMechanics void onWalkingStatePerFrameActions(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage, ESM::Position& pos); void onChooseActionStatePerFrameActions(const MWWorld::Ptr& actor, AiWanderStorage& storage); bool reactionTimeActions(const MWWorld::Ptr& actor, AiWanderStorage& storage, - const MWWorld::CellStore*& currentCell, bool cellChange, ESM::Position& pos, float duration); + const MWWorld::CellStore*& currentCell, bool cellChange, ESM::Position& pos, float duration); bool isPackageCompleted(const MWWorld::Ptr& actor, AiWanderStorage& storage); void returnToStartLocation(const MWWorld::Ptr& actor, AiWanderStorage& storage, ESM::Position& pos); void wanderNearStart(const MWWorld::Ptr &actor, AiWanderStorage &storage, int wanderDistance); @@ -102,11 +98,11 @@ namespace MWMechanics std::vector mIdle; bool mRepeat; - bool mHasReturnPosition; // NOTE: Could be removed if mReturnPosition was initialized to actor position, - // if we had the actor in the AiWander constructor... - osg::Vec3f mReturnPosition; - osg::Vec3f mInitialActorPosition; bool mStoredInitialActorPosition; + osg::Vec3f mInitialActorPosition; + + bool mHasDestination; + osg::Vec3f mDestination; void getAllowedNodes(const MWWorld::Ptr& actor, const ESM::Cell* cell, AiWanderStorage& storage); @@ -122,7 +118,7 @@ namespace MWMechanics /// convert point from local (i.e. cell) to world coordinates void ToWorldCoordinates(ESM::Pathgrid::Point& point, const ESM::Cell * cell); - void SetCurrentNodeToClosestAllowedNode(osg::Vec3f npcPos, AiWanderStorage& storage); + void SetCurrentNodeToClosestAllowedNode(const osg::Vec3f& npcPos, AiWanderStorage& storage); void AddNonPathGridAllowedPoints(osg::Vec3f npcPos, const ESM::Pathgrid * pathGrid, int pointIndex, AiWanderStorage& storage); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 783bbf573..124468641 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -171,10 +171,10 @@ void MWMechanics::Alchemy::updateEffects() if (fPotionT1DurMult<=0) throw std::runtime_error ("invalid gmst: fPotionT1DurMult"); - float magnitude = magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude ? - 1 : (x / fPotionT1MagMul) / magicEffect->mData.mBaseCost; - float duration = magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration ? - 1 : (x / fPotionT1DurMult) / magicEffect->mData.mBaseCost; + float magnitude = (magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude) ? + 1.0f : (x / fPotionT1MagMul) / magicEffect->mData.mBaseCost; + float duration = (magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration) ? + 1.0f : (x / fPotionT1DurMult) / magicEffect->mData.mBaseCost; if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) applyTools (magicEffect->mData.mFlags, magnitude); @@ -457,7 +457,9 @@ bool MWMechanics::Alchemy::knownEffect(unsigned int potionEffectIndex, const MWW static const float fWortChanceValue = MWBase::Environment::get().getWorld()->getStore().get().find("fWortChanceValue")->getFloat(); return (potionEffectIndex <= 1 && alchemySkill >= fWortChanceValue) - || (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue*2); + || (potionEffectIndex <= 3 && alchemySkill >= fWortChanceValue*2) + || (potionEffectIndex <= 5 && alchemySkill >= fWortChanceValue*3) + || (potionEffectIndex <= 7 && alchemySkill >= fWortChanceValue*4); } MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& name) diff --git a/apps/openmw/mwmechanics/autocalcspell.cpp b/apps/openmw/mwmechanics/autocalcspell.cpp index af814edb0..f655a68b4 100644 --- a/apps/openmw/mwmechanics/autocalcspell.cpp +++ b/apps/openmw/mwmechanics/autocalcspell.cpp @@ -1,4 +1,5 @@ #include "autocalcspell.hpp" +#include "spellcasting.hpp" #include #include @@ -255,27 +256,39 @@ namespace MWMechanics void calcWeakestSchool (const ESM::Spell* spell, const int* actorSkills, int& effectiveSchool, float& skillTerm) { + // Morrowind for some reason uses a formula slightly different from magicka cost calculation float minChance = std::numeric_limits::max(); const ESM::EffectList& effects = spell->mEffects; for (std::vector::const_iterator it = effects.mList.begin(); it != effects.mList.end(); ++it) { const ESM::ENAMstruct& effect = *it; - float x = static_cast(effect.mDuration); - const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); - if (!(magicEffect->mData.mFlags & ESM::MagicEffect::UncappedDamage)) - x = std::max(1.f, x); - x *= 0.1f * magicEffect->mData.mBaseCost; - x *= 0.5f * (effect.mMagnMin + effect.mMagnMax); - x += effect.mArea * 0.05f * magicEffect->mData.mBaseCost; - if (effect.mRange == ESM::RT_Target) - x *= 1.5f; + int minMagn = 1; + int maxMagn = 1; + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) + { + minMagn = effect.mMagnMin; + maxMagn = effect.mMagnMax; + } - static const float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore().get().find("fEffectCostMult")->getFloat(); + int duration = 0; + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) + duration = effect.mDuration; + + static const float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore() + .get().find("fEffectCostMult")->getFloat(); + + float x = 0.5 * (std::max(1, minMagn) + std::max(1, maxMagn)); + x *= 0.1 * magicEffect->mData.mBaseCost; + x *= 1 + duration; + x += 0.05 * std::max(1, effect.mArea) * magicEffect->mData.mBaseCost; x *= fEffectCostMult; + if (effect.mRange == ESM::RT_Target) + x *= 1.5f; + float s = 2.f * actorSkills[mapSchoolToSkill(magicEffect->mData.mSchool)]; if (s - x < minChance) { diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 85749d947..25d04d176 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1650,7 +1650,7 @@ void CharacterController::update(float duration) mSecondsOfSwimming -= 1; } } - else if(isrunning) + else if(isrunning && !sneak) { mSecondsOfRunning += duration; while(mSecondsOfRunning > 1) @@ -1673,9 +1673,10 @@ void CharacterController::update(float duration) static const float fFatigueSneakBase = gmst.find("fFatigueSneakBase")->getFloat(); static const float fFatigueSneakMult = gmst.find("fFatigueSneakMult")->getFloat(); - const float encumbrance = cls.getEncumbrance(mPtr) / cls.getCapacity(mPtr); - if (encumbrance < 1) + if (cls.getEncumbrance(mPtr) <= cls.getCapacity(mPtr)) { + const float encumbrance = cls.getEncumbrance(mPtr) / cls.getCapacity(mPtr); + if (sneak) fatigueLoss = fFatigueSneakBase + encumbrance * fFatigueSneakMult; else @@ -1687,7 +1688,7 @@ void CharacterController::update(float duration) else fatigueLoss = fFatigueSwimRunBase + encumbrance * fFatigueSwimRunMult; } - if (isrunning) + else if (isrunning) fatigueLoss = fFatigueRunBase + encumbrance * fFatigueRunMult; } } @@ -1753,7 +1754,7 @@ void CharacterController::update(float duration) float normalizedEncumbrance = mPtr.getClass().getNormalizedEncumbrance(mPtr); if (normalizedEncumbrance > 1) normalizedEncumbrance = 1; - const float fatigueDecrease = fatigueJumpBase + (1 - normalizedEncumbrance) * fatigueJumpMult; + const float fatigueDecrease = fatigueJumpBase + normalizedEncumbrance * fatigueJumpMult; if (!godmode) { @@ -2042,13 +2043,13 @@ bool CharacterController::playGroup(const std::string &groupname, int mode, int } else { - // If the given animation is a looped animation, is already playing - // and has not yet reached its Loop Stop key, make it the only animation - // in the queue, and retain the loop count from the animation that was - // already playing. This emulates observed behavior from the original - // engine and allows banners to animate correctly. + // If this animation is a looped animation (has a "loop start" key) that is already playing + // and has not yet reached the end of the loop, allow it to continue animating with its existing loop count + // and remove any other animations that were queued. + // This emulates observed behavior from the original allows the script "OutsideBanner" to animate banners correctly. if (!mAnimQueue.empty() && mAnimQueue.front().mGroup == groupname && - mAnimation->getTextKeyTime(mAnimQueue.front().mGroup+": loop start") >= 0) + mAnimation->getTextKeyTime(mAnimQueue.front().mGroup + ": loop start") >= 0 && + mAnimation->isPlaying(groupname)) { float endOfLoop = mAnimation->getTextKeyTime(mAnimQueue.front().mGroup+": loop stop"); @@ -2057,8 +2058,7 @@ bool CharacterController::playGroup(const std::string &groupname, int mode, int if (endOfLoop > 0 && (mAnimation->getCurrentTime(mAnimQueue.front().mGroup) < endOfLoop)) { - mAnimation->setLoopingEnabled(mAnimQueue.front().mGroup, true); - mAnimQueue.resize(1); + mAnimQueue.resize(1); return true; } } @@ -2237,12 +2237,24 @@ bool CharacterController::isSneaking() const mMovementState == CharState_SneakRight; } +bool CharacterController::isRunning() const +{ + return mMovementState == CharState_RunForward || + mMovementState == CharState_RunBack || + mMovementState == CharState_RunLeft || + mMovementState == CharState_RunRight || + mMovementState == CharState_SwimRunForward || + mMovementState == CharState_SwimRunBack || + mMovementState == CharState_SwimRunLeft || + mMovementState == CharState_SwimRunRight; +} + void CharacterController::setAttackingOrSpell(bool attackingOrSpell) { mAttackingOrSpell = attackingOrSpell; } -void CharacterController::setAIAttackType(std::string attackType) +void CharacterController::setAIAttackType(const std::string& attackType) { mAttackType = attackType; } diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index 9db127084..66039bf5d 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -266,9 +266,10 @@ public: bool isReadyToBlock() const; bool isKnockedOut() const; bool isSneaking() const; + bool isRunning() const; void setAttackingOrSpell(bool attackingOrSpell); - void setAIAttackType(std::string attackType); // set and used by AiCombat + void setAIAttackType(const std::string& attackType); static void setAttackTypeRandomly(std::string& attackType); bool readyToPrepareAttack() const; diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index 57ece6a79..a658c379a 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -21,7 +21,7 @@ namespace MWMechanics , mSelfEnchanting(false) {} - void Enchanting::setOldItem(MWWorld::Ptr oldItem) + void Enchanting::setOldItem(const MWWorld::Ptr& oldItem) { mOldItemPtr=oldItem; if(!itemEmpty()) @@ -39,7 +39,7 @@ namespace MWMechanics mNewItemName=s; } - void Enchanting::setEffect(ESM::EffectList effectList) + void Enchanting::setEffect(const ESM::EffectList& effectList) { mEffectList=effectList; } @@ -49,7 +49,7 @@ namespace MWMechanics return mCastStyle; } - void Enchanting::setSoulGem(MWWorld::Ptr soulGem) + void Enchanting::setSoulGem(const MWWorld::Ptr& soulGem) { mSoulGemPtr=soulGem; } @@ -172,14 +172,14 @@ namespace MWMechanics const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); std::vector mEffects = mEffectList.mList; - float enchantmentCost = 0; - int effectsLeftCnt = mEffects.size(); + int enchantmentCost = 0; + float cost = 0; for (std::vector::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { float baseCost = (store.get().find(it->mEffectID))->mData.mBaseCost; - int magMin = (it->mMagnMin == 0) ? 1 : it->mMagnMin; - int magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax; - int area = (it->mArea == 0) ? 1 : it->mArea; + int magMin = std::max(1, it->mMagnMin); + int magMax = std::max(1, it->mMagnMax); + int area = std::max(1, it->mArea); float magnitudeCost = (magMin + magMax) * baseCost * 0.05f; if (mCastStyle == ESM::Enchantment::ConstantEffect) @@ -195,16 +195,17 @@ namespace MWMechanics const float fEffectCostMult = store.get().find("fEffectCostMult")->getFloat(); - float cost = (magnitudeCost + areaCost) * fEffectCostMult; + cost += (magnitudeCost + areaCost) * fEffectCostMult; + + cost = std::max(1.f, cost); + if (it->mRange == ESM::RT_Target) cost *= 1.5; - enchantmentCost += cost * effectsLeftCnt; - enchantmentCost = std::max(1.f, enchantmentCost); - --effectsLeftCnt; + enchantmentCost += static_cast(cost); } - return static_cast(enchantmentCost); + return enchantmentCost; } @@ -269,7 +270,7 @@ namespace MWMechanics mSelfEnchanting = selfEnchanting; } - void Enchanting::setEnchanter(MWWorld::Ptr enchanter) + void Enchanting::setEnchanter(const MWWorld::Ptr& enchanter) { mEnchanter = enchanter; } diff --git a/apps/openmw/mwmechanics/enchanting.hpp b/apps/openmw/mwmechanics/enchanting.hpp index a53027bb9..8e3b00e5a 100644 --- a/apps/openmw/mwmechanics/enchanting.hpp +++ b/apps/openmw/mwmechanics/enchanting.hpp @@ -29,14 +29,14 @@ namespace MWMechanics public: Enchanting(); - void setEnchanter(MWWorld::Ptr enchanter); + void setEnchanter(const MWWorld::Ptr& enchanter); void setSelfEnchanting(bool selfEnchanting); - void setOldItem(MWWorld::Ptr oldItem); + void setOldItem(const MWWorld::Ptr& oldItem); MWWorld::Ptr getOldItem() { return mOldItemPtr; } MWWorld::Ptr getGem() { return mSoulGemPtr; } void setNewItemName(const std::string& s); - void setEffect(ESM::EffectList effectList); - void setSoulGem(MWWorld::Ptr soulGem); + void setEffect(const ESM::EffectList& effectList); + void setSoulGem(const MWWorld::Ptr& soulGem); bool create(); //Return true if created, false if failed. void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object) int getCastStyle() const; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 34269d793..68115301f 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -13,6 +13,7 @@ #include "../mwworld/inventorystore.hpp" #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" +#include "../mwworld/ptr.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -328,12 +329,16 @@ namespace MWMechanics winMgr->setValue(fbar, stats.getFatigue()); } - if(stats.getTimeToStartDrowning() != mWatchedTimeToStartDrowning) + float timeToDrown = stats.getTimeToStartDrowning(); + + if(timeToDrown != mWatchedTimeToStartDrowning) { - const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get() + static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get() .find("fHoldBreathTime")->getFloat(); - mWatchedTimeToStartDrowning = stats.getTimeToStartDrowning(); - if(stats.getTimeToStartDrowning() >= fHoldBreathTime) + + mWatchedTimeToStartDrowning = timeToDrown; + + if(timeToDrown >= fHoldBreathTime || timeToDrown == -1.0) // -1.0 is a special value during initialization winMgr->setDrowningBarVisibility(false); else { @@ -418,6 +423,16 @@ namespace MWMechanics mObjects.update(duration, paused); } + bool MechanicsManager::isRunning(const MWWorld::Ptr& ptr) + { + return mActors.isRunning(ptr); + } + + bool MechanicsManager::isSneaking(const MWWorld::Ptr& ptr) + { + return mActors.isSneaking(ptr); + } + void MechanicsManager::rest(bool sleep) { mActors.rest(sleep); @@ -815,8 +830,17 @@ namespace MWMechanics mAI = true; } - bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim) + bool MechanicsManager::isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim) { + const MWWorld::CellRef& cellref = item.getCellRef(); + // there is no harm to use unlocked doors + if (item.getClass().isDoor() && cellref.getLockLevel() <= 0 && ptr.getCellRef().getTrap().empty()) + return true; + + // TODO: implement a better check to check if item is owned bed + if (item.getClass().isActivator() && item.getClass().getScript(item).compare(0, 3, "Bed") != 0) + return true; + const std::string& owner = cellref.getOwner(); bool isOwned = !owner.empty() && owner != "player"; @@ -858,7 +882,7 @@ namespace MWMechanics } MWWorld::Ptr victim; - if (isAllowedToUse(ptr, bed.getCellRef(), victim)) + if (isAllowedToUse(ptr, bed, victim)) return false; if(commitCrime(ptr, victim, OT_SleepingInOwnedBed)) @@ -873,7 +897,7 @@ namespace MWMechanics void MechanicsManager::objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item) { MWWorld::Ptr victim; - if (isAllowedToUse(ptr, item.getCellRef(), victim)) + if (isAllowedToUse(ptr, item, victim)) return; commitCrime(ptr, victim, OT_Trespassing); } @@ -903,6 +927,43 @@ namespace MWMechanics return ownerFound != owners.end(); } + void MechanicsManager::confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count) + { + if (player != getPlayer()) + return; + + const std::string itemId = Misc::StringUtils::lowerCase(item.getCellRef().getRefId()); + + StolenItemsMap::iterator stolenIt = mStolenItems.find(itemId); + if (stolenIt == mStolenItems.end()) + return; + + Owner owner; + owner.first = victim.getCellRef().getRefId(); + owner.second = false; + + Misc::StringUtils::lowerCaseInPlace(owner.first); + + // decrease count of stolen items + int toRemove = std::min(count, mStolenItems[itemId][owner]); + mStolenItems[itemId][owner] -= toRemove; + if (mStolenItems[itemId][owner] == 0) + { + // erase owner from stolen items owners + OwnerMap& owners = stolenIt->second; + OwnerMap::iterator ownersIt = owners.find(owner); + if (ownersIt != owners.end()) + owners.erase(ownersIt); + } + + MWWorld::ContainerStore& store = player.getClass().getContainerStore(player); + + // move items from player to owner and report about theft + victim.getClass().getContainerStore(victim).add(item, toRemove, victim); + store.remove(item, toRemove, player); + commitCrime(player, victim, OT_Theft, item.getClass().getValue(item) * toRemove); + } + void MechanicsManager::confiscateStolenItems(const MWWorld::Ptr &player, const MWWorld::Ptr &targetContainer) { MWWorld::ContainerStore& store = player.getClass().getContainerStore(player); @@ -956,7 +1017,7 @@ namespace MWMechanics } } - if (isAllowedToUse(ptr, *ownerCellRef, victim)) + if (isAllowedToUse(ptr, item, victim)) return; Owner owner; @@ -1026,11 +1087,6 @@ namespace MWMechanics if (playerFollowers.find(*it) != playerFollowers.end()) continue; - if (type == OT_Theft || type == OT_Pickpocket) - MWBase::Environment::get().getDialogueManager()->say(*it, "thief"); - else if (type == OT_Trespassing) - MWBase::Environment::get().getDialogueManager()->say(*it, "intruder"); - crimeSeen = true; } } @@ -1038,7 +1094,13 @@ namespace MWMechanics if (crimeSeen) reportCrime(player, victim, type, arg); else if (type == OT_Assault && !victim.isEmpty()) - startCombat(victim, player); // TODO: combat should be started with an "unaware" flag, which makes the victim flee? + { + if (victim.getClass().isClass(victim, "guard") + && !victim.getClass().getCreatureStats(victim).getAiSequence().hasPackage(AiPackage::TypeIdPursue)) + reportCrime(player, victim, type, arg); + else + startCombat(victim, player); // TODO: combat should be started with an "unaware" flag, which makes the victim flee? + } return crimeSeen; } @@ -1126,10 +1188,25 @@ namespace MWMechanics if (it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(victim)) continue; + // Player's followers should not attack player, or try to arrest him + if (it->getClass().getCreatureStats(*it).getAiSequence().hasPackage(AiPackage::TypeIdFollow)) + { + std::set playerFollowers; + getActorsSidingWith(player, playerFollowers); + + if (playerFollowers.find(*it) != playerFollowers.end()) + continue; + } + // Will the witness report the crime? if (it->getClass().getCreatureStats(*it).getAiSetting(CreatureStats::AI_Alarm).getBase() >= 100) { reported = true; + + if (type == OT_Theft || type == OT_Pickpocket) + MWBase::Environment::get().getDialogueManager()->say(*it, "thief"); + else if (type == OT_Trespassing) + MWBase::Environment::get().getDialogueManager()->say(*it, "intruder"); } if (it->getClass().isClass(*it, "guard")) @@ -1141,7 +1218,10 @@ namespace MWMechanics // once the bounty has been paid. it->getClass().getNpcStats(*it).setCrimeId(id); - it->getClass().getCreatureStats(*it).getAiSequence().stack(AiPursue(player), *it); + if (!it->getClass().getCreatureStats(*it).getAiSequence().hasPackage(AiPackage::TypeIdPursue)) + { + it->getClass().getCreatureStats(*it).getAiSequence().stack(AiPursue(player), *it); + } } else { @@ -1209,7 +1289,8 @@ namespace MWMechanics { // Attacker is in combat with us, but we are not in combat with the attacker yet. Time to fight back. // Note: accidental or collateral damage attacks are ignored. - startCombat(victim, player); + if (!victim.getClass().getCreatureStats(victim).getAiSequence().hasPackage(AiPackage::TypeIdPursue)) + startCombat(victim, player); // Set the crime ID, which we will use to calm down participants // once the bounty has been paid. @@ -1252,7 +1333,8 @@ namespace MWMechanics } if (target.getClass().isNpc() && !attacker.isEmpty() && !seq.isInCombat(attacker) - && !isAggressive(target, attacker) && !isFightingNpc) + && !isAggressive(target, attacker) && !isFightingNpc + && !target.getClass().getCreatureStats(target).getAiSequence().hasPackage(AiPackage::TypeIdPursue)) commitCrime(attacker, target, MWBase::MechanicsManager::OT_Assault); if (!attacker.isEmpty() && (attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(target) @@ -1261,7 +1343,8 @@ namespace MWMechanics { // Attacker is in combat with us, but we are not in combat with the attacker yet. Time to fight back. // Note: accidental or collateral damage attacks are ignored. - startCombat(target, attacker); + if (!target.getClass().getCreatureStats(target).getAiSequence().hasPackage(AiPackage::TypeIdPursue)) + startCombat(target, attacker); } return true; @@ -1476,7 +1559,7 @@ namespace MWMechanics { int disposition = 50; if (ptr.getClass().isNpc()) - disposition = getDerivedDisposition(ptr, false); + disposition = getDerivedDisposition(ptr, true); int fight = std::max(0, ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified() + static_cast(getFightDistanceBias(ptr, target) + getFightDispositionBias(static_cast(disposition)))); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index ed06f58c5..bba2c55d6 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -197,15 +197,19 @@ namespace MWMechanics /// Has the player stolen this item from the given owner? virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid); - + /// @return is \a ptr allowed to take/use \a cellref or is it a crime? - virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim); + virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::ConstPtr& item, MWWorld::Ptr& victim); virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf); virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor); virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId); + virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count); + + virtual bool isRunning(const MWWorld::Ptr& ptr); + virtual bool isSneaking(const MWWorld::Ptr& ptr); private: void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim, OffenseType type, int arg=0); diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 0b016e69d..595635206 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -1,15 +1,9 @@ #include "npcstats.hpp" -#include -#include -#include -#include - #include #include -#include #include #include #include @@ -21,7 +15,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" MWMechanics::NpcStats::NpcStats() : mDisposition (0) @@ -30,7 +23,7 @@ MWMechanics::NpcStats::NpcStats() , mBounty(0) , mWerewolfKills (0) , mLevelProgress(0) -, mTimeToStartDrowning(20.0) +, mTimeToStartDrowning(-1.0) // set breath to special value, it will be replaced during actor update , mIsWerewolf(false) { mSkillIncreases.resize (ESM::Attribute::Length, 0); @@ -260,7 +253,7 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas // Play sound & skill progress notification /// \todo check if character is the player, if levelling is ever implemented for NPCs - MWBase::Environment::get().getSoundManager ()->playSound ("skillraise", 1, 1); + MWBase::Environment::get().getWindowManager()->playSound("skillraise"); std::stringstream message; message << boost::format(MWBase::Environment::get().getWindowManager ()->getGameSettingString ("sNotifyMessage39", "")) diff --git a/apps/openmw/mwmechanics/obstacle.cpp b/apps/openmw/mwmechanics/obstacle.cpp index 5d99fe723..3c6f14bfd 100644 --- a/apps/openmw/mwmechanics/obstacle.cpp +++ b/apps/openmw/mwmechanics/obstacle.cpp @@ -1,6 +1,7 @@ #include "obstacle.hpp" #include +#include #include "../mwbase/world.hpp" #include "../mwworld/class.hpp" @@ -23,50 +24,48 @@ namespace MWMechanics { -1.0f, -1.0f } // move to side and backwards }; - // Proximity check function for interior doors. Given that most interior cells - // do not have many doors performance shouldn't be too much of an issue. - // - // Limitation: there can be false detections, and does not test whether the - // actor is facing the door. - bool proximityToDoor(const MWWorld::Ptr& actor, float minSqr) + bool proximityToDoor(const MWWorld::Ptr& actor, float minDist) { - if(getNearbyDoor(actor, minSqr)!=MWWorld::Ptr()) + if(getNearbyDoor(actor, minDist)!=MWWorld::Ptr()) return true; else return false; } - MWWorld::Ptr getNearbyDoor(const MWWorld::Ptr& actor, float minSqr) + MWWorld::Ptr getNearbyDoor(const MWWorld::Ptr& actor, float minDist) { MWWorld::CellStore *cell = actor.getCell(); - if(cell->getCell()->isExterior()) - return MWWorld::Ptr(); // check interior cells only - // Check all the doors in this cell const MWWorld::CellRefList& doors = cell->getReadOnlyDoors(); const MWWorld::CellRefList::List& refList = doors.mList; MWWorld::CellRefList::List::const_iterator it = refList.begin(); osg::Vec3f pos(actor.getRefData().getPosition().asVec3()); + pos.z() = 0; - /// TODO: How to check whether the actor is facing a door? Below code is for - /// the player, perhaps it can be adapted. - //MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getFacedObject(); - //if(!ptr.isEmpty()) - //std::cout << "faced door " << ptr.getClass().getName(ptr) << std::endl; + osg::Vec3f actorDir = (actor.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0,1,0)); - /// TODO: The in-game observation of rot[2] value seems to be the - /// opposite of the code in World::activateDoor() ::confused:: for (; it != refList.end(); ++it) { const MWWorld::LiveCellRef& ref = *it; - if((pos - ref.mData.getPosition().asVec3()).length2() < minSqr - && ref.mData.getPosition().rot[2] == ref.mRef.getPosition().rot[2]) - { - // FIXME cast - return MWWorld::Ptr(&const_cast &>(ref), actor.getCell()); // found, stop searching - } + + osg::Vec3f doorPos(ref.mData.getPosition().asVec3()); + doorPos.z() = 0; + + float angle = std::acos(actorDir * (doorPos - pos) / (actorDir.length() * (doorPos - pos).length())); + + // Allow 60 degrees angle between actor and door + if (angle < -osg::PI / 3 || angle > osg::PI / 3) + continue; + + // Door is not close enough + if ((pos - doorPos).length2() > minDist*minDist) + continue; + + // FIXME cast + return MWWorld::Ptr(&const_cast &>(ref), actor.getCell()); // found, stop searching } + return MWWorld::Ptr(); // none found } diff --git a/apps/openmw/mwmechanics/obstacle.hpp b/apps/openmw/mwmechanics/obstacle.hpp index 1d7cf1e0e..f71207346 100644 --- a/apps/openmw/mwmechanics/obstacle.hpp +++ b/apps/openmw/mwmechanics/obstacle.hpp @@ -10,19 +10,14 @@ namespace MWMechanics { struct Movement; - /// NOTE: determined empirically based on in-game behaviour - static const float MIN_DIST_TO_DOOR_SQUARED = 128*128; - static const int NUM_EVADE_DIRECTIONS = 4; /// tests actor's proximity to a closed door by default - bool proximityToDoor(const MWWorld::Ptr& actor, - float minSqr = MIN_DIST_TO_DOOR_SQUARED); + bool proximityToDoor(const MWWorld::Ptr& actor, float minDist); /// Returns door pointer within range. No guarantee is given as to which one /** \return Pointer to the door, or NULL if none exists **/ - MWWorld::Ptr getNearbyDoor(const MWWorld::Ptr& actor, - float minSqr = MIN_DIST_TO_DOOR_SQUARED); + MWWorld::Ptr getNearbyDoor(const MWWorld::Ptr& actor, float minDist); class ObstacleCheck { diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index b0bdce8f1..5c0456096 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -15,7 +15,7 @@ namespace // Chooses a reachable end pathgrid point. start is assumed reachable. std::pair getClosestReachablePoint(const ESM::Pathgrid* grid, const MWWorld::CellStore *cell, - const osg::Vec3f pos, int start) + const osg::Vec3f& pos, int start) { assert(grid && !grid->mPoints.empty()); diff --git a/apps/openmw/mwmechanics/repair.cpp b/apps/openmw/mwmechanics/repair.cpp index a1c79ea23..5c6123e82 100644 --- a/apps/openmw/mwmechanics/repair.cpp +++ b/apps/openmw/mwmechanics/repair.cpp @@ -8,7 +8,6 @@ #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/windowmanager.hpp" -#include "../mwbase/soundmanager.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" @@ -71,12 +70,12 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair) // increase skill player.getClass().skillUsageSucceeded(player, ESM::Skill::Armorer, 0); - MWBase::Environment::get().getSoundManager()->playSound("Repair",1,1); + MWBase::Environment::get().getWindowManager()->playSound("Repair"); MWBase::Environment::get().getWindowManager()->messageBox("#{sRepairSuccess}"); } else { - MWBase::Environment::get().getSoundManager()->playSound("Repair Fail",1,1); + MWBase::Environment::get().getWindowManager()->playSound("Repair Fail"); MWBase::Environment::get().getWindowManager()->messageBox("#{sRepairFailed}"); } @@ -100,7 +99,7 @@ void Repair::repair(const MWWorld::Ptr &itemToRepair) { mTool = *iter; - MWBase::Environment::get().getSoundManager()->playSound("Item Repair Up",1,1); + MWBase::Environment::get().getWindowManager()->playSound("Item Repair Up"); break; } diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 5cfaccb84..f7ee15bf4 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -44,8 +44,36 @@ namespace MWMechanics return schoolSkillMap[school]; } - float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap) + float calcEffectCost(const ESM::ENAMstruct& effect) + { + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); + + int minMagn = 1; + int maxMagn = 1; + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) + { + minMagn = effect.mMagnMin; + maxMagn = effect.mMagnMax; + } + + int duration = 0; + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) + duration = effect.mDuration; + + static const float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore() + .get().find("fEffectCostMult")->getFloat(); + + float x = 0.5 * (std::max(1, minMagn) + std::max(1, maxMagn)); + x *= 0.1 * magicEffect->mData.mBaseCost; + x *= 1 + duration; + x += 0.05 * std::max(1, effect.mArea) * magicEffect->mData.mBaseCost; + + return x * fEffectCostMult; + } + + float calcSpellBaseSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool) { + // Morrowind for some reason uses a formula slightly different from magicka cost calculation float y = std::numeric_limits::max(); float lowestSkill = 0; @@ -54,8 +82,10 @@ namespace MWMechanics float x = static_cast(it->mDuration); const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find( it->mEffectID); + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::UncappedDamage)) x = std::max(1.f, x); + x *= 0.1f * magicEffect->mData.mBaseCost; x *= 0.5f * (it->mMagnMin + it->mMagnMax); x *= it->mArea * 0.05f * magicEffect->mData.mBaseCost; @@ -75,10 +105,27 @@ namespace MWMechanics } } + CreatureStats& stats = actor.getClass().getCreatureStats(actor); + + int actorWillpower = stats.getAttribute(ESM::Attribute::Willpower).getModified(); + int actorLuck = stats.getAttribute(ESM::Attribute::Luck).getModified(); + + float castChance = (lowestSkill - spell->mData.mCost + 0.2f * actorWillpower + 0.1f * actorLuck); + + return castChance; + } + + float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool, bool cap) + { bool godmode = actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState(); CreatureStats& stats = actor.getClass().getCreatureStats(actor); + float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude(); + + float castChance = calcSpellBaseSuccessChance(spell, actor, effectiveSchool) + castBonus; + castChance *= stats.getFatigueTerm(); + if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude()&& !godmode) return 0; @@ -96,13 +143,6 @@ namespace MWMechanics return 100; } - float castBonus = -stats.getMagicEffects().get(ESM::MagicEffect::Sound).getMagnitude(); - - int actorWillpower = stats.getAttribute(ESM::Attribute::Willpower).getModified(); - int actorLuck = stats.getAttribute(ESM::Attribute::Luck).getModified(); - - float castChance = (lowestSkill - spell->mData.mCost + castBonus + 0.2f * actorWillpower + 0.1f * actorLuck) * stats.getFatigueTerm(); - if (!cap) return std::max(0.f, castChance); else @@ -633,7 +673,7 @@ namespace MWMechanics } else if (target.getClass().isActor() && effectId == ESM::MagicEffect::Dispel) { - target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude); + target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude, true); return true; } else if (target.getClass().isActor() && target == getPlayer()) @@ -1091,6 +1131,9 @@ namespace MWMechanics receivedMagicDamage = true; adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::DamageHealth, -magnitude); } + + break; + case ESM::MagicEffect::DamageMagicka: case ESM::MagicEffect::DamageFatigue: if (!godmode) @@ -1107,6 +1150,9 @@ namespace MWMechanics receivedMagicDamage = true; adjustDynamicStat(creatureStats, effectKey.mId-ESM::MagicEffect::AbsorbHealth, -magnitude); } + + break; + case ESM::MagicEffect::AbsorbMagicka: case ESM::MagicEffect::AbsorbFatigue: if (!godmode) diff --git a/apps/openmw/mwmechanics/spellcasting.hpp b/apps/openmw/mwmechanics/spellcasting.hpp index 8e48681b6..9991c583d 100644 --- a/apps/openmw/mwmechanics/spellcasting.hpp +++ b/apps/openmw/mwmechanics/spellcasting.hpp @@ -1,6 +1,7 @@ #ifndef MWMECHANICS_SPELLSUCCESS_H #define MWMECHANICS_SPELLSUCCESS_H +#include #include #include "../mwworld/ptr.hpp" @@ -21,6 +22,8 @@ namespace MWMechanics ESM::Skill::SkillEnum spellSchoolToSkill(int school); + float calcEffectCost(const ESM::ENAMstruct& effect); + bool isSummoningEffect(int effectId); /** @@ -62,6 +65,7 @@ namespace MWMechanics bool checkEffectTarget (int effectId, const MWWorld::Ptr& target, const MWWorld::Ptr& caster, bool castByPlayer); int getEffectiveEnchantmentCastCost (float castCost, const MWWorld::Ptr& actor); + float calcSpellBaseSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool); /// Apply a magic effect that is applied in tick intervals until its remaining time ends or it is removed /// @return Was the effect a tickable effect with a magnitude? diff --git a/apps/openmw/mwmechanics/spellpriority.cpp b/apps/openmw/mwmechanics/spellpriority.cpp new file mode 100644 index 000000000..3a730fbeb --- /dev/null +++ b/apps/openmw/mwmechanics/spellpriority.cpp @@ -0,0 +1,606 @@ +#include "spellpriority.hpp" + +#include +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" +#include "../mwbase/mechanicsmanager.hpp" + +#include "../mwworld/class.hpp" +#include "../mwworld/esmstore.hpp" +#include "../mwworld/inventorystore.hpp" +#include "../mwworld/actionequip.hpp" +#include "../mwworld/cellstore.hpp" + +#include "npcstats.hpp" +#include "spellcasting.hpp" +#include "combat.hpp" + +namespace +{ + int numEffectsToDispel (const MWWorld::Ptr& actor, int effectFilter=-1, bool negative = true) + { + int toCure=0; + const MWMechanics::ActiveSpells& activeSpells = actor.getClass().getCreatureStats(actor).getActiveSpells(); + for (MWMechanics::ActiveSpells::TIterator it = activeSpells.begin(); it != activeSpells.end(); ++it) + { + // if the effect filter is not specified, take in account only spells effects. Leave potions, enchanted items etc. + if (effectFilter == -1) + { + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get().search(it->first); + if (!spell || spell->mData.mType != ESM::Spell::ST_Spell) + continue; + } + + const MWMechanics::ActiveSpells::ActiveSpellParams& params = it->second; + for (std::vector::const_iterator effectIt = params.mEffects.begin(); + effectIt != params.mEffects.end(); ++effectIt) + { + int effectId = effectIt->mEffectId; + if (effectFilter != -1 && effectId != effectFilter) + continue; + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effectId); + + if (effectIt->mDuration <= 3) // Don't attempt to dispel if effect runs out shortly anyway + continue; + + if (negative && magicEffect->mData.mFlags & ESM::MagicEffect::Harmful) + ++toCure; + + if (!negative && !(magicEffect->mData.mFlags & ESM::MagicEffect::Harmful)) + ++toCure; + } + } + return toCure; + } + + float getSpellDuration (const MWWorld::Ptr& actor, const std::string& spellId) + { + float duration = 0; + const MWMechanics::ActiveSpells& activeSpells = actor.getClass().getCreatureStats(actor).getActiveSpells(); + for (MWMechanics::ActiveSpells::TIterator it = activeSpells.begin(); it != activeSpells.end(); ++it) + { + if (it->first != spellId) + continue; + + const MWMechanics::ActiveSpells::ActiveSpellParams& params = it->second; + for (std::vector::const_iterator effectIt = params.mEffects.begin(); + effectIt != params.mEffects.end(); ++effectIt) + { + if (effectIt->mDuration > duration) + duration = effectIt->mDuration; + } + } + return duration; + } +} + +namespace MWMechanics +{ + int getRangeTypes (const ESM::EffectList& effects) + { + int types = 0; + for (std::vector::const_iterator it = effects.mList.begin(); it != effects.mList.end(); ++it) + { + if (it->mRange == ESM::RT_Self) + types |= RangeTypes::Self; + else if (it->mRange == ESM::RT_Touch) + types |= RangeTypes::Touch; + else if (it->mRange == ESM::RT_Target) + types |= RangeTypes::Target; + } + return types; + } + + float ratePotion (const MWWorld::Ptr &item, const MWWorld::Ptr& actor) + { + if (item.getTypeName() != typeid(ESM::Potion).name()) + return 0.f; + + const ESM::Potion* potion = item.get()->mBase; + return rateEffects(potion->mEffects, actor, MWWorld::Ptr()); + } + + float rateSpell(const ESM::Spell *spell, const MWWorld::Ptr &actor, const MWWorld::Ptr& enemy) + { + const CreatureStats& stats = actor.getClass().getCreatureStats(actor); + + float successChance = MWMechanics::getSpellSuccessChance(spell, actor); + if (successChance == 0.f) + return 0.f; + + if (spell->mData.mType != ESM::Spell::ST_Spell) + return 0.f; + + // Don't make use of racial bonus spells, like MW. Can be made optional later + if (actor.getClass().isNpc()) + { + std::string raceid = actor.get()->mBase->mRace; + const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); + if (race->mPowers.exists(spell->mId)) + return 0.f; + } + + if (spell->mData.mCost > stats.getMagicka().getCurrent()) + return 0.f; + + // Spells don't stack, so early out if the spell is still active on the target + int types = getRangeTypes(spell->mEffects); + if ((types & Self) && stats.getActiveSpells().isSpellActive(spell->mId)) + return 0.f; + if ( ((types & Touch) || (types & Target)) && enemy.getClass().getCreatureStats(enemy).getActiveSpells().isSpellActive(spell->mId)) + return 0.f; + + return rateEffects(spell->mEffects, actor, enemy) * (successChance / 100.f); + } + + float rateMagicItem(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor, const MWWorld::Ptr& enemy) + { + if (ptr.getClass().getEnchantment(ptr).empty()) + return 0.f; + + const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get().find(ptr.getClass().getEnchantment(ptr)); + + // Spells don't stack, so early out if the spell is still active on the target + int types = getRangeTypes(enchantment->mEffects); + if ((types & Self) && actor.getClass().getCreatureStats(actor).getActiveSpells().isSpellActive(ptr.getCellRef().getRefId())) + return 0.f; + + if (types & (Touch|Target) && getSpellDuration(enemy, ptr.getCellRef().getRefId()) > 3) + return 0.f; + + if (enchantment->mData.mType == ESM::Enchantment::CastOnce) + { + return rateEffects(enchantment->mEffects, actor, enemy); + } + else if (enchantment->mData.mType == ESM::Enchantment::WhenUsed) + { + MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor); + + // Creatures can not wear armor/clothing, so allow creatures to use non-equipped items, + if (actor.getClass().isNpc() && !store.isEquipped(ptr)) + return 0.f; + + int castCost = getEffectiveEnchantmentCastCost(static_cast(enchantment->mData.mCost), actor); + + if (ptr.getCellRef().getEnchantmentCharge() != -1 + && ptr.getCellRef().getEnchantmentCharge() < castCost) + return 0.f; + + float rating = rateEffects(enchantment->mEffects, actor, enemy); + + rating *= 2; // prefer rechargable magic items over spells + return rating; + } + + return 0.f; + } + + float rateEffect(const ESM::ENAMstruct &effect, const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy) + { + // NOTE: enemy may be empty + + float rating = 1; + switch (effect.mEffectID) + { + case ESM::MagicEffect::Soultrap: + case ESM::MagicEffect::AlmsiviIntervention: + case ESM::MagicEffect::DivineIntervention: + case ESM::MagicEffect::CalmHumanoid: + case ESM::MagicEffect::CalmCreature: + case ESM::MagicEffect::FrenzyHumanoid: + case ESM::MagicEffect::FrenzyCreature: + case ESM::MagicEffect::DemoralizeHumanoid: + case ESM::MagicEffect::DemoralizeCreature: + case ESM::MagicEffect::RallyHumanoid: + case ESM::MagicEffect::RallyCreature: + case ESM::MagicEffect::Charm: + case ESM::MagicEffect::DetectAnimal: + case ESM::MagicEffect::DetectEnchantment: + case ESM::MagicEffect::DetectKey: + case ESM::MagicEffect::Telekinesis: + case ESM::MagicEffect::Mark: + case ESM::MagicEffect::Recall: + case ESM::MagicEffect::Jump: + case ESM::MagicEffect::WaterBreathing: + case ESM::MagicEffect::SwiftSwim: + case ESM::MagicEffect::WaterWalking: + case ESM::MagicEffect::SlowFall: + case ESM::MagicEffect::Light: + case ESM::MagicEffect::Lock: + case ESM::MagicEffect::Open: + case ESM::MagicEffect::TurnUndead: + case ESM::MagicEffect::WeaknessToCommonDisease: + case ESM::MagicEffect::WeaknessToBlightDisease: + case ESM::MagicEffect::WeaknessToCorprusDisease: + case ESM::MagicEffect::CureCommonDisease: + case ESM::MagicEffect::CureBlightDisease: + case ESM::MagicEffect::CureCorprusDisease: + case ESM::MagicEffect::ResistBlightDisease: + case ESM::MagicEffect::ResistCommonDisease: + case ESM::MagicEffect::ResistCorprusDisease: + case ESM::MagicEffect::Invisibility: + case ESM::MagicEffect::Chameleon: + case ESM::MagicEffect::NightEye: + case ESM::MagicEffect::Vampirism: + case ESM::MagicEffect::StuntedMagicka: + case ESM::MagicEffect::ExtraSpell: + case ESM::MagicEffect::RemoveCurse: + case ESM::MagicEffect::CommandCreature: + case ESM::MagicEffect::CommandHumanoid: + return 0.f; + + case ESM::MagicEffect::Sound: + { + if (enemy.isEmpty()) + return 0.f; + + // there is no need to cast sound if enemy is not able to cast spells + CreatureStats& stats = enemy.getClass().getCreatureStats(enemy); + + if (stats.getMagicEffects().get(ESM::MagicEffect::Silence).getMagnitude() > 0) + return 0.f; + + if (stats.getMagicEffects().get(ESM::MagicEffect::Paralyze).getMagnitude() > 0) + return 0.f; + + break; + } + + case ESM::MagicEffect::RestoreAttribute: + return 0.f; // TODO: implement based on attribute damage + case ESM::MagicEffect::RestoreSkill: + return 0.f; // TODO: implement based on skill damage + + case ESM::MagicEffect::ResistFire: + case ESM::MagicEffect::ResistFrost: + case ESM::MagicEffect::ResistMagicka: + case ESM::MagicEffect::ResistNormalWeapons: + case ESM::MagicEffect::ResistParalysis: + case ESM::MagicEffect::ResistPoison: + case ESM::MagicEffect::ResistShock: + case ESM::MagicEffect::SpellAbsorption: + case ESM::MagicEffect::Reflect: + return 0.f; // probably useless since we don't know in advance what the enemy will cast + + // don't cast these for now as they would make the NPC cast the same effect over and over again, especially when they have potions + case ESM::MagicEffect::FortifyAttribute: + case ESM::MagicEffect::FortifyHealth: + case ESM::MagicEffect::FortifyMagicka: + case ESM::MagicEffect::FortifyFatigue: + case ESM::MagicEffect::FortifySkill: + case ESM::MagicEffect::FortifyMaximumMagicka: + case ESM::MagicEffect::FortifyAttack: + return 0.f; + + case ESM::MagicEffect::Burden: + { + if (enemy.isEmpty()) + return 0.f; + + // Ignore enemy without inventory + if (!enemy.getClass().hasInventoryStore(enemy)) + return 0.f; + + // burden makes sense only to overburden an enemy + float burden = enemy.getClass().getEncumbrance(enemy) - enemy.getClass().getCapacity(enemy); + if (burden > 0) + return 0.f; + + if ((effect.mMagnMin + effect.mMagnMax)/2.f > -burden) + rating *= 3; + else + return 0.f; + + break; + } + + case ESM::MagicEffect::Feather: + { + // Ignore actors without inventory + if (!actor.getClass().hasInventoryStore(actor)) + return 0.f; + + // feather makes sense only for overburden actors + float burden = actor.getClass().getEncumbrance(actor) - actor.getClass().getCapacity(actor); + if (burden <= 0) + return 0.f; + + if ((effect.mMagnMin + effect.mMagnMax)/2.f >= burden) + rating *= 3; + else + return 0.f; + + break; + } + + case ESM::MagicEffect::Levitate: + return 0.f; // AI isn't designed to take advantage of this, and could be perceived as unfair anyway + case ESM::MagicEffect::BoundBoots: + case ESM::MagicEffect::BoundHelm: + if (actor.getClass().isNpc()) + { + // Beast races can't wear helmets or boots + std::string raceid = actor.get()->mBase->mRace; + const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get().find(raceid); + if (race->mData.mFlags & ESM::Race::Beast) + return 0.f; + } + // Intended fall-through + // Creatures can not wear armor + case ESM::MagicEffect::BoundCuirass: + case ESM::MagicEffect::BoundGloves: + if (!actor.getClass().isNpc()) + return 0.f; + break; + + case ESM::MagicEffect::RestoreHealth: + case ESM::MagicEffect::RestoreMagicka: + case ESM::MagicEffect::RestoreFatigue: + if (effect.mRange == ESM::RT_Self) + { + int priority = 1; + if (effect.mEffectID == ESM::MagicEffect::RestoreHealth) + priority = 10; + const DynamicStat& current = actor.getClass().getCreatureStats(actor). + getDynamic(effect.mEffectID - ESM::MagicEffect::RestoreHealth); + float toHeal = (effect.mMagnMin + effect.mMagnMax)/2.f * effect.mDuration; + // Effect doesn't heal more than we need, *or* we are below 1/2 health + if (current.getModified() - current.getCurrent() > toHeal + || current.getCurrent() < current.getModified()*0.5) + { + return 10000.f * priority + - (toHeal - (current.getModified()-current.getCurrent())); // prefer the most fitting potion + } + else + return -10000.f * priority; // Save for later + } + break; + + case ESM::MagicEffect::Dispel: + { + int numPositive = 0; + int numNegative = 0; + int diff = 0; + + if (effect.mRange == ESM::RT_Self) + { + numPositive = numEffectsToDispel(actor, -1, false); + numNegative = numEffectsToDispel(actor); + + diff = numNegative - numPositive; + } + else + { + if (enemy.isEmpty()) + return 0.f; + + numPositive = numEffectsToDispel(enemy, -1, false); + numNegative = numEffectsToDispel(enemy); + + diff = numPositive - numNegative; + + // if rating < 0 here, the spell will be considered as negative later + rating *= -1; + } + + if (diff <= 0) + return 0.f; + + rating *= (diff) / 5.f; + + break; + } + + // Prefer Cure effects over Dispel, because Dispel also removes positive effects + case ESM::MagicEffect::CureParalyzation: + return 1001.f * numEffectsToDispel(actor, ESM::MagicEffect::Paralyze); + + case ESM::MagicEffect::CurePoison: + return 1001.f * numEffectsToDispel(actor, ESM::MagicEffect::Poison); + case ESM::MagicEffect::DisintegrateArmor: + { + if (enemy.isEmpty()) + return 0.f; + + // Ignore enemy without inventory + if (!enemy.getClass().hasInventoryStore(enemy)) + return 0.f; + + MWWorld::InventoryStore& inv = enemy.getClass().getInventoryStore(enemy); + + // According to UESP + static const int armorSlots[] = { + MWWorld::InventoryStore::Slot_CarriedLeft, + MWWorld::InventoryStore::Slot_Cuirass, + MWWorld::InventoryStore::Slot_LeftPauldron, + MWWorld::InventoryStore::Slot_RightPauldron, + MWWorld::InventoryStore::Slot_LeftGauntlet, + MWWorld::InventoryStore::Slot_RightGauntlet, + MWWorld::InventoryStore::Slot_Helmet, + MWWorld::InventoryStore::Slot_Greaves, + MWWorld::InventoryStore::Slot_Boots + }; + + bool enemyHasArmor = false; + + // Ignore enemy without armor + for (unsigned int i=0; i= 0 && effect.mAttribute < ESM::Attribute::Length) + { + const float attributePriorities[ESM::Attribute::Length] = { + 1.0f, // Strength + 0.5f, // Intelligence + 0.6f, // Willpower + 0.7f, // Agility + 0.5f, // Speed + 0.8f, // Endurance + 0.7f, // Personality + 0.3f // Luck + }; + rating *= attributePriorities[effect.mAttribute]; + } + } + break; + + case ESM::MagicEffect::DamageSkill: + case ESM::MagicEffect::DrainSkill: + if (enemy.isEmpty() || !enemy.getClass().isNpc()) + return 0.f; + if (enemy.getClass().getNpcStats(enemy).getSkill(effect.mSkill).getModified() <= 0) + return 0.f; + break; + + default: + break; + } + + // Allow only one summoned creature at time + if (isSummoningEffect(effect.mEffectID)) + { + MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor); + + if (!creatureStats.getSummonedCreatureMap().empty()) + return 0.f; + } + + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get().find(effect.mEffectID); + + // Underwater casting not possible + if (effect.mRange == ESM::RT_Target) + { + if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.75f)) + return 0.f; + + if (enemy.isEmpty()) + return 0.f; + + if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(enemy), 0.75f)) + return 0.f; + } + + if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful) + { + rating *= -1.f; + + if (enemy.isEmpty()) + return 0.f; + + // Check resistance for harmful effects + CreatureStats& stats = enemy.getClass().getCreatureStats(enemy); + + float resistance = MWMechanics::getEffectResistanceAttribute(effect.mEffectID, &stats.getMagicEffects()); + + rating *= (1.f - std::min(resistance, 100.f) / 100.f); + } + + // for harmful no-magnitude effects (e.g. silence) check if enemy is already has them + // for non-harmful no-magnitude effects (e.g. bound items) check if actor is already has them + if (magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude) + { + if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful) + { + CreatureStats& stats = enemy.getClass().getCreatureStats(enemy); + + if (stats.getMagicEffects().get(effect.mEffectID).getMagnitude() > 0) + return 0.f; + } + else + { + CreatureStats& stats = actor.getClass().getCreatureStats(actor); + + if (stats.getMagicEffects().get(effect.mEffectID).getMagnitude() > 0) + return 0.f; + } + } + + rating *= calcEffectCost(effect); + + // Currently treating all "on target" or "on touch" effects to target the enemy actor. + // Combat AI is egoistic, so doesn't consider applying positive effects to friendly actors. + if (effect.mRange != ESM::RT_Self) + rating *= -1.f; + + return rating; + } + + float rateEffects(const ESM::EffectList &list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) + { + // NOTE: enemy may be empty + float rating = 0.f; + for (std::vector::const_iterator it = list.mList.begin(); it != list.mList.end(); ++it) + { + rating += rateEffect(*it, actor, enemy); + + if (it->mRange == ESM::RT_Target) + rating *= 1.5f; + } + return rating; + } + + float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) + { + const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); + + static const float fAIMagicSpellMult = gmst.find("fAIMagicSpellMult")->getFloat(); + static const float fAIRangeMagicSpellMult = gmst.find("fAIRangeMagicSpellMult")->getFloat(); + + float mult = fAIMagicSpellMult; + + for (std::vector::const_iterator effectIt = + spell->mEffects.mList.begin(); effectIt != spell->mEffects.mList.end(); ++effectIt) + { + if (effectIt->mRange == ESM::RT_Target) + { + if (!MWBase::Environment::get().getWorld()->isSwimming(enemy)) + mult = fAIRangeMagicSpellMult; + else + mult = 0.0f; + break; + } + } + + return MWMechanics::getSpellSuccessChance(spell, actor) * mult; + } +} diff --git a/apps/openmw/mwmechanics/spellpriority.hpp b/apps/openmw/mwmechanics/spellpriority.hpp new file mode 100644 index 000000000..4e5ff5c71 --- /dev/null +++ b/apps/openmw/mwmechanics/spellpriority.hpp @@ -0,0 +1,32 @@ +#ifndef OPENMW_SPELL_PRIORITY_H +#define OPENMW_SPELL_PRIORITY_H + +#include + +#include "../mwworld/ptr.hpp" + +namespace MWMechanics +{ + // RangeTypes using bitflags to allow multiple range types, as can be the case with spells having multiple effects. + enum RangeTypes + { + Self = 0x1, + Touch = 0x10, + Target = 0x100 + }; + + int getRangeTypes (const ESM::EffectList& effects); + + float rateSpell (const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + float rateMagicItem (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + float ratePotion (const MWWorld::Ptr& item, const MWWorld::Ptr &actor); + + /// @note target may be empty + float rateEffect (const ESM::ENAMstruct& effect, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + /// @note target may be empty + float rateEffects (const ESM::EffectList& list, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); + + float vanillaRateSpell(const ESM::Spell* spell, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); +} + +#endif diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index e4a825efc..fad7bc96d 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -38,26 +38,10 @@ namespace MWMechanics } } - void UpdateSummonedCreatures::process() + void UpdateSummonedCreatures::process(bool cleanup) { - - MWMechanics::CreatureStats& creatureStats = mActor.getClass().getCreatureStats(mActor); - - // Update summon effects std::map& creatureMap = creatureStats.getSummonedCreatureMap(); - for (std::map::iterator it = creatureMap.begin(); it != creatureMap.end(); ) - { - bool found = mActiveEffects.find(it->first) != mActiveEffects.end(); - if (!found) - { - // Effect has ended - MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(mActor, it->second); - creatureMap.erase(it++); - continue; - } - ++it; - } for (std::set >::iterator it = mActiveEffects.begin(); it != mActiveEffects.end(); ++it) { @@ -101,21 +85,18 @@ namespace MWMechanics } } + // Update summon effects for (std::map::iterator it = creatureMap.begin(); it != creatureMap.end(); ) { - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaActorId(it->second); - if (!ptr.isEmpty() && ptr.getClass().getCreatureStats(ptr).isDead() && ptr.getClass().getCreatureStats(ptr).isDeathAnimationFinished()) + bool found = mActiveEffects.find(it->first) != mActiveEffects.end(); + if (!found) { - // Purge the magic effect so a new creature can be summoned if desired - creatureStats.getActiveSpells().purgeEffect(it->first.first, it->first.second); - if (mActor.getClass().hasInventoryStore(ptr)) - mActor.getClass().getInventoryStore(mActor).purgeEffect(it->first.first, it->first.second); - + // Effect has ended MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(mActor, it->second); creatureMap.erase(it++); + continue; } - else - ++it; + ++it; } std::vector& graveyard = creatureStats.getSummonedCreatureGraveyard(); @@ -137,6 +118,26 @@ namespace MWMechanics else ++it; } + + if (!cleanup) + return; + + for (std::map::iterator it = creatureMap.begin(); it != creatureMap.end(); ) + { + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaActorId(it->second); + if (ptr.isEmpty() || (ptr.getClass().getCreatureStats(ptr).isDead() && ptr.getClass().getCreatureStats(ptr).isDeathAnimationFinished())) + { + // Purge the magic effect so a new creature can be summoned if desired + creatureStats.getActiveSpells().purgeEffect(it->first.first, it->first.second); + if (mActor.getClass().hasInventoryStore(mActor)) + mActor.getClass().getInventoryStore(mActor).purgeEffect(it->first.first, it->first.second); + + MWBase::Environment::get().getMechanicsManager()->cleanupSummonedCreature(mActor, it->second); + creatureMap.erase(it++); + } + else + ++it; + } } } diff --git a/apps/openmw/mwmechanics/summoning.hpp b/apps/openmw/mwmechanics/summoning.hpp index b2a3c60ea..9329dcb83 100644 --- a/apps/openmw/mwmechanics/summoning.hpp +++ b/apps/openmw/mwmechanics/summoning.hpp @@ -22,7 +22,7 @@ namespace MWMechanics float magnitude, float remainingTime = -1, float totalTime = -1); /// To call after all effect sources have been visited - void process(); + void process(bool cleanup); private: MWWorld::Ptr mActor; diff --git a/apps/openmw/mwmechanics/weaponpriority.cpp b/apps/openmw/mwmechanics/weaponpriority.cpp new file mode 100644 index 000000000..07cf6ff5f --- /dev/null +++ b/apps/openmw/mwmechanics/weaponpriority.cpp @@ -0,0 +1,146 @@ +#include "weaponpriority.hpp" + +#include +#include + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwworld/class.hpp" +#include "../mwworld/esmstore.hpp" + +#include "npcstats.hpp" +#include "combat.hpp" +#include "aicombataction.hpp" +#include "spellpriority.hpp" + +namespace MWMechanics +{ + float rateWeapon (const MWWorld::Ptr &item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, int type, + float arrowRating, float boltRating) + { + if (item.getTypeName() != typeid(ESM::Weapon).name()) + return 0.f; + + const ESM::Weapon* weapon = item.get()->mBase; + + if (type != -1 && weapon->mData.mType != type) + return 0.f; + + float rating=0.f; + float bonus=0.f; + + if (weapon->mData.mType >= ESM::Weapon::MarksmanBow && weapon->mData.mType <= ESM::Weapon::MarksmanThrown) + { + // Range weapon is useless under water + if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(actor), 0.75f)) + return 0.f; + + if (enemy.isEmpty()) + return 0.f; + + if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(enemy), 0.75f)) + return 0.f; + + bonus+=1.5f; + } + + if (weapon->mData.mType >= ESM::Weapon::MarksmanBow) + { + rating = (weapon->mData.mChop[0] + weapon->mData.mChop[1]) / 2.f; + + if (weapon->mData.mType >= ESM::Weapon::MarksmanThrown) + MWMechanics::resistNormalWeapon(enemy, actor, item, rating); + } + else + { + for (int i=0; i<2; ++i) + { + rating += weapon->mData.mSlash[i]; + rating += weapon->mData.mThrust[i]; + rating += weapon->mData.mChop[i]; + } + rating /= 6.f; + + MWMechanics::resistNormalWeapon(enemy, actor, item, rating); + } + + if (item.getClass().hasItemHealth(item)) + { + if (item.getClass().getItemHealth(item) == 0) + return 0.f; + rating *= item.getClass().getItemHealth(item) / float(item.getClass().getItemMaxHealth(item)); + } + + if (weapon->mData.mType == ESM::Weapon::MarksmanBow) + { + if (arrowRating <= 0.f) + rating = 0.f; + else + rating += arrowRating; + } + else if (weapon->mData.mType == ESM::Weapon::MarksmanCrossbow) + { + if (boltRating <= 0.f) + rating = 0.f; + else + rating += boltRating; + } + + if (!weapon->mEnchant.empty()) + { + const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get().find(weapon->mEnchant); + if (enchantment->mData.mType == ESM::Enchantment::WhenStrikes + && (item.getCellRef().getEnchantmentCharge() == -1 + || item.getCellRef().getEnchantmentCharge() >= enchantment->mData.mCost)) + rating += rateEffects(enchantment->mEffects, actor, enemy); + } + + int skill = item.getClass().getEquipmentSkill(item); + if (skill != -1) + rating *= actor.getClass().getSkill(actor, skill) / 100.f; + + // There is no need to apply bonus if weapon rating == 0 + if (rating == 0.f) + return 0.f; + + return rating + bonus; + } + + float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy) + { + const MWWorld::Store& gmst = MWBase::Environment::get().getWorld()->getStore().get(); + + static const float fAIMeleeWeaponMult = gmst.find("fAIMeleeWeaponMult")->getFloat(); + static const float fAIMeleeArmorMult = gmst.find("fAIMeleeArmorMult")->getFloat(); + static const float fAIRangeMeleeWeaponMult = gmst.find("fAIRangeMeleeWeaponMult")->getFloat(); + + if (weapon.isEmpty()) + return 0.f; + + float skillMult = actor.getClass().getSkill(actor, weapon.getClass().getEquipmentSkill(weapon)) * 0.01f; + float chopMult = fAIMeleeWeaponMult; + float bonusDamage = 0.f; + + const ESM::Weapon* esmWeap = weapon.get()->mBase; + + if (esmWeap->mData.mType >= ESM::Weapon::MarksmanBow) + { + if (!ammo.isEmpty() && !MWBase::Environment::get().getWorld()->isSwimming(enemy)) + { + bonusDamage = ammo.get()->mBase->mData.mChop[1]; + chopMult = fAIRangeMeleeWeaponMult; + } + else + chopMult = 0.f; + } + + float chopRating = (esmWeap->mData.mChop[1] + bonusDamage) * skillMult * chopMult; + float slashRating = esmWeap->mData.mSlash[1] * skillMult * fAIMeleeWeaponMult; + float thrustRating = esmWeap->mData.mThrust[1] * skillMult * fAIMeleeWeaponMult; + + return actor.getClass().getArmorRating(actor) * fAIMeleeArmorMult + + std::max(std::max(chopRating, slashRating), thrustRating); + } + +} diff --git a/apps/openmw/mwmechanics/weaponpriority.hpp b/apps/openmw/mwmechanics/weaponpriority.hpp new file mode 100644 index 000000000..90a767c4a --- /dev/null +++ b/apps/openmw/mwmechanics/weaponpriority.hpp @@ -0,0 +1,14 @@ +#ifndef OPENMW_WEAPON_PRIORITY_H +#define OPENMW_WEAPON_PRIORITY_H + +#include "../mwworld/ptr.hpp" + +namespace MWMechanics +{ + float rateWeapon (const MWWorld::Ptr& item, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy, + int type=-1, float arrowRating=0.f, float boltRating=0.f); + + float vanillaRateWeaponAndAmmo(const MWWorld::Ptr& weapon, const MWWorld::Ptr& ammo, const MWWorld::Ptr& actor, const MWWorld::Ptr& enemy); +} + +#endif diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 2730bf4f0..e5e36def8 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -18,7 +18,7 @@ namespace MWPhysics Actor::Actor(const MWWorld::Ptr& ptr, osg::ref_ptr shape, btCollisionWorld* world) : mCanWaterWalk(false), mWalkingOnWater(false) - , mCollisionObject(0), mForce(0.f, 0.f, 0.f), mOnGround(true), mOnSlope(false) + , mCollisionObject(nullptr), mForce(0.f, 0.f, 0.f), mOnGround(false), mOnSlope(false) , mInternalCollisionMode(true) , mExternalCollisionMode(true) , mCollisionWorld(world) diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index 88f7f5537..8ec94200f 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -162,10 +162,10 @@ namespace MWPhysics bool mRotationallyInvariant; - std::auto_ptr mShape; + std::unique_ptr mShape; btConvexShape* mConvexShape; - std::auto_ptr mCollisionObject; + std::unique_ptr mCollisionObject; osg::Vec3f mMeshTranslation; osg::Vec3f mHalfExtents; diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 5e79e2a09..790ae2099 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -230,13 +230,6 @@ namespace MWPhysics return direction - project(direction, planeNormal); } - static inline osg::Vec3f reflect(const osg::Vec3& velocity, const osg::Vec3f& normal) - { - return velocity - (normal * (normal * velocity)) * 2; - // ^ dot product - } - - public: static osg::Vec3f traceDown(const MWWorld::Ptr &ptr, const osg::Vec3f& position, Actor* actor, btCollisionWorld* collisionWorld, float maxHeight) { @@ -674,7 +667,7 @@ namespace MWPhysics } private: - std::auto_ptr mCollisionObject; + std::unique_ptr mCollisionObject; osg::ref_ptr mShapeInstance; std::map mRecIndexToNodePath; bool mSolid; @@ -801,7 +794,7 @@ namespace MWPhysics btVector3 mContactPoint; btScalar mLeastDistSqr; - DeepestNotMeContactTestResultCallback(const btCollisionObject* me, const std::vector targets, const btVector3 &origin) + DeepestNotMeContactTestResultCallback(const btCollisionObject* me, const std::vector& targets, const btVector3 &origin) : mMe(me), mTargets(targets), mOrigin(origin), mObject(NULL), mContactPoint(0,0,0), mLeastDistSqr(std::numeric_limits::max()) { } @@ -919,7 +912,7 @@ namespace MWPhysics class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback { public: - ClosestNotMeRayResultCallback(const btCollisionObject* me, const std::vector targets, const btVector3& from, const btVector3& to) + ClosestNotMeRayResultCallback(const btCollisionObject* me, const std::vector& targets, const btVector3& from, const btVector3& to) : btCollisionWorld::ClosestRayResultCallback(from, to) , mMe(me), mTargets(targets) { @@ -945,7 +938,7 @@ namespace MWPhysics const std::vector mTargets; }; - PhysicsSystem::RayResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, MWWorld::ConstPtr ignore, std::vector targets, int mask, int group) const + PhysicsSystem::RayResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore, std::vector targets, int mask, int group) const { btVector3 btFrom = toBullet(from); btVector3 btTo = toBullet(to); diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 3312f10a0..aaf55e2b6 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -114,7 +114,7 @@ namespace MWPhysics }; /// @param me Optional, a Ptr to ignore in the list of results. targets are actors to filter for, ignoring all other actors. - RayResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, MWWorld::ConstPtr ignore = MWWorld::ConstPtr(), + RayResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore = MWWorld::ConstPtr(), std::vector targets = std::vector(), int mask = CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door, int group=0xff) const; @@ -181,7 +181,7 @@ namespace MWPhysics btCollisionDispatcher* mDispatcher; btCollisionWorld* mCollisionWorld; - std::auto_ptr mShapeManager; + std::unique_ptr mShapeManager; Resource::ResourceSystem* mResourceSystem; typedef std::map ObjectMap; @@ -211,12 +211,12 @@ namespace MWPhysics float mTimeAccum; float mWaterHeight; - float mWaterEnabled; + bool mWaterEnabled; - std::auto_ptr mWaterCollisionObject; - std::auto_ptr mWaterCollisionShape; + std::unique_ptr mWaterCollisionObject; + std::unique_ptr mWaterCollisionShape; - std::auto_ptr mDebugDrawer; + std::unique_ptr mDebugDrawer; osg::ref_ptr mParentNode; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index ba4307c89..98d29bfc9 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -282,7 +282,7 @@ namespace MWRender class GlowUpdater : public SceneUtil::StateSetUpdater { public: - GlowUpdater(int texUnit, osg::Vec4f color, const std::vector >& textures, + GlowUpdater(int texUnit, const osg::Vec4f& color, const std::vector >& textures, osg::Node* node, float duration, Resource::ResourceSystem* resourcesystem) : mTexUnit(texUnit) , mColor(color) @@ -383,7 +383,7 @@ namespace MWRender return mDone; } - void setColor(osg::Vec4f color) + void setColor(const osg::Vec4f& color) { mColor = color; mColorChanged = true; @@ -546,7 +546,7 @@ namespace MWRender if(!mResourceSystem->getVFS()->exists(kfname)) return; - boost::shared_ptr animsrc; + std::shared_ptr animsrc; animsrc.reset(new AnimSource); animsrc->mKeyframes = mResourceSystem->getKeyframeManager()->get(kfname); @@ -598,7 +598,7 @@ namespace MWRender mStates.clear(); for(size_t i = 0;i < sNumBlendMasks;i++) - mAnimationTimePtr[i]->setTimePtr(boost::shared_ptr()); + mAnimationTimePtr[i]->setTimePtr(std::shared_ptr()); mAccumCtrl = NULL; @@ -881,12 +881,12 @@ namespace MWRender active = state; } - mAnimationTimePtr[blendMask]->setTimePtr(active == mStates.end() ? boost::shared_ptr() : active->second.mTime); + mAnimationTimePtr[blendMask]->setTimePtr(active == mStates.end() ? std::shared_ptr() : active->second.mTime); // add external controllers for the AnimSource active in this blend mask if (active != mStates.end()) { - boost::shared_ptr animsrc = active->second.mSource; + std::shared_ptr animsrc = active->second.mSource; for (AnimSource::ControllerMap::iterator it = animsrc->mControllerMap[blendMask].begin(); it != animsrc->mControllerMap[blendMask].end(); ++it) { @@ -1058,11 +1058,9 @@ namespace MWRender float timepassed = duration * state.mSpeedMult; while(state.mPlaying) { - float targetTime; - if (!state.shouldLoop()) { - targetTime = state.getTime() + timepassed; + float targetTime = state.getTime() + timepassed; if(textkey == textkeys.end() || textkey->first > targetTime) { if(mAccumCtrl && state.mTime == mAnimationTimePtr[0]->getTimePtr()) @@ -1364,7 +1362,7 @@ namespace MWRender useQuadratic, quadraticValue, quadraticRadiusMult, useLinear, linearRadiusMult, linearValue); } - void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture) + void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture) { if (!mObjectRoot.get()) return; @@ -1408,9 +1406,9 @@ namespace MWRender params.mEffectId = effectId; params.mBoneName = bonename; - params.mAnimTime = boost::shared_ptr(new EffectAnimationTime); + params.mAnimTime = std::shared_ptr(new EffectAnimationTime); - SceneUtil::AssignControllerSourcesVisitor assignVisitor(boost::shared_ptr(params.mAnimTime)); + SceneUtil::AssignControllerSourcesVisitor assignVisitor(std::shared_ptr(params.mAnimTime)); node->accept(assignVisitor); overrideFirstRootTexture(texture, mResourceSystem, node); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 27572544f..5aec80f5d 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -69,7 +69,7 @@ private: void operator= (const PartHolder&); PartHolder(const PartHolder&); }; -typedef boost::shared_ptr PartHolderPtr; +typedef std::shared_ptr PartHolderPtr; class Animation : public osg::Referenced { @@ -146,13 +146,13 @@ protected: class AnimationTime : public SceneUtil::ControllerSource { private: - boost::shared_ptr mTimePtr; + std::shared_ptr mTimePtr; public: - void setTimePtr(boost::shared_ptr time) + void setTimePtr(std::shared_ptr time) { mTimePtr = time; } - boost::shared_ptr getTimePtr() const + std::shared_ptr getTimePtr() const { return mTimePtr; } virtual float getValue(osg::NodeVisitor* nv); @@ -170,13 +170,13 @@ protected: struct AnimSource; struct AnimState { - boost::shared_ptr mSource; + std::shared_ptr mSource; float mStartTime; float mLoopStartTime; float mLoopStopTime; float mStopTime; - typedef boost::shared_ptr TimePtr; + typedef std::shared_ptr TimePtr; TimePtr mTime; float mSpeedMult; @@ -212,7 +212,7 @@ protected: typedef std::map AnimStateMap; AnimStateMap mStates; - typedef std::vector > AnimSourceList; + typedef std::vector > AnimSourceList; AnimSourceList mAnimSources; osg::ref_ptr mInsert; @@ -234,7 +234,7 @@ protected: typedef std::multimap, osg::ref_ptr > ControllerMap; ControllerMap mActiveControllers; - boost::shared_ptr mAnimationTimePtr[sNumBlendMasks]; + std::shared_ptr mAnimationTimePtr[sNumBlendMasks]; // Stored in all lowercase for a case-insensitive lookup typedef std::map > NodeMap; @@ -251,7 +251,7 @@ protected: { std::string mModelName; // Just here so we don't add the same effect twice PartHolderPtr mObjects; - boost::shared_ptr mAnimTime; + std::shared_ptr mAnimTime; float mMaxControllerLength; int mEffectId; bool mLoop; @@ -362,7 +362,7 @@ public: * @param texture override the texture specified in the model's materials - if empty, do not override * @note Will not add an effect twice. */ - void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", std::string texture = ""); + void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", const std::string& texture = ""); void removeEffect (int effectId); void getLoopingEffects (std::vector& out) const; diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index dfb737d5e..f7219959a 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -105,13 +105,13 @@ namespace MWRender }; CharacterPreview::CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, - MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt) + const MWWorld::Ptr& character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt) : mParent(parent) , mResourceSystem(resourceSystem) , mPosition(position) , mLookAt(lookAt) , mCharacter(character) - , mAnimation(NULL) + , mAnimation(nullptr) , mSizeX(sizeX) , mSizeY(sizeY) { @@ -133,6 +133,7 @@ namespace MWRender mCamera->setRenderOrder(osg::Camera::PRE_RENDER); mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture); mCamera->setName("CharacterPreview"); + mCamera->setComputeNearFarMode(osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); mCamera->setNodeMask(Mask_RenderToTexture); @@ -188,7 +189,7 @@ namespace MWRender mParent->addChild(mCamera); - mCharacter.mCell = NULL; + mCharacter.mCell = nullptr; } CharacterPreview::~CharacterPreview () @@ -244,7 +245,7 @@ namespace MWRender // -------------------------------------------------------------------------------------------------- - InventoryPreview::InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character) + InventoryPreview::InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character) : CharacterPreview(parent, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71)) { } @@ -254,7 +255,11 @@ namespace MWRender sizeX = std::max(sizeX, 0); sizeY = std::max(sizeY, 0); - mCamera->setViewport(0, mSizeY-sizeY, std::min(mSizeX, sizeX), std::min(mSizeY, sizeY)); + // NB Camera::setViewport has threading issues + osg::ref_ptr stateset = new osg::StateSet; + mViewport = new osg::Viewport(0, mSizeY-sizeY, std::min(mSizeX, sizeX), std::min(mSizeY, sizeY)); + stateset->setAttributeAndModes(mViewport); + mCamera->setStateSet(stateset); redraw(); } @@ -331,8 +336,10 @@ namespace MWRender int InventoryPreview::getSlotSelected (int posX, int posY) { - float projX = (posX / mCamera->getViewport()->width()) * 2 - 1.f; - float projY = (posY / mCamera->getViewport()->height()) * 2 - 1.f; + if (!mViewport) + return -1; + float projX = (posX / mViewport->width()) * 2 - 1.f; + float projY = (posY / mViewport->height()) * 2 - 1.f; // With Intersector::WINDOW, the intersection ratios are slightly inaccurate. Seems to be a // precision issue - compiling with OSG_USE_FLOAT_MATRIX=0, Intersector::WINDOW works ok. // Using Intersector::PROJECTION results in better precision because the start/end points and the model matrices diff --git a/apps/openmw/mwrender/characterpreview.hpp b/apps/openmw/mwrender/characterpreview.hpp index 273bacedb..b71bffb62 100644 --- a/apps/openmw/mwrender/characterpreview.hpp +++ b/apps/openmw/mwrender/characterpreview.hpp @@ -17,6 +17,7 @@ namespace osg class Texture2D; class Camera; class Group; + class Viewport; } namespace MWRender @@ -28,7 +29,7 @@ namespace MWRender class CharacterPreview { public: - CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, + CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt); virtual ~CharacterPreview(); @@ -73,7 +74,7 @@ namespace MWRender { public: - InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character); + InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character); void updatePtr(const MWWorld::Ptr& ptr); @@ -83,6 +84,8 @@ namespace MWRender int getSlotSelected(int posX, int posY); protected: + osg::ref_ptr mViewport; + virtual void onSetup(); }; diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index cb6489ef4..2ad362b33 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -59,7 +59,7 @@ CreatureWeaponAnimation::CreatureWeaponAnimation(const MWWorld::Ptr &ptr, const updateParts(); } - mWeaponAnimationTime = boost::shared_ptr(new WeaponAnimationTime(this)); + mWeaponAnimationTime = std::shared_ptr(new WeaponAnimationTime(this)); } void CreatureWeaponAnimation::showWeapons(bool showWeapon) @@ -143,7 +143,7 @@ void CreatureWeaponAnimation::updatePart(PartHolderPtr& scene, int slot) else mAmmunition.reset(); - boost::shared_ptr source; + std::shared_ptr source; if (slot == MWWorld::InventoryStore::Slot_CarriedRight) source = mWeaponAnimationTime; diff --git a/apps/openmw/mwrender/creatureanimation.hpp b/apps/openmw/mwrender/creatureanimation.hpp index bf813075e..ff959a551 100644 --- a/apps/openmw/mwrender/creatureanimation.hpp +++ b/apps/openmw/mwrender/creatureanimation.hpp @@ -61,7 +61,7 @@ namespace MWRender bool mShowWeapons; bool mShowCarriedLeft; - boost::shared_ptr mWeaponAnimationTime; + std::shared_ptr mWeaponAnimationTime; }; } diff --git a/apps/openmw/mwrender/effectmanager.hpp b/apps/openmw/mwrender/effectmanager.hpp index 83acc4c60..5873c00dd 100644 --- a/apps/openmw/mwrender/effectmanager.hpp +++ b/apps/openmw/mwrender/effectmanager.hpp @@ -1,13 +1,12 @@ #ifndef OPENMW_MWRENDER_EFFECTMANAGER_H #define OPENMW_MWRENDER_EFFECTMANAGER_H -#include #include +#include +#include #include -#include - namespace osg { class Group; @@ -44,7 +43,7 @@ namespace MWRender struct Effect { float mMaxControllerLength; - boost::shared_ptr mAnimTime; + std::shared_ptr mAnimTime; }; typedef std::map, Effect> EffectMap; diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 02bc5d01f..b78c4dcd2 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -109,7 +109,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell) if (segment.mFogOfWarImage && segment.mHasFogState) { - std::auto_ptr fog (new ESM::FogState()); + std::unique_ptr fog (new ESM::FogState()); fog->mFogTextures.push_back(ESM::FogTexture()); segment.saveFogOfWar(fog->mFogTextures.back()); @@ -126,7 +126,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell) const int segsX = static_cast(std::ceil(length.x() / mMapWorldSize)); const int segsY = static_cast(std::ceil(length.y() / mMapWorldSize)); - std::auto_ptr fog (new ESM::FogState()); + std::unique_ptr fog (new ESM::FogState()); fog->mBounds.mMinX = mBounds.xMin(); fog->mBounds.mMaxX = mBounds.xMax(); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 87b6ae2bc..73927e0ab 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -99,7 +99,7 @@ private: private: void resetBlinkTimer(); public: - HeadAnimationTime(MWWorld::Ptr reference); + HeadAnimationTime(const MWWorld::Ptr& reference); void updatePtr(const MWWorld::Ptr& updated); @@ -128,7 +128,7 @@ public: { } - void setOffset(osg::Vec3f offset) + void setOffset(const osg::Vec3f& offset) { mOffset = offset; } @@ -155,7 +155,7 @@ private: // -------------------------------------------------------------------------------------------------------------- -HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference) +HeadAnimationTime::HeadAnimationTime(const MWWorld::Ptr& reference) : mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mEnabled(true), mValue(0) { resetBlinkTimer(); @@ -286,8 +286,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr par { mNpc = mPtr.get()->mBase; - mHeadAnimationTime = boost::shared_ptr(new HeadAnimationTime(mPtr)); - mWeaponAnimationTime = boost::shared_ptr(new WeaponAnimationTime(this)); + mHeadAnimationTime = std::shared_ptr(new HeadAnimationTime(mPtr)); + mWeaponAnimationTime = std::shared_ptr(new WeaponAnimationTime(this)); for(size_t i = 0;i < ESM::PRT_Count;i++) { @@ -726,6 +726,19 @@ void NpcAnimation::removePartGroup(int group) } } +bool NpcAnimation::isFirstPersonPart(const ESM::BodyPart* bodypart) +{ + return (bodypart->mId.size() >= 3) + && bodypart->mId[bodypart->mId.size()-3] == '1' + && bodypart->mId[bodypart->mId.size()-2] == 's' + && bodypart->mId[bodypart->mId.size()-1] == 't'; +} + +bool NpcAnimation::isFemalePart(const ESM::BodyPart* bodypart) +{ + return bodypart->mData.mFlags & ESM::BodyPart::BPF_Female; +} + bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int group, int priority, const std::string &mesh, bool enchantedGlow, osg::Vec4f* glowColor) { if(priority <= mPartPriorities[type]) @@ -765,7 +778,7 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g osg::Node* node = mObjectParts[type]->getNode(); if (node->getNumChildrenRequiringUpdateTraversal() > 0) { - boost::shared_ptr src; + std::shared_ptr src; if (type == ESM::PRT_Head) { src = mHeadAnimationTime; @@ -1096,46 +1109,79 @@ const std::vector& NpcAnimation::getBodyParts(const std:: if (!Misc::StringUtils::ciEqual(bodypart.mRace, race)) continue; - bool partFirstPerson = (bodypart.mId.size() >= 3) - && bodypart.mId[bodypart.mId.size()-3] == '1' - && bodypart.mId[bodypart.mId.size()-2] == 's' - && bodypart.mId[bodypart.mId.size()-1] == 't'; - if(partFirstPerson != (firstPerson)) + bool partFirstPerson = isFirstPersonPart(&bodypart); + + bool isHand = bodypart.mData.mPart == ESM::BodyPart::MP_Hand || + bodypart.mData.mPart == ESM::BodyPart::MP_Wrist || + bodypart.mData.mPart == ESM::BodyPart::MP_Forearm || + bodypart.mData.mPart == ESM::BodyPart::MP_Upperarm; + + bool isSameGender = isFemalePart(&bodypart) == female; + + /* A fallback for the arms if 1st person is missing: + 1. Try to use 3d person skin for same gender + 2. Try to use 1st person skin for male, if female == true + 3. Try to use 3d person skin for male, if female == true + + A fallback in another cases: allow to use male bodyparts, if female == true + */ + if (firstPerson && isHand && !partFirstPerson) { - if(firstPerson && (bodypart.mData.mPart == ESM::BodyPart::MP_Hand || - bodypart.mData.mPart == ESM::BodyPart::MP_Wrist || - bodypart.mData.mPart == ESM::BodyPart::MP_Forearm || - bodypart.mData.mPart == ESM::BodyPart::MP_Upperarm)) + // Allow 3rd person skins as a fallback for the arms if 1st person is missing + BodyPartMapType::const_iterator bIt = sBodyPartMap.lower_bound(BodyPartMapType::key_type(bodypart.mData.mPart)); + while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart) { - /* Allow 3rd person skins as a fallback for the arms if 1st person is missing. */ - BodyPartMapType::const_iterator bIt = sBodyPartMap.lower_bound(BodyPartMapType::key_type(bodypart.mData.mPart)); - while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart) - { - if(!parts[bIt->second]) - parts[bIt->second] = &*it; - ++bIt; - } + // If we have no fallback bodypart now and bodypart is for same gender (1) + if(!parts[bIt->second] && isSameGender) + parts[bIt->second] = &bodypart; + + // If we have fallback bodypart for other gender and found fallback for current gender (1) + else if(isSameGender && isFemalePart(parts[bIt->second]) != female) + parts[bIt->second] = &bodypart; + + // If we have no fallback bodypart and searching for female bodyparts (3) + else if(!parts[bIt->second] && female) + parts[bIt->second] = &bodypart; + + ++bIt; } + continue; } - if ((female) != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female)) + // Don't allow to use podyparts for a different view + if (partFirstPerson != firstPerson) + continue; + + if (female && !isFemalePart(&bodypart)) { - // Allow opposite gender's parts as fallback if parts for our gender are missing + // Allow male parts as fallback for females if female parts are missing BodyPartMapType::const_iterator bIt = sBodyPartMap.lower_bound(BodyPartMapType::key_type(bodypart.mData.mPart)); while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart) { + // If we have no fallback bodypart now if(!parts[bIt->second]) - parts[bIt->second] = &*it; + parts[bIt->second] = &bodypart; + + // If we have 3d person fallback bodypart for hand and 1st person fallback found (2) + else if(isHand && !isFirstPersonPart(parts[bIt->second]) && partFirstPerson) + parts[bIt->second] = &bodypart; + ++bIt; } + continue; } + // Don't allow to use podyparts for another gender + if (female != isFemalePart(&bodypart)) + continue; + + // Use properly found bodypart, replacing fallbacks BodyPartMapType::const_iterator bIt = sBodyPartMap.lower_bound(BodyPartMapType::key_type(bodypart.mData.mPart)); while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart) { - parts[bIt->second] = &*it; + parts[bIt->second] = &bodypart; ++bIt; } } diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 427a1baf8..7f3a8da2d 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -64,8 +64,8 @@ private: // Field of view to use when rendering first person meshes float mFirstPersonFieldOfView; - boost::shared_ptr mHeadAnimationTime; - boost::shared_ptr mWeaponAnimationTime; + std::shared_ptr mHeadAnimationTime; + std::shared_ptr mWeaponAnimationTime; bool mSoundsDisabled; @@ -90,6 +90,9 @@ private: osg::ref_ptr mFirstPersonNeckController; + static bool isFirstPersonPart(const ESM::BodyPart* bodypart); + static bool isFemalePart(const ESM::BodyPart* bodypart); + protected: virtual void addControllers(); diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index d4cbf25fe..f0a3d2e38 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -38,6 +38,8 @@ Objects::~Objects() void Objects::insertBegin(const MWWorld::Ptr& ptr) { + assert(mObjects.find(ptr) == mObjects.end()); + osg::ref_ptr cellnode; CellMap::iterator found = mCellSceneNodes.find(ptr.getCell()); @@ -90,9 +92,8 @@ void Objects::insertCreature(const MWWorld::Ptr &ptr, const std::string &mesh, b else anim = new CreatureAnimation(ptr, mesh, mResourceSystem); - ptr.getClass().getContainerStore(ptr).setContListener(static_cast(anim.get())); - - mObjects.insert(std::make_pair(ptr, anim)); + if (mObjects.insert(std::make_pair(ptr, anim)).second) + ptr.getClass().getContainerStore(ptr).setContListener(static_cast(anim.get())); } void Objects::insertNPC(const MWWorld::Ptr &ptr) @@ -102,10 +103,11 @@ void Objects::insertNPC(const MWWorld::Ptr &ptr) osg::ref_ptr anim (new NpcAnimation(ptr, osg::ref_ptr(ptr.getRefData().getBaseNode()), mResourceSystem)); - ptr.getClass().getInventoryStore(ptr).setInvListener(anim.get(), ptr); - ptr.getClass().getInventoryStore(ptr).setContListener(anim.get()); - - mObjects.insert(std::make_pair(ptr, anim)); + if (mObjects.insert(std::make_pair(ptr, anim)).second) + { + ptr.getClass().getInventoryStore(ptr).setInvListener(anim.get(), ptr); + ptr.getClass().getInventoryStore(ptr).setContListener(anim.get()); + } } bool Objects::removeObject (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwrender/objects.hpp b/apps/openmw/mwrender/objects.hpp index 8864e4483..659853763 100644 --- a/apps/openmw/mwrender/objects.hpp +++ b/apps/openmw/mwrender/objects.hpp @@ -37,7 +37,7 @@ class Animation; class PtrHolder : public osg::Object { public: - PtrHolder(MWWorld::Ptr ptr) + PtrHolder(const MWWorld::Ptr& ptr) : mPtr(ptr) { } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 87c13f981..820fdab49 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -258,6 +258,7 @@ namespace MWRender mTerrain.reset(new Terrain::QuadTreeWorld(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile)); else mTerrain.reset(new Terrain::TerrainGrid(sceneRoot, mRootNode, mResourceSystem, mTerrainStorage, Mask_Terrain, Mask_PreCompile)); + mTerrain->setDefaultViewer(mViewer->getCamera()); mCamera.reset(new Camera(mViewer->getCamera())); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 075357335..e575456d9 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -224,16 +224,16 @@ namespace MWRender osg::ref_ptr mSunLight; - std::auto_ptr mPathgrid; - std::auto_ptr mObjects; - std::auto_ptr mWater; - std::auto_ptr mTerrain; + std::unique_ptr mPathgrid; + std::unique_ptr mObjects; + std::unique_ptr mWater; + std::unique_ptr mTerrain; TerrainStorage* mTerrainStorage; - std::auto_ptr mSky; - std::auto_ptr mEffectManager; + std::unique_ptr mSky; + std::unique_ptr mEffectManager; osg::ref_ptr mPlayerAnimation; osg::ref_ptr mPlayerNode; - std::auto_ptr mCamera; + std::unique_ptr mCamera; osg::Vec3f mCurrentCameraPos; osg::ref_ptr mStateUpdater; diff --git a/apps/openmw/mwrender/ripplesimulation.cpp b/apps/openmw/mwrender/ripplesimulation.cpp index 00082f033..141a3eb87 100644 --- a/apps/openmw/mwrender/ripplesimulation.cpp +++ b/apps/openmw/mwrender/ripplesimulation.cpp @@ -47,7 +47,7 @@ namespace } osg::ref_ptr controller (new NifOsg::FlipController(0, 0.3f/rippleFrameCount, textures)); - controller->setSource(boost::shared_ptr(new SceneUtil::FrameTimeSource)); + controller->setSource(std::shared_ptr(new SceneUtil::FrameTimeSource)); node->addUpdateCallback(controller); osg::ref_ptr stateset (new osg::StateSet); diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 09c7af6a2..e6aa013ec 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -1525,7 +1525,7 @@ void SkyManager::setWeather(const WeatherResult& weather) } mParticleEffect = mSceneManager->getInstance(mCurrentParticleEffect, mParticleNode); - SceneUtil::AssignControllerSourcesVisitor assignVisitor(boost::shared_ptr(new SceneUtil::FrameTimeSource)); + SceneUtil::AssignControllerSourcesVisitor assignVisitor(std::shared_ptr(new SceneUtil::FrameTimeSource)); mParticleEffect->accept(assignVisitor); AlphaFader::SetupVisitor alphaFaderSetupVisitor; diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index e047a9832..863ecc77d 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -189,9 +189,9 @@ namespace MWRender osg::ref_ptr mAtmosphereUpdater; - std::auto_ptr mSun; - std::auto_ptr mMasser; - std::auto_ptr mSecunda; + std::unique_ptr mSun; + std::unique_ptr mMasser; + std::unique_ptr mSecunda; osg::ref_ptr mRainNode; osg::ref_ptr mRainParticleSystem; diff --git a/apps/openmw/mwrender/terrainstorage.hpp b/apps/openmw/mwrender/terrainstorage.hpp index cf4011d45..6f716e752 100644 --- a/apps/openmw/mwrender/terrainstorage.hpp +++ b/apps/openmw/mwrender/terrainstorage.hpp @@ -29,7 +29,7 @@ namespace MWRender LandManager* getLandManager() const; private: - std::auto_ptr mLandManager; + std::unique_ptr mLandManager; Resource::ResourceSystem* mResourceSystem; }; diff --git a/apps/openmw/mwrender/util.cpp b/apps/openmw/mwrender/util.cpp index 74047b58b..ed10d86ac 100644 --- a/apps/openmw/mwrender/util.cpp +++ b/apps/openmw/mwrender/util.cpp @@ -14,7 +14,7 @@ namespace MWRender class TextureOverrideVisitor : public osg::NodeVisitor { public: - TextureOverrideVisitor(std::string texture, Resource::ResourceSystem* resourcesystem) + TextureOverrideVisitor(const std::string& texture, Resource::ResourceSystem* resourcesystem) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) , mTexture(texture) , mResourcesystem(resourcesystem) diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index d2ad1f9b5..0ed389bdf 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include @@ -28,11 +26,9 @@ #include #include -#include #include -#include #include @@ -488,7 +484,7 @@ void Water::createSimpleWaterStateSet(osg::Node* node, float alpha) float fps = mFallback->getFallbackFloat("Water_SurfaceFPS"); osg::ref_ptr controller (new NifOsg::FlipController(0, 1.f/fps, textures)); - controller->setSource(boost::shared_ptr(new SceneUtil::FrameTimeSource)); + controller->setSource(std::shared_ptr(new SceneUtil::FrameTimeSource)); node->setUpdateCallback(controller); stateset->setTextureAttributeAndModes(0, textures[0], osg::StateAttribute::ON); diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index 29e78cf52..33b314c51 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -58,7 +58,7 @@ namespace MWRender const Fallback::Map* mFallback; osg::ref_ptr mIncrementalCompileOperation; - std::auto_ptr mSimulation; + std::unique_ptr mSimulation; osg::ref_ptr mRefraction; osg::ref_ptr mReflection; diff --git a/apps/openmw/mwscript/animationextensions.cpp b/apps/openmw/mwscript/animationextensions.cpp index 347bbca56..e737d8ea1 100644 --- a/apps/openmw/mwscript/animationextensions.cpp +++ b/apps/openmw/mwscript/animationextensions.cpp @@ -42,6 +42,9 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); + if (!ptr.getRefData().isEnabled()) + return; + std::string group = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); @@ -69,6 +72,9 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); + if (!ptr.getRefData().isEnabled()) + return; + std::string group = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); diff --git a/apps/openmw/mwscript/containerextensions.cpp b/apps/openmw/mwscript/containerextensions.cpp index b7a7cafe6..dfc066bcd 100644 --- a/apps/openmw/mwscript/containerextensions.cpp +++ b/apps/openmw/mwscript/containerextensions.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -199,7 +198,7 @@ namespace MWScript MWBase::Environment::get().getWindowManager()->useItem(*it); else { - boost::shared_ptr action = it->getClass().use(*it); + std::shared_ptr action = it->getClass().use(*it); // No equip sound for actors other than the player action->execute(ptr, true); } diff --git a/apps/openmw/mwscript/controlextensions.cpp b/apps/openmw/mwscript/controlextensions.cpp index 626fafb5a..21b3b5587 100644 --- a/apps/openmw/mwscript/controlextensions.cpp +++ b/apps/openmw/mwscript/controlextensions.cpp @@ -9,12 +9,14 @@ #include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/world.hpp" #include "../mwworld/class.hpp" #include "../mwworld/ptr.hpp" #include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/movement.hpp" #include "interpretercontext.hpp" #include "ref.hpp" @@ -167,7 +169,11 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayerPtr(); - runtime.push (ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Run)); + const MWWorld::Class &cls = ptr.getClass(); + + bool isRunning = MWBase::Environment::get().getMechanicsManager()->isRunning(ptr); + + runtime.push (isRunning && cls.getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Run)); } }; @@ -177,8 +183,12 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayerPtr(); - runtime.push (ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Sneak)); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr(); + const MWWorld::Class &cls = ptr.getClass(); + + bool isSneaking = MWBase::Environment::get().getMechanicsManager()->isSneaking(ptr); + + runtime.push (isSneaking && cls.getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Sneak)); } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 0c70b6996..26d7916b1 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -137,7 +137,7 @@ namespace MWScript InterpreterContext::InterpreterContext ( - MWScript::Locals *locals, MWWorld::Ptr reference, const std::string& targetId) + MWScript::Locals *locals, const MWWorld::Ptr& reference, const std::string& targetId) : mLocals (locals), mReference (reference), mTargetId (targetId) { // If we run on a reference (local script, dialogue script or console with object @@ -478,7 +478,7 @@ namespace MWScript void InterpreterContext::executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor) { - boost::shared_ptr action = (ptr.getClass().activate(ptr, actor)); + std::shared_ptr action = (ptr.getClass().activate(ptr, actor)); action->execute (actor); if (action->getTarget() != MWWorld::Ptr() && action->getTarget() != ptr) { diff --git a/apps/openmw/mwscript/interpretercontext.hpp b/apps/openmw/mwscript/interpretercontext.hpp index fdd5aa55f..ac8e1833b 100644 --- a/apps/openmw/mwscript/interpretercontext.hpp +++ b/apps/openmw/mwscript/interpretercontext.hpp @@ -1,8 +1,6 @@ #ifndef GAME_SCRIPT_INTERPRETERCONTEXT_H #define GAME_SCRIPT_INTERPRETERCONTEXT_H -#include - #include #include "../mwworld/ptr.hpp" @@ -51,7 +49,7 @@ namespace MWScript public: - InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference, + InterpreterContext (MWScript::Locals *locals, const MWWorld::Ptr& reference, const std::string& targetId = ""); ///< The ownership of \a locals is not transferred. 0-pointer allowed. diff --git a/apps/openmw/mwscript/skyextensions.cpp b/apps/openmw/mwscript/skyextensions.cpp index e0fccd16d..479c9d70c 100644 --- a/apps/openmw/mwscript/skyextensions.cpp +++ b/apps/openmw/mwscript/skyextensions.cpp @@ -1,5 +1,7 @@ #include "skyextensions.hpp" +#include + #include #include diff --git a/apps/openmw/mwscript/soundextensions.cpp b/apps/openmw/mwscript/soundextensions.cpp index 516c58b26..bedc02138 100644 --- a/apps/openmw/mwscript/soundextensions.cpp +++ b/apps/openmw/mwscript/soundextensions.cpp @@ -82,7 +82,7 @@ namespace MWScript std::string sound = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - MWBase::Environment::get().getSoundManager()->playSound (sound, 1.0, 1.0); + MWBase::Environment::get().getSoundManager()->playSound(sound, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoEnv); } }; @@ -101,7 +101,7 @@ namespace MWScript Interpreter::Type_Float pitch = runtime[0].mFloat; runtime.pop(); - MWBase::Environment::get().getSoundManager()->playSound (sound, volume, pitch); + MWBase::Environment::get().getSoundManager()->playSound(sound, volume, pitch, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoEnv); } }; diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 038b2338b..1f1834761 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -1,10 +1,10 @@ #include "ffmpeg_decoder.hpp" -// auto_ptr #include #include #include +#include #include diff --git a/apps/openmw/mwsound/loudness.cpp b/apps/openmw/mwsound/loudness.cpp index 19e5cd586..ae31d6094 100644 --- a/apps/openmw/mwsound/loudness.cpp +++ b/apps/openmw/mwsound/loudness.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "soundmanagerimp.hpp" diff --git a/apps/openmw/mwsound/movieaudiofactory.cpp b/apps/openmw/mwsound/movieaudiofactory.cpp index af9932f74..2d7f3a969 100644 --- a/apps/openmw/mwsound/movieaudiofactory.cpp +++ b/apps/openmw/mwsound/movieaudiofactory.cpp @@ -92,7 +92,7 @@ namespace MWSound } MWBase::SoundStreamPtr mAudioTrack; - boost::shared_ptr mDecoderBridge; + std::shared_ptr mDecoderBridge; }; @@ -156,9 +156,9 @@ namespace MWSound - boost::shared_ptr MovieAudioFactory::createDecoder(Video::VideoState* videoState) + std::shared_ptr MovieAudioFactory::createDecoder(Video::VideoState* videoState) { - boost::shared_ptr decoder(new MWSound::MovieAudioDecoder(videoState)); + std::shared_ptr decoder(new MWSound::MovieAudioDecoder(videoState)); decoder->setupFormat(); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); diff --git a/apps/openmw/mwsound/movieaudiofactory.hpp b/apps/openmw/mwsound/movieaudiofactory.hpp index 1391a0012..6ec49a4d3 100644 --- a/apps/openmw/mwsound/movieaudiofactory.hpp +++ b/apps/openmw/mwsound/movieaudiofactory.hpp @@ -8,7 +8,7 @@ namespace MWSound class MovieAudioFactory : public Video::MovieAudioFactory { - virtual boost::shared_ptr createDecoder(Video::VideoState* videoState); + virtual std::shared_ptr createDecoder(Video::VideoState* videoState); }; } diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index fb259ff5f..042795a8c 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -217,7 +217,7 @@ private: DecoderPtr mDecoder; - std::auto_ptr mLoudnessAnalyzer; + std::unique_ptr mLoudnessAnalyzer; volatile bool mIsFinished; diff --git a/apps/openmw/mwsound/openal_output.hpp b/apps/openmw/mwsound/openal_output.hpp index 24c8609d6..ea3f393ff 100644 --- a/apps/openmw/mwsound/openal_output.hpp +++ b/apps/openmw/mwsound/openal_output.hpp @@ -33,7 +33,7 @@ namespace MWSound Environment mListenerEnv; struct StreamThread; - std::auto_ptr mStreamThread; + std::unique_ptr mStreamThread; void initCommon2D(ALuint source, const osg::Vec3f &pos, ALfloat gain, ALfloat pitch, bool loop, bool useenv); void initCommon3D(ALuint source, const osg::Vec3f &pos, ALfloat mindist, ALfloat maxdist, ALfloat gain, ALfloat pitch, bool loop, bool useenv); diff --git a/apps/openmw/mwsound/sound.hpp b/apps/openmw/mwsound/sound.hpp index a59027fc1..8c663fb1e 100644 --- a/apps/openmw/mwsound/sound.hpp +++ b/apps/openmw/mwsound/sound.hpp @@ -1,6 +1,8 @@ #ifndef GAME_SOUND_SOUND_H #define GAME_SOUND_SOUND_H +#include + #include "sound_output.hpp" namespace MWSound diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 9b5fb1b3d..c6f663059 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -34,7 +34,7 @@ namespace MWSound { - SoundManager::SoundManager(const VFS::Manager* vfs, const std::map& fallbackMap, bool useSound) + SoundManager::SoundManager(const VFS::Manager* vfs, const std::map& fallbackMap, bool useSound) : mVFS(vfs) , mFallback(fallbackMap) , mOutput(new DEFAULT_OUTPUT(*this)) @@ -259,7 +259,7 @@ namespace MWSound float basevol = volumeFromType(Play_TypeVoice); if(playlocal) { - sound.reset(new Stream(1.0f, basevol, 1.0f, Play_Normal|Play_TypeVoice|Play_2D)); + sound.reset(new Stream(1.0f, basevol, 1.0f, Play_NoEnv|Play_TypeVoice|Play_2D)); mOutput->streamSound(decoder, sound); } else @@ -328,9 +328,22 @@ namespace MWSound } } + void SoundManager::advanceMusic(const std::string& filename) + { + if (!isMusicPlaying()) + { + streamMusicFull(filename); + return; + } + + mNextMusic = filename; + + mMusic->setFadeout(0.5f); + } + void SoundManager::streamMusic(const std::string& filename) { - streamMusicFull("Music/"+filename); + advanceMusic("Music/"+filename); } void SoundManager::startRandomTitle() @@ -370,7 +383,7 @@ namespace MWSound i = (i+1) % filelist.size(); } - streamMusicFull(filelist[i]); + advanceMusic(filelist[i]); } bool SoundManager::isMusicPlaying() @@ -925,6 +938,8 @@ namespace MWSound env ); + updateMusic(duration); + // Check if any sounds are finished playing, and trash them SoundMap::iterator snditer = mActiveSounds.begin(); while(snditer != mActiveSounds.end()) @@ -1029,6 +1044,23 @@ namespace MWSound } + void SoundManager::updateMusic(float duration) + { + if (!mNextMusic.empty()) + { + mMusic->updateFade(duration); + + mOutput->updateStream(mMusic); + + if (mMusic->getRealVolume() <= 0.f) + { + streamMusicFull(mNextMusic); + mNextMusic.clear(); + } + } + } + + void SoundManager::update(float duration) { if(!mOutput->isInitialized()) diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index abf5edb97..5d911d4be 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -7,8 +7,6 @@ #include #include -#include - #include #include @@ -47,8 +45,7 @@ namespace MWSound const VFS::Manager* mVFS; Fallback::Map mFallback; - - std::auto_ptr mOutput; + std::unique_ptr mOutput; // Caches available music tracks by std::map > mMusicFiles; @@ -66,8 +63,7 @@ namespace MWSound float mNearWaterOutdoorTolerance; std::string mNearWaterIndoorID; std::string mNearWaterOutdoorID; - - typedef std::auto_ptr > SoundBufferList; + typedef std::unique_ptr > SoundBufferList; // List of sound buffers, grown as needed. New enties are added to the // back, allowing existing Sound_Buffer references/pointers to remain // valid. @@ -118,9 +114,14 @@ namespace MWSound MWBase::SoundStreamPtr playVoice(DecoderPtr decoder, const osg::Vec3f &pos, bool playlocal); void streamMusicFull(const std::string& filename); + void advanceMusic(const std::string& filename); + void updateSounds(float duration); void updateRegionSound(float duration); void updateWaterSound(float duration); + void updateMusic(float duration); + + std::string mNextMusic; float volumeFromType(PlayType type) const; diff --git a/apps/openmw/mwstate/character.cpp b/apps/openmw/mwstate/character.cpp index 733ac1171..4f7d365b4 100644 --- a/apps/openmw/mwstate/character.cpp +++ b/apps/openmw/mwstate/character.cpp @@ -1,18 +1,12 @@ #include "character.hpp" -#include - #include -#include -#include #include #include #include -#include - bool MWState::operator< (const Slot& left, const Slot& right) { return left.mTimeStamp -#include -#include // std::isalnum #include @@ -60,7 +58,7 @@ MWState::Character* MWState::CharacterManager::createCharacter(const std::string // The character name is user-supplied, so we need to escape the path for (std::string::const_iterator it = name.begin(); it != name.end(); ++it) { - if (std::isalnum(*it)) // Ignores multibyte characters and non alphanumeric characters + if (isalnum(*it)) // Ignores multibyte characters and non alphanumeric characters stream << *it; else stream << "_"; diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 64c543fb1..14ee5adee 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -7,8 +7,6 @@ #include -#include - #include #include @@ -35,7 +33,6 @@ #include "../mwworld/inventorystore.hpp" #include "../mwmechanics/npcstats.hpp" -#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/actorutil.hpp" #include "../mwscript/globalscripts.hpp" @@ -149,6 +146,9 @@ void MWState::StateManager::newGame (bool bypass) MWBase::Environment::get().getWorld()->startNewGame (bypass); mState = State_Running; + + MWBase::Environment::get().getWindowManager()->fadeScreenOut(0); + MWBase::Environment::get().getWindowManager()->fadeScreenIn(1); } catch (std::exception& e) { diff --git a/apps/openmw/mwworld/action.cpp b/apps/openmw/mwworld/action.cpp index 92e959e41..468207e81 100644 --- a/apps/openmw/mwworld/action.cpp +++ b/apps/openmw/mwworld/action.cpp @@ -4,6 +4,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwmechanics/actorutil.hpp" @@ -26,9 +27,18 @@ void MWWorld::Action::execute (const Ptr& actor, bool noSound) { if(!mSoundId.empty() && !noSound) { + MWBase::SoundManager::PlayMode envType = MWBase::SoundManager::Play_Normal; + + // Action sounds should not have a distortion in GUI mode + // example: take an item or drink a potion underwater + if (actor == MWMechanics::getPlayer() && MWBase::Environment::get().getWindowManager()->isGuiMode()) + { + envType = MWBase::SoundManager::Play_NoEnv; + } + if(mKeepSound && actor == MWMechanics::getPlayer()) MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0, - MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Normal, mSoundOffset + MWBase::SoundManager::Play_TypeSfx, envType, mSoundOffset ); else { @@ -37,12 +47,12 @@ void MWWorld::Action::execute (const Ptr& actor, bool noSound) MWBase::Environment::get().getSoundManager()->playSound3D( (local ? actor : mTarget).getRefData().getPosition().asVec3(), mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, - MWBase::SoundManager::Play_Normal, mSoundOffset + envType, mSoundOffset ); else MWBase::Environment::get().getSoundManager()->playSound3D(local ? actor : mTarget, mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, - MWBase::SoundManager::Play_Normal, mSoundOffset + envType, mSoundOffset ); } } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 6cd495ee6..752659eb6 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -88,7 +89,7 @@ void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const MWWorld::Cells::Cells (const MWWorld::ESMStore& store, std::vector& reader) : mStore (store), mReader (reader), - mIdCache (40, std::pair ("", (CellStore*)0)), /// \todo make cache size configurable + mIdCache (Settings::Manager::getInt("pointers cache size", "Cells"), std::pair ("", (CellStore*)0)), mIdCacheIndex (0) {} diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index aa7d68d8c..4452ad889 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -6,8 +6,7 @@ #include #include #include - -#include +#include #include "livecellref.hpp" #include "cellreflist.hpp" @@ -67,7 +66,7 @@ namespace MWWorld // Even though fog actually belongs to the player and not cells, // it makes sense to store it here since we need it once for each cell. // Note this is NULL until the cell is explored to save some memory - boost::shared_ptr mFogState; + std::shared_ptr mFogState; const ESM::Cell *mCell; State mState; diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 72696e209..e59dde7b1 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -24,7 +24,7 @@ namespace MWWorld { - std::map > Class::sClasses; + std::map > Class::sClasses; Class::Class() {} @@ -108,14 +108,14 @@ namespace MWWorld throw std::runtime_error("class cannot be hit"); } - boost::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const + std::shared_ptr Class::activate (const Ptr& ptr, const Ptr& actor) const { - return boost::shared_ptr (new NullAction); + return std::shared_ptr (new NullAction); } - boost::shared_ptr Class::use (const Ptr& ptr) const + std::shared_ptr Class::use (const Ptr& ptr) const { - return boost::shared_ptr (new NullAction); + return std::shared_ptr (new NullAction); } ContainerStore& Class::getContainerStore (const Ptr& ptr) const @@ -233,7 +233,7 @@ namespace MWWorld if (key.empty()) throw std::logic_error ("Class::get(): attempting to get an empty key"); - std::map >::const_iterator iter = sClasses.find (key); + std::map >::const_iterator iter = sClasses.find (key); if (iter==sClasses.end()) throw std::logic_error ("Class::get(): unknown class key: " + key); @@ -246,7 +246,7 @@ namespace MWWorld throw std::runtime_error ("class does not support persistence"); } - void Class::registerClass(const std::string& key, boost::shared_ptr instance) + void Class::registerClass(const std::string& key, std::shared_ptr instance) { instance->mTypeName = key; sClasses.insert(std::make_pair(key, instance)); @@ -330,23 +330,23 @@ namespace MWWorld { } - boost::shared_ptr Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const + std::shared_ptr Class::defaultItemActivate(const Ptr &ptr, const Ptr &actor) const { if(!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory)) - return boost::shared_ptr(new NullAction()); + return std::shared_ptr(new NullAction()); if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Sound *sound = store.get().searchRandom("WolfItem"); - boost::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); + std::shared_ptr action(new MWWorld::FailedAction("#{sWerewolfRefusal}")); if(sound) action->setSound(sound->mId); return action; } - boost::shared_ptr action(new ActionTake(ptr)); + std::shared_ptr action(new ActionTake(ptr)); action->setSound(getUpSoundId(ptr)); return action; diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 3b1ddb647..097ec0faa 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -2,11 +2,10 @@ #define GAME_MWWORLD_CLASS_H #include +#include #include #include -#include - #include "ptr.hpp" namespace ESM @@ -51,7 +50,7 @@ namespace MWWorld /// \brief Base class for referenceable esm records class Class { - static std::map > sClasses; + static std::map > sClasses; std::string mTypeName; @@ -63,7 +62,7 @@ namespace MWWorld Class(); - boost::shared_ptr defaultItemActivate(const Ptr &ptr, const Ptr &actor) const; + std::shared_ptr defaultItemActivate(const Ptr &ptr, const Ptr &actor) const; ///< Generate default action for activating inventory items virtual Ptr copyToCellImpl(const ConstPtr &ptr, CellStore &cell) const; @@ -139,10 +138,10 @@ namespace MWWorld ///< \return Can the player activate this object? /// (default implementation: true if object's user-readable name is not empty, false otherwise) - virtual boost::shared_ptr activate (const Ptr& ptr, const Ptr& actor) const; + virtual std::shared_ptr activate (const Ptr& ptr, const Ptr& actor) const; ///< Generate action for activation (default implementation: return a null action). - virtual boost::shared_ptr use (const Ptr& ptr) + virtual std::shared_ptr use (const Ptr& ptr) const; ///< Generate action for using via inventory menu (default implementation: return a /// null action). @@ -302,6 +301,10 @@ namespace MWWorld virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const; + virtual bool isActivator() const { + return false; + } + virtual bool isActor() const { return false; } @@ -310,6 +313,10 @@ namespace MWWorld return false; } + virtual bool isDoor() const { + return false; + } + virtual bool isBipedal(const MWWorld::ConstPtr& ptr) const; virtual bool canFly(const MWWorld::ConstPtr& ptr) const; virtual bool canSwim(const MWWorld::ConstPtr& ptr) const; @@ -332,7 +339,7 @@ namespace MWWorld static const Class& get (const std::string& key); ///< If there is no class for this \a key, an exception is thrown. - static void registerClass (const std::string& key, boost::shared_ptr instance); + static void registerClass (const std::string& key, std::shared_ptr instance); virtual int getBaseGold(const MWWorld::ConstPtr& ptr) const; diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index a4154e125..eef10b905 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -156,6 +156,16 @@ int MWWorld::ContainerStore::count(const std::string &id) return total; } +int MWWorld::ContainerStore::restockCount(const std::string &id) +{ + int total=0; + for (MWWorld::ContainerStoreIterator iter (begin()); iter!=end(); ++iter) + if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), id)) + if (iter->getCellRef().getSoul().empty()) + total += iter->getRefData().getCount(); + return total; +} + MWWorld::ContainerStoreListener* MWWorld::ContainerStore::getContListener() const { return mListener; @@ -512,7 +522,7 @@ void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MW for (std::map, int>::iterator it = mLevelledItemMap.begin(); it != mLevelledItemMap.end();) { int spawnedCount = it->second; //How many items should be in shop originally - int itemCount = count(it->first.first); //How many items are there in shop now + int itemCount = restockCount(it->first.first); //How many items are there in shop now //If something was not sold if(itemCount >= spawnedCount) { @@ -578,7 +588,7 @@ void MWWorld::ContainerStore::restock (const ESM::InventoryList& items, const MW else { //Restocking static item - just restock to the max count - int currentCount = count(itemOrList); + int currentCount = restockCount(itemOrList); if (currentCount < std::abs(it->mCount)) addInitialItem(itemOrList, owner, -(std::abs(it->mCount) - currentCount), true); } diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 21e126a32..f27ff1db9 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -162,8 +162,12 @@ namespace MWWorld /// If a compatible stack is found, the item's count is added to that stack, then the original is deleted. /// @return If the item was stacked, return the stack, otherwise return the old (untouched) item. - /// @return How many items with refID \a id are in this container? int count (const std::string& id); + ///< @return How many items with refID \a id are in this container? + + int restockCount (const std::string& id); + ///< Item count with restock adjustments (such as ignoring filled soul gems). + /// @return How many items with refID \a id are in this container? ContainerStoreListener* getContListener() const; void setContListener(ContainerStoreListener* listener); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 44e62c755..a6394757f 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -824,7 +824,7 @@ void MWWorld::InventoryStore::visitEffectSources(MWMechanics::EffectSourceVisito int i=0; for (std::vector::const_iterator effectIt (enchantment.mEffects.mList.begin()); - effectIt!=enchantment.mEffects.mList.end(); ++effectIt) + effectIt!=enchantment.mEffects.mList.end(); ++effectIt, ++i) { // Don't get spell icon display information for enchantments that weren't actually applied if (mMagicEffects.get(MWMechanics::EffectKey(*effectIt)).getMagnitude() == 0) @@ -834,8 +834,6 @@ void MWWorld::InventoryStore::visitEffectSources(MWMechanics::EffectSourceVisito magnitude *= params.mMultiplier; if (magnitude > 0) visitor.visit(MWMechanics::EffectKey(*effectIt), (**iter).getClass().getName(**iter), (**iter).getCellRef().getRefId(), -1, magnitude); - - ++i; } } } @@ -940,7 +938,6 @@ void MWWorld::InventoryStore::purgeEffect(short effectId, const std::string &sou mMagicEffects.add (*effectIt, -magnitude); params[i].mMultiplier = 0; - break; } } } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index fe13a4d60..d233fba6f 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -255,7 +255,7 @@ namespace MWWorld return MWBase::Environment::get().getMechanicsManager()->getEnemiesNearby(getPlayer()).size() != 0; } - void Player::markPosition(CellStore *markedCell, ESM::Position markedPosition) + void Player::markPosition(CellStore *markedCell, const ESM::Position& markedPosition) { mMarkedCell = markedCell; mMarkedPosition = markedPosition; diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 157501803..4ba66e37e 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -61,7 +61,7 @@ namespace MWWorld void setWerewolfSkillsAttributes(); // For mark/recall magic effects - void markPosition (CellStore* markedCell, ESM::Position markedPosition); + void markPosition (CellStore* markedCell, const ESM::Position& markedPosition); void getMarkedPosition (CellStore*& markedCell, ESM::Position& markedPosition) const; /// Interiors can not always be mapped to a world position. However diff --git a/apps/openmw/mwworld/projectilemanager.hpp b/apps/openmw/mwworld/projectilemanager.hpp index 2289706d3..bfa4980e9 100644 --- a/apps/openmw/mwworld/projectilemanager.hpp +++ b/apps/openmw/mwworld/projectilemanager.hpp @@ -73,7 +73,7 @@ namespace MWWorld struct State { osg::ref_ptr mNode; - boost::shared_ptr mEffectAnimationTime; + std::shared_ptr mEffectAnimationTime; int mActorId; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index e27c0b585..c83165239 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -54,6 +54,12 @@ namespace void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, MWRender::RenderingManager& rendering) { + if (ptr.getRefData().getBaseNode() || physics.getActor(ptr)) + { + std::cerr << "Warning: Tried to add " << ptr.getCellRef().getRefId() << " to the scene twice" << std::endl; + return; + } + bool useAnim = ptr.getClass().useAnim(); std::string model = ptr.getClass().getModel(ptr); if (useAnim) @@ -461,6 +467,8 @@ namespace MWWorld mechMgr->updateCell(old, player); mechMgr->watchActor(player); + mPhysics->updatePtr(old, player); + MWBase::Environment::get().getWorld()->adjustSky(); mLastPlayerPos = pos.asVec3(); @@ -476,6 +484,7 @@ namespace MWWorld , mPreloadExteriorGrid(Settings::Manager::getBool("preload exterior grid", "Cells")) , mPreloadDoors(Settings::Manager::getBool("preload doors", "Cells")) , mPreloadFastTravel(Settings::Manager::getBool("preload fast travel", "Cells")) + , mPredictionTime(Settings::Manager::getFloat("prediction time", "Cells")) { mPreloader.reset(new CellPreloader(rendering.getResourceSystem(), physics->getShapeManager(), rendering.getTerrain(), rendering.getLandManager())); mPreloader->setWorkQueue(mRendering.getWorkQueue()); @@ -538,13 +547,9 @@ namespace MWWorld std::cout << "Changing to interior\n"; // unload - int current = 0; CellStoreCollection::iterator active = mActiveCells.begin(); while (active!=mActiveCells.end()) - { unloadCell (active++); - ++current; - } int refsToLoad = cell->count(); loadingListener->setProgressRange(refsToLoad); @@ -687,7 +692,7 @@ namespace MWWorld const MWWorld::ConstPtr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); osg::Vec3f playerPos = player.getRefData().getPosition().asVec3(); osg::Vec3f moved = playerPos - mLastPlayerPos; - osg::Vec3f predictedPos = playerPos + moved / dt; + osg::Vec3f predictedPos = playerPos + moved / dt * mPredictionTime; if (mCurrentCell->isExterior()) exteriorPositions.push_back(predictedPos); diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index f3c2d31ca..e2fac6438 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -57,7 +57,7 @@ namespace MWWorld bool mCellChanged; MWPhysics::PhysicsSystem *mPhysics; MWRender::RenderingManager& mRendering; - std::auto_ptr mPreloader; + std::unique_ptr mPreloader; float mPreloadTimer; int mHalfGridSize; float mCellLoadingThreshold; @@ -67,6 +67,7 @@ namespace MWWorld bool mPreloadExteriorGrid; bool mPreloadDoors; bool mPreloadFastTravel; + float mPredictionTime; osg::Vec3f mLastPlayerPos; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 6ae348966..a9506385d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -222,8 +222,6 @@ namespace MWWorld renderPlayer(); mRendering->resetCamera(); - MWBase::Environment::get().getWindowManager()->updatePlayer(); - // we don't want old weather to persist on a new game // Note that if reset later, the initial ChangeWeather that the chargen script calls will be lost. delete mWeatherManager; @@ -283,6 +281,8 @@ namespace MWWorld if (!mStartupScript.empty()) MWBase::Environment::get().getWindowManager()->executeInConsole(mStartupScript); + + MWBase::Environment::get().getWindowManager()->updatePlayer(); } void World::clear() @@ -309,6 +309,7 @@ namespace MWWorld mDoorStates.clear(); + mGoToJail = false; mTeleportEnabled = true; mLevitationEnabled = true; @@ -378,8 +379,11 @@ namespace MWWorld return; case ESM::REC_PLAY: mPlayer->readRecord(reader, type); - mWorldScene->preloadCell(getPlayerPtr().getCell(), true); - mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3()); + if (getPlayerPtr().isInCell()) + { + mWorldScene->preloadCell(getPlayerPtr().getCell(), true); + mWorldScene->preloadTerrain(getPlayerPtr().getRefData().getPosition().asVec3()); + } break; default: if (!mStore.readRecord (reader, type) && @@ -819,7 +823,10 @@ namespace MWWorld mWeatherManager->advanceTime (hours, incremental); if (!incremental) + { + mRendering->notifyWorldSpaceChanged(); mProjectileManager->clear(); + } hours += mGameHour->getFloat(); @@ -1453,6 +1460,7 @@ namespace MWWorld { osg::Vec3f a(x1,y1,z1); osg::Vec3f b(x2,y2,z2); + MWPhysics::PhysicsSystem::RayResult result = mPhysics->castRay(a, b, MWWorld::Ptr(), std::vector(), MWPhysics::CollisionType_World|MWPhysics::CollisionType_Door); return result.mHit; } @@ -1620,16 +1628,14 @@ namespace MWWorld if (!paused) doPhysics (duration); + updatePlayer(paused); + mPhysics->debugDraw(); mWorldScene->update (duration, paused); - updateWindowManager (); - updateSoundListener(); - updatePlayer(paused); - mSpellPreloadTimer -= duration; if (mSpellPreloadTimer <= 0.f) { @@ -1754,8 +1760,6 @@ namespace MWWorld // inform the GUI about focused object MWWorld::Ptr object = getFacedObject (); - MWBase::Environment::get().getWindowManager()->setFocusObject(object); - // retrieve object dimensions so we know where to place the floating label if (!object.isEmpty ()) { @@ -1764,6 +1768,8 @@ namespace MWWorld MWBase::Environment::get().getWindowManager()->setFocusObjectScreenCoords( screenBounds.x(), screenBounds.y(), screenBounds.z(), screenBounds.w()); } + + MWBase::Environment::get().getWindowManager()->setFocusObject(object); } MWWorld::Ptr World::getFacedObject(float maxDistance, bool ignorePlayer) @@ -2576,7 +2582,25 @@ namespace MWWorld { pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - if (const ESM::Cell *ext = getExterior(name)) { + const ESM::Cell *ext = getExterior(name); + + if (!ext && name.find(',') != std::string::npos) { + try { + int x = std::stoi(name.substr(0, name.find(','))); + int y = std::stoi(name.substr(name.find(',')+1)); + ext = getExterior(x, y)->getCell(); + } + catch (std::invalid_argument) + { + // This exception can be ignored, as this means that name probably refers to a interior cell instead of comma separated coordinates + } + catch (std::out_of_range) + { + throw std::runtime_error("Cell coordinates out of range."); + } + } + + if (ext) { int x = ext->getGridX(); int y = ext->getGridY(); indexToPosition(x, y, pos.pos[0], pos.pos[1], true); @@ -2586,6 +2610,7 @@ namespace MWWorld return true; } + return false; } @@ -2989,7 +3014,7 @@ namespace MWWorld struct AddDetectedReferenceVisitor { - AddDetectedReferenceVisitor(std::vector& out, Ptr detector, World::DetectionType type, float squaredDist) + AddDetectedReferenceVisitor(std::vector& out, const Ptr& detector, World::DetectionType type, float squaredDist) : mOut(out), mDetector(detector), mSquaredDist(squaredDist), mType(type) { } @@ -3358,7 +3383,7 @@ namespace MWWorld if (object.getRefData().activate()) { - boost::shared_ptr action = (object.getClass().activate(object, actor)); + std::shared_ptr action = (object.getClass().activate(object, actor)); action->execute (actor); } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index ce6e27672..a15dcaf3d 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -1,8 +1,6 @@ #ifndef GAME_MWWORLD_WORLDIMP_H #define GAME_MWWORLD_WORLDIMP_H -#include - #include #include @@ -100,7 +98,7 @@ namespace MWWorld std::string mCurrentWorldSpace; - boost::shared_ptr mProjectileManager; + std::shared_ptr mProjectileManager; bool mGodMode; bool mScriptsEnabled; @@ -132,7 +130,6 @@ namespace MWWorld Ptr copyObjectToCell(const ConstPtr &ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos); void updateSoundListener(); - void updateWindowManager (); void updatePlayer(bool paused); void preloadSpells(); @@ -168,9 +165,6 @@ namespace MWWorld float mDistanceToFacedObject; - bool isUnderwater(const MWWorld::ConstPtr &object, const float heightRatio) const; - ///< helper function for implementing isSwimming(), isSubmerged(), isWading() - bool mTeleportEnabled; bool mLevitationEnabled; bool mGoToJail; @@ -466,6 +460,8 @@ namespace MWWorld virtual void update (float duration, bool paused); + virtual void updateWindowManager (); + virtual MWWorld::Ptr placeObject (const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount); ///< copy and place an object into the gameworld at the specified cursor position /// @param object @@ -490,6 +486,7 @@ namespace MWWorld virtual bool isSubmerged(const MWWorld::ConstPtr &object) const; virtual bool isSwimming(const MWWorld::ConstPtr &object) const; virtual bool isUnderwater(const MWWorld::CellStore* cell, const osg::Vec3f &pos) const; + virtual bool isUnderwater(const MWWorld::ConstPtr &object, const float heightRatio) const; virtual bool isWading(const MWWorld::ConstPtr &object) const; virtual bool isWaterWalkingCastableOnTarget(const MWWorld::ConstPtr &target) const; virtual bool isOnGround(const MWWorld::Ptr &ptr) const; diff --git a/apps/openmw_test_suite/CMakeLists.txt b/apps/openmw_test_suite/CMakeLists.txt index 24ea1835a..ea4b1209c 100644 --- a/apps/openmw_test_suite/CMakeLists.txt +++ b/apps/openmw_test_suite/CMakeLists.txt @@ -11,6 +11,8 @@ if (GTEST_FOUND) mwdialogue/test_keywordsearch.cpp esm/test_fixed_string.cpp + + misc/test_stringops.cpp ) source_group(apps\\openmw_test_suite FILES openmw_test_suite.cpp ${UNITTEST_SRC_FILES}) diff --git a/apps/openmw_test_suite/misc/test_stringops.cpp b/apps/openmw_test_suite/misc/test_stringops.cpp new file mode 100644 index 000000000..53a33dbf4 --- /dev/null +++ b/apps/openmw_test_suite/misc/test_stringops.cpp @@ -0,0 +1,45 @@ +#include +#include "components/misc/stringops.hpp" + +struct PartialBinarySearchTest : public ::testing::Test +{ + protected: + std::vector mDataVec; + virtual void SetUp() + { + const char* data[] = { "Head", "Chest", "Tri Head", "Tri Chest", "Bip01" }; + mDataVec = std::vector(data, data+sizeof(data)/sizeof(data[0])); + std::sort(mDataVec.begin(), mDataVec.end(), Misc::StringUtils::ciLess); + } + + virtual void TearDown() + { + } + + bool matches(const std::string& keyword) + { + return Misc::StringUtils::partialBinarySearch(mDataVec.begin(), mDataVec.end(), keyword) != mDataVec.end(); + } +}; + +TEST_F(PartialBinarySearchTest, partial_binary_search_test) +{ + EXPECT_TRUE( matches("Head 01") ); + EXPECT_TRUE( matches("Head") ); + EXPECT_TRUE( matches("Tri Head 01") ); + EXPECT_TRUE( matches("Tri Head") ); + EXPECT_TRUE( matches("tri head") ); + + EXPECT_FALSE( matches("Hea") ); + EXPECT_FALSE( matches(" Head") ); + EXPECT_FALSE( matches("Tri Head") ); +} + +TEST_F (PartialBinarySearchTest, ci_test) +{ + EXPECT_TRUE (Misc::StringUtils::lowerCase("ASD") == "asd"); + + // test to make sure system locale is not used + std::string unicode1 = "\u04151 \u0418"; // CYRILLIC CAPITAL LETTER IE, CYRILLIC CAPITAL LETTER I + EXPECT_TRUE( Misc::StringUtils::lowerCase(unicode1) == unicode1 ); +} diff --git a/apps/wizard/componentselectionpage.cpp b/apps/wizard/componentselectionpage.cpp index 161e51515..d99884966 100644 --- a/apps/wizard/componentselectionpage.cpp +++ b/apps/wizard/componentselectionpage.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include "mainwizard.hpp" @@ -26,7 +25,7 @@ Wizard::ComponentSelectionPage::ComponentSelectionPage(QWidget *parent) : void Wizard::ComponentSelectionPage::updateButton(QListWidgetItem*) { - if (field(QLatin1String("installation.new")).toBool() == true) + if (field(QLatin1String("installation.retailDisc")).toBool() == true) return; // Morrowind is always checked here bool unchecked = true; @@ -60,7 +59,7 @@ void Wizard::ComponentSelectionPage::initializePage() QListWidgetItem *tribunalItem = new QListWidgetItem(QLatin1String("Tribunal")); QListWidgetItem *bloodmoonItem = new QListWidgetItem(QLatin1String("Bloodmoon")); - if (field(QLatin1String("installation.new")).toBool() == true) + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { morrowindItem->setFlags((morrowindItem->flags() & ~Qt::ItemIsEnabled) | Qt::ItemIsUserCheckable); morrowindItem->setData(Qt::CheckStateRole, Qt::Checked); @@ -117,7 +116,7 @@ bool Wizard::ComponentSelectionPage::validatePage() // qDebug() << components << path << mWizard->mInstallations[path]; - if (field(QLatin1String("installation.new")).toBool() == false) { + if (field(QLatin1String("installation.retailDisc")).toBool() == false) { if (components.contains(QLatin1String("Tribunal")) && !components.contains(QLatin1String("Bloodmoon"))) { if (mWizard->mInstallations[path].hasBloodmoon) diff --git a/apps/wizard/conclusionpage.cpp b/apps/wizard/conclusionpage.cpp index 87154732a..f6a6015b8 100644 --- a/apps/wizard/conclusionpage.cpp +++ b/apps/wizard/conclusionpage.cpp @@ -16,14 +16,14 @@ Wizard::ConclusionPage::ConclusionPage(QWidget *parent) : void Wizard::ConclusionPage::initializePage() { // Write the path to openmw.cfg - if (field(QLatin1String("installation.new")).toBool() == true) { + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { QString path(field(QLatin1String("installation.path")).toString()); mWizard->addInstallation(path); } if (!mWizard->mError) { - if ((field(QLatin1String("installation.new")).toBool() == true) + if ((field(QLatin1String("installation.retailDisc")).toBool() == true) || (field(QLatin1String("installation.import-settings")).toBool() == true)) { qDebug() << "IMPORT SETTINGS"; @@ -33,7 +33,7 @@ void Wizard::ConclusionPage::initializePage() if (!mWizard->mError) { - if (field(QLatin1String("installation.new")).toBool() == true) + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { textLabel->setText(tr("

The OpenMW Wizard successfully installed Morrowind on your computer.

\

Click Finish to close the Wizard.

")); diff --git a/apps/wizard/installationpage.cpp b/apps/wizard/installationpage.cpp index 2f0af88c9..7a4dcbf10 100644 --- a/apps/wizard/installationpage.cpp +++ b/apps/wizard/installationpage.cpp @@ -7,7 +7,6 @@ #include #include "mainwizard.hpp" -#include "inisettings.hpp" Wizard::InstallationPage::InstallationPage(QWidget *parent) : QWizardPage(parent) @@ -76,7 +75,7 @@ void Wizard::InstallationPage::initializePage() // That way installing all three components would yield 300% // When one component is done the bar will be filled by 33% - if (field(QLatin1String("installation.new")).toBool() == true) { + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { installProgressBar->setMaximum((components.count() * 100)); } else { if (components.contains(QLatin1String("Tribunal")) @@ -96,7 +95,7 @@ void Wizard::InstallationPage::startInstallation() QStringList components(field(QLatin1String("installation.components")).toStringList()); QString path(field(QLatin1String("installation.path")).toString()); - if (field(QLatin1String("installation.new")).toBool() == true) + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { // Always install Morrowind mUnshield->setInstallComponent(Wizard::Component_Morrowind, true); @@ -227,7 +226,7 @@ bool Wizard::InstallationPage::isComplete() const int Wizard::InstallationPage::nextId() const { - if (field(QLatin1String("installation.new")).toBool() == true) { + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { return MainWizard::Page_Conclusion; } else { if (!mWizard->mError) { diff --git a/apps/wizard/languageselectionpage.cpp b/apps/wizard/languageselectionpage.cpp index 0d5132f5b..4c10bf38c 100644 --- a/apps/wizard/languageselectionpage.cpp +++ b/apps/wizard/languageselectionpage.cpp @@ -30,7 +30,7 @@ void Wizard::LanguageSelectionPage::initializePage() int Wizard::LanguageSelectionPage::nextId() const { - if (field(QLatin1String("installation.new")).toBool() == true) { + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { return MainWizard::Page_ComponentSelection; } else { QString path(field(QLatin1String("installation.path")).toString()); diff --git a/apps/wizard/mainwizard.cpp b/apps/wizard/mainwizard.cpp index 7ef8761dd..b99f151aa 100644 --- a/apps/wizard/mainwizard.cpp +++ b/apps/wizard/mainwizard.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -258,7 +257,7 @@ void Wizard::MainWizard::runSettingsImporter() QStringList arguments; // Import plugin selection? - if (field(QLatin1String("installation.new")).toBool() == true + if (field(QLatin1String("installation.retailDisc")).toBool() == true || field(QLatin1String("installation.import-addons")).toBool() == true) arguments.append(QLatin1String("--game-files")); @@ -278,7 +277,7 @@ void Wizard::MainWizard::runSettingsImporter() // Now the paths arguments.append(QLatin1String("--ini")); - if (field(QLatin1String("installation.new")).toBool() == true) { + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { arguments.append(path + QDir::separator() + QLatin1String("Morrowind.ini")); } else { arguments.append(mInstallations[path].iniPath); diff --git a/apps/wizard/methodselectionpage.cpp b/apps/wizard/methodselectionpage.cpp index 5f3917bd5..e00344af9 100644 --- a/apps/wizard/methodselectionpage.cpp +++ b/apps/wizard/methodselectionpage.cpp @@ -1,5 +1,4 @@ #include "methodselectionpage.hpp" -#include #include "mainwizard.hpp" Wizard::MethodSelectionPage::MethodSelectionPage(QWidget *parent) : @@ -10,16 +9,16 @@ Wizard::MethodSelectionPage::MethodSelectionPage(QWidget *parent) : setupUi(this); #ifndef OPENMW_USE_UNSHIELD - newLocationRadioButton->setEnabled(false); + retailDiscRadioButton->setEnabled(false); existingLocationRadioButton->setChecked(true); #endif - registerField(QLatin1String("installation.new"), newLocationRadioButton); + registerField(QLatin1String("installation.retailDisc"), retailDiscRadioButton); } int Wizard::MethodSelectionPage::nextId() const { - if (field(QLatin1String("installation.new")).toBool() == true) { + if (field(QLatin1String("installation.retailDisc")).toBool() == true) { return MainWizard::Page_InstallationTarget; } else { return MainWizard::Page_ExistingInstallation; diff --git a/apps/wizard/unshield/unshieldworker.cpp b/apps/wizard/unshield/unshieldworker.cpp index d3ccfe03a..020de9f80 100644 --- a/apps/wizard/unshield/unshieldworker.cpp +++ b/apps/wizard/unshield/unshieldworker.cpp @@ -46,6 +46,7 @@ Wizard::UnshieldWorker::~UnshieldWorker() void Wizard::UnshieldWorker::stopWorker() { mStopped = true; + mWait.wakeOne(); } void Wizard::UnshieldWorker::setInstallComponent(Wizard::Component component, bool install) @@ -448,6 +449,10 @@ bool Wizard::UnshieldWorker::setupComponent(Component component) QReadLocker readLock(&mLock); emit requestFileDialog(component); mWait.wait(&mLock); + if(mStopped) { + qDebug() << "We are asked to stop !!"; + break; + } disk.setPath(getDiskPath()); } else { disk.setPath(getDiskPath()); diff --git a/components/bsa/bsa_file.cpp b/components/bsa/bsa_file.cpp index 2b9a3f632..c4be428b3 100644 --- a/components/bsa/bsa_file.cpp +++ b/components/bsa/bsa_file.cpp @@ -23,7 +23,7 @@ #include "bsa_file.hpp" -#include +#include #include #include diff --git a/components/compiler/lineparser.cpp b/components/compiler/lineparser.cpp index a5b67f58b..c7f82a3d0 100644 --- a/components/compiler/lineparser.cpp +++ b/components/compiler/lineparser.cpp @@ -294,7 +294,7 @@ namespace Compiler { // workaround for broken positioncell instructions. /// \todo add option to disable this - std::auto_ptr errorDowngrade (0); + std::unique_ptr errorDowngrade (nullptr); if (Misc::StringUtils::lowerCase (loc.mLiteral)=="positioncell") errorDowngrade.reset (new ErrorDowngrade (getErrorHandler())); diff --git a/components/compiler/scanner.cpp b/components/compiler/scanner.cpp index 720fde9f1..c2ec13b01 100644 --- a/components/compiler/scanner.cpp +++ b/components/compiler/scanner.cpp @@ -408,6 +408,11 @@ namespace Compiler special = S_cmpEQ; else if (c=='=') special = S_cmpEQ; + else if (c == '>' || c == '<') // Treat => and =< as == + { + special = S_cmpEQ; + mErrorHandler.warning (std::string("invalid operator =") + c + ", treating it as ==", mLoc); + } else { special = S_cmpEQ; diff --git a/components/contentselector/model/loadordererror.cpp b/components/contentselector/model/loadordererror.cpp index aa69f330e..7177e8ec1 100644 --- a/components/contentselector/model/loadordererror.cpp +++ b/components/contentselector/model/loadordererror.cpp @@ -1,5 +1,5 @@ #include "loadordererror.hpp" -#include +#include QString ContentSelectorModel::LoadOrderError::sErrorToolTips[ErrorCode_LoadOrder] = { diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index 514a0444a..f4da7e6ad 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -11,7 +11,6 @@ #include #include #include -#include ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) : QObject(parent) diff --git a/components/esm/aisequence.cpp b/components/esm/aisequence.cpp index 71f87b170..c39ef8269 100644 --- a/components/esm/aisequence.cpp +++ b/components/esm/aisequence.cpp @@ -170,49 +170,49 @@ namespace AiSequence { case Ai_Wander: { - std::auto_ptr ptr (new AiWander()); + std::unique_ptr ptr (new AiWander()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; } case Ai_Travel: { - std::auto_ptr ptr (new AiTravel()); + std::unique_ptr ptr (new AiTravel()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; } case Ai_Escort: { - std::auto_ptr ptr (new AiEscort()); + std::unique_ptr ptr (new AiEscort()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; } case Ai_Follow: { - std::auto_ptr ptr (new AiFollow()); + std::unique_ptr ptr (new AiFollow()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; } case Ai_Activate: { - std::auto_ptr ptr (new AiActivate()); + std::unique_ptr ptr (new AiActivate()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; } case Ai_Combat: { - std::auto_ptr ptr (new AiCombat()); + std::unique_ptr ptr (new AiCombat()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; } case Ai_Pursue: { - std::auto_ptr ptr (new AiPursue()); + std::unique_ptr ptr (new AiPursue()); ptr->load(esm); mPackages.back().mPackage = ptr.release(); break; diff --git a/components/esm/esmwriter.hpp b/components/esm/esmwriter.hpp index d11b3c940..5d7aebaf9 100644 --- a/components/esm/esmwriter.hpp +++ b/components/esm/esmwriter.hpp @@ -86,7 +86,7 @@ private: // Prevent using writeHNT with strings. This already happened by accident and results in // state being discarded without any error on writing or reading it. :( // writeHNString and friends must be used instead. - void writeHNT(const std::string &name, std::string data) + void writeHNT(const std::string& name, const std::string& data) { } void writeT(const std::string& data) diff --git a/components/esm/loadclot.hpp b/components/esm/loadclot.hpp index 39e5ea672..a9ea3e70a 100644 --- a/components/esm/loadclot.hpp +++ b/components/esm/loadclot.hpp @@ -39,7 +39,7 @@ struct Clothing { int mType; float mWeight; - short mValue; + unsigned short mValue; short mEnchant; }; CTDTstruct mData; diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index dc8266132..3a918cf19 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -1,10 +1,7 @@ #include "loadmgef.hpp" -#include #include -#include - #include "esmreader.hpp" #include "esmwriter.hpp" #include "defs.hpp" @@ -524,7 +521,7 @@ const std::string &MagicEffect::effectIdToString(short effectID) { std::map::const_iterator name = sNames.find(effectID); if(name == sNames.end()) - throw std::runtime_error(std::string("Unimplemented effect ID ")+boost::lexical_cast(effectID)); + throw std::runtime_error(std::string("Unimplemented effect ID ")+std::to_string(effectID)); return name->second; } diff --git a/components/esm/npcstats.cpp b/components/esm/npcstats.cpp index 4c1095b6e..a12879109 100644 --- a/components/esm/npcstats.cpp +++ b/components/esm/npcstats.cpp @@ -1,3 +1,5 @@ +#include + #include "npcstats.hpp" #include "esmreader.hpp" diff --git a/components/fallback/fallback.cpp b/components/fallback/fallback.cpp index 354595660..11a577a45 100644 --- a/components/fallback/fallback.cpp +++ b/components/fallback/fallback.cpp @@ -2,8 +2,13 @@ #include + namespace Fallback { + bool stob(std::string const& s) { + return s != "0"; + } + Map::Map(const std::map& fallback):mFallbackMap(fallback) {} @@ -16,6 +21,7 @@ namespace Fallback } return it->second; } + float Map::getFallbackFloat(const std::string& fall) const { std::string fallback=getFallbackString(fall); @@ -24,13 +30,14 @@ namespace Fallback else return boost::lexical_cast(fallback); } + int Map::getFallbackInt(const std::string& fall) const { std::string fallback=getFallbackString(fall); if(fallback.empty()) return 0; else - return boost::lexical_cast(fallback); + return std::stoi(fallback); } bool Map::getFallbackBool(const std::string& fall) const @@ -39,8 +46,9 @@ namespace Fallback if(fallback.empty()) return false; else - return boost::lexical_cast(fallback); + return stob(fallback); } + osg::Vec4f Map::getFallbackColour(const std::string& fall) const { std::string sum=getFallbackString(fall); @@ -55,7 +63,7 @@ namespace Fallback else if (sum[i] != ' ') ret[j]+=sum[i]; } - return osg::Vec4f(boost::lexical_cast(ret[0])/255.f,boost::lexical_cast(ret[1])/255.f,boost::lexical_cast(ret[2])/255.f, 1.f); + return osg::Vec4f(std::stoi(ret[0])/255.f,std::stoi(ret[1])/255.f,std::stoi(ret[2])/255.f, 1.f); } } diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index b53e3834a..5316255ad 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -1,18 +1,12 @@ #include "configurationmanager.hpp" -#include #include -#include -#include #include -#include #include #include #include -#include - /** * \namespace Files */ @@ -130,7 +124,7 @@ void ConfigurationManager::processPaths(Files::PathContainer& dataDirs, bool cre } dataDirs.erase(std::remove_if(dataDirs.begin(), dataDirs.end(), - boost::bind(&boost::filesystem::path::empty, _1)), dataDirs.end()); + std::bind(&boost::filesystem::path::empty, std::placeholders::_1)), dataDirs.end()); } bool ConfigurationManager::loadConfig(const boost::filesystem::path& path, diff --git a/components/files/constrainedfilestream.cpp b/components/files/constrainedfilestream.cpp index cd9a3c8f5..4f76139d9 100644 --- a/components/files/constrainedfilestream.cpp +++ b/components/files/constrainedfilestream.cpp @@ -1,6 +1,7 @@ #include "constrainedfilestream.hpp" #include +#include #include "lowlevelfile.hpp" diff --git a/components/files/constrainedfilestream.hpp b/components/files/constrainedfilestream.hpp index 069ceec58..05ae0fbec 100644 --- a/components/files/constrainedfilestream.hpp +++ b/components/files/constrainedfilestream.hpp @@ -2,8 +2,7 @@ #define OPENMW_CONSTRAINEDFILESTREAM_H #include - -#include +#include namespace Files { @@ -17,7 +16,7 @@ public: virtual ~ConstrainedFileStream(); }; -typedef boost::shared_ptr IStreamPtr; +typedef std::shared_ptr IStreamPtr; IStreamPtr openConstrainedFileStream(const char *filename, size_t start=0, size_t length=0xFFFFFFFF); diff --git a/components/files/escape.cpp b/components/files/escape.cpp index c5d2c041e..f28870c70 100644 --- a/components/files/escape.cpp +++ b/components/files/escape.cpp @@ -1,7 +1,6 @@ #include "escape.hpp" #include -#include namespace Files { diff --git a/components/files/linuxpath.cpp b/components/files/linuxpath.cpp index 89b4bf45a..1f6a3d913 100644 --- a/components/files/linuxpath.cpp +++ b/components/files/linuxpath.cpp @@ -2,8 +2,6 @@ #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) -#include -#include #include #include #include diff --git a/components/files/multidircollection.cpp b/components/files/multidircollection.cpp index b37a95b2f..93db6834d 100644 --- a/components/files/multidircollection.cpp +++ b/components/files/multidircollection.cpp @@ -1,15 +1,9 @@ #include "multidircollection.hpp" -#include - -#include -#include #include #include -#include - namespace Files { struct NameEqual diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index b14051a81..9acd81710 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -114,6 +114,30 @@ public: return ciLess(left, right); } }; + + + /// Performs a binary search on a sorted container for a string that 'key' starts with + template + static Iterator partialBinarySearch(Iterator begin, Iterator end, const T& key) + { + const Iterator notFound = end; + + while(begin < end) + { + const Iterator middle = begin + (std::distance(begin, end) / 2); + + int comp = Misc::StringUtils::ciCompareLen((*middle), key, (*middle).size()); + + if(comp == 0) + return middle; + else if(comp > 0) + end = middle; + else + begin = middle + 1; + } + + return notFound; + } }; } diff --git a/components/misc/utf8stream.hpp b/components/misc/utf8stream.hpp index 4856d6503..760015902 100644 --- a/components/misc/utf8stream.hpp +++ b/components/misc/utf8stream.hpp @@ -1,7 +1,7 @@ #ifndef MISC_UTF8ITER_HPP #define MISC_UTF8ITER_HPP -#include +#include class Utf8Stream { @@ -60,7 +60,7 @@ public: int octets; UnicodeChar chr; - boost::tie (octets, chr) = octet_count (*cur++); + std::tie (octets, chr) = octet_count (*cur++); if (octets > 5) return std::make_pair (sBadChar(), cur); @@ -104,7 +104,7 @@ private: void next () { - boost::tie (val, nxt) = decode (nxt, end); + std::tie (val, nxt) = decode (nxt, end); } Point cur; diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index 69bc3878d..485a87ba7 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -18,7 +18,7 @@ void DataManager::setResourcePath(const std::string &path) MyGUI::IDataStream *DataManager::getData(const std::string &name) { std::string fullpath = getDataPath(name); - std::auto_ptr stream; + std::unique_ptr stream; stream.reset(new boost::filesystem::ifstream); stream->open(fullpath, std::ios::binary); if (stream->fail()) diff --git a/components/myguiplatform/myguiloglistener.cpp b/components/myguiplatform/myguiloglistener.cpp index b36e0d852..a22ac8fc5 100644 --- a/components/myguiplatform/myguiloglistener.cpp +++ b/components/myguiplatform/myguiloglistener.cpp @@ -1,9 +1,6 @@ #include "myguiloglistener.hpp" #include -#include - -#include namespace osgMyGUI { diff --git a/components/nif/niffile.hpp b/components/nif/niffile.hpp index 9a2acbb9f..9e39a37ab 100644 --- a/components/nif/niffile.hpp +++ b/components/nif/niffile.hpp @@ -92,7 +92,7 @@ public: /// Get the name of the file std::string getFilename() const { return filename; } }; -typedef boost::shared_ptr NIFFilePtr; +typedef std::shared_ptr NIFFilePtr; diff --git a/components/nif/nifkey.hpp b/components/nif/nifkey.hpp index 75353044d..9238a6548 100644 --- a/components/nif/nifkey.hpp +++ b/components/nif/nifkey.hpp @@ -8,8 +8,6 @@ #include #include -#include - #include "niffile.hpp" namespace Nif @@ -156,10 +154,10 @@ typedef KeyMapT Vector3KeyMap; typedef KeyMapT Vector4KeyMap; typedef KeyMapT QuaternionKeyMap; -typedef boost::shared_ptr FloatKeyMapPtr; -typedef boost::shared_ptr Vector3KeyMapPtr; -typedef boost::shared_ptr Vector4KeyMapPtr; -typedef boost::shared_ptr QuaternionKeyMapPtr; +typedef std::shared_ptr FloatKeyMapPtr; +typedef std::shared_ptr Vector3KeyMapPtr; +typedef std::shared_ptr Vector4KeyMapPtr; +typedef std::shared_ptr QuaternionKeyMapPtr; } // Namespace #endif //#ifndef OPENMW_COMPONENTS_NIF_NIFKEY_HPP diff --git a/components/nif/nifstream.hpp b/components/nif/nifstream.hpp index f4163ce47..860c62e64 100644 --- a/components/nif/nifstream.hpp +++ b/components/nif/nifstream.hpp @@ -3,6 +3,7 @@ #ifndef OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP #define OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP +#include #include #include #include diff --git a/components/nifbullet/bulletnifloader.cpp b/components/nifbullet/bulletnifloader.cpp index 1cfac15eb..3865b17a5 100644 --- a/components/nifbullet/bulletnifloader.cpp +++ b/components/nifbullet/bulletnifloader.cpp @@ -75,7 +75,7 @@ osg::ref_ptr BulletNifLoader::load(const Nif::NIFFilePtr if (findBoundingBox(node)) { - std::auto_ptr compound (new btCompoundShape); + std::unique_ptr compound (new btCompoundShape); btBoxShape* boxShape = new btBoxShape(getbtVector(mShape->mCollisionBoxHalfExtents)); btTransform transform = btTransform::getIdentity(); @@ -203,8 +203,7 @@ void BulletNifLoader::handleNode(const Nif::Node *node, int flags, // affecting the entire subtree of this node Nif::NiStringExtraData *sd = (Nif::NiStringExtraData*)e; - // not sure what the difference between NCO and NCC is, or if there even is one - if (sd->string == "NCO" || sd->string == "NCC") + if (Misc::StringUtils::ciCompareLen(sd->string, "NC", 2) == 0) { // No collision. Use an internal flag setting to mark this. flags |= 0x800; diff --git a/components/nifosg/controller.cpp b/components/nifosg/controller.cpp index 8d0c73bff..87a0b830e 100644 --- a/components/nifosg/controller.cpp +++ b/components/nifosg/controller.cpp @@ -218,7 +218,7 @@ UVController::UVController() { } -UVController::UVController(const Nif::NiUVData *data, std::set textureUnits) +UVController::UVController(const Nif::NiUVData *data, const std::set& textureUnits) : mUTrans(data->mKeyList[0], 0.f) , mVTrans(data->mKeyList[1], 0.f) , mUScale(data->mKeyList[2], 1.f) @@ -381,14 +381,14 @@ void MaterialColorController::apply(osg::StateSet *stateset, osg::NodeVisitor *n } } -FlipController::FlipController(const Nif::NiFlipController *ctrl, std::vector > textures) +FlipController::FlipController(const Nif::NiFlipController *ctrl, const std::vector >& textures) : mTexSlot(ctrl->mTexSlot) , mDelta(ctrl->mDelta) , mTextures(textures) { } -FlipController::FlipController(int texSlot, float delta, std::vector > textures) +FlipController::FlipController(int texSlot, float delta, const std::vector >& textures) : mTexSlot(texSlot) , mDelta(delta) , mTextures(textures) diff --git a/components/nifosg/controller.hpp b/components/nifosg/controller.hpp index ce268f587..5fbb172f9 100644 --- a/components/nifosg/controller.hpp +++ b/components/nifosg/controller.hpp @@ -9,8 +9,6 @@ #include #include -#include - #include //UVController // FlipController @@ -53,7 +51,7 @@ namespace NifOsg { } - ValueInterpolator(boost::shared_ptr keys, ValueT defaultVal = ValueT()) + ValueInterpolator(std::shared_ptr keys, ValueT defaultVal = ValueT()) : mKeys(keys) , mDefaultVal(defaultVal) { @@ -101,8 +99,6 @@ namespace NifOsg // cache for next time mLastHighKey = it; - assert (it != keys.begin()); // Shouldn't happen, was checked at beginning of this function - typename MapT::MapType::const_iterator last = --it; mLastLowKey = last; float aLastTime = last->first; @@ -125,7 +121,7 @@ namespace NifOsg mutable typename MapT::MapType::const_iterator mLastLowKey; mutable typename MapT::MapType::const_iterator mLastHighKey; - boost::shared_ptr mKeys; + std::shared_ptr mKeys; ValueT mDefaultVal; }; @@ -223,7 +219,7 @@ namespace NifOsg public: UVController(); UVController(const UVController&,const osg::CopyOp&); - UVController(const Nif::NiUVData *data, std::set textureUnits); + UVController(const Nif::NiUVData *data, const std::set& textureUnits); META_Object(NifOsg,UVController) @@ -297,8 +293,8 @@ namespace NifOsg std::vector > mTextures; public: - FlipController(const Nif::NiFlipController* ctrl, std::vector > textures); - FlipController(int texSlot, float delta, std::vector > textures); + FlipController(const Nif::NiFlipController* ctrl, const std::vector >& textures); + FlipController(int texSlot, float delta, const std::vector >& textures); FlipController(); FlipController(const FlipController& copy, const osg::CopyOp& copyop); diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index ff986c1f8..e514cca12 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -334,7 +334,7 @@ namespace NifOsg continue; osg::ref_ptr callback(new NifOsg::KeyframeController(key->data.getPtr())); - callback->setFunction(boost::shared_ptr(new NifOsg::ControllerFunction(key))); + callback->setFunction(std::shared_ptr(new NifOsg::ControllerFunction(key))); if (target.mKeyframeControllers.find(strdata->string) != target.mKeyframeControllers.end()) std::cerr << "Warning: controller " << strdata->string << " present more than once in " << nif->getFilename() << ", ignoring later version" << std::endl; @@ -411,9 +411,9 @@ namespace NifOsg { bool autoPlay = animflags & Nif::NiNode::AnimFlag_AutoPlay; if (autoPlay) - toSetup->setSource(boost::shared_ptr(new SceneUtil::FrameTimeSource)); + toSetup->setSource(std::shared_ptr(new SceneUtil::FrameTimeSource)); - toSetup->setFunction(boost::shared_ptr(new ControllerFunction(ctrl))); + toSetup->setFunction(std::shared_ptr(new ControllerFunction(ctrl))); } osg::ref_ptr handleLodNode(const Nif::NiLODNode* niLodNode) @@ -623,11 +623,6 @@ namespace NifOsg node->setNodeMask(0x1); } - if (skipMeshes && isAnimated) // make sure the empty node is not optimized away so the physicssystem can find it. - { - node->setDataVariance(osg::Object::DYNAMIC); - } - // We can skip creating meshes for hidden nodes if they don't have a VisController that // might make them visible later if (nifNode->flags & Nif::NiNode::Flag_Hidden) @@ -643,6 +638,11 @@ namespace NifOsg node->setNodeMask(0x1); } + if (skipMeshes && isAnimated) // make sure the empty node is not optimized away so the physicssystem can find it. + { + node->setDataVariance(osg::Object::DYNAMIC); + } + osg::ref_ptr composite = new SceneUtil::CompositeStateSetUpdater; applyNodeProperties(nifNode, node, composite, imageManager, boundTextures, animflags); @@ -1773,8 +1773,10 @@ namespace NifOsg } if (!hasMatCtrl && mat->getColorMode() == osg::Material::OFF + && mat->getEmission(osg::Material::FRONT_AND_BACK) == osg::Vec4f(0,0,0,1) && mat->getDiffuse(osg::Material::FRONT_AND_BACK) == osg::Vec4f(1,1,1,1) && mat->getAmbient(osg::Material::FRONT_AND_BACK) == osg::Vec4f(1,1,1,1) + && mat->getShininess(osg::Material::FRONT_AND_BACK) == 0 && mat->getSpecular(osg::Material::FRONT_AND_BACK) == osg::Vec4f(0.f, 0.f, 0.f, 0.f)) { // default state, skip diff --git a/components/resource/bulletshapemanager.cpp b/components/resource/bulletshapemanager.cpp index ef35b31ef..c1a7eb8f3 100644 --- a/components/resource/bulletshapemanager.cpp +++ b/components/resource/bulletshapemanager.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -42,7 +43,11 @@ struct GetTriangleFunctor return btVector3(vec.x(), vec.y(), vec.z()); } +#if OSG_MIN_VERSION_REQUIRED(3,5,6) + void inline operator()( const osg::Vec3 v1, const osg::Vec3 v2, const osg::Vec3 v3 ) +#else void inline operator()( const osg::Vec3 v1, const osg::Vec3 v2, const osg::Vec3 v3, bool _temp ) +#endif { if (mTriMesh) mTriMesh->addTriangle( toBullet(mMatrix.preMult(v1)), toBullet(mMatrix.preMult(v2)), toBullet(mMatrix.preMult(v3))); @@ -185,6 +190,13 @@ void BulletShapeManager::updateCache(double referenceTime) mInstanceCache->removeUnreferencedObjectsInCache(); } +void BulletShapeManager::clearCache() +{ + ResourceManager::clearCache(); + + mInstanceCache->clear(); +} + void BulletShapeManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const { stats->setAttribute(frameNumber, "Shape", mCache->getCacheSize()); diff --git a/components/resource/bulletshapemanager.hpp b/components/resource/bulletshapemanager.hpp index fec7251ac..8ae2b531f 100644 --- a/components/resource/bulletshapemanager.hpp +++ b/components/resource/bulletshapemanager.hpp @@ -42,6 +42,8 @@ namespace Resource /// @see ResourceManager::updateCache virtual void updateCache(double referenceTime); + virtual void clearCache(); + void reportStats(unsigned int frameNumber, osg::Stats *stats) const; private: diff --git a/components/resource/imagemanager.cpp b/components/resource/imagemanager.cpp index db47324fb..441fd8212 100644 --- a/components/resource/imagemanager.cpp +++ b/components/resource/imagemanager.cpp @@ -1,7 +1,7 @@ #include "imagemanager.hpp" +#include #include -#include #include diff --git a/components/resource/multiobjectcache.cpp b/components/resource/multiobjectcache.cpp index fcda455cc..266139f3c 100644 --- a/components/resource/multiobjectcache.cpp +++ b/components/resource/multiobjectcache.cpp @@ -43,6 +43,12 @@ namespace Resource objectsToRemove.clear(); } + void MultiObjectCache::clear() + { + OpenThreads::ScopedLock lock(_objectCacheMutex); + _objectCache.clear(); + } + void MultiObjectCache::addEntryToObjectCache(const std::string &filename, osg::Object *object) { OpenThreads::ScopedLock lock(_objectCacheMutex); diff --git a/components/resource/multiobjectcache.hpp b/components/resource/multiobjectcache.hpp index a314a9e4b..527247bf9 100644 --- a/components/resource/multiobjectcache.hpp +++ b/components/resource/multiobjectcache.hpp @@ -25,6 +25,9 @@ namespace Resource void removeUnreferencedObjectsInCache(); + /** Remove all objects from the cache. */ + void clear(); + void addEntryToObjectCache(const std::string& filename, osg::Object* object); /** Take an Object from cache. Return NULL if no object found. */ diff --git a/components/resource/resourcemanager.cpp b/components/resource/resourcemanager.cpp index d19d9cf80..4e48d9745 100644 --- a/components/resource/resourcemanager.cpp +++ b/components/resource/resourcemanager.cpp @@ -23,6 +23,11 @@ namespace Resource mCache->removeExpiredObjectsInCache(referenceTime - mExpiryDelay); } + void ResourceManager::clearCache() + { + mCache->clear(); + } + void ResourceManager::setExpiryDelay(double expiryDelay) { mExpiryDelay = expiryDelay; diff --git a/components/resource/resourcemanager.hpp b/components/resource/resourcemanager.hpp index 61599cd5e..58200993b 100644 --- a/components/resource/resourcemanager.hpp +++ b/components/resource/resourcemanager.hpp @@ -28,6 +28,9 @@ namespace Resource /// Clear cache entries that have not been referenced for longer than expiryDelay. virtual void updateCache(double referenceTime); + /// Clear all cache entries. + virtual void clearCache(); + /// How long to keep objects in cache after no longer being referenced. void setExpiryDelay (double expiryDelay); diff --git a/components/resource/resourcesystem.cpp b/components/resource/resourcesystem.cpp index 19b280ff1..d7a6771c4 100644 --- a/components/resource/resourcesystem.cpp +++ b/components/resource/resourcesystem.cpp @@ -1,5 +1,7 @@ #include "resourcesystem.hpp" +#include + #include "scenemanager.hpp" #include "imagemanager.hpp" #include "niffilemanager.hpp" @@ -28,8 +30,6 @@ namespace Resource // this has to be defined in the .cpp file as we can't delete incomplete types mResourceManagers.clear(); - - // no delete, all handled by auto_ptr } SceneManager* ResourceSystem::getSceneManager() @@ -68,6 +68,12 @@ namespace Resource (*it)->updateCache(referenceTime); } + void ResourceSystem::clearCache() + { + for (std::vector::iterator it = mResourceManagers.begin(); it != mResourceManagers.end(); ++it) + (*it)->clearCache(); + } + void ResourceSystem::addResourceManager(ResourceManager *resourceMgr) { mResourceManagers.push_back(resourceMgr); diff --git a/components/resource/resourcesystem.hpp b/components/resource/resourcesystem.hpp index 6e308fd9b..efce50b97 100644 --- a/components/resource/resourcesystem.hpp +++ b/components/resource/resourcesystem.hpp @@ -41,6 +41,10 @@ namespace Resource /// @note May be called from any thread if you do not add or remove resource managers at that point. void updateCache(double referenceTime); + /// Indicates to each resource manager to clear the entire cache. + /// @note May be called from any thread if you do not add or remove resource managers at that point. + void clearCache(); + /// Add this ResourceManager to be handled by the ResourceSystem. /// @note Does not transfer ownership. void addResourceManager(ResourceManager* resourceMgr); @@ -57,10 +61,10 @@ namespace Resource void reportStats(unsigned int frameNumber, osg::Stats* stats) const; private: - std::auto_ptr mSceneManager; - std::auto_ptr mImageManager; - std::auto_ptr mNifFileManager; - std::auto_ptr mKeyframeManager; + std::unique_ptr mSceneManager; + std::unique_ptr mImageManager; + std::unique_ptr mNifFileManager; + std::unique_ptr mKeyframeManager; // Store the base classes separately to get convenient access to the common interface // Here users can register their own resourcemanager as well diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 167ab6221..69a54bf17 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -122,6 +122,13 @@ namespace Resource { return _sharedStateSetList.size(); } + + void clearCache() + { + OpenThreads::ScopedLock lock(_listMutex); + _sharedTextureList.clear(); + _sharedStateSetList.clear(); + } }; /// Set texture filtering settings on textures contained in a FlipController. @@ -383,18 +390,25 @@ namespace Resource public: bool isReservedName(const std::string& name) const { - static std::set reservedNames; + if (name.empty()) + return false; + + static std::vector reservedNames; if (reservedNames.empty()) { const char* reserved[] = {"Head", "Neck", "Chest", "Groin", "Right Hand", "Left Hand", "Right Wrist", "Left Wrist", "Shield Bone", "Right Forearm", "Left Forearm", "Right Upper Arm", "Left Upper Arm", "Right Foot", "Left Foot", "Right Ankle", "Left Ankle", "Right Knee", "Left Knee", "Right Upper Leg", "Left Upper Leg", "Right Clavicle", "Left Clavicle", "Weapon Bone", "Tail", "Bip01 L Hand", "Bip01 R Hand", "Bip01 Head", "Bip01 Spine1", "Bip01 Spine2", "Bip01 L Clavicle", "Bip01 R Clavicle", "bip01", "Root Bone", "Bip01 Neck", "BoneOffset", "AttachLight", "ArrowBone", "Camera"}; - reservedNames = std::set(reserved, reserved + sizeof(reserved)/sizeof(reserved[0])); + reservedNames = std::vector(reserved, reserved + sizeof(reserved)/sizeof(reserved[0])); for (unsigned int i=0; i::iterator it = Misc::StringUtils::partialBinarySearch(reservedNames.begin(), reservedNames.end(), name); + return it != reservedNames.end(); } virtual bool isOperationPermissibleForObjectImplementation(const SceneUtil::Optimizer* optimizer, const osg::Drawable* node,unsigned int option) const @@ -445,7 +459,7 @@ namespace Resource { std::string str(env); - if(str.find("OFF")!=std::string::npos) options = 0; + if(str.find("OFF")!=std::string::npos || str.find("0")!= std::string::npos) options = 0; if(str.find("~FLATTEN_STATIC_TRANSFORMS")!=std::string::npos) options ^= Optimizer::FLATTEN_STATIC_TRANSFORMS; else if(str.find("FLATTEN_STATIC_TRANSFORMS")!=std::string::npos) options |= Optimizer::FLATTEN_STATIC_TRANSFORMS; @@ -703,6 +717,15 @@ namespace Resource mSharedStateMutex.unlock(); } + void SceneManager::clearCache() + { + ResourceManager::clearCache(); + + OpenThreads::ScopedLock lock(mSharedStateMutex); + mSharedStateManager->clearCache(); + mInstanceCache->clear(); + } + void SceneManager::reportStats(unsigned int frameNumber, osg::Stats *stats) const { { diff --git a/components/resource/scenemanager.hpp b/components/resource/scenemanager.hpp index 2da28eaf4..14032df77 100644 --- a/components/resource/scenemanager.hpp +++ b/components/resource/scenemanager.hpp @@ -143,11 +143,13 @@ namespace Resource /// @see ResourceManager::updateCache virtual void updateCache(double referenceTime); + virtual void clearCache(); + virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const; private: - std::auto_ptr mShaderManager; + std::unique_ptr mShaderManager; bool mForceShaders; bool mClampLighting; bool mForcePerPixelLighting; diff --git a/components/sceneutil/attach.cpp b/components/sceneutil/attach.cpp index e61b8a6e0..1385f771e 100644 --- a/components/sceneutil/attach.cpp +++ b/components/sceneutil/attach.cpp @@ -81,14 +81,23 @@ namespace SceneUtil std::string mFilter2; }; + void mergeUserData(osg::UserDataContainer* source, osg::Object* target) + { + if (!target->getUserDataContainer()) + target->setUserDataContainer(source); + else + { + for (unsigned int i=0; igetNumUserObjects(); ++i) + target->getUserDataContainer()->addUserObject(source->getUserObject(i)); + } + } + osg::ref_ptr attach(osg::ref_ptr toAttach, osg::Node *master, const std::string &filter, osg::Group* attachNode) { if (dynamic_cast(toAttach.get())) { osg::ref_ptr handle = new osg::Group; - osg::UserDataContainer* udc = toAttach->getUserDataContainer(); - CopyRigVisitor copyVisitor(handle, filter); toAttach->accept(copyVisitor); copyVisitor.doCopy(); @@ -98,13 +107,13 @@ namespace SceneUtil osg::ref_ptr newHandle = handle->getChild(0); handle->removeChild(newHandle); master->asGroup()->addChild(newHandle); - newHandle->setUserDataContainer(udc); + mergeUserData(toAttach->getUserDataContainer(), newHandle); return newHandle; } else { master->asGroup()->addChild(handle); - handle->setUserDataContainer(udc); + handle->setUserDataContainer(toAttach->getUserDataContainer()); return handle; } } diff --git a/components/sceneutil/controller.cpp b/components/sceneutil/controller.cpp index 6cd0cb036..8fef00333 100644 --- a/components/sceneutil/controller.cpp +++ b/components/sceneutil/controller.cpp @@ -1,5 +1,7 @@ #include "controller.hpp" +#include + #include "statesetupdater.hpp" #include @@ -28,22 +30,22 @@ namespace SceneUtil return mSource->getValue(nv); } - void Controller::setSource(boost::shared_ptr source) + void Controller::setSource(std::shared_ptr source) { mSource = source; } - void Controller::setFunction(boost::shared_ptr function) + void Controller::setFunction(std::shared_ptr function) { mFunction = function; } - boost::shared_ptr Controller::getSource() const + std::shared_ptr Controller::getSource() const { return mSource; } - boost::shared_ptr Controller::getFunction() const + std::shared_ptr Controller::getFunction() const { return mFunction; } @@ -107,7 +109,7 @@ namespace SceneUtil { } - AssignControllerSourcesVisitor::AssignControllerSourcesVisitor(boost::shared_ptr toAssign) + AssignControllerSourcesVisitor::AssignControllerSourcesVisitor(std::shared_ptr toAssign) : ControllerVisitor() , mToAssign(toAssign) { diff --git a/components/sceneutil/controller.hpp b/components/sceneutil/controller.hpp index fd8964ae1..775cb23b0 100644 --- a/components/sceneutil/controller.hpp +++ b/components/sceneutil/controller.hpp @@ -1,8 +1,7 @@ #ifndef OPENMW_COMPONENTS_SCENEUTIL_CONTROLLER_H #define OPENMW_COMPONENTS_SCENEUTIL_CONTROLLER_H -#include - +#include #include namespace SceneUtil @@ -43,17 +42,17 @@ namespace SceneUtil float getInputValue(osg::NodeVisitor* nv); - void setSource(boost::shared_ptr source); - void setFunction(boost::shared_ptr function); + void setSource(std::shared_ptr source); + void setFunction(std::shared_ptr function); - boost::shared_ptr getSource() const; - boost::shared_ptr getFunction() const; + std::shared_ptr getSource() const; + std::shared_ptr getFunction() const; private: - boost::shared_ptr mSource; + std::shared_ptr mSource; // The source value gets passed through this function before it's passed on to the DestValue. - boost::shared_ptr mFunction; + std::shared_ptr mFunction; }; /// Pure virtual base class - visit() all controllers that are attached as UpdateCallbacks in a scene graph. @@ -78,14 +77,14 @@ namespace SceneUtil { public: AssignControllerSourcesVisitor(); - AssignControllerSourcesVisitor(boost::shared_ptr toAssign); + AssignControllerSourcesVisitor(std::shared_ptr toAssign); /// Assign the wanted ControllerSource. May be overridden in derived classes. /// By default assigns the ControllerSource passed to the constructor of this class if no ControllerSource is assigned to that controller yet. virtual void visit(osg::Node& node, Controller& ctrl); private: - boost::shared_ptr mToAssign; + std::shared_ptr mToAssign; }; /// Finds the maximum of all controller functions in the given scene graph diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index 341bc8034..018abeefc 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -1,15 +1,9 @@ #include "lightmanager.hpp" -#include - -#include - #include #include -#include - namespace SceneUtil { @@ -215,12 +209,21 @@ namespace SceneUtil mLights.push_back(l); } + /* similar to the boost::hash_combine */ + template + inline void hash_combine(std::size_t& seed, const T& v) + { + std::hash hasher; + seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + osg::ref_ptr LightManager::getLightListStateSet(const LightList &lightList, unsigned int frameNum) { + // possible optimization: return a StateSet containing all requested lights plus some extra lights (if a suitable one exists) size_t hash = 0; for (unsigned int i=0; imLightSource->getId()); + hash_combine(hash, lightList[i]->mLightSource->getId()); LightStateSetMap& stateSetCache = mStateSetCache[frameNum%2]; diff --git a/components/sceneutil/skeleton.hpp b/components/sceneutil/skeleton.hpp index 24dcc6b3f..542471ff1 100644 --- a/components/sceneutil/skeleton.hpp +++ b/components/sceneutil/skeleton.hpp @@ -63,7 +63,7 @@ namespace SceneUtil private: // The root bone is not a "real" bone, it has no corresponding node in the scene graph. // As far as the scene graph goes we support multiple root bones. - std::auto_ptr mRootBone; + std::unique_ptr mRootBone; typedef std::map > BoneCache; BoneCache mBoneCache; diff --git a/components/sdlutil/sdlinputwrapper.cpp b/components/sdlutil/sdlinputwrapper.cpp index c88210b0a..a76de00d1 100644 --- a/components/sdlutil/sdlinputwrapper.cpp +++ b/components/sdlutil/sdlinputwrapper.cpp @@ -1,7 +1,6 @@ #include "sdlinputwrapper.hpp" #include -#include #include @@ -221,10 +220,12 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr v case SDL_WINDOWEVENT_CLOSE: break; case SDL_WINDOWEVENT_SHOWN: + case SDL_WINDOWEVENT_RESTORED: if (mWindowListener) mWindowListener->windowVisibilityChange(true); break; case SDL_WINDOWEVENT_HIDDEN: + case SDL_WINDOWEVENT_MINIMIZED: if (mWindowListener) mWindowListener->windowVisibilityChange(false); break; @@ -421,7 +422,6 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr v mKeyMap.insert( KeyMap::value_type(SDLK_o, OIS::KC_O) ); mKeyMap.insert( KeyMap::value_type(SDLK_p, OIS::KC_P) ); mKeyMap.insert( KeyMap::value_type(SDLK_RETURN, OIS::KC_RETURN) ); - mKeyMap.insert( KeyMap::value_type(SDLK_LCTRL, OIS::KC_LCONTROL)); mKeyMap.insert( KeyMap::value_type(SDLK_a, OIS::KC_A) ); mKeyMap.insert( KeyMap::value_type(SDLK_s, OIS::KC_S) ); mKeyMap.insert( KeyMap::value_type(SDLK_d, OIS::KC_D) ); @@ -497,9 +497,20 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr v mKeyMap.insert( KeyMap::value_type(SDLK_INSERT, OIS::KC_INSERT) ); mKeyMap.insert( KeyMap::value_type(SDLK_DELETE, OIS::KC_DELETE) ); mKeyMap.insert( KeyMap::value_type(SDLK_KP_ENTER, OIS::KC_NUMPADENTER) ); - mKeyMap.insert( KeyMap::value_type(SDLK_RCTRL, OIS::KC_RCONTROL) ); + mKeyMap.insert( KeyMap::value_type(SDLK_APPLICATION, OIS::KC_APPS) ); + +//The function of the Ctrl and Meta keys are switched on macOS compared to other platforms. +//For instance, Cmd+C versus Ctrl+C to copy from the system clipboard +#if defined(__APPLE__) + mKeyMap.insert( KeyMap::value_type(SDLK_LGUI, OIS::KC_LCONTROL) ); + mKeyMap.insert( KeyMap::value_type(SDLK_RGUI, OIS::KC_RCONTROL) ); + mKeyMap.insert( KeyMap::value_type(SDLK_LCTRL, OIS::KC_LWIN)); + mKeyMap.insert( KeyMap::value_type(SDLK_RCTRL, OIS::KC_RWIN) ); +#else mKeyMap.insert( KeyMap::value_type(SDLK_LGUI, OIS::KC_LWIN) ); mKeyMap.insert( KeyMap::value_type(SDLK_RGUI, OIS::KC_RWIN) ); - mKeyMap.insert( KeyMap::value_type(SDLK_APPLICATION, OIS::KC_APPS) ); + mKeyMap.insert( KeyMap::value_type(SDLK_LCTRL, OIS::KC_LCONTROL)); + mKeyMap.insert( KeyMap::value_type(SDLK_RCTRL, OIS::KC_RCONTROL) ); +#endif } } diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 0c0600cc0..e93642ee2 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -1,13 +1,11 @@ #include "settings.hpp" -#include #include #include #include #include -#include #include namespace diff --git a/components/shader/shadermanager.cpp b/components/shader/shadermanager.cpp index ce77f46dc..2bfb17b5c 100644 --- a/components/shader/shadermanager.cpp +++ b/components/shader/shadermanager.cpp @@ -3,16 +3,14 @@ #include #include #include +#include #include -#include #include #include #include -#include - namespace Shader { @@ -139,7 +137,7 @@ namespace Shader shader->setShaderSource(shaderSource); // Assign a unique name to allow the SharedStateManager to compare shaders efficiently static unsigned int counter = 0; - shader->setName(boost::lexical_cast(counter++)); + shader->setName(std::to_string(counter++)); shaderIt = mShaders.insert(std::make_pair(std::make_pair(shaderTemplate, defines), shader)).first; } diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index b68d419a3..d85b72203 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -5,11 +5,9 @@ #include #include #include -#include #include -#include #include #include @@ -263,7 +261,7 @@ namespace Shader for (std::map::const_iterator texIt = reqs.mTextures.begin(); texIt != reqs.mTextures.end(); ++texIt) { defineMap[texIt->second] = "1"; - defineMap[texIt->second + std::string("UV")] = boost::lexical_cast(texIt->first); + defineMap[texIt->second + std::string("UV")] = std::to_string(texIt->first); } if (!reqs.mColorMaterial) diff --git a/components/terrain/buffercache.cpp b/components/terrain/buffercache.cpp index 470655539..361dd6c04 100644 --- a/components/terrain/buffercache.cpp +++ b/components/terrain/buffercache.cpp @@ -231,4 +231,16 @@ namespace Terrain return buffer; } + void BufferCache::clearCache() + { + { + OpenThreads::ScopedLock lock(mIndexBufferMutex); + mIndexBufferMap.clear(); + } + { + OpenThreads::ScopedLock lock(mUvBufferMutex); + mUvBufferMap.clear(); + } + } + } diff --git a/components/terrain/buffercache.hpp b/components/terrain/buffercache.hpp index e8963354b..bfdf558bc 100644 --- a/components/terrain/buffercache.hpp +++ b/components/terrain/buffercache.hpp @@ -22,6 +22,8 @@ namespace Terrain /// @note Thread safe. osg::ref_ptr getUVBuffer(unsigned int numVerts); + void clearCache(); + // TODO: add releaseGLObjects() for our vertex/element buffer objects private: diff --git a/components/terrain/chunkmanager.cpp b/components/terrain/chunkmanager.cpp index e4a7c2d68..ea71c726f 100644 --- a/components/terrain/chunkmanager.cpp +++ b/components/terrain/chunkmanager.cpp @@ -55,6 +55,13 @@ void ChunkManager::reportStats(unsigned int frameNumber, osg::Stats *stats) cons stats->setAttribute(frameNumber, "Terrain Chunk", mCache->getCacheSize()); } +void ChunkManager::clearCache() +{ + ResourceManager::clearCache(); + + mBufferCache.clearCache(); +} + void ChunkManager::setCullingActive(bool active) { mCullingActive = active; diff --git a/components/terrain/chunkmanager.hpp b/components/terrain/chunkmanager.hpp index 553e06d97..2f92fa836 100644 --- a/components/terrain/chunkmanager.hpp +++ b/components/terrain/chunkmanager.hpp @@ -34,6 +34,8 @@ namespace Terrain virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) const; + virtual void clearCache(); + void setCullingActive(bool active); private: diff --git a/components/terrain/quadtreenode.cpp b/components/terrain/quadtreenode.cpp index 438303c27..0394adea7 100644 --- a/components/terrain/quadtreenode.cpp +++ b/components/terrain/quadtreenode.cpp @@ -99,8 +99,10 @@ void QuadTreeNode::traverse(osg::NodeVisitor &nv) if (!hasValidBounds()) return; - if ((mLodCallback && mLodCallback->isSufficientDetail(this, nv.getEyePoint())) || !getNumChildren()) - getView(nv)->add(this, true); + ViewData* vd = getView(nv); + + if ((mLodCallback && mLodCallback->isSufficientDetail(this, vd->getEyePoint())) || !getNumChildren()) + vd->add(this, true); else osg::Group::traverse(nv); } @@ -130,11 +132,20 @@ ViewData* QuadTreeNode::getView(osg::NodeVisitor &nv) if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR) { osgUtil::CullVisitor* cv = static_cast(&nv); - return mViewDataMap->getViewData(cv->getCurrentCamera(), true); + ViewData* vd = mViewDataMap->getViewData(cv->getCurrentCamera()); + vd->setEyePoint(nv.getEyePoint()); + return vd; } else // INTERSECTION_VISITOR { - return mViewDataMap->getViewData(&nv, (nv.referenceCount() > 0)); // if no referenceCount, the visitor was allocated on the stack + static osg::ref_ptr dummyObj = new osg::DummyObject; + ViewData* vd = mViewDataMap->getViewData(dummyObj.get()); + ViewData* defaultView = mViewDataMap->getDefaultView(); + if (defaultView->hasEyePoint()) + vd->setEyePoint(defaultView->getEyePoint()); + else + vd->setEyePoint(nv.getEyePoint()); + return vd; } } diff --git a/components/terrain/quadtreeworld.cpp b/components/terrain/quadtreeworld.cpp index f2a80d673..f31064805 100644 --- a/components/terrain/quadtreeworld.cpp +++ b/components/terrain/quadtreeworld.cpp @@ -456,5 +456,10 @@ void QuadTreeWorld::reportStats(unsigned int frameNumber, osg::Stats *stats) stats->setAttribute(frameNumber, "Composite", mCompositeMapRenderer->getCompileSetSize()); } +void QuadTreeWorld::setDefaultViewer(osg::Object *obj) +{ + mViewDataMap->setDefaultViewer(obj); +} + } diff --git a/components/terrain/quadtreeworld.hpp b/components/terrain/quadtreeworld.hpp index 8ec75917b..ef33f158e 100644 --- a/components/terrain/quadtreeworld.hpp +++ b/components/terrain/quadtreeworld.hpp @@ -33,6 +33,8 @@ namespace Terrain void reportStats(unsigned int frameNumber, osg::Stats* stats); + virtual void setDefaultViewer(osg::Object* obj); + private: void ensureQuadTreeBuilt(); diff --git a/components/terrain/viewdata.cpp b/components/terrain/viewdata.cpp index 7b3df56b9..5c70f65f2 100644 --- a/components/terrain/viewdata.cpp +++ b/components/terrain/viewdata.cpp @@ -7,6 +7,7 @@ ViewData::ViewData() : mNumEntries(0) , mFrameLastUsed(0) , mChanged(false) + , mHasEyePoint(false) { } @@ -43,6 +44,22 @@ bool ViewData::hasChanged() const return mChanged; } +bool ViewData::hasEyePoint() const +{ + return mHasEyePoint; +} + +void ViewData::setEyePoint(const osg::Vec3f &eye) +{ + mEyePoint = eye; + mHasEyePoint = true; +} + +const osg::Vec3f& ViewData::getEyePoint() const +{ + return mEyePoint; +} + void ViewData::reset(unsigned int frame) { // clear any unused entries @@ -95,14 +112,13 @@ bool ViewData::Entry::set(QuadTreeNode *node, bool visible) } } -ViewData *ViewDataMap::getViewData(osg::Object *viewer, bool ref) +ViewData *ViewDataMap::getViewData(osg::Object *viewer) { Map::const_iterator found = mViews.find(viewer); if (found == mViews.end()) { ViewData* vd = createOrReuseView(); - if (ref) - vd->setViewer(viewer); + vd->setViewer(viewer); mViews[viewer] = vd; return vd; } @@ -130,8 +146,7 @@ void ViewDataMap::clearUnusedViews(unsigned int frame) for (Map::iterator it = mViews.begin(); it != mViews.end(); ) { ViewData* vd = it->second; - if ((!vd->getViewer() // if no ref was held, always need to clear to avoid holding a dangling ref. - || vd->getFrameLastUsed() + 2 < frame)) + if (vd->getFrameLastUsed() + 2 < frame) { vd->setViewer(NULL); vd->clear(); @@ -150,5 +165,15 @@ void ViewDataMap::clear() mViewVector.clear(); } +void ViewDataMap::setDefaultViewer(osg::Object *viewer) +{ + mDefaultViewer = viewer; +} + +ViewData* ViewDataMap::getDefaultView() +{ + return getViewData(mDefaultViewer); +} + } diff --git a/components/terrain/viewdata.hpp b/components/terrain/viewdata.hpp index 30563d566..aaf5b788f 100644 --- a/components/terrain/viewdata.hpp +++ b/components/terrain/viewdata.hpp @@ -52,18 +52,25 @@ namespace Terrain /// @return Have any nodes changed since the last frame bool hasChanged() const; + bool hasEyePoint() const; + + void setEyePoint(const osg::Vec3f& eye); + const osg::Vec3f& getEyePoint() const; + private: std::vector mEntries; unsigned int mNumEntries; unsigned int mFrameLastUsed; bool mChanged; osg::ref_ptr mViewer; + osg::Vec3f mEyePoint; + bool mHasEyePoint; }; class ViewDataMap : public osg::Referenced { public: - ViewData* getViewData(osg::Object* viewer, bool ref); + ViewData* getViewData(osg::Object* viewer); ViewData* createOrReuseView(); @@ -71,6 +78,10 @@ namespace Terrain void clear(); + void setDefaultViewer(osg::Object* viewer); + + ViewData* getDefaultView(); + private: std::list mViewVector; @@ -78,6 +89,8 @@ namespace Terrain Map mViews; std::deque mUnusedViews; + + osg::ref_ptr mDefaultViewer; }; } diff --git a/components/terrain/world.hpp b/components/terrain/world.hpp index 6aac963ce..d0576fbd3 100644 --- a/components/terrain/world.hpp +++ b/components/terrain/world.hpp @@ -14,6 +14,7 @@ namespace osg class Group; class Stats; class Node; + class Object; } namespace Resource @@ -87,6 +88,9 @@ namespace Terrain virtual void reportStats(unsigned int frameNumber, osg::Stats* stats) {} + /// Set the default viewer (usually a Camera), used as viewpoint for any viewers that don't use their own viewpoint. + virtual void setDefaultViewer(osg::Object* obj) {} + Storage* getStorage() { return mStorage; } protected: @@ -100,8 +104,8 @@ namespace Terrain Resource::ResourceSystem* mResourceSystem; - std::auto_ptr mTextureManager; - std::auto_ptr mChunkManager; + std::unique_ptr mTextureManager; + std::unique_ptr mChunkManager; }; } diff --git a/components/translation/translation.cpp b/components/translation/translation.cpp index 51947f6f9..14a32f178 100644 --- a/components/translation/translation.cpp +++ b/components/translation/translation.cpp @@ -2,8 +2,6 @@ #include -#include - namespace Translation { Storage::Storage() diff --git a/components/vfs/manager.cpp b/components/vfs/manager.cpp index 457947d40..4f3994bac 100644 --- a/components/vfs/manager.cpp +++ b/components/vfs/manager.cpp @@ -39,6 +39,12 @@ namespace VFS Manager::~Manager() { + reset(); + } + + void Manager::reset() + { + mIndex.clear(); for (std::vector::iterator it = mArchives.begin(); it != mArchives.end(); ++it) delete *it; mArchives.clear(); diff --git a/components/vfs/manager.hpp b/components/vfs/manager.hpp index 6592a65a8..c5f0a8fec 100644 --- a/components/vfs/manager.hpp +++ b/components/vfs/manager.hpp @@ -26,6 +26,9 @@ namespace VFS ~Manager(); + // Empty the file index and unregister archives. + void reset(); + /// Register the given archive. All files contained in it will be added to the index on the next buildIndex() call. /// @note Takes ownership of the given pointer. void addArchive(Archive* archive); diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index 0ac2ff7fd..0ce8ce951 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -422,4 +422,10 @@ namespace Gui align(); } + Spacer::Spacer() + { + setUserString("HStretch", "true"); + setUserString("VStretch", "true"); + } + } diff --git a/components/widgets/box.hpp b/components/widgets/box.hpp index ccdc5784b..70f73ce42 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -81,6 +81,15 @@ namespace Gui bool mAutoResize; // auto resize the box so that it exactly fits all elements }; + class Spacer : public AutoSizedWidget, public MyGUI::Widget + { + MYGUI_RTTI_DERIVED( Spacer ) + public: + Spacer(); + + virtual MyGUI::IntSize getRequestedSize() { return MyGUI::IntSize(0,0); } + }; + class HBox : public Box, public MyGUI::Widget { MYGUI_RTTI_DERIVED( HBox ) diff --git a/components/widgets/numericeditbox.cpp b/components/widgets/numericeditbox.cpp index 5361b3127..828a84589 100644 --- a/components/widgets/numericeditbox.cpp +++ b/components/widgets/numericeditbox.cpp @@ -1,6 +1,6 @@ -#include "numericeditbox.hpp" +#include -#include +#include "numericeditbox.hpp" namespace Gui { @@ -30,7 +30,7 @@ namespace Gui try { - mValue = boost::lexical_cast(newCaption); + mValue = std::stoi(newCaption); int capped = std::min(mMaxValue, std::max(mValue, mMinValue)); if (capped != mValue) { @@ -38,7 +38,11 @@ namespace Gui setCaption(MyGUI::utility::toString(mValue)); } } - catch (boost::bad_lexical_cast&) + catch (std::invalid_argument) + { + setCaption(MyGUI::utility::toString(mValue)); + } + catch (std::out_of_range) { setCaption(MyGUI::utility::toString(mValue)); } diff --git a/components/widgets/widgets.cpp b/components/widgets/widgets.cpp index 3b6361cf8..92f2084df 100644 --- a/components/widgets/widgets.cpp +++ b/components/widgets/widgets.cpp @@ -16,6 +16,7 @@ namespace Gui { MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); + MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); diff --git a/docs/requirements.txt b/docs/requirements.txt index 6ee8d6987..72c2aaa12 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,2 @@ -breathe parse_cmake sphinx diff --git a/docs/source/conf.py b/docs/source/conf.py index 273b2f7d5..b18b40c50 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,7 +11,6 @@ # # All configuration values have a default; values that are commented out # serve to show the default. -import glob import os import sys @@ -21,12 +20,6 @@ import sys project_root = os.path.abspath('../../') sys.path.insert(0, project_root) - -def insensitive_glob(pattern): - def either(c): - return '[%s%s]' % (c.lower(), c.upper()) if c.isalpha() else c - return glob.glob(''.join(map(either, pattern))) - # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. @@ -43,37 +36,6 @@ extensions = [ 'sphinx.ext.viewcode', ] -try: - import breathe - extensions.append('breathe') -except ImportError: - print("WARNING: Unable to import breathe, code documentation won't be generated.") - -# Where breathe can find the source files -openmw_path = os.path.join(project_root, "apps", "openmw") -openmw_sub_dirs = os.walk(openmw_path).next()[1] -openmw_headers = insensitive_glob(os.path.join(openmw_path, "*.hpp")) -for dir in openmw_sub_dirs: - openmw_headers += insensitive_glob(os.path.join(openmw_path, dir, "*.hpp")) -# massage the headers to get the relative path needed -openmw_headers = [os.path.relpath(x, openmw_path) for x in openmw_headers] - -opencs_path = os.path.join(project_root, "apps", "opencs") -opencs_sub_dirs = os.walk(opencs_path).next()[1] -opencs_headers = insensitive_glob(os.path.join(opencs_path, "*.hpp")) -opencs_sub_sub_dirs = [] -for dir in opencs_sub_dirs: - opencs_headers += insensitive_glob(os.path.join(opencs_path, dir, "*.hpp")) - opencs_sub_sub_dirs += os.walk(os.path.join(opencs_path, dir)).next()[1] - for sub_dir in opencs_sub_sub_dirs: - opencs_headers += insensitive_glob(os.path.join(opencs_path, dir, sub_dir, "*.hpp")) -opencs_headers = [os.path.relpath(x, opencs_path) for x in opencs_headers] - -breathe_projects_source = { - "openmw": (openmw_path, openmw_headers), - "opencs": (opencs_path, opencs_headers), -} - # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -88,7 +50,7 @@ master_doc = 'index' # General information about the project. project = u'OpenMW' -copyright = u'2016, OpenMW Team' +copyright = u'2017, OpenMW Team' # The version info for the project you're documenting, acts as replacement for diff --git a/docs/source/index.rst b/docs/source/index.rst index f51cda909..3781733cb 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -5,16 +5,7 @@ Sections -------- .. toctree:: - :maxdepth: 2 + :maxdepth: 3 manuals/index reference/index - source/index - - -Indices and Tables -================== - -* :ref:`genindex` -* :ref:`search` - diff --git a/docs/source/reference/modding/settings/GUI.rst b/docs/source/reference/modding/settings/GUI.rst index 0c39cf172..ad3514ffa 100644 --- a/docs/source/reference/modding/settings/GUI.rst +++ b/docs/source/reference/modding/settings/GUI.rst @@ -8,9 +8,13 @@ scaling factor :Range: > 0.0 :Default: 1.0 -This setting scales the GUI interface windows. The value must be greater than 0.0. A value of 1.0 results in the normal scale. Values much larger than 2.0 may result in user interface components being inaccessible. Until a gamepad interface is created, increasing this setting is helpful for simulating the larger interface used in console games. +This setting scales the GUI interface windows. +The value must be greater than 0.0. A value of 1.0 results in the normal scale. +Values much larger than 2.0 may result in user interface components being inaccessible. +Until a gamepad interface is created, +increasing this setting is helpful for simulating the larger interface used in console games. -The default value is 1.0. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. menu transparency ----------------- @@ -19,8 +23,9 @@ menu transparency :Range: 0.0 (transparent) to 1.0 (opaque) :Default: 0.84 -This setting controls the transparency of the GUI windows. The value should be between 0.0 (transparent) and 1.0 (opaque). -The default value is 0.84. This setting can be adjusted in game with the Menu Transparency slider in the Prefs panel of the Options menu. +This setting controls the transparency of the GUI windows. +The value should be between 0.0 (transparent) and 1.0 (opaque). +This setting can be adjusted in game with the Menu Transparency slider in the Prefs panel of the Options menu. tooltip delay ------------- @@ -29,11 +34,15 @@ tooltip delay :Range: > 0.0 :Default: 0.0 -This value determines the number of seconds between when you begin hovering over an item and when its tooltip appears. This setting only affects the tooltip delay for objects under the crosshair in GUI mode windows. There does not appear to be a setting to control the tool tip delay in outside of GUI mode. +This value determines the number of seconds between when you begin hovering over an item and when its tooltip appears. +This setting only affects the tooltip delay for objects under the crosshair in GUI mode windows. +There does not appear to be a setting to control the tool tip delay in outside of GUI mode. -The tooltip displays context sensitive information on the selected GUI element, such as weight, value, damage, armor rating, magical effects, and detailed description. +The tooltip displays context sensitive information on the selected GUI element, +such as weight, value, damage, armor rating, magical effects, and detailed description. -The default value is 0.0. This setting can be adjusted between 0.0 and 1.0 in game with the Menu Help Delay slider in the Prefs panel of the Options menu. +This setting can be adjusted between 0.0 and 1.0 in game +with the Menu Help Delay slider in the Prefs panel of the Options menu. stretch menu background ----------------------- @@ -42,9 +51,13 @@ stretch menu background :Range: True/False :Default: False -Stretch or shrink the main menu screen, loading splash screens, introductory movie, and cut scenes to fill the specified video resolution, distorting their aspect ratio. The Bethesda provided assets have a 4:3 aspect ratio, but other assets are permitted to have other aspect ratios. If this setting is false, the assets will be centered in their correct aspect ratio, with black bars filling the remainder of the screen. +Stretch or shrink the main menu screen, loading splash screens, introductory movie, +and cut scenes to fill the specified video resolution, distorting their aspect ratio. +The Bethesda provided assets have a 4:3 aspect ratio, but other assets are permitted to have other aspect ratios. +If this setting is false, the assets will be centered in their correct aspect ratio, +with black bars filling the remainder of the screen. -The default value is false. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. subtitles --------- @@ -53,9 +66,10 @@ subtitles :Range: True/False :Default: False -Enable or disable subtitles for NPC spoken dialog (and some sound effects). Subtitles will appear in a tool tip box in the lower center of the screen. +Enable or disable subtitles for NPC spoken dialog (and some sound effects). +Subtitles will appear in a tool tip box in the lower center of the screen. -The default value is false. This setting can be toggled in game with the Subtitles button in the Prefs panel of Options menu. +This setting can be toggled in game with the Subtitles button in the Prefs panel of Options menu. hit fader --------- @@ -88,9 +102,15 @@ color background owned :Range: 0.0 to 1.0 :Default: 0.15 0.0 0.0 1.0 -The following two settings determine the background color of the tool tip and the crosshair when hovering over an item owned by an NPC. The color definitions are composed of four floating point values between 0.0 and 1.0 inclusive, representing the red, green, blue and alpha channels. The alpha value is currently ignored. The crosshair color will have no effect if the crosshair setting in the HUD section is disabled. +The following two settings determine the background color of the tool tip and the crosshair +when hovering over an item owned by an NPC. +The color definitions are composed of four floating point values between 0.0 and 1.0 inclusive, +representing the red, green, blue and alpha channels. The alpha value is currently ignored. +The crosshair color will have no effect if the crosshair setting in the HUD section is disabled. -The default value is "0.15 0.0 0.0 1.0", which is a dark red color. This setting can only be configured by editing the settings configuration file. This setting has no effect if the show owned setting in the Game Settings Section is false. +The default value is "0.15 0.0 0.0 1.0", which is a dark red color. +This setting can only be configured by editing the settings configuration file. +This setting has no effect if the show owned setting in the Game Settings Section is false. color crosshair owned --------------------- @@ -99,6 +119,11 @@ color crosshair owned :Range: 0.0 to 1.0 :Default: 1.0 0.15 0.15 1.0 -This setting sets the color of the crosshair when hovering over an item owned by an NPC. The value is composed of four floating point values representing the red, green, blue and alpha channels. The alpha value is currently ignored. +This setting sets the color of the crosshair when hovering over an item owned by an NPC. +The value is composed of four floating point values representing the red, green, blue and alpha channels. +The alpha value is currently ignored. -The default value is "1.0 0.15 0.15 1.0" which is a bright red color. This setting can only be configured by editing the settings configuration file. This setting has no effect if the crosshair setting in the HUD Settings Section is false. This setting has no effect if the show owned setting in the Game Settings Section is false. +The default value is "1.0 0.15 0.15 1.0" which is a bright red color. +This setting can only be configured by editing the settings configuration file. +This setting has no effect if the crosshair setting in the HUD Settings Section is false. +This setting has no effect if the show owned setting in the Game Settings Section is false. diff --git a/docs/source/reference/modding/settings/HUD.rst b/docs/source/reference/modding/settings/HUD.rst index 8ee5267dd..920c4460e 100644 --- a/docs/source/reference/modding/settings/HUD.rst +++ b/docs/source/reference/modding/settings/HUD.rst @@ -8,6 +8,9 @@ crosshair :Range: True/False :Default: True -This setting determines whether the crosshair or reticle is displayed. Some players perceive that disabling the crosshair provides a more immersive experience. Another common use is to disable the crosshair for screen shots. Enabling the crosshair provides more immediate feedback about which object is currently the focus of actions. +This setting determines whether the crosshair or reticle is displayed. +Some players perceive that disabling the crosshair provides a more immersive experience. +Another common use is to disable the crosshair for screen shots. +Enabling the crosshair provides more immediate feedback about which object is currently the focus of actions. -The default value is true. This setting can be toggled with the Crosshair button in the Prefs panel of the Options menu. +This setting can be toggled with the Crosshair button in the Prefs panel of the Options menu. diff --git a/docs/source/reference/modding/settings/camera.rst b/docs/source/reference/modding/settings/camera.rst index 2edc98d02..222391fa8 100644 --- a/docs/source/reference/modding/settings/camera.rst +++ b/docs/source/reference/modding/settings/camera.rst @@ -8,9 +8,13 @@ near clip :Range: > 0 :Default: 1.0 -This setting controls the distance to the near clipping plane. The value must be greater than zero. Values greater than approximately 18.0 will occasionally clip objects in the world in front of the character. Values greater than approximately 8.0 will clip the character's hands in first person view and/or the back of their head in third person view. +This setting controls the distance to the near clipping plane. The value must be greater than zero. +Values greater than approximately 18.0 will occasionally clip objects in the world in front of the character. +Values greater than approximately 8.0 will clip the character's hands in first person view +and/or the back of their head in third person view. -The default value is 1.0. This setting can only be configured by editing the settings configuration file. The value must be greater than 0.0, but it's unclear if the engine enforces this limitation. +The default value is 1.0. This setting can only be configured by editing the settings configuration file. +The value must be greater than 0.0, but it's unclear if the engine enforces this limitation. small feature culling --------------------- @@ -19,7 +23,10 @@ small feature culling :Range: True/False :Default: True -This setting determines whether objects that render to a few pixels or smaller will be culled (not drawn). It generally improves performance to enable this feature, and by definition the culled objects will be very small on screen. The size in pixels for an object to be considered 'small' is controlled by a separate setting. +This setting determines whether objects that render to a few pixels or smaller will be culled (not drawn). +It generally improves performance to enable this feature, +and by definition the culled objects will be very small on screen. +The size in pixels for an object to be considered 'small' is controlled by a separate setting. The default value is true. This setting can only be configured by editing the settings configuration file. @@ -30,7 +37,8 @@ small feature culling pixel size :Range: > 0 :Default: 2.0 -Controls the cutoff in pixels for the 'small feature culling' setting which will have no effect if 'small feature culling' is disabled. +Controls the cutoff in pixels for the 'small feature culling' setting, +which will have no effect if 'small feature culling' is disabled. This setting can only be configured by editing the settings configuration file. @@ -41,15 +49,28 @@ viewing distance :Range: > 0 :Default: 6666.0 -This value controls the maximum visible distance (also called the far clipping plane). Larger values significantly improve rendering in exterior spaces, but also increase the amount of rendered geometry and significantly reduce the frame rate. This value interacts with the exterior cell load distance setting in that it's probably undesired for this value to provide visibility into cells that have not yet been loaded. When cells are visible before loading, the geometry will "pop-in" suddenly, creating a jarring visual effect. To prevent this effect, this value must be less than:: +This value controls the maximum visible distance (also called the far clipping plane). +Larger values significantly improve rendering in exterior spaces, +but also increase the amount of rendered geometry and significantly reduce the frame rate. +This value interacts with the exterior cell load distance setting +in that it's probably undesired for this value to provide visibility into cells that have not yet been loaded. +When cells are visible before loading, the geometry will "pop-in" suddenly, creating a jarring visual effect. +To prevent this effect, this value must be less than:: (8192 * exterior cell load distance - 1024) * 0.93 -The constant 8192 is the size of a cell, and 1024 is the threshold distance for loading a new cell. Additionally, the field of view setting also interacts with this setting because the view frustrum end is a plane, so you can see further at the edges of the screen than you should be able to. This can be observed in game by looking at distant objects and rotating the camera so the objects are near the edge of the screen. As a result, this setting should further be reduced by a factor that depends on the field of view setting. In the default configuration this reduction is 7%, hence the factor of 0.93 above. Using this factor, approximate values recommended for other exterior cell load distance settings are: +The constant 8192 is the size of a cell, and 1024 is the threshold distance for loading a new cell. +Additionally, the field of view setting also interacts with this setting because the view frustum end is a plane, +so you can see further at the edges of the screen than you should be able to. +This can be observed in game by looking at distant objects +and rotating the camera so the objects are near the edge of the screen. +As a result, this setting should further be reduced by a factor that depends on the field of view setting. +In the default configuration this reduction is 7%, hence the factor of 0.93 above. +Using this factor, approximate values recommended for other exterior cell load distance settings are: ======= ======== - Cells Viewing - Distance +Cells Viewing + Distance ======= ======== 2 14285 3 21903 @@ -57,11 +78,19 @@ The constant 8192 is the size of a cell, and 1024 is the threshold distance for 5 35924 ======= ======== -Reductions of up to 25% or more can be required to completely eliminate pop-in for wide fields of view and long viewing distances near the edges of the screen, but such situations are unusual and probably not worth the performance penalty introduced by loading geometry obscured by fog in the center of the screen. See RenderingManager::configureFog for the relevant source code. +Reductions of up to 25% or more can be required to completely eliminate pop-in for wide fields of view +and long viewing distances near the edges of the screen. +Such situations are unusual and probably not worth the performance penalty introduced +by loading geometry obscured by fog in the center of the screen. +See RenderingManager::configureFog for the relevant source code. -Enabling the distant terrain setting is an alternative to increasing exterior cell load distance. Note that the distant land setting does not include rendering of distant static objects, so the resulting visual effect is not the same. +Enabling the distant terrain setting is an alternative to increasing exterior cell load distance. +Note that the distant land setting does not include rendering of distant static objects, +so the resulting visual effect is not the same. -The default value is 6666.0. This setting can be adjusted in game from the ridiculously low value of 2000.0 to a maximum of 6666.0, using the View Distance slider in the Detail tab of the Video panel of the Options menu. +The default value is 6666.0. +This setting can be adjusted in game from the ridiculously low value of 2000.0 to a maximum of 6666.0 +using the View Distance slider in the Detail tab of the Video panel of the Options menu. field of view ------------- @@ -70,9 +99,14 @@ field of view :Range: 0-360 :Default: 55.0 -Sets the camera field of view in degrees. Recommended values range from 30 degrees to 110 degrees. Small values provide a very narrow field of view that creates a "zoomed in" effect, while large values cause distortion at the edges of the screen. The "field of view" setting interacts with aspect ratio of your video resolution in that more square aspect ratios (e.g. 4:3) need a wider field of view to more resemble the same field of view on a widescreen (e.g. 16:9) monitor. +Sets the camera field of view in degrees. Recommended values range from 30 degrees to 110 degrees. +Small values provide a very narrow field of view that creates a "zoomed in" effect, +while large values cause distortion at the edges of the screen. +The "field of view" setting interacts with aspect ratio of your video resolution in that more square aspect ratios +(e.g. 4:3) need a wider field of view to more resemble the same field of view on a widescreen (e.g. 16:9) monitor. -The default value is 55.0. This setting can be changed in game using the Field of View slider from the Video tab of the Video panel of the Options menu. +The default value is 55.0. This setting can be changed in game using the Field of View slider +from the Video tab of the Video panel of the Options menu. first person field of view -------------------------- @@ -81,6 +115,9 @@ first person field of view :Range: 0-360 :Default: 55.0 -This setting controls the field of view for first person meshes such as the player's hands and held objects. It is not recommended to change this value from its default value because the Bethesda provided Morrowind assets do not adapt well to large values, while small values can result in the hands not being visible. +This setting controls the field of view for first person meshes such as the player's hands and held objects. +It is not recommended to change this value from its default value +because the Bethesda provided Morrowind assets do not adapt well to large values, +while small values can result in the hands not being visible. The default value is 55.0. This setting can only be configured by editing the settings configuration file. diff --git a/docs/source/reference/modding/settings/cells.rst b/docs/source/reference/modding/settings/cells.rst index 66baedbee..d2e7cf5be 100644 --- a/docs/source/reference/modding/settings/cells.rst +++ b/docs/source/reference/modding/settings/cells.rst @@ -8,13 +8,17 @@ exterior cell load distance :Range: >= 1 :Default: 1 -This setting determines the number of exterior cells adjacent to the character that will be loaded for rendering. Values greater than one may significantly affect loading times when exiting interior spaces or loading additional exterior cells. Caution is advised when increasing this setting. +This setting determines the number of exterior cells adjacent to the character that will be loaded for rendering. +Values greater than 1 may significantly affect loading times when exiting interior spaces +or loading additional exterior cells. Caution is advised when increasing this setting. This setting interacts with viewing distance and field of view settings. -It is generally very wasteful for this value to load geometry than will almost never be visible due to viewing distance and fog. For low frame rate screen shots of scenic vistas, this setting should be set high, and viewing distances adjusted accordingly. +It is generally very wasteful for this value to load geometry than will almost never be visible +due to viewing distance and fog. For low frame rate screen shots of scenic vistas, +this setting should be set high, and viewing distances adjusted accordingly. -The default value is 1. This value must be greater than or equal to 1. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. preload enabled @@ -24,11 +28,17 @@ preload enabled :Range: True/False :Default: True -Controls whether textures and objects will be pre-loaded in background threads. This setting being enabled should result in a reduced amount of loading screens, no impact on frame rate and a varying amount of additional RAM usage, depending on how the preloader was configured (see the below settings). The default preloading settings with vanilla game files should only use negligible amounts of RAM, however, when using high-res texture and model replacers it may be necessary to tweak these settings to prevent the game from running out of memory. +Controls whether textures and objects will be pre-loaded in background threads. +This setting being enabled should result in a reduced amount of loading screens, no impact on frame rate, +and a varying amount of additional RAM usage, depending on how the preloader was configured (see the below settings). +The default preloading settings with vanilla game files should only use negligible amounts of RAM, however, +when using high-res texture and model replacers +it may be necessary to tweak these settings to prevent the game from running out of memory. The effects of (pre-)loading can be observed on the in-game statistics panel brought up with the 'F4' key. -All settings starting with 'preload' in this section will have no effect if preloading is disabled, and can only be configured by editing the settings configuration file. +All settings starting with 'preload' in this section will have no effect if preloading is disabled, +and can only be configured by editing the settings configuration file. preload num threads @@ -38,9 +48,18 @@ preload num threads :Range: >=1 :Default: 1 -Controls the number of worker threads used for preloading operations. In addition to the preloading threads, OpenMW uses a main thread, a sound streaming thread, and a graphics thread. Therefore, the default setting of one preloading thread will result in a total of 4 threads used which should work well with quad-core CPUs. If you have additional cores to spare, consider increasing the number of preloading threads to 2 or 3 for a boost in preloading performance. Faster preloading will reduce the chance that a cell could not be completely loaded before the player moves into it, and hence reduce the chance of seeing loading screens or frame drops. This may be especially relevant when the player moves at high speed and/or a large number of cells are loaded in via 'exterior cell load distance'. +Controls the number of worker threads used for preloading operations. +In addition to the preloading threads, OpenMW uses a main thread, a sound streaming thread, and a graphics thread. +Therefore, the default setting of one preloading thread will result in a total of 4 threads used, +which should work well with quad-core CPUs. If you have additional cores to spare, +consider increasing the number of preloading threads to 2 or 3 for a boost in preloading performance. +Faster preloading will reduce the chance that a cell could not be completely loaded before the player moves into it, +and hence reduce the chance of seeing loading screens or frame drops. +This may be especially relevant when the player moves at high speed +and/or a large number of cells are loaded in via 'exterior cell load distance'. -A value of 4 or higher is not recommended. With 4 or more threads, improvements will start to diminish due to file reading and synchronization bottlenecks. +A value of 4 or higher is not recommended. +With 4 or more threads, improvements will start to diminish due to file reading and synchronization bottlenecks. preload exterior grid --------------------- @@ -58,7 +77,10 @@ preload fast travel :Range: True/False :Default: False -Controls whether fast travel destinations are preloaded when the player moves close to a travel service. Because the game can not predict the destination that the player will choose, all possible destinations will be preloaded. This setting is disabled by default due to the adverse effect on memory usage caused by the preloading of all possible destinations. +Controls whether fast travel destinations are preloaded when the player moves close to a travel service. +Because the game can not predict the destination that the player will choose, +all possible destinations will be preloaded. This setting is disabled by default +due to the adverse effect on memory usage caused by the preloading of all possible destinations. preload doors ------------- @@ -76,9 +98,11 @@ preload distance :Range: >0 :Default: 1000 -Controls the distance in in-game units that is considered the player being 'close' to a preloading trigger. Used by all the preloading mechanisms i.e. 'preload exterior grid', 'preload fast travel' and 'preload doors'. +Controls the distance in in-game units that is considered the player being 'close' to a preloading trigger. +Used by all the preloading mechanisms i.e. 'preload exterior grid', 'preload fast travel' and 'preload doors'. -For measurement purposes, the distance to an object in-game can be observed by opening the console, clicking on the object and typing 'getdistance player'. +For measurement purposes, the distance to an object in-game can be observed by opening the console, +clicking on the object and typing 'getdistance player'. preload instances ----------------- @@ -87,9 +111,15 @@ preload instances :Range: True/False :Default: True -Controls whether or not objects are also pre-instanced on top of being pre-loaded. Instancing happens when the same object is placed more than once in the cell, and to be sure that any modifications to one instance do not affect the other, the game will create independent copies (instances) of the object. If this setting is enabled, the creation of instances will be done in the preloading thread; otherwise, instancing will only happen in the main thread once the cell is actually loaded. +Controls whether or not objects are also pre-instanced on top of being pre-loaded. +Instancing happens when the same object is placed more than once in the cell, +and to be sure that any modifications to one instance do not affect the other, +the game will create independent copies (instances) of the object. +If this setting is enabled, the creation of instances will be done in the preloading thread; +otherwise, instancing will only happen in the main thread once the cell is actually loaded. -Enabling this setting should reduce the chance of frame drops when transitioning into a preloaded cell, but will also result in some additional memory usage. +Enabling this setting should reduce the chance of frame drops when transitioning into a preloaded cell, +but will also result in some additional memory usage. preload cell cache min ---------------------- @@ -98,7 +128,12 @@ preload cell cache min :Range: >0 :Default: 12 -The minimum number of preloaded cells that will be kept in the cache. Once the number of preloaded cells in the cache exceeds this setting, the game may start to expire preloaded cells, based on the 'preload cell expiry delay' setting, starting with the oldest cell. When a preloaded cell expires, all the assets that were loaded for it will also expire and will have to be loaded again the next time the cell is requested for preloading. +The minimum number of preloaded cells that will be kept in the cache. +Once the number of preloaded cells in the cache exceeds this setting, +the game may start to expire preloaded cells based on the 'preload cell expiry delay' setting, +starting with the oldest cell. +When a preloaded cell expires, all the assets that were loaded for it will also expire +and will have to be loaded again the next time the cell is requested for preloading. preload cell cache max ---------------------- @@ -107,7 +142,8 @@ preload cell cache max :Range: >0 :Default: 20 -The maximum number of cells that will ever be in pre-loaded state simultaneously. This setting is intended to put a cap on the amount of memory that could potentially be used by preload state. +The maximum number of cells that will ever be in pre-loaded state simultaneously. +This setting is intended to put a cap on the amount of memory that could potentially be used by preload state. preload cell expiry delay ------------------------- @@ -116,7 +152,21 @@ preload cell expiry delay :Range: >=0 :Default: 5 -The amount of time (in seconds) that a preloaded cell will stay in cache after it is no longer referenced or required, for example, after the player has moved away from a door without entering it. +The amount of time (in seconds) that a preloaded cell will stay in cache after it is no longer referenced or required, +for example, after the player has moved away from a door without entering it. + +prediction time +--------------- + +:Type: floating point +:Range: >=0 +:Default: 1 + +The amount of time (in seconds) in the future to predict the player position for. This predicted position is used to preload any cells and/or distant terrain required at that position. + +This setting will only have an effect if 'preload enabled' is set or the 'distant terrain' in the Terrain section is set. + +Increasing this setting from its default may help if your computer/hard disk is too slow to preload in time and you see loading screens and/or lag spikes. cache expiry delay ------------------ @@ -125,4 +175,14 @@ cache expiry delay :Range: >=0 :Default: 5 -The amount of time (in seconds) that a preloaded texture or object will stay in cache after it is no longer referenced or required, for example, when all cells containing this texture have been unloaded. +The amount of time (in seconds) that a preloaded texture or object will stay in cache +after it is no longer referenced or required, for example, when all cells containing this texture have been unloaded. + +pointers cache size +------------------ + +:Type: integer +:Range: >0 +:Default: 40 + +The count of object pointers, that will be saved for a faster search by object ID. diff --git a/docs/source/reference/modding/settings/game.rst b/docs/source/reference/modding/settings/game.rst index 1eaa22db4..e1d5d75f6 100644 --- a/docs/source/reference/modding/settings/game.rst +++ b/docs/source/reference/modding/settings/game.rst @@ -8,10 +8,49 @@ show owned :Range: 0, 1, 2, 3 :Default: 0 -Enable visual clues for items owned by NPCs when the crosshair is on the object. If the setting is 0, no clues are provided which is the default Morrowind behavior. If the setting is 1, the background of the tool tip for the object is highlight in the color specified by the color background owned setting in the GUI Settings Section. If the setting is 2, the crosshair is the color of the color crosshair owned setting in the GUI Settings section. If the setting is 3, both the tool tip background and the crosshair are colored. The crosshair is not visible if crosshair is false. +Enable visual clues for items owned by NPCs when the crosshair is on the object. +If the setting is 0, no clues are provided which is the default Morrowind behavior. +If the setting is 1, the background of the tool tip for the object is highlighted +in the color specified by the color background owned setting in the GUI Settings Section. +If the setting is 2, the crosshair is the color of the color crosshair owned setting in the GUI Settings section. +If the setting is 3, both the tool tip background and the crosshair are colored. +The crosshair is not visible if crosshair is false. The default value is 0 (no clues). This setting can only be configured by editing the settings configuration file. +show projectile damage +---------------------- + +:Type: boolean +:Range: True/False +:Default: False + +If this setting is true, damage bonus of arrows and bolts will be showed on item tooltip. + +The default value is false. This setting can only be configured by editing the settings configuration file. + +show melee info +--------------- + +:Type: boolean +:Range: True/False +:Default: False + +If this setting is true, melee weapons reach and speed will be showed on item tooltip. + +The default value is false. This setting can only be configured by editing the settings configuration file. + +show enchant chance +------------------- + +:Type: boolean +:Range: True/False +:Default: False + +Whether or not the chance of success will be displayed in the enchanting menu. + +The default value is false. This setting can only be configured by editing the settings configuration file. + best attack ----------- @@ -19,9 +58,28 @@ best attack :Range: True/False :Default: False -If this setting is true, the player character will always use the most powerful attack when striking with a weapon (chop, slash or thrust). If this setting is false, the type of attack is determined by the direction that the character is moving at the time the attack begins. +If this setting is true, the player character will always use the most powerful attack when striking with a weapon +(chop, slash or thrust). If this setting is false, +the type of attack is determined by the direction that the character is moving at the time the attack begins. + +The default value is false. +This setting can be toggled with the Always Use Best Attack button in the Prefs panel of the Options menu. -The default value is false. This setting can be toggled with the Always Use Best Attack button in the Prefs panel of the Options menu. +can loot during death animation +------------------------------- + +:Type: boolean +:Range: True/False +:Default: True + +If this setting is true, the player is allowed to loot actors (e.g. summoned creatures) during death animation, if they are not in combat. +However disposing corpses during death animation is not recommended - death counter may not be incremented, and this behaviour can break quests. +This is how original Morrowind behaves. + +If this setting is false, player has to wait until end of death animation in all cases. +This case is more safe, but makes using of summoned creatures exploit (looting summoned Dremoras and Golden Saints for expensive weapons) a lot harder. + +The default value is true. This setting can only be configured by editing the settings configuration file. difficulty ---------- @@ -30,9 +88,14 @@ difficulty :Range: -500 to 500 :Default: 0 -This setting adjusts the difficulty of the game and is intended to be in the range -100 to 100 inclusive. Given the default game setting for fDifficultyMult of 5.0, a value of -100 results in the player taking 80% of the usual damage, doing 6 times the normal damage. A value of 100 results in the player taking 6 times as much damage, but inflicting only 80% of the usual damage. Values less than -500 will result in the player receiving no damage, and values greater than 500 will result in the player inflicting no damage. +This setting adjusts the difficulty of the game and is intended to be in the range -100 to 100 inclusive. +Given the default game setting for fDifficultyMult of 5.0, +a value of -100 results in the player taking 80% of the usual damage, doing 6 times the normal damage. +A value of 100 results in the player taking 6 times as much damage, but inflicting only 80% of the usual damage. +Values less than -500 will result in the player receiving no damage, +and values greater than 500 will result in the player inflicting no damage. -The default value is 0. This setting can be controlled in game with the Difficulty slider in the Prefs panel of the Options menu. +This setting can be controlled in game with the Difficulty slider in the Prefs panel of the Options menu. show effect duration -------------------- @@ -41,6 +104,26 @@ show effect duration :Range: True/False :Default: False -Show the remaining duration of magic effects and lights if this setting is true. The remaining duration is displayed in the tooltip by hovering over the magical effect. +Show the remaining duration of magic effects and lights if this setting is true. +The remaining duration is displayed in the tooltip by hovering over the magical effect. The default value is false. This setting can only be configured by editing the settings configuration file. + +prevent merchant equipping +-------------------------- + +:Type: boolean +:Range: True/False +:Default: False + +Prevents merchants from equipping items that are sold to them. + +followers attack on sight +------------------------- + +:Type: boolean +:Range: True/False +:Default: False + +Makes player followers and escorters start combat with enemies who have started combat with them or the player. +Otherwise they wait for the enemies or the player to do an attack first. diff --git a/docs/source/reference/modding/settings/general.rst b/docs/source/reference/modding/settings/general.rst index e71e82977..be253d613 100644 --- a/docs/source/reference/modding/settings/general.rst +++ b/docs/source/reference/modding/settings/general.rst @@ -8,9 +8,15 @@ anisotropy :Range: 0 to 16 :Default: 4 -Set the maximum anisotropic filtering on textures. Anisotropic filtering is a method of enhancing the image quality of textures on surfaces that are at oblique viewing angles with respect to the camera. Valid values range from 0 to 16. Modern video cards can often perform 8 or 16 anisotropic filtering with a minimal performance impact. This effect of this setting can be seen in the Video panel of the Options menu by finding a location with straight lines (striped rugs and Balmora cobblestones work well) radiating into the distance, and adjusting the anisotropy slider. +Set the maximum anisotropic filtering on textures. +Anisotropic filtering is a method of enhancing the image quality of textures +on surfaces that are at oblique viewing angles with respect to the camera. Valid values range from 0 to 16. +Modern video cards can often perform 8 or 16 anisotropic filtering with a minimal performance impact. +This effect of this setting can be seen in the Video panel of the Options menu by finding a location with straight lines +(striped rugs and Balmora cobblestones work well) radiating into the distance, and adjusting the anisotropy slider. -The default value is 4. This setting can be changed in game using the Anisotropy slider in the Detail tab of the Video panel of the Options menu. +This setting can be changed in game +using the Anisotropy slider in the Detail tab of the Video panel of the Options menu. screenshot format ----------------- @@ -19,17 +25,37 @@ screenshot format :Range: jpg, png, tga :Default: png -Specify the format for screen shots taken by pressing the screen shot key (bound to F12 by default). This setting should be the file extension commonly associated with the desired format. The formats supported will be determined at compilation, but "jpg", "png", and "tga" should be allowed. +Specify the format for screen shots taken by pressing the screen shot key (bound to F12 by default). +This setting should be the file extension commonly associated with the desired format. +The formats supported will be determined at compilation, but "jpg", "png", and "tga" should be allowed. -The default value is "png". This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. -texture filtering ------------------ +texture mag filter +------------------ + +:Type: string +:Range: nearest, linear +:Default: linear + +Set the texture magnification filter type. + +texture min filter +------------------ :Type: string -:Range: bilinear, trilinear -:Default: trilinear +:Range: nearest, linear +:Default: linear + +Set the texture minification filter type. -Set the isotropic texture filtering mode to bilinear or trilinear. Bilinear filtering is a texture filtering method used to smooth textures when displayed larger or smaller than they actually are. Bilinear filtering is reasonably accurate until the scaling of the texture gets below half or above double the original size of the texture. Trilinear filtering is an extension of the bilinear texture filtering method, which also performs linear interpolation between mipmaps. Both methods use mipmaps in OpenMW, and the corresponding OpenGL modes are LINEAR_MIPMAP_NEAREST and LINEAR_MIPMAP_LINEAR. Trilinear filtering produces better texturing at a minimal cost on modern video cards. +texture mipmap +-------------- + +:Type: string +:Range: none, nearest, linear +:Default: nearest -The default value is trilinear. This setting can be changed in game using the Texture filtering pull down in the Detail tab of the Video panel of the Options menu. \ No newline at end of file +Set the texture mipmap type to control the method mipmaps are created. +Mipmapping is a way of reducing the processing power needed during minification +by pregenerating a series of smaller textures. \ No newline at end of file diff --git a/docs/source/reference/modding/settings/index.rst b/docs/source/reference/modding/settings/index.rst index 0d0c9323d..56d76a8d1 100644 --- a/docs/source/reference/modding/settings/index.rst +++ b/docs/source/reference/modding/settings/index.rst @@ -2,28 +2,39 @@ Advanced Settings Configuration ############################### -This part of the guide will cover how to make modifications to the more arcane settings in OpenMW, most of which are not available from in-game menus, to optimize or customize your OpenMW experience. If you are familiar with ``.ini`` tweaks in Morrowind or the other games, this will be quite similar. All settings described in this section are changed in ``settings.cfg``, located in your OpenMW user directory. See :doc:`paths` for this location. +This part of the guide will cover how to make modifications to the more arcane settings in OpenMW, +most of which are not available from in-game menus, to optimize or customize your OpenMW experience. +If you are familiar with ``.ini`` tweaks in Morrowind or the other games, this will be quite similar. +All settings described in this section are changed in ``settings.cfg``, located in your OpenMW user directory. +See :doc:`../paths` for this location. -Although this guide attempts to be comprehensive and up to date, you will always be able to find the full list of settings available and their default values in ``settings-default.cfg`` in your main OpenMW installation directory. The ranges I have included with each setting are the physically possible ranges, not recommendations. +Although this guide attempts to be comprehensive and up to date, +you will always be able to find the full list of settings available and their default values in ``settings-default.cfg`` +in your main OpenMW installation directory. +The ranges I have included with each setting are the physically possible ranges, not recommendations. .. warning:: - As the title suggests, these are advanced settings. If digging around plain text files and manually editing settings sounds scary to you, you may want to stear clear of altering these files. That being said, this guide should be plenty clear enough that you can find the setting you want to change and safely edit it. + As the title suggests, these are advanced settings. + If digging around plain text files and manually editing settings sounds scary to you, + you may want to steer clear of altering these files. That being said, + this guide should be plenty clear enough that you can find the setting you want to change and safely edit it. .. toctree:: - :caption: Table of Contents - :maxdepth: 2 + :caption: Table of Contents + :maxdepth: 2 - camera - cells - map - GUI - HUD - game - general - input - saves - sound - terrain - video - water - windows + camera + cells + map + GUI + HUD + game + general + shaders + input + saves + sound + terrain + video + water + windows diff --git a/docs/source/reference/modding/settings/input.rst b/docs/source/reference/modding/settings/input.rst index 5d0f8f662..042dba119 100644 --- a/docs/source/reference/modding/settings/input.rst +++ b/docs/source/reference/modding/settings/input.rst @@ -10,13 +10,22 @@ grab cursor OpenMW will capture control of the cursor if this setting is true. -In "look mode", OpenMW will center the cursor regardless of the value of this setting (since the cursor/crosshair is always centered in the OpenMW window). However, in GUI mode, this setting determines the behavior when the cursor is moved outside the OpenMW window. If true, the cursor movement stops at the edge of the window preventing access to other applications. If false, the cursor is allowed to move freely on the desktop. +In "look mode", OpenMW will center the cursor regardless of the value of this setting +(since the cursor/crosshair is always centered in the OpenMW window). +However, in GUI mode, this setting determines the behavior when the cursor is moved outside the OpenMW window. +If true, the cursor movement stops at the edge of the window preventing access to other applications. +If false, the cursor is allowed to move freely on the desktop. -This setting does not apply to the screen where escape has been pressed, where the cursor is never captured. Regardless of this setting "Alt-Tab" or some other operating system dependent key sequence can be used to allow the operating system to regain control of the mouse cursor. This setting interacts with the minimize on focus loss setting by affecting what counts as a focus loss. Specifically on a two-screen configuration it may be more convenient to access the second screen with setting disabled. +This setting does not apply to the screen where escape has been pressed, where the cursor is never captured. +Regardless of this setting "Alt-Tab" or some other operating system dependent key sequence can be used +to allow the operating system to regain control of the mouse cursor. +This setting interacts with the minimize on focus loss setting by affecting what counts as a focus loss. +Specifically on a two-screen configuration it may be more convenient to access the second screen with setting disabled. -Note for developers: it's desirable to have this setting disabled when running the game in a debugger, to prevent the mouse cursor from becoming unusable when the game pauses on a breakpoint. +Note for developers: it's desirable to have this setting disabled when running the game in a debugger, +to prevent the mouse cursor from becoming unusable when the game pauses on a breakpoint. -The default value is true. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. toggle sneak ------------ @@ -25,9 +34,11 @@ toggle sneak :Range: True/False :Default: False -This setting causes the behavior of the sneak key (bound to Ctrl by default) to toggle sneaking on and off rather than requiring the key to be held down while sneaking. Players that spend significant time sneaking may find the character easier to control with this option enabled. +This setting causes the behavior of the sneak key (bound to Ctrl by default) +to toggle sneaking on and off rather than requiring the key to be held down while sneaking. +Players that spend significant time sneaking may find the character easier to control with this option enabled. -The default value is false. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. always run ---------- @@ -36,9 +47,12 @@ always run :Range: True/False :Default: False -If this setting is true, the character is running by default, otherwise the character is walking by default. The shift key will temporarily invert this setting, and the caps lock key will invert this setting while it's "locked". This setting is updated every time you exit the game, based on whether the caps lock key was on or off at the time you exited. +If this setting is true, the character is running by default, otherwise the character is walking by default. +The shift key will temporarily invert this setting, and the caps lock key will invert this setting while it's "locked". +This setting is updated every time you exit the game, +based on whether the caps lock key was on or off at the time you exited. -The default value is false. This settings can be toggled in game by pressing the CapsLock key and exiting. +This settings can be toggled in game by pressing the CapsLock key and exiting. allow third person zoom ----------------------- @@ -47,7 +61,10 @@ allow third person zoom :Range: True/False :Default: False -Allow zooming in and out using the middle mouse wheel in third person view. This feature may not work correctly if the mouse wheel is bound to other actions, and may be triggered accidentally in some cases, so is disabled by default. This setting can only be configured by editing the settings configuration file. +Allow zooming in and out using the middle mouse wheel in third person view. +This feature may not work correctly if the mouse wheel is bound to other actions, +and may be triggered accidentally in some cases, so is disabled by default. +This setting can only be configured by editing the settings configuration file. camera sensitivity ------------------ @@ -56,9 +73,13 @@ camera sensitivity :Range: > 0 :Default: 1.0 -This setting controls the overall camera/mouse sensitivity when not in GUI mode. The default sensitivity is 1.0, with smaller values requiring more mouse movement, and larger values requiring less. This setting is multiplicative in magnitude. This setting does not affect mouse speed in GUI mode, which is instead controlled by your operating system mouse speed setting. +This setting controls the overall camera/mouse sensitivity when not in GUI mode. +The default sensitivity is 1.0, with smaller values requiring more mouse movement, +and larger values requiring less. This setting is multiplicative in magnitude. +This setting does not affect mouse speed in GUI mode, +which is instead controlled by your operating system mouse speed setting. -The default value is 1.0. This setting can be changed with the Camera Sensitivity slider in the Controls panel of the Options menu. +This setting can be changed with the Camera Sensitivity slider in the Controls panel of the Options menu. camera y multiplier ------------------- @@ -67,9 +88,11 @@ camera y multiplier :Range: > 0 :Default: 1.0 -This setting controls the vertical camera/mouse sensitivity relative to the horizontal sensitivity (see camera sensitivity above). It is multiplicative with the previous setting, meaning that it should remain set at 1.0 unless the player desires to have different sensitivities in the two axes. +This setting controls the vertical camera/mouse sensitivity relative to the horizontal sensitivity +(see camera sensitivity above). It is multiplicative with the previous setting, +meaning that it should remain set at 1.0 unless the player desires to have different sensitivities in the two axes. -The default value is 1.0. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. invert y axis ------------- @@ -78,6 +101,8 @@ invert y axis :Range: True/False :Default: False -Invert the vertical axis while not in GUI mode. If this setting is true, moving the mouse away from the player will look down, while moving it towards the player will look up. This setting does not affect cursor movement in GUI mode. +Invert the vertical axis while not in GUI mode. +If this setting is true, moving the mouse away from the player will look down, +while moving it towards the player will look up. This setting does not affect cursor movement in GUI mode. -The default value is false. This setting can be toggled in game with the Invert Y Axis button in the Controls panel of the Options menu. +This setting can be toggled in game with the Invert Y Axis button in the Controls panel of the Options menu. diff --git a/docs/source/reference/modding/settings/map.rst b/docs/source/reference/modding/settings/map.rst index f3e0a1c53..e2dc71824 100644 --- a/docs/source/reference/modding/settings/map.rst +++ b/docs/source/reference/modding/settings/map.rst @@ -1,18 +1,41 @@ Map Settings ############ -global map size ---------------- +global +------ + +:Type: boolean +:Range: True/False +:Default: False + +If this setting is true, a world map on a map window will be displayed, otherwise a local map will be displayed. + +This setting can be toggled with the local/world map switch button on the map window. + +global map cell size +-------------------- :Type: integer :Range: >= 1 :Default: 18 -This setting adjusts the scale of the world map in the GUI mode map window. The value is the width in pixels of each cell in the map, so larger values result in larger more detailed world maps, while smaller values result in smaller less detailed world maps. However, the native resolution of the map source material appears to be 9 pixels per unexplored cell and approximately 18 pixels per explored cell, so values larger than 36 don't produce much additional detail. Similarly, the size of place markers is currently fixed at 12 pixels, so values smaller than this result in overlapping place markers. Values from 12 to 36 are recommended. For reference, Vvardenfell is approximately 41x36 cells. +This setting adjusts the scale of the world map in the GUI mode map window. +The value is the width in pixels of each cell in the map, so larger values result in larger more detailed world maps, +while smaller values result in smaller less detailed world maps. +However, the native resolution of the map source material appears to be 9 pixels per unexplored cell +and approximately 18 pixels per explored cell, so values larger than 36 don't produce much additional detail. +Similarly, the size of place markers is currently fixed at 12 pixels, +so values smaller than this result in overlapping place markers. +Values from 12 to 36 are recommended. For reference, Vvardenfell is approximately 41x36 cells. -Warning: Changing this setting affects saved games. The currently explored area is stored as an image in the save file that's overlayed on the default world map in game. When you increase the resolution of the map, the overlay of earlier saved games will be scaled up on load, and appear blurry. When you visit the cell again, the overlay for that cell is regenerated at the new resolution, so the blurry areas can be corrected by revisiting all the cells you've already visited. +.. Warning:: + Changing this setting affects saved games. The currently explored area is stored as an image + in the save file that's overlayed on the default world map in game. + When you increase the resolution of the map, the overlay of earlier saved games will be scaled up on load, + and appear blurry. When you visit the cell again, the overlay for that cell is regenerated at the new resolution, + so the blurry areas can be corrected by revisiting all the cells you've already visited. -The default value for this setting is 18. This setting can not be configured except by editing the settings configuration file. +This setting can not be configured except by editing the settings configuration file. local map hud widget size ------------------------- @@ -21,11 +44,29 @@ local map hud widget size :Range: >= 1 :Default: 256 -This setting controls the zoom level for the HUD map widget (the map in the lower right corner of the window). A value of 64 results in the HUD map widget displaying one entire exterior cell. Since the GUI mode map displays 3x3 cells, a value of approximately 21 displays the same area as the GUI mode map. Larger values increase the level of zoom, while smaller values are wasteful since there's no map data to display beyond the 3x3 cell grid. +This setting controls the zoom level for the HUD map widget (the map in the lower right corner of the window). +A value of 64 results in the HUD map widget displaying one entire exterior cell. +Since the GUI mode map displays 3x3 cells, a value of approximately 21 displays the same area as the GUI mode map. +Larger values increase the level of zoom, +while smaller values are wasteful since there's no map data to display beyond the 3x3 cell grid. + +Note that the actual size of the widget is always the same on the screen +unless the scaling factor setting in the "GUI" section is changed. +Increasing both the scaling factor of the GUI and this setting does result in a higher resolution HUD map, +unfortunately with a scaled direction pointer on top of it. + +This setting can not be configured except by editing the settings configuration file. -Note that the actual size of the widget is always the same on the screen unless the scaling factor setting in the "GUI" section is changed. Increasing both the scaling factor of the GUI and this setting does result in a higher resolution HUD map, but unfortunately with a scaled direction pointer on top of it. +local map hud fog of war +------------------------ -The default value for this setting is 256. This setting can not be configured except by editing the settings configuration file. +:Type: boolean +:Range: True/False +:Default: False + +This setting enables fog of war rendering on the HUD map. +Default is Off since with default settings the map is so small that the fog would not obscure anything, +just darken the edges slightly. local map resolution -------------------- @@ -34,12 +75,21 @@ local map resolution :Range: >= 1 :Default: 256 -This setting controls the resolution of the GUI mode local map window. Larger values generally increase the visible detail in map. If this setting is half the local map widget size or smaller, the map will generally be be fairly blurry. Setting both options to the same value results in a map with good detail. Values that exceed the local map widget size setting by more than a factor of two are unlikely to provide much of an improvement in detail since they're subsequently scaled back to the approximately the map widget size before display. The video resolution settings interacts with this setting in that regard. +This setting controls the resolution of the GUI mode local map window. +Larger values generally increase the visible detail in map. +If this setting is half the local map widget size or smaller, the map will generally be be fairly blurry. +Setting both options to the same value results in a map with good detail. +Values that exceed the local map widget size setting by more than a factor of two +are unlikely to provide much of an improvement in detail since they're subsequently scaled back +to the approximately the map widget size before display. +The video resolution settings interacts with this setting in that regard. .. warning:: - Increasing this setting can increase cell load times, because the map is rendered on demand each time you enter a new cell. Large values may exceed video card limits or exhaust VRAM. + Increasing this setting can increase cell load times, + because the map is rendered on demand each time you enter a new cell. + Large values may exceed video card limits or exhaust VRAM. -The default value for this setting is 256. This setting can not be configured except by editing the settings configuration file. +This setting can not be configured except by editing the settings configuration file. local map widget size --------------------- @@ -48,6 +98,19 @@ local map widget size :Range: >= 1 :Default: 512 -This setting controls the canvas size of the GUI mode local map window. Larger values result in a larger physical map size on screen, and typically require more panning to see all available portions of the map. This larger size also enables an overall greater level of detail if the local map resolution setting is also increased. +This setting controls the canvas size of the GUI mode local map window. +Larger values result in a larger physical map size on screen, +and typically require more panning to see all available portions of the map. +This larger size also enables an overall greater level of detail if the local map resolution setting is also increased. + +This setting can not be configured except by editing the settings configuration file. + +local map cell distance +----------------------- + +:Type: integer +:Range: >= 1 +:Default: 1 -The default value for this setting is 512. This setting can not be configured except by editing the settings configuration file. +Similar to "[Cells] exterior cell load distance", controls how many cells are rendered on the local map. +Values higher than the default may result in longer loading times. \ No newline at end of file diff --git a/docs/source/reference/modding/settings/saves.rst b/docs/source/reference/modding/settings/saves.rst index de0c06558..90bd56ca5 100644 --- a/docs/source/reference/modding/settings/saves.rst +++ b/docs/source/reference/modding/settings/saves.rst @@ -10,7 +10,8 @@ character This setting contains the default character name for loading saved games. -The default value is the empty string, which results in no character being selected by default. This setting is automatically updated from the Load menu when a different character is selected. +The default value is the empty string, which results in no character being selected by default. +This setting is automatically updated from the Load menu when a different character is selected. autosave -------- @@ -21,7 +22,7 @@ autosave This setting determines whether the game will be automatically saved when the character rests. -The default value is true. This setting can be toggled in game with the Auto-Save when Rest button in the Prefs panel of the Options menu. +This setting can be toggled in game with the Auto-Save when Rest button in the Prefs panel of the Options menu. timeplayed ---------- @@ -30,6 +31,7 @@ timeplayed :Range: True/False :Default: False -This setting determines whether the amount of the time the player has spent playing will be displayed for each saved game in the Load menu. +This setting determines whether the amount of the time the player has spent playing will be displayed +for each saved game in the Load menu. -The default value is false. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. diff --git a/docs/source/reference/modding/settings/shaders.rst b/docs/source/reference/modding/settings/shaders.rst new file mode 100644 index 000000000..3794c7d9a --- /dev/null +++ b/docs/source/reference/modding/settings/shaders.rst @@ -0,0 +1,122 @@ +Shader Settings +############### + +force shaders +------------- + +:Type: boolean +:Range: True/False +:Default: False + +Force rendering with shaders. By default, only bump-mapped objects will use shaders. +Enabling this option may cause slightly different visuals if the "clamp lighting" option is set to false. +Otherwise, there should not be a visual difference. + +force per pixel lighting +------------------------ + +:Type: boolean +:Range: True/False +:Default: False + +Force the use of per pixel lighting. By default, only bump mapped objects use per-pixel lighting. +Has no effect if the 'force shaders' option is false. +Enabling per-pixel lighting can result in visual differences to the original MW engine. +It is not recommended to enable this option when using vanilla Morrowind files, +because certain lights in Morrowind rely on vertex lighting to look as intended. + +clamp lighting +-------------- + +:Type: boolean +:Range: True/False +:Default: True + +Restrict the amount of lighting that an object can receive to a maximum of (1,1,1). +Only affects objects that render with shaders (see 'force shaders' option). +Always affects terrain. Setting this option to 'true' results in fixed-function compatible lighting, +but the lighting may appear 'dull' and there might be color shifts. +Setting this option to 'false' results in more realistic lighting. + +auto use object normal maps +--------------------------- + +:Type: boolean +:Range: True/False +:Default: False + +If this option is enabled, normal maps are automatically recognized and used if they are named appropriately +(see 'normal map pattern', e.g. for a base texture foo.dds, the normal map texture would have to be named foo_n.dds). +If this option is disabled, +normal maps are only used if they are explicitly listed within the mesh file (.nif or .osg file). Affects objects. + +auto use object specular maps +----------------------------- + +:Type: boolean +:Range: True/False +:Default: False + +If this option is enabled, specular maps are automatically recognized and used if they are named appropriately +(see 'specular map pattern', e.g. for a base texture foo.dds, +the specular map texture would have to be named foo_spec.dds). +If this option is disabled, normal maps are only used if they are explicitly listed within the mesh file +(.osg file, not supported in .nif files). Affects objects. + +auto use terrain normal maps +---------------------------- + +:Type: boolean +:Range: True/False +:Default: False + +See 'auto use object normal maps'. Affects terrain. + +auto use terrain specular maps +------------------------------ + +:Type: boolean +:Range: True/False +:Default: False + +If a file with pattern 'terrain specular map pattern' exists, use that file as a 'diffuse specular' map. +The texture must contain the layer color in the RGB channel (as usual), and a specular multiplier in the alpha channel. + +normal map pattern +------------------ + +:Type: string +:Range: +:Default: _n + +The filename pattern to probe for when detecting normal maps +(see 'auto use object normal maps', 'auto use terrain normal maps') + +normal height map pattern +------------------------- + +:Type: string +:Range: +:Default: _nh + +Alternative filename pattern to probe for when detecting normal maps. +Files with this pattern are expected to include 'height' in the alpha channel. +This height is used for parallax effects. Works for both terrain and objects. + +specular map pattern +-------------------- + +:Type: string +:Range: +:Default: _spec + +The filename pattern to probe for when detecting object specular maps (see 'auto use object specular maps') + +terrain specular map pattern +---------------------------- + +:Type: string +:Range: +:Default: _diffusespec + +The filename pattern to probe for when detecting terrain specular maps (see 'auto use terrain specular maps') \ No newline at end of file diff --git a/docs/source/reference/modding/settings/sound.rst b/docs/source/reference/modding/settings/sound.rst index dec4bb3a2..33185ed66 100644 --- a/docs/source/reference/modding/settings/sound.rst +++ b/docs/source/reference/modding/settings/sound.rst @@ -8,7 +8,8 @@ device :Range: :Default: "" -This setting determines which audio device to use. A blank or missing setting means to use the default device, which should usually be sufficient, but if you need to explicitly specify a device use this setting. +This setting determines which audio device to use. A blank or missing setting means to use the default device, +which should usually be sufficient, but if you need to explicitly specify a device use this setting. The names of detected devices can be found in the openmw.log file in your configuration directory. @@ -21,9 +22,11 @@ master volume :Range: 0.0 to 1.0 :Default: 1.0 -This setting controls the overall volume. The master volume is multiplied with all other volume settings to determine the final volume. +This setting controls the overall volume. +The master volume is multiplied with all other volume settings to determine the final volume. -The default value is 1.0. Valid values range from 0.0 (silent) to 1.0 (maximum volume). This setting can be changed in game using the Master slider from the Audio panel of the Options menu. +The default value is 1.0. Valid values range from 0.0 (silent) to 1.0 (maximum volume). +This setting can be changed in game using the Master slider from the Audio panel of the Options menu. footsteps volume ---------------- @@ -34,7 +37,8 @@ footsteps volume This setting controls the volume of footsteps from the character and other actors. -The default value is 0.2. Valid values range from 0.0 (silent) to 1.0 (maximum volume). This setting can be changed in game using the Footsteps slider from the Audio panel of the Options menu. +Valid values range from 0.0 (silent) to 1.0 (maximum volume). +This setting can be changed in game using the Footsteps slider from the Audio panel of the Options menu. music volume ------------ @@ -45,7 +49,8 @@ music volume This setting controls the volume for music tracks. -The default value is 0.5. Valid values range from 0.0 (silent) to 1.0 (maximum volume). This setting can be changed in game using the Music slider from the Audio panel of the Options menu. +The default value is 0.5. Valid values range from 0.0 (silent) to 1.0 (maximum volume). +This setting can be changed in game using the Music slider from the Audio panel of the Options menu. sfx volume ---------- @@ -56,7 +61,8 @@ sfx volume This setting controls the volume for special sound effects such as combat noises. -The default value is 1.0. Valid values range from 0.0 (silent) to 1.0 (maximum volume). This setting can be changed in game using the Effects slider from the Audio panel of the Options menu. +Valid values range from 0.0 (silent) to 1.0 (maximum volume). +This setting can be changed in game using the Effects slider from the Audio panel of the Options menu. voice volume ------------ @@ -67,7 +73,8 @@ voice volume This setting controls the volume for spoken dialog from NPCs. -The default value is 0.8. Valid values range from 0.0 (silent) to 1.0 (maximum volume). This setting can be changed in game using the Voice slider from the Audio panel of the Options menu. +Valid values range from 0.0 (silent) to 1.0 (maximum volume). +This setting can be changed in game using the Voice slider from the Audio panel of the Options menu. buffer cache min ---------------- @@ -76,9 +83,12 @@ buffer cache min :Range: > 0 :Default: 14 -This setting determines the minimum size of the sound buffer cache in megabytes. When the cache reaches the size specified by the buffer cache max setting, old buffers will be unloaded until it's using no more memory than specified by this setting. This setting must be less than or equal to the buffer cache max setting. +This setting determines the minimum size of the sound buffer cache in megabytes. +When the cache reaches the size specified by the buffer cache max setting, +old buffers will be unloaded until it's using no more memory than specified by this setting. +This setting must be less than or equal to the buffer cache max setting. -The default value is 14. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. buffer cache max ---------------- @@ -87,9 +97,11 @@ buffer cache max :Range: > 0 :Default: 16 -This setting determines the maximum size of the sound buffer cache in megabytes. When the cache reaches this size, old buffers will be unloaded until it reaches the size specified by the buffer cache min setting. This setting must be greater than or equal to the buffer cache min setting. +This setting determines the maximum size of the sound buffer cache in megabytes. When the cache reaches this size, +old buffers will be unloaded until it reaches the size specified by the buffer cache min setting. +This setting must be greater than or equal to the buffer cache min setting. -The default value is 16. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. hrtf enable ----------- @@ -98,8 +110,13 @@ hrtf enable :Range: -1, 0, 1 :Default: -1 -This setting determines whether to enable head-related transfer function (HRTF) audio processing. HRTF audio processing creates the perception of sounds occurring in a three dimensional space when wearing headphones. Enabling HRTF may also require an OpenAL Soft version greater than 1.17.0, and possibly some operating system configuration. A value of 0 disables HRTF processing, while a value of 1 explicitly enables HRTF processing. -The default value is -1, which should enable the feature automatically for most users when possible. This setting can only be configured by editing the settings configuration file. +This setting determines whether to enable head-related transfer function (HRTF) audio processing. +HRTF audio processing creates the perception of sounds occurring in a three dimensional space when wearing headphones. +Enabling HRTF may also require an OpenAL Soft version greater than 1.17.0, +and possibly some operating system configuration. +A value of 0 disables HRTF processing, while a value of 1 explicitly enables HRTF processing. +The default value is -1, which should enable the feature automatically for most users when possible. +This setting can only be configured by editing the settings configuration file. hrtf ---- @@ -108,6 +125,9 @@ hrtf :Range: :Default: "" -This setting specifies which HRTF profile to use when HRTF is enabled. Blank means use the default. This setting has no effect if HRTF is not enabled based on the hrtf enable setting. Allowed values for this field are enumerated in openmw.log file is an HRTF enabled ausio system is installed. +This setting specifies which HRTF profile to use when HRTF is enabled. Blank means use the default. +This setting has no effect if HRTF is not enabled based on the hrtf enable setting. +Allowed values for this field are enumerated in openmw.log file is an HRTF enabled ausio system is installed. -The default value is the empty string, which uses the default profile. This setting can only be configured by editing the settings configuration file. +The default value is the empty string, which uses the default profile. +This setting can only be configured by editing the settings configuration file. diff --git a/docs/source/reference/modding/settings/terrain.rst b/docs/source/reference/modding/settings/terrain.rst index 8c550b269..6bb87629a 100644 --- a/docs/source/reference/modding/settings/terrain.rst +++ b/docs/source/reference/modding/settings/terrain.rst @@ -1,5 +1,5 @@ Terrain Settings -############### +################ distant terrain --------------- @@ -8,8 +8,15 @@ distant terrain :Range: True/False :Default: False -Controls whether the engine will use paging and LOD algorithms to render the terrain of the entire world at all times. Otherwise, only the terrain of the loaded cells is displayed. This setting is best used together with the 'viewing distance' setting in the camera section. +Controls whether the engine will use paging and LOD algorithms to render the terrain of the entire world at all times. +Otherwise, only the terrain of the loaded cells is displayed. +This setting is best used together with the 'viewing distance' setting in the camera section. -To avoid frame drops as the player moves around, nearby terrain pages are always preloaded in the background, regardless of the preloading settings in the 'Cells' section, but the preloading of terrain behind a door or a travel destination, for example, will still be controlled by cell preloading settings. +To avoid frame drops as the player moves around, nearby terrain pages are always preloaded in the background, +regardless of the preloading settings in the 'Cells' section, +but the preloading of terrain behind a door or a travel destination, for example, +will still be controlled by cell preloading settings. -The distant terrain engine is currently considered experimental and may receive updates and/or further configuration options in the future. The glaring omission of non-terrain objects in the distance somewhat limits this setting's usefulness. +The distant terrain engine is currently considered experimental +and may receive updates and/or further configuration options in the future. +The glaring omission of non-terrain objects in the distance somewhat limits this setting's usefulness. diff --git a/docs/source/reference/modding/settings/video.rst b/docs/source/reference/modding/settings/video.rst index b724611ad..3581d7226 100644 --- a/docs/source/reference/modding/settings/video.rst +++ b/docs/source/reference/modding/settings/video.rst @@ -8,9 +8,13 @@ resolution x :Range: > 0 :Default: 800 -This setting determines the horizontal resolution of the OpenMW game window. Larger values produce more detailed images within the constraints of your graphics hardware but also significantly reduce the frame rate. +This setting determines the horizontal resolution of the OpenMW game window. +Larger values produce more detailed images within the constraints of your graphics hardware, +but also significantly reduce the frame rate. -The default value is 800. The window resolution can be selected from a menu of common screen sizes in the Video tab of the Video Panel of the Options menu, or in the Graphics tab of the OpenMW Launcher. The horizontal resolution can also be set to a custom value in the Graphics tab of the OpenMW Launcher. +The window resolution can be selected from a menu of common screen sizes +in the Video tab of the Video Panel of the Options menu, or in the Graphics tab of the OpenMW Launcher. +The horizontal resolution can also be set to a custom value in the Graphics tab of the OpenMW Launcher. resolution y ------------ @@ -19,9 +23,13 @@ resolution y :Range: > 0 :Default: 600 -This setting determines the vertical resolution of the OpenMW game window. Larger values produce more detailed images within the constraints of your graphics hardware but also significantly reduce the frame rate. +This setting determines the vertical resolution of the OpenMW game window. +Larger values produce more detailed images within the constraints of your graphics hardware, +but also significantly reduce the frame rate. -The default value is 600. The window resolution can be selected from a menu of common screen sizes in the Video tab of the Video Panel of the Options menu, or in the Graphics tab of the OpenMW Launcher. The vertical resolution can also be set to a custom value in the Graphics tab of the OpenMW Launcher. +The window resolution can be selected from a menu of common screen sizes +in the Video tab of the Video Panel of the Options menu, or in the Graphics tab of the OpenMW Launcher. +The vertical resolution can also be set to a custom value in the Graphics tab of the OpenMW Launcher. fullscreen ---------- @@ -32,7 +40,8 @@ fullscreen This setting determines whether the entire screen is used for the specified resolution. -The default value is false. This setting can be toggled in game using the Fullscreen button in the Video tab of the Video panel in the Options menu. It can also be toggled with the Full Screen check box in the Graphics tab of the OpenMW Launcher. +This setting can be toggled in game using the Fullscreen button in the Video tab of the Video panel in the Options menu. +It can also be toggled with the Full Screen check box in the Graphics tab of the OpenMW Launcher. screen ------ @@ -41,26 +50,38 @@ screen :Range: >= 0 :Default: 0 -This setting determines which screen the game will open on in multi-monitor configurations. This setting is particularly important when the fullscreen setting is true, since this is the only way to control which screen is used, but it can also be used to control which screen a normal window or a borderless window opens on as well. The screens are numbered in increasing order, beginning with 0. +This setting determines which screen the game will open on in multi-monitor configurations. +This setting is particularly important when the fullscreen setting is true, +since this is the only way to control which screen is used, +but it can also be used to control which screen a normal window or a borderless window opens on as well. +The screens are numbered in increasing order, beginning with 0. -The default value is 0. This setting can be selected from a pull down menu in the Graphics tab of the OpenMW Launcher, but cannot be changed during game play. +This setting can be selected from a pull down menu in the Graphics tab of the OpenMW Launcher, +but cannot be changed during game play. minimize on focus loss ---------------------- :Type: boolean :Range: True/False -:Default: False +:Default: True -Minimize the OpenMW window if it loses cursor focus. This setting is primarily useful for single screen configurations, so that the OpenMW screen in full screen mode can be minimized when the operating system regains control of the mouse and keyboard. On multiple screen configurations, disabling this option makes it easier to switch between screens while playing OpenMW. +Minimize the OpenMW window if it loses cursor focus. This setting is primarily useful for single screen configurations, +so that the OpenMW screen in full screen mode can be minimized +when the operating system regains control of the mouse and keyboard. +On multiple screen configurations, disabling this option makes it easier to switch between screens while playing OpenMW. -Note that a minimized game window consumes less system resources and produces less heat, since the game does not need to render in minimized state. It is therefore advisable to minimize the game during pauses (either via use of this setting, or by minimizing the window manually). +.. Note:: + A minimized game window consumes less system resources and produces less heat, + since the game does not need to render in minimized state. + It is therefore advisable to minimize the game during pauses + (either via use of this setting, or by minimizing the window manually). This setting has no effect if the fullscreen setting is false. Developer note: corresponds to SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS. -The default value is true. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. window border ------------- @@ -69,11 +90,15 @@ window border :Range: True/False :Default: True -This setting determines whether there's an operating system border drawn around the OpenMW window. If this setting is true, the window can be moved and resized with the operating system window controls. If this setting is false, the window has no operating system border. +This setting determines whether there's an operating system border drawn around the OpenMW window. +If this setting is true, the window can be moved and resized with the operating system window controls. +If this setting is false, the window has no operating system border. This setting has no effect if the fullscreen setting is true. -The default value is true. This setting can be toggled in game using the Window Border button in the Video tab of the Video panel in the Options menu. It can also be toggled with the Window Border check box in the OpenMW Launcher. +This setting can be toggled in game using the Window Border button +in the Video tab of the Video panel in the Options menu. +It can also be toggled with the Window Border check box in the OpenMW Launcher. antialiasing ------------ @@ -82,9 +107,16 @@ antialiasing :Range: 0, 2, 4, 8, 16 :Default: 0 -This setting controls anti-aliasing. Anti-aliasing is a technique designed to improve the appearance of polygon edges, so they do not appear to be "jagged". Anti-aliasing can smooth these edges at the cost of a minor reduction in the frame rate. A value of 0 disables anti-aliasing. Other powers of two (e.g. 2, 4, 8, 16) are supported according to the capabilities of your graphics hardware. Higher values do a better job of smoothing out the image but have a greater impact on frame rate. +This setting controls anti-aliasing. Anti-aliasing is a technique designed to improve the appearance of polygon edges, +so they do not appear to be "jagged". +Anti-aliasing can smooth these edges at the cost of a minor reduction in the frame rate. +A value of 0 disables anti-aliasing. +Other powers of two (e.g. 2, 4, 8, 16) are supported according to the capabilities of your graphics hardware. +Higher values do a better job of smoothing out the image but have a greater impact on frame rate. -This setting can be configured from a list of valid choices in the Graphics panel of the OpenMW Launcher, but cannot be changed during game play - due to a technical limitation that may be addressed in a future version of OpenMW. +This setting can be configured from a list of valid choices in the Graphics panel of the OpenMW Launcher, +but cannot be changed during game play +due to a technical limitation that may be addressed in a future version of OpenMW. vsync ----- @@ -93,9 +125,15 @@ vsync :Range: True/False :Default: False -This setting determines whether frame draws are synchronized with the vertical refresh rate of your monitor. Enabling this setting can reduce screen tearing, a visual defect caused by updating the image buffer in the middle of a screen draw. Enabling this option typically implies limiting the framerate to 60 frames per second, but may also introduce additional delays caused by having to wait until the appropriate time (the vertical blanking interval) to draw a frame. +This setting determines whether frame draws are synchronized with the vertical refresh rate of your monitor. +Enabling this setting can reduce screen tearing, +a visual defect caused by updating the image buffer in the middle of a screen draw. +Enabling this option typically implies limiting the framerate to 60 frames per second, +but may also introduce additional delays caused by having to wait until the appropriate time +(the vertical blanking interval) to draw a frame. -The default value is false. This setting can be adjusted in game using the VSync button in the Video tab of the Video panel in the Options menu. It can also be changed by toggling the Vertical Sync check box in the Graphics tab of the OpenMW Launcher. +This setting can be adjusted in game using the VSync button in the Video tab of the Video panel in the Options menu. +It can also be changed by toggling the Vertical Sync check box in the Graphics tab of the OpenMW Launcher. framerate limit --------------- @@ -104,13 +142,24 @@ framerate limit :Range: >= 0.0 :Default: 0.0 -This setting determines the maximum frame rate in frames per second. If this setting is 0.0, the frame rate is unlimited. +This setting determines the maximum frame rate in frames per second. +If this setting is 0.0, the frame rate is unlimited. -There are several reasons to consider capping your frame rate, especially if you're already experiencing a relatively high frame rate (greater than 60 frames per second). Lower frame rates will consume less power and generate less heat and noise. Frame rates above 60 frames per second rarely produce perceptible improvements in visual quality, but may improve input responsiveness. Capping the frame rate may in some situations reduce the perception of choppiness (highly variable frame rates during game play) by lowering the peak frame rates. +There are several reasons to consider capping your frame rate, +especially if you're already experiencing a relatively high frame rate (greater than 60 frames per second). +Lower frame rates will consume less power and generate less heat and noise. +Frame rates above 60 frames per second rarely produce perceptible improvements in visual quality, +but may improve input responsiveness. +Capping the frame rate may in some situations reduce the perception of choppiness +(highly variable frame rates during game play) by lowering the peak frame rates. -This setting interacts with the vsync setting in the Video section in the sense that enabling vertical sync limits the frame rate to the refresh rate of your monitor (often 60 frames per second). Choosing to limit the frame rate using this setting instead of vsync may reduce input lag due to the game not having to wait for the vertical blanking interval. +This setting interacts with the vsync setting in the Video section +in the sense that enabling vertical sync limits the frame rate to the refresh rate of your monitor +(often 60 frames per second). +Choosing to limit the frame rate using this setting instead of vsync may reduce input lag +due to the game not having to wait for the vertical blanking interval. -The default value is 0.0. This setting can only be configured by editing the settings configuration file. +This setting can only be configured by editing the settings configuration file. contrast -------- @@ -121,7 +170,8 @@ contrast This setting controls the contrast correction for all video in the game. -The default value is 1.0. This setting can only be configured by editing the settings configuration file. This setting does not currently work under Linux. +This setting can only be configured by editing the settings configuration file. +This setting does not currently work under Linux. gamma ----- @@ -130,6 +180,8 @@ gamma :Range: > 0.0 :Default: 1.0 -This setting controls the gamma correction for all video in the game. Gamma is an exponent that makes colors brighter if greater than 1.0 and darker if less than 1.0. +This setting controls the gamma correction for all video in the game. +Gamma is an exponent that makes colors brighter if greater than 1.0 and darker if less than 1.0. -The default value is 1.0. This setting can be changed in the Detail tab of the Video panel of the Options menu. This setting does not currently work under Linux, and the in-game setting in the Options menu has been disabled. +This setting can be changed in the Detail tab of the Video panel of the Options menu. +This setting does not currently work under Linux, and the in-game setting in the Options menu has been disabled. diff --git a/docs/source/reference/modding/settings/water.rst b/docs/source/reference/modding/settings/water.rst index b2d04a416..2344222e5 100644 --- a/docs/source/reference/modding/settings/water.rst +++ b/docs/source/reference/modding/settings/water.rst @@ -2,7 +2,13 @@ Water Settings ############## .. note:: - The settings for the water shader are difficult to describe, but can be seen immediately in the Water tab of the Video panel in the Options menu. Changes there will be saved to these settings. It is suggested to stand on the shore of a moderately broad body of water with trees or other objects on the far shore to test reflection textures, underwater plants in shallow water near by to test refraction textures, and some deep water visible from your location to test deep water visibility. + The settings for the water shader are difficult to describe, + but can be seen immediately in the Water tab of the Video panel in the Options menu. + Changes there will be saved to these settings. + It is suggested to stand on the shore of a moderately broad body of water with trees or other objects + on the far shore to test reflection textures, + underwater plants in shallow water near by to test refraction textures, + and some deep water visible from your location to test deep water visibility. shader ------ @@ -11,9 +17,10 @@ shader :Range: True/False :Default: False -This setting enables or disables the water shader, which results in much more realistic looking water surfaces, including reflected objects and a more detailed wavy surface. +This setting enables or disables the water shader, which results in much more realistic looking water surfaces, +including reflected objects and a more detailed wavy surface. -The default value is false. This setting can be toggled with the Shader button in the Water tab of the Video panel of the Options menu. +This setting can be toggled with the Shader button in the Water tab of the Video panel of the Options menu. rtt size -------- @@ -22,10 +29,16 @@ rtt size :Range: > 0 :Default: 512 -The setting determines the size of the texture used for reflection and refraction (if enabled). For reflection, the texture size determines the detail of reflected images on the surface of the water. For refraction, the texture size determines the detail of the objects on the other side of the plane of water (which have a wavy appearance caused by the refraction). RTT is an acronym for Render to Texture which allows rendering of the scene to be saved as a texture. +The setting determines the size of the texture used for reflection and refraction (if enabled). +For reflection, the texture size determines the detail of reflected images on the surface of the water. +For refraction, the texture size determines the detail of the objects on the other side of the plane of water +(which have a wavy appearance caused by the refraction). +RTT is an acronym for Render To Texture which allows rendering of the scene to be saved as a texture. Higher values produces better visuals and result in a marginally lower frame rate depending on your graphics hardware. -In the Water tab of the Video panel of the Options menu, the choices are Low (512), Medium (1024) and High (2048). This setting has no effect if the shader setting is false. It is recommended to use values that are a power of two because this results in more efficient use of video hardware. +In the Water tab of the Video panel of the Options menu, the choices are Low (512), Medium (1024) and High (2048). +This setting has no effect if the shader setting is false. +It is recommended to use values that are a power of two because this results in more efficient use of video hardware. This setting has no effect if the shader setting is false. @@ -36,11 +49,24 @@ refraction :Range: True/False :Default: False -This setting enables the refraction rendering feature of the water shader. Refraction causes deep water to be more opaque and objects seen through the plane of the water to have a wavy appearance. Enabling this feature results in better visuals, and a marginally lower frame rate depending on your graphics hardware. +This setting enables the refraction rendering feature of the water shader. +Refraction causes deep water to be more opaque +and objects seen through the plane of the water to have a wavy appearance. +Enabling this feature results in better visuals, and a marginally lower frame rate depending on your graphics hardware. This setting has no effect if the shader setting is false. -The default setting is false. This setting can be toggled with the Refraction button in the Water tab of the Video panel of the Options menu. +This setting can be toggled with the Refraction button in the Water tab of the Video panel of the Options menu. + +reflect actors +-------------- + +:Type: boolean +:Range: True/False +:Default: False + +This setting controls whether or not NPCs and creatures are drawn in water reflections. +Setting this to true will enable actors in reflections and increase realism with a likely decrease in performance. small feature culling pixel size -------------------------------- @@ -49,10 +75,14 @@ small feature culling pixel size :Range: > 0 :Default: 20.0 -Controls the cutoff in pixels for small feature culling - see the 'Camera' section for more details, however this setting in the 'Water' section applies specifically to objects rendered in water reflection and refraction textures. +Controls the cutoff in pixels for small feature culling - see the 'Camera' section for more details, +however this setting in the 'Water' section applies specifically to objects rendered in water reflection +and refraction textures. -The setting 'rtt size' interacts with this setting because it controls how large a pixel on the water texture (technically called a texel) is in pixels on the screen. +The setting 'rtt size' interacts with this setting +because it controls how large a pixel on the water texture (technically called a texel) is in pixels on the screen. -This setting will have no effect if the shader setting is false, or the 'small feature culling' (in the 'Camera' section) is disabled. +This setting will have no effect if the shader setting is false, +or the 'small feature culling' (in the 'Camera' section) is disabled. This setting can only be configured by editing the settings configuration file. diff --git a/docs/source/reference/modding/settings/windows.rst b/docs/source/reference/modding/settings/windows.rst index 8860de983..170f68381 100644 --- a/docs/source/reference/modding/settings/windows.rst +++ b/docs/source/reference/modding/settings/windows.rst @@ -4,146 +4,246 @@ Windows Settings :Type: floating point :Range: 0.0 to 1.0 -This section controls the location and size of each window in GUI mode. Each setting is a floating point number representing a *fraction* of the resolution x or resolution y setting in the Video Settings Section. The X and Y values locate the top left corner of the window, while the W value determines the width of the window and the H value determines the height of the window. +This section controls the location and size of each window in GUI mode. +Each setting is a floating point number representing a *fraction* +of the resolution x or resolution y setting in the Video Settings Section. +The X and Y values locate the top left corner of the window, +while the W value determines the width of the window and the H value determines the height of the window. -Unlike the documentation for most sections which lists the exact setting name, this page instead lists the names of the windows. For example, to configure the alchemy window, the actual settings would be:: +Unlike the documentation for most sections which lists the exact setting name, +this page instead lists the names of the windows. +For example, to configure the alchemy window, the actual settings would be:: alchemy x = 0.25 alchemy y = 0.25 alchemy h = 0.5 alchemy w = 0.5 -Each window in the GUI mode remembers it's previous location when exiting the game. By far the easiest way to configure these settings is to simply move the windows around in game. Hand editing the configuration file might result in some fine tuning for alignment, but the settings will be overwritten if a window is moved. +Each window in the GUI mode remembers it's previous location when exiting the game. +By far the easiest way to configure these settings is to simply move the windows around in game. +Hand editing the configuration file might result in some fine tuning for alignment, +but the settings will be overwritten if a window is moved. .. note:: To scale the windows, making the widgets proportionally larger, see the scaling factor setting instead. +:Type: boolean +:Range: True/False + +This section controls the state of pinnable windows: pinned or not. +For example, to pin only the map window, the actual settings will be:: + + inventory pin = false + map pin = true + stats pin = false + spells pin = false + +The pinnable window can be pinned/unpinned by clicking on a button in the right upper corner of the window. + +.. note:: + A world/local map switch button on the map window will be shown only in GUI mode. + stats ----- -:Default: x = 0.0 - y = 0.0 - h = 0.375 - w = 0.4275 +:Default: + x = 0.0 + + y = 0.0 + + h = 0.375 + + w = 0.4275 -The stats window, displaying level, race, class, skills and stats. Activated by clicking on any of the three bars in the lower left corner of the HUD. + pin = false + +The stats window, displaying level, race, class, skills and stats. +Activated by clicking on any of the three bars in the lower left corner of the HUD. spells ------ -:Default: x = 0.625 - y = 0.5725 - h = 0.375 - w = 0.4275 - -The spells window, displaying powers, spells, and magical items. Activated by clicking on the spells widget (third from left) in the bottom left corner of the HUD. +:Default: + x = 0.625 -map ---- + y = 0.5725 -:Default: x = 0.625 - y = 0.0 - h = 0.375 - w = 0.5725 + h = 0.375 -The local and world map window. Activated by clicking on the map widget in the bottom right corner of the HUD. + w = 0.4275 -dialogue --------- + pin = false -:Default: x = 0.095 - y = 0.095 - h = 0.810 - w = 0.810 +The spells window, displaying powers, spells, and magical items. +Activated by clicking on the spells widget (third from left) in the bottom left corner of the HUD. -The dialog window, for talking with NPCs. Activated by clicking on a NPC. +map +--- -alchemy -------- +:Default: + x = 0.625 -:Default: x = 0.25 - y = 0.25 - h = 0.5 - w = 0.5 + y = 0.0 -The alchemy window, for crafting potions. Activated by dragging an alchemy tool on to the rag doll. Unlike most other windows, this window hides all other windows when opened. + h = 0.375 -console -------- + w = 0.5725 -:Default: x = 0.0 - y = 0.0 - h = 1.0 - w = 0.5 + pin = false -The console command window. Activated by pressing the tilde (~) key. +The local and world map window. +Activated by clicking on the map widget in the bottom right corner of the HUD. inventory --------- -:Default: x = 0.0 - y = 0.4275 - h = 0.6225 - w = 0.5725 +:Default: + x = 0.0 + + y = 0.4275 -The inventory window, displaying the paper doll and possessions, when activated by clicking on the inventory widget (second from left) in the bottom left corner of the HUD. + h = 0.6225 + + w = 0.5725 + + pin = false + +The inventory window, displaying the paper doll and possessions, +when activated by clicking on the inventory widget (second from left) in the bottom left corner of the HUD. inventory container ------------------- -:Default: x = 0.0 - y = 0.4275 - h = 0.6225 - w = 0.5725 +:Default: + x = 0.0 + + y = 0.4275 -The player's inventory window while searching a container, showing the contents of the character's inventory. Activated by clicking on a container. The same window is used for searching dead bodies, and pickpocketing people. + h = 0.6225 + + w = 0.5725 + + +The player's inventory window while searching a container, showing the contents of the character's inventory. +Activated by clicking on a container. The same window is used for searching dead bodies, and pickpocketing people. inventory barter ---------------- -:Default: x = 0.0 - y = 0.4275 - h = 0.6225 - w = 0.5725 +:Default: + x = 0.0 + + y = 0.4275 -The player's inventory window while bartering. It displays goods owned by the character while bartering. Activated by clicking on the Barter choice in the dialog window for an NPC. + h = 0.6225 + + w = 0.5725 + +The player's inventory window while bartering. It displays goods owned by the character while bartering. +Activated by clicking on the Barter choice in the dialog window for an NPC. inventory companion ------------------- -:Default: x = 0.0 - y = 0.4275 - h = 0.6225 - w = 0.5725 +:Default: + x = 0.0 + + y = 0.4275 + + h = 0.6225 -The player's inventory window while interacting with a companion. The companion windows were added in the Tribunal expansion, but are available everywhere in the OpenMW engine. + w = 0.5725 + +The player's inventory window while interacting with a companion. +The companion windows were added in the Tribunal expansion, but are available everywhere in the OpenMW engine. container --------- -:Default: x = 0.25 - y = 0.0 - h = 0.75 - w = 0.375 +:Default: + x = 0.25 + + y = 0.0 + + h = 0.75 -The container window, showing the contents of the container. Activated by clicking on a container. The same window is used for searching dead bodies, and pickpocketing people. + w = 0.375 + +The container window, showing the contents of the container. Activated by clicking on a container. +The same window is used for searching dead bodies, and pickpocketing people. barter ------ -:Default: x = 0.25 - y = 0.0 - h = 0.75 - w = 0.375 +:Default: + x = 0.25 + + y = 0.0 -The NPC bartering window, displaying goods owned by the shopkeeper while bartering. Activated by clicking on the Barter choice in the dialog window for an NPC. + h = 0.75 + + w = 0.375 + +The NPC bartering window, displaying goods owned by the shopkeeper while bartering. +Activated by clicking on the Barter choice in the dialog window for an NPC. companion --------- -:Default: x = 0.25 - y = 0.0 - h = 0.75 - w = 0.375 +:Default: + x = 0.25 + + y = 0.0 + + h = 0.75 + + w = 0.375 + +The NPC's inventory window while interacting with a companion. +The companion windows were added in the Tribunal expansion, but are available everywhere in the OpenMW engine. + +dialogue +-------- + +:Default: + x = 0.095 + + y = 0.095 + + h = 0.810 + + w = 0.810 + +The dialog window, for talking with NPCs. +Activated by clicking on a NPC. + +alchemy +------- + +:Default: + x = 0.25 + + y = 0.25 + + h = 0.5 + + w = 0.5 + +The alchemy window, for crafting potions. +Activated by dragging an alchemy tool on to the rag doll. +Unlike most other windows, this window hides all other windows when opened. + +console +------- + +:Default: + x = 0.0 + + y = 0.0 + + h = 1.0 + + w = 0.5 -The NPC's inventory window while interacting with a companion. The companion windows were added in the Tribunal expansion, but are available everywhere in the OpenMW engine. \ No newline at end of file +The console command window. +Activated by pressing the tilde (~) key. diff --git a/docs/source/source/index.rst b/docs/source/source/index.rst deleted file mode 100644 index b58bf2b37..000000000 --- a/docs/source/source/index.rst +++ /dev/null @@ -1,8 +0,0 @@ -Project Source Documentation -============================ - -.. toctree:: - :maxdepth: 2 - - openmw/index - opencs/index \ No newline at end of file diff --git a/docs/source/source/opencs/index.rst b/docs/source/source/opencs/index.rst deleted file mode 100644 index b648bc49c..000000000 --- a/docs/source/source/opencs/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -OpenMW-CS Source Documentation -############################## - -.. toctree:: - :maxdepth: 2 - - model/index - view/index - -.. autodoxygenfile:: editor.hpp - :project: opencs \ No newline at end of file diff --git a/docs/source/source/opencs/model/index.rst b/docs/source/source/opencs/model/index.rst deleted file mode 100644 index 38ca0c31c..000000000 --- a/docs/source/source/opencs/model/index.rst +++ /dev/null @@ -1,358 +0,0 @@ -./opencs/model -############## - -doc ---- - .. autodoxygenfile:: model/doc/blacklist.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/document.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/documentmanager.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/loader.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/messages.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/operationholder.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/operation.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/runner.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/saving.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/savingstages.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/savingstate.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/stage.hpp - :project: opencs - - .. autodoxygenfile:: model/doc/state.hpp - :project: opencs - -filter ------- - .. autodoxygenfile:: model/filter/andnode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/booleannode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/leafnode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/narynode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/node.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/notnode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/ornode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/parser.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/textnode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/unarynode.hpp - :project: opencs - - .. autodoxygenfile:: model/filter/valuenode.hpp - :project: opencs - -prefs ------ - .. autodoxygenfile:: model/prefs/boolsetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/category.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/coloursetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/doublesetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/enumsetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/intsetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/modifiersetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/setting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/shortcuteventhandler.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/shortcut.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/shortcutmanager.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/shortcutsetting.hpp - :project: opencs - - .. autodoxygenfile:: model/prefs/state.hpp - :project: opencs - -tools ------ - .. autodoxygenfile:: model/tools/birthsigncheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/bodypartcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/classcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/factioncheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/gmstcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/journalcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/magiceffectcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/mandatoryid.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/mergeoperation.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/mergestages.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/mergestate.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/pathgridcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/racecheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/referenceablecheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/referencecheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/regioncheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/reportmodel.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/scriptcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/search.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/searchoperation.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/searchstage.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/skillcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/soundcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/soundgencheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/spellcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/startscriptcheck.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/tools.hpp - :project: opencs - - .. autodoxygenfile:: model/tools/topicinfocheck.hpp - :project: opencs - -world ------ - .. autodoxygenfile:: model/world/cellcoordinates.hpp - :project: opencs - - .. autodoxygenfile:: model/world/cell.hpp - :project: opencs - - .. autodoxygenfile:: model/world/cellselection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/collectionbase.hpp - :project: opencs - - .. autodoxygenfile:: model/world/collection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/columnbase.hpp - :project: opencs - - .. autodoxygenfile:: model/world/columnimp.hpp - :project: opencs - - .. autodoxygenfile:: model/world/columns.hpp - :project: opencs - - .. autodoxygenfile:: model/world/commanddispatcher.hpp - :project: opencs - - .. autodoxygenfile:: model/world/commandmacro.hpp - :project: opencs - - .. autodoxygenfile:: model/world/commands.hpp - :project: opencs - - .. autodoxygenfile:: model/world/data.hpp - :project: opencs - - .. autodoxygenfile:: model/world/defaultgmsts.hpp - :project: opencs - - .. autodoxygenfile:: model/world/idcollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/idcompletionmanager.hpp - :project: opencs - - .. autodoxygenfile:: model/world/idtablebase.hpp - :project: opencs - - .. autodoxygenfile:: model/world/idtable.hpp - :project: opencs - - .. autodoxygenfile:: model/world/idtableproxymodel.hpp - :project: opencs - - .. autodoxygenfile:: model/world/idtree.hpp - :project: opencs - - .. autodoxygenfile:: model/world/infocollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/info.hpp - :project: opencs - - .. autodoxygenfile:: model/world/infoselectwrapper.hpp - :project: opencs - - .. autodoxygenfile:: model/world/infotableproxymodel.hpp - :project: opencs - - .. autodoxygenfile:: model/world/land.hpp - :project: opencs - - .. autodoxygenfile:: model/world/landtexture.hpp - :project: opencs - - .. autodoxygenfile:: model/world/metadata.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedcoladapterimp.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedcollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedcolumnadapter.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedidcollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedinfocollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedtableproxymodel.hpp - :project: opencs - - .. autodoxygenfile:: model/world/nestedtablewrapper.hpp - :project: opencs - - .. autodoxygenfile:: model/world/pathgrid.hpp - :project: opencs - - .. autodoxygenfile:: model/world/record.hpp - :project: opencs - - .. autodoxygenfile:: model/world/refcollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/ref.hpp - :project: opencs - - .. autodoxygenfile:: model/world/refidadapter.hpp - :project: opencs - - .. autodoxygenfile:: model/world/refidadapterimp.hpp - :project: opencs - - .. autodoxygenfile:: model/world/refidcollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/refiddata.hpp - :project: opencs - - .. autodoxygenfile:: model/world/regionmap.hpp - :project: opencs - - .. autodoxygenfile:: model/world/resources.hpp - :project: opencs - - .. autodoxygenfile:: model/world/resourcesmanager.hpp - :project: opencs - - .. autodoxygenfile:: model/world/resourcetable.hpp - :project: opencs - - .. autodoxygenfile:: model/world/scope.hpp - :project: opencs - - .. autodoxygenfile:: model/world/scriptcontext.hpp - :project: opencs - - .. autodoxygenfile:: model/world/subcellcollection.hpp - :project: opencs - - .. autodoxygenfile:: model/world/tablemimedata.hpp - :project: opencs - - .. autodoxygenfile:: model/world/universalid.hpp - :project: opencs - diff --git a/docs/source/source/opencs/view/index.rst b/docs/source/source/opencs/view/index.rst deleted file mode 100644 index 54d00ccc0..000000000 --- a/docs/source/source/opencs/view/index.rst +++ /dev/null @@ -1,340 +0,0 @@ -./opencs/view -############# - -doc ---- - .. autodoxygenfile:: view/doc/adjusterwidget.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/filedialog.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/filewidget.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/globaldebugprofilemenu.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/loader.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/newgame.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/operation.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/operations.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/runlogsubview.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/sizehint.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/startup.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/subviewfactory.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/subviewfactoryimp.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/subview.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/view.hpp - :project: opencs - - .. autodoxygenfile:: view/doc/viewmanager.hpp - :project: opencs - -filter ------- - .. autodoxygenfile:: view/filter/editwidget.hpp - :project: opencs - - .. autodoxygenfile:: view/filter/filterbox.hpp - :project: opencs - - .. autodoxygenfile:: view/filter/recordfilterbox.hpp - :project: opencs - -prefs ------ - .. autodoxygenfile:: view/prefs/dialogue.hpp - :project: opencs - - .. autodoxygenfile:: view/prefs/keybindingpage.hpp - :project: opencs - - .. autodoxygenfile:: view/prefs/pagebase.hpp - :project: opencs - - .. autodoxygenfile:: view/prefs/page.hpp - :project: opencs - -render ------- - .. autodoxygenfile:: view/render/cameracontroller.hpp - :project: opencs - - .. autodoxygenfile:: view/render/cellarrow.hpp - :project: opencs - - .. autodoxygenfile:: view/render/cellborder.hpp - :project: opencs - - .. autodoxygenfile:: view/render/cell.hpp - :project: opencs - - .. autodoxygenfile:: view/render/cellmarker.hpp - :project: opencs - - .. autodoxygenfile:: view/render/cellwater.hpp - :project: opencs - - .. autodoxygenfile:: view/render/editmode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/instancemode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/instancemovemode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/instanceselectionmode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/lightingbright.hpp - :project: opencs - - .. autodoxygenfile:: view/render/lightingday.hpp - :project: opencs - - .. autodoxygenfile:: view/render/lighting.hpp - :project: opencs - - .. autodoxygenfile:: view/render/lightingnight.hpp - :project: opencs - - .. autodoxygenfile:: view/render/mask.hpp - :project: opencs - - .. autodoxygenfile:: view/render/object.hpp - :project: opencs - - .. autodoxygenfile:: view/render/orbitcameramode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/pagedworldspacewidget.hpp - :project: opencs - - .. autodoxygenfile:: view/render/pathgrid.hpp - :project: opencs - - .. autodoxygenfile:: view/render/pathgridmode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/pathgridselectionmode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/previewwidget.hpp - :project: opencs - - .. autodoxygenfile:: view/render/scenewidget.hpp - :project: opencs - - .. autodoxygenfile:: view/render/selectionmode.hpp - :project: opencs - - .. autodoxygenfile:: view/render/tagbase.hpp - :project: opencs - - .. autodoxygenfile:: view/render/terrainstorage.hpp - :project: opencs - - .. autodoxygenfile:: view/render/unpagedworldspacewidget.hpp - :project: opencs - - .. autodoxygenfile:: view/render/worldspacewidget.hpp - :project: opencs - -tools ------ - .. autodoxygenfile:: view/tools/merge.hpp - :project: opencs - - .. autodoxygenfile:: view/tools/reportsubview.hpp - :project: opencs - - .. autodoxygenfile:: view/tools/reporttable.hpp - :project: opencs - - .. autodoxygenfile:: view/tools/searchbox.hpp - :project: opencs - - .. autodoxygenfile:: view/tools/searchsubview.hpp - :project: opencs - - .. autodoxygenfile:: view/tools/subviews.hpp - :project: opencs - -widget ------- - .. autodoxygenfile:: view/widget/coloreditor.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/colorpickerpopup.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/completerpopup.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/droplineedit.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/modebutton.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/pushbutton.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/scenetoolbar.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/scenetool.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/scenetoolmode.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/scenetoolrun.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/scenetooltoggle2.hpp - :project: opencs - - .. autodoxygenfile:: view/widget/scenetooltoggle.hpp - :project: opencs - -world ------ - .. autodoxygenfile:: view/world/cellcreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/colordelegate.hpp - :project: opencs - - .. autodoxygenfile:: view/world/creator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/datadisplaydelegate.hpp - :project: opencs - - .. autodoxygenfile:: view/world/dialoguecreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/dialoguespinbox.hpp - :project: opencs - - .. autodoxygenfile:: view/world/dialoguesubview.hpp - :project: opencs - - .. autodoxygenfile:: view/world/dragdroputils.hpp - :project: opencs - - .. autodoxygenfile:: view/world/dragrecordtable.hpp - :project: opencs - - .. autodoxygenfile:: view/world/enumdelegate.hpp - :project: opencs - - .. autodoxygenfile:: view/world/extendedcommandconfigurator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/genericcreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/globalcreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/idcompletiondelegate.hpp - :project: opencs - - .. autodoxygenfile:: view/world/idtypedelegate.hpp - :project: opencs - - .. autodoxygenfile:: view/world/idvalidator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/infocreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/nestedtable.hpp - :project: opencs - - .. autodoxygenfile:: view/world/pathgridcreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/previewsubview.hpp - :project: opencs - - .. autodoxygenfile:: view/world/recordbuttonbar.hpp - :project: opencs - - .. autodoxygenfile:: view/world/recordstatusdelegate.hpp - :project: opencs - - .. autodoxygenfile:: view/world/referenceablecreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/referencecreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/regionmap.hpp - :project: opencs - - .. autodoxygenfile:: view/world/regionmapsubview.hpp - :project: opencs - - .. autodoxygenfile:: view/world/scenesubview.hpp - :project: opencs - - .. autodoxygenfile:: view/world/scriptedit.hpp - :project: opencs - - .. autodoxygenfile:: view/world/scripterrortable.hpp - :project: opencs - - .. autodoxygenfile:: view/world/scripthighlighter.hpp - :project: opencs - - .. autodoxygenfile:: view/world/scriptsubview.hpp - :project: opencs - - .. autodoxygenfile:: view/world/startscriptcreator.hpp - :project: opencs - - .. autodoxygenfile:: view/world/subviews.hpp - :project: opencs - - .. autodoxygenfile:: view/world/tablebottombox.hpp - :project: opencs - - .. autodoxygenfile:: view/world/tableeditidaction.hpp - :project: opencs - - .. autodoxygenfile:: view/world/table.hpp - :project: opencs - - .. autodoxygenfile:: view/world/tablesubview.hpp - :project: opencs - - .. autodoxygenfile:: view/world/util.hpp - :project: opencs - - .. autodoxygenfile:: view/world/vartypedelegate.hpp - :project: opencs diff --git a/docs/source/source/openmw/index.rst b/docs/source/source/openmw/index.rst deleted file mode 100644 index 5367995de..000000000 --- a/docs/source/source/openmw/index.rst +++ /dev/null @@ -1,24 +0,0 @@ -OpenMW Source Documentation -########################### - -.. toctree:: - :maxdepth: 2 - - mwbase - mwclass - mwdialogue - mwgui - mwinput - mwmechanics - mwphysics - mwrender - mwscript - mwsound - mwstate - mwworld - -.. autodoxygenfile:: engine.hpp - :project: openmw - -.. autodoxygenfile:: doc.hpp - :project: openmw \ No newline at end of file diff --git a/docs/source/source/openmw/mwbase.rst b/docs/source/source/openmw/mwbase.rst deleted file mode 100644 index 8fd7ffc1e..000000000 --- a/docs/source/source/openmw/mwbase.rst +++ /dev/null @@ -1,32 +0,0 @@ -./mwbase -######## - -.. autodoxygenfile:: mwbase/dialoguemanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/environment.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/inputmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/journal.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/mechanicsmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/scriptmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/soundmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/statemanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/windowmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwbase/world.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwclass.rst b/docs/source/source/openmw/mwclass.rst deleted file mode 100644 index 3365d2582..000000000 --- a/docs/source/source/openmw/mwclass.rst +++ /dev/null @@ -1,68 +0,0 @@ -./mwclass -######### - -.. autodoxygenfile:: mwclass/activator.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/actor.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/apparatus.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/armor.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/bodypart.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/book.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/classes.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/clothing.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/container.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/creature.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/creaturelevlist.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/ingredient.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/itemlevlist.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/light.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/lockpick.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/misc.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/npc.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/potion.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/probe.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/repair.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/static.hpp - :project: openmw - -.. autodoxygenfile:: mwclass/weapon.hpp - :project: openmw \ No newline at end of file diff --git a/docs/source/source/openmw/mwdialogue.rst b/docs/source/source/openmw/mwdialogue.rst deleted file mode 100644 index 1f3522f2c..000000000 --- a/docs/source/source/openmw/mwdialogue.rst +++ /dev/null @@ -1,32 +0,0 @@ -./mwdialogue -############ - -.. autodoxygenfile:: mwdialogue/dialoguemanagerimp.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/filter.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/hypertextparser.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/journalentry.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/journalimp.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/keywordsearch.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/quest.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/scripttest.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/selectwrapper.hpp - :project: openmw - -.. autodoxygenfile:: mwdialogue/topic.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwgui.rst b/docs/source/source/openmw/mwgui.rst deleted file mode 100644 index 0e3726832..000000000 --- a/docs/source/source/openmw/mwgui.rst +++ /dev/null @@ -1,227 +0,0 @@ -./mwgui -####### - -.. autodoxygenfile:: mwgui/alchemywindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/backgroundimage.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/birth.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/bookpage.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/bookwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/charactercreation.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/class.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/companionitemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/companionwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/confirmationdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/console.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/container.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/containeritemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/controllers.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/countdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/cursor.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/debugwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/dialogue.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/draganddrop.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/enchantingdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/exposedwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/formatting.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/hud.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/inventoryitemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/inventorywindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/itemchargeview.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/itemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/itemselection.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/itemview.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/itemwidget.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/jailscreen.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/journalbooks.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/journalviewmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/journalwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/layout.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/levelupdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/loadingscreen.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/mainmenu.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/mapwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/merchantrepair.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/messagebox.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/mode.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/pickpocketitemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/quickkeysmenu.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/race.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/recharge.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/referenceinterface.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/repair.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/review.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/savegamedialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/screenfader.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/scrollwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/settingswindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/sortfilteritemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/soulgemdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/spellbuyingwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/spellcreationdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/spellicons.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/spellmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/spellview.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/spellwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/statswindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/textinput.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/timeadvancer.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/tooltips.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/tradeitemmodel.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/tradewindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/trainingwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/travelwindow.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/videowidget.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/waitdialog.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/widgets.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/windowbase.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/windowmanagerimp.hpp - :project: openmw - -.. autodoxygenfile:: mwgui/windowpinnablebase.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwinput.rst b/docs/source/source/openmw/mwinput.rst deleted file mode 100644 index b24d8dfdb..000000000 --- a/docs/source/source/openmw/mwinput.rst +++ /dev/null @@ -1,5 +0,0 @@ -./mwinput -######### - -.. autodoxygenfile:: mwinput/inputmanagerimp.hpp - :project: openmw \ No newline at end of file diff --git a/docs/source/source/openmw/mwmechanics.rst b/docs/source/source/openmw/mwmechanics.rst deleted file mode 100644 index 3427b712a..000000000 --- a/docs/source/source/openmw/mwmechanics.rst +++ /dev/null @@ -1,137 +0,0 @@ -./mwmechanics -############# - -.. autodoxygenfile:: mwmechanics/activespells.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/actor.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/actors.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/actorutil.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aiactivate.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aiavoiddoor.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aicombataction.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aicombat.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aiescort.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aiface.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aifollow.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aipackage.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aipursue.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aisequence.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aistate.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aitravel.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/aiwander.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/alchemy.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/autocalcspell.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/character.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/combat.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/coordinateconverter.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/creaturestats.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/difficultyscaling.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/disease.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/drawstate.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/enchanting.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/levelledlist.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/magiceffects.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/mechanicsmanagerimp.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/movement.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/npcstats.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/objects.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/obstacle.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/pathfinding.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/pathgrid.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/pickpocket.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/repair.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/security.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/spellcasting.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/spells.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/stat.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/steering.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/summoning.hpp - :project: openmw - -.. autodoxygenfile:: mwmechanics/trading.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwphysics.rst b/docs/source/source/openmw/mwphysics.rst deleted file mode 100644 index 6eebab4d9..000000000 --- a/docs/source/source/openmw/mwphysics.rst +++ /dev/null @@ -1,15 +0,0 @@ -./mwphysics -########### - -.. autodoxygenfile:: mwphysics/actor.hpp - :project: openmw - -.. autodoxygenfile:: mwphysics/collisiontype.hpp - :project: openmw - -.. autodoxygenfile:: mwphysics/convert.hpp - :project: openmw - -.. autodoxygenfile:: mwphysics/physicssystem.hpp - :project: openmw - diff --git a/docs/source/source/openmw/mwrender.rst b/docs/source/source/openmw/mwrender.rst deleted file mode 100644 index d284f6586..000000000 --- a/docs/source/source/openmw/mwrender.rst +++ /dev/null @@ -1,77 +0,0 @@ -./mwrender -########## - -.. autodoxygenfile:: mwrender/actoranimation.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/animation.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/bulletdebugdraw.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/camera.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/cell.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/characterpreview.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/creatureanimation.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/effectmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/globalmap.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/localmap.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/npcanimation.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/objects.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/pathgrid.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/renderbin.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/renderinginterface.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/renderingmanager.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/rendermode.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/ripplesimulation.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/rotatecontroller.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/sky.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/terrainstorage.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/util.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/vismask.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/water.hpp - :project: openmw - -.. autodoxygenfile:: mwrender/weaponanimation.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwscript.rst b/docs/source/source/openmw/mwscript.rst deleted file mode 100644 index 8db8f40e2..000000000 --- a/docs/source/source/openmw/mwscript.rst +++ /dev/null @@ -1,65 +0,0 @@ -./mwscript -########## - -.. autodoxygenfile:: mwscript/aiextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/animationextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/cellextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/compilercontext.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/consoleextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/containerextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/controlextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/dialogueextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/extensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/globalscripts.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/guiextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/interpretercontext.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/locals.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/miscextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/ref.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/scriptmanagerimp.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/skyextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/soundextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/statsextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/transformationextensions.hpp - :project: openmw - -.. autodoxygenfile:: mwscript/userextensions.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwsound.rst b/docs/source/source/openmw/mwsound.rst deleted file mode 100644 index d4fcb0e6b..000000000 --- a/docs/source/source/openmw/mwsound.rst +++ /dev/null @@ -1,29 +0,0 @@ -./mwsound -######### - -.. autodoxygenfile:: mwsound/ffmpeg_decoder.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/loudness.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/movieaudiofactory.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/openal_output.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/sound_buffer.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/sound_decoder.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/sound.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/soundmanagerimp.hpp - :project: openmw - -.. autodoxygenfile:: mwsound/sound_output.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwstate.rst b/docs/source/source/openmw/mwstate.rst deleted file mode 100644 index 2618c6ff0..000000000 --- a/docs/source/source/openmw/mwstate.rst +++ /dev/null @@ -1,11 +0,0 @@ -./mwstate -######### - -.. autodoxygenfile:: mwstate/character.hpp - :project: openmw - -.. autodoxygenfile:: mwstate/charactermanager.hpp - :project: openmw - -.. autodoxygenfile:: mwstate/statemanagerimp.hpp - :project: openmw diff --git a/docs/source/source/openmw/mwworld.rst b/docs/source/source/openmw/mwworld.rst deleted file mode 100644 index 21026b3e2..000000000 --- a/docs/source/source/openmw/mwworld.rst +++ /dev/null @@ -1,132 +0,0 @@ -./mwworld -######### - -.. autodoxygenfile:: mwworld/actionalchemy.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionapply.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actiondoor.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actioneat.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionequip.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/action.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionopen.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionread.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionrepair.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionsoulgem.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actiontake.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actiontalk.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actionteleport.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/actiontrap.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/cellpreloader.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/cellref.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/cellreflist.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/cells.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/cellstore.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/cellvisitors.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/class.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/containerstore.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/contentloader.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/customdata.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/esmloader.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/esmstore.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/failedaction.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/globals.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/inventorystore.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/livecellref.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/localscripts.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/manualref.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/nullaction.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/player.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/projectilemanager.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/ptr.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/recordcmp.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/refdata.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/scene.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/store.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/timestamp.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/weather.hpp - :project: openmw - -.. autodoxygenfile:: mwworld/worldimp.hpp - :project: openmw - diff --git a/docs/source/tutorial-style-guide.txt b/docs/source/tutorial-style-guide.txt index b37992057..d640d266c 100644 --- a/docs/source/tutorial-style-guide.txt +++ b/docs/source/tutorial-style-guide.txt @@ -7,7 +7,8 @@ Please contact Ravenwing about any questions relating to this guide. Foreword -------- -I shall try to be as brief as possible without sacrificing clarity, just as you should be when writing documentation. The SCOPE of this guide is limited to all non-source code documentation. +I shall try to be as brief as possible without sacrificing clarity, just as you should be when writing documentation. +The SCOPE of this guide is limited to all non-source code documentation. References ---------- @@ -20,27 +21,43 @@ Language -------- British English -Sorry, I'm American and I'll probably have a million relapses, but this seems to have been decided and uniformity is key! +Sorry, I'm American and I'll probably have a million relapses, +but this seems to have been decided and uniformity is key! Text Wrapping ------------- -DO NOT manually decide where each line ends! Enable text wrapping in your text editor! (usually under View) Even Notepad allows automatic text wrapping, so use it. If you program, you may be used to keeping your lines under 80 characters wide and manually pressing enter, but don't. This is because we are writing mostly prose. When someone has to come in and edit portions of text that puts all this out of alignment, it takes FOREVER to readjust everything. Plus, indentation is very important in ReST, and you may forget to indent properly. +After discussing the various benefits of manual and automatic linefeeds, +we've come to the conclusion that we should use semantic linefeeds with a hard max at 120 characters. +Basically this boils down manually inserting a line break where it makes sense within the phrasing. +I prefer to keep it at commas and periods because those are universal places people pause, +even while reading in their head. +It may look a little funny in plain text, but it is readable, +and none of this makes a difference in the final documentation. + +The reason this makes the most sense is GitHub won't text wrap automatically in RST documents, +and it also compares files based on lines. +This means you're less likely to run into conflicts and simply makes it easier to view changes. Indentations ------------ -This isn't as important, especially since Sphinx converts tabs to spaces, but I find it much easier to keep large blocks of things aligned if you just tab. If you can edit your tab width, please set it to 4 spaces. +This isn't as important, especially since Sphinx converts tabs to spaces, +but I find it much easier to keep large blocks of things aligned if you just tab. +If you can edit your tab width, please set it to 4 spaces. Spaces ------ -Use only one space after each sentence. Some people were taught two spaces, but this is a carry-over from typewriters. Even though your text editor is probably using monospaced characters like a typewriter, the formats Sphinx is converting into will make all the adjustments they need to be beautifully legible. +Use only one space after each sentence. Some people were taught two spaces, but this is a carry-over from typewriters. +Even though your text editor is probably using monospaced characters like a typewriter, +the formats Sphinx is converting into will make all the adjustments they need to be beautifully legible. Commas ------ -Oxford comma. Use it. I know this goes against using British English, but this is technical writing. You cannot assume our audience will know from context if the last two items in a list are grouped or not. +Oxford comma. Use it. I know this goes against using British English, but this is technical writing. +You cannot assume our audience will know from context if the last two items in a list are grouped or not. I also prefer parentheticals to commas around gerund phrases. Files and Extensions diff --git a/extern/oics/ICSInputControlSystem.cpp b/extern/oics/ICSInputControlSystem.cpp index a8aedfd2e..8bb9c4638 100644 --- a/extern/oics/ICSInputControlSystem.cpp +++ b/extern/oics/ICSInputControlSystem.cpp @@ -28,6 +28,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace ICS { + const float ICS_MAX = std::numeric_limits::max(); + InputControlSystem::InputControlSystem(std::string file, bool active , DetectingBindingListener* detectingBindingListener , InputControlSystemLog* log, size_t channelCount) diff --git a/extern/oics/ICSInputControlSystem.h b/extern/oics/ICSInputControlSystem.h index a82a11d75..0e8e6ecad 100644 --- a/extern/oics/ICSInputControlSystem.h +++ b/extern/oics/ICSInputControlSystem.h @@ -32,8 +32,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "ICSControl.h" #include "ICSChannel.h" -#include "boost/lexical_cast.hpp" - #define ICS_LOG(text) if(mLog) mLog->logMessage( ("ICS: " + std::string(text)).c_str() ); #define ICS_MAX_JOYSTICK_AXIS 16 #define ICS_MOUSE_BINDING_MARGIN 30 @@ -122,6 +120,8 @@ namespace ICS bool isMouseButtonBound(unsigned int button) const; void addJoystickAxisBinding(Control* control, int deviceID, int axis, Control::ControlChangingDirection direction); void addJoystickButtonBinding(Control* control, int deviceID, unsigned int button, Control::ControlChangingDirection direction); + bool isJoystickButtonBound(int deviceID, unsigned int button) const; + bool isJoystickAxisBound(int deviceID, unsigned int axis) const; void removeKeyBinding(SDL_Scancode key); void removeMouseAxisBinding(NamedAxis axis); void removeMouseButtonBinding(unsigned int button); @@ -236,7 +236,7 @@ namespace ICS }; - static const float ICS_MAX = std::numeric_limits::max(); + extern const float ICS_MAX; } diff --git a/extern/oics/ICSInputControlSystem_joystick.cpp b/extern/oics/ICSInputControlSystem_joystick.cpp index ab219d074..ed6e2f664 100644 --- a/extern/oics/ICSInputControlSystem_joystick.cpp +++ b/extern/oics/ICSInputControlSystem_joystick.cpp @@ -78,6 +78,9 @@ namespace ICS // add bindings void InputControlSystem::addJoystickAxisBinding(Control* control, int deviceID, int axis, Control::ControlChangingDirection direction) { + if (std::find(mJoystickIDList.begin(), mJoystickIDList.end(), deviceID) == mJoystickIDList.end()) + mJoystickIDList.push_back(deviceID); + ICS_LOG("\tAdding AxisBinder [axis=" + ToString(axis) + ", deviceID=" + ToString(deviceID) + ", direction=" @@ -93,6 +96,9 @@ namespace ICS void InputControlSystem::addJoystickButtonBinding(Control* control, int deviceID, unsigned int button, Control::ControlChangingDirection direction) { + if (std::find(mJoystickIDList.begin(), mJoystickIDList.end(), deviceID) == mJoystickIDList.end()) + mJoystickIDList.push_back(deviceID); // Hack: add the device to the list so bindings are saved in save() even when joystick is not connected + ICS_LOG("\tAdding JoystickButtonBinder [button=" + ToString(button) + ", deviceID=" + ToString(deviceID) + ", direction=" @@ -104,6 +110,24 @@ namespace ICS mControlsJoystickButtonBinderMap[deviceID][button] = controlJoystickButtonBinderItem; } + bool InputControlSystem::isJoystickButtonBound(int deviceID, unsigned int button) const + { + JoystickButtonBinderMapType::const_iterator found = mControlsJoystickButtonBinderMap.find(deviceID); + if (found == mControlsJoystickButtonBinderMap.end()) + return false; + + return (found->second.find(button) != found->second.end()); + } + + bool InputControlSystem::isJoystickAxisBound(int deviceID, unsigned int axis) const + { + JoystickAxisBinderMapType::const_iterator found = mControlsJoystickAxisBinderMap.find(deviceID); + if (found == mControlsJoystickAxisBinderMap.end()) + return false; + + return (found->second.find(axis) != found->second.end()); + } + // get bindings int InputControlSystem::getJoystickAxisBinding(Control* control, int deviceID, ICS::Control::ControlChangingDirection direction) { diff --git a/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp b/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp index 096a17a64..ee6400177 100644 --- a/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp +++ b/extern/osg-ffmpeg-videoplayer/audiodecoder.cpp @@ -1,6 +1,8 @@ #include "audiodecoder.hpp" +#include #include +#include extern "C" { diff --git a/extern/osg-ffmpeg-videoplayer/audiodecoder.hpp b/extern/osg-ffmpeg-videoplayer/audiodecoder.hpp index a592b02d3..95644ea69 100644 --- a/extern/osg-ffmpeg-videoplayer/audiodecoder.hpp +++ b/extern/osg-ffmpeg-videoplayer/audiodecoder.hpp @@ -55,7 +55,7 @@ private: }; - std::auto_ptr mAudioResampler; + std::unique_ptr mAudioResampler; uint8_t *mDataBuf; uint8_t **mFrameData; diff --git a/extern/osg-ffmpeg-videoplayer/audiofactory.hpp b/extern/osg-ffmpeg-videoplayer/audiofactory.hpp index 06abd6a74..023d536e2 100644 --- a/extern/osg-ffmpeg-videoplayer/audiofactory.hpp +++ b/extern/osg-ffmpeg-videoplayer/audiofactory.hpp @@ -3,7 +3,6 @@ #include "audiodecoder.hpp" -#include namespace Video { @@ -11,7 +10,7 @@ namespace Video class MovieAudioFactory { public: - virtual boost::shared_ptr createDecoder(VideoState* videoState) = 0; + virtual std::shared_ptr createDecoder(VideoState* videoState) = 0; virtual ~MovieAudioFactory() {} }; diff --git a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp index 9ec815130..c6544de9c 100644 --- a/extern/osg-ffmpeg-videoplayer/videoplayer.cpp +++ b/extern/osg-ffmpeg-videoplayer/videoplayer.cpp @@ -27,7 +27,7 @@ void VideoPlayer::setAudioFactory(MovieAudioFactory *factory) mAudioFactory.reset(factory); } -void VideoPlayer::playVideo(boost::shared_ptr inputstream, const std::string& name) +void VideoPlayer::playVideo(std::shared_ptr inputstream, const std::string& name) { if(mState) close(); diff --git a/extern/osg-ffmpeg-videoplayer/videoplayer.hpp b/extern/osg-ffmpeg-videoplayer/videoplayer.hpp index c118ddb7f..97ef13032 100644 --- a/extern/osg-ffmpeg-videoplayer/videoplayer.hpp +++ b/extern/osg-ffmpeg-videoplayer/videoplayer.hpp @@ -10,8 +10,6 @@ #include -#include - namespace osg { class Texture2D; @@ -44,7 +42,7 @@ namespace Video /// Play the given video. If a video is already playing, the old video is closed first. /// @note The video will be unpaused by default. Use the pause() and play() methods to control pausing. /// @param name A name for the video stream - only used for logging purposes. - void playVideo (boost::shared_ptr inputstream, const std::string& name); + void playVideo (std::shared_ptr inputstream, const std::string& name); /// Get the current playback time position in the video, in seconds double getCurrentTime(); @@ -78,7 +76,7 @@ namespace Video private: VideoState* mState; - std::auto_ptr mAudioFactory; + std::unique_ptr mAudioFactory; }; } diff --git a/extern/osg-ffmpeg-videoplayer/videostate.cpp b/extern/osg-ffmpeg-videoplayer/videostate.cpp index 6779f2472..9fd209d56 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.cpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.cpp @@ -1,7 +1,8 @@ #include "videostate.hpp" +#include +#include #include -#include #include @@ -19,8 +20,6 @@ extern "C" #include #endif - #include - #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1) #define av_frame_alloc avcodec_alloc_frame #endif @@ -626,7 +625,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx) return 0; } -void VideoState::init(boost::shared_ptr inputstream, const std::string &name) +void VideoState::init(std::shared_ptr inputstream, const std::string &name) { int video_index = -1; int audio_index = -1; diff --git a/extern/osg-ffmpeg-videoplayer/videostate.hpp b/extern/osg-ffmpeg-videoplayer/videostate.hpp index 2f0e8f30a..e61f4feb7 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.hpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.hpp @@ -5,8 +5,6 @@ #include #include -#include - #include #include #include @@ -94,7 +92,7 @@ struct VideoState { void setAudioFactory(MovieAudioFactory* factory); - void init(boost::shared_ptr inputstream, const std::string& name); + void init(std::shared_ptr inputstream, const std::string& name); void deinit(); void setPaused(bool isPaused); @@ -127,11 +125,11 @@ struct VideoState { osg::ref_ptr mTexture; MovieAudioFactory* mAudioFactory; - boost::shared_ptr mAudioDecoder; + std::shared_ptr mAudioDecoder; ExternalClock mExternalClock; - boost::shared_ptr stream; + std::shared_ptr stream; AVFormatContext* format_ctx; int av_sync_type; @@ -152,8 +150,8 @@ struct VideoState { OpenThreads::Mutex pictq_mutex; OpenThreads::Condition pictq_cond; - std::auto_ptr parse_thread; - std::auto_ptr video_thread; + std::unique_ptr parse_thread; + std::unique_ptr video_thread; volatile bool mSeekRequested; uint64_t mSeekPos; diff --git a/files/mac/qt.conf b/files/mac/qt.conf new file mode 100644 index 000000000..64d729736 --- /dev/null +++ b/files/mac/qt.conf @@ -0,0 +1,2 @@ +[Paths] +Plugins = PlugIns diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 6592de56e..ed673c5d6 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -38,6 +38,7 @@ set(MYGUI_FILES openmw_hud.layout openmw_infobox.layout openmw_interactive_messagebox.layout + openmw_interactive_messagebox_notransp.layout openmw_inventory_window.layout openmw_journal.layout openmw_journal.skin.xml diff --git a/files/mygui/openmw_alchemy_window.layout b/files/mygui/openmw_alchemy_window.layout index ef8296980..8a1bf1347 100644 --- a/files/mygui/openmw_alchemy_window.layout +++ b/files/mygui/openmw_alchemy_window.layout @@ -6,12 +6,13 @@ - + - + + diff --git a/files/mygui/openmw_chargen_class.layout b/files/mygui/openmw_chargen_class.layout index 53a6a6642..d875fae22 100644 --- a/files/mygui/openmw_chargen_class.layout +++ b/files/mygui/openmw_chargen_class.layout @@ -27,16 +27,24 @@ - - - - - - - + + + + + + + + + + + + + + - - + + + diff --git a/files/mygui/openmw_chargen_class_description.layout b/files/mygui/openmw_chargen_class_description.layout index 3d341eee5..43b0518fd 100644 --- a/files/mygui/openmw_chargen_class_description.layout +++ b/files/mygui/openmw_chargen_class_description.layout @@ -1,7 +1,7 @@ - + diff --git a/files/mygui/openmw_chargen_create_class.layout b/files/mygui/openmw_chargen_create_class.layout index 5f0b02c1b..e2920c742 100644 --- a/files/mygui/openmw_chargen_create_class.layout +++ b/files/mygui/openmw_chargen_create_class.layout @@ -26,22 +26,31 @@ - - - - - - - - + + + + + + + + + + + + + + - - + + + + + diff --git a/files/mygui/openmw_chargen_race.layout b/files/mygui/openmw_chargen_race.layout index 58eb6f6f7..04bd9cc53 100644 --- a/files/mygui/openmw_chargen_race.layout +++ b/files/mygui/openmw_chargen_race.layout @@ -57,7 +57,7 @@ - + @@ -84,7 +84,7 @@ - + diff --git a/files/mygui/openmw_chargen_select_attribute.layout b/files/mygui/openmw_chargen_select_attribute.layout index a00577e41..0821d4a57 100644 --- a/files/mygui/openmw_chargen_select_attribute.layout +++ b/files/mygui/openmw_chargen_select_attribute.layout @@ -1,23 +1,23 @@ - - + + - + - - - - - - - - + + + + + + + + diff --git a/files/mygui/openmw_chargen_select_skill.layout b/files/mygui/openmw_chargen_select_skill.layout index b6e90b688..d1061882d 100644 --- a/files/mygui/openmw_chargen_select_skill.layout +++ b/files/mygui/openmw_chargen_select_skill.layout @@ -1,6 +1,6 @@ - + diff --git a/files/mygui/openmw_chargen_select_specialization.layout b/files/mygui/openmw_chargen_select_specialization.layout index 70c5fdca5..c4fe6c631 100644 --- a/files/mygui/openmw_chargen_select_specialization.layout +++ b/files/mygui/openmw_chargen_select_specialization.layout @@ -1,13 +1,13 @@ - + - + - + diff --git a/files/mygui/openmw_container_window.layout b/files/mygui/openmw_container_window.layout index 87651b0f2..6bb585e50 100644 --- a/files/mygui/openmw_container_window.layout +++ b/files/mygui/openmw_container_window.layout @@ -10,9 +10,7 @@ - - - + diff --git a/files/mygui/openmw_count_window.layout b/files/mygui/openmw_count_window.layout index a3234c405..520d49fa3 100644 --- a/files/mygui/openmw_count_window.layout +++ b/files/mygui/openmw_count_window.layout @@ -16,13 +16,15 @@ - - + + + - + + diff --git a/files/mygui/openmw_edit_effect.layout b/files/mygui/openmw_edit_effect.layout index 387c01231..376e87efa 100644 --- a/files/mygui/openmw_edit_effect.layout +++ b/files/mygui/openmw_edit_effect.layout @@ -1,7 +1,7 @@ - + diff --git a/files/mygui/openmw_edit_note.layout b/files/mygui/openmw_edit_note.layout index eb2a2789d..7039c719e 100644 --- a/files/mygui/openmw_edit_note.layout +++ b/files/mygui/openmw_edit_note.layout @@ -1,7 +1,7 @@ - + diff --git a/files/mygui/openmw_enchanting_dialog.layout b/files/mygui/openmw_enchanting_dialog.layout index 88e0ec247..6a08e6fd0 100644 --- a/files/mygui/openmw_enchanting_dialog.layout +++ b/files/mygui/openmw_enchanting_dialog.layout @@ -1,9 +1,10 @@ - + - + + @@ -23,7 +24,7 @@ - + @@ -35,7 +36,9 @@ - + + + @@ -49,7 +52,7 @@ - + @@ -92,32 +95,43 @@ + + + + + + + + + + + - + - + - + - - + + - + diff --git a/files/mygui/openmw_hud_box.skin.xml b/files/mygui/openmw_hud_box.skin.xml index 33199d6ae..e53493bb1 100644 --- a/files/mygui/openmw_hud_box.skin.xml +++ b/files/mygui/openmw_hud_box.skin.xml @@ -36,6 +36,18 @@ + + + + + + + + + + + + diff --git a/files/mygui/openmw_infobox.layout b/files/mygui/openmw_infobox.layout index ea9f78614..252a237cd 100644 --- a/files/mygui/openmw_infobox.layout +++ b/files/mygui/openmw_infobox.layout @@ -11,6 +11,6 @@ - + diff --git a/files/mygui/openmw_interactive_messagebox_notransp.layout b/files/mygui/openmw_interactive_messagebox_notransp.layout new file mode 100644 index 000000000..6b79b9417 --- /dev/null +++ b/files/mygui/openmw_interactive_messagebox_notransp.layout @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/files/mygui/openmw_inventory_window.layout b/files/mygui/openmw_inventory_window.layout index 09e5ed9c7..bb707fa0d 100644 --- a/files/mygui/openmw_inventory_window.layout +++ b/files/mygui/openmw_inventory_window.layout @@ -12,7 +12,7 @@ - + diff --git a/files/mygui/openmw_itemselection_dialog.layout b/files/mygui/openmw_itemselection_dialog.layout index 5ae30563a..b2337b669 100644 --- a/files/mygui/openmw_itemselection_dialog.layout +++ b/files/mygui/openmw_itemselection_dialog.layout @@ -1,6 +1,6 @@ - + diff --git a/files/mygui/openmw_journal.layout b/files/mygui/openmw_journal.layout index 9b530b379..1131b1bbc 100644 --- a/files/mygui/openmw_journal.layout +++ b/files/mygui/openmw_journal.layout @@ -3,6 +3,7 @@ + @@ -48,33 +49,33 @@ - - + + - + - + - + - + - + @@ -87,7 +88,7 @@ - + diff --git a/files/mygui/openmw_levelup_dialog.layout b/files/mygui/openmw_levelup_dialog.layout index ad0004934..fc11ddfd7 100644 --- a/files/mygui/openmw_levelup_dialog.layout +++ b/files/mygui/openmw_levelup_dialog.layout @@ -2,7 +2,7 @@ - + @@ -22,25 +22,25 @@ - + - + - - - - - - - - + + + + + + + + - + @@ -54,7 +54,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/files/mygui/openmw_list.skin.xml b/files/mygui/openmw_list.skin.xml index 111d3bf30..5b6f14dd5 100644 --- a/files/mygui/openmw_list.skin.xml +++ b/files/mygui/openmw_list.skin.xml @@ -127,7 +127,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -150,6 +150,19 @@ + + + + + + + + + + + + + diff --git a/files/mygui/openmw_magicselection_dialog.layout b/files/mygui/openmw_magicselection_dialog.layout index 5301ecfe9..027250d7a 100644 --- a/files/mygui/openmw_magicselection_dialog.layout +++ b/files/mygui/openmw_magicselection_dialog.layout @@ -1,6 +1,6 @@ - + diff --git a/files/mygui/openmw_merchantrepair.layout b/files/mygui/openmw_merchantrepair.layout index de5d0e316..fc85dc7ae 100644 --- a/files/mygui/openmw_merchantrepair.layout +++ b/files/mygui/openmw_merchantrepair.layout @@ -4,25 +4,25 @@ - + - + - + - + - + diff --git a/files/mygui/openmw_persuasion_dialog.layout b/files/mygui/openmw_persuasion_dialog.layout index d9a673ec2..c66f9d0ad 100644 --- a/files/mygui/openmw_persuasion_dialog.layout +++ b/files/mygui/openmw_persuasion_dialog.layout @@ -1,7 +1,7 @@ - + diff --git a/files/mygui/openmw_quickkeys_menu_assign.layout b/files/mygui/openmw_quickkeys_menu_assign.layout index 4bbd9f1fa..2c80fefcd 100644 --- a/files/mygui/openmw_quickkeys_menu_assign.layout +++ b/files/mygui/openmw_quickkeys_menu_assign.layout @@ -1,6 +1,6 @@ - + diff --git a/files/mygui/openmw_recharge_dialog.layout b/files/mygui/openmw_recharge_dialog.layout index 9301bec92..d620aadab 100644 --- a/files/mygui/openmw_recharge_dialog.layout +++ b/files/mygui/openmw_recharge_dialog.layout @@ -1,22 +1,12 @@ - + - - - - - - - - - - - - + + @@ -26,14 +16,25 @@ - - - - - - + + + + + + + + + + + + + + + + + + - diff --git a/files/mygui/openmw_repair.layout b/files/mygui/openmw_repair.layout index 9a349c56b..340711bb1 100644 --- a/files/mygui/openmw_repair.layout +++ b/files/mygui/openmw_repair.layout @@ -1,26 +1,13 @@ - + - - - - - - - - - - - - - - - - + + + @@ -29,14 +16,31 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/files/mygui/openmw_resources.xml b/files/mygui/openmw_resources.xml index 662d78ab7..811fa4f7f 100644 --- a/files/mygui/openmw_resources.xml +++ b/files/mygui/openmw_resources.xml @@ -68,11 +68,13 @@ - + + - + + @@ -104,7 +106,7 @@ - + diff --git a/files/mygui/openmw_scroll.skin.xml b/files/mygui/openmw_scroll.skin.xml index b0b9dca17..415c2479a 100644 --- a/files/mygui/openmw_scroll.skin.xml +++ b/files/mygui/openmw_scroll.skin.xml @@ -4,12 +4,12 @@ - + - + diff --git a/files/mygui/openmw_spell_buying_window.layout b/files/mygui/openmw_spell_buying_window.layout index 73fb6e869..3481575de 100644 --- a/files/mygui/openmw_spell_buying_window.layout +++ b/files/mygui/openmw_spell_buying_window.layout @@ -1,28 +1,28 @@ - + - + - + - - + + - + - + diff --git a/files/mygui/openmw_stats_window.layout b/files/mygui/openmw_stats_window.layout index d9860ae20..098b3c2d8 100644 --- a/files/mygui/openmw_stats_window.layout +++ b/files/mygui/openmw_stats_window.layout @@ -87,12 +87,12 @@ - + - + diff --git a/files/mygui/openmw_text.skin.xml b/files/mygui/openmw_text.skin.xml index e442e37ee..163b9d134 100644 --- a/files/mygui/openmw_text.skin.xml +++ b/files/mygui/openmw_text.skin.xml @@ -139,24 +139,24 @@ color_misc=0,205,205 # ???? - + - + - + - + diff --git a/files/mygui/openmw_tooltips.layout b/files/mygui/openmw_tooltips.layout index 6d4421702..a7eeabfa5 100644 --- a/files/mygui/openmw_tooltips.layout +++ b/files/mygui/openmw_tooltips.layout @@ -18,27 +18,56 @@ - + - + - + - - + + - + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + @@ -46,15 +75,16 @@ - + - + + - + @@ -68,7 +98,7 @@ - + @@ -84,9 +114,9 @@ - + - + @@ -97,7 +127,7 @@ - + @@ -105,20 +135,21 @@ - + - + + - + - + @@ -126,9 +157,9 @@ - + - + @@ -136,30 +167,35 @@ - + - + - + + + + - + + + - + @@ -173,9 +209,9 @@ - + - + @@ -184,35 +220,41 @@ - + - + - + + + + - - + + + + + - - - + + + @@ -233,9 +275,9 @@ - + - + @@ -244,13 +286,13 @@ - + - + @@ -258,7 +300,7 @@ - + diff --git a/files/mygui/openmw_travel_window.layout b/files/mygui/openmw_travel_window.layout index 2d6b1324a..7dd9df4eb 100644 --- a/files/mygui/openmw_travel_window.layout +++ b/files/mygui/openmw_travel_window.layout @@ -1,29 +1,29 @@ - + - + - - - + + + - - + + - + - + diff --git a/files/mygui/openmw_windows.skin.xml b/files/mygui/openmw_windows.skin.xml index 00e6f9148..a272ae84a 100644 --- a/files/mygui/openmw_windows.skin.xml +++ b/files/mygui/openmw_windows.skin.xml @@ -158,13 +158,20 @@ - + + + + + + + + diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 55f550d5a..a0460326b 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -73,9 +73,15 @@ preload cell cache max = 20 # How long to keep preloaded cells in cache after they're no longer referenced/required (in seconds) preload cell expiry delay = 5 +# The predicted position of the player N seconds in the future will be used for preloading cells and distant terrain +prediction time = 1 + # How long to keep models/textures/collision shapes in cache after they're no longer referenced/required (in seconds) cache expiry delay = 5 +# The count of pointers, that will be saved for a faster search by object ID. +pointers cache size = 40 + [Terrain] # If true, use paging and LOD algorithms to display the entire terrain. If false, only display terrain of the loaded cells @@ -107,6 +113,9 @@ local map widget size = 512 # may result in longer loading times. local map cell distance = 1 +# If true, map in world mode, otherwise in local mode +global = false + [GUI] # Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger). @@ -146,6 +155,15 @@ crosshair = true # no color, 1 is tool tip only, 2 is crosshair only, and 3 is both). show owned = 0 +# Show damage bonus of arrow and bolts. +show projectile damage = false + +# Show additional melee weapon info: reach and attack speed +show melee info = false + +# Show success probability in self-enchant dialog +show enchant chance = false + # Always use the best mode of attack: e.g. chop, slash or thrust. best attack = false @@ -162,6 +180,9 @@ prevent merchant equipping = false # or the player. Otherwise they wait for the enemies or the player to do an attack first. followers attack on sight = false +# Can loot non-fighting actors during death animation +can loot during death animation = true + [General] # Anisotropy reduces distortion in textures at low angles (e.g. 0 to 16). @@ -365,18 +386,24 @@ stats x = 0.0 stats y = 0.0 stats w = 0.375 stats h = 0.4275 +# Stats window pin status +stats pin = false # Spells window displaying powers, spells, and magical items. spells x = 0.625 spells y = 0.5725 spells w = 0.375 spells h = 0.4275 +# Spells window pin status +spells pin = false # Local and world map window. map x = 0.625 map y = 0.0 map w = 0.375 map h = 0.5725 +# Map window pin status +map pin = false # Dialog window for talking with NPCs. dialogue x = 0.095 @@ -401,6 +428,8 @@ inventory x = 0.0 inventory y = 0.4275 inventory w = 0.6225 inventory h = 0.5725 +# Inventory window pin status +inventory pin = false # Player inventory window when searching a container. inventory container x = 0.0 diff --git a/files/ui/mainwindow.ui b/files/ui/mainwindow.ui index a9e493926..45578ef9e 100644 --- a/files/ui/mainwindow.ui +++ b/files/ui/mainwindow.ui @@ -7,13 +7,13 @@ 0 0 635 - 575 + 565 635 - 535 + 565 @@ -57,6 +57,18 @@ + + 0 + + + 0 + + + 0 + + + 0 + diff --git a/files/ui/settingspage.ui b/files/ui/settingspage.ui index 7f5e4a7de..f4f41f839 100644 --- a/files/ui/settingspage.ui +++ b/files/ui/settingspage.ui @@ -17,20 +17,10 @@ - General + Morrowind Content Language - - - <html><head/><body><p>The language of the original Morrowind installation files (used for the character encoding)</p></body></html> - - - Morrowind content language: - - - - @@ -40,6 +30,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -50,7 +53,7 @@ - + Qt::Horizontal @@ -112,7 +115,7 @@ - + Qt::Horizontal @@ -131,15 +134,18 @@ - - - - 4 - - - + + + + 4 + + + false + + + diff --git a/files/ui/wizard/methodselectionpage.ui b/files/ui/wizard/methodselectionpage.ui index 531d093af..4d4d66bad 100644 --- a/files/ui/wizard/methodselectionpage.ui +++ b/files/ui/wizard/methodselectionpage.ui @@ -17,16 +17,16 @@ Select Installation Method - Select how OpenMW should get the required Morrowind installation files. + <html><head/><body><p>Select how you would like to install <i>The Elder Scrolls III: Morrowind</i>.</p></body></html> - + font-weight:bold; - Install Morrowind to a new location + Retail CD/DVD true @@ -34,7 +34,7 @@ - + @@ -72,14 +72,14 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - newLocationRadioButton + retailDiscRadioButton - + - Install Morrowind from a retail disk to a new location for OpenMW to use. + Install from a retail disc to a new location. true @@ -94,7 +94,7 @@ font-weight:bold - Select an existing Morrowind installation + Existing Installation @@ -138,7 +138,7 @@ - Select an existing Morrowind installation for OpenMW to use. + Select an existing installation. true